@@ -9,7 +9,7 @@ |
||
| 9 | 9 | |
| 10 | 10 | // If uninstall, not called from WordPress, then exit. |
| 11 | 11 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 12 | - exit; |
|
| 12 | + exit; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // TODO: Define uninstall functionality here. |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // This is your option name where all the Redux data is stored. |
| 16 | -$opt_name = 'redux_demo'; // YOU MUST CHANGE THIS. DO NOT USE 'redux_demo' IN YOUR PROJECT!!! |
|
| 16 | +$opt_name = 'redux_demo'; // YOU MUST CHANGE THIS. DO NOT USE 'redux_demo' IN YOUR PROJECT!!! |
|
| 17 | 17 | |
| 18 | 18 | // Uncomment to disable demo mode. |
| 19 | 19 | /* Redux::disable_demo(); */ // phpcs:ignore Squiz.PHP.CommentedOutCode |
@@ -643,10 +643,10 @@ discard block |
||
| 643 | 643 | $warning = false; |
| 644 | 644 | |
| 645 | 645 | // Do your validation. |
| 646 | - if ( 1 === (int) $value ) { |
|
| 646 | + if ( 1 === ( int ) $value ) { |
|
| 647 | 647 | $error = true; |
| 648 | 648 | $value = $existing_value; |
| 649 | - } elseif ( 2 === (int) $value ) { |
|
| 649 | + } elseif ( 2 === ( int ) $value ) { |
|
| 650 | 650 | $warning = true; |
| 651 | 651 | $value = $existing_value; |
| 652 | 652 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | defined( 'ABSPATH' ) || exit; |
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux' ) ) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // This is your option name where all the Redux data is stored. |
@@ -31,32 +31,32 @@ discard block |
||
| 31 | 31 | $sample_patterns = array(); |
| 32 | 32 | |
| 33 | 33 | if ( is_dir( $sample_patterns_path ) ) { |
| 34 | - $sample_patterns_dir = opendir( $sample_patterns_path ); |
|
| 35 | - |
|
| 36 | - if ( $sample_patterns_dir ) { |
|
| 37 | - |
|
| 38 | - // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition |
|
| 39 | - while ( false !== ( $sample_patterns_file = readdir( $sample_patterns_dir ) ) ) { |
|
| 40 | - if ( stristr( $sample_patterns_file, '.png' ) !== false || stristr( $sample_patterns_file, '.jpg' ) !== false ) { |
|
| 41 | - $name = explode( '.', $sample_patterns_file ); |
|
| 42 | - $name = str_replace( '.' . end( $name ), '', $sample_patterns_file ); |
|
| 43 | - $sample_patterns[] = array( |
|
| 44 | - 'alt' => $name, |
|
| 45 | - 'img' => $sample_patterns_url . $sample_patterns_file, |
|
| 46 | - ); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 34 | + $sample_patterns_dir = opendir( $sample_patterns_path ); |
|
| 35 | + |
|
| 36 | + if ( $sample_patterns_dir ) { |
|
| 37 | + |
|
| 38 | + // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition |
|
| 39 | + while ( false !== ( $sample_patterns_file = readdir( $sample_patterns_dir ) ) ) { |
|
| 40 | + if ( stristr( $sample_patterns_file, '.png' ) !== false || stristr( $sample_patterns_file, '.jpg' ) !== false ) { |
|
| 41 | + $name = explode( '.', $sample_patterns_file ); |
|
| 42 | + $name = str_replace( '.' . end( $name ), '', $sample_patterns_file ); |
|
| 43 | + $sample_patterns[] = array( |
|
| 44 | + 'alt' => $name, |
|
| 45 | + 'img' => $sample_patterns_url . $sample_patterns_file, |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Used to except HTML tags in description arguments where esc_html would remove. |
| 53 | 53 | $kses_exceptions = array( |
| 54 | - 'a' => array( |
|
| 55 | - 'href' => array(), |
|
| 56 | - ), |
|
| 57 | - 'strong' => array(), |
|
| 58 | - 'br' => array(), |
|
| 59 | - 'code' => array(), |
|
| 54 | + 'a' => array( |
|
| 55 | + 'href' => array(), |
|
| 56 | + ), |
|
| 57 | + 'strong' => array(), |
|
| 58 | + 'br' => array(), |
|
| 59 | + 'code' => array(), |
|
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | 62 | /* |
@@ -71,155 +71,155 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // TYPICAL → Change these values as you need/desire. |
| 73 | 73 | $args = array( |
| 74 | - // This is where your data is stored in the database and also becomes your global variable name. |
|
| 75 | - 'opt_name' => $opt_name, |
|
| 74 | + // This is where your data is stored in the database and also becomes your global variable name. |
|
| 75 | + 'opt_name' => $opt_name, |
|
| 76 | 76 | |
| 77 | - // Name that appears at the top of your panel. |
|
| 78 | - 'display_name' => $theme->get( 'Name' ), |
|
| 77 | + // Name that appears at the top of your panel. |
|
| 78 | + 'display_name' => $theme->get( 'Name' ), |
|
| 79 | 79 | |
| 80 | - // Version that appears at the top of your panel. |
|
| 81 | - 'display_version' => $theme->get( 'Version' ), |
|
| 80 | + // Version that appears at the top of your panel. |
|
| 81 | + 'display_version' => $theme->get( 'Version' ), |
|
| 82 | 82 | |
| 83 | - // Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only). |
|
| 84 | - 'menu_type' => 'menu', |
|
| 83 | + // Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only). |
|
| 84 | + 'menu_type' => 'menu', |
|
| 85 | 85 | |
| 86 | - // Show the sections below the admin menu item or not. |
|
| 87 | - 'allow_sub_menu' => true, |
|
| 86 | + // Show the sections below the admin menu item or not. |
|
| 87 | + 'allow_sub_menu' => true, |
|
| 88 | 88 | |
| 89 | - // The text to appear in the admin menu. |
|
| 90 | - 'menu_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 89 | + // The text to appear in the admin menu. |
|
| 90 | + 'menu_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 91 | 91 | |
| 92 | - // The text to appear on the page title. |
|
| 93 | - 'page_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 92 | + // The text to appear on the page title. |
|
| 93 | + 'page_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 94 | 94 | |
| 95 | - // Disable to create your own Google fonts loader. |
|
| 96 | - 'disable_google_fonts_link' => false, |
|
| 95 | + // Disable to create your own Google fonts loader. |
|
| 96 | + 'disable_google_fonts_link' => false, |
|
| 97 | 97 | |
| 98 | - // Show the panel pages on the admin bar. |
|
| 99 | - 'admin_bar' => true, |
|
| 98 | + // Show the panel pages on the admin bar. |
|
| 99 | + 'admin_bar' => true, |
|
| 100 | 100 | |
| 101 | - // Icon for the admin bar menu. |
|
| 102 | - 'admin_bar_icon' => 'dashicons-portfolio', |
|
| 101 | + // Icon for the admin bar menu. |
|
| 102 | + 'admin_bar_icon' => 'dashicons-portfolio', |
|
| 103 | 103 | |
| 104 | - // Priority for the admin bar menu. |
|
| 105 | - 'admin_bar_priority' => 50, |
|
| 104 | + // Priority for the admin bar menu. |
|
| 105 | + 'admin_bar_priority' => 50, |
|
| 106 | 106 | |
| 107 | - // Sets a different name for your global variable other than the opt_name. |
|
| 108 | - 'global_variable' => $opt_name, |
|
| 107 | + // Sets a different name for your global variable other than the opt_name. |
|
| 108 | + 'global_variable' => $opt_name, |
|
| 109 | 109 | |
| 110 | - // Show the time the page took to load, etc. (forced on while on localhost or when WP_DEBUG is enabled). |
|
| 111 | - 'dev_mode' => true, |
|
| 110 | + // Show the time the page took to load, etc. (forced on while on localhost or when WP_DEBUG is enabled). |
|
| 111 | + 'dev_mode' => true, |
|
| 112 | 112 | |
| 113 | - // Enable basic customizer support. |
|
| 114 | - 'customizer' => true, |
|
| 113 | + // Enable basic customizer support. |
|
| 114 | + 'customizer' => true, |
|
| 115 | 115 | |
| 116 | - // Allow the panel to open expanded. |
|
| 117 | - 'open_expanded' => false, |
|
| 116 | + // Allow the panel to open expanded. |
|
| 117 | + 'open_expanded' => false, |
|
| 118 | 118 | |
| 119 | - // Disable the save warning when a user changes a field. |
|
| 120 | - 'disable_save_warn' => false, |
|
| 119 | + // Disable the save warning when a user changes a field. |
|
| 120 | + 'disable_save_warn' => false, |
|
| 121 | 121 | |
| 122 | - // Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning. |
|
| 123 | - 'page_priority' => 90, |
|
| 122 | + // Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning. |
|
| 123 | + 'page_priority' => 90, |
|
| 124 | 124 | |
| 125 | - // For a full list of options, visit: https://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters. |
|
| 126 | - 'page_parent' => 'themes.php', |
|
| 125 | + // For a full list of options, visit: https://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters. |
|
| 126 | + 'page_parent' => 'themes.php', |
|
| 127 | 127 | |
| 128 | - // Permissions needed to access the options panel. |
|
| 129 | - 'page_permissions' => 'manage_options', |
|
| 128 | + // Permissions needed to access the options panel. |
|
| 129 | + 'page_permissions' => 'manage_options', |
|
| 130 | 130 | |
| 131 | - // Specify a custom URL to an icon. |
|
| 132 | - 'menu_icon' => '', |
|
| 131 | + // Specify a custom URL to an icon. |
|
| 132 | + 'menu_icon' => '', |
|
| 133 | 133 | |
| 134 | - // Force your panel to always open to a specific tab (by id). |
|
| 135 | - 'last_tab' => '', |
|
| 134 | + // Force your panel to always open to a specific tab (by id). |
|
| 135 | + 'last_tab' => '', |
|
| 136 | 136 | |
| 137 | - // Icon displayed in the admin panel next to your menu_title. |
|
| 138 | - 'page_icon' => 'icon-themes', |
|
| 137 | + // Icon displayed in the admin panel next to your menu_title. |
|
| 138 | + 'page_icon' => 'icon-themes', |
|
| 139 | 139 | |
| 140 | - // Page slug used to denote the panel, will be based off page title, then menu title, then opt_name if not provided. |
|
| 141 | - 'page_slug' => $opt_name, |
|
| 140 | + // Page slug used to denote the panel, will be based off page title, then menu title, then opt_name if not provided. |
|
| 141 | + 'page_slug' => $opt_name, |
|
| 142 | 142 | |
| 143 | - // On load save the defaults to DB before user clicks save. |
|
| 144 | - 'save_defaults' => true, |
|
| 143 | + // On load save the defaults to DB before user clicks save. |
|
| 144 | + 'save_defaults' => true, |
|
| 145 | 145 | |
| 146 | - // Display the default value next to each field when not set to the default value. |
|
| 147 | - 'default_show' => false, |
|
| 146 | + // Display the default value next to each field when not set to the default value. |
|
| 147 | + 'default_show' => false, |
|
| 148 | 148 | |
| 149 | - // What to print by the field's title if the value shown is default. |
|
| 150 | - 'default_mark' => '*', |
|
| 149 | + // What to print by the field's title if the value shown is default. |
|
| 150 | + 'default_mark' => '*', |
|
| 151 | 151 | |
| 152 | - // Shows the Import/Export panel when not used as a field. |
|
| 153 | - 'show_import_export' => true, |
|
| 152 | + // Shows the Import/Export panel when not used as a field. |
|
| 153 | + 'show_import_export' => true, |
|
| 154 | 154 | |
| 155 | - // Shows the Options Object for debugging purposes. Show be set to false before deploying. |
|
| 156 | - 'show_options_object' => true, |
|
| 155 | + // Shows the Options Object for debugging purposes. Show be set to false before deploying. |
|
| 156 | + 'show_options_object' => true, |
|
| 157 | 157 | |
| 158 | - // The time transients will expire when the 'database' arg is set. |
|
| 159 | - 'transient_time' => 60 * MINUTE_IN_SECONDS, |
|
| 158 | + // The time transients will expire when the 'database' arg is set. |
|
| 159 | + 'transient_time' => 60 * MINUTE_IN_SECONDS, |
|
| 160 | 160 | |
| 161 | - // Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output. |
|
| 162 | - 'output' => true, |
|
| 161 | + // Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output. |
|
| 162 | + 'output' => true, |
|
| 163 | 163 | |
| 164 | - // Allows dynamic CSS to be generated for customizer and google fonts, |
|
| 165 | - // but stops the dynamic CSS from going to the page head. |
|
| 166 | - 'output_tag' => true, |
|
| 164 | + // Allows dynamic CSS to be generated for customizer and google fonts, |
|
| 165 | + // but stops the dynamic CSS from going to the page head. |
|
| 166 | + 'output_tag' => true, |
|
| 167 | 167 | |
| 168 | - // Disable the footer credit of Redux. Please leave if you can help it. |
|
| 169 | - 'footer_credit' => '', |
|
| 168 | + // Disable the footer credit of Redux. Please leave if you can help it. |
|
| 169 | + 'footer_credit' => '', |
|
| 170 | 170 | |
| 171 | - // If you prefer not to use the CDN for ACE Editor. |
|
| 172 | - // You may download the Redux Vendor Support plugin to run locally or embed it in your code. |
|
| 173 | - 'use_cdn' => true, |
|
| 171 | + // If you prefer not to use the CDN for ACE Editor. |
|
| 172 | + // You may download the Redux Vendor Support plugin to run locally or embed it in your code. |
|
| 173 | + 'use_cdn' => true, |
|
| 174 | 174 | |
| 175 | - // Set the theme of the option panel. Use 'wp' to use a more modern style, default is classic. |
|
| 176 | - 'admin_theme' => 'wp', |
|
| 175 | + // Set the theme of the option panel. Use 'wp' to use a more modern style, default is classic. |
|
| 176 | + 'admin_theme' => 'wp', |
|
| 177 | 177 | |
| 178 | - // Enable or disable flyout menus when hovering over a menu with submenus. |
|
| 179 | - 'flyout_submenus' => true, |
|
| 178 | + // Enable or disable flyout menus when hovering over a menu with submenus. |
|
| 179 | + 'flyout_submenus' => true, |
|
| 180 | 180 | |
| 181 | - // Mode to display fonts (auto|block|swap|fallback|optional) |
|
| 182 | - // See: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display. |
|
| 183 | - 'font_display' => 'swap', |
|
| 181 | + // Mode to display fonts (auto|block|swap|fallback|optional) |
|
| 182 | + // See: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display. |
|
| 183 | + 'font_display' => 'swap', |
|
| 184 | 184 | |
| 185 | - // HINTS. |
|
| 186 | - 'hints' => array( |
|
| 187 | - 'icon' => 'el el-question-sign', |
|
| 188 | - 'icon_position' => 'right', |
|
| 189 | - 'icon_color' => 'lightgray', |
|
| 190 | - 'icon_size' => 'normal', |
|
| 191 | - 'tip_style' => array( |
|
| 192 | - 'color' => 'red', |
|
| 193 | - 'shadow' => true, |
|
| 194 | - 'rounded' => false, |
|
| 195 | - 'style' => '', |
|
| 196 | - ), |
|
| 197 | - 'tip_position' => array( |
|
| 198 | - 'my' => 'top left', |
|
| 199 | - 'at' => 'bottom right', |
|
| 200 | - ), |
|
| 201 | - 'tip_effect' => array( |
|
| 202 | - 'show' => array( |
|
| 203 | - 'effect' => 'slide', |
|
| 204 | - 'duration' => '500', |
|
| 205 | - 'event' => 'mouseover', |
|
| 206 | - ), |
|
| 207 | - 'hide' => array( |
|
| 208 | - 'effect' => 'slide', |
|
| 209 | - 'duration' => '500', |
|
| 210 | - 'event' => 'click mouseleave', |
|
| 211 | - ), |
|
| 212 | - ), |
|
| 213 | - ), |
|
| 214 | - |
|
| 215 | - // FUTURE → Not in use yet, but reserved or partially implemented. |
|
| 216 | - // Use at your own risk. |
|
| 217 | - // Possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning! |
|
| 218 | - 'database' => '', |
|
| 219 | - 'network_admin' => true, |
|
| 220 | - 'search' => true, |
|
| 221 | - 'widget_area' => true, |
|
| 222 | - 'custom_fonts' => true, |
|
| 185 | + // HINTS. |
|
| 186 | + 'hints' => array( |
|
| 187 | + 'icon' => 'el el-question-sign', |
|
| 188 | + 'icon_position' => 'right', |
|
| 189 | + 'icon_color' => 'lightgray', |
|
| 190 | + 'icon_size' => 'normal', |
|
| 191 | + 'tip_style' => array( |
|
| 192 | + 'color' => 'red', |
|
| 193 | + 'shadow' => true, |
|
| 194 | + 'rounded' => false, |
|
| 195 | + 'style' => '', |
|
| 196 | + ), |
|
| 197 | + 'tip_position' => array( |
|
| 198 | + 'my' => 'top left', |
|
| 199 | + 'at' => 'bottom right', |
|
| 200 | + ), |
|
| 201 | + 'tip_effect' => array( |
|
| 202 | + 'show' => array( |
|
| 203 | + 'effect' => 'slide', |
|
| 204 | + 'duration' => '500', |
|
| 205 | + 'event' => 'mouseover', |
|
| 206 | + ), |
|
| 207 | + 'hide' => array( |
|
| 208 | + 'effect' => 'slide', |
|
| 209 | + 'duration' => '500', |
|
| 210 | + 'event' => 'click mouseleave', |
|
| 211 | + ), |
|
| 212 | + ), |
|
| 213 | + ), |
|
| 214 | + |
|
| 215 | + // FUTURE → Not in use yet, but reserved or partially implemented. |
|
| 216 | + // Use at your own risk. |
|
| 217 | + // Possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning! |
|
| 218 | + 'database' => '', |
|
| 219 | + 'network_admin' => true, |
|
| 220 | + 'search' => true, |
|
| 221 | + 'widget_area' => true, |
|
| 222 | + 'custom_fonts' => true, |
|
| 223 | 223 | ); |
| 224 | 224 | |
| 225 | 225 | |
@@ -227,53 +227,53 @@ discard block |
||
| 227 | 227 | // PLEASE CHANGE THESE SETTINGS IN YOUR THEME BEFORE RELEASING YOUR PRODUCT!! |
| 228 | 228 | // If these are left unchanged, they will not display in your panel! |
| 229 | 229 | $args['admin_bar_links'][] = array( |
| 230 | - 'id' => 'redux-docs', |
|
| 231 | - 'href' => '//devs.redux.io/', |
|
| 232 | - 'title' => __( 'Documentation', 'your-textdomain-here' ), |
|
| 230 | + 'id' => 'redux-docs', |
|
| 231 | + 'href' => '//devs.redux.io/', |
|
| 232 | + 'title' => __( 'Documentation', 'your-textdomain-here' ), |
|
| 233 | 233 | ); |
| 234 | 234 | |
| 235 | 235 | $args['admin_bar_links'][] = array( |
| 236 | - 'id' => 'redux-support', |
|
| 237 | - 'href' => '//github.com/ReduxFramework/redux-framework/issues', |
|
| 238 | - 'title' => __( 'Support', 'your-textdomain-here' ), |
|
| 236 | + 'id' => 'redux-support', |
|
| 237 | + 'href' => '//github.com/ReduxFramework/redux-framework/issues', |
|
| 238 | + 'title' => __( 'Support', 'your-textdomain-here' ), |
|
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | // SOCIAL ICONS → Set up custom links in the footer for quick links in your panel footer icons. |
| 242 | 242 | // PLEASE CHANGE THESE SETTINGS IN YOUR THEME BEFORE RELEASING YOUR PRODUCT!! |
| 243 | 243 | // If these are left unchanged, they will not display in your panel! |
| 244 | 244 | $args['share_icons'][] = array( |
| 245 | - 'url' => '//github.com/ReduxFramework/ReduxFramework', |
|
| 246 | - 'title' => 'Visit us on GitHub', |
|
| 247 | - 'icon' => 'el el-github', |
|
| 245 | + 'url' => '//github.com/ReduxFramework/ReduxFramework', |
|
| 246 | + 'title' => 'Visit us on GitHub', |
|
| 247 | + 'icon' => 'el el-github', |
|
| 248 | 248 | ); |
| 249 | 249 | $args['share_icons'][] = array( |
| 250 | - 'url' => '//www.facebook.com/pages/Redux-Framework/243141545850368', |
|
| 251 | - 'title' => 'Like us on Facebook', |
|
| 252 | - 'icon' => 'el el-facebook', |
|
| 250 | + 'url' => '//www.facebook.com/pages/Redux-Framework/243141545850368', |
|
| 251 | + 'title' => 'Like us on Facebook', |
|
| 252 | + 'icon' => 'el el-facebook', |
|
| 253 | 253 | ); |
| 254 | 254 | $args['share_icons'][] = array( |
| 255 | - 'url' => '//twitter.com/reduxframework', |
|
| 256 | - 'title' => 'Follow us on Twitter', |
|
| 257 | - 'icon' => 'el el-twitter', |
|
| 255 | + 'url' => '//twitter.com/reduxframework', |
|
| 256 | + 'title' => 'Follow us on Twitter', |
|
| 257 | + 'icon' => 'el el-twitter', |
|
| 258 | 258 | ); |
| 259 | 259 | $args['share_icons'][] = array( |
| 260 | - 'url' => '//www.linkedin.com/company/redux-framework', |
|
| 261 | - 'title' => 'Find us on LinkedIn', |
|
| 262 | - 'icon' => 'el el-linkedin', |
|
| 260 | + 'url' => '//www.linkedin.com/company/redux-framework', |
|
| 261 | + 'title' => 'Find us on LinkedIn', |
|
| 262 | + 'icon' => 'el el-linkedin', |
|
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | 265 | // Panel Intro text → before the form. |
| 266 | 266 | if ( ! isset( $args['global_variable'] ) || false !== $args['global_variable'] ) { |
| 267 | - if ( ! empty( $args['global_variable'] ) ) { |
|
| 268 | - $v = $args['global_variable']; |
|
| 269 | - } else { |
|
| 270 | - $v = str_replace( '-', '_', $args['opt_name'] ); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - // translators: Panel opt_name. |
|
| 274 | - $args['intro_text'] = '<p>' . sprintf( esc_html__( 'Did you know that Redux sets a global variable for you? To access any of your saved options from within your code you can use your global variable: $%1$s', 'your-textdomain-here' ), '<strong>' . $v . '</strong>' ) . '<p>'; |
|
| 267 | + if ( ! empty( $args['global_variable'] ) ) { |
|
| 268 | + $v = $args['global_variable']; |
|
| 269 | + } else { |
|
| 270 | + $v = str_replace( '-', '_', $args['opt_name'] ); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + // translators: Panel opt_name. |
|
| 274 | + $args['intro_text'] = '<p>' . sprintf( esc_html__( 'Did you know that Redux sets a global variable for you? To access any of your saved options from within your code you can use your global variable: $%1$s', 'your-textdomain-here' ), '<strong>' . $v . '</strong>' ) . '<p>'; |
|
| 275 | 275 | } else { |
| 276 | - $args['intro_text'] = '<p>' . esc_html__( 'This text is displayed above the options panel. It isn\'t required, but more info is always better! The intro_text field accepts all HTML.', 'your-textdomain-here' ) . '</p>'; |
|
| 276 | + $args['intro_text'] = '<p>' . esc_html__( 'This text is displayed above the options panel. It isn\'t required, but more info is always better! The intro_text field accepts all HTML.', 'your-textdomain-here' ) . '</p>'; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // Add content after the form. |
@@ -289,16 +289,16 @@ discard block |
||
| 289 | 289 | * ---> START HELP TABS |
| 290 | 290 | */ |
| 291 | 291 | $help_tabs = array( |
| 292 | - array( |
|
| 293 | - 'id' => 'redux-help-tab-1', |
|
| 294 | - 'title' => esc_html__( 'Theme Information 1', 'your-textdomain-here' ), |
|
| 295 | - 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 296 | - ), |
|
| 297 | - array( |
|
| 298 | - 'id' => 'redux-help-tab-2', |
|
| 299 | - 'title' => esc_html__( 'Theme Information 2', 'your-textdomain-here' ), |
|
| 300 | - 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 301 | - ), |
|
| 292 | + array( |
|
| 293 | + 'id' => 'redux-help-tab-1', |
|
| 294 | + 'title' => esc_html__( 'Theme Information 1', 'your-textdomain-here' ), |
|
| 295 | + 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 296 | + ), |
|
| 297 | + array( |
|
| 298 | + 'id' => 'redux-help-tab-2', |
|
| 299 | + 'title' => esc_html__( 'Theme Information 2', 'your-textdomain-here' ), |
|
| 300 | + 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 301 | + ), |
|
| 302 | 302 | ); |
| 303 | 303 | Redux::set_help_tab( $opt_name, $help_tabs ); |
| 304 | 304 | |
@@ -317,14 +317,14 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | // -> START Basic Fields |
| 319 | 319 | Redux::set_section( |
| 320 | - $opt_name, |
|
| 321 | - array( |
|
| 322 | - 'title' => esc_html__( 'Basic Fields', 'your-textdomain-here' ), |
|
| 323 | - 'id' => 'basic', |
|
| 324 | - 'desc' => esc_html__( 'These are really basic fields!', 'your-textdomain-here' ), |
|
| 325 | - 'customizer_width' => '400px', |
|
| 326 | - 'icon' => 'el el-home', |
|
| 327 | - ) |
|
| 320 | + $opt_name, |
|
| 321 | + array( |
|
| 322 | + 'title' => esc_html__( 'Basic Fields', 'your-textdomain-here' ), |
|
| 323 | + 'id' => 'basic', |
|
| 324 | + 'desc' => esc_html__( 'These are really basic fields!', 'your-textdomain-here' ), |
|
| 325 | + 'customizer_width' => '400px', |
|
| 326 | + 'icon' => 'el el-home', |
|
| 327 | + ) |
|
| 328 | 328 | ); |
| 329 | 329 | |
| 330 | 330 | require_once Redux_Core::$dir . '../sample/sections/basic-fields/checkbox.php'; |
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | // -> START Editors. |
| 339 | 339 | Redux::set_section( |
| 340 | - $opt_name, |
|
| 341 | - array( |
|
| 342 | - 'title' => esc_html__( 'Editors', 'your-textdomain-here' ), |
|
| 343 | - 'id' => 'editor', |
|
| 344 | - 'customizer_width' => '500px', |
|
| 345 | - 'icon' => 'el el-edit', |
|
| 346 | - ) |
|
| 340 | + $opt_name, |
|
| 341 | + array( |
|
| 342 | + 'title' => esc_html__( 'Editors', 'your-textdomain-here' ), |
|
| 343 | + 'id' => 'editor', |
|
| 344 | + 'customizer_width' => '500px', |
|
| 345 | + 'icon' => 'el el-edit', |
|
| 346 | + ) |
|
| 347 | 347 | ); |
| 348 | 348 | |
| 349 | 349 | require_once Redux_Core::$dir . '../sample/sections/editors/wordpress-editor.php'; |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | // -> START Color Selection. |
| 353 | 353 | Redux::set_section( |
| 354 | - $opt_name, |
|
| 355 | - array( |
|
| 356 | - 'title' => esc_html__( 'Color Selection', 'your-textdomain-here' ), |
|
| 357 | - 'id' => 'color', |
|
| 358 | - 'icon' => 'el el-brush', |
|
| 359 | - ) |
|
| 354 | + $opt_name, |
|
| 355 | + array( |
|
| 356 | + 'title' => esc_html__( 'Color Selection', 'your-textdomain-here' ), |
|
| 357 | + 'id' => 'color', |
|
| 358 | + 'icon' => 'el el-brush', |
|
| 359 | + ) |
|
| 360 | 360 | ); |
| 361 | 361 | |
| 362 | 362 | require_once Redux_Core::$dir . '../sample/sections/color-selection/color.php'; |
@@ -368,12 +368,12 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | // -> START Design Fields. |
| 370 | 370 | Redux::set_section( |
| 371 | - $opt_name, |
|
| 372 | - array( |
|
| 373 | - 'title' => esc_html__( 'Design Fields', 'your-textdomain-here' ), |
|
| 374 | - 'id' => 'design', |
|
| 375 | - 'icon' => 'el el-wrench', |
|
| 376 | - ) |
|
| 371 | + $opt_name, |
|
| 372 | + array( |
|
| 373 | + 'title' => esc_html__( 'Design Fields', 'your-textdomain-here' ), |
|
| 374 | + 'id' => 'design', |
|
| 375 | + 'icon' => 'el el-wrench', |
|
| 376 | + ) |
|
| 377 | 377 | ); |
| 378 | 378 | |
| 379 | 379 | require_once Redux_Core::$dir . '../sample/sections/design-fields/background.php'; |
@@ -384,12 +384,12 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | // -> START Media Uploads. |
| 386 | 386 | Redux::set_section( |
| 387 | - $opt_name, |
|
| 388 | - array( |
|
| 389 | - 'title' => esc_html__( 'Media Uploads', 'your-textdomain-here' ), |
|
| 390 | - 'id' => 'media', |
|
| 391 | - 'icon' => 'el el-picture', |
|
| 392 | - ) |
|
| 387 | + $opt_name, |
|
| 388 | + array( |
|
| 389 | + 'title' => esc_html__( 'Media Uploads', 'your-textdomain-here' ), |
|
| 390 | + 'id' => 'media', |
|
| 391 | + 'icon' => 'el el-picture', |
|
| 392 | + ) |
|
| 393 | 393 | ); |
| 394 | 394 | |
| 395 | 395 | require_once Redux_Core::$dir . '../sample/sections/media-uploads/gallery.php'; |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | // -> START Presentation Fields. |
| 401 | 401 | Redux::set_section( |
| 402 | - $opt_name, |
|
| 403 | - array( |
|
| 404 | - 'title' => esc_html__( 'Presentation Fields', 'your-textdomain-here' ), |
|
| 405 | - 'id' => 'presentation', |
|
| 406 | - 'icon' => 'el el-screen', |
|
| 407 | - ) |
|
| 402 | + $opt_name, |
|
| 403 | + array( |
|
| 404 | + 'title' => esc_html__( 'Presentation Fields', 'your-textdomain-here' ), |
|
| 405 | + 'id' => 'presentation', |
|
| 406 | + 'icon' => 'el el-screen', |
|
| 407 | + ) |
|
| 408 | 408 | ); |
| 409 | 409 | |
| 410 | 410 | require_once Redux_Core::$dir . '../sample/sections/presentation-fields/divide.php'; |
@@ -413,21 +413,21 @@ discard block |
||
| 413 | 413 | require_once Redux_Core::$dir . '../sample/sections/presentation-fields/section.php'; |
| 414 | 414 | |
| 415 | 415 | Redux::set_section( |
| 416 | - $opt_name, |
|
| 417 | - array( |
|
| 418 | - 'id' => 'presentation-divide-sample', |
|
| 419 | - 'type' => 'divide', |
|
| 420 | - ) |
|
| 416 | + $opt_name, |
|
| 417 | + array( |
|
| 418 | + 'id' => 'presentation-divide-sample', |
|
| 419 | + 'type' => 'divide', |
|
| 420 | + ) |
|
| 421 | 421 | ); |
| 422 | 422 | |
| 423 | 423 | // → START Switch & Button Set. |
| 424 | 424 | Redux::set_section( |
| 425 | - $opt_name, |
|
| 426 | - array( |
|
| 427 | - 'title' => esc_html__( 'Switch / Button Set', 'your-textdomain-here' ), |
|
| 428 | - 'id' => 'switch_buttonset', |
|
| 429 | - 'icon' => 'el el-cogs', |
|
| 430 | - ) |
|
| 425 | + $opt_name, |
|
| 426 | + array( |
|
| 427 | + 'title' => esc_html__( 'Switch / Button Set', 'your-textdomain-here' ), |
|
| 428 | + 'id' => 'switch_buttonset', |
|
| 429 | + 'icon' => 'el el-cogs', |
|
| 430 | + ) |
|
| 431 | 431 | ); |
| 432 | 432 | |
| 433 | 433 | require_once Redux_Core::$dir . '../sample/sections/switch-button/button-set.php'; |
@@ -435,12 +435,12 @@ discard block |
||
| 435 | 435 | |
| 436 | 436 | // -> START Select Fields. |
| 437 | 437 | Redux::set_section( |
| 438 | - $opt_name, |
|
| 439 | - array( |
|
| 440 | - 'title' => esc_html__( 'Select Fields', 'your-textdomain-here' ), |
|
| 441 | - 'id' => 'select', |
|
| 442 | - 'icon' => 'el el-list-alt', |
|
| 443 | - ) |
|
| 438 | + $opt_name, |
|
| 439 | + array( |
|
| 440 | + 'title' => esc_html__( 'Select Fields', 'your-textdomain-here' ), |
|
| 441 | + 'id' => 'select', |
|
| 442 | + 'icon' => 'el el-list-alt', |
|
| 443 | + ) |
|
| 444 | 444 | ); |
| 445 | 445 | |
| 446 | 446 | require_once Redux_Core::$dir . '../sample/sections/select-fields/select.php'; |
@@ -449,12 +449,12 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | // -> START Slider / Spinner. |
| 451 | 451 | Redux::set_section( |
| 452 | - $opt_name, |
|
| 453 | - array( |
|
| 454 | - 'title' => esc_html__( 'Slider / Spinner', 'your-textdomain-here' ), |
|
| 455 | - 'id' => 'slider_spinner', |
|
| 456 | - 'icon' => 'el el-adjust-alt', |
|
| 457 | - ) |
|
| 452 | + $opt_name, |
|
| 453 | + array( |
|
| 454 | + 'title' => esc_html__( 'Slider / Spinner', 'your-textdomain-here' ), |
|
| 455 | + 'id' => 'slider_spinner', |
|
| 456 | + 'icon' => 'el el-adjust-alt', |
|
| 457 | + ) |
|
| 458 | 458 | ); |
| 459 | 459 | |
| 460 | 460 | require_once Redux_Core::$dir . '../sample/sections/slider-spinner/slider.php'; |
@@ -465,12 +465,12 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | // -> START Additional Types. |
| 467 | 467 | Redux::set_section( |
| 468 | - $opt_name, |
|
| 469 | - array( |
|
| 470 | - 'title' => esc_html__( 'Additional Types', 'your-textdomain-here' ), |
|
| 471 | - 'id' => 'additional', |
|
| 472 | - 'icon' => 'el el-magic', |
|
| 473 | - ) |
|
| 468 | + $opt_name, |
|
| 469 | + array( |
|
| 470 | + 'title' => esc_html__( 'Additional Types', 'your-textdomain-here' ), |
|
| 471 | + 'id' => 'additional', |
|
| 472 | + 'icon' => 'el el-magic', |
|
| 473 | + ) |
|
| 474 | 474 | ); |
| 475 | 475 | |
| 476 | 476 | require_once Redux_Core::$dir . '../sample/sections/additional-types/date.php'; |
@@ -479,11 +479,11 @@ discard block |
||
| 479 | 479 | require_once Redux_Core::$dir . '../sample/sections/additional-types/raw.php'; |
| 480 | 480 | |
| 481 | 481 | Redux::set_section( |
| 482 | - $opt_name, |
|
| 483 | - array( |
|
| 484 | - 'title' => esc_html__( 'Advanced Features', 'your-textdomain-here' ), |
|
| 485 | - 'icon' => 'el el-thumbs-up', |
|
| 486 | - ) |
|
| 482 | + $opt_name, |
|
| 483 | + array( |
|
| 484 | + 'title' => esc_html__( 'Advanced Features', 'your-textdomain-here' ), |
|
| 485 | + 'icon' => 'el el-thumbs-up', |
|
| 486 | + ) |
|
| 487 | 487 | ); |
| 488 | 488 | |
| 489 | 489 | require_once Redux_Core::$dir . '../sample/sections/advanced-features/callback.php'; |
@@ -501,11 +501,11 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | // -> START Disabling. |
| 503 | 503 | Redux::set_section( |
| 504 | - $opt_name, |
|
| 505 | - array( |
|
| 506 | - 'title' => esc_html__( 'Disabling', 'your-textdomain-here' ), |
|
| 507 | - 'icon' => 'el el-lock', |
|
| 508 | - ) |
|
| 504 | + $opt_name, |
|
| 505 | + array( |
|
| 506 | + 'title' => esc_html__( 'Disabling', 'your-textdomain-here' ), |
|
| 507 | + 'icon' => 'el el-lock', |
|
| 508 | + ) |
|
| 509 | 509 | ); |
| 510 | 510 | |
| 511 | 511 | require_once Redux_Core::$dir . '../sample/sections/disabling/disable-field.php'; |
@@ -513,14 +513,14 @@ discard block |
||
| 513 | 513 | |
| 514 | 514 | // -> START Extensions. |
| 515 | 515 | Redux::set_section( |
| 516 | - $opt_name, |
|
| 517 | - array( |
|
| 518 | - 'title' => esc_html__( 'Redux Extensions', 'your-textdomain-here' ), |
|
| 519 | - 'id' => 'redux-extensions', |
|
| 520 | - 'icon' => 'el el-redux', |
|
| 521 | - 'class' => 'pro_highlight', |
|
| 522 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/" target="_blank">https://devs.redux.io/core-extensions/</a>', |
|
| 523 | - ) |
|
| 516 | + $opt_name, |
|
| 517 | + array( |
|
| 518 | + 'title' => esc_html__( 'Redux Extensions', 'your-textdomain-here' ), |
|
| 519 | + 'id' => 'redux-extensions', |
|
| 520 | + 'icon' => 'el el-redux', |
|
| 521 | + 'class' => 'pro_highlight', |
|
| 522 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/" target="_blank">https://devs.redux.io/core-extensions/</a>', |
|
| 523 | + ) |
|
| 524 | 524 | ); |
| 525 | 525 | |
| 526 | 526 | require_once Redux_Core::$dir . '../sample/sections/extensions/accordion.php'; |
@@ -546,46 +546,46 @@ discard block |
||
| 546 | 546 | * Raw README |
| 547 | 547 | */ |
| 548 | 548 | if ( file_exists( $dir . '/../README.md' ) ) { |
| 549 | - $section = array( |
|
| 550 | - 'icon' => 'el el-list-alt', |
|
| 551 | - 'title' => esc_html__( 'Documentation', 'your-textdomain-here' ), |
|
| 552 | - 'fields' => array( |
|
| 553 | - array( |
|
| 554 | - 'id' => 'opt-raw-documentation', |
|
| 555 | - 'type' => 'raw', |
|
| 556 | - 'markdown' => true, |
|
| 557 | - 'content_path' => __DIR__ . '/../README.md', // FULL PATH, not relative, please. |
|
| 558 | - ), |
|
| 559 | - ), |
|
| 560 | - ); |
|
| 561 | - |
|
| 562 | - Redux::set_section( $opt_name, $section ); |
|
| 549 | + $section = array( |
|
| 550 | + 'icon' => 'el el-list-alt', |
|
| 551 | + 'title' => esc_html__( 'Documentation', 'your-textdomain-here' ), |
|
| 552 | + 'fields' => array( |
|
| 553 | + array( |
|
| 554 | + 'id' => 'opt-raw-documentation', |
|
| 555 | + 'type' => 'raw', |
|
| 556 | + 'markdown' => true, |
|
| 557 | + 'content_path' => __DIR__ . '/../README.md', // FULL PATH, not relative, please. |
|
| 558 | + ), |
|
| 559 | + ), |
|
| 560 | + ); |
|
| 561 | + |
|
| 562 | + Redux::set_section( $opt_name, $section ); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | Redux::set_section( |
| 566 | - $opt_name, |
|
| 567 | - array( |
|
| 568 | - 'icon' => 'el el-list-alt', |
|
| 569 | - 'title' => esc_html__( 'Customizer Only', 'your-textdomain-here' ), |
|
| 570 | - 'desc' => '<p class="description">' . esc_html__( 'This Section should be visible only in Customizer', 'your-textdomain-here' ) . '</p>', |
|
| 571 | - 'customizer_only' => true, |
|
| 572 | - 'fields' => array( |
|
| 573 | - array( |
|
| 574 | - 'id' => 'opt-customizer-only', |
|
| 575 | - 'type' => 'select', |
|
| 576 | - 'title' => esc_html__( 'Customizer Only Option', 'your-textdomain-here' ), |
|
| 577 | - 'subtitle' => esc_html__( 'The subtitle is NOT visible in customizer', 'your-textdomain-here' ), |
|
| 578 | - 'desc' => esc_html__( 'The field desc is NOT visible in customizer.', 'your-textdomain-here' ), |
|
| 579 | - 'customizer_only' => true, |
|
| 580 | - 'options' => array( |
|
| 581 | - '1' => esc_html__( 'Opt 1', 'your-textdomain-here' ), |
|
| 582 | - '2' => esc_html__( 'Opt 2', 'your-textdomain-here' ), |
|
| 583 | - '3' => esc_html__( 'Opt 3', 'your-textdomain-here' ), |
|
| 584 | - ), |
|
| 585 | - 'default' => '2', |
|
| 586 | - ), |
|
| 587 | - ), |
|
| 588 | - ) |
|
| 566 | + $opt_name, |
|
| 567 | + array( |
|
| 568 | + 'icon' => 'el el-list-alt', |
|
| 569 | + 'title' => esc_html__( 'Customizer Only', 'your-textdomain-here' ), |
|
| 570 | + 'desc' => '<p class="description">' . esc_html__( 'This Section should be visible only in Customizer', 'your-textdomain-here' ) . '</p>', |
|
| 571 | + 'customizer_only' => true, |
|
| 572 | + 'fields' => array( |
|
| 573 | + array( |
|
| 574 | + 'id' => 'opt-customizer-only', |
|
| 575 | + 'type' => 'select', |
|
| 576 | + 'title' => esc_html__( 'Customizer Only Option', 'your-textdomain-here' ), |
|
| 577 | + 'subtitle' => esc_html__( 'The subtitle is NOT visible in customizer', 'your-textdomain-here' ), |
|
| 578 | + 'desc' => esc_html__( 'The field desc is NOT visible in customizer.', 'your-textdomain-here' ), |
|
| 579 | + 'customizer_only' => true, |
|
| 580 | + 'options' => array( |
|
| 581 | + '1' => esc_html__( 'Opt 1', 'your-textdomain-here' ), |
|
| 582 | + '2' => esc_html__( 'Opt 2', 'your-textdomain-here' ), |
|
| 583 | + '3' => esc_html__( 'Opt 3', 'your-textdomain-here' ), |
|
| 584 | + ), |
|
| 585 | + 'default' => '2', |
|
| 586 | + ), |
|
| 587 | + ), |
|
| 588 | + ) |
|
| 589 | 589 | ); |
| 590 | 590 | |
| 591 | 591 | /* |
@@ -615,150 +615,150 @@ discard block |
||
| 615 | 615 | // add_filter('redux/options/' . $opt_name . '/sections', 'dynamic_section'); |
| 616 | 616 | // . |
| 617 | 617 | if ( ! function_exists( 'compiler_action' ) ) { |
| 618 | - /** |
|
| 619 | - * This is a test function that will let you see when the compiler hook occurs. |
|
| 620 | - * It only runs if a field's value has changed and compiler => true is set. |
|
| 621 | - * |
|
| 622 | - * @param array $options Options values. |
|
| 623 | - * @param string $css Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 624 | - * @param array $changed_values Any values that have changed since last save. |
|
| 625 | - */ |
|
| 626 | - function compiler_action( array $options, string $css, array $changed_values ) { |
|
| 627 | - echo '<h1>The compiler hook has run!</h1>'; |
|
| 628 | - echo '<pre>'; |
|
| 629 | - // phpcs:ignore WordPress.PHP.DevelopmentFunctions |
|
| 630 | - print_r( $changed_values ); // Values that have changed since the last save. |
|
| 631 | - // echo '<br/>'; |
|
| 632 | - // print_r($options); //Option values. |
|
| 633 | - // echo '<br/>'; |
|
| 634 | - // print_r($css); // Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 635 | - echo '</pre>'; |
|
| 636 | - } |
|
| 618 | + /** |
|
| 619 | + * This is a test function that will let you see when the compiler hook occurs. |
|
| 620 | + * It only runs if a field's value has changed and compiler => true is set. |
|
| 621 | + * |
|
| 622 | + * @param array $options Options values. |
|
| 623 | + * @param string $css Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 624 | + * @param array $changed_values Any values that have changed since last save. |
|
| 625 | + */ |
|
| 626 | + function compiler_action( array $options, string $css, array $changed_values ) { |
|
| 627 | + echo '<h1>The compiler hook has run!</h1>'; |
|
| 628 | + echo '<pre>'; |
|
| 629 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions |
|
| 630 | + print_r( $changed_values ); // Values that have changed since the last save. |
|
| 631 | + // echo '<br/>'; |
|
| 632 | + // print_r($options); //Option values. |
|
| 633 | + // echo '<br/>'; |
|
| 634 | + // print_r($css); // Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 635 | + echo '</pre>'; |
|
| 636 | + } |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | if ( ! function_exists( 'redux_validate_callback_function' ) ) { |
| 640 | - /** |
|
| 641 | - * Custom function for the callback validation referenced above |
|
| 642 | - * |
|
| 643 | - * @param array $field Field array. |
|
| 644 | - * @param mixed $value New value. |
|
| 645 | - * @param mixed $existing_value Existing value. |
|
| 646 | - * |
|
| 647 | - * @return array |
|
| 648 | - */ |
|
| 649 | - function redux_validate_callback_function( array $field, $value, $existing_value ): array { |
|
| 650 | - $error = false; |
|
| 651 | - $warning = false; |
|
| 652 | - |
|
| 653 | - // Do your validation. |
|
| 654 | - if ( 1 === (int) $value ) { |
|
| 655 | - $error = true; |
|
| 656 | - $value = $existing_value; |
|
| 657 | - } elseif ( 2 === (int) $value ) { |
|
| 658 | - $warning = true; |
|
| 659 | - $value = $existing_value; |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - $return['value'] = $value; |
|
| 663 | - |
|
| 664 | - if ( true === $error ) { |
|
| 665 | - $field['msg'] = 'your custom error message'; |
|
| 666 | - $return['error'] = $field; |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - if ( true === $warning ) { |
|
| 670 | - $field['msg'] = 'your custom warning message'; |
|
| 671 | - $return['warning'] = $field; |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - return $return; |
|
| 675 | - } |
|
| 640 | + /** |
|
| 641 | + * Custom function for the callback validation referenced above |
|
| 642 | + * |
|
| 643 | + * @param array $field Field array. |
|
| 644 | + * @param mixed $value New value. |
|
| 645 | + * @param mixed $existing_value Existing value. |
|
| 646 | + * |
|
| 647 | + * @return array |
|
| 648 | + */ |
|
| 649 | + function redux_validate_callback_function( array $field, $value, $existing_value ): array { |
|
| 650 | + $error = false; |
|
| 651 | + $warning = false; |
|
| 652 | + |
|
| 653 | + // Do your validation. |
|
| 654 | + if ( 1 === (int) $value ) { |
|
| 655 | + $error = true; |
|
| 656 | + $value = $existing_value; |
|
| 657 | + } elseif ( 2 === (int) $value ) { |
|
| 658 | + $warning = true; |
|
| 659 | + $value = $existing_value; |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + $return['value'] = $value; |
|
| 663 | + |
|
| 664 | + if ( true === $error ) { |
|
| 665 | + $field['msg'] = 'your custom error message'; |
|
| 666 | + $return['error'] = $field; |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + if ( true === $warning ) { |
|
| 670 | + $field['msg'] = 'your custom warning message'; |
|
| 671 | + $return['warning'] = $field; |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + return $return; |
|
| 675 | + } |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | |
| 679 | 679 | if ( ! function_exists( 'dynamic_section' ) ) { |
| 680 | - /** |
|
| 681 | - * Custom function for filtering the section array. |
|
| 682 | - * Good for child themes to override or add to the sections. |
|
| 683 | - * Simply include this function in the child themes functions.php file. |
|
| 684 | - * NOTE: the defined constants for URLs and directories will NOT be available at this point in a child theme, |
|
| 685 | - * so you must use get_template_directory_uri() if you want to use any of the built-in icons. |
|
| 686 | - * |
|
| 687 | - * @param array $sections Section array. |
|
| 688 | - * |
|
| 689 | - * @return array |
|
| 690 | - */ |
|
| 691 | - function dynamic_section( array $sections ): array { |
|
| 692 | - $sections[] = array( |
|
| 693 | - 'title' => esc_html__( 'Section via hook', 'your-textdomain-here' ), |
|
| 694 | - 'desc' => '<p class="description">' . esc_html__( 'This is a section created by adding a filter to the sections array. Can be used by child themes to add/remove sections from the options.', 'your-textdomain-here' ) . '</p>', |
|
| 695 | - 'icon' => 'el el-paper-clip', |
|
| 696 | - |
|
| 697 | - // Leave this as a blank section, no options just some intro text set above. |
|
| 698 | - 'fields' => array(), |
|
| 699 | - ); |
|
| 700 | - |
|
| 701 | - return $sections; |
|
| 702 | - } |
|
| 680 | + /** |
|
| 681 | + * Custom function for filtering the section array. |
|
| 682 | + * Good for child themes to override or add to the sections. |
|
| 683 | + * Simply include this function in the child themes functions.php file. |
|
| 684 | + * NOTE: the defined constants for URLs and directories will NOT be available at this point in a child theme, |
|
| 685 | + * so you must use get_template_directory_uri() if you want to use any of the built-in icons. |
|
| 686 | + * |
|
| 687 | + * @param array $sections Section array. |
|
| 688 | + * |
|
| 689 | + * @return array |
|
| 690 | + */ |
|
| 691 | + function dynamic_section( array $sections ): array { |
|
| 692 | + $sections[] = array( |
|
| 693 | + 'title' => esc_html__( 'Section via hook', 'your-textdomain-here' ), |
|
| 694 | + 'desc' => '<p class="description">' . esc_html__( 'This is a section created by adding a filter to the sections array. Can be used by child themes to add/remove sections from the options.', 'your-textdomain-here' ) . '</p>', |
|
| 695 | + 'icon' => 'el el-paper-clip', |
|
| 696 | + |
|
| 697 | + // Leave this as a blank section, no options just some intro text set above. |
|
| 698 | + 'fields' => array(), |
|
| 699 | + ); |
|
| 700 | + |
|
| 701 | + return $sections; |
|
| 702 | + } |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | if ( ! function_exists( 'change_arguments' ) ) { |
| 706 | - /** |
|
| 707 | - * Filter hook for filtering the args. |
|
| 708 | - * Good for child themes to override or add to the args array. |
|
| 709 | - * It can also be used in other functions. |
|
| 710 | - * |
|
| 711 | - * @param array $args Global arguments array. |
|
| 712 | - * |
|
| 713 | - * @return array |
|
| 714 | - */ |
|
| 715 | - function change_arguments( array $args ): array { |
|
| 716 | - $args['dev_mode'] = true; |
|
| 717 | - |
|
| 718 | - return $args; |
|
| 719 | - } |
|
| 706 | + /** |
|
| 707 | + * Filter hook for filtering the args. |
|
| 708 | + * Good for child themes to override or add to the args array. |
|
| 709 | + * It can also be used in other functions. |
|
| 710 | + * |
|
| 711 | + * @param array $args Global arguments array. |
|
| 712 | + * |
|
| 713 | + * @return array |
|
| 714 | + */ |
|
| 715 | + function change_arguments( array $args ): array { |
|
| 716 | + $args['dev_mode'] = true; |
|
| 717 | + |
|
| 718 | + return $args; |
|
| 719 | + } |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | if ( ! function_exists( 'change_defaults' ) ) { |
| 723 | - /** |
|
| 724 | - * Filter hook for filtering the default value of any given field. Very useful in development mode. |
|
| 725 | - * |
|
| 726 | - * @param array $defaults Default value array. |
|
| 727 | - * |
|
| 728 | - * @return array |
|
| 729 | - */ |
|
| 730 | - function change_defaults( array $defaults ): array { |
|
| 731 | - $defaults['str_replace'] = esc_html__( 'Testing filter hook!', 'your-textdomain-here' ); |
|
| 732 | - |
|
| 733 | - return $defaults; |
|
| 734 | - } |
|
| 723 | + /** |
|
| 724 | + * Filter hook for filtering the default value of any given field. Very useful in development mode. |
|
| 725 | + * |
|
| 726 | + * @param array $defaults Default value array. |
|
| 727 | + * |
|
| 728 | + * @return array |
|
| 729 | + */ |
|
| 730 | + function change_defaults( array $defaults ): array { |
|
| 731 | + $defaults['str_replace'] = esc_html__( 'Testing filter hook!', 'your-textdomain-here' ); |
|
| 732 | + |
|
| 733 | + return $defaults; |
|
| 734 | + } |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | if ( ! function_exists( 'redux_custom_sanitize' ) ) { |
| 738 | - /** |
|
| 739 | - * Function to be used if the field sanitizes argument. |
|
| 740 | - * Return value MUST be formatted or cleaned text to display. |
|
| 741 | - * |
|
| 742 | - * @param string $value Value to evaluate or clean. Required. |
|
| 743 | - * |
|
| 744 | - * @return string |
|
| 745 | - */ |
|
| 746 | - function redux_custom_sanitize( string $value ): string { |
|
| 747 | - $return = ''; |
|
| 748 | - |
|
| 749 | - foreach ( explode( ' ', $value ) as $w ) { |
|
| 750 | - foreach ( str_split( $w ) as $k => $v ) { |
|
| 751 | - if ( ( $k + 1 ) % 2 !== 0 && ctype_alpha( $v ) ) { |
|
| 752 | - $return .= mb_strtoupper( $v ); |
|
| 753 | - } else { |
|
| 754 | - $return .= $v; |
|
| 755 | - } |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - $return .= ' '; |
|
| 759 | - } |
|
| 760 | - |
|
| 761 | - return $return; |
|
| 762 | - } |
|
| 738 | + /** |
|
| 739 | + * Function to be used if the field sanitizes argument. |
|
| 740 | + * Return value MUST be formatted or cleaned text to display. |
|
| 741 | + * |
|
| 742 | + * @param string $value Value to evaluate or clean. Required. |
|
| 743 | + * |
|
| 744 | + * @return string |
|
| 745 | + */ |
|
| 746 | + function redux_custom_sanitize( string $value ): string { |
|
| 747 | + $return = ''; |
|
| 748 | + |
|
| 749 | + foreach ( explode( ' ', $value ) as $w ) { |
|
| 750 | + foreach ( str_split( $w ) as $k => $v ) { |
|
| 751 | + if ( ( $k + 1 ) % 2 !== 0 && ctype_alpha( $v ) ) { |
|
| 752 | + $return .= mb_strtoupper( $v ); |
|
| 753 | + } else { |
|
| 754 | + $return .= $v; |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + $return .= ' '; |
|
| 759 | + } |
|
| 760 | + |
|
| 761 | + return $return; |
|
| 762 | + } |
|
| 763 | 763 | } |
| 764 | 764 | // phpcs:enable |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public static function get_instance( $opt_name = false ) { |
| 37 | 37 | |
| 38 | - if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) { |
|
| 39 | - return self::$instances[ $opt_name ]; |
|
| 38 | + if ( $opt_name && ! empty( self::$instances[$opt_name] ) ) { |
|
| 39 | + return self::$instances[$opt_name]; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return new self(); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | public function store( $redux_framework ) { |
| 84 | 84 | if ( $redux_framework instanceof ReduxFramework ) { |
| 85 | 85 | $key = $redux_framework->args['opt_name']; |
| 86 | - self::$instances[ $key ] = $redux_framework; |
|
| 86 | + self::$instances[$key] = $redux_framework; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -12,108 +12,108 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Instances', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Instances |
|
| 17 | - */ |
|
| 18 | - class Redux_Instances { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Instances |
|
| 17 | + */ |
|
| 18 | + class Redux_Instances { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * ReduxFramework instances |
|
| 22 | - * |
|
| 23 | - * @var ReduxFramework[] |
|
| 24 | - */ |
|
| 25 | - private static $instances; |
|
| 20 | + /** |
|
| 21 | + * ReduxFramework instances |
|
| 22 | + * |
|
| 23 | + * @var ReduxFramework[] |
|
| 24 | + */ |
|
| 25 | + private static $instances; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Get Instance |
|
| 29 | - * Get Redux_Instances instance |
|
| 30 | - * OR an instance of ReduxFramework by [opt_name] |
|
| 31 | - * |
|
| 32 | - * @param string|false $opt_name the defined opt_name. |
|
| 33 | - * |
|
| 34 | - * @return ReduxFramework|Redux_Instances class instance |
|
| 35 | - */ |
|
| 36 | - public static function get_instance( $opt_name = false ) { |
|
| 27 | + /** |
|
| 28 | + * Get Instance |
|
| 29 | + * Get Redux_Instances instance |
|
| 30 | + * OR an instance of ReduxFramework by [opt_name] |
|
| 31 | + * |
|
| 32 | + * @param string|false $opt_name the defined opt_name. |
|
| 33 | + * |
|
| 34 | + * @return ReduxFramework|Redux_Instances class instance |
|
| 35 | + */ |
|
| 36 | + public static function get_instance( $opt_name = false ) { |
|
| 37 | 37 | |
| 38 | - if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) { |
|
| 39 | - return self::$instances[ $opt_name ]; |
|
| 40 | - } |
|
| 38 | + if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) { |
|
| 39 | + return self::$instances[ $opt_name ]; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return new self(); |
|
| 43 | - } |
|
| 42 | + return new self(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Shim for old get_redux_instance method. |
|
| 47 | - * |
|
| 48 | - * @param string|false $opt_name the defined opt_name. |
|
| 49 | - * |
|
| 50 | - * @return ReduxFramework class instance |
|
| 51 | - */ |
|
| 52 | - public static function get_redux_instance( $opt_name = '' ) { |
|
| 53 | - return self::get_instance( $opt_name ); |
|
| 54 | - } |
|
| 45 | + /** |
|
| 46 | + * Shim for old get_redux_instance method. |
|
| 47 | + * |
|
| 48 | + * @param string|false $opt_name the defined opt_name. |
|
| 49 | + * |
|
| 50 | + * @return ReduxFramework class instance |
|
| 51 | + */ |
|
| 52 | + public static function get_redux_instance( $opt_name = '' ) { |
|
| 53 | + return self::get_instance( $opt_name ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Get all instantiated ReduxFramework instances (so far) |
|
| 58 | - * |
|
| 59 | - * @return array|null [type] [description] |
|
| 60 | - */ |
|
| 61 | - public static function get_all_instances(): ?array { |
|
| 62 | - return self::$instances; |
|
| 63 | - } |
|
| 56 | + /** |
|
| 57 | + * Get all instantiated ReduxFramework instances (so far) |
|
| 58 | + * |
|
| 59 | + * @return array|null [type] [description] |
|
| 60 | + */ |
|
| 61 | + public static function get_all_instances(): ?array { |
|
| 62 | + return self::$instances; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Redux_Instances constructor. |
|
| 67 | - * |
|
| 68 | - * @param mixed $redux_framework Is object. |
|
| 69 | - */ |
|
| 70 | - public function __construct( $redux_framework = false ) { |
|
| 71 | - if ( false !== $redux_framework ) { |
|
| 72 | - $this->store( $redux_framework ); |
|
| 73 | - } else { |
|
| 74 | - add_action( 'redux/construct', array( $this, 'store' ), 5, 1 ); |
|
| 75 | - } |
|
| 76 | - } |
|
| 65 | + /** |
|
| 66 | + * Redux_Instances constructor. |
|
| 67 | + * |
|
| 68 | + * @param mixed $redux_framework Is object. |
|
| 69 | + */ |
|
| 70 | + public function __construct( $redux_framework = false ) { |
|
| 71 | + if ( false !== $redux_framework ) { |
|
| 72 | + $this->store( $redux_framework ); |
|
| 73 | + } else { |
|
| 74 | + add_action( 'redux/construct', array( $this, 'store' ), 5, 1 ); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Action hook callback. |
|
| 80 | - * |
|
| 81 | - * @param object $redux_framework Pointer. |
|
| 82 | - */ |
|
| 83 | - public function store( $redux_framework ) { |
|
| 84 | - if ( $redux_framework instanceof ReduxFramework ) { |
|
| 85 | - $key = $redux_framework->args['opt_name']; |
|
| 86 | - self::$instances[ $key ] = $redux_framework; |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - } |
|
| 78 | + /** |
|
| 79 | + * Action hook callback. |
|
| 80 | + * |
|
| 81 | + * @param object $redux_framework Pointer. |
|
| 82 | + */ |
|
| 83 | + public function store( $redux_framework ) { |
|
| 84 | + if ( $redux_framework instanceof ReduxFramework ) { |
|
| 85 | + $key = $redux_framework->args['opt_name']; |
|
| 86 | + self::$instances[ $key ] = $redux_framework; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | if ( ! class_exists( 'ReduxFrameworkInstances' ) ) { |
| 93 | - class_alias( 'Redux_Instances', 'ReduxFrameworkInstances' ); |
|
| 93 | + class_alias( 'Redux_Instances', 'ReduxFrameworkInstances' ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | if ( ! function_exists( 'get_redux_instance' ) ) { |
| 97 | - /** |
|
| 98 | - * Shim function that some theme oddly used. |
|
| 99 | - * |
|
| 100 | - * @param string|false $opt_name the defined opt_name. |
|
| 101 | - * |
|
| 102 | - * @return ReduxFramework class instance |
|
| 103 | - */ |
|
| 104 | - function get_redux_instance( $opt_name ) { |
|
| 105 | - return Redux_Instances::get_instance( $opt_name ); |
|
| 106 | - } |
|
| 97 | + /** |
|
| 98 | + * Shim function that some theme oddly used. |
|
| 99 | + * |
|
| 100 | + * @param string|false $opt_name the defined opt_name. |
|
| 101 | + * |
|
| 102 | + * @return ReduxFramework class instance |
|
| 103 | + */ |
|
| 104 | + function get_redux_instance( $opt_name ) { |
|
| 105 | + return Redux_Instances::get_instance( $opt_name ); |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | if ( ! function_exists( 'get_all_redux_instances' ) ) { |
| 110 | - /** |
|
| 111 | - * Fetch all instances of ReduxFramework |
|
| 112 | - * as an associative array. |
|
| 113 | - * |
|
| 114 | - * @return array format ['opt_name' => $ReduxFramework] |
|
| 115 | - */ |
|
| 116 | - function get_all_redux_instances(): ?array { |
|
| 117 | - return Redux_Instances::get_all_instances(); |
|
| 118 | - } |
|
| 110 | + /** |
|
| 111 | + * Fetch all instances of ReduxFramework |
|
| 112 | + * as an associative array. |
|
| 113 | + * |
|
| 114 | + * @return array format ['opt_name' => $ReduxFramework] |
|
| 115 | + */ |
|
| 116 | + function get_all_redux_instances(): ?array { |
|
| 117 | + return Redux_Instances::get_all_instances(); |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -65,8 +65,8 @@ |
||
| 65 | 65 | public function save_network_page() { |
| 66 | 66 | $core = $this->core(); |
| 67 | 67 | |
| 68 | - if ( isset( $_POST[ $core->args['opt_name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 69 | - $opt_name = sanitize_text_field( wp_unslash( $_POST[ $core->args['opt_name'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 68 | + if ( isset( $_POST[$core->args['opt_name']] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 69 | + $opt_name = sanitize_text_field( wp_unslash( $_POST[$core->args['opt_name']] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $data = $core->options_class->validate_options( $opt_name ); |
@@ -11,81 +11,81 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Network', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Network |
|
| 16 | - */ |
|
| 17 | - class Redux_Network extends Redux_Class { |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Network |
|
| 16 | + */ |
|
| 17 | + class Redux_Network extends Redux_Class { |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Redux_Network constructor. |
|
| 21 | - * |
|
| 22 | - * @param object $redux ReduxFramework pointer. |
|
| 23 | - */ |
|
| 24 | - public function __construct( $redux ) { |
|
| 25 | - parent::__construct( $redux ); |
|
| 19 | + /** |
|
| 20 | + * Redux_Network constructor. |
|
| 21 | + * |
|
| 22 | + * @param object $redux ReduxFramework pointer. |
|
| 23 | + */ |
|
| 24 | + public function __construct( $redux ) { |
|
| 25 | + parent::__construct( $redux ); |
|
| 26 | 26 | |
| 27 | - if ( 'network' === $redux->args['database'] && $redux->args['network_admin'] ) { |
|
| 28 | - add_action( |
|
| 29 | - 'network_admin_edit_redux_' . $redux->args['opt_name'], |
|
| 30 | - array( |
|
| 31 | - $this, |
|
| 32 | - 'save_network_page', |
|
| 33 | - ), |
|
| 34 | - 10, |
|
| 35 | - 0 |
|
| 36 | - ); |
|
| 27 | + if ( 'network' === $redux->args['database'] && $redux->args['network_admin'] ) { |
|
| 28 | + add_action( |
|
| 29 | + 'network_admin_edit_redux_' . $redux->args['opt_name'], |
|
| 30 | + array( |
|
| 31 | + $this, |
|
| 32 | + 'save_network_page', |
|
| 33 | + ), |
|
| 34 | + 10, |
|
| 35 | + 0 |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | - // phpcs:ignore Generic.Strings.UnnecessaryStringConcat |
|
| 39 | - add_action( 'admin' . '_bar' . '_menu', array( $this, 'network_admin_bar' ), 999 ); |
|
| 40 | - } |
|
| 41 | - } |
|
| 38 | + // phpcs:ignore Generic.Strings.UnnecessaryStringConcat |
|
| 39 | + add_action( 'admin' . '_bar' . '_menu', array( $this, 'network_admin_bar' ), 999 ); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Add node to network admin bar. |
|
| 45 | - * |
|
| 46 | - * @param object $wp_admin_bar Admin bar. |
|
| 47 | - */ |
|
| 48 | - public function network_admin_bar( $wp_admin_bar ) { |
|
| 49 | - $core = $this->core(); |
|
| 43 | + /** |
|
| 44 | + * Add node to network admin bar. |
|
| 45 | + * |
|
| 46 | + * @param object $wp_admin_bar Admin bar. |
|
| 47 | + */ |
|
| 48 | + public function network_admin_bar( $wp_admin_bar ) { |
|
| 49 | + $core = $this->core(); |
|
| 50 | 50 | |
| 51 | - $args = array( |
|
| 52 | - 'id' => $core->args['opt_name'] . '_network_admin', |
|
| 53 | - 'title' => $core->args['menu_title'], |
|
| 54 | - 'parent' => 'network-admin', |
|
| 55 | - 'href' => network_admin_url( 'settings.php' ) . '?page=' . $core->args['page_slug'], |
|
| 56 | - 'meta' => array( 'class' => 'redux-network-admin' ), |
|
| 57 | - ); |
|
| 51 | + $args = array( |
|
| 52 | + 'id' => $core->args['opt_name'] . '_network_admin', |
|
| 53 | + 'title' => $core->args['menu_title'], |
|
| 54 | + 'parent' => 'network-admin', |
|
| 55 | + 'href' => network_admin_url( 'settings.php' ) . '?page=' . $core->args['page_slug'], |
|
| 56 | + 'meta' => array( 'class' => 'redux-network-admin' ), |
|
| 57 | + ); |
|
| 58 | 58 | |
| 59 | - $wp_admin_bar->add_node( $args ); |
|
| 60 | - } |
|
| 59 | + $wp_admin_bar->add_node( $args ); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Saves network options. |
|
| 64 | - */ |
|
| 65 | - public function save_network_page() { |
|
| 66 | - $core = $this->core(); |
|
| 62 | + /** |
|
| 63 | + * Saves network options. |
|
| 64 | + */ |
|
| 65 | + public function save_network_page() { |
|
| 66 | + $core = $this->core(); |
|
| 67 | 67 | |
| 68 | - if ( isset( $_POST[ $core->args['opt_name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 69 | - $opt_name = sanitize_text_field( wp_unslash( $_POST[ $core->args['opt_name'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 70 | - } |
|
| 68 | + if ( isset( $_POST[ $core->args['opt_name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 69 | + $opt_name = sanitize_text_field( wp_unslash( $_POST[ $core->args['opt_name'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $data = $core->options_class->validate_options( $opt_name ); |
|
| 72 | + $data = $core->options_class->validate_options( $opt_name ); |
|
| 73 | 73 | |
| 74 | - if ( ! empty( $data ) ) { |
|
| 75 | - $core->options_class->set( $data ); |
|
| 76 | - } |
|
| 74 | + if ( ! empty( $data ) ) { |
|
| 75 | + $core->options_class->set( $data ); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - wp_safe_redirect( |
|
| 79 | - add_query_arg( |
|
| 80 | - array( |
|
| 81 | - 'page' => $core->args['page_slug'], |
|
| 82 | - 'updated' => 'true', |
|
| 83 | - ), |
|
| 84 | - network_admin_url( 'settings.php' ) |
|
| 85 | - ) |
|
| 86 | - ); |
|
| 78 | + wp_safe_redirect( |
|
| 79 | + add_query_arg( |
|
| 80 | + array( |
|
| 81 | + 'page' => $core->args['page_slug'], |
|
| 82 | + 'updated' => 'true', |
|
| 83 | + ), |
|
| 84 | + network_admin_url( 'settings.php' ) |
|
| 85 | + ) |
|
| 86 | + ); |
|
| 87 | 87 | |
| 88 | - exit(); |
|
| 89 | - } |
|
| 90 | - } |
|
| 88 | + exit(); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | $search_values = preg_grep( '~' . $args['s'] . '~i', $values ); |
| 72 | 72 | if ( ! empty( $search_values ) ) { |
| 73 | 73 | foreach ( $search_values as $id => $val ) { |
| 74 | - $to_json[ $keys[ $id ] ] = array( |
|
| 75 | - 'id' => $keys[ $id ], |
|
| 74 | + $to_json[$keys[$id]] = array( |
|
| 75 | + 'id' => $keys[$id], |
|
| 76 | 76 | 'text' => $val, |
| 77 | 77 | ); |
| 78 | 78 | } |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | $search_keys = preg_grep( '~' . $args['s'] . '~i', $keys ); |
| 82 | 82 | if ( ! empty( $search_keys ) ) { |
| 83 | 83 | foreach ( $search_keys as $id => $val ) { |
| 84 | - $to_json[ $val ] = array( |
|
| 84 | + $to_json[$val] = array( |
|
| 85 | 85 | 'id' => $val, |
| 86 | - 'text' => $values[ $id ], |
|
| 86 | + 'text' => $values[$id], |
|
| 87 | 87 | ); |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -12,86 +12,86 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_AJAX_Select2', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_AJAX_Select2 |
|
| 17 | - */ |
|
| 18 | - class Redux_AJAX_Select2 extends Redux_Class { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_AJAX_Select2 |
|
| 17 | + */ |
|
| 18 | + class Redux_AJAX_Select2 extends Redux_Class { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Redux_AJAX_Select2 constructor. |
|
| 22 | - * |
|
| 23 | - * @param object $redux ReduxFramework object pointer. |
|
| 24 | - */ |
|
| 25 | - public function __construct( $redux ) { |
|
| 26 | - parent::__construct( $redux ); |
|
| 27 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 28 | - add_action( "wp_ajax_redux_{$redux->args['opt_name']}_select2", array( $this, 'ajax' ) ); |
|
| 29 | - } |
|
| 20 | + /** |
|
| 21 | + * Redux_AJAX_Select2 constructor. |
|
| 22 | + * |
|
| 23 | + * @param object $redux ReduxFramework object pointer. |
|
| 24 | + */ |
|
| 25 | + public function __construct( $redux ) { |
|
| 26 | + parent::__construct( $redux ); |
|
| 27 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 28 | + add_action( "wp_ajax_redux_{$redux->args['opt_name']}_select2", array( $this, 'ajax' ) ); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * AJAX callback for select2 match search. |
|
| 33 | - */ |
|
| 34 | - public function ajax() { |
|
| 35 | - $core = $this->core(); |
|
| 31 | + /** |
|
| 32 | + * AJAX callback for select2 match search. |
|
| 33 | + */ |
|
| 34 | + public function ajax() { |
|
| 35 | + $core = $this->core(); |
|
| 36 | 36 | |
| 37 | - if ( isset( $_REQUEST['nonce'] ) && isset( $_REQUEST['action'] ) ) { |
|
| 38 | - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ), sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) ) ) { |
|
| 39 | - wp_send_json_error( esc_html__( 'Invalid security credential. Please reload the page and try again.', 'redux-framework' ) ); |
|
| 40 | - } |
|
| 37 | + if ( isset( $_REQUEST['nonce'] ) && isset( $_REQUEST['action'] ) ) { |
|
| 38 | + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ), sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) ) ) { |
|
| 39 | + wp_send_json_error( esc_html__( 'Invalid security credential. Please reload the page and try again.', 'redux-framework' ) ); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - if ( ! Redux_Helpers::current_user_can( $this->parent->args['page_permissions'] ) ) { |
|
| 43 | - wp_send_json_error( esc_html__( 'Invalid user capability. Please reload the page and try again.', 'redux-framework' ) ); |
|
| 44 | - } |
|
| 42 | + if ( ! Redux_Helpers::current_user_can( $this->parent->args['page_permissions'] ) ) { |
|
| 43 | + wp_send_json_error( esc_html__( 'Invalid user capability. Please reload the page and try again.', 'redux-framework' ) ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - if ( isset( $_REQUEST['data'] ) ) { |
|
| 46 | + if ( isset( $_REQUEST['data'] ) ) { |
|
| 47 | 47 | |
| 48 | - $args = isset( $_REQUEST['data_args'] ) ? json_decode( sanitize_text_field( wp_unslash( $_REQUEST['data_args'] ) ), true ) : array(); |
|
| 49 | - $args = wp_parse_args( |
|
| 50 | - $args, |
|
| 51 | - array( |
|
| 52 | - 's' => isset( $_REQUEST['q'] ) && ! empty( $_REQUEST['q'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['q'] ) ) : '', |
|
| 53 | - ) |
|
| 54 | - ); |
|
| 48 | + $args = isset( $_REQUEST['data_args'] ) ? json_decode( sanitize_text_field( wp_unslash( $_REQUEST['data_args'] ) ), true ) : array(); |
|
| 49 | + $args = wp_parse_args( |
|
| 50 | + $args, |
|
| 51 | + array( |
|
| 52 | + 's' => isset( $_REQUEST['q'] ) && ! empty( $_REQUEST['q'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['q'] ) ) : '', |
|
| 53 | + ) |
|
| 54 | + ); |
|
| 55 | 55 | |
| 56 | - if ( isset( $_REQUEST['q'] ) && ! empty( $_REQUEST['q'] ) ) { |
|
| 57 | - $criteria = sanitize_text_field( wp_unslash( $_REQUEST['q'] ) ); |
|
| 58 | - $args['s'] = $criteria; |
|
| 59 | - } |
|
| 56 | + if ( isset( $_REQUEST['q'] ) && ! empty( $_REQUEST['q'] ) ) { |
|
| 57 | + $criteria = sanitize_text_field( wp_unslash( $_REQUEST['q'] ) ); |
|
| 58 | + $args['s'] = $criteria; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $return = $core->wordpress_data->get( sanitize_text_field( wp_unslash( $_REQUEST['data'] ) ), $args ); |
|
| 61 | + $return = $core->wordpress_data->get( sanitize_text_field( wp_unslash( $_REQUEST['data'] ) ), $args ); |
|
| 62 | 62 | |
| 63 | - if ( is_array( $return ) && ! empty( $_REQUEST['action'] ) ) { |
|
| 64 | - if ( ! empty( $args['s'] ) ) { |
|
| 65 | - $keys = array_keys( $return ); |
|
| 66 | - $values = array_values( $return ); |
|
| 63 | + if ( is_array( $return ) && ! empty( $_REQUEST['action'] ) ) { |
|
| 64 | + if ( ! empty( $args['s'] ) ) { |
|
| 65 | + $keys = array_keys( $return ); |
|
| 66 | + $values = array_values( $return ); |
|
| 67 | 67 | |
| 68 | - $to_json = array(); |
|
| 68 | + $to_json = array(); |
|
| 69 | 69 | |
| 70 | - // Search all the values. |
|
| 71 | - $search_values = preg_grep( '~' . $args['s'] . '~i', $values ); |
|
| 72 | - if ( ! empty( $search_values ) ) { |
|
| 73 | - foreach ( $search_values as $id => $val ) { |
|
| 74 | - $to_json[ $keys[ $id ] ] = array( |
|
| 75 | - 'id' => $keys[ $id ], |
|
| 76 | - 'text' => $val, |
|
| 77 | - ); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - // Search all the keys. |
|
| 81 | - $search_keys = preg_grep( '~' . $args['s'] . '~i', $keys ); |
|
| 82 | - if ( ! empty( $search_keys ) ) { |
|
| 83 | - foreach ( $search_keys as $id => $val ) { |
|
| 84 | - $to_json[ $val ] = array( |
|
| 85 | - 'id' => $val, |
|
| 86 | - 'text' => $values[ $id ], |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - wp_send_json_success( array_values( $to_json ) ); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 70 | + // Search all the values. |
|
| 71 | + $search_values = preg_grep( '~' . $args['s'] . '~i', $values ); |
|
| 72 | + if ( ! empty( $search_values ) ) { |
|
| 73 | + foreach ( $search_values as $id => $val ) { |
|
| 74 | + $to_json[ $keys[ $id ] ] = array( |
|
| 75 | + 'id' => $keys[ $id ], |
|
| 76 | + 'text' => $val, |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + // Search all the keys. |
|
| 81 | + $search_keys = preg_grep( '~' . $args['s'] . '~i', $keys ); |
|
| 82 | + if ( ! empty( $search_keys ) ) { |
|
| 83 | + foreach ( $search_keys as $id => $val ) { |
|
| 84 | + $to_json[ $val ] = array( |
|
| 85 | + 'id' => $val, |
|
| 86 | + 'text' => $values[ $id ], |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + wp_send_json_success( array_values( $to_json ) ); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | // phpcs:ignore WordPress.PHP.DontExtract |
| 76 | 76 | extract( $data ); |
| 77 | 77 | |
| 78 | - self::$notices[ $parent->args['page_slug'] ][] = array( |
|
| 78 | + self::$notices[$parent->args['page_slug']][] = array( |
|
| 79 | 79 | 'type' => $type, |
| 80 | 80 | 'msg' => $msg, |
| 81 | 81 | 'id' => $id . '_' . $parent->args['opt_name'], |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // Check for an active admin notice array. |
| 105 | 105 | if ( ! empty( $notices ) ) { |
| 106 | - if ( isset( $notices[ $core->args['page_slug'] ] ) ) { |
|
| 106 | + if ( isset( $notices[$core->args['page_slug']] ) ) { |
|
| 107 | 107 | // Enum admin notices. |
| 108 | - foreach ( $notices[ $core->args['page_slug'] ] as $notice ) { |
|
| 108 | + foreach ( $notices[$core->args['page_slug']] as $notice ) { |
|
| 109 | 109 | |
| 110 | 110 | $add_style = ''; |
| 111 | 111 | if ( strpos( $notice['type'], 'redux-message' ) !== false ) { |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | // Clear the admin notice array. |
| 165 | - self::$notices[ $core->args['opt_name'] ] = array(); |
|
| 165 | + self::$notices[$core->args['opt_name']] = array(); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
@@ -14,133 +14,133 @@ discard block |
||
| 14 | 14 | // Don't duplicate me! |
| 15 | 15 | if ( ! class_exists( 'Redux_Admin_Notices', false ) ) { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Redux Admin Notices Class |
|
| 19 | - * |
|
| 20 | - * @since 3.0.0 |
|
| 21 | - */ |
|
| 22 | - class Redux_Admin_Notices extends Redux_Class { |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * WordPress admin notice array. |
|
| 26 | - * |
|
| 27 | - * @var array |
|
| 28 | - * @access private |
|
| 29 | - */ |
|
| 30 | - private static array $notices = array(); |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Redux_Admin_Notices constructor. |
|
| 34 | - * |
|
| 35 | - * @param array $redux ReduxFramework object. |
|
| 36 | - * @access public |
|
| 37 | - */ |
|
| 38 | - public function __construct( $redux ) { |
|
| 39 | - parent::__construct( $redux ); |
|
| 40 | - |
|
| 41 | - add_action( 'wp_ajax_redux_hide_admin_notice', array( $this, 'ajax' ) ); |
|
| 42 | - add_action( 'admin_notices', array( $this, 'notices' ), 99 ); |
|
| 43 | - add_action( 'admin_init', array( $this, 'dismiss' ), 9 ); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Display notices stored in a notice array. |
|
| 48 | - * |
|
| 49 | - * @access public |
|
| 50 | - */ |
|
| 51 | - public function notices() { |
|
| 52 | - $this->admin_notices( self::$notices ); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Dismisses admin notice |
|
| 57 | - * |
|
| 58 | - * @access public |
|
| 59 | - */ |
|
| 60 | - public function dismiss() { |
|
| 61 | - $this->dismiss_admin_notice(); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Sets an admin notice for display. |
|
| 66 | - * |
|
| 67 | - * @param array $data Notice data. |
|
| 68 | - */ |
|
| 69 | - public static function set_notice( array $data ) { |
|
| 70 | - $type = null; |
|
| 71 | - $msg = null; |
|
| 72 | - $id = null; |
|
| 73 | - $dismiss = null; |
|
| 74 | - |
|
| 75 | - // phpcs:ignore WordPress.PHP.DontExtract |
|
| 76 | - extract( $data ); |
|
| 77 | - |
|
| 78 | - self::$notices[ $parent->args['page_slug'] ][] = array( |
|
| 79 | - 'type' => $type, |
|
| 80 | - 'msg' => $msg, |
|
| 81 | - 'id' => $id . '_' . $parent->args['opt_name'], |
|
| 82 | - 'dismiss' => $dismiss, |
|
| 83 | - 'color' => $color ?? '#00A2E3', |
|
| 84 | - ); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Evaluates a user-dismissed option for displaying admin notices. |
|
| 89 | - * |
|
| 90 | - * @param array $notices Array of stored notices to display. |
|
| 91 | - * |
|
| 92 | - * @return void |
|
| 93 | - * @since 3.2.0 |
|
| 94 | - * @access public |
|
| 95 | - */ |
|
| 96 | - public function admin_notices( array $notices = array() ) { |
|
| 97 | - global $current_user; |
|
| 98 | - |
|
| 99 | - $core = $this->core(); |
|
| 100 | - if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 101 | - do_action( 'redux_admin_notices_run', $core->args ); |
|
| 102 | - |
|
| 103 | - // Check for an active admin notice array. |
|
| 104 | - if ( ! empty( $notices ) ) { |
|
| 105 | - if ( isset( $notices[ $core->args['page_slug'] ] ) ) { |
|
| 106 | - // Enum admin notices. |
|
| 107 | - foreach ( $notices[ $core->args['page_slug'] ] as $notice ) { |
|
| 108 | - |
|
| 109 | - $add_style = ''; |
|
| 110 | - if ( strpos( $notice['type'], 'redux-message' ) !== false ) { |
|
| 111 | - $add_style = 'style="border-left: 4px solid ' . esc_attr( $notice['color'] ) . '!important;"'; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - if ( true === $notice['dismiss'] ) { |
|
| 115 | - |
|
| 116 | - // Get user ID. |
|
| 117 | - $userid = $current_user->ID; |
|
| 118 | - |
|
| 119 | - if ( ! get_user_meta( $userid, 'ignore_' . $notice['id'] ) ) { |
|
| 120 | - global $wp_version; |
|
| 121 | - |
|
| 122 | - $css_id = ''; |
|
| 123 | - |
|
| 124 | - // Print the notice with the dismiss link. |
|
| 125 | - if ( version_compare( $wp_version, '4.2', '>' ) ) { |
|
| 126 | - $css_id = esc_attr( $notice['id'] ); |
|
| 127 | - $css_class = esc_attr( $notice['type'] ) . ' redux-notice notice is-dismissible redux-notice'; |
|
| 128 | - |
|
| 129 | - $nonce = wp_create_nonce( $notice['id'] . $userid . 'nonce' ); |
|
| 130 | - |
|
| 131 | - echo '<div ' . $add_style . ' id="' . esc_attr( $css_id ) . '" class="' . esc_attr( $css_class ) . '">'; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 132 | - echo '<input type="hidden" class="dismiss_data" id="' . esc_attr( $css_id ) . '" value="' . esc_attr( $nonce ) . '">'; |
|
| 133 | - echo '<p>' . wp_kses_post( $notice['msg'] ) . '</p>'; |
|
| 134 | - echo '</div>'; |
|
| 135 | - } else { |
|
| 136 | - echo '<div ' . esc_html( $add_style ) . ' class="' . esc_attr( $notice['type'] ) . ' notice is-dismissable"><p>' . wp_kses_post( $notice['msg'] ) . ' <a href="?dismiss=true&id=' . esc_attr( $css_id ) . '">' . esc_html__( 'Dismiss', 'redux-framework' ) . '</a>.</p></div>'; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - // Standard notice. |
|
| 141 | - echo '<div ' . esc_html( $add_style ) . ' class="' . esc_attr( $notice['type'] ) . ' notice"><p>' . wp_kses_post( $notice['msg'] ) . '</a>.</p></div>'; |
|
| 142 | - } |
|
| 143 | - ?> |
|
| 17 | + /** |
|
| 18 | + * Redux Admin Notices Class |
|
| 19 | + * |
|
| 20 | + * @since 3.0.0 |
|
| 21 | + */ |
|
| 22 | + class Redux_Admin_Notices extends Redux_Class { |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * WordPress admin notice array. |
|
| 26 | + * |
|
| 27 | + * @var array |
|
| 28 | + * @access private |
|
| 29 | + */ |
|
| 30 | + private static array $notices = array(); |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Redux_Admin_Notices constructor. |
|
| 34 | + * |
|
| 35 | + * @param array $redux ReduxFramework object. |
|
| 36 | + * @access public |
|
| 37 | + */ |
|
| 38 | + public function __construct( $redux ) { |
|
| 39 | + parent::__construct( $redux ); |
|
| 40 | + |
|
| 41 | + add_action( 'wp_ajax_redux_hide_admin_notice', array( $this, 'ajax' ) ); |
|
| 42 | + add_action( 'admin_notices', array( $this, 'notices' ), 99 ); |
|
| 43 | + add_action( 'admin_init', array( $this, 'dismiss' ), 9 ); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Display notices stored in a notice array. |
|
| 48 | + * |
|
| 49 | + * @access public |
|
| 50 | + */ |
|
| 51 | + public function notices() { |
|
| 52 | + $this->admin_notices( self::$notices ); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Dismisses admin notice |
|
| 57 | + * |
|
| 58 | + * @access public |
|
| 59 | + */ |
|
| 60 | + public function dismiss() { |
|
| 61 | + $this->dismiss_admin_notice(); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Sets an admin notice for display. |
|
| 66 | + * |
|
| 67 | + * @param array $data Notice data. |
|
| 68 | + */ |
|
| 69 | + public static function set_notice( array $data ) { |
|
| 70 | + $type = null; |
|
| 71 | + $msg = null; |
|
| 72 | + $id = null; |
|
| 73 | + $dismiss = null; |
|
| 74 | + |
|
| 75 | + // phpcs:ignore WordPress.PHP.DontExtract |
|
| 76 | + extract( $data ); |
|
| 77 | + |
|
| 78 | + self::$notices[ $parent->args['page_slug'] ][] = array( |
|
| 79 | + 'type' => $type, |
|
| 80 | + 'msg' => $msg, |
|
| 81 | + 'id' => $id . '_' . $parent->args['opt_name'], |
|
| 82 | + 'dismiss' => $dismiss, |
|
| 83 | + 'color' => $color ?? '#00A2E3', |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Evaluates a user-dismissed option for displaying admin notices. |
|
| 89 | + * |
|
| 90 | + * @param array $notices Array of stored notices to display. |
|
| 91 | + * |
|
| 92 | + * @return void |
|
| 93 | + * @since 3.2.0 |
|
| 94 | + * @access public |
|
| 95 | + */ |
|
| 96 | + public function admin_notices( array $notices = array() ) { |
|
| 97 | + global $current_user; |
|
| 98 | + |
|
| 99 | + $core = $this->core(); |
|
| 100 | + if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 101 | + do_action( 'redux_admin_notices_run', $core->args ); |
|
| 102 | + |
|
| 103 | + // Check for an active admin notice array. |
|
| 104 | + if ( ! empty( $notices ) ) { |
|
| 105 | + if ( isset( $notices[ $core->args['page_slug'] ] ) ) { |
|
| 106 | + // Enum admin notices. |
|
| 107 | + foreach ( $notices[ $core->args['page_slug'] ] as $notice ) { |
|
| 108 | + |
|
| 109 | + $add_style = ''; |
|
| 110 | + if ( strpos( $notice['type'], 'redux-message' ) !== false ) { |
|
| 111 | + $add_style = 'style="border-left: 4px solid ' . esc_attr( $notice['color'] ) . '!important;"'; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + if ( true === $notice['dismiss'] ) { |
|
| 115 | + |
|
| 116 | + // Get user ID. |
|
| 117 | + $userid = $current_user->ID; |
|
| 118 | + |
|
| 119 | + if ( ! get_user_meta( $userid, 'ignore_' . $notice['id'] ) ) { |
|
| 120 | + global $wp_version; |
|
| 121 | + |
|
| 122 | + $css_id = ''; |
|
| 123 | + |
|
| 124 | + // Print the notice with the dismiss link. |
|
| 125 | + if ( version_compare( $wp_version, '4.2', '>' ) ) { |
|
| 126 | + $css_id = esc_attr( $notice['id'] ); |
|
| 127 | + $css_class = esc_attr( $notice['type'] ) . ' redux-notice notice is-dismissible redux-notice'; |
|
| 128 | + |
|
| 129 | + $nonce = wp_create_nonce( $notice['id'] . $userid . 'nonce' ); |
|
| 130 | + |
|
| 131 | + echo '<div ' . $add_style . ' id="' . esc_attr( $css_id ) . '" class="' . esc_attr( $css_class ) . '">'; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 132 | + echo '<input type="hidden" class="dismiss_data" id="' . esc_attr( $css_id ) . '" value="' . esc_attr( $nonce ) . '">'; |
|
| 133 | + echo '<p>' . wp_kses_post( $notice['msg'] ) . '</p>'; |
|
| 134 | + echo '</div>'; |
|
| 135 | + } else { |
|
| 136 | + echo '<div ' . esc_html( $add_style ) . ' class="' . esc_attr( $notice['type'] ) . ' notice is-dismissable"><p>' . wp_kses_post( $notice['msg'] ) . ' <a href="?dismiss=true&id=' . esc_attr( $css_id ) . '">' . esc_html__( 'Dismiss', 'redux-framework' ) . '</a>.</p></div>'; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + // Standard notice. |
|
| 141 | + echo '<div ' . esc_html( $add_style ) . ' class="' . esc_attr( $notice['type'] ) . ' notice"><p>' . wp_kses_post( $notice['msg'] ) . '</a>.</p></div>'; |
|
| 142 | + } |
|
| 143 | + ?> |
|
| 144 | 144 | <script> |
| 145 | 145 | document.addEventListener( |
| 146 | 146 | 'DOMContentLoaded', |
@@ -163,70 +163,70 @@ discard block |
||
| 163 | 163 | </script> |
| 164 | 164 | <?php |
| 165 | 165 | |
| 166 | - } |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - // Clear the admin notice array. |
|
| 170 | - self::$notices[ $core->args['opt_name'] ] = array(); |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Updates user meta to store dismiss notice preference. |
|
| 176 | - * |
|
| 177 | - * @since 3.2.0 |
|
| 178 | - * @access private |
|
| 179 | - * @return void |
|
| 180 | - */ |
|
| 181 | - private function dismiss_admin_notice() { |
|
| 182 | - global $current_user; |
|
| 183 | - |
|
| 184 | - // Verify the dismissed notice and id parameters are present. |
|
| 185 | - if ( isset( $_GET['dismiss'] ) && isset( $_GET['id'] ) ) { |
|
| 186 | - if ( isset( $_GET['nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_GET['nonce'] ) ), 'redux_hint_toggle' ) ) { |
|
| 187 | - if ( 'true' === $_GET['dismiss'] || 'false' === $_GET['dismiss'] ) { |
|
| 188 | - |
|
| 189 | - // Get the user id. |
|
| 190 | - $userid = $current_user->ID; |
|
| 191 | - |
|
| 192 | - // Get the notice id. |
|
| 193 | - $id = sanitize_text_field( wp_unslash( $_GET['id'] ) ); |
|
| 194 | - $val = sanitize_text_field( wp_unslash( $_GET['dismiss'] ) ); |
|
| 195 | - |
|
| 196 | - // Add the dismissed request to the user meta. |
|
| 197 | - update_user_meta( $userid, 'ignore_' . $id, $val ); |
|
| 198 | - } |
|
| 199 | - } else { |
|
| 200 | - wp_nonce_ays( 'redux_hint_toggle' ); |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Updates user meta to store dismiss notice preference |
|
| 207 | - * |
|
| 208 | - * @since 3.2.0 |
|
| 209 | - * @access public |
|
| 210 | - * @return void |
|
| 211 | - */ |
|
| 212 | - public function ajax() { |
|
| 213 | - global $current_user; |
|
| 214 | - |
|
| 215 | - if ( isset( $_POST['id'] ) ) { |
|
| 216 | - // Get the notice id. |
|
| 217 | - $id = explode( '&', sanitize_text_field( wp_unslash( $_POST['id'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 218 | - $id = $id[0]; |
|
| 219 | - |
|
| 220 | - // Get the user id. |
|
| 221 | - $userid = $current_user->ID; |
|
| 222 | - |
|
| 223 | - if ( ! isset( $_POST['nonce'] ) || ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), $id . $userid . 'nonce' ) ) ) { |
|
| 224 | - die( 0 ); |
|
| 225 | - } else { |
|
| 226 | - // Add the dismissed request to the user meta. |
|
| 227 | - update_user_meta( $userid, 'ignore_' . $id, true ); |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - } |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + // Clear the admin notice array. |
|
| 170 | + self::$notices[ $core->args['opt_name'] ] = array(); |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Updates user meta to store dismiss notice preference. |
|
| 176 | + * |
|
| 177 | + * @since 3.2.0 |
|
| 178 | + * @access private |
|
| 179 | + * @return void |
|
| 180 | + */ |
|
| 181 | + private function dismiss_admin_notice() { |
|
| 182 | + global $current_user; |
|
| 183 | + |
|
| 184 | + // Verify the dismissed notice and id parameters are present. |
|
| 185 | + if ( isset( $_GET['dismiss'] ) && isset( $_GET['id'] ) ) { |
|
| 186 | + if ( isset( $_GET['nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_GET['nonce'] ) ), 'redux_hint_toggle' ) ) { |
|
| 187 | + if ( 'true' === $_GET['dismiss'] || 'false' === $_GET['dismiss'] ) { |
|
| 188 | + |
|
| 189 | + // Get the user id. |
|
| 190 | + $userid = $current_user->ID; |
|
| 191 | + |
|
| 192 | + // Get the notice id. |
|
| 193 | + $id = sanitize_text_field( wp_unslash( $_GET['id'] ) ); |
|
| 194 | + $val = sanitize_text_field( wp_unslash( $_GET['dismiss'] ) ); |
|
| 195 | + |
|
| 196 | + // Add the dismissed request to the user meta. |
|
| 197 | + update_user_meta( $userid, 'ignore_' . $id, $val ); |
|
| 198 | + } |
|
| 199 | + } else { |
|
| 200 | + wp_nonce_ays( 'redux_hint_toggle' ); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Updates user meta to store dismiss notice preference |
|
| 207 | + * |
|
| 208 | + * @since 3.2.0 |
|
| 209 | + * @access public |
|
| 210 | + * @return void |
|
| 211 | + */ |
|
| 212 | + public function ajax() { |
|
| 213 | + global $current_user; |
|
| 214 | + |
|
| 215 | + if ( isset( $_POST['id'] ) ) { |
|
| 216 | + // Get the notice id. |
|
| 217 | + $id = explode( '&', sanitize_text_field( wp_unslash( $_POST['id'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 218 | + $id = $id[0]; |
|
| 219 | + |
|
| 220 | + // Get the user id. |
|
| 221 | + $userid = $current_user->ID; |
|
| 222 | + |
|
| 223 | + if ( ! isset( $_POST['nonce'] ) || ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), $id . $userid . 'nonce' ) ) ) { |
|
| 224 | + die( 0 ); |
|
| 225 | + } else { |
|
| 226 | + // Add the dismissed request to the user meta. |
|
| 227 | + update_user_meta( $userid, 'ignore_' . $id, true ); |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | 232 | } |
@@ -11,31 +11,31 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Transients', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Transients |
|
| 16 | - */ |
|
| 17 | - class Redux_Transients extends Redux_Class { |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Transients |
|
| 16 | + */ |
|
| 17 | + class Redux_Transients extends Redux_Class { |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get transients from database. |
|
| 21 | - */ |
|
| 22 | - public function get() { |
|
| 23 | - $core = $this->core(); |
|
| 19 | + /** |
|
| 20 | + * Get transients from database. |
|
| 21 | + */ |
|
| 22 | + public function get() { |
|
| 23 | + $core = $this->core(); |
|
| 24 | 24 | |
| 25 | - if ( empty( $core->transients ) ) { |
|
| 26 | - $core->transients = get_option( $core->args['opt_name'] . '-transients', array() ); |
|
| 27 | - } |
|
| 28 | - } |
|
| 25 | + if ( empty( $core->transients ) ) { |
|
| 26 | + $core->transients = get_option( $core->args['opt_name'] . '-transients', array() ); |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Set transients in database. |
|
| 32 | - */ |
|
| 33 | - public function set() { |
|
| 34 | - $core = $this->core(); |
|
| 30 | + /** |
|
| 31 | + * Set transients in database. |
|
| 32 | + */ |
|
| 33 | + public function set() { |
|
| 34 | + $core = $this->core(); |
|
| 35 | 35 | |
| 36 | - if ( ! isset( $core->transients ) || ! isset( $core->transients_check ) || $core->transients_check !== $core->transients ) { |
|
| 37 | - update_option( $core->args['opt_name'] . '-transients', $core->transients ); |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - } |
|
| 36 | + if ( ! isset( $core->transients ) || ! isset( $core->transients_check ) || $core->transients_check !== $core->transients ) { |
|
| 37 | + update_option( $core->args['opt_name'] . '-transients', $core->transients ); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | foreach ( $blacklist as $file => $reason ) { |
| 56 | 56 | checkcount(); |
| 57 | 57 | if ( file_exists( $redux['parent_dir'] . $file ) ) { |
| 58 | - $errors[ $redux['parent_dir'] . $file ] = $reason; |
|
| 58 | + $errors[$redux['parent_dir'] . $file] = $reason; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -14,71 +14,71 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Redux_Full_Package implements themecheck { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Themecheck error array. |
|
| 19 | - * |
|
| 20 | - * @var array $error Error storage. |
|
| 21 | - */ |
|
| 22 | - protected array $error = array(); |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Check files. |
|
| 26 | - * |
|
| 27 | - * @param array $php_files File to check. |
|
| 28 | - * @param array $css_files Files to check. |
|
| 29 | - * @param array $other_files Files to check. |
|
| 30 | - * |
|
| 31 | - * @return bool |
|
| 32 | - */ |
|
| 33 | - public function check( $php_files, $css_files, $other_files ): bool { |
|
| 34 | - |
|
| 35 | - $ret = true; |
|
| 36 | - |
|
| 37 | - $check = Redux_ThemeCheck::get_instance(); |
|
| 38 | - $redux = $check::get_redux_details( $php_files ); |
|
| 39 | - |
|
| 40 | - if ( $redux ) { |
|
| 41 | - |
|
| 42 | - $blacklist = array( |
|
| 43 | - 'codestyles' => esc_html__( 'Redux Code Styles', 'redux-framework' ), |
|
| 44 | - 'class-redux-framework-plugin.php' => esc_html__( 'Redux Plugin File', 'redux-framework' ), |
|
| 45 | - '.travis.yml' => esc_html__( 'CI Testing File', 'redux-framework' ), |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - $errors = array(); |
|
| 49 | - |
|
| 50 | - foreach ( $blacklist as $file => $reason ) { |
|
| 51 | - checkcount(); |
|
| 52 | - if ( file_exists( $redux['parent_dir'] . $file ) ) { |
|
| 53 | - $errors[ $redux['parent_dir'] . $file ] = $reason; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if ( ! empty( $errors ) ) { |
|
| 58 | - $error = '<span class="tc-lead tc-required">REQUIRED</span> ' . esc_html__( 'It appears that you have embedded the full Redux package inside your theme. You need only embed the', 'redux-framework' ) . ' <strong>redux-core</strong> ' . esc_html__( 'folder. Embedding anything else will get your rejected from theme submission. Suspected Redux package file(s):', 'redux-framework' ); |
|
| 59 | - $error .= '<ol>'; |
|
| 60 | - |
|
| 61 | - foreach ( $errors as $key => $e ) { |
|
| 62 | - $error .= '<li><strong>' . $e . '</strong>: ' . $key . '</li>'; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $error .= '</ol>'; |
|
| 66 | - $this->error[] = '<div class="redux-error">' . $error . '</div>'; |
|
| 67 | - $ret = false; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - return $ret; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Retrieve errors. |
|
| 76 | - * |
|
| 77 | - * @return array |
|
| 78 | - */ |
|
| 79 | - public function getError(): array { |
|
| 80 | - return $this->error; |
|
| 81 | - } |
|
| 17 | + /** |
|
| 18 | + * Themecheck error array. |
|
| 19 | + * |
|
| 20 | + * @var array $error Error storage. |
|
| 21 | + */ |
|
| 22 | + protected array $error = array(); |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Check files. |
|
| 26 | + * |
|
| 27 | + * @param array $php_files File to check. |
|
| 28 | + * @param array $css_files Files to check. |
|
| 29 | + * @param array $other_files Files to check. |
|
| 30 | + * |
|
| 31 | + * @return bool |
|
| 32 | + */ |
|
| 33 | + public function check( $php_files, $css_files, $other_files ): bool { |
|
| 34 | + |
|
| 35 | + $ret = true; |
|
| 36 | + |
|
| 37 | + $check = Redux_ThemeCheck::get_instance(); |
|
| 38 | + $redux = $check::get_redux_details( $php_files ); |
|
| 39 | + |
|
| 40 | + if ( $redux ) { |
|
| 41 | + |
|
| 42 | + $blacklist = array( |
|
| 43 | + 'codestyles' => esc_html__( 'Redux Code Styles', 'redux-framework' ), |
|
| 44 | + 'class-redux-framework-plugin.php' => esc_html__( 'Redux Plugin File', 'redux-framework' ), |
|
| 45 | + '.travis.yml' => esc_html__( 'CI Testing File', 'redux-framework' ), |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + $errors = array(); |
|
| 49 | + |
|
| 50 | + foreach ( $blacklist as $file => $reason ) { |
|
| 51 | + checkcount(); |
|
| 52 | + if ( file_exists( $redux['parent_dir'] . $file ) ) { |
|
| 53 | + $errors[ $redux['parent_dir'] . $file ] = $reason; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if ( ! empty( $errors ) ) { |
|
| 58 | + $error = '<span class="tc-lead tc-required">REQUIRED</span> ' . esc_html__( 'It appears that you have embedded the full Redux package inside your theme. You need only embed the', 'redux-framework' ) . ' <strong>redux-core</strong> ' . esc_html__( 'folder. Embedding anything else will get your rejected from theme submission. Suspected Redux package file(s):', 'redux-framework' ); |
|
| 59 | + $error .= '<ol>'; |
|
| 60 | + |
|
| 61 | + foreach ( $errors as $key => $e ) { |
|
| 62 | + $error .= '<li><strong>' . $e . '</strong>: ' . $key . '</li>'; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $error .= '</ol>'; |
|
| 66 | + $this->error[] = '<div class="redux-error">' . $error . '</div>'; |
|
| 67 | + $ret = false; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + return $ret; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Retrieve errors. |
|
| 76 | + * |
|
| 77 | + * @return array |
|
| 78 | + */ |
|
| 79 | + public function getError(): array { |
|
| 80 | + return $this->error; |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $themechecks[] = new Redux_Full_Package(); |
@@ -122,7 +122,7 @@ |
||
| 122 | 122 | |
| 123 | 123 | // phpcs:ignore Generic.Strings.UnnecessaryStringConcat |
| 124 | 124 | if ( false !== strpos( $phpfile, 'class' . ' ReduxFramework {' ) ) { |
| 125 | - self::$redux_details = array( |
|
| 125 | + self::$redux_details = array( |
|
| 126 | 126 | 'filename' => Redux_Core::strtolower( basename( $php_key ) ), |
| 127 | 127 | 'path' => $php_key, |
| 128 | 128 | ); |
@@ -12,221 +12,221 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_ThemeCheck', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_ThemeCheck |
|
| 17 | - */ |
|
| 18 | - class Redux_ThemeCheck { |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Plugin version, used for cache-busting of style and script file references. |
|
| 22 | - * |
|
| 23 | - * @since 1.0.0 |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - protected string $version = '1.0.0'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Instance of this class. |
|
| 30 | - * |
|
| 31 | - * @since 1.0.0 |
|
| 32 | - * @var Redux_ThemeCheck|null |
|
| 33 | - */ |
|
| 34 | - protected static ?Redux_ThemeCheck $instance = null; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Instance of the Redux class. |
|
| 38 | - * |
|
| 39 | - * @since 1.0.0 |
|
| 40 | - * @var ReduxFramework|null |
|
| 41 | - */ |
|
| 42 | - protected static ?ReduxFramework $redux; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Details of the embedded Redux class. |
|
| 46 | - * |
|
| 47 | - * @since 1.0.0 |
|
| 48 | - * @var mixed|null |
|
| 49 | - */ |
|
| 50 | - protected static $redux_details = array(); |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Slug for various elements. |
|
| 54 | - * |
|
| 55 | - * @since 1.0.0 |
|
| 56 | - * @var string |
|
| 57 | - */ |
|
| 58 | - protected string $slug = 'redux_themecheck'; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - */ |
|
| 65 | - private function __construct() { |
|
| 66 | - if ( ! class_exists( 'ThemeCheckMain' ) ) { |
|
| 67 | - return; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // Load the admin stylesheet and JavaScript. |
|
| 71 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) ); |
|
| 72 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); |
|
| 73 | - |
|
| 74 | - add_action( 'themecheck_checks_loaded', array( $this, 'disable_checks' ) ); |
|
| 75 | - add_action( 'themecheck_checks_loaded', array( $this, 'add_checks' ) ); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Return an instance of this class. |
|
| 80 | - * |
|
| 81 | - * @since 1.0.0 |
|
| 82 | - * @return object A single instance of this class. |
|
| 83 | - */ |
|
| 84 | - public static function get_instance() { |
|
| 85 | - |
|
| 86 | - // If the single instance hasn't been set, set it now. |
|
| 87 | - if ( null === self::$instance ) { |
|
| 88 | - self::$instance = new self(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return self::$instance; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Return an instance of this class. |
|
| 96 | - * |
|
| 97 | - * @since 1.0.0 |
|
| 98 | - * @return object A single instance of this class. |
|
| 99 | - */ |
|
| 100 | - public static function get_redux_instance() { |
|
| 101 | - |
|
| 102 | - // If the single instance hasn't been set, set it now. |
|
| 103 | - if ( null === self::$redux && Redux_Core::$as_plugin ) { |
|
| 104 | - self::$redux = new ReduxFramework(); |
|
| 105 | - self::$redux->init(); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - return self::$redux; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Return the Redux path info, if had. |
|
| 113 | - * |
|
| 114 | - * @param array $php_files Array of files to check. |
|
| 115 | - * |
|
| 116 | - * @return array|false|null A single instance of this class. |
|
| 117 | - * @since 1.0.0 |
|
| 118 | - */ |
|
| 119 | - public static function get_redux_details( array $php_files = array() ) { |
|
| 120 | - if ( null === self::$redux_details ) { |
|
| 121 | - foreach ( $php_files as $php_key => $phpfile ) { |
|
| 122 | - |
|
| 123 | - // phpcs:ignore Generic.Strings.UnnecessaryStringConcat |
|
| 124 | - if ( false !== strpos( $phpfile, 'class' . ' ReduxFramework {' ) ) { |
|
| 125 | - self::$redux_details = array( |
|
| 126 | - 'filename' => Redux_Core::strtolower( basename( $php_key ) ), |
|
| 127 | - 'path' => $php_key, |
|
| 128 | - ); |
|
| 129 | - self::$redux_details['dir'] = str_replace( basename( $php_key ), '', $php_key ); |
|
| 130 | - self::$redux_details['parent_dir'] = str_replace( basename( self::$redux_details['dir'] ) . '/', '', self::$redux_details['dir'] ); |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - if ( null === self::$redux_details ) { |
|
| 135 | - self::$redux_details = false; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return self::$redux_details; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Disable Theme-Check checks that aren't relevant for ThemeForest themes |
|
| 143 | - * |
|
| 144 | - * @since 1.0.0 |
|
| 145 | - */ |
|
| 146 | - public function disable_checks() { |
|
| 147 | - /** |
|
| 148 | - * Uncomment code to use. |
|
| 149 | - * |
|
| 150 | - * global $themechecks; |
|
| 151 | - * |
|
| 152 | - * $checks_to_disable = array( |
|
| 153 | - * 'IncludeCheck', |
|
| 154 | - * 'I18NCheck', |
|
| 155 | - * 'AdminMenu', |
|
| 156 | - * 'Bad_Checks', |
|
| 157 | - * 'MalwareCheck', |
|
| 158 | - * 'Theme_Support', |
|
| 159 | - * 'CustomCheck', |
|
| 160 | - * 'EditorStyleCheck', |
|
| 161 | - * 'IframeCheck', |
|
| 162 | - * ); |
|
| 163 | - * foreach ( $themechecks as $keyindex => $check ) { |
|
| 164 | - * if ( $check instanceof themecheck ) { |
|
| 165 | - * $check_class = get_class( $check ); |
|
| 166 | - * if ( in_array( $check_class, $checks_to_disable ) ) { |
|
| 167 | - * unset( $themechecks[$keyindex] ); |
|
| 168 | - * } |
|
| 169 | - * } |
|
| 170 | - * } |
|
| 171 | - */ |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Disable Theme-Check checks that aren't relevant for ThemeForest themes |
|
| 176 | - * |
|
| 177 | - * @since 1.0.0 |
|
| 178 | - */ |
|
| 179 | - public function add_checks() { |
|
| 180 | - |
|
| 181 | - // load all the checks in the checks directory. |
|
| 182 | - $dir = 'checks'; |
|
| 183 | - foreach ( glob( __DIR__ . '/' . $dir . '/*.php' ) as $file ) { |
|
| 184 | - require_once $file; |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Register and enqueue admin-specific style sheet. |
|
| 190 | - * |
|
| 191 | - * @since 1.0.1 |
|
| 192 | - */ |
|
| 193 | - public function enqueue_admin_styles() { |
|
| 194 | - $screen = get_current_screen(); |
|
| 195 | - if ( 'appearance_page_themecheck' === $screen->id ) { |
|
| 196 | - wp_enqueue_style( $this->slug . '-admin-styles', Redux_Core::$url . 'inc/themecheck/css/admin.css', array(), $this->version ); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Register and enqueue admin-specific JavaScript. |
|
| 202 | - * |
|
| 203 | - * @since 1.0.1 |
|
| 204 | - */ |
|
| 205 | - public function enqueue_admin_scripts() { |
|
| 206 | - |
|
| 207 | - $screen = get_current_screen(); |
|
| 208 | - |
|
| 209 | - if ( 'appearance_page_themecheck' === $screen->id ) { |
|
| 210 | - wp_enqueue_script( |
|
| 211 | - $this->slug . '-admin-script', |
|
| 212 | - Redux_Core::$url . 'inc/themecheck/js/admin' . Redux_Functions::is_min() . '.js', |
|
| 213 | - array( 'jquery' ), |
|
| 214 | - $this->version, |
|
| 215 | - true |
|
| 216 | - ); |
|
| 217 | - |
|
| 218 | - if ( ! isset( $_POST['themename'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 219 | - |
|
| 220 | - $intro = '<h2>Redux Theme-Check</h2>'; |
|
| 221 | - $intro .= '<p>Extra checks for Redux to ensure you\'re ready for marketplace submission to marketplaces.</p>'; |
|
| 222 | - |
|
| 223 | - $redux_check_intro['text'] = $intro; |
|
| 224 | - |
|
| 225 | - wp_localize_script( $this->slug . '-admin-script', 'redux_check_intro', $redux_check_intro ); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - Redux_ThemeCheck::get_instance(); |
|
| 15 | + /** |
|
| 16 | + * Class Redux_ThemeCheck |
|
| 17 | + */ |
|
| 18 | + class Redux_ThemeCheck { |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Plugin version, used for cache-busting of style and script file references. |
|
| 22 | + * |
|
| 23 | + * @since 1.0.0 |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + protected string $version = '1.0.0'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Instance of this class. |
|
| 30 | + * |
|
| 31 | + * @since 1.0.0 |
|
| 32 | + * @var Redux_ThemeCheck|null |
|
| 33 | + */ |
|
| 34 | + protected static ?Redux_ThemeCheck $instance = null; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Instance of the Redux class. |
|
| 38 | + * |
|
| 39 | + * @since 1.0.0 |
|
| 40 | + * @var ReduxFramework|null |
|
| 41 | + */ |
|
| 42 | + protected static ?ReduxFramework $redux; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Details of the embedded Redux class. |
|
| 46 | + * |
|
| 47 | + * @since 1.0.0 |
|
| 48 | + * @var mixed|null |
|
| 49 | + */ |
|
| 50 | + protected static $redux_details = array(); |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Slug for various elements. |
|
| 54 | + * |
|
| 55 | + * @since 1.0.0 |
|
| 56 | + * @var string |
|
| 57 | + */ |
|
| 58 | + protected string $slug = 'redux_themecheck'; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + */ |
|
| 65 | + private function __construct() { |
|
| 66 | + if ( ! class_exists( 'ThemeCheckMain' ) ) { |
|
| 67 | + return; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // Load the admin stylesheet and JavaScript. |
|
| 71 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) ); |
|
| 72 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); |
|
| 73 | + |
|
| 74 | + add_action( 'themecheck_checks_loaded', array( $this, 'disable_checks' ) ); |
|
| 75 | + add_action( 'themecheck_checks_loaded', array( $this, 'add_checks' ) ); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Return an instance of this class. |
|
| 80 | + * |
|
| 81 | + * @since 1.0.0 |
|
| 82 | + * @return object A single instance of this class. |
|
| 83 | + */ |
|
| 84 | + public static function get_instance() { |
|
| 85 | + |
|
| 86 | + // If the single instance hasn't been set, set it now. |
|
| 87 | + if ( null === self::$instance ) { |
|
| 88 | + self::$instance = new self(); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return self::$instance; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Return an instance of this class. |
|
| 96 | + * |
|
| 97 | + * @since 1.0.0 |
|
| 98 | + * @return object A single instance of this class. |
|
| 99 | + */ |
|
| 100 | + public static function get_redux_instance() { |
|
| 101 | + |
|
| 102 | + // If the single instance hasn't been set, set it now. |
|
| 103 | + if ( null === self::$redux && Redux_Core::$as_plugin ) { |
|
| 104 | + self::$redux = new ReduxFramework(); |
|
| 105 | + self::$redux->init(); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + return self::$redux; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Return the Redux path info, if had. |
|
| 113 | + * |
|
| 114 | + * @param array $php_files Array of files to check. |
|
| 115 | + * |
|
| 116 | + * @return array|false|null A single instance of this class. |
|
| 117 | + * @since 1.0.0 |
|
| 118 | + */ |
|
| 119 | + public static function get_redux_details( array $php_files = array() ) { |
|
| 120 | + if ( null === self::$redux_details ) { |
|
| 121 | + foreach ( $php_files as $php_key => $phpfile ) { |
|
| 122 | + |
|
| 123 | + // phpcs:ignore Generic.Strings.UnnecessaryStringConcat |
|
| 124 | + if ( false !== strpos( $phpfile, 'class' . ' ReduxFramework {' ) ) { |
|
| 125 | + self::$redux_details = array( |
|
| 126 | + 'filename' => Redux_Core::strtolower( basename( $php_key ) ), |
|
| 127 | + 'path' => $php_key, |
|
| 128 | + ); |
|
| 129 | + self::$redux_details['dir'] = str_replace( basename( $php_key ), '', $php_key ); |
|
| 130 | + self::$redux_details['parent_dir'] = str_replace( basename( self::$redux_details['dir'] ) . '/', '', self::$redux_details['dir'] ); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + if ( null === self::$redux_details ) { |
|
| 135 | + self::$redux_details = false; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return self::$redux_details; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Disable Theme-Check checks that aren't relevant for ThemeForest themes |
|
| 143 | + * |
|
| 144 | + * @since 1.0.0 |
|
| 145 | + */ |
|
| 146 | + public function disable_checks() { |
|
| 147 | + /** |
|
| 148 | + * Uncomment code to use. |
|
| 149 | + * |
|
| 150 | + * global $themechecks; |
|
| 151 | + * |
|
| 152 | + * $checks_to_disable = array( |
|
| 153 | + * 'IncludeCheck', |
|
| 154 | + * 'I18NCheck', |
|
| 155 | + * 'AdminMenu', |
|
| 156 | + * 'Bad_Checks', |
|
| 157 | + * 'MalwareCheck', |
|
| 158 | + * 'Theme_Support', |
|
| 159 | + * 'CustomCheck', |
|
| 160 | + * 'EditorStyleCheck', |
|
| 161 | + * 'IframeCheck', |
|
| 162 | + * ); |
|
| 163 | + * foreach ( $themechecks as $keyindex => $check ) { |
|
| 164 | + * if ( $check instanceof themecheck ) { |
|
| 165 | + * $check_class = get_class( $check ); |
|
| 166 | + * if ( in_array( $check_class, $checks_to_disable ) ) { |
|
| 167 | + * unset( $themechecks[$keyindex] ); |
|
| 168 | + * } |
|
| 169 | + * } |
|
| 170 | + * } |
|
| 171 | + */ |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Disable Theme-Check checks that aren't relevant for ThemeForest themes |
|
| 176 | + * |
|
| 177 | + * @since 1.0.0 |
|
| 178 | + */ |
|
| 179 | + public function add_checks() { |
|
| 180 | + |
|
| 181 | + // load all the checks in the checks directory. |
|
| 182 | + $dir = 'checks'; |
|
| 183 | + foreach ( glob( __DIR__ . '/' . $dir . '/*.php' ) as $file ) { |
|
| 184 | + require_once $file; |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Register and enqueue admin-specific style sheet. |
|
| 190 | + * |
|
| 191 | + * @since 1.0.1 |
|
| 192 | + */ |
|
| 193 | + public function enqueue_admin_styles() { |
|
| 194 | + $screen = get_current_screen(); |
|
| 195 | + if ( 'appearance_page_themecheck' === $screen->id ) { |
|
| 196 | + wp_enqueue_style( $this->slug . '-admin-styles', Redux_Core::$url . 'inc/themecheck/css/admin.css', array(), $this->version ); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Register and enqueue admin-specific JavaScript. |
|
| 202 | + * |
|
| 203 | + * @since 1.0.1 |
|
| 204 | + */ |
|
| 205 | + public function enqueue_admin_scripts() { |
|
| 206 | + |
|
| 207 | + $screen = get_current_screen(); |
|
| 208 | + |
|
| 209 | + if ( 'appearance_page_themecheck' === $screen->id ) { |
|
| 210 | + wp_enqueue_script( |
|
| 211 | + $this->slug . '-admin-script', |
|
| 212 | + Redux_Core::$url . 'inc/themecheck/js/admin' . Redux_Functions::is_min() . '.js', |
|
| 213 | + array( 'jquery' ), |
|
| 214 | + $this->version, |
|
| 215 | + true |
|
| 216 | + ); |
|
| 217 | + |
|
| 218 | + if ( ! isset( $_POST['themename'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 219 | + |
|
| 220 | + $intro = '<h2>Redux Theme-Check</h2>'; |
|
| 221 | + $intro .= '<p>Extra checks for Redux to ensure you\'re ready for marketplace submission to marketplaces.</p>'; |
|
| 222 | + |
|
| 223 | + $redux_check_intro['text'] = $intro; |
|
| 224 | + |
|
| 225 | + wp_localize_script( $this->slug . '-admin-script', 'redux_check_intro', $redux_check_intro ); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + Redux_ThemeCheck::get_instance(); |
|
| 232 | 232 | } |