Skip to content

Commit 63972df

Browse files
authored
Merge pull request #312 from indieweb/fix/extensions-page-styles
Fix broken styles and scripts on extensions page
2 parents a38c8c5 + e0e782e commit 63972df

File tree

4 files changed

+24
-31
lines changed

4 files changed

+24
-31
lines changed

includes/class-indieweb.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function init() {
6262
\add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) );
6363
\add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_style' ) );
6464

65+
// Plugin installer (extensions page).
66+
$plugin_installer = new Plugin_Installer();
67+
$plugin_installer->start();
68+
6569
// Admin menu and settings.
6670
\add_action( 'admin_menu', array( $this, 'add_menu_item' ), 9 );
6771
\add_action( 'admin_menu', array( General_Settings::class, 'admin_menu' ) );

includes/class-plugin-installer.php

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @author Darren Cooney
66
* @link https://github.com/dcooney/wordpress-plugin-installer
77
* @link https://connekthq.com
8-
* @version 1.0
8+
* @version 1.0.2
99
* @package Indieweb
1010
*/
1111

@@ -20,9 +20,9 @@ class Plugin_Installer {
2020
* Start the installer.
2121
*/
2222
public function start() {
23-
\add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue scripts and Localize.
24-
\add_action( 'wp_ajax_cnkt_plugin_installer', array( $this, 'cnkt_plugin_installer' ) ); // Install plugin.
25-
\add_action( 'wp_ajax_cnkt_plugin_activation', array( $this, 'cnkt_plugin_activation' ) ); // Activate plugin.
23+
\add_action( 'cnkt_installer_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
24+
\add_action( 'wp_ajax_cnkt_plugin_installer', array( $this, 'cnkt_plugin_installer' ) );
25+
\add_action( 'wp_ajax_cnkt_plugin_activation', array( $this, 'cnkt_plugin_activation' ) );
2626
}
2727

2828
/**
@@ -31,6 +31,8 @@ public function start() {
3131
* @param array $plugins Array of plugin data.
3232
*/
3333
public static function init( $plugins ) {
34+
// Add the required plugin scripts.
35+
\do_action( 'cnkt_installer_enqueue_scripts' );
3436
?>
3537

3638
<div class="cnkt-plugin-installer">
@@ -63,10 +65,12 @@ public static function init( $plugins ) {
6365
)
6466
);
6567

66-
if ( ! \is_wp_error( $api ) ) { // Confirm error free.
68+
if ( ! \is_wp_error( $api ) ) {
6769

6870
$main_plugin_file = self::get_plugin_file( $plugin['slug'] ); // Get main plugin file.
69-
if ( self::check_file_extension( $main_plugin_file ) ) { // Check file extension.
71+
72+
// Plugin is installed.
73+
if ( $main_plugin_file ) {
7074
if ( \is_plugin_active( $main_plugin_file ) ) {
7175
// Plugin activation, confirmed!
7276
$button_classes = 'button disabled';
@@ -299,26 +303,11 @@ public static function get_plugin_file( $plugin_slug ) {
299303
return null;
300304
}
301305

302-
/**
303-
* A helper to check file extension.
304-
*
305-
* @param string $filename The filename of the plugin.
306-
* @return bool True if PHP file, false otherwise.
307-
*/
308-
public static function check_file_extension( $filename ) {
309-
if ( substr( strrchr( $filename, '.' ), 1 ) === 'php' ) {
310-
// Has .php extension.
311-
return true;
312-
} else {
313-
return false;
314-
}
315-
}
316-
317306
/**
318307
* Enqueue admin scripts and scripts localization.
319308
*/
320309
public function enqueue_scripts() {
321-
\wp_enqueue_script( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/js/installer.js', array( 'jquery' ), Indieweb::$version, true );
310+
\wp_enqueue_script( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/js/installer.js', array( 'jquery' ), INDIEWEB_VERSION, true );
322311
\wp_localize_script(
323312
'plugin-installer',
324313
'cnkt_installer_localize',
@@ -332,11 +321,6 @@ public function enqueue_scripts() {
332321
)
333322
);
334323

335-
\wp_enqueue_style( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/css/installer.css', array(), Indieweb::$version );
324+
\wp_enqueue_style( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/css/installer.css', array(), INDIEWEB_VERSION );
336325
}
337326
}
338-
339-
340-
// Initialize.
341-
$indieweb_plugin_installer = new Plugin_Installer();
342-
$indieweb_plugin_installer->start();

indieweb.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: Interested in connecting your WordPress site to the IndieWeb?
66
* Author: IndieWebCamp WordPress Outreach Club
77
* Author URI: https://indieweb.org/WordPress_Outreach_Club
8-
* Version: 5.1.0
8+
* Version: 5.1.1
99
* License: MIT
1010
* License URI: http://opensource.org/licenses/MIT
1111
* Text Domain: indieweb
@@ -15,7 +15,7 @@
1515

1616
namespace Indieweb;
1717

18-
\define( 'INDIEWEB_VERSION', '5.1.0' );
18+
\define( 'INDIEWEB_VERSION', '5.1.1' );
1919

2020
\defined( 'INDIEWEB_ADD_HCARD_SUPPORT' ) || \define( 'INDIEWEB_ADD_HCARD_SUPPORT', true );
2121
\defined( 'INDIEWEB_ADD_RELME_SUPPORT' ) || \define( 'INDIEWEB_ADD_RELME_SUPPORT', true );

readme.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- Requires at least: 4.7
77
- Requires PHP: 7.4
88
- Tested up to: 7.0
9-
- Stable tag: 5.1.0
9+
- Stable tag: 5.1.1
1010
- License: MIT
1111
- License URI: http://opensource.org/licenses/MIT
1212

@@ -80,6 +80,11 @@ One could certainly download, install, and activate some or all of these plugins
8080

8181
Project maintained on github at [indieweb/wordpress-indieweb](https://github.com/indieweb/wordpress-indieweb).
8282

83+
### 5.1.1
84+
* Update Plugin Installer to upstream version 1.0.2
85+
* Fix broken styles and scripts on extensions page
86+
* Fix PHP deprecation warning for uninstalled plugins
87+
8388
### 5.1.0
8489
* Tested with WordPress 7.0
8590
* Added namespacing and PSR-4 style autoloader

0 commit comments

Comments
 (0)