Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions includes/class-indieweb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down
40 changes: 12 additions & 28 deletions includes/class-plugin-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -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' ) );
}

/**
Expand All @@ -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' );
?>

<div class="cnkt-plugin-installer">
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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',
Expand All @@ -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();
4 changes: 2 additions & 2 deletions indieweb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 );
Expand Down
7 changes: 6 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down