diff --git a/includes/class-indieweb.php b/includes/class-indieweb.php index 6f6bda8..403f8cf 100644 --- a/includes/class-indieweb.php +++ b/includes/class-indieweb.php @@ -62,6 +62,10 @@ public function init() { \add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); \add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_style' ) ); + // Plugin installer (extensions page). + $plugin_installer = new Plugin_Installer(); + $plugin_installer->start(); + // Admin menu and settings. \add_action( 'admin_menu', array( $this, 'add_menu_item' ), 9 ); \add_action( 'admin_menu', array( General_Settings::class, 'admin_menu' ) ); diff --git a/includes/class-plugin-installer.php b/includes/class-plugin-installer.php index 342437b..2e51910 100644 --- a/includes/class-plugin-installer.php +++ b/includes/class-plugin-installer.php @@ -5,7 +5,7 @@ * @author Darren Cooney * @link https://github.com/dcooney/wordpress-plugin-installer * @link https://connekthq.com - * @version 1.0 + * @version 1.0.2 * @package Indieweb */ @@ -20,9 +20,9 @@ class Plugin_Installer { * Start the installer. */ public function start() { - \add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue scripts and Localize. - \add_action( 'wp_ajax_cnkt_plugin_installer', array( $this, 'cnkt_plugin_installer' ) ); // Install plugin. - \add_action( 'wp_ajax_cnkt_plugin_activation', array( $this, 'cnkt_plugin_activation' ) ); // Activate plugin. + \add_action( 'cnkt_installer_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + \add_action( 'wp_ajax_cnkt_plugin_installer', array( $this, 'cnkt_plugin_installer' ) ); + \add_action( 'wp_ajax_cnkt_plugin_activation', array( $this, 'cnkt_plugin_activation' ) ); } /** @@ -31,6 +31,8 @@ public function start() { * @param array $plugins Array of plugin data. */ public static function init( $plugins ) { + // Add the required plugin scripts. + \do_action( 'cnkt_installer_enqueue_scripts' ); ?>
@@ -63,10 +65,12 @@ public static function init( $plugins ) { ) ); - if ( ! \is_wp_error( $api ) ) { // Confirm error free. + if ( ! \is_wp_error( $api ) ) { $main_plugin_file = self::get_plugin_file( $plugin['slug'] ); // Get main plugin file. - if ( self::check_file_extension( $main_plugin_file ) ) { // Check file extension. + + // Plugin is installed. + if ( $main_plugin_file ) { if ( \is_plugin_active( $main_plugin_file ) ) { // Plugin activation, confirmed! $button_classes = 'button disabled'; @@ -299,26 +303,11 @@ public static function get_plugin_file( $plugin_slug ) { return null; } - /** - * A helper to check file extension. - * - * @param string $filename The filename of the plugin. - * @return bool True if PHP file, false otherwise. - */ - public static function check_file_extension( $filename ) { - if ( substr( strrchr( $filename, '.' ), 1 ) === 'php' ) { - // Has .php extension. - return true; - } else { - return false; - } - } - /** * Enqueue admin scripts and scripts localization. */ public function enqueue_scripts() { - \wp_enqueue_script( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/js/installer.js', array( 'jquery' ), Indieweb::$version, true ); + \wp_enqueue_script( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/js/installer.js', array( 'jquery' ), INDIEWEB_VERSION, true ); \wp_localize_script( 'plugin-installer', 'cnkt_installer_localize', @@ -332,11 +321,6 @@ public function enqueue_scripts() { ) ); - \wp_enqueue_style( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/css/installer.css', array(), Indieweb::$version ); + \wp_enqueue_style( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/css/installer.css', array(), INDIEWEB_VERSION ); } } - - -// Initialize. -$indieweb_plugin_installer = new Plugin_Installer(); -$indieweb_plugin_installer->start(); diff --git a/indieweb.php b/indieweb.php index b7b61f9..58e068f 100755 --- a/indieweb.php +++ b/indieweb.php @@ -5,7 +5,7 @@ * Description: Interested in connecting your WordPress site to the IndieWeb? * Author: IndieWebCamp WordPress Outreach Club * Author URI: https://indieweb.org/WordPress_Outreach_Club - * Version: 5.1.0 + * Version: 5.1.1 * License: MIT * License URI: http://opensource.org/licenses/MIT * Text Domain: indieweb @@ -15,7 +15,7 @@ namespace Indieweb; -\define( 'INDIEWEB_VERSION', '5.1.0' ); +\define( 'INDIEWEB_VERSION', '5.1.1' ); \defined( 'INDIEWEB_ADD_HCARD_SUPPORT' ) || \define( 'INDIEWEB_ADD_HCARD_SUPPORT', true ); \defined( 'INDIEWEB_ADD_RELME_SUPPORT' ) || \define( 'INDIEWEB_ADD_RELME_SUPPORT', true ); diff --git a/readme.md b/readme.md index 1430ec6..9c317d1 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ - Requires at least: 4.7 - Requires PHP: 7.4 - Tested up to: 7.0 -- Stable tag: 5.1.0 +- Stable tag: 5.1.1 - License: MIT - License URI: http://opensource.org/licenses/MIT @@ -80,6 +80,11 @@ One could certainly download, install, and activate some or all of these plugins Project maintained on github at [indieweb/wordpress-indieweb](https://github.com/indieweb/wordpress-indieweb). +### 5.1.1 +* Update Plugin Installer to upstream version 1.0.2 +* Fix broken styles and scripts on extensions page +* Fix PHP deprecation warning for uninstalled plugins + ### 5.1.0 * Tested with WordPress 7.0 * Added namespacing and PSR-4 style autoloader