@@ -11,390 +11,390 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Args', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Args |
|
| 16 | - */ |
|
| 17 | - class Redux_Args { |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Returns entire arguments array. |
|
| 21 | - * |
|
| 22 | - * @var array|mixed |
|
| 23 | - */ |
|
| 24 | - public $get = array(); |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * ReduxFramework object. |
|
| 28 | - * |
|
| 29 | - * @var ReduxFramework|null |
|
| 30 | - */ |
|
| 31 | - private ?ReduxFramework $parent; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Switch to omit social icons if dev_mode is set to true and Redux defaults are used. |
|
| 35 | - * |
|
| 36 | - * @var bool |
|
| 37 | - */ |
|
| 38 | - public bool $omit_icons = false; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Switch to omit support menu items if dev_mode is set to true and redux defaults are used. |
|
| 42 | - * |
|
| 43 | - * @var bool |
|
| 44 | - */ |
|
| 45 | - public bool $omit_items = false; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Flag to force dev_mod to true if in localhost or WP_DEBUG is set to true. |
|
| 49 | - * |
|
| 50 | - * @var bool |
|
| 51 | - */ |
|
| 52 | - public bool $dev_mode_forced = false; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Redux_Args constructor. |
|
| 56 | - * |
|
| 57 | - * @param ReduxFramework $redux ReduxFramework object. |
|
| 58 | - * @param array $args Global arguments array. |
|
| 59 | - */ |
|
| 60 | - public function __construct( ReduxFramework $redux, array $args ) { |
|
| 61 | - $this->parent = $redux; |
|
| 62 | - |
|
| 63 | - $default = array( |
|
| 64 | - 'opt_name' => '', |
|
| 65 | - 'last_tab' => '', |
|
| 66 | - 'menu_icon' => '', |
|
| 67 | - 'menu_title' => '', |
|
| 68 | - 'page_title' => '', |
|
| 69 | - 'page_slug' => '', |
|
| 70 | - 'page_permissions' => 'manage_options', |
|
| 71 | - 'menu_type' => 'menu', |
|
| 72 | - 'page_parent' => 'themes.php', |
|
| 73 | - 'page_priority' => null, |
|
| 74 | - 'allow_sub_menu' => true, |
|
| 75 | - 'save_defaults' => true, |
|
| 76 | - 'footer_credit' => '', |
|
| 77 | - 'async_typography' => false, |
|
| 78 | - 'disable_google_fonts_link' => false, |
|
| 79 | - 'class' => '', |
|
| 80 | - 'admin_bar' => true, |
|
| 81 | - 'admin_bar_priority' => 999, |
|
| 82 | - 'admin_bar_icon' => '', |
|
| 83 | - 'help_tabs' => array(), |
|
| 84 | - 'help_sidebar' => '', |
|
| 85 | - 'database' => '', |
|
| 86 | - 'customizer' => false, |
|
| 87 | - 'global_variable' => '', |
|
| 88 | - 'output' => true, |
|
| 89 | - 'output_variables_prefix' => '--', |
|
| 90 | - 'compiler_output_variables_prefix' => '$', |
|
| 91 | - 'compiler' => true, |
|
| 92 | - 'output_tag' => true, |
|
| 93 | - 'output_location' => array( 'frontend' ), |
|
| 94 | - 'transient_time' => '', |
|
| 95 | - 'default_show' => false, |
|
| 96 | - 'default_mark' => '', |
|
| 97 | - 'disable_save_warn' => false, |
|
| 98 | - 'open_expanded' => false, |
|
| 99 | - 'hide_expand' => false, |
|
| 100 | - 'network_admin' => false, |
|
| 101 | - 'network_sites' => true, |
|
| 102 | - 'hide_reset' => false, |
|
| 103 | - 'hide_save' => false, |
|
| 104 | - 'hints' => array( |
|
| 105 | - 'icon' => 'el el-question-sign', |
|
| 106 | - 'icon_position' => 'right', |
|
| 107 | - 'icon_color' => 'lightgray', |
|
| 108 | - 'icon_size' => 'normal', |
|
| 109 | - 'tip_style' => array( |
|
| 110 | - 'color' => 'light', |
|
| 111 | - 'shadow' => true, |
|
| 112 | - 'rounded' => false, |
|
| 113 | - 'style' => '', |
|
| 114 | - ), |
|
| 115 | - 'tip_position' => array( |
|
| 116 | - 'my' => 'top_left', |
|
| 117 | - 'at' => 'bottom_right', |
|
| 118 | - ), |
|
| 119 | - 'tip_effect' => array( |
|
| 120 | - 'show' => array( |
|
| 121 | - 'effect' => 'slide', |
|
| 122 | - 'duration' => '500', |
|
| 123 | - 'event' => 'mouseover', |
|
| 124 | - ), |
|
| 125 | - 'hide' => array( |
|
| 126 | - 'effect' => 'fade', |
|
| 127 | - 'duration' => '500', |
|
| 128 | - 'event' => 'click mouseleave', |
|
| 129 | - ), |
|
| 130 | - ), |
|
| 131 | - ), |
|
| 132 | - 'font_weights' => array( |
|
| 133 | - array( |
|
| 134 | - 'id' => '400', |
|
| 135 | - 'name' => __( 'Regular 400', 'redux-framework' ), |
|
| 136 | - ), |
|
| 137 | - array( |
|
| 138 | - 'id' => '400italic', |
|
| 139 | - 'name' => __( 'Regular 400 Italic', 'redux-framework' ), |
|
| 140 | - ), |
|
| 141 | - array( |
|
| 142 | - 'id' => '700', |
|
| 143 | - 'name' => __( 'Bold 700', 'redux-framework' ), |
|
| 144 | - ), |
|
| 145 | - array( |
|
| 146 | - 'id' => '700italic', |
|
| 147 | - 'name' => __( 'Bold 700 Italic', 'redux-framework' ), |
|
| 148 | - ), |
|
| 149 | - ), |
|
| 150 | - 'show_import_export' => true, |
|
| 151 | - 'show_options_object' => true, |
|
| 152 | - 'dev_mode' => true, |
|
| 153 | - 'templates_path' => '', |
|
| 154 | - 'ajax_save' => true, |
|
| 155 | - 'use_cdn' => true, |
|
| 156 | - 'cdn_check_time' => 1440, |
|
| 157 | - 'options_api' => true, |
|
| 158 | - 'allow_tracking' => true, |
|
| 159 | - 'admin_theme' => 'wp', |
|
| 160 | - 'elusive_frontend' => false, |
|
| 161 | - 'fontawesome_frontend' => false, |
|
| 162 | - 'flyout_submenus' => true, |
|
| 163 | - 'font_display' => 'swap', // block|swap|fallback|optional. |
|
| 164 | - 'load_on_cron' => false, |
|
| 165 | - 'search' => false, |
|
| 166 | - 'widget_area' => false, |
|
| 167 | - 'custom_fonts' => true, |
|
| 168 | - ); |
|
| 169 | - |
|
| 170 | - $args = Redux_Functions::parse_args( $args, $default ); |
|
| 171 | - |
|
| 172 | - $args = $this->args( $args ); |
|
| 173 | - |
|
| 174 | - $args = $this->default_cleanup( $args ); |
|
| 175 | - |
|
| 176 | - if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) { |
|
| 177 | - $args['font_display'] = 'swap'; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - if ( isset( $args['async_typography'] ) && $args['async_typography'] ) { |
|
| 181 | - $args['async_typography'] = false; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $this->get = $args; |
|
| 185 | - |
|
| 186 | - $this->parent->args = $args; |
|
| 187 | - |
|
| 188 | - if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) { |
|
| 189 | - $this->change_demo_defaults( $args ); |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Builds and sanitizes a global args array. |
|
| 195 | - * |
|
| 196 | - * @param array $args Global args. |
|
| 197 | - * |
|
| 198 | - * @return array |
|
| 199 | - */ |
|
| 200 | - private function args( array $args ): array { |
|
| 201 | - $args = $this->no_errors_please( $args ); |
|
| 202 | - |
|
| 203 | - $this->parent->old_opt_name = $args['opt_name']; |
|
| 204 | - |
|
| 205 | - $args = $this->filters( $args ); |
|
| 206 | - |
|
| 207 | - if ( ! function_exists( 'wp_rand' ) ) { |
|
| 208 | - require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if ( $args['opt_name'] === $this->parent->old_opt_name ) { |
|
| 212 | - $this->parent->old_opt_name = null; |
|
| 213 | - unset( $this->parent->old_opt_name ); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - // Do not save the defaults if we're on a live preview! |
|
| 217 | - if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 218 | - $args['save_defaults'] = false; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - return $this->shim( $args ); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Apply filters to arg data. |
|
| 226 | - * |
|
| 227 | - * @param array $args Global args. |
|
| 228 | - * |
|
| 229 | - * @return mixed|void |
|
| 230 | - */ |
|
| 231 | - private function filters( array $args ) { |
|
| 232 | - /** |
|
| 233 | - * Filter 'redux/args/{opt_name}' |
|
| 234 | - * |
|
| 235 | - * @param array $args ReduxFramework configuration |
|
| 236 | - */ |
|
| 237 | - |
|
| 238 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 239 | - $args = apply_filters( "redux/args/{$args['opt_name']}", $args ); |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Filter 'redux/options/{opt_name}/args' |
|
| 243 | - * |
|
| 244 | - * @param array $args ReduxFramework configuration |
|
| 245 | - */ |
|
| 246 | - |
|
| 247 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 248 | - return apply_filters( "redux/options/{$args['opt_name']}/args", $args ); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Sanitize args that should not be empty. |
|
| 253 | - * |
|
| 254 | - * @param array $args Global args. |
|
| 255 | - * |
|
| 256 | - * @return array |
|
| 257 | - */ |
|
| 258 | - private function no_errors_please( array $args ): array { |
|
| 259 | - if ( empty( $args['transient_time'] ) ) { |
|
| 260 | - $args['transient_time'] = 60 * MINUTE_IN_SECONDS; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - if ( empty( $args['footer_credit'] ) ) { |
|
| 264 | - |
|
| 265 | - $footer_text = sprintf( |
|
| 266 | - /* translators: 1: Redux, 2: Link to plugin review */ |
|
| 267 | - __( 'Enjoyed %1$s? Please leave us a %2$s. We really appreciate your support!', 'redux-framework' ), |
|
| 268 | - '<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>', |
|
| 269 | - '<a href="https://wordpress.org/support/plugin/redux-framework/reviews/#new-post" target="_blank">' . __( 'review', 'redux-framework' ) . '</a>' |
|
| 270 | - ); |
|
| 271 | - $args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>'; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - if ( empty( $args['menu_title'] ) ) { |
|
| 275 | - $args['menu_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - if ( empty( $args['page_title'] ) ) { |
|
| 279 | - $args['page_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - // Auto creates the page_slug appropriately. |
|
| 283 | - if ( empty( $args['page_slug'] ) ) { |
|
| 284 | - if ( ! empty( $args['display_name'] ) ) { |
|
| 285 | - $args['page_slug'] = sanitize_html_class( $args['display_name'] ); |
|
| 286 | - } elseif ( ! empty( $args['page_title'] ) ) { |
|
| 287 | - $args['page_slug'] = sanitize_html_class( $args['page_title'] ); |
|
| 288 | - } elseif ( ! empty( $args['menu_title'] ) ) { |
|
| 289 | - $args['page_slug'] = sanitize_html_class( $args['menu_title'] ); |
|
| 290 | - } else { |
|
| 291 | - $args['page_slug'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - return $args; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * Shims for much older v3 configs. |
|
| 300 | - * |
|
| 301 | - * @param array $args Global args. |
|
| 302 | - * |
|
| 303 | - * @return array |
|
| 304 | - */ |
|
| 305 | - private function shim( array $args ): array { |
|
| 306 | - /** |
|
| 307 | - * SHIM SECTION |
|
| 308 | - * Old variables and ways of doing things that need correcting. ;) |
|
| 309 | - * */ |
|
| 310 | - // Variable name change. |
|
| 311 | - if ( ! empty( $args['page_cap'] ) ) { |
|
| 312 | - $args['page_permissions'] = $args['page_cap']; |
|
| 313 | - unset( $args['page_cap'] ); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - if ( ! empty( $args['page_position'] ) ) { |
|
| 317 | - $args['page_priority'] = $args['page_position']; |
|
| 318 | - unset( $args['page_position'] ); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - if ( ! empty( $args['page_type'] ) ) { |
|
| 322 | - $args['menu_type'] = $args['page_type']; |
|
| 323 | - unset( $args['page_type'] ); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - return $args; |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own. |
|
| 331 | - * |
|
| 332 | - * @param array $args Global args. |
|
| 333 | - */ |
|
| 334 | - private function change_demo_defaults( array $args ) { |
|
| 335 | - if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) { |
|
| 336 | - if ( ! empty( $args['admin_bar_links'] ) ) { |
|
| 337 | - foreach ( $args['admin_bar_links'] as $arr ) { |
|
| 338 | - if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 339 | - foreach ( $arr as $y ) { |
|
| 340 | - if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 341 | - $this->omit_items = true; |
|
| 342 | - break; |
|
| 343 | - } |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - if ( ! empty( $args['share_icons'] ) ) { |
|
| 350 | - foreach ( $args['share_icons'] as $arr ) { |
|
| 351 | - if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 352 | - foreach ( $arr as $y ) { |
|
| 353 | - if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 354 | - $this->omit_icons = true; |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * Fix other arg criteria that sometimes gets hosed up. |
|
| 365 | - * |
|
| 366 | - * @param array $args Global args. |
|
| 367 | - * |
|
| 368 | - * @return array |
|
| 369 | - * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection |
|
| 370 | - */ |
|
| 371 | - private function default_cleanup( array $args ): array { |
|
| 372 | - |
|
| 373 | - // Fix the global variable name. |
|
| 374 | - if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) { |
|
| 375 | - $args['global_variable'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) { |
|
| 379 | - $args['menu_type'] = 'hidden'; |
|
| 380 | - $args['customizer'] = true; |
|
| 381 | - $args['admin_bar'] = false; |
|
| 382 | - $args['allow_sub_menu'] = false; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - // Check if the Airplane Mode plugin is installed. |
|
| 386 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 387 | - $airplane = Airplane_Mode_Core::getInstance(); |
|
| 388 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 389 | - if ( $airplane->enabled() ) { |
|
| 390 | - $args['use_cdn'] = false; |
|
| 391 | - } |
|
| 392 | - } elseif ( 'on' === $airplane->check_status() ) { |
|
| 393 | - $args['use_cdn'] = false; |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - return $args; |
|
| 398 | - } |
|
| 399 | - } |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Args |
|
| 16 | + */ |
|
| 17 | + class Redux_Args { |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Returns entire arguments array. |
|
| 21 | + * |
|
| 22 | + * @var array|mixed |
|
| 23 | + */ |
|
| 24 | + public $get = array(); |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * ReduxFramework object. |
|
| 28 | + * |
|
| 29 | + * @var ReduxFramework|null |
|
| 30 | + */ |
|
| 31 | + private ?ReduxFramework $parent; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Switch to omit social icons if dev_mode is set to true and Redux defaults are used. |
|
| 35 | + * |
|
| 36 | + * @var bool |
|
| 37 | + */ |
|
| 38 | + public bool $omit_icons = false; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Switch to omit support menu items if dev_mode is set to true and redux defaults are used. |
|
| 42 | + * |
|
| 43 | + * @var bool |
|
| 44 | + */ |
|
| 45 | + public bool $omit_items = false; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Flag to force dev_mod to true if in localhost or WP_DEBUG is set to true. |
|
| 49 | + * |
|
| 50 | + * @var bool |
|
| 51 | + */ |
|
| 52 | + public bool $dev_mode_forced = false; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Redux_Args constructor. |
|
| 56 | + * |
|
| 57 | + * @param ReduxFramework $redux ReduxFramework object. |
|
| 58 | + * @param array $args Global arguments array. |
|
| 59 | + */ |
|
| 60 | + public function __construct( ReduxFramework $redux, array $args ) { |
|
| 61 | + $this->parent = $redux; |
|
| 62 | + |
|
| 63 | + $default = array( |
|
| 64 | + 'opt_name' => '', |
|
| 65 | + 'last_tab' => '', |
|
| 66 | + 'menu_icon' => '', |
|
| 67 | + 'menu_title' => '', |
|
| 68 | + 'page_title' => '', |
|
| 69 | + 'page_slug' => '', |
|
| 70 | + 'page_permissions' => 'manage_options', |
|
| 71 | + 'menu_type' => 'menu', |
|
| 72 | + 'page_parent' => 'themes.php', |
|
| 73 | + 'page_priority' => null, |
|
| 74 | + 'allow_sub_menu' => true, |
|
| 75 | + 'save_defaults' => true, |
|
| 76 | + 'footer_credit' => '', |
|
| 77 | + 'async_typography' => false, |
|
| 78 | + 'disable_google_fonts_link' => false, |
|
| 79 | + 'class' => '', |
|
| 80 | + 'admin_bar' => true, |
|
| 81 | + 'admin_bar_priority' => 999, |
|
| 82 | + 'admin_bar_icon' => '', |
|
| 83 | + 'help_tabs' => array(), |
|
| 84 | + 'help_sidebar' => '', |
|
| 85 | + 'database' => '', |
|
| 86 | + 'customizer' => false, |
|
| 87 | + 'global_variable' => '', |
|
| 88 | + 'output' => true, |
|
| 89 | + 'output_variables_prefix' => '--', |
|
| 90 | + 'compiler_output_variables_prefix' => '$', |
|
| 91 | + 'compiler' => true, |
|
| 92 | + 'output_tag' => true, |
|
| 93 | + 'output_location' => array( 'frontend' ), |
|
| 94 | + 'transient_time' => '', |
|
| 95 | + 'default_show' => false, |
|
| 96 | + 'default_mark' => '', |
|
| 97 | + 'disable_save_warn' => false, |
|
| 98 | + 'open_expanded' => false, |
|
| 99 | + 'hide_expand' => false, |
|
| 100 | + 'network_admin' => false, |
|
| 101 | + 'network_sites' => true, |
|
| 102 | + 'hide_reset' => false, |
|
| 103 | + 'hide_save' => false, |
|
| 104 | + 'hints' => array( |
|
| 105 | + 'icon' => 'el el-question-sign', |
|
| 106 | + 'icon_position' => 'right', |
|
| 107 | + 'icon_color' => 'lightgray', |
|
| 108 | + 'icon_size' => 'normal', |
|
| 109 | + 'tip_style' => array( |
|
| 110 | + 'color' => 'light', |
|
| 111 | + 'shadow' => true, |
|
| 112 | + 'rounded' => false, |
|
| 113 | + 'style' => '', |
|
| 114 | + ), |
|
| 115 | + 'tip_position' => array( |
|
| 116 | + 'my' => 'top_left', |
|
| 117 | + 'at' => 'bottom_right', |
|
| 118 | + ), |
|
| 119 | + 'tip_effect' => array( |
|
| 120 | + 'show' => array( |
|
| 121 | + 'effect' => 'slide', |
|
| 122 | + 'duration' => '500', |
|
| 123 | + 'event' => 'mouseover', |
|
| 124 | + ), |
|
| 125 | + 'hide' => array( |
|
| 126 | + 'effect' => 'fade', |
|
| 127 | + 'duration' => '500', |
|
| 128 | + 'event' => 'click mouseleave', |
|
| 129 | + ), |
|
| 130 | + ), |
|
| 131 | + ), |
|
| 132 | + 'font_weights' => array( |
|
| 133 | + array( |
|
| 134 | + 'id' => '400', |
|
| 135 | + 'name' => __( 'Regular 400', 'redux-framework' ), |
|
| 136 | + ), |
|
| 137 | + array( |
|
| 138 | + 'id' => '400italic', |
|
| 139 | + 'name' => __( 'Regular 400 Italic', 'redux-framework' ), |
|
| 140 | + ), |
|
| 141 | + array( |
|
| 142 | + 'id' => '700', |
|
| 143 | + 'name' => __( 'Bold 700', 'redux-framework' ), |
|
| 144 | + ), |
|
| 145 | + array( |
|
| 146 | + 'id' => '700italic', |
|
| 147 | + 'name' => __( 'Bold 700 Italic', 'redux-framework' ), |
|
| 148 | + ), |
|
| 149 | + ), |
|
| 150 | + 'show_import_export' => true, |
|
| 151 | + 'show_options_object' => true, |
|
| 152 | + 'dev_mode' => true, |
|
| 153 | + 'templates_path' => '', |
|
| 154 | + 'ajax_save' => true, |
|
| 155 | + 'use_cdn' => true, |
|
| 156 | + 'cdn_check_time' => 1440, |
|
| 157 | + 'options_api' => true, |
|
| 158 | + 'allow_tracking' => true, |
|
| 159 | + 'admin_theme' => 'wp', |
|
| 160 | + 'elusive_frontend' => false, |
|
| 161 | + 'fontawesome_frontend' => false, |
|
| 162 | + 'flyout_submenus' => true, |
|
| 163 | + 'font_display' => 'swap', // block|swap|fallback|optional. |
|
| 164 | + 'load_on_cron' => false, |
|
| 165 | + 'search' => false, |
|
| 166 | + 'widget_area' => false, |
|
| 167 | + 'custom_fonts' => true, |
|
| 168 | + ); |
|
| 169 | + |
|
| 170 | + $args = Redux_Functions::parse_args( $args, $default ); |
|
| 171 | + |
|
| 172 | + $args = $this->args( $args ); |
|
| 173 | + |
|
| 174 | + $args = $this->default_cleanup( $args ); |
|
| 175 | + |
|
| 176 | + if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) { |
|
| 177 | + $args['font_display'] = 'swap'; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + if ( isset( $args['async_typography'] ) && $args['async_typography'] ) { |
|
| 181 | + $args['async_typography'] = false; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $this->get = $args; |
|
| 185 | + |
|
| 186 | + $this->parent->args = $args; |
|
| 187 | + |
|
| 188 | + if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) { |
|
| 189 | + $this->change_demo_defaults( $args ); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Builds and sanitizes a global args array. |
|
| 195 | + * |
|
| 196 | + * @param array $args Global args. |
|
| 197 | + * |
|
| 198 | + * @return array |
|
| 199 | + */ |
|
| 200 | + private function args( array $args ): array { |
|
| 201 | + $args = $this->no_errors_please( $args ); |
|
| 202 | + |
|
| 203 | + $this->parent->old_opt_name = $args['opt_name']; |
|
| 204 | + |
|
| 205 | + $args = $this->filters( $args ); |
|
| 206 | + |
|
| 207 | + if ( ! function_exists( 'wp_rand' ) ) { |
|
| 208 | + require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if ( $args['opt_name'] === $this->parent->old_opt_name ) { |
|
| 212 | + $this->parent->old_opt_name = null; |
|
| 213 | + unset( $this->parent->old_opt_name ); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + // Do not save the defaults if we're on a live preview! |
|
| 217 | + if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 218 | + $args['save_defaults'] = false; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + return $this->shim( $args ); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Apply filters to arg data. |
|
| 226 | + * |
|
| 227 | + * @param array $args Global args. |
|
| 228 | + * |
|
| 229 | + * @return mixed|void |
|
| 230 | + */ |
|
| 231 | + private function filters( array $args ) { |
|
| 232 | + /** |
|
| 233 | + * Filter 'redux/args/{opt_name}' |
|
| 234 | + * |
|
| 235 | + * @param array $args ReduxFramework configuration |
|
| 236 | + */ |
|
| 237 | + |
|
| 238 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 239 | + $args = apply_filters( "redux/args/{$args['opt_name']}", $args ); |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Filter 'redux/options/{opt_name}/args' |
|
| 243 | + * |
|
| 244 | + * @param array $args ReduxFramework configuration |
|
| 245 | + */ |
|
| 246 | + |
|
| 247 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 248 | + return apply_filters( "redux/options/{$args['opt_name']}/args", $args ); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Sanitize args that should not be empty. |
|
| 253 | + * |
|
| 254 | + * @param array $args Global args. |
|
| 255 | + * |
|
| 256 | + * @return array |
|
| 257 | + */ |
|
| 258 | + private function no_errors_please( array $args ): array { |
|
| 259 | + if ( empty( $args['transient_time'] ) ) { |
|
| 260 | + $args['transient_time'] = 60 * MINUTE_IN_SECONDS; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + if ( empty( $args['footer_credit'] ) ) { |
|
| 264 | + |
|
| 265 | + $footer_text = sprintf( |
|
| 266 | + /* translators: 1: Redux, 2: Link to plugin review */ |
|
| 267 | + __( 'Enjoyed %1$s? Please leave us a %2$s. We really appreciate your support!', 'redux-framework' ), |
|
| 268 | + '<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>', |
|
| 269 | + '<a href="https://wordpress.org/support/plugin/redux-framework/reviews/#new-post" target="_blank">' . __( 'review', 'redux-framework' ) . '</a>' |
|
| 270 | + ); |
|
| 271 | + $args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>'; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + if ( empty( $args['menu_title'] ) ) { |
|
| 275 | + $args['menu_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + if ( empty( $args['page_title'] ) ) { |
|
| 279 | + $args['page_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + // Auto creates the page_slug appropriately. |
|
| 283 | + if ( empty( $args['page_slug'] ) ) { |
|
| 284 | + if ( ! empty( $args['display_name'] ) ) { |
|
| 285 | + $args['page_slug'] = sanitize_html_class( $args['display_name'] ); |
|
| 286 | + } elseif ( ! empty( $args['page_title'] ) ) { |
|
| 287 | + $args['page_slug'] = sanitize_html_class( $args['page_title'] ); |
|
| 288 | + } elseif ( ! empty( $args['menu_title'] ) ) { |
|
| 289 | + $args['page_slug'] = sanitize_html_class( $args['menu_title'] ); |
|
| 290 | + } else { |
|
| 291 | + $args['page_slug'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + return $args; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * Shims for much older v3 configs. |
|
| 300 | + * |
|
| 301 | + * @param array $args Global args. |
|
| 302 | + * |
|
| 303 | + * @return array |
|
| 304 | + */ |
|
| 305 | + private function shim( array $args ): array { |
|
| 306 | + /** |
|
| 307 | + * SHIM SECTION |
|
| 308 | + * Old variables and ways of doing things that need correcting. ;) |
|
| 309 | + * */ |
|
| 310 | + // Variable name change. |
|
| 311 | + if ( ! empty( $args['page_cap'] ) ) { |
|
| 312 | + $args['page_permissions'] = $args['page_cap']; |
|
| 313 | + unset( $args['page_cap'] ); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + if ( ! empty( $args['page_position'] ) ) { |
|
| 317 | + $args['page_priority'] = $args['page_position']; |
|
| 318 | + unset( $args['page_position'] ); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + if ( ! empty( $args['page_type'] ) ) { |
|
| 322 | + $args['menu_type'] = $args['page_type']; |
|
| 323 | + unset( $args['page_type'] ); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + return $args; |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own. |
|
| 331 | + * |
|
| 332 | + * @param array $args Global args. |
|
| 333 | + */ |
|
| 334 | + private function change_demo_defaults( array $args ) { |
|
| 335 | + if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) { |
|
| 336 | + if ( ! empty( $args['admin_bar_links'] ) ) { |
|
| 337 | + foreach ( $args['admin_bar_links'] as $arr ) { |
|
| 338 | + if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 339 | + foreach ( $arr as $y ) { |
|
| 340 | + if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 341 | + $this->omit_items = true; |
|
| 342 | + break; |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + if ( ! empty( $args['share_icons'] ) ) { |
|
| 350 | + foreach ( $args['share_icons'] as $arr ) { |
|
| 351 | + if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 352 | + foreach ( $arr as $y ) { |
|
| 353 | + if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 354 | + $this->omit_icons = true; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * Fix other arg criteria that sometimes gets hosed up. |
|
| 365 | + * |
|
| 366 | + * @param array $args Global args. |
|
| 367 | + * |
|
| 368 | + * @return array |
|
| 369 | + * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection |
|
| 370 | + */ |
|
| 371 | + private function default_cleanup( array $args ): array { |
|
| 372 | + |
|
| 373 | + // Fix the global variable name. |
|
| 374 | + if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) { |
|
| 375 | + $args['global_variable'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) { |
|
| 379 | + $args['menu_type'] = 'hidden'; |
|
| 380 | + $args['customizer'] = true; |
|
| 381 | + $args['admin_bar'] = false; |
|
| 382 | + $args['allow_sub_menu'] = false; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + // Check if the Airplane Mode plugin is installed. |
|
| 386 | + if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 387 | + $airplane = Airplane_Mode_Core::getInstance(); |
|
| 388 | + if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 389 | + if ( $airplane->enabled() ) { |
|
| 390 | + $args['use_cdn'] = false; |
|
| 391 | + } |
|
| 392 | + } elseif ( 'on' === $airplane->check_status() ) { |
|
| 393 | + $args['use_cdn'] = false; |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + return $args; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | 400 | } |