@@ -11,389 +11,389 @@ |
||
| 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 | - ); |
|
| 168 | - |
|
| 169 | - $args = Redux_Functions::parse_args( $args, $default ); |
|
| 170 | - |
|
| 171 | - $args = $this->args( $args ); |
|
| 172 | - |
|
| 173 | - $args = $this->default_cleanup( $args ); |
|
| 174 | - |
|
| 175 | - if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) { |
|
| 176 | - $args['font_display'] = 'swap'; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if ( isset( $args['async_typography'] ) && $args['async_typography'] ) { |
|
| 180 | - $args['async_typography'] = false; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - $this->get = $args; |
|
| 184 | - |
|
| 185 | - $this->parent->args = $args; |
|
| 186 | - |
|
| 187 | - if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) { |
|
| 188 | - $this->change_demo_defaults( $args ); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Builds and sanitizes a global args array. |
|
| 194 | - * |
|
| 195 | - * @param array $args Global args. |
|
| 196 | - * |
|
| 197 | - * @return array |
|
| 198 | - */ |
|
| 199 | - private function args( array $args ): array { |
|
| 200 | - $args = $this->no_errors_please( $args ); |
|
| 201 | - |
|
| 202 | - $this->parent->old_opt_name = $args['opt_name']; |
|
| 203 | - |
|
| 204 | - $args = $this->filters( $args ); |
|
| 205 | - |
|
| 206 | - if ( ! function_exists( 'wp_rand' ) ) { |
|
| 207 | - require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - if ( $args['opt_name'] === $this->parent->old_opt_name ) { |
|
| 211 | - $this->parent->old_opt_name = null; |
|
| 212 | - unset( $this->parent->old_opt_name ); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - // Do not save the defaults if we're on a live preview! |
|
| 216 | - if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 217 | - $args['save_defaults'] = false; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - return $this->shim( $args ); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Apply filters to arg data. |
|
| 225 | - * |
|
| 226 | - * @param array $args Global args. |
|
| 227 | - * |
|
| 228 | - * @return mixed|void |
|
| 229 | - */ |
|
| 230 | - private function filters( array $args ) { |
|
| 231 | - /** |
|
| 232 | - * Filter 'redux/args/{opt_name}' |
|
| 233 | - * |
|
| 234 | - * @param array $args ReduxFramework configuration |
|
| 235 | - */ |
|
| 236 | - |
|
| 237 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 238 | - $args = apply_filters( "redux/args/{$args['opt_name']}", $args ); |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * Filter 'redux/options/{opt_name}/args' |
|
| 242 | - * |
|
| 243 | - * @param array $args ReduxFramework configuration |
|
| 244 | - */ |
|
| 245 | - |
|
| 246 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 247 | - return apply_filters( "redux/options/{$args['opt_name']}/args", $args ); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Sanitize args that should not be empty. |
|
| 252 | - * |
|
| 253 | - * @param array $args Global args. |
|
| 254 | - * |
|
| 255 | - * @return array |
|
| 256 | - */ |
|
| 257 | - private function no_errors_please( array $args ): array { |
|
| 258 | - if ( empty( $args['transient_time'] ) ) { |
|
| 259 | - $args['transient_time'] = 60 * MINUTE_IN_SECONDS; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - if ( empty( $args['footer_credit'] ) ) { |
|
| 263 | - |
|
| 264 | - $footer_text = sprintf( |
|
| 265 | - /* translators: 1: Redux, 2: Link to plugin review */ |
|
| 266 | - __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'redux-framework' ), |
|
| 267 | - '<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>', |
|
| 268 | - '<a href="https://wordpress.org/support/plugin/redux-framework/reviews/?filter=5/#new-post" target="_blank">★★★★★</a>' |
|
| 269 | - ); |
|
| 270 | - $args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>'; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - if ( empty( $args['menu_title'] ) ) { |
|
| 274 | - $args['menu_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - if ( empty( $args['page_title'] ) ) { |
|
| 278 | - $args['page_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - // Auto creates the page_slug appropriately. |
|
| 282 | - if ( empty( $args['page_slug'] ) ) { |
|
| 283 | - if ( ! empty( $args['display_name'] ) ) { |
|
| 284 | - $args['page_slug'] = sanitize_html_class( $args['display_name'] ); |
|
| 285 | - } elseif ( ! empty( $args['page_title'] ) ) { |
|
| 286 | - $args['page_slug'] = sanitize_html_class( $args['page_title'] ); |
|
| 287 | - } elseif ( ! empty( $args['menu_title'] ) ) { |
|
| 288 | - $args['page_slug'] = sanitize_html_class( $args['menu_title'] ); |
|
| 289 | - } else { |
|
| 290 | - $args['page_slug'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - return $args; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Shims for much older v3 configs. |
|
| 299 | - * |
|
| 300 | - * @param array $args Global args. |
|
| 301 | - * |
|
| 302 | - * @return array |
|
| 303 | - */ |
|
| 304 | - private function shim( array $args ): array { |
|
| 305 | - /** |
|
| 306 | - * SHIM SECTION |
|
| 307 | - * Old variables and ways of doing things that need correcting. ;) |
|
| 308 | - * */ |
|
| 309 | - // Variable name change. |
|
| 310 | - if ( ! empty( $args['page_cap'] ) ) { |
|
| 311 | - $args['page_permissions'] = $args['page_cap']; |
|
| 312 | - unset( $args['page_cap'] ); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - if ( ! empty( $args['page_position'] ) ) { |
|
| 316 | - $args['page_priority'] = $args['page_position']; |
|
| 317 | - unset( $args['page_position'] ); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - if ( ! empty( $args['page_type'] ) ) { |
|
| 321 | - $args['menu_type'] = $args['page_type']; |
|
| 322 | - unset( $args['page_type'] ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - return $args; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own. |
|
| 330 | - * |
|
| 331 | - * @param array $args Global args. |
|
| 332 | - */ |
|
| 333 | - private function change_demo_defaults( array $args ) { |
|
| 334 | - if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) { |
|
| 335 | - if ( ! empty( $args['admin_bar_links'] ) ) { |
|
| 336 | - foreach ( $args['admin_bar_links'] as $arr ) { |
|
| 337 | - if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 338 | - foreach ( $arr as $y ) { |
|
| 339 | - if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 340 | - $this->omit_items = true; |
|
| 341 | - break; |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - if ( ! empty( $args['share_icons'] ) ) { |
|
| 349 | - foreach ( $args['share_icons'] as $arr ) { |
|
| 350 | - if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 351 | - foreach ( $arr as $y ) { |
|
| 352 | - if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 353 | - $this->omit_icons = true; |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * Fix other arg criteria that sometimes gets hosed up. |
|
| 364 | - * |
|
| 365 | - * @param array $args Global args. |
|
| 366 | - * |
|
| 367 | - * @return array |
|
| 368 | - * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection |
|
| 369 | - */ |
|
| 370 | - private function default_cleanup( array $args ): array { |
|
| 371 | - |
|
| 372 | - // Fix the global variable name. |
|
| 373 | - if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) { |
|
| 374 | - $args['global_variable'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) { |
|
| 378 | - $args['menu_type'] = 'hidden'; |
|
| 379 | - $args['customizer'] = true; |
|
| 380 | - $args['admin_bar'] = false; |
|
| 381 | - $args['allow_sub_menu'] = false; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - // Check if the Airplane Mode plugin is installed. |
|
| 385 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 386 | - $airplane = Airplane_Mode_Core::getInstance(); |
|
| 387 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 388 | - if ( $airplane->enabled() ) { |
|
| 389 | - $args['use_cdn'] = false; |
|
| 390 | - } |
|
| 391 | - } elseif ( 'on' === $airplane->check_status() ) { |
|
| 392 | - $args['use_cdn'] = false; |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - return $args; |
|
| 397 | - } |
|
| 398 | - } |
|
| 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 | + ); |
|
| 168 | + |
|
| 169 | + $args = Redux_Functions::parse_args( $args, $default ); |
|
| 170 | + |
|
| 171 | + $args = $this->args( $args ); |
|
| 172 | + |
|
| 173 | + $args = $this->default_cleanup( $args ); |
|
| 174 | + |
|
| 175 | + if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) { |
|
| 176 | + $args['font_display'] = 'swap'; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if ( isset( $args['async_typography'] ) && $args['async_typography'] ) { |
|
| 180 | + $args['async_typography'] = false; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + $this->get = $args; |
|
| 184 | + |
|
| 185 | + $this->parent->args = $args; |
|
| 186 | + |
|
| 187 | + if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) { |
|
| 188 | + $this->change_demo_defaults( $args ); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Builds and sanitizes a global args array. |
|
| 194 | + * |
|
| 195 | + * @param array $args Global args. |
|
| 196 | + * |
|
| 197 | + * @return array |
|
| 198 | + */ |
|
| 199 | + private function args( array $args ): array { |
|
| 200 | + $args = $this->no_errors_please( $args ); |
|
| 201 | + |
|
| 202 | + $this->parent->old_opt_name = $args['opt_name']; |
|
| 203 | + |
|
| 204 | + $args = $this->filters( $args ); |
|
| 205 | + |
|
| 206 | + if ( ! function_exists( 'wp_rand' ) ) { |
|
| 207 | + require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + if ( $args['opt_name'] === $this->parent->old_opt_name ) { |
|
| 211 | + $this->parent->old_opt_name = null; |
|
| 212 | + unset( $this->parent->old_opt_name ); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + // Do not save the defaults if we're on a live preview! |
|
| 216 | + if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 217 | + $args['save_defaults'] = false; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + return $this->shim( $args ); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Apply filters to arg data. |
|
| 225 | + * |
|
| 226 | + * @param array $args Global args. |
|
| 227 | + * |
|
| 228 | + * @return mixed|void |
|
| 229 | + */ |
|
| 230 | + private function filters( array $args ) { |
|
| 231 | + /** |
|
| 232 | + * Filter 'redux/args/{opt_name}' |
|
| 233 | + * |
|
| 234 | + * @param array $args ReduxFramework configuration |
|
| 235 | + */ |
|
| 236 | + |
|
| 237 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 238 | + $args = apply_filters( "redux/args/{$args['opt_name']}", $args ); |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Filter 'redux/options/{opt_name}/args' |
|
| 242 | + * |
|
| 243 | + * @param array $args ReduxFramework configuration |
|
| 244 | + */ |
|
| 245 | + |
|
| 246 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 247 | + return apply_filters( "redux/options/{$args['opt_name']}/args", $args ); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Sanitize args that should not be empty. |
|
| 252 | + * |
|
| 253 | + * @param array $args Global args. |
|
| 254 | + * |
|
| 255 | + * @return array |
|
| 256 | + */ |
|
| 257 | + private function no_errors_please( array $args ): array { |
|
| 258 | + if ( empty( $args['transient_time'] ) ) { |
|
| 259 | + $args['transient_time'] = 60 * MINUTE_IN_SECONDS; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + if ( empty( $args['footer_credit'] ) ) { |
|
| 263 | + |
|
| 264 | + $footer_text = sprintf( |
|
| 265 | + /* translators: 1: Redux, 2: Link to plugin review */ |
|
| 266 | + __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'redux-framework' ), |
|
| 267 | + '<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>', |
|
| 268 | + '<a href="https://wordpress.org/support/plugin/redux-framework/reviews/?filter=5/#new-post" target="_blank">★★★★★</a>' |
|
| 269 | + ); |
|
| 270 | + $args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>'; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + if ( empty( $args['menu_title'] ) ) { |
|
| 274 | + $args['menu_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + if ( empty( $args['page_title'] ) ) { |
|
| 278 | + $args['page_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + // Auto creates the page_slug appropriately. |
|
| 282 | + if ( empty( $args['page_slug'] ) ) { |
|
| 283 | + if ( ! empty( $args['display_name'] ) ) { |
|
| 284 | + $args['page_slug'] = sanitize_html_class( $args['display_name'] ); |
|
| 285 | + } elseif ( ! empty( $args['page_title'] ) ) { |
|
| 286 | + $args['page_slug'] = sanitize_html_class( $args['page_title'] ); |
|
| 287 | + } elseif ( ! empty( $args['menu_title'] ) ) { |
|
| 288 | + $args['page_slug'] = sanitize_html_class( $args['menu_title'] ); |
|
| 289 | + } else { |
|
| 290 | + $args['page_slug'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + return $args; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Shims for much older v3 configs. |
|
| 299 | + * |
|
| 300 | + * @param array $args Global args. |
|
| 301 | + * |
|
| 302 | + * @return array |
|
| 303 | + */ |
|
| 304 | + private function shim( array $args ): array { |
|
| 305 | + /** |
|
| 306 | + * SHIM SECTION |
|
| 307 | + * Old variables and ways of doing things that need correcting. ;) |
|
| 308 | + * */ |
|
| 309 | + // Variable name change. |
|
| 310 | + if ( ! empty( $args['page_cap'] ) ) { |
|
| 311 | + $args['page_permissions'] = $args['page_cap']; |
|
| 312 | + unset( $args['page_cap'] ); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + if ( ! empty( $args['page_position'] ) ) { |
|
| 316 | + $args['page_priority'] = $args['page_position']; |
|
| 317 | + unset( $args['page_position'] ); |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + if ( ! empty( $args['page_type'] ) ) { |
|
| 321 | + $args['menu_type'] = $args['page_type']; |
|
| 322 | + unset( $args['page_type'] ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + return $args; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own. |
|
| 330 | + * |
|
| 331 | + * @param array $args Global args. |
|
| 332 | + */ |
|
| 333 | + private function change_demo_defaults( array $args ) { |
|
| 334 | + if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) { |
|
| 335 | + if ( ! empty( $args['admin_bar_links'] ) ) { |
|
| 336 | + foreach ( $args['admin_bar_links'] as $arr ) { |
|
| 337 | + if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 338 | + foreach ( $arr as $y ) { |
|
| 339 | + if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 340 | + $this->omit_items = true; |
|
| 341 | + break; |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + if ( ! empty( $args['share_icons'] ) ) { |
|
| 349 | + foreach ( $args['share_icons'] as $arr ) { |
|
| 350 | + if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 351 | + foreach ( $arr as $y ) { |
|
| 352 | + if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 353 | + $this->omit_icons = true; |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * Fix other arg criteria that sometimes gets hosed up. |
|
| 364 | + * |
|
| 365 | + * @param array $args Global args. |
|
| 366 | + * |
|
| 367 | + * @return array |
|
| 368 | + * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection |
|
| 369 | + */ |
|
| 370 | + private function default_cleanup( array $args ): array { |
|
| 371 | + |
|
| 372 | + // Fix the global variable name. |
|
| 373 | + if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) { |
|
| 374 | + $args['global_variable'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) { |
|
| 378 | + $args['menu_type'] = 'hidden'; |
|
| 379 | + $args['customizer'] = true; |
|
| 380 | + $args['admin_bar'] = false; |
|
| 381 | + $args['allow_sub_menu'] = false; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + // Check if the Airplane Mode plugin is installed. |
|
| 385 | + if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 386 | + $airplane = Airplane_Mode_Core::getInstance(); |
|
| 387 | + if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 388 | + if ( $airplane->enabled() ) { |
|
| 389 | + $args['use_cdn'] = false; |
|
| 390 | + } |
|
| 391 | + } elseif ( 'on' === $airplane->check_status() ) { |
|
| 392 | + $args['use_cdn'] = false; |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + return $args; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | 399 | } |
@@ -12,73 +12,73 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Gallery', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_gallery class |
|
| 17 | - * |
|
| 18 | - * @since 3.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Gallery extends Redux_Field { |
|
| 15 | + /** |
|
| 16 | + * Main Redux_gallery class |
|
| 17 | + * |
|
| 18 | + * @since 3.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Gallery extends Redux_Field { |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Field Render Function. |
|
| 24 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 25 | - * |
|
| 26 | - * @since 1.0.0 |
|
| 27 | - * @access public |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function render() { |
|
| 31 | - echo '<div class="screenshot">'; |
|
| 22 | + /** |
|
| 23 | + * Field Render Function. |
|
| 24 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 25 | + * |
|
| 26 | + * @since 1.0.0 |
|
| 27 | + * @access public |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function render() { |
|
| 31 | + echo '<div class="screenshot">'; |
|
| 32 | 32 | |
| 33 | - if ( ! empty( $this->value ) ) { |
|
| 34 | - $ids = explode( ',', $this->value ); |
|
| 33 | + if ( ! empty( $this->value ) ) { |
|
| 34 | + $ids = explode( ',', $this->value ); |
|
| 35 | 35 | |
| 36 | - foreach ( $ids as $attachment_id ) { |
|
| 37 | - $img = wp_get_attachment_image_src( $attachment_id ); |
|
| 38 | - if ( false !== $img ) { |
|
| 39 | - $alt = wp_prepare_attachment_for_js( $attachment_id ); |
|
| 40 | - $alt = $alt['alt'] ?? ''; |
|
| 36 | + foreach ( $ids as $attachment_id ) { |
|
| 37 | + $img = wp_get_attachment_image_src( $attachment_id ); |
|
| 38 | + if ( false !== $img ) { |
|
| 39 | + $alt = wp_prepare_attachment_for_js( $attachment_id ); |
|
| 40 | + $alt = $alt['alt'] ?? ''; |
|
| 41 | 41 | |
| 42 | - echo '<a class="of-uploaded-image" href="' . esc_url( $img[0] ) . '">'; |
|
| 43 | - echo '<img class="redux-option-image" id="image_' . esc_attr( $this->field['id'] ) . '_' . esc_attr( $attachment_id ) . '" src="' . esc_url( $img[0] ) . '" alt="' . esc_attr( $alt ) . '" target="_blank" rel="external" />'; |
|
| 44 | - echo '</a>'; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 42 | + echo '<a class="of-uploaded-image" href="' . esc_url( $img[0] ) . '">'; |
|
| 43 | + echo '<img class="redux-option-image" id="image_' . esc_attr( $this->field['id'] ) . '_' . esc_attr( $attachment_id ) . '" src="' . esc_url( $img[0] ) . '" alt="' . esc_attr( $alt ) . '" target="_blank" rel="external" />'; |
|
| 44 | + echo '</a>'; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - echo '</div>'; |
|
| 50 | - echo '<a href="#" onclick="return false;" id="edit-gallery" class="gallery-attachments button button-primary">' . esc_html__( 'Add/Edit Gallery', 'redux-framework' ) . '</a> '; |
|
| 51 | - echo '<a href="#" onclick="return false;" id="clear-gallery" class="gallery-attachments button">' . esc_html__( 'Clear Gallery', 'redux-framework' ) . '</a>'; |
|
| 52 | - echo '<input type="hidden" class="gallery_values ' . esc_attr( $this->field['class'] ) . '" value="' . esc_attr( $this->value ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" />'; |
|
| 53 | - } |
|
| 49 | + echo '</div>'; |
|
| 50 | + echo '<a href="#" onclick="return false;" id="edit-gallery" class="gallery-attachments button button-primary">' . esc_html__( 'Add/Edit Gallery', 'redux-framework' ) . '</a> '; |
|
| 51 | + echo '<a href="#" onclick="return false;" id="clear-gallery" class="gallery-attachments button">' . esc_html__( 'Clear Gallery', 'redux-framework' ) . '</a>'; |
|
| 52 | + echo '<input type="hidden" class="gallery_values ' . esc_attr( $this->field['class'] ) . '" value="' . esc_attr( $this->value ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" />'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Enqueue Function. |
|
| 57 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 58 | - * |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * @access public |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public function enqueue() { |
|
| 55 | + /** |
|
| 56 | + * Enqueue Function. |
|
| 57 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 58 | + * |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * @access public |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public function enqueue() { |
|
| 64 | 64 | |
| 65 | - if ( function_exists( 'wp_enqueue_media' ) ) { |
|
| 66 | - wp_enqueue_media(); |
|
| 67 | - } else { |
|
| 68 | - wp_enqueue_script( 'media-upload' ); |
|
| 69 | - wp_enqueue_script( 'thickbox' ); |
|
| 70 | - wp_enqueue_style( 'thickbox' ); |
|
| 71 | - } |
|
| 65 | + if ( function_exists( 'wp_enqueue_media' ) ) { |
|
| 66 | + wp_enqueue_media(); |
|
| 67 | + } else { |
|
| 68 | + wp_enqueue_script( 'media-upload' ); |
|
| 69 | + wp_enqueue_script( 'thickbox' ); |
|
| 70 | + wp_enqueue_style( 'thickbox' ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - wp_enqueue_script( |
|
| 74 | - 'redux-field-gallery', |
|
| 75 | - Redux_Core::$url . 'inc/fields/gallery/redux-gallery' . Redux_Functions::is_min() . '.js', |
|
| 76 | - array( 'jquery', 'redux-js' ), |
|
| 77 | - $this->timestamp, |
|
| 78 | - true |
|
| 79 | - ); |
|
| 80 | - } |
|
| 81 | - } |
|
| 73 | + wp_enqueue_script( |
|
| 74 | + 'redux-field-gallery', |
|
| 75 | + Redux_Core::$url . 'inc/fields/gallery/redux-gallery' . Redux_Functions::is_min() . '.js', |
|
| 76 | + array( 'jquery', 'redux-js' ), |
|
| 77 | + $this->timestamp, |
|
| 78 | + true |
|
| 79 | + ); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | class_alias( 'Redux_Gallery', 'ReduxFramework_Gallery' ); |
@@ -12,84 +12,84 @@ discard block |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Widget_Areas' ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main ReduxFramework customizer extension class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Widget_Areas { |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Extension URI. |
|
| 24 | - * |
|
| 25 | - * @var null|string |
|
| 26 | - */ |
|
| 27 | - private ?string $extension_url; |
|
| 28 | - |
|
| 29 | - /** Extension directory. |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - private string $extension_dir; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Array of enabled widget_areas |
|
| 37 | - * |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - * @var array |
|
| 40 | - */ |
|
| 41 | - protected array $widget_areas = array(); |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Widget array. |
|
| 45 | - * |
|
| 46 | - * @var array |
|
| 47 | - */ |
|
| 48 | - protected array $orig = array(); |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * ReduxFramework object. |
|
| 52 | - * |
|
| 53 | - * @var ReduxFramework |
|
| 54 | - */ |
|
| 55 | - private ReduxFramework $parent; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Redux_Widget_Areas constructor. |
|
| 59 | - * |
|
| 60 | - * @param ReduxFramework $redux ReduxFramework pointer. |
|
| 61 | - */ |
|
| 62 | - public function __construct( ReduxFramework $redux ) { |
|
| 63 | - global $pagenow; |
|
| 64 | - |
|
| 65 | - $this->parent = $redux; |
|
| 66 | - |
|
| 67 | - if ( empty( $this->extension_dir ) ) { |
|
| 68 | - $this->extension_dir = trailingslashit( str_replace( '\\', '/', __DIR__ ) ); |
|
| 69 | - $this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) ); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - add_action( 'init', array( &$this, 'register_custom_widget_areas' ), 1000 ); |
|
| 73 | - |
|
| 74 | - if ( 'widgets.php' === $pagenow ) { |
|
| 75 | - if ( true === $redux->args['widget_area'] ) { |
|
| 76 | - add_action( 'admin_print_scripts', array( $this, 'add_new_widget_area_box' ) ); |
|
| 77 | - } |
|
| 78 | - add_action( 'load-widgets.php', array( $this, 'add_widget_area_area' ), 100 ); |
|
| 79 | - add_action( 'load-widgets.php', array( $this, 'enqueue' ), 100 ); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Function to create the HTML used to create widget_areas. |
|
| 85 | - * |
|
| 86 | - * @since 1.0.0 |
|
| 87 | - */ |
|
| 88 | - public function add_new_widget_area_box() { |
|
| 89 | - $nonce = wp_create_nonce( 'add-redux-widget_area-nonce' ); |
|
| 90 | - $del_nonce = wp_create_nonce( 'delete-redux-widget_area-nonce' ); |
|
| 91 | - |
|
| 92 | - ?> |
|
| 15 | + /** |
|
| 16 | + * Main ReduxFramework customizer extension class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Widget_Areas { |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Extension URI. |
|
| 24 | + * |
|
| 25 | + * @var null|string |
|
| 26 | + */ |
|
| 27 | + private ?string $extension_url; |
|
| 28 | + |
|
| 29 | + /** Extension directory. |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + private string $extension_dir; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Array of enabled widget_areas |
|
| 37 | + * |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + * @var array |
|
| 40 | + */ |
|
| 41 | + protected array $widget_areas = array(); |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Widget array. |
|
| 45 | + * |
|
| 46 | + * @var array |
|
| 47 | + */ |
|
| 48 | + protected array $orig = array(); |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * ReduxFramework object. |
|
| 52 | + * |
|
| 53 | + * @var ReduxFramework |
|
| 54 | + */ |
|
| 55 | + private ReduxFramework $parent; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Redux_Widget_Areas constructor. |
|
| 59 | + * |
|
| 60 | + * @param ReduxFramework $redux ReduxFramework pointer. |
|
| 61 | + */ |
|
| 62 | + public function __construct( ReduxFramework $redux ) { |
|
| 63 | + global $pagenow; |
|
| 64 | + |
|
| 65 | + $this->parent = $redux; |
|
| 66 | + |
|
| 67 | + if ( empty( $this->extension_dir ) ) { |
|
| 68 | + $this->extension_dir = trailingslashit( str_replace( '\\', '/', __DIR__ ) ); |
|
| 69 | + $this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) ); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + add_action( 'init', array( &$this, 'register_custom_widget_areas' ), 1000 ); |
|
| 73 | + |
|
| 74 | + if ( 'widgets.php' === $pagenow ) { |
|
| 75 | + if ( true === $redux->args['widget_area'] ) { |
|
| 76 | + add_action( 'admin_print_scripts', array( $this, 'add_new_widget_area_box' ) ); |
|
| 77 | + } |
|
| 78 | + add_action( 'load-widgets.php', array( $this, 'add_widget_area_area' ), 100 ); |
|
| 79 | + add_action( 'load-widgets.php', array( $this, 'enqueue' ), 100 ); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Function to create the HTML used to create widget_areas. |
|
| 85 | + * |
|
| 86 | + * @since 1.0.0 |
|
| 87 | + */ |
|
| 88 | + public function add_new_widget_area_box() { |
|
| 89 | + $nonce = wp_create_nonce( 'add-redux-widget_area-nonce' ); |
|
| 90 | + $del_nonce = wp_create_nonce( 'delete-redux-widget_area-nonce' ); |
|
| 91 | + |
|
| 92 | + ?> |
|
| 93 | 93 | <script type="text/html" id="redux-add-widget-template"> |
| 94 | 94 | <div id="redux-add-widget" class="widgets-holder-wrap"> |
| 95 | 95 | <div class=""> |
@@ -122,191 +122,191 @@ discard block |
||
| 122 | 122 | </div> |
| 123 | 123 | </script> |
| 124 | 124 | <?php |
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Add widget area. |
|
| 129 | - */ |
|
| 130 | - public function add_widget_area_area() { |
|
| 131 | - if ( isset( $_POST ) && isset( $_POST['redux-add-widget-nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['redux-add-widget-nonce'] ) ), 'add-redux-widget_area-nonce' ) ) { |
|
| 132 | - if ( ! empty( $_POST['redux-add-widget-input'] ) ) { |
|
| 133 | - $this->widget_areas = $this->get_widget_areas(); |
|
| 134 | - |
|
| 135 | - $this->widget_areas[] = $this->check_widget_area_name( sanitize_text_field( wp_unslash( $_POST['redux-add-widget-input'] ) ) ); |
|
| 136 | - |
|
| 137 | - $this->save_widget_areas(); |
|
| 138 | - |
|
| 139 | - wp_safe_redirect( admin_url( 'widgets.php' ) ); |
|
| 140 | - |
|
| 141 | - die(); |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Before we create a new widget_area, verify it doesn't already exist. If it does, append a number to the name. |
|
| 148 | - * |
|
| 149 | - * @param string $name Name of the widget_area to be created. |
|
| 150 | - * |
|
| 151 | - * @return string|void $name Name of the new widget_area just created. |
|
| 152 | - * @since 1.0.0 |
|
| 153 | - */ |
|
| 154 | - private function check_widget_area_name( string $name ) { |
|
| 155 | - if ( empty( $GLOBALS['wp_registered_widget_areas'] ) ) { |
|
| 156 | - return $name; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $taken = array(); |
|
| 160 | - |
|
| 161 | - foreach ( $GLOBALS['wp_registered_widget_areas'] as $widget_area ) { |
|
| 162 | - $taken[] = $widget_area['name']; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $taken = array_merge( $taken, $this->widget_areas ); |
|
| 166 | - |
|
| 167 | - if ( in_array( $name, $taken, true ) ) { |
|
| 168 | - $counter = substr( $name, - 1 ); |
|
| 169 | - |
|
| 170 | - if ( ! is_numeric( $counter ) ) { |
|
| 171 | - $new_name = $name . ' 1'; |
|
| 172 | - } else { |
|
| 173 | - $new_name = substr( $name, 0, - 1 ) . ( (int) $counter + 1 ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $name = $this->check_widget_area_name( $new_name ); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - echo $name; // phpcs:disable WordPress.Security.EscapeOutput |
|
| 180 | - |
|
| 181 | - exit(); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Save Widget Areas. |
|
| 186 | - */ |
|
| 187 | - private function save_widget_areas() { |
|
| 188 | - set_theme_mod( 'redux-widget-areas', array_unique( $this->widget_areas ) ); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Register and display the custom widget_area areas we have set. |
|
| 193 | - * |
|
| 194 | - * @since 1.0.0 |
|
| 195 | - */ |
|
| 196 | - public function register_custom_widget_areas() { |
|
| 197 | - |
|
| 198 | - // If the single instance hasn't been set, set it now. |
|
| 199 | - if ( empty( $this->widget_areas ) ) { |
|
| 200 | - $this->widget_areas = $this->get_widget_areas(); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 204 | - $this->orig = array_unique( apply_filters( 'redux/' . $this->parent->args['opt_name'] . '/widget_areas', array() ) ); |
|
| 205 | - |
|
| 206 | - if ( ! empty( $this->orig ) && $this->orig !== $this->widget_areas ) { |
|
| 207 | - $this->widget_areas = array_unique( array_merge( $this->widget_areas, $this->orig ) ); |
|
| 208 | - $this->save_widget_areas(); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $options = array( |
|
| 212 | - 'before_title' => '<h3 class="widgettitle">', |
|
| 213 | - 'after_title' => '</h3>', |
|
| 214 | - 'before_widget' => '<div id="%1$s" class="widget clearfix %2$s">', |
|
| 215 | - 'after_widget' => '</div>', |
|
| 216 | - ); |
|
| 217 | - |
|
| 218 | - $options = apply_filters( 'redux_custom_widget_args', $options ); |
|
| 219 | - |
|
| 220 | - foreach ( array_unique( $this->widget_areas ) as $widget_area ) { |
|
| 221 | - $options['class'] = 'redux-custom'; |
|
| 222 | - $options['name'] = $widget_area; |
|
| 223 | - $options['id'] = sanitize_key( $widget_area ); |
|
| 224 | - |
|
| 225 | - register_sidebar( $options ); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Return the widget_areas array. |
|
| 232 | - * |
|
| 233 | - * @since 1.0.0 |
|
| 234 | - * @return array If not empty, active redux widget_areas are returned. |
|
| 235 | - */ |
|
| 236 | - public function get_widget_areas(): array { |
|
| 237 | - |
|
| 238 | - // If the single instance hasn't been set, set it now. |
|
| 239 | - if ( ! empty( $this->widget_areas ) ) { |
|
| 240 | - return $this->widget_areas; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - $db = get_theme_mod( 'redux-widget-areas' ); |
|
| 244 | - |
|
| 245 | - if ( ! empty( $db ) ) { |
|
| 246 | - $this->widget_areas = array_unique( array_merge( $this->widget_areas, $db ) ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return $this->widget_areas; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Delete widget area. |
|
| 254 | - */ |
|
| 255 | - public function redux_delete_widget_area_area() { |
|
| 256 | - if ( isset( $_POST ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'delete-redux-widget_area-nonce' ) ) { |
|
| 257 | - if ( isset( $_POST['name'] ) && ! empty( sanitize_text_field( wp_unslash( $_POST['name'] ) ) ) ) { |
|
| 258 | - $name = sanitize_text_field( wp_unslash( $_POST['name'] ) ); |
|
| 259 | - $this->widget_areas = $this->get_widget_areas(); |
|
| 260 | - $key = array_search( $name, $this->widget_areas, true ); |
|
| 261 | - |
|
| 262 | - if ( $key >= 0 ) { |
|
| 263 | - unset( $this->widget_areas[ $key ] ); |
|
| 264 | - $this->save_widget_areas(); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - echo 'widget_area-deleted'; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - die(); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Enqueue support files. |
|
| 276 | - */ |
|
| 277 | - public function enqueue() { |
|
| 278 | - $min = Redux_Functions::is_min(); |
|
| 279 | - |
|
| 280 | - wp_enqueue_style( 'dashicons' ); |
|
| 281 | - |
|
| 282 | - wp_enqueue_script( |
|
| 283 | - 'redux-widget-areas', |
|
| 284 | - $this->extension_url . 'redux-extension-widget-areas' . $min . '.js', |
|
| 285 | - array( 'jquery' ), |
|
| 286 | - Redux_Extension_Widget_Areas::$version, |
|
| 287 | - true |
|
| 288 | - ); |
|
| 289 | - |
|
| 290 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 291 | - wp_enqueue_style( |
|
| 292 | - 'redux-widget-areas', |
|
| 293 | - $this->extension_url . 'redux-extension-widget-areas.css', |
|
| 294 | - array(), |
|
| 295 | - Redux_Extension_Widget_Areas::$version |
|
| 296 | - ); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - // Localize script. |
|
| 300 | - wp_localize_script( |
|
| 301 | - 'redux-widget-areas', |
|
| 302 | - 'reduxWidgetAreasLocalize', |
|
| 303 | - array( |
|
| 304 | - 'count' => count( $this->orig ), |
|
| 305 | - 'delete' => esc_html__( 'Delete', 'redux-framework' ), |
|
| 306 | - 'confirm' => esc_html__( 'Confirm', 'redux-framework' ), |
|
| 307 | - 'cancel' => esc_html__( 'Cancel', 'redux-framework' ), |
|
| 308 | - ) |
|
| 309 | - ); |
|
| 310 | - } |
|
| 311 | - } |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Add widget area. |
|
| 129 | + */ |
|
| 130 | + public function add_widget_area_area() { |
|
| 131 | + if ( isset( $_POST ) && isset( $_POST['redux-add-widget-nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['redux-add-widget-nonce'] ) ), 'add-redux-widget_area-nonce' ) ) { |
|
| 132 | + if ( ! empty( $_POST['redux-add-widget-input'] ) ) { |
|
| 133 | + $this->widget_areas = $this->get_widget_areas(); |
|
| 134 | + |
|
| 135 | + $this->widget_areas[] = $this->check_widget_area_name( sanitize_text_field( wp_unslash( $_POST['redux-add-widget-input'] ) ) ); |
|
| 136 | + |
|
| 137 | + $this->save_widget_areas(); |
|
| 138 | + |
|
| 139 | + wp_safe_redirect( admin_url( 'widgets.php' ) ); |
|
| 140 | + |
|
| 141 | + die(); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Before we create a new widget_area, verify it doesn't already exist. If it does, append a number to the name. |
|
| 148 | + * |
|
| 149 | + * @param string $name Name of the widget_area to be created. |
|
| 150 | + * |
|
| 151 | + * @return string|void $name Name of the new widget_area just created. |
|
| 152 | + * @since 1.0.0 |
|
| 153 | + */ |
|
| 154 | + private function check_widget_area_name( string $name ) { |
|
| 155 | + if ( empty( $GLOBALS['wp_registered_widget_areas'] ) ) { |
|
| 156 | + return $name; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $taken = array(); |
|
| 160 | + |
|
| 161 | + foreach ( $GLOBALS['wp_registered_widget_areas'] as $widget_area ) { |
|
| 162 | + $taken[] = $widget_area['name']; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $taken = array_merge( $taken, $this->widget_areas ); |
|
| 166 | + |
|
| 167 | + if ( in_array( $name, $taken, true ) ) { |
|
| 168 | + $counter = substr( $name, - 1 ); |
|
| 169 | + |
|
| 170 | + if ( ! is_numeric( $counter ) ) { |
|
| 171 | + $new_name = $name . ' 1'; |
|
| 172 | + } else { |
|
| 173 | + $new_name = substr( $name, 0, - 1 ) . ( (int) $counter + 1 ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $name = $this->check_widget_area_name( $new_name ); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + echo $name; // phpcs:disable WordPress.Security.EscapeOutput |
|
| 180 | + |
|
| 181 | + exit(); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Save Widget Areas. |
|
| 186 | + */ |
|
| 187 | + private function save_widget_areas() { |
|
| 188 | + set_theme_mod( 'redux-widget-areas', array_unique( $this->widget_areas ) ); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Register and display the custom widget_area areas we have set. |
|
| 193 | + * |
|
| 194 | + * @since 1.0.0 |
|
| 195 | + */ |
|
| 196 | + public function register_custom_widget_areas() { |
|
| 197 | + |
|
| 198 | + // If the single instance hasn't been set, set it now. |
|
| 199 | + if ( empty( $this->widget_areas ) ) { |
|
| 200 | + $this->widget_areas = $this->get_widget_areas(); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 204 | + $this->orig = array_unique( apply_filters( 'redux/' . $this->parent->args['opt_name'] . '/widget_areas', array() ) ); |
|
| 205 | + |
|
| 206 | + if ( ! empty( $this->orig ) && $this->orig !== $this->widget_areas ) { |
|
| 207 | + $this->widget_areas = array_unique( array_merge( $this->widget_areas, $this->orig ) ); |
|
| 208 | + $this->save_widget_areas(); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $options = array( |
|
| 212 | + 'before_title' => '<h3 class="widgettitle">', |
|
| 213 | + 'after_title' => '</h3>', |
|
| 214 | + 'before_widget' => '<div id="%1$s" class="widget clearfix %2$s">', |
|
| 215 | + 'after_widget' => '</div>', |
|
| 216 | + ); |
|
| 217 | + |
|
| 218 | + $options = apply_filters( 'redux_custom_widget_args', $options ); |
|
| 219 | + |
|
| 220 | + foreach ( array_unique( $this->widget_areas ) as $widget_area ) { |
|
| 221 | + $options['class'] = 'redux-custom'; |
|
| 222 | + $options['name'] = $widget_area; |
|
| 223 | + $options['id'] = sanitize_key( $widget_area ); |
|
| 224 | + |
|
| 225 | + register_sidebar( $options ); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Return the widget_areas array. |
|
| 232 | + * |
|
| 233 | + * @since 1.0.0 |
|
| 234 | + * @return array If not empty, active redux widget_areas are returned. |
|
| 235 | + */ |
|
| 236 | + public function get_widget_areas(): array { |
|
| 237 | + |
|
| 238 | + // If the single instance hasn't been set, set it now. |
|
| 239 | + if ( ! empty( $this->widget_areas ) ) { |
|
| 240 | + return $this->widget_areas; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + $db = get_theme_mod( 'redux-widget-areas' ); |
|
| 244 | + |
|
| 245 | + if ( ! empty( $db ) ) { |
|
| 246 | + $this->widget_areas = array_unique( array_merge( $this->widget_areas, $db ) ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return $this->widget_areas; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Delete widget area. |
|
| 254 | + */ |
|
| 255 | + public function redux_delete_widget_area_area() { |
|
| 256 | + if ( isset( $_POST ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'delete-redux-widget_area-nonce' ) ) { |
|
| 257 | + if ( isset( $_POST['name'] ) && ! empty( sanitize_text_field( wp_unslash( $_POST['name'] ) ) ) ) { |
|
| 258 | + $name = sanitize_text_field( wp_unslash( $_POST['name'] ) ); |
|
| 259 | + $this->widget_areas = $this->get_widget_areas(); |
|
| 260 | + $key = array_search( $name, $this->widget_areas, true ); |
|
| 261 | + |
|
| 262 | + if ( $key >= 0 ) { |
|
| 263 | + unset( $this->widget_areas[ $key ] ); |
|
| 264 | + $this->save_widget_areas(); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + echo 'widget_area-deleted'; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + die(); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Enqueue support files. |
|
| 276 | + */ |
|
| 277 | + public function enqueue() { |
|
| 278 | + $min = Redux_Functions::is_min(); |
|
| 279 | + |
|
| 280 | + wp_enqueue_style( 'dashicons' ); |
|
| 281 | + |
|
| 282 | + wp_enqueue_script( |
|
| 283 | + 'redux-widget-areas', |
|
| 284 | + $this->extension_url . 'redux-extension-widget-areas' . $min . '.js', |
|
| 285 | + array( 'jquery' ), |
|
| 286 | + Redux_Extension_Widget_Areas::$version, |
|
| 287 | + true |
|
| 288 | + ); |
|
| 289 | + |
|
| 290 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 291 | + wp_enqueue_style( |
|
| 292 | + 'redux-widget-areas', |
|
| 293 | + $this->extension_url . 'redux-extension-widget-areas.css', |
|
| 294 | + array(), |
|
| 295 | + Redux_Extension_Widget_Areas::$version |
|
| 296 | + ); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + // Localize script. |
|
| 300 | + wp_localize_script( |
|
| 301 | + 'redux-widget-areas', |
|
| 302 | + 'reduxWidgetAreasLocalize', |
|
| 303 | + array( |
|
| 304 | + 'count' => count( $this->orig ), |
|
| 305 | + 'delete' => esc_html__( 'Delete', 'redux-framework' ), |
|
| 306 | + 'confirm' => esc_html__( 'Confirm', 'redux-framework' ), |
|
| 307 | + 'cancel' => esc_html__( 'Cancel', 'redux-framework' ), |
|
| 308 | + ) |
|
| 309 | + ); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | 312 | } |
@@ -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,154 +71,154 @@ 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, |
|
| 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 | 222 | ); |
| 223 | 223 | |
| 224 | 224 | |
@@ -226,53 +226,53 @@ discard block |
||
| 226 | 226 | // PLEASE CHANGE THESE SETTINGS IN YOUR THEME BEFORE RELEASING YOUR PRODUCT!! |
| 227 | 227 | // If these are left unchanged, they will not display in your panel! |
| 228 | 228 | $args['admin_bar_links'][] = array( |
| 229 | - 'id' => 'redux-docs', |
|
| 230 | - 'href' => '//devs.redux.io/', |
|
| 231 | - 'title' => __( 'Documentation', 'your-textdomain-here' ), |
|
| 229 | + 'id' => 'redux-docs', |
|
| 230 | + 'href' => '//devs.redux.io/', |
|
| 231 | + 'title' => __( 'Documentation', 'your-textdomain-here' ), |
|
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | 234 | $args['admin_bar_links'][] = array( |
| 235 | - 'id' => 'redux-support', |
|
| 236 | - 'href' => '//github.com/ReduxFramework/redux-framework/issues', |
|
| 237 | - 'title' => __( 'Support', 'your-textdomain-here' ), |
|
| 235 | + 'id' => 'redux-support', |
|
| 236 | + 'href' => '//github.com/ReduxFramework/redux-framework/issues', |
|
| 237 | + 'title' => __( 'Support', 'your-textdomain-here' ), |
|
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | 240 | // SOCIAL ICONS → Set up custom links in the footer for quick links in your panel footer icons. |
| 241 | 241 | // PLEASE CHANGE THESE SETTINGS IN YOUR THEME BEFORE RELEASING YOUR PRODUCT!! |
| 242 | 242 | // If these are left unchanged, they will not display in your panel! |
| 243 | 243 | $args['share_icons'][] = array( |
| 244 | - 'url' => '//github.com/ReduxFramework/ReduxFramework', |
|
| 245 | - 'title' => 'Visit us on GitHub', |
|
| 246 | - 'icon' => 'el el-github', |
|
| 244 | + 'url' => '//github.com/ReduxFramework/ReduxFramework', |
|
| 245 | + 'title' => 'Visit us on GitHub', |
|
| 246 | + 'icon' => 'el el-github', |
|
| 247 | 247 | ); |
| 248 | 248 | $args['share_icons'][] = array( |
| 249 | - 'url' => '//www.facebook.com/pages/Redux-Framework/243141545850368', |
|
| 250 | - 'title' => 'Like us on Facebook', |
|
| 251 | - 'icon' => 'el el-facebook', |
|
| 249 | + 'url' => '//www.facebook.com/pages/Redux-Framework/243141545850368', |
|
| 250 | + 'title' => 'Like us on Facebook', |
|
| 251 | + 'icon' => 'el el-facebook', |
|
| 252 | 252 | ); |
| 253 | 253 | $args['share_icons'][] = array( |
| 254 | - 'url' => '//twitter.com/reduxframework', |
|
| 255 | - 'title' => 'Follow us on Twitter', |
|
| 256 | - 'icon' => 'el el-twitter', |
|
| 254 | + 'url' => '//twitter.com/reduxframework', |
|
| 255 | + 'title' => 'Follow us on Twitter', |
|
| 256 | + 'icon' => 'el el-twitter', |
|
| 257 | 257 | ); |
| 258 | 258 | $args['share_icons'][] = array( |
| 259 | - 'url' => '//www.linkedin.com/company/redux-framework', |
|
| 260 | - 'title' => 'Find us on LinkedIn', |
|
| 261 | - 'icon' => 'el el-linkedin', |
|
| 259 | + 'url' => '//www.linkedin.com/company/redux-framework', |
|
| 260 | + 'title' => 'Find us on LinkedIn', |
|
| 261 | + 'icon' => 'el el-linkedin', |
|
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | 264 | // Panel Intro text → before the form. |
| 265 | 265 | if ( ! isset( $args['global_variable'] ) || false !== $args['global_variable'] ) { |
| 266 | - if ( ! empty( $args['global_variable'] ) ) { |
|
| 267 | - $v = $args['global_variable']; |
|
| 268 | - } else { |
|
| 269 | - $v = str_replace( '-', '_', $args['opt_name'] ); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - // translators: Panel opt_name. |
|
| 273 | - $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>'; |
|
| 266 | + if ( ! empty( $args['global_variable'] ) ) { |
|
| 267 | + $v = $args['global_variable']; |
|
| 268 | + } else { |
|
| 269 | + $v = str_replace( '-', '_', $args['opt_name'] ); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + // translators: Panel opt_name. |
|
| 273 | + $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>'; |
|
| 274 | 274 | } else { |
| 275 | - $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>'; |
|
| 275 | + $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 | 276 | } |
| 277 | 277 | |
| 278 | 278 | // Add content after the form. |
@@ -288,16 +288,16 @@ discard block |
||
| 288 | 288 | * ---> START HELP TABS |
| 289 | 289 | */ |
| 290 | 290 | $help_tabs = array( |
| 291 | - array( |
|
| 292 | - 'id' => 'redux-help-tab-1', |
|
| 293 | - 'title' => esc_html__( 'Theme Information 1', 'your-textdomain-here' ), |
|
| 294 | - 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 295 | - ), |
|
| 296 | - array( |
|
| 297 | - 'id' => 'redux-help-tab-2', |
|
| 298 | - 'title' => esc_html__( 'Theme Information 2', 'your-textdomain-here' ), |
|
| 299 | - 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 300 | - ), |
|
| 291 | + array( |
|
| 292 | + 'id' => 'redux-help-tab-1', |
|
| 293 | + 'title' => esc_html__( 'Theme Information 1', 'your-textdomain-here' ), |
|
| 294 | + 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 295 | + ), |
|
| 296 | + array( |
|
| 297 | + 'id' => 'redux-help-tab-2', |
|
| 298 | + 'title' => esc_html__( 'Theme Information 2', 'your-textdomain-here' ), |
|
| 299 | + 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 300 | + ), |
|
| 301 | 301 | ); |
| 302 | 302 | Redux::set_help_tab( $opt_name, $help_tabs ); |
| 303 | 303 | |
@@ -316,14 +316,14 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // -> START Basic Fields |
| 318 | 318 | Redux::set_section( |
| 319 | - $opt_name, |
|
| 320 | - array( |
|
| 321 | - 'title' => esc_html__( 'Basic Fields', 'your-textdomain-here' ), |
|
| 322 | - 'id' => 'basic', |
|
| 323 | - 'desc' => esc_html__( 'These are really basic fields!', 'your-textdomain-here' ), |
|
| 324 | - 'customizer_width' => '400px', |
|
| 325 | - 'icon' => 'el el-home', |
|
| 326 | - ) |
|
| 319 | + $opt_name, |
|
| 320 | + array( |
|
| 321 | + 'title' => esc_html__( 'Basic Fields', 'your-textdomain-here' ), |
|
| 322 | + 'id' => 'basic', |
|
| 323 | + 'desc' => esc_html__( 'These are really basic fields!', 'your-textdomain-here' ), |
|
| 324 | + 'customizer_width' => '400px', |
|
| 325 | + 'icon' => 'el el-home', |
|
| 326 | + ) |
|
| 327 | 327 | ); |
| 328 | 328 | |
| 329 | 329 | require_once Redux_Core::$dir . '../sample/sections/basic-fields/checkbox.php'; |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | // -> START Editors. |
| 338 | 338 | Redux::set_section( |
| 339 | - $opt_name, |
|
| 340 | - array( |
|
| 341 | - 'title' => esc_html__( 'Editors', 'your-textdomain-here' ), |
|
| 342 | - 'id' => 'editor', |
|
| 343 | - 'customizer_width' => '500px', |
|
| 344 | - 'icon' => 'el el-edit', |
|
| 345 | - ) |
|
| 339 | + $opt_name, |
|
| 340 | + array( |
|
| 341 | + 'title' => esc_html__( 'Editors', 'your-textdomain-here' ), |
|
| 342 | + 'id' => 'editor', |
|
| 343 | + 'customizer_width' => '500px', |
|
| 344 | + 'icon' => 'el el-edit', |
|
| 345 | + ) |
|
| 346 | 346 | ); |
| 347 | 347 | |
| 348 | 348 | require_once Redux_Core::$dir . '../sample/sections/editors/wordpress-editor.php'; |
@@ -350,12 +350,12 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | // -> START Color Selection. |
| 352 | 352 | Redux::set_section( |
| 353 | - $opt_name, |
|
| 354 | - array( |
|
| 355 | - 'title' => esc_html__( 'Color Selection', 'your-textdomain-here' ), |
|
| 356 | - 'id' => 'color', |
|
| 357 | - 'icon' => 'el el-brush', |
|
| 358 | - ) |
|
| 353 | + $opt_name, |
|
| 354 | + array( |
|
| 355 | + 'title' => esc_html__( 'Color Selection', 'your-textdomain-here' ), |
|
| 356 | + 'id' => 'color', |
|
| 357 | + 'icon' => 'el el-brush', |
|
| 358 | + ) |
|
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | 361 | require_once Redux_Core::$dir . '../sample/sections/color-selection/color.php'; |
@@ -367,12 +367,12 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | // -> START Design Fields. |
| 369 | 369 | Redux::set_section( |
| 370 | - $opt_name, |
|
| 371 | - array( |
|
| 372 | - 'title' => esc_html__( 'Design Fields', 'your-textdomain-here' ), |
|
| 373 | - 'id' => 'design', |
|
| 374 | - 'icon' => 'el el-wrench', |
|
| 375 | - ) |
|
| 370 | + $opt_name, |
|
| 371 | + array( |
|
| 372 | + 'title' => esc_html__( 'Design Fields', 'your-textdomain-here' ), |
|
| 373 | + 'id' => 'design', |
|
| 374 | + 'icon' => 'el el-wrench', |
|
| 375 | + ) |
|
| 376 | 376 | ); |
| 377 | 377 | |
| 378 | 378 | require_once Redux_Core::$dir . '../sample/sections/design-fields/background.php'; |
@@ -383,12 +383,12 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | // -> START Media Uploads. |
| 385 | 385 | Redux::set_section( |
| 386 | - $opt_name, |
|
| 387 | - array( |
|
| 388 | - 'title' => esc_html__( 'Media Uploads', 'your-textdomain-here' ), |
|
| 389 | - 'id' => 'media', |
|
| 390 | - 'icon' => 'el el-picture', |
|
| 391 | - ) |
|
| 386 | + $opt_name, |
|
| 387 | + array( |
|
| 388 | + 'title' => esc_html__( 'Media Uploads', 'your-textdomain-here' ), |
|
| 389 | + 'id' => 'media', |
|
| 390 | + 'icon' => 'el el-picture', |
|
| 391 | + ) |
|
| 392 | 392 | ); |
| 393 | 393 | |
| 394 | 394 | require_once Redux_Core::$dir . '../sample/sections/media-uploads/gallery.php'; |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | |
| 399 | 399 | // -> START Presentation Fields. |
| 400 | 400 | Redux::set_section( |
| 401 | - $opt_name, |
|
| 402 | - array( |
|
| 403 | - 'title' => esc_html__( 'Presentation Fields', 'your-textdomain-here' ), |
|
| 404 | - 'id' => 'presentation', |
|
| 405 | - 'icon' => 'el el-screen', |
|
| 406 | - ) |
|
| 401 | + $opt_name, |
|
| 402 | + array( |
|
| 403 | + 'title' => esc_html__( 'Presentation Fields', 'your-textdomain-here' ), |
|
| 404 | + 'id' => 'presentation', |
|
| 405 | + 'icon' => 'el el-screen', |
|
| 406 | + ) |
|
| 407 | 407 | ); |
| 408 | 408 | |
| 409 | 409 | require_once Redux_Core::$dir . '../sample/sections/presentation-fields/divide.php'; |
@@ -412,21 +412,21 @@ discard block |
||
| 412 | 412 | require_once Redux_Core::$dir . '../sample/sections/presentation-fields/section.php'; |
| 413 | 413 | |
| 414 | 414 | Redux::set_section( |
| 415 | - $opt_name, |
|
| 416 | - array( |
|
| 417 | - 'id' => 'presentation-divide-sample', |
|
| 418 | - 'type' => 'divide', |
|
| 419 | - ) |
|
| 415 | + $opt_name, |
|
| 416 | + array( |
|
| 417 | + 'id' => 'presentation-divide-sample', |
|
| 418 | + 'type' => 'divide', |
|
| 419 | + ) |
|
| 420 | 420 | ); |
| 421 | 421 | |
| 422 | 422 | // → START Switch & Button Set. |
| 423 | 423 | Redux::set_section( |
| 424 | - $opt_name, |
|
| 425 | - array( |
|
| 426 | - 'title' => esc_html__( 'Switch / Button Set', 'your-textdomain-here' ), |
|
| 427 | - 'id' => 'switch_buttonset', |
|
| 428 | - 'icon' => 'el el-cogs', |
|
| 429 | - ) |
|
| 424 | + $opt_name, |
|
| 425 | + array( |
|
| 426 | + 'title' => esc_html__( 'Switch / Button Set', 'your-textdomain-here' ), |
|
| 427 | + 'id' => 'switch_buttonset', |
|
| 428 | + 'icon' => 'el el-cogs', |
|
| 429 | + ) |
|
| 430 | 430 | ); |
| 431 | 431 | |
| 432 | 432 | require_once Redux_Core::$dir . '../sample/sections/switch-button/button-set.php'; |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | // -> START Select Fields. |
| 436 | 436 | Redux::set_section( |
| 437 | - $opt_name, |
|
| 438 | - array( |
|
| 439 | - 'title' => esc_html__( 'Select Fields', 'your-textdomain-here' ), |
|
| 440 | - 'id' => 'select', |
|
| 441 | - 'icon' => 'el el-list-alt', |
|
| 442 | - ) |
|
| 437 | + $opt_name, |
|
| 438 | + array( |
|
| 439 | + 'title' => esc_html__( 'Select Fields', 'your-textdomain-here' ), |
|
| 440 | + 'id' => 'select', |
|
| 441 | + 'icon' => 'el el-list-alt', |
|
| 442 | + ) |
|
| 443 | 443 | ); |
| 444 | 444 | |
| 445 | 445 | require_once Redux_Core::$dir . '../sample/sections/select-fields/select.php'; |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | // -> START Slider / Spinner. |
| 450 | 450 | Redux::set_section( |
| 451 | - $opt_name, |
|
| 452 | - array( |
|
| 453 | - 'title' => esc_html__( 'Slider / Spinner', 'your-textdomain-here' ), |
|
| 454 | - 'id' => 'slider_spinner', |
|
| 455 | - 'icon' => 'el el-adjust-alt', |
|
| 456 | - ) |
|
| 451 | + $opt_name, |
|
| 452 | + array( |
|
| 453 | + 'title' => esc_html__( 'Slider / Spinner', 'your-textdomain-here' ), |
|
| 454 | + 'id' => 'slider_spinner', |
|
| 455 | + 'icon' => 'el el-adjust-alt', |
|
| 456 | + ) |
|
| 457 | 457 | ); |
| 458 | 458 | |
| 459 | 459 | require_once Redux_Core::$dir . '../sample/sections/slider-spinner/slider.php'; |
@@ -464,12 +464,12 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | // -> START Additional Types. |
| 466 | 466 | Redux::set_section( |
| 467 | - $opt_name, |
|
| 468 | - array( |
|
| 469 | - 'title' => esc_html__( 'Additional Types', 'your-textdomain-here' ), |
|
| 470 | - 'id' => 'additional', |
|
| 471 | - 'icon' => 'el el-magic', |
|
| 472 | - ) |
|
| 467 | + $opt_name, |
|
| 468 | + array( |
|
| 469 | + 'title' => esc_html__( 'Additional Types', 'your-textdomain-here' ), |
|
| 470 | + 'id' => 'additional', |
|
| 471 | + 'icon' => 'el el-magic', |
|
| 472 | + ) |
|
| 473 | 473 | ); |
| 474 | 474 | |
| 475 | 475 | require_once Redux_Core::$dir . '../sample/sections/additional-types/date.php'; |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | require_once Redux_Core::$dir . '../sample/sections/additional-types/raw.php'; |
| 479 | 479 | |
| 480 | 480 | Redux::set_section( |
| 481 | - $opt_name, |
|
| 482 | - array( |
|
| 483 | - 'title' => esc_html__( 'Advanced Features', 'your-textdomain-here' ), |
|
| 484 | - 'icon' => 'el el-thumbs-up', |
|
| 485 | - ) |
|
| 481 | + $opt_name, |
|
| 482 | + array( |
|
| 483 | + 'title' => esc_html__( 'Advanced Features', 'your-textdomain-here' ), |
|
| 484 | + 'icon' => 'el el-thumbs-up', |
|
| 485 | + ) |
|
| 486 | 486 | ); |
| 487 | 487 | |
| 488 | 488 | require_once Redux_Core::$dir . '../sample/sections/advanced-features/callback.php'; |
@@ -500,11 +500,11 @@ discard block |
||
| 500 | 500 | |
| 501 | 501 | // -> START Disabling. |
| 502 | 502 | Redux::set_section( |
| 503 | - $opt_name, |
|
| 504 | - array( |
|
| 505 | - 'title' => esc_html__( 'Disabling', 'your-textdomain-here' ), |
|
| 506 | - 'icon' => 'el el-lock', |
|
| 507 | - ) |
|
| 503 | + $opt_name, |
|
| 504 | + array( |
|
| 505 | + 'title' => esc_html__( 'Disabling', 'your-textdomain-here' ), |
|
| 506 | + 'icon' => 'el el-lock', |
|
| 507 | + ) |
|
| 508 | 508 | ); |
| 509 | 509 | |
| 510 | 510 | require_once Redux_Core::$dir . '../sample/sections/disabling/disable-field.php'; |
@@ -512,14 +512,14 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | // -> START Extensions. |
| 514 | 514 | Redux::set_section( |
| 515 | - $opt_name, |
|
| 516 | - array( |
|
| 517 | - 'title' => esc_html__( 'Redux Extensions', 'your-textdomain-here' ), |
|
| 518 | - 'id' => 'redux-extensions', |
|
| 519 | - 'icon' => 'el el-redux', |
|
| 520 | - 'class' => 'pro_highlight', |
|
| 521 | - '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>', |
|
| 522 | - ) |
|
| 515 | + $opt_name, |
|
| 516 | + array( |
|
| 517 | + 'title' => esc_html__( 'Redux Extensions', 'your-textdomain-here' ), |
|
| 518 | + 'id' => 'redux-extensions', |
|
| 519 | + 'icon' => 'el el-redux', |
|
| 520 | + 'class' => 'pro_highlight', |
|
| 521 | + '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>', |
|
| 522 | + ) |
|
| 523 | 523 | ); |
| 524 | 524 | |
| 525 | 525 | require_once Redux_Core::$dir . '../sample/sections/extensions/accordion.php'; |
@@ -545,46 +545,46 @@ discard block |
||
| 545 | 545 | * Raw README |
| 546 | 546 | */ |
| 547 | 547 | if ( file_exists( $dir . '/../README.md' ) ) { |
| 548 | - $section = array( |
|
| 549 | - 'icon' => 'el el-list-alt', |
|
| 550 | - 'title' => esc_html__( 'Documentation', 'your-textdomain-here' ), |
|
| 551 | - 'fields' => array( |
|
| 552 | - array( |
|
| 553 | - 'id' => 'opt-raw-documentation', |
|
| 554 | - 'type' => 'raw', |
|
| 555 | - 'markdown' => true, |
|
| 556 | - 'content_path' => __DIR__ . '/../README.md', // FULL PATH, not relative, please. |
|
| 557 | - ), |
|
| 558 | - ), |
|
| 559 | - ); |
|
| 560 | - |
|
| 561 | - Redux::set_section( $opt_name, $section ); |
|
| 548 | + $section = array( |
|
| 549 | + 'icon' => 'el el-list-alt', |
|
| 550 | + 'title' => esc_html__( 'Documentation', 'your-textdomain-here' ), |
|
| 551 | + 'fields' => array( |
|
| 552 | + array( |
|
| 553 | + 'id' => 'opt-raw-documentation', |
|
| 554 | + 'type' => 'raw', |
|
| 555 | + 'markdown' => true, |
|
| 556 | + 'content_path' => __DIR__ . '/../README.md', // FULL PATH, not relative, please. |
|
| 557 | + ), |
|
| 558 | + ), |
|
| 559 | + ); |
|
| 560 | + |
|
| 561 | + Redux::set_section( $opt_name, $section ); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | Redux::set_section( |
| 565 | - $opt_name, |
|
| 566 | - array( |
|
| 567 | - 'icon' => 'el el-list-alt', |
|
| 568 | - 'title' => esc_html__( 'Customizer Only', 'your-textdomain-here' ), |
|
| 569 | - 'desc' => '<p class="description">' . esc_html__( 'This Section should be visible only in Customizer', 'your-textdomain-here' ) . '</p>', |
|
| 570 | - 'customizer_only' => true, |
|
| 571 | - 'fields' => array( |
|
| 572 | - array( |
|
| 573 | - 'id' => 'opt-customizer-only', |
|
| 574 | - 'type' => 'select', |
|
| 575 | - 'title' => esc_html__( 'Customizer Only Option', 'your-textdomain-here' ), |
|
| 576 | - 'subtitle' => esc_html__( 'The subtitle is NOT visible in customizer', 'your-textdomain-here' ), |
|
| 577 | - 'desc' => esc_html__( 'The field desc is NOT visible in customizer.', 'your-textdomain-here' ), |
|
| 578 | - 'customizer_only' => true, |
|
| 579 | - 'options' => array( |
|
| 580 | - '1' => esc_html__( 'Opt 1', 'your-textdomain-here' ), |
|
| 581 | - '2' => esc_html__( 'Opt 2', 'your-textdomain-here' ), |
|
| 582 | - '3' => esc_html__( 'Opt 3', 'your-textdomain-here' ), |
|
| 583 | - ), |
|
| 584 | - 'default' => '2', |
|
| 585 | - ), |
|
| 586 | - ), |
|
| 587 | - ) |
|
| 565 | + $opt_name, |
|
| 566 | + array( |
|
| 567 | + 'icon' => 'el el-list-alt', |
|
| 568 | + 'title' => esc_html__( 'Customizer Only', 'your-textdomain-here' ), |
|
| 569 | + 'desc' => '<p class="description">' . esc_html__( 'This Section should be visible only in Customizer', 'your-textdomain-here' ) . '</p>', |
|
| 570 | + 'customizer_only' => true, |
|
| 571 | + 'fields' => array( |
|
| 572 | + array( |
|
| 573 | + 'id' => 'opt-customizer-only', |
|
| 574 | + 'type' => 'select', |
|
| 575 | + 'title' => esc_html__( 'Customizer Only Option', 'your-textdomain-here' ), |
|
| 576 | + 'subtitle' => esc_html__( 'The subtitle is NOT visible in customizer', 'your-textdomain-here' ), |
|
| 577 | + 'desc' => esc_html__( 'The field desc is NOT visible in customizer.', 'your-textdomain-here' ), |
|
| 578 | + 'customizer_only' => true, |
|
| 579 | + 'options' => array( |
|
| 580 | + '1' => esc_html__( 'Opt 1', 'your-textdomain-here' ), |
|
| 581 | + '2' => esc_html__( 'Opt 2', 'your-textdomain-here' ), |
|
| 582 | + '3' => esc_html__( 'Opt 3', 'your-textdomain-here' ), |
|
| 583 | + ), |
|
| 584 | + 'default' => '2', |
|
| 585 | + ), |
|
| 586 | + ), |
|
| 587 | + ) |
|
| 588 | 588 | ); |
| 589 | 589 | |
| 590 | 590 | /* |
@@ -614,150 +614,150 @@ discard block |
||
| 614 | 614 | // add_filter('redux/options/' . $opt_name . '/sections', 'dynamic_section'); |
| 615 | 615 | // . |
| 616 | 616 | if ( ! function_exists( 'compiler_action' ) ) { |
| 617 | - /** |
|
| 618 | - * This is a test function that will let you see when the compiler hook occurs. |
|
| 619 | - * It only runs if a field's value has changed and compiler => true is set. |
|
| 620 | - * |
|
| 621 | - * @param array $options Options values. |
|
| 622 | - * @param string $css Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 623 | - * @param array $changed_values Any values that have changed since last save. |
|
| 624 | - */ |
|
| 625 | - function compiler_action( array $options, string $css, array $changed_values ) { |
|
| 626 | - echo '<h1>The compiler hook has run!</h1>'; |
|
| 627 | - echo '<pre>'; |
|
| 628 | - // phpcs:ignore WordPress.PHP.DevelopmentFunctions |
|
| 629 | - print_r( $changed_values ); // Values that have changed since the last save. |
|
| 630 | - // echo '<br/>'; |
|
| 631 | - // print_r($options); //Option values. |
|
| 632 | - // echo '<br/>'; |
|
| 633 | - // print_r($css); // Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 634 | - echo '</pre>'; |
|
| 635 | - } |
|
| 617 | + /** |
|
| 618 | + * This is a test function that will let you see when the compiler hook occurs. |
|
| 619 | + * It only runs if a field's value has changed and compiler => true is set. |
|
| 620 | + * |
|
| 621 | + * @param array $options Options values. |
|
| 622 | + * @param string $css Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 623 | + * @param array $changed_values Any values that have changed since last save. |
|
| 624 | + */ |
|
| 625 | + function compiler_action( array $options, string $css, array $changed_values ) { |
|
| 626 | + echo '<h1>The compiler hook has run!</h1>'; |
|
| 627 | + echo '<pre>'; |
|
| 628 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions |
|
| 629 | + print_r( $changed_values ); // Values that have changed since the last save. |
|
| 630 | + // echo '<br/>'; |
|
| 631 | + // print_r($options); //Option values. |
|
| 632 | + // echo '<br/>'; |
|
| 633 | + // print_r($css); // Compiler selector CSS values compiler => array( CSS SELECTORS ). |
|
| 634 | + echo '</pre>'; |
|
| 635 | + } |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | if ( ! function_exists( 'redux_validate_callback_function' ) ) { |
| 639 | - /** |
|
| 640 | - * Custom function for the callback validation referenced above |
|
| 641 | - * |
|
| 642 | - * @param array $field Field array. |
|
| 643 | - * @param mixed $value New value. |
|
| 644 | - * @param mixed $existing_value Existing value. |
|
| 645 | - * |
|
| 646 | - * @return array |
|
| 647 | - */ |
|
| 648 | - function redux_validate_callback_function( array $field, $value, $existing_value ): array { |
|
| 649 | - $error = false; |
|
| 650 | - $warning = false; |
|
| 651 | - |
|
| 652 | - // Do your validation. |
|
| 653 | - if ( 1 === (int) $value ) { |
|
| 654 | - $error = true; |
|
| 655 | - $value = $existing_value; |
|
| 656 | - } elseif ( 2 === (int) $value ) { |
|
| 657 | - $warning = true; |
|
| 658 | - $value = $existing_value; |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - $return['value'] = $value; |
|
| 662 | - |
|
| 663 | - if ( true === $error ) { |
|
| 664 | - $field['msg'] = 'your custom error message'; |
|
| 665 | - $return['error'] = $field; |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - if ( true === $warning ) { |
|
| 669 | - $field['msg'] = 'your custom warning message'; |
|
| 670 | - $return['warning'] = $field; |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - return $return; |
|
| 674 | - } |
|
| 639 | + /** |
|
| 640 | + * Custom function for the callback validation referenced above |
|
| 641 | + * |
|
| 642 | + * @param array $field Field array. |
|
| 643 | + * @param mixed $value New value. |
|
| 644 | + * @param mixed $existing_value Existing value. |
|
| 645 | + * |
|
| 646 | + * @return array |
|
| 647 | + */ |
|
| 648 | + function redux_validate_callback_function( array $field, $value, $existing_value ): array { |
|
| 649 | + $error = false; |
|
| 650 | + $warning = false; |
|
| 651 | + |
|
| 652 | + // Do your validation. |
|
| 653 | + if ( 1 === (int) $value ) { |
|
| 654 | + $error = true; |
|
| 655 | + $value = $existing_value; |
|
| 656 | + } elseif ( 2 === (int) $value ) { |
|
| 657 | + $warning = true; |
|
| 658 | + $value = $existing_value; |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + $return['value'] = $value; |
|
| 662 | + |
|
| 663 | + if ( true === $error ) { |
|
| 664 | + $field['msg'] = 'your custom error message'; |
|
| 665 | + $return['error'] = $field; |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + if ( true === $warning ) { |
|
| 669 | + $field['msg'] = 'your custom warning message'; |
|
| 670 | + $return['warning'] = $field; |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + return $return; |
|
| 674 | + } |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
| 678 | 678 | if ( ! function_exists( 'dynamic_section' ) ) { |
| 679 | - /** |
|
| 680 | - * Custom function for filtering the section array. |
|
| 681 | - * Good for child themes to override or add to the sections. |
|
| 682 | - * Simply include this function in the child themes functions.php file. |
|
| 683 | - * NOTE: the defined constants for URLs and directories will NOT be available at this point in a child theme, |
|
| 684 | - * so you must use get_template_directory_uri() if you want to use any of the built-in icons. |
|
| 685 | - * |
|
| 686 | - * @param array $sections Section array. |
|
| 687 | - * |
|
| 688 | - * @return array |
|
| 689 | - */ |
|
| 690 | - function dynamic_section( array $sections ): array { |
|
| 691 | - $sections[] = array( |
|
| 692 | - 'title' => esc_html__( 'Section via hook', 'your-textdomain-here' ), |
|
| 693 | - '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>', |
|
| 694 | - 'icon' => 'el el-paper-clip', |
|
| 695 | - |
|
| 696 | - // Leave this as a blank section, no options just some intro text set above. |
|
| 697 | - 'fields' => array(), |
|
| 698 | - ); |
|
| 699 | - |
|
| 700 | - return $sections; |
|
| 701 | - } |
|
| 679 | + /** |
|
| 680 | + * Custom function for filtering the section array. |
|
| 681 | + * Good for child themes to override or add to the sections. |
|
| 682 | + * Simply include this function in the child themes functions.php file. |
|
| 683 | + * NOTE: the defined constants for URLs and directories will NOT be available at this point in a child theme, |
|
| 684 | + * so you must use get_template_directory_uri() if you want to use any of the built-in icons. |
|
| 685 | + * |
|
| 686 | + * @param array $sections Section array. |
|
| 687 | + * |
|
| 688 | + * @return array |
|
| 689 | + */ |
|
| 690 | + function dynamic_section( array $sections ): array { |
|
| 691 | + $sections[] = array( |
|
| 692 | + 'title' => esc_html__( 'Section via hook', 'your-textdomain-here' ), |
|
| 693 | + '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>', |
|
| 694 | + 'icon' => 'el el-paper-clip', |
|
| 695 | + |
|
| 696 | + // Leave this as a blank section, no options just some intro text set above. |
|
| 697 | + 'fields' => array(), |
|
| 698 | + ); |
|
| 699 | + |
|
| 700 | + return $sections; |
|
| 701 | + } |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | if ( ! function_exists( 'change_arguments' ) ) { |
| 705 | - /** |
|
| 706 | - * Filter hook for filtering the args. |
|
| 707 | - * Good for child themes to override or add to the args array. |
|
| 708 | - * It can also be used in other functions. |
|
| 709 | - * |
|
| 710 | - * @param array $args Global arguments array. |
|
| 711 | - * |
|
| 712 | - * @return array |
|
| 713 | - */ |
|
| 714 | - function change_arguments( array $args ): array { |
|
| 715 | - $args['dev_mode'] = true; |
|
| 716 | - |
|
| 717 | - return $args; |
|
| 718 | - } |
|
| 705 | + /** |
|
| 706 | + * Filter hook for filtering the args. |
|
| 707 | + * Good for child themes to override or add to the args array. |
|
| 708 | + * It can also be used in other functions. |
|
| 709 | + * |
|
| 710 | + * @param array $args Global arguments array. |
|
| 711 | + * |
|
| 712 | + * @return array |
|
| 713 | + */ |
|
| 714 | + function change_arguments( array $args ): array { |
|
| 715 | + $args['dev_mode'] = true; |
|
| 716 | + |
|
| 717 | + return $args; |
|
| 718 | + } |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | if ( ! function_exists( 'change_defaults' ) ) { |
| 722 | - /** |
|
| 723 | - * Filter hook for filtering the default value of any given field. Very useful in development mode. |
|
| 724 | - * |
|
| 725 | - * @param array $defaults Default value array. |
|
| 726 | - * |
|
| 727 | - * @return array |
|
| 728 | - */ |
|
| 729 | - function change_defaults( array $defaults ): array { |
|
| 730 | - $defaults['str_replace'] = esc_html__( 'Testing filter hook!', 'your-textdomain-here' ); |
|
| 731 | - |
|
| 732 | - return $defaults; |
|
| 733 | - } |
|
| 722 | + /** |
|
| 723 | + * Filter hook for filtering the default value of any given field. Very useful in development mode. |
|
| 724 | + * |
|
| 725 | + * @param array $defaults Default value array. |
|
| 726 | + * |
|
| 727 | + * @return array |
|
| 728 | + */ |
|
| 729 | + function change_defaults( array $defaults ): array { |
|
| 730 | + $defaults['str_replace'] = esc_html__( 'Testing filter hook!', 'your-textdomain-here' ); |
|
| 731 | + |
|
| 732 | + return $defaults; |
|
| 733 | + } |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | if ( ! function_exists( 'redux_custom_sanitize' ) ) { |
| 737 | - /** |
|
| 738 | - * Function to be used if the field sanitizes argument. |
|
| 739 | - * Return value MUST be formatted or cleaned text to display. |
|
| 740 | - * |
|
| 741 | - * @param string $value Value to evaluate or clean. Required. |
|
| 742 | - * |
|
| 743 | - * @return string |
|
| 744 | - */ |
|
| 745 | - function redux_custom_sanitize( string $value ): string { |
|
| 746 | - $return = ''; |
|
| 747 | - |
|
| 748 | - foreach ( explode( ' ', $value ) as $w ) { |
|
| 749 | - foreach ( str_split( $w ) as $k => $v ) { |
|
| 750 | - if ( ( $k + 1 ) % 2 !== 0 && ctype_alpha( $v ) ) { |
|
| 751 | - $return .= mb_strtoupper( $v ); |
|
| 752 | - } else { |
|
| 753 | - $return .= $v; |
|
| 754 | - } |
|
| 755 | - } |
|
| 756 | - |
|
| 757 | - $return .= ' '; |
|
| 758 | - } |
|
| 759 | - |
|
| 760 | - return $return; |
|
| 761 | - } |
|
| 737 | + /** |
|
| 738 | + * Function to be used if the field sanitizes argument. |
|
| 739 | + * Return value MUST be formatted or cleaned text to display. |
|
| 740 | + * |
|
| 741 | + * @param string $value Value to evaluate or clean. Required. |
|
| 742 | + * |
|
| 743 | + * @return string |
|
| 744 | + */ |
|
| 745 | + function redux_custom_sanitize( string $value ): string { |
|
| 746 | + $return = ''; |
|
| 747 | + |
|
| 748 | + foreach ( explode( ' ', $value ) as $w ) { |
|
| 749 | + foreach ( str_split( $w ) as $k => $v ) { |
|
| 750 | + if ( ( $k + 1 ) % 2 !== 0 && ctype_alpha( $v ) ) { |
|
| 751 | + $return .= mb_strtoupper( $v ); |
|
| 752 | + } else { |
|
| 753 | + $return .= $v; |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | + |
|
| 757 | + $return .= ' '; |
|
| 758 | + } |
|
| 759 | + |
|
| 760 | + return $return; |
|
| 761 | + } |
|
| 762 | 762 | } |
| 763 | 763 | // phpcs:enable |