api_url = trailingslashit( $_api_url ); $this->api_data = $_api_data; $this->name = plugin_basename( $_plugin_file ); $this->slug = basename( $_plugin_file, '.php' ); $this->version = $_api_data['version']; // Set up hooks. $this->init(); } /** * Set up WordPress filters to hook into WP's update process. * * @since 1.0.0 * * @return void */ public function init() { add_action( 'load-plugins.php', array( $this, 'setup_update_notification' ), 30 ); add_action( 'admin_init', array( $this, 'show_changelog' ) ); } /** * This disables the default update row shown for Charitable extensions, * and sets up our own callback to show the update notification. * * @since 1.4.20 * * @return void */ public function setup_update_notification() { remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); } /** * Show update nofication row. * * This is a drop-in replacement for wp_plugin_update_row(), * which is the function that will normally show the update row * for a plugin. Replaced here to show our changelog and also * prompt to the user to renew/set their license if it has * expired or hasn't been added yet. * * @since 1.0.0 * * @param string $file * @param array $plugin */ public function show_update_notification( $file, $plugin ) { if ( ! current_user_can( 'update_plugins' ) ) { return; } if ( $this->name != $file ) { return; } $version_info = Charitable_Licenses::get_instance()->get_version_info( $this->name ); if ( ! $version_info ) { return; } if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { // Build a plugin list row, with update notification. echo '