Skip to content

Add Update URI: to plugin.php header metadata #27

@Herm71

Description

@Herm71

Update URI

WordPress 5.8 introduced Update URI: in the plugin header.

Per the WordPress Dev note:

This allows third-party plugins to avoid accidentally being overwritten with an update of a plugin of a similar name from the WordPress.org Plugin Directory.

Add any url here to prevent the plugin from accidentally being overwritten from WordPress.org.

  • e.g., * Update URI: https://ucsc.edu

And we can remove the following function from plugin.php:

if ( ! function_exists( 'ucsc_custom_functionality_hidden' ) ) {
	/**
	* Don't Update Plugin
	*
	* @since 1.0.0
	*
	* This prevents you being prompted to update if there's a public plugin
	* with the same name.
	*
	* @author Mark Jaquith
	* @link http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
	*
	* @param array  $r, request arguments
	* @param string $url, request url
	* @return array request arguments
	*/

	function ucsc_custom_functionality_hidden( $r, $url ) {
		if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) ) {
			return $r; // Not a plugin update request. Bail immediately.
		}
		$plugins = unserialize( $r['body']['plugins'] );
		unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );
		unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] );
		$r['body']['plugins'] = serialize( $plugins );
		return $r;
	}
}

add_filter( 'http_request_args', 'ucsc_custom_functionality_hidden', 5, 2 );

Metadata

Metadata

Assignees

Labels

changeChange to an existing but not broken feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions