1
1
<?php
2
2
3
+
4
+
3
5
/**
4
6
* Redux Framework is free software: you can redistribute it and/or modify
5
7
* it under the terms of the GNU General Public License as published by
@@ -66,7 +68,7 @@ class ReduxFramework {
66
68
// ATTENTION DEVS
67
69
// Please update the build number with each push, no matter how small.
68
70
// This will make for easier support when we ask users what version they are using.
69
- public static $ _version = '3.2.8.20 ' ;
71
+ public static $ _version = '3.2.8.21 ' ;
70
72
public static $ _dir ;
71
73
public static $ _url ;
72
74
public static $ _upload_dir ;
@@ -138,7 +140,7 @@ static function init() {
138
140
'admin_bar ' => true , // Show the panel pages on the admin bar
139
141
'help_tabs ' => array (),
140
142
'help_sidebar ' => '' , // __( '', 'redux-framework' );
141
- 'database ' => '' , // possible: options, theme_mods, theme_mods_expanded, transient
143
+ 'database ' => '' , // possible: options, theme_mods, theme_mods_expanded, transient, network
142
144
'customizer ' => false , // setting to true forces get_theme_mod_expanded
143
145
'global_variable ' => '' , // Changes global variable from $GLOBALS['YOUR_OPT_NAME'] to whatever you set here. false disables the global variable
144
146
'output ' => true , // Dynamically generate CSS
@@ -150,6 +152,8 @@ static function init() {
150
152
'update_notice ' => true , // Recieve an update notice of new commits when in dev mode
151
153
'disable_save_warn ' => false , // Disable the save warn
152
154
'open_expanded ' => false , // Start the panel fully expanded to start with
155
+ 'network_admin ' => false , // Enable network admin when using network database mode
156
+ 'network_sites ' => true , // Enable sites as well as admin when using network database mode
153
157
'hints ' => array (
154
158
'icon ' => 'icon-question-sign ' ,
155
159
'icon_position ' => 'right ' ,
@@ -349,6 +353,11 @@ public function __construct( $sections = array(), $args = array(), $extra_tabs =
349
353
// Options page
350
354
add_action ( 'admin_menu ' , array ( $ this , '_options_page ' ) );
351
355
356
+ // Add a network menu
357
+ if ( $ this ->args ['database ' ] == "network " && $ this ->args ['network_admin ' ] ) {
358
+ add_action ( 'network_admin_menu ' , array ( $ this , '_options_page ' ) );
359
+ }
360
+
352
361
// Admin Bar menu
353
362
add_action ( 'admin_bar_menu ' , array ( $ this , '_admin_bar_menu ' ) , 999 );
354
363
@@ -385,6 +394,13 @@ public function __construct( $sections = array(), $args = array(), $extra_tabs =
385
394
require_once (self ::$ _dir . 'inc/fields/import_export/import_export.php ' );
386
395
$ this ->import_export = new Redux_import_export ($ this );
387
396
397
+ if ( $ this ->args ['database ' ] == "network " && $ this ->args ['network_admin ' ] ) {
398
+ add_action ('network_admin_edit_redux_ ' . $ this ->args ['opt_name ' ], array ( $ this , 'save_network_page ' ), 10 , 0 );
399
+ add_action ( 'admin_bar_menu ' , array ( $ this , 'network_admin_bar ' ), 999 );
400
+
401
+
402
+ }
403
+
388
404
// mod_rewrite check
389
405
//Redux_Functions::modRewriteCheck();
390
406
}
@@ -399,8 +415,46 @@ public function __construct( $sections = array(), $args = array(), $extra_tabs =
399
415
400
416
} // __construct()
401
417
418
+
419
+ public function network_admin_bar ( $ wp_admin_bar ) {
420
+
421
+ $ args = array (
422
+ 'id ' => $ this ->args ['opt_name ' ].'_network_admin ' ,
423
+ 'title ' => $ this ->args ['menu_title ' ],
424
+ 'parent ' => 'network-admin ' ,
425
+ 'href ' => network_admin_url ('settings.php ' ).'?page= ' .$ this ->args ['page_slug ' ],
426
+ 'meta ' => array ( 'class ' => 'redux-network-admin ' )
427
+ );
428
+ $ wp_admin_bar ->add_node ( $ args );
429
+
430
+ }
431
+
432
+ public function stripslashes_deep ( $ value ) {
433
+ $ value = is_array ($ value ) ?
434
+ array_map ('stripslashes_deep ' , $ value ) :
435
+ stripslashes ($ value );
436
+
437
+ return $ value ;
438
+ }
439
+
440
+ public function save_network_page () {
441
+
442
+ $ data = $ this ->_validate_options ( $ _POST [$ this ->args ['opt_name ' ]] );
443
+
444
+ if (!empty ($ data )) {
445
+ $ this ->set_options ( $ data );
446
+ }
447
+
448
+ wp_redirect (add_query_arg (array ('page ' => $ this ->args ['page_slug ' ], 'updated ' => 'true ' ), network_admin_url ('settings.php ' )));
449
+ exit ();
450
+ }
451
+
402
452
public function _update_check () {
403
- Redux_Functions::updateCheck (self ::$ _version );
453
+ // Only one notice per instance please
454
+ if ( !isset ( $ this ->update_checked ) ) {
455
+ Redux_Functions::updateCheck (self ::$ _version );
456
+ $ this ->update_checked = 1 ;
457
+ }
404
458
}
405
459
406
460
public function _admin_notices () {
@@ -551,6 +605,10 @@ function set_options( $value = '' ) {
551
605
foreach ( $ value as $ k =>$ v ) {
552
606
set_theme_mod ( $ k , $ v );
553
607
}
608
+ } else if ( $ this ->args ['database ' ] === 'network ' ) {
609
+ // Strip those slashes!
610
+ $ value = json_decode ( stripslashes ( json_encode ( $ value ) ), true );
611
+ update_site_option ( $ this ->args ['opt_name ' ], $ value );
554
612
} else {
555
613
update_option ( $ this ->args ['opt_name ' ], $ value );
556
614
}
@@ -599,6 +657,9 @@ function get_options() {
599
657
$ result = get_theme_mod ( $ this ->args ['opt_name ' ] . '-mods ' );
600
658
} else if ( $ this ->args ['database ' ] === 'theme_mods_expanded ' ) {
601
659
$ result = get_theme_mods ();
660
+ } else if ( $ this ->args ['database ' ] === 'network ' ) {
661
+ $ result = get_site_option ( $ this ->args ['opt_name ' ], array () );
662
+ $ result = json_decode (stripslashes (json_encode ($ result )), true );
602
663
} else {
603
664
$ result = get_option ( $ this ->args ['opt_name ' ], array () );
604
665
}
@@ -2483,7 +2544,7 @@ public function _validate_options( $plugin_options ) {
2483
2544
$ _COOKIE ['redux_current_tab ' ] = 1 ;
2484
2545
2485
2546
unset( $ plugin_options ['defaults ' ], $ plugin_options ['compiler ' ], $ plugin_options ['import ' ], $ plugin_options ['import_code ' ] );
2486
- if ( $ this ->args ['database ' ] == 'transient ' || $ this ->args ['database ' ] == 'theme_mods ' || $ this ->args ['database ' ] == 'theme_mods_expanded ' ) {
2547
+ if ( $ this ->args ['database ' ] == 'transient ' || $ this ->args ['database ' ] == 'theme_mods ' || $ this ->args ['database ' ] == 'theme_mods_expanded ' || $ this -> args [ ' database ' ] == ' network ' ) {
2487
2548
$ this ->set_options ( $ plugin_options );
2488
2549
return ;
2489
2550
}
@@ -2916,7 +2977,13 @@ public function _options_page_html() {
2916
2977
$ expanded = ($ this ->args ['open_expanded ' ]) ? ' fully-expanded ' : '' ;
2917
2978
2918
2979
echo '<div class="redux-container ' . $ expanded . ( !empty ( $ this ->args ['class ' ] ) ? ' ' . $ this ->args ['class ' ] : '' ) . '"> ' ;
2919
- echo '<form method="post" action=" ' . './options.php" enctype="multipart/form-data" id="redux-form-wrapper"> ' ;
2980
+ $ url = './options.php ' ;
2981
+ if ( $ this ->args ['database ' ] == "network " && $ this ->args ['network_admin ' ] ) {
2982
+ if ( is_network_admin () ) {
2983
+ $ url = './edit.php?action=redux_ ' . $ this ->args ['opt_name ' ];
2984
+ }
2985
+ }
2986
+ echo '<form method="post" action=" ' . $ url . '" enctype="multipart/form-data" id="redux-form-wrapper"> ' ;
2920
2987
echo '<input type="hidden" id="redux-compiler-hook" name=" ' . $ this ->args ['opt_name ' ] . '[compiler]" value="" /> ' ;
2921
2988
echo '<input type="hidden" id="currentSection" name=" ' . $ this ->args ['opt_name ' ] . '[redux-section]" value="" /> ' ;
2922
2989
0 commit comments