Giter Club home page Giter Club logo

misha-update-checker's People

Contributors

alexivashchenko avatar rudrastyh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

misha-update-checker's Issues

To many requests to the backend

Hello,

I've encountered an issue with my custom update script in a WordPress plugin when caching is disabled. The problem arises irrespective of which admin page is accessed, resulting in multiple unnecessary remote requests.

The relevant part of my __construct() function looks like this:

public function __construct() { $this->cache_allowed = true; }
Despite this setting, the update function $this->request() is being called multiple times (around 9 times) during a single admin page load. This behavior seems to occur on every admin page load, leading to a significant number of redundant requests to my backend.

I have calculated how the many times the function is called:
int(1) int(2) int(3) int(4) int(5) int(6) int(7) int(8) int(9)

This issue appears to be related to the number of plugins installed on the site (currently, I have only three plugins, including the one with this update functionality).

I am seeking advice or solutions to optimize the update check mechanism to prevent these excessive requests. Any insights or recommendations would be greatly appreciated.

Thank you!

Undefined variable $options

Please fix:
public function purge( )
to
public function purge( $upgrader_object, $options )

as you mentioned it would need two parameters when adding add_action so It would not show error.

Plugin folder gets renamed after each upgrade

It appears since the newest WordPress version (6.0+), upon a successful new version upgrade, the plugin folder gets renamed to something like misha-update-checker-n17qiE with an additional random string appended to the original folder name.

Do you happen to have any idea why?

Two or more plugins using the self hosted functionality

Hello there!

First, I want to tank you because this plugin works amazingly good that I create a custom post type with custom fields to have an endpoint to use it as a plugin's repository. Everything worked well until I try to see the details of my second plugin.

When I click on "View version x.x details" this is what I get.
Screenshot 2023-01-21 at 12 26 33 AM

The first plugin that I create works just fine.
Screenshot 2023-01-21 at 12 28 54 AM

All the validations to show the updates works just fine.
Screenshot 2023-01-21 at 12 30 18 AM

Do you have any ideas of how could I fix this?

Any way to get the update-checker to work with themes?

Hello,

I just wanted to ask if anyone has had any luck getting this updater-checker project working with updating themes?

It is working for plugin's no problem, and I found equivalent theme action hooks to replace the plugin-specific hooks, such as:

Plugin hooks

add_filter( 'plugins_api', array( $this, 'info' ), 20, 3 );
add_filter( 'site_transient_update_plugins', array( $this, 'update' ) );
add_action( 'upgrader_process_complete', array( $this, 'purge' ), 10, 2 );

Equivalent theme hooks

add_filter( 'themes_api', array( $this, 'info' ), 20, 3 );
add_filter( 'site_transient_update_themes', array( $this, 'update' ) );
add_action( 'upgrader_process_complete', array( $this, 'purge' ), 10, 2 );

Currently I can instantiate the update-checker with my theme, and it hits the update() function and see's that there is a new version of the theme available, but unfortunately the update notification on the theme does not display like it does for plugins.

I'm going to dive into the WP source code for updating to see if I can figure this out, but just wanted to run this by the user's of this repo to see if anyone had any ideas

Thank you!

Incorrect return for `plugins_api` hook.

Your plugins_api filter called to info() method.

The info() method that return false; after checked something is incorrect.

The return false; will be mess with another plugins information that is using the self hosted.

To be correct, it should return $res;.

Example:

		function info( $res, $action, $args ) {

			// print_r( $action );
			// print_r( $args );

			// do nothing if you're not getting plugin information right now
			if( 'plugin_information' !== $action ) {
				return $res;
			}

			// do nothing if it is not our plugin
			if( $this->plugin_slug !== $args->slug ) {
				return $res;
			}

			// get updates
			$remote = $this->request();

			if( ! $remote ) {
				return $res;
			}
			// your code
		}

Details link only visible if update available?

Great and very useful piece of code. What I'm trying to understand is why the "View Details" link is only visible when a new update is available. I'm fairly new to plugin development and I cant work out how to display the link constantly even if no new update is available.

Update only visible when plugin has been activated

Hi Misha, first of all BIG thanks for sharing the code and the awesome clear tutorial!

I've got a question.

When the plugin has NOT been activated it will not check for available updates, right?
Is that by design in your code? Or does the WordPress update mechanism only check those with a lower interval (and am I thus too impatient, since I started today with your code)?

Steven

Update not possible in WP Multisite unless network activated

I have tested this on several sites that are not WPMU and it works great. The only issue is, this plugin does not show update available in a WordPress Multisite unless it is network activated. In other words, it does show the update available icon in the top menu bar, but when you click on it, it shows no update available if the plugin is activated on a single site in the network.

What I have discovered is, it has to be Network Activated for it to allow you to click "Update" in the plugins list only in the Network Admin. I know it's possible for this to work on sub-sites as I've seen this done with the GeneratePress Premium plugin. I'm just wondering if you know of an easy fix for this.

How set plugin logo?

Hello, on the update page /wp-admin/update-core.php in the list of plugins when a new update is available with information about the plugin has an icon. This solution does not describe how to add it? Is there any information on how to do this?

изображение

The .zip file for my updated plugin requires authorization headers to request the .zip, stumped on how to add that functionality to this project

Hello,

I have used the source code from this project and it has worked great, but now I have run into an issue I am a little stumped on.

In the update() function:

public function update( $transient ) {

	if ( empty($transient->checked ) ) {
		return $transient;
	}

	$remote = $this->request();

	if(
		$remote
		&& version_compare( $this->version, $remote->version, '<' ) 
		&& version_compare( $remote->requires, get_bloginfo( 'version' ), '<=' ) 
		&& version_compare( $remote->requires_php, PHP_VERSION, '<' ) 
	) 
		{
			$res = new stdClass(); 
			$res->slug = $this->plugin_slug;
			$res->plugin = plugin_basename( __FILE__ );
			$res->new_version = $remote->version;
			$res->tested = $remote->tested;
			$res->package = $remote->download_url;

			$transient->response[ $res->plugin ] = $res;

		}

	return $transient;

}

We have the line, which tells WordPress which URL to download the .zip file from:

$res->package = $remote->download_url;

My question: This worked great until we required an access-token (As a header on the request) to request that .zip file, now the call fails because the header is not added to the request, but I am stumped as to how I can tell wordpress to add the authorization header to the request and just wanted to see if anyone had any ideas on how to do that?

Things I tried:

  • Doing a get request for the .zip and storing the response in a variable ($response), and then setting $res->package = $response but then I get the error on my plugin page "Update failed: Download failed. A valid URL was not provided." so that is making me realize it needs to be a valid URL, it cant be the .zip itself
  • This lead me to my second idea, could put those headers in query params instead? In theory this should work but the resource can't be requested query paramaters, it has to be a header, does anyone know a workaround for this?

So that has left me a little stumped on how to accomplish this, I feel it should be totally doable somehow... Somehow??

Any help or discussion on this is much appreciated, thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.