Skip to content
This repository was archived by the owner on Dec 4, 2019. It is now read-only.

Commit 23f1bbf

Browse files
committed
Fixing redux framework and adding a hook 'before_theme_loaded' that will fire if the must use plugin is used before the themes and plugins are required (used to load redux before any other plugin)
1 parent 89b50d6 commit 23f1bbf

File tree

8 files changed

+35
-22
lines changed

8 files changed

+35
-22
lines changed

WPlusPlusCore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Plugin Name: W++ Core
2525
* Plugin URI: https://github.com/tofandel/wplusplus-core/
2626
* Description: A Wordpress Plugin acting as core for other of my plugins and including the Ultimate Redux Framework Bundle and OOP APIs to use it
27-
* Version: 1.9.1
27+
* Version: 1.9.2
2828
* Author: Adrien Foulon <tofandel@tukan.hu>
2929
* Author URI: https://tukan.fr/a-propos/#adrien-foulon
3030
* Text Domain: wppc

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tofandel/wplusplus-core",
3-
"version": "1.9.1",
3+
"version": "1.9.2",
44
"authors": [
55
{
66
"name": "Tofandel"

functions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77

88
//namespace Tofandel;
99

10+
if ( defined( 'WPP_MUPLUGIN' ) ) {
11+
function wpp_before_theme_loaded( $root ) {
12+
//Add a hook after the taxonomies and wp global variables are declared but before theme is loaded
13+
do_action( 'before_theme_loaded' );
14+
remove_filter( 'theme_root', 'wpp_before_theme_loaded' );
15+
16+
return $root;
17+
}
18+
19+
add_filter( 'theme_root', 'wpp_before_theme_loaded' );
20+
} else {
21+
define( 'WPP_MUPLUGIN', false );
22+
}
23+
1024
if ( ! function_exists( 'wpp_array_insert_after' ) ) {
1125
/**
1226
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended

plugins/redux-framework/ReduxCore/framework.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,6 @@ public function set_options( $value = '' ) {
820820
set_theme_mod( $k, $v );
821821
}
822822
} else if ( $this->args['database'] === 'network' ) {
823-
// Strip those slashes!
824-
$value = json_decode( stripslashes( json_encode( $value ) ), true );
825823
update_site_option( $this->args['opt_name'], $value );
826824
} else {
827825
update_option( $this->args['opt_name'], $value );
@@ -873,7 +871,6 @@ public function get_options() {
873871
$result = get_theme_mods();
874872
} else if ( $this->args['database'] === 'network' ) {
875873
$result = get_site_option( $this->args['opt_name'], array() );
876-
$result = json_decode( stripslashes( json_encode( $result ) ), true );
877874
} else {
878875
$result = get_option( $this->args['opt_name'], array() );
879876
}

plugins/redux-framework/ReduxCore/inc/class.redux_api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public static function checkExtensionClassFile( $opt_name, $name = "", $class_fi
550550
self::$extensions[ $name ][ $version ] = isset( self::$extensions[ $name ][ $version ] ) ? self::$extensions[ $name ][ $version ] : $class_file;
551551

552552
$api_check = str_replace( 'extension_' . $name, $name . '_api', $class_file );
553-
if ( file_exists( $api_check ) && ! class_exists( 'Redux_' . ucfirst( $name, false ) ) ) {
553+
if ( file_exists( $api_check ) && ! class_exists( 'Redux_' . ucfirst( $name ), false ) ) {
554554
include_once( $api_check );
555555
}
556556
}

src/Objects/ReduxConfig.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function setArgs( $args = array() ) {
9898
'page_priority' => '39',
9999
'customizer' => false,
100100
'default_mark' => ' ¤',
101-
'hints' => array(
101+
'hints' => array(
102102
'icon' => 'el el-question-sign',
103103
'icon_position' => 'right',
104104
'icon_color' => '#071f49',
@@ -126,18 +126,19 @@ public function setArgs( $args = array() ) {
126126
),
127127
),
128128
),
129-
'output' => true,
130-
'output_tag' => true,
131-
'settings_api' => true,
132-
'cdn_check_time' => '1440',
133-
'compiler' => true,
134-
'page_permissions' => 'manage_options',
135-
'save_defaults' => true,
136-
'show_import_export' => true,
137-
'open_expanded' => false,
138-
'database' => 'options',
139-
'transient_time' => '3600',
140-
'network_sites' => true,
129+
'output' => true,
130+
'output_tag' => true,
131+
'settings_api' => true,
132+
'cdn_check_time' => '1440',
133+
'compiler' => true,
134+
'page_permissions' => 'manage_options',
135+
'save_defaults' => true,
136+
'show_import_export' => true,
137+
'open_expanded' => false,
138+
'database' => 'options',
139+
'transient_time' => '3600',
140+
'network_sites' => true,
141+
'admin_bar' => false,
141142
);
142143

143144
$args = array_merge( $def_args, $args );

src/Objects/WP_Plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ protected function setup() {
342342
if ( is_admin() && ! wp_doing_ajax() ||
343343
( wp_doing_ajax() && isset ( $_REQUEST['action'] ) &&
344344
( $_REQUEST['action'] == $this->redux_opt_name . '_ajax_save' || strpos( $_REQUEST['action'], 'redux' ) === 0 ) ) ) {
345-
add_action( 'plugins_loaded', [ $this, '_reduxConfig' ] );
345+
add_action( WPP_MUPLUGIN ? 'before_theme_loaded' : 'plugins_loaded', [ $this, '_reduxConfig' ] );
346346
add_action( 'init', [ $this, 'removeDemoModeLink' ] );
347347
} else {
348348
//We define it before in case some dummy used the option before plugins_loaded
@@ -1009,7 +1009,7 @@ public function _reduxConfig() {
10091009
* @var ReduxFramework $module
10101010
*/
10111011
$this->reduxInit( $module );
1012-
do_action( 'wpp_redux_' . $this->redux_opt_name . '_config', $module );
1012+
apply_filters( 'wpp_redux_' . $this->redux_opt_name . '_config', $module );
10131013
}
10141014

10151015
/**

wplusplus-muloader.php.bak

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
* Plugin Name: W++ Core MuLoader
55
* Plugin URI: https://github.com/tofandel/wplusplus-core
66
* Description: The must use plugin loader for W++ Core to load it before anything else
7-
* Version: 1.7
7+
* Version: 1.8
88
* Author: Adrien Foulon <tofandel@tukan.hu>
99
* Author URI: https://tukan.fr/a-propos/#adrien-foulon
1010
*/
1111

1212
defined('WP_PLUGIN_DIR') or die('WP_PLUGIN_DIR not defined');
1313

14+
define( 'WPP_MUPLUGIN', true );
1415
if ($file = get_transient('wpp_reactivate_core')) {
1516
if (!function_exists('activate_plugin')) {
1617
include_once ABSPATH . 'wp-admin/includes/plugin.php';

0 commit comments

Comments
 (0)