@@ -16,115 +16,115 @@ |
||
| 16 | 16 | if ( ! class_exists( 'Redux_Extension_Icon_Select' ) ) { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Main ReduxFramework icon_select extension class |
|
| 21 | - * |
|
| 22 | - * @since 3.1.6 |
|
| 23 | - */ |
|
| 24 | - class Redux_Extension_Icon_Select extends Redux_Extension_Abstract { |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Extension version. |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - public static $version = '4.4.2'; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Extension friendly name. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public string $extension_name = 'Icon Select'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * ReduxFramework_Extension_Icon_Select constructor. |
|
| 42 | - * |
|
| 43 | - * @param ReduxFramework $redux ReduxFramework object. |
|
| 44 | - */ |
|
| 45 | - public function __construct( $redux ) { |
|
| 46 | - parent::__construct( $redux, __FILE__ ); |
|
| 47 | - |
|
| 48 | - $this->add_field( 'icon_select' ); |
|
| 49 | - |
|
| 50 | - add_action( 'wp_ajax_redux_get_icons', array( $this, 'get_icons' ) ); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Add icons to modal. |
|
| 55 | - * |
|
| 56 | - * @return void |
|
| 57 | - */ |
|
| 58 | - public function get_icons() { |
|
| 59 | - $nonce = ( ! empty( $_POST['nonce'] ) ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; |
|
| 60 | - $icon_set = ( ! empty( $_POST['icon_set'] ) ) ? sanitize_text_field( wp_unslash( $_POST['icon_set'] ) ) : ''; |
|
| 61 | - $select_text = ( ! empty( $_POST['select_text'] ) ) ? sanitize_text_field( wp_unslash( $_POST['select_text'] ) ) : ''; |
|
| 62 | - |
|
| 63 | - if ( ! wp_verify_nonce( $nonce, 'redux_icon_nonce' ) ) { |
|
| 64 | - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'redux-framework' ) ) ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - ob_start(); |
|
| 68 | - |
|
| 69 | - $class = ''; |
|
| 70 | - |
|
| 71 | - if ( 'font-awesome' === $icon_set ) { |
|
| 72 | - require_once Redux_Core::$dir . 'inc/lib/font-awesome-6-free.php'; |
|
| 73 | - |
|
| 74 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 75 | - $icon_lists = apply_filters( 'redux/extensions/icon_select/fontawesome/icons', redux_icon_select_fa_6_free() ); |
|
| 76 | - } elseif ( 'dashicons' === $icon_set ) { |
|
| 77 | - require_once Redux_Core::$dir . 'inc/lib/dashicons.php'; |
|
| 78 | - |
|
| 79 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 80 | - $icon_lists = apply_filters( 'redux/extensions/icon_select/dashicons/icons', redux_get_dashicons() ); |
|
| 81 | - } elseif ( 'elusive' === $icon_set ) { |
|
| 82 | - require_once Redux_Core::$dir . 'inc/lib/elusive-icons.php'; |
|
| 83 | - |
|
| 84 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 85 | - $icon_lists = apply_filters( 'redux/extensions/icon_select/elusive/icons', redux_get_font_icons() ); |
|
| 86 | - } else { |
|
| 87 | - $data = ( ! empty( $_POST['data'] ) ) ? ( wp_unslash( $_POST['data'] ) ) : ''; // phpcs:ignore WordPress.Security |
|
| 88 | - $data = json_decode( rawurldecode( $data ), true ); |
|
| 89 | - $icons = ''; |
|
| 90 | - |
|
| 91 | - foreach ( $data as $arr_data ) { |
|
| 92 | - if ( $arr_data['title'] === $select_text ) { |
|
| 93 | - $icons = $arr_data['icons']; |
|
| 94 | - |
|
| 95 | - $class = ( ! empty( $arr_data['class'] ) ? $arr_data['class'] . ' ' : '' ); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 100 | - $icon_lists = apply_filters( 'redux/extensions/icon_select/custom/icons', $icons ); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if ( ! empty( $icon_lists ) ) { |
|
| 104 | - foreach ( $icon_lists as $list ) { |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Icon output. |
|
| 108 | - * Custom output for icon libraries that support different standards. |
|
| 109 | - * |
|
| 110 | - * @param string $default Original output. |
|
| 111 | - * @param string $title Title of the icon. |
|
| 112 | - * @param string $class Class of the icon. |
|
| 113 | - * @param string $icon_Set Selected Icon set. |
|
| 114 | - * |
|
| 115 | - * @since 4.4.2 |
|
| 116 | - */ |
|
| 117 | - echo apply_filters( 'redux/extension/icon_select/' . $this->parent->args['opt_name'] . '/output', '<i title="' . esc_attr( $list ) . '" class="' . esc_attr( $class . ' ' . $list ) . '" /></i>', $list, $class, $select_text ); // phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.Security.EscapeOutput |
|
| 118 | - } |
|
| 119 | - } else { |
|
| 120 | - echo '<div class="redux-error-text">' . esc_html__( 'No data available.', 'redux-framework' ) . '</div>'; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $content = ob_get_clean(); |
|
| 124 | - |
|
| 125 | - wp_send_json_success( array( 'content' => $content ) ); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - class_alias( Redux_Extension_Icon_Select::class, 'ReduxFramework_extension_icon_select' ); |
|
| 19 | + /** |
|
| 20 | + * Main ReduxFramework icon_select extension class |
|
| 21 | + * |
|
| 22 | + * @since 3.1.6 |
|
| 23 | + */ |
|
| 24 | + class Redux_Extension_Icon_Select extends Redux_Extension_Abstract { |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Extension version. |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + public static $version = '4.4.2'; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Extension friendly name. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public string $extension_name = 'Icon Select'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * ReduxFramework_Extension_Icon_Select constructor. |
|
| 42 | + * |
|
| 43 | + * @param ReduxFramework $redux ReduxFramework object. |
|
| 44 | + */ |
|
| 45 | + public function __construct( $redux ) { |
|
| 46 | + parent::__construct( $redux, __FILE__ ); |
|
| 47 | + |
|
| 48 | + $this->add_field( 'icon_select' ); |
|
| 49 | + |
|
| 50 | + add_action( 'wp_ajax_redux_get_icons', array( $this, 'get_icons' ) ); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Add icons to modal. |
|
| 55 | + * |
|
| 56 | + * @return void |
|
| 57 | + */ |
|
| 58 | + public function get_icons() { |
|
| 59 | + $nonce = ( ! empty( $_POST['nonce'] ) ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; |
|
| 60 | + $icon_set = ( ! empty( $_POST['icon_set'] ) ) ? sanitize_text_field( wp_unslash( $_POST['icon_set'] ) ) : ''; |
|
| 61 | + $select_text = ( ! empty( $_POST['select_text'] ) ) ? sanitize_text_field( wp_unslash( $_POST['select_text'] ) ) : ''; |
|
| 62 | + |
|
| 63 | + if ( ! wp_verify_nonce( $nonce, 'redux_icon_nonce' ) ) { |
|
| 64 | + wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'redux-framework' ) ) ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + ob_start(); |
|
| 68 | + |
|
| 69 | + $class = ''; |
|
| 70 | + |
|
| 71 | + if ( 'font-awesome' === $icon_set ) { |
|
| 72 | + require_once Redux_Core::$dir . 'inc/lib/font-awesome-6-free.php'; |
|
| 73 | + |
|
| 74 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 75 | + $icon_lists = apply_filters( 'redux/extensions/icon_select/fontawesome/icons', redux_icon_select_fa_6_free() ); |
|
| 76 | + } elseif ( 'dashicons' === $icon_set ) { |
|
| 77 | + require_once Redux_Core::$dir . 'inc/lib/dashicons.php'; |
|
| 78 | + |
|
| 79 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 80 | + $icon_lists = apply_filters( 'redux/extensions/icon_select/dashicons/icons', redux_get_dashicons() ); |
|
| 81 | + } elseif ( 'elusive' === $icon_set ) { |
|
| 82 | + require_once Redux_Core::$dir . 'inc/lib/elusive-icons.php'; |
|
| 83 | + |
|
| 84 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 85 | + $icon_lists = apply_filters( 'redux/extensions/icon_select/elusive/icons', redux_get_font_icons() ); |
|
| 86 | + } else { |
|
| 87 | + $data = ( ! empty( $_POST['data'] ) ) ? ( wp_unslash( $_POST['data'] ) ) : ''; // phpcs:ignore WordPress.Security |
|
| 88 | + $data = json_decode( rawurldecode( $data ), true ); |
|
| 89 | + $icons = ''; |
|
| 90 | + |
|
| 91 | + foreach ( $data as $arr_data ) { |
|
| 92 | + if ( $arr_data['title'] === $select_text ) { |
|
| 93 | + $icons = $arr_data['icons']; |
|
| 94 | + |
|
| 95 | + $class = ( ! empty( $arr_data['class'] ) ? $arr_data['class'] . ' ' : '' ); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 100 | + $icon_lists = apply_filters( 'redux/extensions/icon_select/custom/icons', $icons ); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if ( ! empty( $icon_lists ) ) { |
|
| 104 | + foreach ( $icon_lists as $list ) { |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Icon output. |
|
| 108 | + * Custom output for icon libraries that support different standards. |
|
| 109 | + * |
|
| 110 | + * @param string $default Original output. |
|
| 111 | + * @param string $title Title of the icon. |
|
| 112 | + * @param string $class Class of the icon. |
|
| 113 | + * @param string $icon_Set Selected Icon set. |
|
| 114 | + * |
|
| 115 | + * @since 4.4.2 |
|
| 116 | + */ |
|
| 117 | + echo apply_filters( 'redux/extension/icon_select/' . $this->parent->args['opt_name'] . '/output', '<i title="' . esc_attr( $list ) . '" class="' . esc_attr( $class . ' ' . $list ) . '" /></i>', $list, $class, $select_text ); // phpcs:ignore WordPress.NamingConventions.ValidHookName, WordPress.Security.EscapeOutput |
|
| 118 | + } |
|
| 119 | + } else { |
|
| 120 | + echo '<div class="redux-error-text">' . esc_html__( 'No data available.', 'redux-framework' ) . '</div>'; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $content = ob_get_clean(); |
|
| 124 | + |
|
| 125 | + wp_send_json_success( array( 'content' => $content ) ); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + class_alias( Redux_Extension_Icon_Select::class, 'ReduxFramework_extension_icon_select' ); |
|
| 130 | 130 | } |
@@ -15,78 +15,78 @@ |
||
| 15 | 15 | if ( ! class_exists( 'Redux_Extension_Options_Object', false ) ) { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Main ReduxFramework options_object extension class |
|
| 20 | - * |
|
| 21 | - * @since 3.1.6 |
|
| 22 | - */ |
|
| 23 | - class Redux_Extension_Options_Object extends Redux_Extension_Abstract { |
|
| 18 | + /** |
|
| 19 | + * Main ReduxFramework options_object extension class |
|
| 20 | + * |
|
| 21 | + * @since 3.1.6 |
|
| 22 | + */ |
|
| 23 | + class Redux_Extension_Options_Object extends Redux_Extension_Abstract { |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Ext version. |
|
| 27 | - * |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - public static $version = '4.0.0'; |
|
| 25 | + /** |
|
| 26 | + * Ext version. |
|
| 27 | + * |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + public static $version = '4.0.0'; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Set the name of the field. Ideally, this will also be your extension's name. |
|
| 34 | - * Please use underscores and NOT dashes. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - private string $field_name = 'options_object'; |
|
| 32 | + /** |
|
| 33 | + * Set the name of the field. Ideally, this will also be your extension's name. |
|
| 34 | + * Please use underscores and NOT dashes. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + private string $field_name = 'options_object'; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Is field bit. |
|
| 42 | - * |
|
| 43 | - * @var bool |
|
| 44 | - */ |
|
| 45 | - public bool $is_field = false; |
|
| 40 | + /** |
|
| 41 | + * Is field bit. |
|
| 42 | + * |
|
| 43 | + * @var bool |
|
| 44 | + */ |
|
| 45 | + public bool $is_field = false; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Class Constructor. Defines the args for the extensions class |
|
| 49 | - * |
|
| 50 | - * @since 1.0.0 |
|
| 51 | - * @access public |
|
| 52 | - * |
|
| 53 | - * @param object $redux Redux object. |
|
| 54 | - * |
|
| 55 | - * @return void |
|
| 56 | - */ |
|
| 57 | - public function __construct( $redux ) { |
|
| 58 | - parent::__construct( $redux, __FILE__ ); |
|
| 47 | + /** |
|
| 48 | + * Class Constructor. Defines the args for the extensions class |
|
| 49 | + * |
|
| 50 | + * @since 1.0.0 |
|
| 51 | + * @access public |
|
| 52 | + * |
|
| 53 | + * @param object $redux Redux object. |
|
| 54 | + * |
|
| 55 | + * @return void |
|
| 56 | + */ |
|
| 57 | + public function __construct( $redux ) { |
|
| 58 | + parent::__construct( $redux, __FILE__ ); |
|
| 59 | 59 | |
| 60 | - $this->add_field( $this->field_name ); |
|
| 61 | - $this->is_field = Redux_Helpers::is_field_in_use( $redux, $this->field_name ); |
|
| 60 | + $this->add_field( $this->field_name ); |
|
| 61 | + $this->is_field = Redux_Helpers::is_field_in_use( $redux, $this->field_name ); |
|
| 62 | 62 | |
| 63 | - if ( ! $this->is_field && $this->parent->args['dev_mode'] && $this->parent->args['show_options_object'] ) { |
|
| 64 | - $this->add_section(); |
|
| 65 | - } |
|
| 66 | - } |
|
| 63 | + if ( ! $this->is_field && $this->parent->args['dev_mode'] && $this->parent->args['show_options_object'] ) { |
|
| 64 | + $this->add_section(); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Add section to panel. |
|
| 70 | - */ |
|
| 71 | - public function add_section() { |
|
| 72 | - $this->parent->sections[] = array( |
|
| 73 | - 'id' => 'options-object', |
|
| 74 | - 'title' => esc_html__( 'Options Object', 'redux-framework' ), |
|
| 75 | - 'heading' => '', |
|
| 76 | - 'icon' => 'el el-info-circle', |
|
| 77 | - 'customizer' => false, |
|
| 78 | - 'fields' => array( |
|
| 79 | - array( |
|
| 80 | - 'id' => 'redux_options_object', |
|
| 81 | - 'type' => 'options_object', |
|
| 82 | - 'title' => '', |
|
| 83 | - ), |
|
| 84 | - ), |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - } |
|
| 68 | + /** |
|
| 69 | + * Add section to panel. |
|
| 70 | + */ |
|
| 71 | + public function add_section() { |
|
| 72 | + $this->parent->sections[] = array( |
|
| 73 | + 'id' => 'options-object', |
|
| 74 | + 'title' => esc_html__( 'Options Object', 'redux-framework' ), |
|
| 75 | + 'heading' => '', |
|
| 76 | + 'icon' => 'el el-info-circle', |
|
| 77 | + 'customizer' => false, |
|
| 78 | + 'fields' => array( |
|
| 79 | + array( |
|
| 80 | + 'id' => 'redux_options_object', |
|
| 81 | + 'type' => 'options_object', |
|
| 82 | + 'title' => '', |
|
| 83 | + ), |
|
| 84 | + ), |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if ( ! class_exists( 'ReduxFramework_Extension_options_object' ) ) { |
| 91 | - class_alias( 'Redux_Extension_Options_Object', 'ReduxFramework_Extension_options_object' ); |
|
| 91 | + class_alias( 'Redux_Extension_Options_Object', 'ReduxFramework_Extension_options_object' ); |
|
| 92 | 92 | } |
@@ -17,41 +17,41 @@ |
||
| 17 | 17 | if ( ! class_exists( 'Redux_Extension_Repeater' ) ) { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Class Redux_Extension_Repeater |
|
| 22 | - */ |
|
| 23 | - class Redux_Extension_Repeater extends Redux_Extension_Abstract { |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Extension version. |
|
| 27 | - * |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - public static $version = '4.3.13'; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Extension friendly name. |
|
| 34 | - * |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 37 | - public string $extension_name = 'Repeater'; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Class Constructor. Defines the args for the extensions class |
|
| 41 | - * |
|
| 42 | - * @since 1.0.0 |
|
| 43 | - * @access public |
|
| 44 | - * |
|
| 45 | - * @param object $redux Parent settings. |
|
| 46 | - * |
|
| 47 | - * @return void |
|
| 48 | - */ |
|
| 49 | - public function __construct( $redux ) { |
|
| 50 | - parent::__construct( $redux, __FILE__ ); |
|
| 51 | - |
|
| 52 | - $this->add_field( 'repeater' ); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - class_alias( Redux_Extension_Repeater::class, 'ReduxFramework_Extension_repeater' ); |
|
| 20 | + /** |
|
| 21 | + * Class Redux_Extension_Repeater |
|
| 22 | + */ |
|
| 23 | + class Redux_Extension_Repeater extends Redux_Extension_Abstract { |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Extension version. |
|
| 27 | + * |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + public static $version = '4.3.13'; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Extension friendly name. |
|
| 34 | + * |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | + public string $extension_name = 'Repeater'; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Class Constructor. Defines the args for the extensions class |
|
| 41 | + * |
|
| 42 | + * @since 1.0.0 |
|
| 43 | + * @access public |
|
| 44 | + * |
|
| 45 | + * @param object $redux Parent settings. |
|
| 46 | + * |
|
| 47 | + * @return void |
|
| 48 | + */ |
|
| 49 | + public function __construct( $redux ) { |
|
| 50 | + parent::__construct( $redux, __FILE__ ); |
|
| 51 | + |
|
| 52 | + $this->add_field( 'repeater' ); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + class_alias( Redux_Extension_Repeater::class, 'ReduxFramework_Extension_repeater' ); |
|
| 57 | 57 | } |
@@ -12,130 +12,130 @@ discard block |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Color_Scheme' ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main ReduxFramework_color_scheme class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Color_Scheme extends Redux_Field { |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Set Defaults. |
|
| 24 | - */ |
|
| 25 | - public function set_defaults() { |
|
| 26 | - // Validate. |
|
| 27 | - $this->field['options']['picker_font_size'] = $this->field['options']['picker_font_size'] ?? '11px'; |
|
| 28 | - $this->field['options']['picker_gap'] = $this->field['options']['picker_gap'] ?? '60px'; |
|
| 29 | - |
|
| 30 | - $this->field['options']['show_input'] = $this->field['options']['show_input'] ?? true; |
|
| 31 | - $this->field['options']['show_initial'] = $this->field['options']['show_initial'] ?? true; |
|
| 32 | - $this->field['options']['show_alpha'] = $this->field['options']['show_alpha'] ?? true; |
|
| 33 | - $this->field['options']['show_palette'] = $this->field['options']['show_palette'] ?? true; |
|
| 34 | - $this->field['options']['show_palette_only'] = $this->field['options']['show_palette_only'] ?? false; |
|
| 35 | - $this->field['options']['max_palette_size'] = $this->field['options']['max_palette_size'] ?? 10; |
|
| 36 | - $this->field['options']['show_selection_palette'] = $this->field['options']['show_selection_palette'] ?? true; |
|
| 37 | - $this->field['options']['allow_empty'] = $this->field['options']['allow_empty'] ?? true; |
|
| 38 | - $this->field['options']['clickout_fires_change'] = $this->field['options']['clickout_fires_change'] ?? false; |
|
| 39 | - $this->field['options']['choose_text'] = $this->field['options']['choose_text'] ?? 'Choose'; |
|
| 40 | - $this->field['options']['cancel_text'] = $this->field['options']['cancel_text'] ?? 'Cancel'; |
|
| 41 | - $this->field['options']['show_buttons'] = $this->field['options']['show_buttons'] ?? true; |
|
| 42 | - $this->field['options']['container_class'] = $this->field['options']['container_class'] ?? 'redux-colorpicker-container'; |
|
| 43 | - $this->field['options']['replacer_class'] = $this->field['options']['replacer_class'] ?? 'redux-colorpicker-replacer'; |
|
| 44 | - $this->field['options']['use_extended_classes'] = $this->field['options']['use_extended_classes'] ?? false; |
|
| 45 | - $this->field['options']['palette'] = $this->field['options']['palette'] ?? null; |
|
| 46 | - $this->field['simple'] = $this->field['simple'] ?? false; |
|
| 47 | - |
|
| 48 | - // Convert an empty array to null, if there. |
|
| 49 | - $this->field['options']['palette'] = empty( $this->field['options']['palette'] ) ? null : $this->field['options']['palette']; |
|
| 50 | - |
|
| 51 | - $this->field['no_compiler_output'] = $this->field['no_compiler_output'] ?? false; |
|
| 52 | - |
|
| 53 | - $this->field['output_transparent'] = $this->field['output_transparent'] ?? false; |
|
| 54 | - $this->field['accordion'] = $this->field['accordion'] ?? true; |
|
| 55 | - |
|
| 56 | - // tooltips. |
|
| 57 | - $this->field['tooltip_toggle'] = $this->field['tooltip_toggle'] ?? true; |
|
| 58 | - |
|
| 59 | - $this->field['tooltips']['style']['color'] = $this->field['tooltips']['style']['color'] ?? 'light'; |
|
| 60 | - $this->field['tooltips']['style']['shadow'] = $this->field['tooltips']['style']['shadow'] ?? true; |
|
| 61 | - $this->field['tooltips']['style']['rounded'] = $this->field['tooltips']['style']['rounded'] ?? false; |
|
| 62 | - $this->field['tooltips']['style']['style'] = $this->field['tooltips']['style']['style'] ?? ''; |
|
| 63 | - |
|
| 64 | - $this->field['tooltips']['position']['my'] = $this->field['tooltips']['position']['my'] ?? 'top center'; |
|
| 65 | - $this->field['tooltips']['position']['at'] = $this->field['tooltips']['position']['at'] ?? 'bottom center'; |
|
| 66 | - |
|
| 67 | - $this->field['tooltips']['effect']['show_effect'] = $this->field['tooltips']['effect']['show_effect'] ?? 'slide'; |
|
| 68 | - $this->field['tooltips']['effect']['show_duration'] = $this->field['tooltips']['effect']['show_duration'] ?? 500; |
|
| 69 | - $this->field['tooltips']['effect']['show_event'] = $this->field['tooltips']['effect']['show_event'] ?? 'mouseover'; |
|
| 70 | - $this->field['tooltips']['effect']['hide_effect'] = $this->field['tooltips']['effect']['hide_effect'] ?? 'slide'; |
|
| 71 | - $this->field['tooltips']['effect']['hide_duration'] = $this->field['tooltips']['effect']['hide_duration'] ?? 500; |
|
| 72 | - $this->field['tooltips']['effect']['hide_effect'] = $this->field['tooltips']['effect']['hide_effect'] ?? 'mouseleave'; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Field Render Function. |
|
| 77 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 78 | - * |
|
| 79 | - * @since 1.0.0 |
|
| 80 | - * @access public |
|
| 81 | - * @return void |
|
| 82 | - */ |
|
| 83 | - public function render() { |
|
| 84 | - $field_id = esc_attr( $this->field['id'] ); |
|
| 85 | - |
|
| 86 | - // Set field ID, just in case. |
|
| 87 | - Redux_Color_Scheme_Functions::$field_id = $field_id; |
|
| 88 | - Redux_Color_Scheme_Functions::$field = $this->field; |
|
| 89 | - Redux_Color_Scheme_Functions::$parent = $this->parent; |
|
| 90 | - |
|
| 91 | - if ( isset( $this->field['select'] ) ) { |
|
| 92 | - if ( is_array( $this->field['select'] ) && ! empty( $this->field['select'] ) ) { |
|
| 93 | - Redux_Color_Scheme_Functions::$select = $this->field['select']; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // Nonce. |
|
| 98 | - $nonce = wp_create_nonce( "redux_{$this->parent->args['opt_name']}_color_schemes" ); |
|
| 99 | - |
|
| 100 | - // Modal message. |
|
| 101 | - echo '<div id="redux-' . esc_attr( $field_id ) . '-scheme-message-notice" style="display:none; cursor: default">'; |
|
| 102 | - echo ' <h2>message</h2>'; |
|
| 103 | - echo ' <input type="button" id="redux-' . esc_attr( $field_id ) . '-scheme-ok" value="OK" />'; |
|
| 104 | - echo '</div>'; |
|
| 105 | - |
|
| 106 | - // Waiting message. |
|
| 107 | - echo '<div id="redux-' . esc_attr( $field_id ) . '-scheme-wait-message" style="display:none;">'; |
|
| 108 | - // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- Icon hard coded for project. |
|
| 109 | - echo ' <h1><img alt="Please wait..." src="' . esc_url( $this->url ) . 'img/busy.gif" /> Please wait...</h1>'; |
|
| 110 | - echo '</div>'; |
|
| 111 | - |
|
| 112 | - // Delete dialog. |
|
| 113 | - echo '<div id="redux-' . esc_attr( $field_id ) . '-delete-scheme-question" style="display:none; cursor: default">'; |
|
| 114 | - echo ' <h2>Are you sure you want to delete this scheme?</h2>'; |
|
| 115 | - echo ' <input type="button" id="redux-' . esc_attr( $field_id ) . '-delete-scheme-yes" value="Yes" />'; |
|
| 116 | - echo ' <input type="button" id="redux-' . esc_attr( $field_id ) . '-delete-scheme-no" value="No" />'; |
|
| 117 | - echo '</div>'; |
|
| 118 | - |
|
| 119 | - // Select2 params. |
|
| 120 | - if ( isset( $this->field['select2'] ) ) { // if there are any, let's pass them to js. |
|
| 121 | - $select2_params = wp_json_encode( $this->field['select2'] ); |
|
| 122 | - $select2_params = htmlspecialchars( $select2_params, ENT_QUOTES ); |
|
| 123 | - |
|
| 124 | - echo '<input type="hidden" class="select2_params" value="' . $select2_params . '">'; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $tt_in_use = Redux_Color_Scheme_Functions::tooltips_in_use( $this->field ); |
|
| 128 | - |
|
| 129 | - $tooltips = ''; |
|
| 130 | - if ( $tt_in_use ) { |
|
| 131 | - $tooltips = rawurlencode( wp_json_encode( $this->field['tooltips'] ) ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $tt_toggle_state = Redux_Color_Scheme_Functions::get_tooltip_toggle_state(); |
|
| 135 | - |
|
| 136 | - // Color picker container. |
|
| 137 | - // phpcs:disable WordPress.Security.EscapeOutput |
|
| 138 | - echo '<div |
|
| 15 | + /** |
|
| 16 | + * Main ReduxFramework_color_scheme class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Color_Scheme extends Redux_Field { |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Set Defaults. |
|
| 24 | + */ |
|
| 25 | + public function set_defaults() { |
|
| 26 | + // Validate. |
|
| 27 | + $this->field['options']['picker_font_size'] = $this->field['options']['picker_font_size'] ?? '11px'; |
|
| 28 | + $this->field['options']['picker_gap'] = $this->field['options']['picker_gap'] ?? '60px'; |
|
| 29 | + |
|
| 30 | + $this->field['options']['show_input'] = $this->field['options']['show_input'] ?? true; |
|
| 31 | + $this->field['options']['show_initial'] = $this->field['options']['show_initial'] ?? true; |
|
| 32 | + $this->field['options']['show_alpha'] = $this->field['options']['show_alpha'] ?? true; |
|
| 33 | + $this->field['options']['show_palette'] = $this->field['options']['show_palette'] ?? true; |
|
| 34 | + $this->field['options']['show_palette_only'] = $this->field['options']['show_palette_only'] ?? false; |
|
| 35 | + $this->field['options']['max_palette_size'] = $this->field['options']['max_palette_size'] ?? 10; |
|
| 36 | + $this->field['options']['show_selection_palette'] = $this->field['options']['show_selection_palette'] ?? true; |
|
| 37 | + $this->field['options']['allow_empty'] = $this->field['options']['allow_empty'] ?? true; |
|
| 38 | + $this->field['options']['clickout_fires_change'] = $this->field['options']['clickout_fires_change'] ?? false; |
|
| 39 | + $this->field['options']['choose_text'] = $this->field['options']['choose_text'] ?? 'Choose'; |
|
| 40 | + $this->field['options']['cancel_text'] = $this->field['options']['cancel_text'] ?? 'Cancel'; |
|
| 41 | + $this->field['options']['show_buttons'] = $this->field['options']['show_buttons'] ?? true; |
|
| 42 | + $this->field['options']['container_class'] = $this->field['options']['container_class'] ?? 'redux-colorpicker-container'; |
|
| 43 | + $this->field['options']['replacer_class'] = $this->field['options']['replacer_class'] ?? 'redux-colorpicker-replacer'; |
|
| 44 | + $this->field['options']['use_extended_classes'] = $this->field['options']['use_extended_classes'] ?? false; |
|
| 45 | + $this->field['options']['palette'] = $this->field['options']['palette'] ?? null; |
|
| 46 | + $this->field['simple'] = $this->field['simple'] ?? false; |
|
| 47 | + |
|
| 48 | + // Convert an empty array to null, if there. |
|
| 49 | + $this->field['options']['palette'] = empty( $this->field['options']['palette'] ) ? null : $this->field['options']['palette']; |
|
| 50 | + |
|
| 51 | + $this->field['no_compiler_output'] = $this->field['no_compiler_output'] ?? false; |
|
| 52 | + |
|
| 53 | + $this->field['output_transparent'] = $this->field['output_transparent'] ?? false; |
|
| 54 | + $this->field['accordion'] = $this->field['accordion'] ?? true; |
|
| 55 | + |
|
| 56 | + // tooltips. |
|
| 57 | + $this->field['tooltip_toggle'] = $this->field['tooltip_toggle'] ?? true; |
|
| 58 | + |
|
| 59 | + $this->field['tooltips']['style']['color'] = $this->field['tooltips']['style']['color'] ?? 'light'; |
|
| 60 | + $this->field['tooltips']['style']['shadow'] = $this->field['tooltips']['style']['shadow'] ?? true; |
|
| 61 | + $this->field['tooltips']['style']['rounded'] = $this->field['tooltips']['style']['rounded'] ?? false; |
|
| 62 | + $this->field['tooltips']['style']['style'] = $this->field['tooltips']['style']['style'] ?? ''; |
|
| 63 | + |
|
| 64 | + $this->field['tooltips']['position']['my'] = $this->field['tooltips']['position']['my'] ?? 'top center'; |
|
| 65 | + $this->field['tooltips']['position']['at'] = $this->field['tooltips']['position']['at'] ?? 'bottom center'; |
|
| 66 | + |
|
| 67 | + $this->field['tooltips']['effect']['show_effect'] = $this->field['tooltips']['effect']['show_effect'] ?? 'slide'; |
|
| 68 | + $this->field['tooltips']['effect']['show_duration'] = $this->field['tooltips']['effect']['show_duration'] ?? 500; |
|
| 69 | + $this->field['tooltips']['effect']['show_event'] = $this->field['tooltips']['effect']['show_event'] ?? 'mouseover'; |
|
| 70 | + $this->field['tooltips']['effect']['hide_effect'] = $this->field['tooltips']['effect']['hide_effect'] ?? 'slide'; |
|
| 71 | + $this->field['tooltips']['effect']['hide_duration'] = $this->field['tooltips']['effect']['hide_duration'] ?? 500; |
|
| 72 | + $this->field['tooltips']['effect']['hide_effect'] = $this->field['tooltips']['effect']['hide_effect'] ?? 'mouseleave'; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Field Render Function. |
|
| 77 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 78 | + * |
|
| 79 | + * @since 1.0.0 |
|
| 80 | + * @access public |
|
| 81 | + * @return void |
|
| 82 | + */ |
|
| 83 | + public function render() { |
|
| 84 | + $field_id = esc_attr( $this->field['id'] ); |
|
| 85 | + |
|
| 86 | + // Set field ID, just in case. |
|
| 87 | + Redux_Color_Scheme_Functions::$field_id = $field_id; |
|
| 88 | + Redux_Color_Scheme_Functions::$field = $this->field; |
|
| 89 | + Redux_Color_Scheme_Functions::$parent = $this->parent; |
|
| 90 | + |
|
| 91 | + if ( isset( $this->field['select'] ) ) { |
|
| 92 | + if ( is_array( $this->field['select'] ) && ! empty( $this->field['select'] ) ) { |
|
| 93 | + Redux_Color_Scheme_Functions::$select = $this->field['select']; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // Nonce. |
|
| 98 | + $nonce = wp_create_nonce( "redux_{$this->parent->args['opt_name']}_color_schemes" ); |
|
| 99 | + |
|
| 100 | + // Modal message. |
|
| 101 | + echo '<div id="redux-' . esc_attr( $field_id ) . '-scheme-message-notice" style="display:none; cursor: default">'; |
|
| 102 | + echo ' <h2>message</h2>'; |
|
| 103 | + echo ' <input type="button" id="redux-' . esc_attr( $field_id ) . '-scheme-ok" value="OK" />'; |
|
| 104 | + echo '</div>'; |
|
| 105 | + |
|
| 106 | + // Waiting message. |
|
| 107 | + echo '<div id="redux-' . esc_attr( $field_id ) . '-scheme-wait-message" style="display:none;">'; |
|
| 108 | + // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- Icon hard coded for project. |
|
| 109 | + echo ' <h1><img alt="Please wait..." src="' . esc_url( $this->url ) . 'img/busy.gif" /> Please wait...</h1>'; |
|
| 110 | + echo '</div>'; |
|
| 111 | + |
|
| 112 | + // Delete dialog. |
|
| 113 | + echo '<div id="redux-' . esc_attr( $field_id ) . '-delete-scheme-question" style="display:none; cursor: default">'; |
|
| 114 | + echo ' <h2>Are you sure you want to delete this scheme?</h2>'; |
|
| 115 | + echo ' <input type="button" id="redux-' . esc_attr( $field_id ) . '-delete-scheme-yes" value="Yes" />'; |
|
| 116 | + echo ' <input type="button" id="redux-' . esc_attr( $field_id ) . '-delete-scheme-no" value="No" />'; |
|
| 117 | + echo '</div>'; |
|
| 118 | + |
|
| 119 | + // Select2 params. |
|
| 120 | + if ( isset( $this->field['select2'] ) ) { // if there are any, let's pass them to js. |
|
| 121 | + $select2_params = wp_json_encode( $this->field['select2'] ); |
|
| 122 | + $select2_params = htmlspecialchars( $select2_params, ENT_QUOTES ); |
|
| 123 | + |
|
| 124 | + echo '<input type="hidden" class="select2_params" value="' . $select2_params . '">'; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $tt_in_use = Redux_Color_Scheme_Functions::tooltips_in_use( $this->field ); |
|
| 128 | + |
|
| 129 | + $tooltips = ''; |
|
| 130 | + if ( $tt_in_use ) { |
|
| 131 | + $tooltips = rawurlencode( wp_json_encode( $this->field['tooltips'] ) ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $tt_toggle_state = Redux_Color_Scheme_Functions::get_tooltip_toggle_state(); |
|
| 135 | + |
|
| 136 | + // Color picker container. |
|
| 137 | + // phpcs:disable WordPress.Security.EscapeOutput |
|
| 138 | + echo '<div |
|
| 139 | 139 | class="redux-color-scheme-container ' . esc_attr( $this->field['class'] ) . '" |
| 140 | 140 | data-id="' . esc_attr( $field_id ) . '" |
| 141 | 141 | data-opt-name="' . esc_attr( $this->parent->args['opt_name'] ) . '" |
@@ -158,52 +158,52 @@ discard block |
||
| 158 | 158 | data-cancel-text="' . esc_attr( $this->field['options']['cancel_text'] ) . '" |
| 159 | 159 | data-palette="' . rawurlencode( wp_json_encode( $this->field['options']['palette'] ) ) . '" |
| 160 | 160 | >'; |
| 161 | - // phpcs:enable WordPress.Security.EscapeOutput |
|
| 161 | + // phpcs:enable WordPress.Security.EscapeOutput |
|
| 162 | 162 | |
| 163 | - // Hide scheme save stuff on simple mode. |
|
| 164 | - if ( false === $this->field['simple'] ) { |
|
| 165 | - echo '<div>'; |
|
| 166 | - // Select container. |
|
| 167 | - echo '<div class="redux-scheme-select-container input_wrapper">'; |
|
| 168 | - echo ' <span class="redux-label redux-select-scheme-label">Scheme:</span>'; |
|
| 163 | + // Hide scheme save stuff on simple mode. |
|
| 164 | + if ( false === $this->field['simple'] ) { |
|
| 165 | + echo '<div>'; |
|
| 166 | + // Select container. |
|
| 167 | + echo '<div class="redux-scheme-select-container input_wrapper">'; |
|
| 168 | + echo ' <span class="redux-label redux-select-scheme-label">Scheme:</span>'; |
|
| 169 | 169 | |
| 170 | - // Output scheme selector. |
|
| 171 | - echo Redux_Color_Scheme_Functions::get_scheme_select_html( '' ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 170 | + // Output scheme selector. |
|
| 171 | + echo Redux_Color_Scheme_Functions::get_scheme_select_html( '' ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 172 | 172 | |
| 173 | - echo '</div>'; |
|
| 173 | + echo '</div>'; |
|
| 174 | 174 | |
| 175 | - // Text input. |
|
| 176 | - echo '<div class="redux-scheme-name input_wrapper">'; |
|
| 177 | - echo ' <span class="redux-label redux-text-scheme-label">Name:</span>'; |
|
| 178 | - echo ' <input |
|
| 175 | + // Text input. |
|
| 176 | + echo '<div class="redux-scheme-name input_wrapper">'; |
|
| 177 | + echo ' <span class="redux-label redux-text-scheme-label">Name:</span>'; |
|
| 178 | + echo ' <input |
|
| 179 | 179 | type="text" |
| 180 | 180 | class="noUpdate redux-scheme-input-' . esc_attr( $field_id ) . '" |
| 181 | 181 | id="redux-scheme-input" |
| 182 | 182 | />'; |
| 183 | - echo '</div>'; |
|
| 183 | + echo '</div>'; |
|
| 184 | 184 | |
| 185 | - // Action buttons/links. |
|
| 186 | - echo ' <div class="redux-action-links">'; |
|
| 187 | - echo ' <span class="redux-label redux-action-scheme-label">Actions:</span>'; |
|
| 185 | + // Action buttons/links. |
|
| 186 | + echo ' <div class="redux-action-links">'; |
|
| 187 | + echo ' <span class="redux-label redux-action-scheme-label">Actions:</span>'; |
|
| 188 | 188 | |
| 189 | - // Save button. |
|
| 190 | - echo ' <a |
|
| 189 | + // Save button. |
|
| 190 | + echo ' <a |
|
| 191 | 191 | href="javascript:void(0);" |
| 192 | 192 | id="redux-' . esc_attr( $field_id ) . '-save-scheme-button" |
| 193 | 193 | class="redux-save-scheme-button button-secondary">' . esc_html__( 'Add', 'redux-framework' ) . ' |
| 194 | 194 | </a>'; |
| 195 | 195 | |
| 196 | - // Delete button. |
|
| 197 | - echo ' <a |
|
| 196 | + // Delete button. |
|
| 197 | + echo ' <a |
|
| 198 | 198 | href="javascript:void(0);" |
| 199 | 199 | id="redux-' . esc_attr( $field_id ) . '-delete-scheme-button" |
| 200 | 200 | class="redux-delete-scheme-button button-secondary">' . esc_html__( 'Delete', 'redux-framework' ) . ' |
| 201 | 201 | </a>'; |
| 202 | 202 | |
| 203 | - $link = admin_url( 'admin-ajax.php?action=redux_color_schemes&type=export&nonce=' . esc_attr( $nonce ) ) . '&opt_name=' . esc_attr( $this->parent->args['opt_name'] ); |
|
| 203 | + $link = admin_url( 'admin-ajax.php?action=redux_color_schemes&type=export&nonce=' . esc_attr( $nonce ) ) . '&opt_name=' . esc_attr( $this->parent->args['opt_name'] ); |
|
| 204 | 204 | |
| 205 | - // Export button. |
|
| 206 | - echo ' <a |
|
| 205 | + // Export button. |
|
| 206 | + echo ' <a |
|
| 207 | 207 | href="' . esc_url( $link ) . '" |
| 208 | 208 | id="redux-' . esc_attr( $field_id ) . '-export-scheme-button" |
| 209 | 209 | data-opt-name="' . esc_attr( $this->parent->args['opt_name'] ) . '" |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | class="redux-export-scheme-button button-primary">' . esc_html__( 'Export', 'redux-framework' ) . ' |
| 212 | 212 | </a>'; |
| 213 | 213 | |
| 214 | - // Import button. |
|
| 215 | - echo ' <a |
|
| 214 | + // Import button. |
|
| 215 | + echo ' <a |
|
| 216 | 216 | href="javascript:void(0);" |
| 217 | 217 | id="redux-' . esc_attr( $field_id ) . '-import-scheme-button" |
| 218 | 218 | data-submit="' . esc_url( $this->url ) . '" |
@@ -220,197 +220,197 @@ discard block |
||
| 220 | 220 | class="noUpdate redux-import-scheme-button button-secondary">' . esc_html__( 'Import', 'redux-framework' ) . ' |
| 221 | 221 | </a>'; |
| 222 | 222 | |
| 223 | - echo ' <input type="file" accept="application/json" id="redux-color-scheme-upload-file" size="50">'; |
|
| 224 | - |
|
| 225 | - if ( $this->field['tooltip_toggle'] && $tt_in_use ) { |
|
| 226 | - $checked = ''; |
|
| 227 | - if ( $tt_toggle_state ) { |
|
| 228 | - $checked = 'checked'; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - echo '<div class="redux-color-scheme-tooltip-checkbox">'; |
|
| 232 | - echo '<input class="" name="' . esc_attr( $this->parent->args['opt_name'] ) . '[redux-color-scheme-tooltip-toggle]" id="redux-' . esc_attr( $field_id ) . '-tooltip-checkbox" type="checkbox" value="' . esc_attr( $tt_toggle_state ) . '" ' . esc_html( $checked ) . '>Show Tooltips'; |
|
| 233 | - echo '</div>'; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - echo ' </div>'; |
|
| 237 | - echo '</div>'; |
|
| 238 | - echo '<div>'; |
|
| 239 | - echo '<hr/>'; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - // Set field class. Gotta do it this way so custom class makes |
|
| 243 | - // it through AJAX. |
|
| 244 | - Redux_Color_Scheme_Functions::$field_class = 'redux-color-scheme '; |
|
| 245 | - |
|
| 246 | - // Color picker layout. |
|
| 247 | - echo Redux_Color_Scheme_Functions::get_current_color_scheme_html(); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 248 | - |
|
| 249 | - echo '</div>'; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Enqueue Function. |
|
| 254 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 255 | - * |
|
| 256 | - * @since 1.0.0 |
|
| 257 | - * @access public |
|
| 258 | - * @return void |
|
| 259 | - */ |
|
| 260 | - public function enqueue() { |
|
| 261 | - |
|
| 262 | - // Set up min files for dev_mode = false. |
|
| 263 | - $min = Redux_Functions::is_min(); |
|
| 264 | - |
|
| 265 | - // Field dependent JS. |
|
| 266 | - wp_enqueue_script( |
|
| 267 | - 'redux-field-color-scheme', |
|
| 268 | - $this->url . 'redux-color-scheme' . $min . '.js', |
|
| 269 | - array( 'jquery', 'redux-spectrum-js', 'select2-js', 'redux-block-ui' ), |
|
| 270 | - Redux_Extension_Color_Scheme::$version, |
|
| 271 | - true |
|
| 272 | - ); |
|
| 273 | - |
|
| 274 | - // Field CSS. |
|
| 275 | - if ( true === $this->parent->args['dev_mode'] ) { |
|
| 276 | - wp_enqueue_style( |
|
| 277 | - 'redux-field-color-scheme', |
|
| 278 | - $this->url . 'redux-color-scheme.css', |
|
| 279 | - array( 'redux-spectrum-css', 'select2-css' ), |
|
| 280 | - Redux_Extension_Color_Scheme::$version |
|
| 281 | - ); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - // AJAX. |
|
| 285 | - wp_localize_script( |
|
| 286 | - 'redux-field-color-scheme', |
|
| 287 | - 'redux_ajax_script', |
|
| 288 | - array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) |
|
| 289 | - ); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Get default data. |
|
| 294 | - * |
|
| 295 | - * @param string $id Field ID. |
|
| 296 | - * |
|
| 297 | - * @return array |
|
| 298 | - */ |
|
| 299 | - private function data_from_default( string $id ): array { |
|
| 300 | - $x = $this->field; |
|
| 301 | - |
|
| 302 | - $data = array(); |
|
| 303 | - |
|
| 304 | - foreach ( $x['default'] as $arr ) { |
|
| 305 | - if ( $arr['id'] === $id ) { |
|
| 306 | - $data['selector'] = $arr['selector'] ?? ''; |
|
| 307 | - $data['mode'] = $arr['mode'] ?? ''; |
|
| 308 | - $data['important'] = $arr['important'] ?? ''; |
|
| 309 | - |
|
| 310 | - break; |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - return $data; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * If this field requires any scripts or CSS, define this function and register/enqueue the scripts/css |
|
| 319 | - * |
|
| 320 | - * @since 1.0.0 |
|
| 321 | - * @access private |
|
| 322 | - * @return string |
|
| 323 | - */ |
|
| 324 | - private function get_css(): string { |
|
| 325 | - |
|
| 326 | - // No notices. |
|
| 327 | - $css = ''; |
|
| 328 | - |
|
| 329 | - // Must be an array. |
|
| 330 | - if ( is_array( $this->value ) ) { |
|
| 331 | - |
|
| 332 | - // Enum array to parse values. |
|
| 333 | - foreach ( $this->value as $id => $val ) { |
|
| 334 | - |
|
| 335 | - // Default selector data, so we always have current info. |
|
| 336 | - $def_data = $this->data_from_default( $id ); |
|
| 337 | - |
|
| 338 | - // Sanitize alpha. |
|
| 339 | - $alpha = $val['alpha'] ?? 1; |
|
| 340 | - |
|
| 341 | - // Sanitize color. |
|
| 342 | - $color = $val['color'] ?? ''; |
|
| 343 | - |
|
| 344 | - // Only build rgba output if alpha ia less than 1. |
|
| 345 | - if ( $alpha < 1 && '' !== $alpha ) { |
|
| 346 | - $color = Redux_Helpers::hex2rgba( $color, $alpha ); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - $important = $def_data['important'] ?? false; |
|
| 350 | - if ( true === $important ) { |
|
| 351 | - $important = ' !important'; |
|
| 352 | - } else { |
|
| 353 | - $important = ''; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - // Sanitize selector. |
|
| 357 | - $selector = $def_data['selector'] ?? ''; |
|
| 358 | - |
|
| 359 | - if ( is_array( $selector ) ) { |
|
| 360 | - foreach ( $selector as $mode => $element ) { |
|
| 361 | - if ( '' !== $element && '' !== $color ) { |
|
| 362 | - $css .= $element . '{' . $mode . ': ' . $color . $important . ';}'; |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - } else { |
|
| 366 | - // Sanitize mode, default to 'color'. |
|
| 367 | - $mode = $def_data['mode'] ?? 'color'; |
|
| 368 | - |
|
| 369 | - // Only build value if selector is indicated. |
|
| 370 | - if ( '' !== $selector && '' !== $color ) { |
|
| 371 | - $css .= $selector . '{' . $mode . ': ' . $color . $important . ';} '; |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - } |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - return $css; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Generate CSS style. |
|
| 382 | - * |
|
| 383 | - * @param string $data Field data. |
|
| 384 | - * |
|
| 385 | - * @return string |
|
| 386 | - */ |
|
| 387 | - public function css_style( $data ): string { |
|
| 388 | - return ''; |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Output Function. |
|
| 393 | - * Used to enqueue to the front-end |
|
| 394 | - * |
|
| 395 | - * @param string|null|array $style Style. |
|
| 396 | - * @since 1.0.0 |
|
| 397 | - * @access public |
|
| 398 | - * @return void |
|
| 399 | - */ |
|
| 400 | - public function output( $style = '' ) { |
|
| 401 | - if ( ! empty( $this->value ) ) { |
|
| 402 | - if ( ! empty( $this->field['output'] ) && ( true === $this->field['output'] ) ) { |
|
| 403 | - $css = $this->get_css(); |
|
| 404 | - $this->parent->outputCSS .= $css; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - if ( ! $this->field['no_compiler_output'] ) { |
|
| 408 | - if ( ! empty( $this->field['compiler'] ) && ( true === $this->field['compiler'] ) ) { |
|
| 409 | - $css = $this->get_css(); |
|
| 410 | - $this->parent->compilerCSS .= $css; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - } |
|
| 223 | + echo ' <input type="file" accept="application/json" id="redux-color-scheme-upload-file" size="50">'; |
|
| 224 | + |
|
| 225 | + if ( $this->field['tooltip_toggle'] && $tt_in_use ) { |
|
| 226 | + $checked = ''; |
|
| 227 | + if ( $tt_toggle_state ) { |
|
| 228 | + $checked = 'checked'; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + echo '<div class="redux-color-scheme-tooltip-checkbox">'; |
|
| 232 | + echo '<input class="" name="' . esc_attr( $this->parent->args['opt_name'] ) . '[redux-color-scheme-tooltip-toggle]" id="redux-' . esc_attr( $field_id ) . '-tooltip-checkbox" type="checkbox" value="' . esc_attr( $tt_toggle_state ) . '" ' . esc_html( $checked ) . '>Show Tooltips'; |
|
| 233 | + echo '</div>'; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + echo ' </div>'; |
|
| 237 | + echo '</div>'; |
|
| 238 | + echo '<div>'; |
|
| 239 | + echo '<hr/>'; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + // Set field class. Gotta do it this way so custom class makes |
|
| 243 | + // it through AJAX. |
|
| 244 | + Redux_Color_Scheme_Functions::$field_class = 'redux-color-scheme '; |
|
| 245 | + |
|
| 246 | + // Color picker layout. |
|
| 247 | + echo Redux_Color_Scheme_Functions::get_current_color_scheme_html(); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 248 | + |
|
| 249 | + echo '</div>'; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Enqueue Function. |
|
| 254 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 255 | + * |
|
| 256 | + * @since 1.0.0 |
|
| 257 | + * @access public |
|
| 258 | + * @return void |
|
| 259 | + */ |
|
| 260 | + public function enqueue() { |
|
| 261 | + |
|
| 262 | + // Set up min files for dev_mode = false. |
|
| 263 | + $min = Redux_Functions::is_min(); |
|
| 264 | + |
|
| 265 | + // Field dependent JS. |
|
| 266 | + wp_enqueue_script( |
|
| 267 | + 'redux-field-color-scheme', |
|
| 268 | + $this->url . 'redux-color-scheme' . $min . '.js', |
|
| 269 | + array( 'jquery', 'redux-spectrum-js', 'select2-js', 'redux-block-ui' ), |
|
| 270 | + Redux_Extension_Color_Scheme::$version, |
|
| 271 | + true |
|
| 272 | + ); |
|
| 273 | + |
|
| 274 | + // Field CSS. |
|
| 275 | + if ( true === $this->parent->args['dev_mode'] ) { |
|
| 276 | + wp_enqueue_style( |
|
| 277 | + 'redux-field-color-scheme', |
|
| 278 | + $this->url . 'redux-color-scheme.css', |
|
| 279 | + array( 'redux-spectrum-css', 'select2-css' ), |
|
| 280 | + Redux_Extension_Color_Scheme::$version |
|
| 281 | + ); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + // AJAX. |
|
| 285 | + wp_localize_script( |
|
| 286 | + 'redux-field-color-scheme', |
|
| 287 | + 'redux_ajax_script', |
|
| 288 | + array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) |
|
| 289 | + ); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Get default data. |
|
| 294 | + * |
|
| 295 | + * @param string $id Field ID. |
|
| 296 | + * |
|
| 297 | + * @return array |
|
| 298 | + */ |
|
| 299 | + private function data_from_default( string $id ): array { |
|
| 300 | + $x = $this->field; |
|
| 301 | + |
|
| 302 | + $data = array(); |
|
| 303 | + |
|
| 304 | + foreach ( $x['default'] as $arr ) { |
|
| 305 | + if ( $arr['id'] === $id ) { |
|
| 306 | + $data['selector'] = $arr['selector'] ?? ''; |
|
| 307 | + $data['mode'] = $arr['mode'] ?? ''; |
|
| 308 | + $data['important'] = $arr['important'] ?? ''; |
|
| 309 | + |
|
| 310 | + break; |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + return $data; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * If this field requires any scripts or CSS, define this function and register/enqueue the scripts/css |
|
| 319 | + * |
|
| 320 | + * @since 1.0.0 |
|
| 321 | + * @access private |
|
| 322 | + * @return string |
|
| 323 | + */ |
|
| 324 | + private function get_css(): string { |
|
| 325 | + |
|
| 326 | + // No notices. |
|
| 327 | + $css = ''; |
|
| 328 | + |
|
| 329 | + // Must be an array. |
|
| 330 | + if ( is_array( $this->value ) ) { |
|
| 331 | + |
|
| 332 | + // Enum array to parse values. |
|
| 333 | + foreach ( $this->value as $id => $val ) { |
|
| 334 | + |
|
| 335 | + // Default selector data, so we always have current info. |
|
| 336 | + $def_data = $this->data_from_default( $id ); |
|
| 337 | + |
|
| 338 | + // Sanitize alpha. |
|
| 339 | + $alpha = $val['alpha'] ?? 1; |
|
| 340 | + |
|
| 341 | + // Sanitize color. |
|
| 342 | + $color = $val['color'] ?? ''; |
|
| 343 | + |
|
| 344 | + // Only build rgba output if alpha ia less than 1. |
|
| 345 | + if ( $alpha < 1 && '' !== $alpha ) { |
|
| 346 | + $color = Redux_Helpers::hex2rgba( $color, $alpha ); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + $important = $def_data['important'] ?? false; |
|
| 350 | + if ( true === $important ) { |
|
| 351 | + $important = ' !important'; |
|
| 352 | + } else { |
|
| 353 | + $important = ''; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + // Sanitize selector. |
|
| 357 | + $selector = $def_data['selector'] ?? ''; |
|
| 358 | + |
|
| 359 | + if ( is_array( $selector ) ) { |
|
| 360 | + foreach ( $selector as $mode => $element ) { |
|
| 361 | + if ( '' !== $element && '' !== $color ) { |
|
| 362 | + $css .= $element . '{' . $mode . ': ' . $color . $important . ';}'; |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + } else { |
|
| 366 | + // Sanitize mode, default to 'color'. |
|
| 367 | + $mode = $def_data['mode'] ?? 'color'; |
|
| 368 | + |
|
| 369 | + // Only build value if selector is indicated. |
|
| 370 | + if ( '' !== $selector && '' !== $color ) { |
|
| 371 | + $css .= $selector . '{' . $mode . ': ' . $color . $important . ';} '; |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + return $css; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Generate CSS style. |
|
| 382 | + * |
|
| 383 | + * @param string $data Field data. |
|
| 384 | + * |
|
| 385 | + * @return string |
|
| 386 | + */ |
|
| 387 | + public function css_style( $data ): string { |
|
| 388 | + return ''; |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Output Function. |
|
| 393 | + * Used to enqueue to the front-end |
|
| 394 | + * |
|
| 395 | + * @param string|null|array $style Style. |
|
| 396 | + * @since 1.0.0 |
|
| 397 | + * @access public |
|
| 398 | + * @return void |
|
| 399 | + */ |
|
| 400 | + public function output( $style = '' ) { |
|
| 401 | + if ( ! empty( $this->value ) ) { |
|
| 402 | + if ( ! empty( $this->field['output'] ) && ( true === $this->field['output'] ) ) { |
|
| 403 | + $css = $this->get_css(); |
|
| 404 | + $this->parent->outputCSS .= $css; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + if ( ! $this->field['no_compiler_output'] ) { |
|
| 408 | + if ( ! empty( $this->field['compiler'] ) && ( true === $this->field['compiler'] ) ) { |
|
| 409 | + $css = $this->get_css(); |
|
| 410 | + $this->parent->compilerCSS .= $css; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | 416 | } |
@@ -7,54 +7,54 @@ |
||
| 7 | 7 | |
| 8 | 8 | if ( ! class_exists( 'Redux_PHP' ) ) { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Redux_PHP class. |
|
| 12 | - */ |
|
| 13 | - class Redux_PHP { |
|
| 10 | + /** |
|
| 11 | + * Redux_PHP class. |
|
| 12 | + */ |
|
| 13 | + class Redux_PHP { |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Minimum PHP version. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - * |
|
| 20 | - * @noinspection PhpMissingFieldTypeInspection |
|
| 21 | - */ |
|
| 22 | - public static $minimum_version = '7.4.0'; |
|
| 15 | + /** |
|
| 16 | + * Minimum PHP version. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + * |
|
| 20 | + * @noinspection PhpMissingFieldTypeInspection |
|
| 21 | + */ |
|
| 22 | + public static $minimum_version = '7.4.0'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Is PHP version met. |
|
| 26 | - * |
|
| 27 | - * @return bool |
|
| 28 | - */ |
|
| 29 | - public static function version_met(): bool { |
|
| 30 | - return version_compare( PHP_VERSION, self::$minimum_version, '>=' ); |
|
| 31 | - } |
|
| 24 | + /** |
|
| 25 | + * Is PHP version met. |
|
| 26 | + * |
|
| 27 | + * @return bool |
|
| 28 | + */ |
|
| 29 | + public static function version_met(): bool { |
|
| 30 | + return version_compare( PHP_VERSION, self::$minimum_version, '>=' ); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Display incompatibility message on admin screen. |
|
| 35 | - * |
|
| 36 | - * @return void |
|
| 37 | - */ |
|
| 38 | - public static function php_version_nope() { |
|
| 39 | - printf( |
|
| 40 | - '<div id="redux-php-nope" class="notice notice-error"><p>%s</p></div>', |
|
| 41 | - wp_kses( |
|
| 42 | - sprintf( |
|
| 43 | - /* translators: 1: Redux Framework, 2: Required PHP version number, 3: Current PHP version number, 4: URL of PHP update help page */ |
|
| 44 | - __( 'The %1$s plugin requires PHP version %2$s or higher. This site is running PHP version %3$s. The theme/plugin that relies on Redux will not run properly without a PHP update. <a href="%4$s">Learn about updating PHP</a>.', 'redux-framework' ), |
|
| 45 | - 'Redux Framework', |
|
| 46 | - '<strong>7.4.0</strong>', |
|
| 47 | - '<strong>' . PHP_VERSION . '</strong>', |
|
| 48 | - 'https://wordpress.org/support/update-php/' |
|
| 49 | - ), |
|
| 50 | - array( |
|
| 51 | - 'a' => array( |
|
| 52 | - 'href' => array(), |
|
| 53 | - ), |
|
| 54 | - 'strong' => array(), |
|
| 55 | - ) |
|
| 56 | - ) |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - } |
|
| 33 | + /** |
|
| 34 | + * Display incompatibility message on admin screen. |
|
| 35 | + * |
|
| 36 | + * @return void |
|
| 37 | + */ |
|
| 38 | + public static function php_version_nope() { |
|
| 39 | + printf( |
|
| 40 | + '<div id="redux-php-nope" class="notice notice-error"><p>%s</p></div>', |
|
| 41 | + wp_kses( |
|
| 42 | + sprintf( |
|
| 43 | + /* translators: 1: Redux Framework, 2: Required PHP version number, 3: Current PHP version number, 4: URL of PHP update help page */ |
|
| 44 | + __( 'The %1$s plugin requires PHP version %2$s or higher. This site is running PHP version %3$s. The theme/plugin that relies on Redux will not run properly without a PHP update. <a href="%4$s">Learn about updating PHP</a>.', 'redux-framework' ), |
|
| 45 | + 'Redux Framework', |
|
| 46 | + '<strong>7.4.0</strong>', |
|
| 47 | + '<strong>' . PHP_VERSION . '</strong>', |
|
| 48 | + 'https://wordpress.org/support/update-php/' |
|
| 49 | + ), |
|
| 50 | + array( |
|
| 51 | + 'a' => array( |
|
| 52 | + 'href' => array(), |
|
| 53 | + ), |
|
| 54 | + 'strong' => array(), |
|
| 55 | + ) |
|
| 56 | + ) |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -13,1121 +13,1121 @@ |
||
| 13 | 13 | |
| 14 | 14 | if ( ! class_exists( 'Redux_Page_Render', false ) ) { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Class Redux_Page_Render |
|
| 18 | - */ |
|
| 19 | - class Redux_Page_Render extends Redux_Class { |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Flag to show or hide hints in a panel. |
|
| 23 | - * |
|
| 24 | - * @var bool |
|
| 25 | - * @access private |
|
| 26 | - */ |
|
| 27 | - private $show_hints = false; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Creates page's hook suffix. |
|
| 31 | - * |
|
| 32 | - * @var false|string |
|
| 33 | - * @access private |
|
| 34 | - */ |
|
| 35 | - private $page = ''; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Redux_Page_Render constructor. |
|
| 39 | - * |
|
| 40 | - * @param object $redux ReduxFramework pointer. |
|
| 41 | - */ |
|
| 42 | - public function __construct( $redux ) { |
|
| 43 | - parent::__construct( $redux ); |
|
| 44 | - |
|
| 45 | - // phpcs:ignore Generic.Strings.UnnecessaryStringConcat |
|
| 46 | - add_action( 'admin' . '_bar' . '_menu', array( $this, 'add_menu' ), $redux->args['admin_bar_priority'] ); |
|
| 47 | - |
|
| 48 | - // Options page. |
|
| 49 | - add_action( 'admin_menu', array( $this, 'options_page' ) ); |
|
| 50 | - |
|
| 51 | - // Add a network menu. |
|
| 52 | - if ( 'network' === $redux->args['database'] && $redux->args['network_admin'] ) { |
|
| 53 | - add_action( 'network_admin_menu', array( $this, 'options_page' ) ); |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Class Options Page Function, creates main options page. |
|
| 59 | - * |
|
| 60 | - * @since 1.0.0 |
|
| 61 | - * @access public |
|
| 62 | - * @return void |
|
| 63 | - */ |
|
| 64 | - public function options_page() { |
|
| 65 | - $core = $this->core(); |
|
| 66 | - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement |
|
| 67 | - if ( 'hidden' === $core->args['menu_type'] ) { |
|
| 68 | - // No menu to add! |
|
| 69 | - } elseif ( 'submenu' === $core->args['menu_type'] ) { |
|
| 70 | - $this->submenu( $core ); |
|
| 71 | - } else { |
|
| 72 | - // Theme-Check notice is displayed for WP.org theme devs, informing them to NOT use this. |
|
| 73 | - $this->page = call_user_func( |
|
| 74 | - 'add_menu_page', |
|
| 75 | - $core->args['page_title'], |
|
| 76 | - $core->args['menu_title'], |
|
| 77 | - $core->args['page_permissions'], |
|
| 78 | - $core->args['page_slug'], |
|
| 79 | - array( |
|
| 80 | - $this, |
|
| 81 | - 'generate_panel', |
|
| 82 | - ), |
|
| 83 | - $core->args['menu_icon'], |
|
| 84 | - (int) $core->args['page_priority'] |
|
| 85 | - ); |
|
| 86 | - |
|
| 87 | - if ( true === $core->args['allow_sub_menu'] ) { |
|
| 88 | - foreach ( $core->sections as $k => $section ) { |
|
| 89 | - $can_be_subsection = $k > 0 && ( ! isset( $core->sections[ ( $k ) ]['type'] ) || 'divide' !== $core->sections[ ( $k ) ]['type'] ); |
|
| 90 | - |
|
| 91 | - if ( ! isset( $section['title'] ) || ( $can_be_subsection && ( isset( $section['subsection'] ) && true === $section['subsection'] ) ) ) { |
|
| 92 | - continue; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if ( isset( $section['submenu'] ) && false === $section['submenu'] ) { |
|
| 96 | - continue; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) { |
|
| 100 | - continue; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if ( isset( $section['hidden'] ) && true === $section['hidden'] ) { |
|
| 104 | - continue; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ( isset( $section['permissions'] ) && ! Redux_Helpers::current_user_can( $section['permissions'] ) ) { |
|
| 108 | - continue; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // ONLY for non-wp.org themes OR plugins. Theme-Check alert shown if used and IS theme. |
|
| 112 | - call_user_func( |
|
| 113 | - 'add_submenu_page', |
|
| 114 | - $core->args['page_slug'], |
|
| 115 | - $section['title'], |
|
| 116 | - $section['title'], |
|
| 117 | - $core->args['page_permissions'], |
|
| 118 | - $core->args['page_slug'] . '&tab=' . $k, |
|
| 119 | - '__return_null' |
|
| 120 | - ); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // Remove parent submenu item instead of adding null item. |
|
| 124 | - remove_submenu_page( $core->args['page_slug'], $core->args['page_slug'] ); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - add_action( "load-$this->page", array( $this, 'load_page' ) ); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Show page help |
|
| 133 | - * |
|
| 134 | - * @since 1.0.0 |
|
| 135 | - * @access public |
|
| 136 | - * @return void |
|
| 137 | - */ |
|
| 138 | - public function load_page() { |
|
| 139 | - $core = $this->core(); |
|
| 140 | - |
|
| 141 | - // Do admin head action for this page. |
|
| 142 | - add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
| 143 | - |
|
| 144 | - // Do admin footer text hook. |
|
| 145 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
| 146 | - |
|
| 147 | - $screen = get_current_screen(); |
|
| 148 | - |
|
| 149 | - if ( is_array( $core->args['help_tabs'] ) ) { |
|
| 150 | - foreach ( $core->args['help_tabs'] as $tab ) { |
|
| 151 | - $screen->add_help_tab( $tab ); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // If hint argument is set, display hint tab. |
|
| 156 | - if ( true === $this->show_hints ) { |
|
| 157 | - global $current_user; |
|
| 158 | - |
|
| 159 | - $cur_page = ''; |
|
| 160 | - |
|
| 161 | - // Users enable/disable hint choice. |
|
| 162 | - $hint_status = get_user_meta( $current_user->ID, 'ignore_hints' ) ? get_user_meta( $current_user->ID, 'ignore_hints', true ) : 'true'; |
|
| 163 | - |
|
| 164 | - // current page parameters. |
|
| 165 | - if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 166 | - $cur_page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - $cur_tab = '0'; |
|
| 170 | - if ( isset( $_GET['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 171 | - $cur_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // Default url values for enabling hints. |
|
| 175 | - $dismiss = 'true'; |
|
| 176 | - $s = esc_html__( 'Enable', 'redux-framework' ); |
|
| 177 | - |
|
| 178 | - // Values for disabling hints. |
|
| 179 | - if ( 'true' === $hint_status ) { |
|
| 180 | - $dismiss = 'false'; |
|
| 181 | - $s = esc_html__( 'Disable', 'redux-framework' ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Make URL. |
|
| 185 | - $nonce = wp_create_nonce( 'redux_hint_toggle' ); |
|
| 186 | - $url = '<a class="redux_hint_status" href="?nonce=' . $nonce . '&dismiss=' . $dismiss . '&id=hints&page=' . esc_attr( $cur_page ) . '&tab=' . esc_attr( $cur_tab ) . '">' . $s . ' hints</a>'; |
|
| 187 | - |
|
| 188 | - $event = esc_html__( 'moving the mouse over', 'redux-framework' ); |
|
| 189 | - if ( 'click' === $core->args['hints']['tip_effect']['show']['event'] ) { |
|
| 190 | - $event = esc_html__( 'clicking', 'redux-framework' ); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - // Construct message. |
|
| 194 | - // translators: %1$s: Mouse action. %2$s: Hint status. |
|
| 195 | - $msg = sprintf( esc_html__( 'Hints are tooltips that popup when %1$s the hint icon, offering addition information about the field in which they appear. They can be %2$s by using the link below.', 'redux-framework' ), $event, Redux_Core::strtolower( $s ) ) . '<br/><br/>' . $url; |
|
| 196 | - |
|
| 197 | - // Construct hint tab. |
|
| 198 | - $tab = array( |
|
| 199 | - 'id' => 'redux-hint-tab', |
|
| 200 | - 'title' => esc_html__( 'Hints', 'redux-framework' ), |
|
| 201 | - 'content' => '<p>' . $msg . '</p>', |
|
| 202 | - ); |
|
| 203 | - |
|
| 204 | - $screen->add_help_tab( $tab ); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - // Sidebar text. |
|
| 208 | - if ( '' !== $core->args['help_sidebar'] ) { |
|
| 209 | - |
|
| 210 | - // Specify user's text from arguments. |
|
| 211 | - $screen->set_help_sidebar( $core->args['help_sidebar'] ); |
|
| 212 | - } elseif ( true === $this->show_hints ) { |
|
| 213 | - // If a sidebar text is empty and hints are active, display text |
|
| 214 | - // about hints. |
|
| 215 | - |
|
| 216 | - $screen->set_help_sidebar( '<p><strong>Redux Framework</strong><br/><br/>' . esc_html__( 'Hint Tooltip Preferences', 'redux-framework' ) . '</p>' ); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Action 'redux/page/{opt_name}/load' |
|
| 221 | - * |
|
| 222 | - * @param object $screen WP_Screen |
|
| 223 | - */ |
|
| 224 | - |
|
| 225 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 226 | - do_action( "redux/page/{$core->args['opt_name']}/load", $screen ); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Class Add Sub Menu Function, creates option submenu in WordPress admin area. |
|
| 231 | - * |
|
| 232 | - * @param object $core ReduxFramework core pointer. |
|
| 233 | - * |
|
| 234 | - * @since 3.1.9 |
|
| 235 | - * @access private |
|
| 236 | - * @return void |
|
| 237 | - */ |
|
| 238 | - private function submenu( $core ) { |
|
| 239 | - global $submenu; |
|
| 240 | - |
|
| 241 | - $page_parent = $core->args['page_parent']; |
|
| 242 | - $page_title = $core->args['page_title']; |
|
| 243 | - $menu_title = $core->args['menu_title']; |
|
| 244 | - $page_permissions = $core->args['page_permissions']; |
|
| 245 | - $page_slug = $core->args['page_slug']; |
|
| 246 | - |
|
| 247 | - // Just in case. One never knows. |
|
| 248 | - $page_parent = Redux_Core::strtolower( $page_parent ); |
|
| 249 | - |
|
| 250 | - $test = array( |
|
| 251 | - 'index.php' => 'dashboard', |
|
| 252 | - 'edit.php' => 'posts', |
|
| 253 | - 'upload.php' => 'media', |
|
| 254 | - 'link-manager.php' => 'links', |
|
| 255 | - 'edit.php?post_type=page' => 'pages', |
|
| 256 | - 'edit-comments.php' => 'comments', |
|
| 257 | - 'themes.php' => 'theme', |
|
| 258 | - 'plugins.php' => 'plugins', |
|
| 259 | - 'users.php' => 'users', |
|
| 260 | - 'tools.php' => 'management', |
|
| 261 | - 'options-general.php' => 'options', |
|
| 262 | - ); |
|
| 263 | - |
|
| 264 | - if ( isset( $test[ $page_parent ] ) ) { |
|
| 265 | - $function = 'add_' . $test[ $page_parent ] . '_page'; |
|
| 266 | - $this->page = $function( |
|
| 267 | - $page_title, |
|
| 268 | - $menu_title, |
|
| 269 | - $page_permissions, |
|
| 270 | - $page_slug, |
|
| 271 | - array( $this, 'generate_panel' ) |
|
| 272 | - ); |
|
| 273 | - } else { |
|
| 274 | - // Network settings and Post type menus. These do not have |
|
| 275 | - // wrappers and need to be appended to using add_submenu_page. |
|
| 276 | - // Okay, since we've left the post-type menu appending |
|
| 277 | - // as default, we need to validate it, so anything that |
|
| 278 | - // isn't post_type=<post_type> doesn't get through and mess |
|
| 279 | - // things up. |
|
| 280 | - $add_menu = false; |
|
| 281 | - if ( 'settings.php' !== $page_parent ) { |
|
| 282 | - // Establish the needle. |
|
| 283 | - $needle = '?post_type='; |
|
| 284 | - |
|
| 285 | - // Check if it exists in the page_parent (how I miss instr). |
|
| 286 | - $needle_pos = strrpos( $page_parent, $needle ); |
|
| 287 | - |
|
| 288 | - // It's there, so... |
|
| 289 | - if ( $needle_pos > 0 ) { |
|
| 290 | - |
|
| 291 | - // Get the post-type. |
|
| 292 | - $post_type = substr( $page_parent, $needle_pos + strlen( $needle ) ); |
|
| 293 | - |
|
| 294 | - // Ensure it exists. |
|
| 295 | - if ( post_type_exists( $post_type ) ) { |
|
| 296 | - // Set the flag to add the menu page. |
|
| 297 | - $add_menu = true; |
|
| 298 | - } |
|
| 299 | - // custom menu. |
|
| 300 | - } elseif ( isset( $submenu[ $core->args['page_parent'] ] ) ) { |
|
| 301 | - $add_menu = true; |
|
| 302 | - } else { |
|
| 303 | - global $menu; |
|
| 304 | - |
|
| 305 | - foreach ( $menu as $menuitem ) { |
|
| 306 | - $needle_menu_slug = isset( $menuitem ) ? $menuitem[2] : false; |
|
| 307 | - if ( false !== $needle_menu_slug ) { |
|
| 308 | - |
|
| 309 | - // check if the current needle menu equals page_parent. |
|
| 310 | - if ( 0 === strcasecmp( $needle_menu_slug, $page_parent ) ) { |
|
| 311 | - |
|
| 312 | - // found an empty parent menu. |
|
| 313 | - $add_menu = true; |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - } else { |
|
| 319 | - // The page_parent was settings.php, so set menu add flag to true. |
|
| 320 | - $add_menu = true; |
|
| 321 | - } |
|
| 322 | - // Add the submenu if it's permitted. |
|
| 323 | - if ( true === $add_menu ) { |
|
| 324 | - // ONLY for non-wp.org themes OR plugins. Theme-Check alert shown if used and IS theme. |
|
| 325 | - $this->page = call_user_func( |
|
| 326 | - 'add_submenu_page', |
|
| 327 | - $page_parent, |
|
| 328 | - $page_title, |
|
| 329 | - $menu_title, |
|
| 330 | - $page_permissions, |
|
| 331 | - $page_slug, |
|
| 332 | - array( |
|
| 333 | - $this, |
|
| 334 | - 'generate_panel', |
|
| 335 | - ) |
|
| 336 | - ); |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Output the option panel. |
|
| 343 | - */ |
|
| 344 | - public function generate_panel() { |
|
| 345 | - $core = $this->core(); |
|
| 346 | - |
|
| 347 | - $panel = new Redux_Panel( $core ); |
|
| 348 | - $panel->init(); |
|
| 349 | - $core->transient_class->set(); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * Section HTML OUTPUT. |
|
| 354 | - * |
|
| 355 | - * @param array $section Sections array. |
|
| 356 | - * |
|
| 357 | - * @return void |
|
| 358 | - * @since 1.0.0 |
|
| 359 | - * @access public |
|
| 360 | - */ |
|
| 361 | - public function section_desc( array $section ) { |
|
| 362 | - $core = $this->core(); |
|
| 363 | - |
|
| 364 | - $id = rtrim( $section['id'], '_section' ); |
|
| 365 | - $id = str_replace( $core->args['opt_name'], '', $id ); |
|
| 366 | - |
|
| 367 | - if ( isset( $core->sections[ $id ]['desc'] ) && ! empty( $core->sections[ $id ]['desc'] ) ) { |
|
| 368 | - echo '<div class="redux-section-desc">' . wp_kses_post( $core->sections[ $id ]['desc'] ) . '</div>'; |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Field HTML OUTPUT. |
|
| 374 | - * Gets an option from an option array, then calls the specific field type class - allows extending by other devs |
|
| 375 | - * |
|
| 376 | - * @param array $field Field array. |
|
| 377 | - * @param string|array|null $v Values. |
|
| 378 | - * |
|
| 379 | - * @return void |
|
| 380 | - * @since 1.0.0 |
|
| 381 | - */ |
|
| 382 | - public function field_input( array $field, $v = null ) { |
|
| 383 | - $core = $this->core(); |
|
| 384 | - |
|
| 385 | - if ( isset( $field['callback'] ) && ( is_callable( $field['callback'] ) || ( is_string( $field['callback'] ) && function_exists( $field['callback'] ) ) ) ) { |
|
| 386 | - |
|
| 387 | - $value = ( isset( $core->options[ $field['id'] ] ) ) ? $core->options[ $field['id'] ] : ''; |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Action 'redux/field/{opt_name}/{field.type}/callback/before' |
|
| 391 | - * |
|
| 392 | - * @param array $field field data |
|
| 393 | - * @param string $value field.id |
|
| 394 | - */ |
|
| 395 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 396 | - do_action_ref_array( |
|
| 397 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 398 | - "redux/field/{$core->args['opt_name']}/{$field['type']}/callback/before", |
|
| 399 | - array( |
|
| 400 | - &$field, |
|
| 401 | - &$value, |
|
| 402 | - ) |
|
| 403 | - ); |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Action 'redux/field/{opt_name}/callback/before' |
|
| 407 | - * |
|
| 408 | - * @param array $field field data |
|
| 409 | - * @param string $value field.id |
|
| 410 | - */ |
|
| 411 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 412 | - do_action_ref_array( |
|
| 413 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 414 | - "redux/field/{$core->args['opt_name']}/callback/before", |
|
| 415 | - array( |
|
| 416 | - &$field, |
|
| 417 | - &$value, |
|
| 418 | - ) |
|
| 419 | - ); |
|
| 420 | - |
|
| 421 | - call_user_func( $field['callback'], $field, $value ); |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * Action 'redux/field/{opt_name}/{field.type}/callback/after' |
|
| 425 | - * |
|
| 426 | - * @param array $field field data |
|
| 427 | - * @param string $value field.id |
|
| 428 | - */ |
|
| 429 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 430 | - do_action_ref_array( |
|
| 431 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 432 | - "redux/field/{$core->args['opt_name']}/{$field['type']}/callback/after", |
|
| 433 | - array( |
|
| 434 | - &$field, |
|
| 435 | - &$value, |
|
| 436 | - ) |
|
| 437 | - ); |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * Action 'redux/field/{opt_name}/callback/after' |
|
| 441 | - * |
|
| 442 | - * @param array $field field data |
|
| 443 | - * @param string $value field.id |
|
| 444 | - */ |
|
| 445 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 446 | - do_action_ref_array( |
|
| 447 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 448 | - "redux/field/{$core->args['opt_name']}/callback/after", |
|
| 449 | - array( |
|
| 450 | - &$field, |
|
| 451 | - &$value, |
|
| 452 | - ) |
|
| 453 | - ); |
|
| 454 | - |
|
| 455 | - return; |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - if ( isset( $field['type'] ) ) { |
|
| 459 | - // If the field is set not to display in the panel. |
|
| 460 | - $display = true; |
|
| 461 | - |
|
| 462 | - if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 463 | - if ( isset( $field['panel'] ) && false === $field['panel'] ) { |
|
| 464 | - $display = false; |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - if ( ! $display ) { |
|
| 469 | - return; |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - $field_type = str_replace( '_', '-', $field['type'] ); |
|
| 473 | - $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php"; |
|
| 474 | - |
|
| 475 | - // Shim for v3 extension class names. |
|
| 476 | - if ( ! file_exists( $core_path ) ) { |
|
| 477 | - $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php"; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - $filter_path = $core_path; |
|
| 481 | - |
|
| 482 | - $field_class = ''; |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * Filter 'redux/{opt_name}/field/class/{field.type}' |
|
| 486 | - * |
|
| 487 | - * @param string $path Field class file path. |
|
| 488 | - * @param array $field field data |
|
| 489 | - */ |
|
| 490 | - |
|
| 491 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 492 | - $class_file = apply_filters( "redux/{$core->args['opt_name']}/field/class/{$field['type']}", $filter_path, $field ); |
|
| 493 | - |
|
| 494 | - if ( $class_file ) { |
|
| 495 | - $field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] ); |
|
| 496 | - |
|
| 497 | - $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 498 | - |
|
| 499 | - if ( ! class_exists( $field_class ) ) { |
|
| 500 | - if ( file_exists( $class_file ) ) { |
|
| 501 | - require_once $class_file; |
|
| 502 | - $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 503 | - } else { |
|
| 504 | - // translators: %1$s is the field ID, %2$s is the field type. |
|
| 505 | - printf( esc_html__( 'Field %1$s could not be displayed. Field type %2$s was not found.', 'redux-framework' ), '<code>' . esc_attr( $field['id'] ) . '</code>', '<code>' . esc_attr( $field['type'] ) . '</code>' ); |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - if ( class_exists( $field_class ) ) { |
|
| 511 | - $value = $core->options[ $field['id'] ] ?? ''; |
|
| 512 | - |
|
| 513 | - if ( null !== $v ) { |
|
| 514 | - $value = $v; |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - /** |
|
| 518 | - * Action 'redux/field/{opt_name}/{field.type}/render/before' |
|
| 519 | - * |
|
| 520 | - * @param array $field field data |
|
| 521 | - * @param string $value field id |
|
| 522 | - */ |
|
| 523 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 524 | - do_action_ref_array( |
|
| 525 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 526 | - "redux/field/{$core->args['opt_name']}/{$field['type']}/render/before", |
|
| 527 | - array( |
|
| 528 | - &$field, |
|
| 529 | - &$value, |
|
| 530 | - ) |
|
| 531 | - ); |
|
| 532 | - |
|
| 533 | - /** |
|
| 534 | - * Action 'redux/field/{$this->args['opt_name']}/render/before' |
|
| 535 | - * |
|
| 536 | - * @param array $field field data |
|
| 537 | - * @param string $value field id |
|
| 538 | - */ |
|
| 539 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 540 | - do_action_ref_array( |
|
| 541 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 542 | - "redux/field/{$core->args['opt_name']}/render/before", |
|
| 543 | - array( |
|
| 544 | - &$field, |
|
| 545 | - &$value, |
|
| 546 | - ) |
|
| 547 | - ); |
|
| 548 | - |
|
| 549 | - if ( ! isset( $field['name_suffix'] ) ) { |
|
| 550 | - $field['name_suffix'] = ''; |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - $render = new $field_class( $field, $value, $core ); |
|
| 554 | - |
|
| 555 | - ob_start(); |
|
| 556 | - |
|
| 557 | - try { |
|
| 558 | - $render->render(); |
|
| 559 | - } catch ( Error $e ) { |
|
| 560 | - echo 'Field failed to render: ', esc_html( $e->getMessage() ), "\n"; |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - /** |
|
| 564 | - * Filter 'redux/field/{opt_name}' |
|
| 565 | - * |
|
| 566 | - * @param string $content Rendered field markup. |
|
| 567 | - * @param array $field field data |
|
| 568 | - */ |
|
| 569 | - |
|
| 570 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 571 | - $_render = apply_filters( "redux/field/{$core->args['opt_name']}", ob_get_contents(), $field ); |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * Filter 'redux/field/{opt_name}/{field.type}/render/after' |
|
| 575 | - * |
|
| 576 | - * @param string $content Rendered field markup. |
|
| 577 | - * @param array $field Field data |
|
| 578 | - */ |
|
| 579 | - |
|
| 580 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 581 | - $_render = apply_filters( "redux/field/{$core->args['opt_name']}/{$field['type']}/render/after", $_render, $field ); |
|
| 582 | - |
|
| 583 | - /** |
|
| 584 | - * Filter 'redux/field/{opt_name}/render/after' |
|
| 585 | - * |
|
| 586 | - * @param string $content Rendered field markup. |
|
| 587 | - * @param array $field Field data |
|
| 588 | - */ |
|
| 589 | - |
|
| 590 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 591 | - $_render = apply_filters( "redux/field/{$core->args['opt_name']}/render/after", $_render, $field ); |
|
| 592 | - |
|
| 593 | - ob_end_clean(); |
|
| 594 | - |
|
| 595 | - // create default data und class string and checks the dependencies of an object. |
|
| 596 | - $class_string = ''; |
|
| 597 | - |
|
| 598 | - $core->required_class->check_dependencies( $field ); |
|
| 599 | - |
|
| 600 | - /** |
|
| 601 | - * Action 'redux/field/{opt_name}/{field.type}/fieldset/before/{opt_name}' |
|
| 602 | - * |
|
| 603 | - * @param array $field field data |
|
| 604 | - * @param string $value field id |
|
| 605 | - */ |
|
| 606 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 607 | - do_action_ref_array( |
|
| 608 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 609 | - "redux/field/{$core->args['opt_name']}/{$field['type']}/fieldset/before/{$core->args['opt_name']}", |
|
| 610 | - array( |
|
| 611 | - &$field, |
|
| 612 | - &$value, |
|
| 613 | - ) |
|
| 614 | - ); |
|
| 615 | - |
|
| 616 | - /** |
|
| 617 | - * Action 'redux/field/{opt_name}/fieldset/before/{opt_name}' |
|
| 618 | - * |
|
| 619 | - * @param array $field field data |
|
| 620 | - * @param string $value field id |
|
| 621 | - */ |
|
| 622 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 623 | - do_action_ref_array( |
|
| 624 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 625 | - "redux/field/{$core->args['opt_name']}/fieldset/before/{$core->args['opt_name']}", |
|
| 626 | - array( |
|
| 627 | - &$field, |
|
| 628 | - &$value, |
|
| 629 | - ) |
|
| 630 | - ); |
|
| 631 | - |
|
| 632 | - $hidden = ''; |
|
| 633 | - if ( isset( $field['hidden'] ) && $field['hidden'] ) { |
|
| 634 | - $hidden = 'hidden '; |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - $disabled = ''; |
|
| 638 | - if ( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
| 639 | - $disabled = 'disabled '; |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - if ( isset( $field['full_width'] ) && true === $field['full_width'] ) { |
|
| 643 | - $class_string .= 'redux_remove_th'; |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - if ( isset( $field['fieldset_class'] ) && ! empty( $field['fieldset_class'] ) ) { |
|
| 647 | - $class_string .= ' ' . $field['fieldset_class']; |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - echo '<fieldset id="' . esc_attr( $core->args['opt_name'] . '-' . $field['id'] ) . '" class="' . esc_attr( $hidden . esc_attr( $disabled ) . 'redux-field-container redux-field redux-field-init redux-container-' . $field['type'] . ' ' . $class_string ) . '" data-id="' . esc_attr( $field['id'] ) . '" data-type="' . esc_attr( $field['type'] ) . '">'; |
|
| 651 | - echo $_render; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 652 | - |
|
| 653 | - if ( ! empty( $field['desc'] ) ) { |
|
| 654 | - $field['description'] = $field['desc']; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - echo ( isset( $field['description'] ) && 'info' !== $field['type'] && 'section' !== $field['type'] && ! empty( $field['description'] ) ) ? '<div class="description field-desc">' . wp_kses_post( $field['description'] ) . '</div>' : ''; |
|
| 658 | - echo '</fieldset>'; |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * Action 'redux/field/{opt_name}/{field.type}/fieldset/after/{opt_name}' |
|
| 662 | - * |
|
| 663 | - * @param array $field field data |
|
| 664 | - * @param string $value field id |
|
| 665 | - */ |
|
| 666 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 667 | - do_action_ref_array( |
|
| 668 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 669 | - "redux/field/{$core->args['opt_name']}/{$field['type']}/fieldset/after/{$core->args['opt_name']}", |
|
| 670 | - array( |
|
| 671 | - &$field, |
|
| 672 | - &$value, |
|
| 673 | - ) |
|
| 674 | - ); |
|
| 675 | - |
|
| 676 | - /** |
|
| 677 | - * Action 'redux/field/{opt_name}/fieldset/after/{opt_name}' |
|
| 678 | - * |
|
| 679 | - * @param array $field field data |
|
| 680 | - * @param string $value field id |
|
| 681 | - */ |
|
| 682 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 683 | - do_action_ref_array( |
|
| 684 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 685 | - "redux/field/{$core->args['opt_name']}/fieldset/after/{$core->args['opt_name']}", |
|
| 686 | - array( |
|
| 687 | - &$field, |
|
| 688 | - &$value, |
|
| 689 | - ) |
|
| 690 | - ); |
|
| 691 | - } |
|
| 692 | - } |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * Add admin bar menu. |
|
| 697 | - * |
|
| 698 | - * @since 3.1.5.16 |
|
| 699 | - * @access public |
|
| 700 | - * @global $menu , $submenu, $wp_admin_bar |
|
| 701 | - * @return void |
|
| 702 | - */ |
|
| 703 | - public function add_menu() { |
|
| 704 | - global $menu, $submenu, $wp_admin_bar; |
|
| 705 | - |
|
| 706 | - $core = $this->core(); |
|
| 707 | - |
|
| 708 | - if ( ! is_super_admin() || ! is_admin_bar_showing() || ! $core->args['admin_bar'] || 'hidden' === $core->args['menu_type'] ) { |
|
| 709 | - return; |
|
| 710 | - } |
|
| 711 | - |
|
| 712 | - if ( $menu ) { |
|
| 713 | - foreach ( $menu as $menu_item ) { |
|
| 714 | - if ( isset( $menu_item[2] ) && $menu_item[2] === $core->args['page_slug'] ) { |
|
| 715 | - |
|
| 716 | - // Fetch the title. |
|
| 717 | - $title = empty( $core->args['admin_bar_icon'] ) ? $menu_item[0] : '<span class="ab-icon ' . esc_attr( $core->args['admin_bar_icon'] ) . '"></span>' . esc_html( $menu_item[0] ); |
|
| 718 | - |
|
| 719 | - $nodeargs = array( |
|
| 720 | - 'id' => $menu_item[2], |
|
| 721 | - 'title' => $title, |
|
| 722 | - 'href' => admin_url( 'admin.php?page=' . $menu_item[2] ), |
|
| 723 | - 'meta' => array(), |
|
| 724 | - ); |
|
| 725 | - |
|
| 726 | - $wp_admin_bar->add_node( $nodeargs ); |
|
| 727 | - |
|
| 728 | - break; |
|
| 729 | - } |
|
| 730 | - } |
|
| 731 | - |
|
| 732 | - if ( isset( $submenu[ $core->args['page_slug'] ] ) && is_array( $submenu[ $core->args['page_slug'] ] ) ) { |
|
| 733 | - foreach ( $submenu[ $core->args['page_slug'] ] as $index => $redux_options_submenu ) { |
|
| 734 | - $subnodeargs = array( |
|
| 735 | - 'id' => esc_html( $core->args['page_slug'] . '_' . $index ), |
|
| 736 | - 'title' => esc_html( $redux_options_submenu[0] ), |
|
| 737 | - 'parent' => esc_html( $core->args['page_slug'] ), |
|
| 738 | - 'href' => esc_url( admin_url( 'admin.php?page=' . $redux_options_submenu[2] ) ), |
|
| 739 | - ); |
|
| 740 | - |
|
| 741 | - $wp_admin_bar->add_node( $subnodeargs ); |
|
| 742 | - } |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - // Let's deal with external links. |
|
| 746 | - if ( isset( $core->args['admin_bar_links'] ) ) { |
|
| 747 | - if ( ! $core->args['dev_mode'] && $core->args_class->omit_items ) { |
|
| 748 | - return; |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - // Group for Main Root Menu (External Group). |
|
| 752 | - $wp_admin_bar->add_node( |
|
| 753 | - array( |
|
| 754 | - 'id' => esc_html( $core->args['page_slug'] . '-external' ), |
|
| 755 | - 'parent' => esc_html( $core->args['page_slug'] ), |
|
| 756 | - 'group' => true, |
|
| 757 | - 'meta' => array( 'class' => 'ab-sub-secondary' ), |
|
| 758 | - ) |
|
| 759 | - ); |
|
| 760 | - |
|
| 761 | - // Add Child Menus to External Group Menu. |
|
| 762 | - foreach ( $core->args['admin_bar_links'] as $link ) { |
|
| 763 | - if ( ! isset( $link['id'] ) ) { |
|
| 764 | - $link['id'] = $core->args['page_slug'] . '-sub-' . sanitize_html_class( $link['title'] ); |
|
| 765 | - } |
|
| 766 | - |
|
| 767 | - $externalnodeargs = array( |
|
| 768 | - 'id' => esc_html( $link['id'] ), |
|
| 769 | - 'title' => esc_html( $link['title'] ), |
|
| 770 | - 'parent' => esc_html( $core->args['page_slug'] . '-external' ), |
|
| 771 | - 'href' => esc_url( $link['href'] ), |
|
| 772 | - 'meta' => array( 'target' => '_blank' ), |
|
| 773 | - ); |
|
| 774 | - |
|
| 775 | - $wp_admin_bar->add_node( $externalnodeargs ); |
|
| 776 | - } |
|
| 777 | - } |
|
| 778 | - } else { |
|
| 779 | - // Fetch the title. |
|
| 780 | - $title = empty( $core->args['admin_bar_icon'] ) ? $core->args['menu_title'] : '<span class="ab-icon ' . esc_attr( $core->args['admin_bar_icon'] ) . '"></span>' . esc_html( $core->args['menu_title'] ); |
|
| 781 | - |
|
| 782 | - $nodeargs = array( |
|
| 783 | - 'id' => esc_html( $core->args['page_slug'] ), |
|
| 784 | - 'title' => $title, |
|
| 785 | - 'href' => esc_url( admin_url( 'admin.php?page=' . $core->args['page_slug'] ) ), |
|
| 786 | - 'meta' => array(), |
|
| 787 | - ); |
|
| 788 | - |
|
| 789 | - $wp_admin_bar->add_node( $nodeargs ); |
|
| 790 | - } |
|
| 791 | - } |
|
| 792 | - |
|
| 793 | - /** |
|
| 794 | - * Do action redux-admin-head for option page |
|
| 795 | - * |
|
| 796 | - * @since 1.0.0 |
|
| 797 | - * @access public |
|
| 798 | - * @return void |
|
| 799 | - */ |
|
| 800 | - public function admin_head() { |
|
| 801 | - $core = $this->core(); |
|
| 802 | - |
|
| 803 | - /** |
|
| 804 | - * Action 'redux/page/{opt_name}/header' |
|
| 805 | - * |
|
| 806 | - * @param object $this ReduxFramework |
|
| 807 | - */ |
|
| 808 | - |
|
| 809 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 810 | - do_action( "redux/page/{$core->args['opt_name']}/header", $core ); |
|
| 811 | - } |
|
| 812 | - |
|
| 813 | - /** |
|
| 814 | - * Return footer text |
|
| 815 | - * |
|
| 816 | - * @since 2.0.0 |
|
| 817 | - * @access public |
|
| 818 | - * @return string $this->args['footer_credit'] |
|
| 819 | - */ |
|
| 820 | - public function admin_footer_text(): string { |
|
| 821 | - $core = $this->core(); |
|
| 822 | - |
|
| 823 | - return $core->args['footer_credit']; |
|
| 824 | - } |
|
| 825 | - |
|
| 826 | - /** |
|
| 827 | - * Generate field header HTML |
|
| 828 | - * |
|
| 829 | - * @param array $field Field array. |
|
| 830 | - * |
|
| 831 | - * @return string |
|
| 832 | - */ |
|
| 833 | - public function get_header_html( array $field ): string { |
|
| 834 | - global $current_user; |
|
| 835 | - |
|
| 836 | - $core = $this->core(); |
|
| 837 | - |
|
| 838 | - // Set to empty string to avoid warnings. |
|
| 839 | - $hint = ''; |
|
| 840 | - $th = ''; |
|
| 841 | - |
|
| 842 | - if ( isset( $field['title'] ) && isset( $field['type'] ) && 'info' !== $field['type'] && 'section' !== $field['type'] ) { |
|
| 843 | - $default_mark = ( ! empty( $field['default'] ) && isset( $core->options[ $field['id'] ] ) && $field['default'] === $core->options[ $field['id'] ] && ! empty( $core->args['default_mark'] ) ) ? $core->args['default_mark'] : ''; |
|
| 844 | - |
|
| 845 | - // If a hint is specified in the field, process it. |
|
| 846 | - if ( isset( $field['hint'] ) && ! empty( $field['hint'] ) ) { |
|
| 847 | - |
|
| 848 | - // Set the show_hints flag to true, so the help tab will be displayed. |
|
| 849 | - $this->show_hints = true; |
|
| 850 | - |
|
| 851 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 852 | - $hint = apply_filters( 'redux/hints/html', $hint, $field, $core->args ); |
|
| 853 | - |
|
| 854 | - // Get user pref for displaying hints. |
|
| 855 | - $meta_val = get_user_meta( $current_user->ID, 'ignore_hints', true ); |
|
| 856 | - |
|
| 857 | - if ( 'true' === $meta_val || empty( $meta_val ) && empty( $hint ) ) { |
|
| 858 | - |
|
| 859 | - // Set hand cursor for clickable hints. |
|
| 860 | - $pointer = ''; |
|
| 861 | - if ( isset( $core->args['hints']['tip_effect']['show']['event'] ) && 'click' === $core->args['hints']['tip_effect']['show']['event'] ) { |
|
| 862 | - $pointer = 'pointer'; |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - $size = '16px'; |
|
| 866 | - if ( 'large' === $core->args['hints']['icon_size'] ) { |
|
| 867 | - $size = '18px'; |
|
| 868 | - } |
|
| 869 | - |
|
| 870 | - // In case docs are ignored. |
|
| 871 | - $title_param = $field['hint']['title'] ?? ''; |
|
| 872 | - $content_param = $field['hint']['content'] ?? ''; |
|
| 873 | - |
|
| 874 | - $hint_color = $core->args['hints']['icon_color'] ?? '#d3d3d3'; |
|
| 875 | - |
|
| 876 | - // Set hint html with appropriate position css. |
|
| 877 | - $hint = '<div class="redux-hint-qtip" style="float:' . esc_attr( $core->args['hints']['icon_position'] ) . '; font-size: ' . esc_attr( $size ) . '; color:' . esc_attr( $hint_color ) . '; cursor: ' . $pointer . ';" qtip-title="' . esc_attr( $title_param ) . '" qtip-content="' . wp_kses_post( $content_param ) . '"> <i class="' . ( isset( $core->args['hints']['icon'] ) ? esc_attr( $core->args['hints']['icon'] ) : '' ) . '"></i></div>'; |
|
| 878 | - } |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - if ( ! empty( $field['title'] ) ) { |
|
| 882 | - if ( 'left' === $core->args['hints']['icon_position'] ) { |
|
| 883 | - $th = $hint . wp_kses_post( $field['title'] ) . $default_mark . ' '; |
|
| 884 | - } else { |
|
| 885 | - $th = wp_kses_post( $field['title'] ) . $default_mark . ' ' . $hint; |
|
| 886 | - } |
|
| 887 | - } |
|
| 888 | - |
|
| 889 | - if ( isset( $field['subtitle'] ) ) { |
|
| 890 | - $th .= '<span class="description">' . wp_kses_post( $field['subtitle'] ) . '</span>'; |
|
| 891 | - } |
|
| 892 | - } |
|
| 893 | - |
|
| 894 | - if ( ! empty( $th ) ) { |
|
| 895 | - $th = '<div class="redux_field_th">' . $th . '</div>'; |
|
| 896 | - } |
|
| 897 | - |
|
| 898 | - $filter_arr = array( |
|
| 899 | - 'editor', |
|
| 900 | - 'ace_editor', |
|
| 901 | - 'info', |
|
| 902 | - 'section', |
|
| 903 | - 'repeater', |
|
| 904 | - 'tabbed', |
|
| 905 | - 'color_scheme', |
|
| 906 | - 'social_profiles', |
|
| 907 | - 'css_layout', |
|
| 908 | - ); |
|
| 909 | - |
|
| 910 | - if ( true === $core->args['default_show'] && isset( $field['default'] ) && isset( $core->options[ $field['id'] ] ) && $field['default'] !== $core->options[ $field['id'] ] && ! in_array( $field['type'], $filter_arr, true ) ) { |
|
| 911 | - $th .= $this->get_default_output_string( $field ); |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - return $th; |
|
| 915 | - } |
|
| 916 | - |
|
| 917 | - /** |
|
| 918 | - * Return default output string for use in a panel |
|
| 919 | - * |
|
| 920 | - * @param array $field Field array. |
|
| 921 | - * |
|
| 922 | - * @return string default_output |
|
| 923 | - * @since 3.1.5 |
|
| 924 | - * @access public |
|
| 925 | - */ |
|
| 926 | - private function get_default_output_string( array $field ): string { |
|
| 927 | - $default_output = ''; |
|
| 928 | - |
|
| 929 | - if ( ! isset( $field['default'] ) ) { |
|
| 930 | - $field['default'] = ''; |
|
| 931 | - } |
|
| 932 | - |
|
| 933 | - if ( ! is_array( $field['default'] ) ) { |
|
| 934 | - if ( ! empty( $field['options'][ $field['default'] ] ) ) { |
|
| 935 | - if ( ! empty( $field['options'][ $field['default'] ]['alt'] ) ) { |
|
| 936 | - $default_output .= $field['options'][ $field['default'] ]['alt'] . ', '; |
|
| 937 | - } elseif ( ! is_array( $field['options'][ $field['default'] ] ) ) { |
|
| 938 | - $default_output .= $field['options'][ $field['default'] ] . ', '; |
|
| 939 | - } else { |
|
| 940 | - $default_output .= maybe_serialize( $field['options'][ $field['default'] ] ) . ', '; |
|
| 941 | - } |
|
| 942 | - } elseif ( ! empty( $field['options'][ $field['default'] ] ) ) { |
|
| 943 | - $default_output .= $field['options'][ $field['default'] ] . ', '; |
|
| 944 | - } elseif ( ! empty( $field['default'] ) ) { |
|
| 945 | - if ( 'switch' === $field['type'] && isset( $field['on'] ) && isset( $field['off'] ) ) { |
|
| 946 | - $default_output .= ( 1 === $field['default'] ? $field['on'] : $field['off'] ) . ', '; |
|
| 947 | - } else { |
|
| 948 | - $default_output .= $field['default'] . ', '; |
|
| 949 | - } |
|
| 950 | - } |
|
| 951 | - } else { |
|
| 952 | - foreach ( $field['default'] as $defaultk => $defaultv ) { |
|
| 953 | - $defaultk = is_numeric( $defaultk ) ? (string) $defaultk : $defaultk; |
|
| 954 | - $defaultv = is_numeric( $defaultv ) ? (string) $defaultv : $defaultv; |
|
| 955 | - |
|
| 956 | - if ( ! empty( $field['options'][ $defaultv ]['alt'] ) ) { |
|
| 957 | - $default_output .= $field['options'][ $defaultv ]['alt'] . ', '; |
|
| 958 | - } elseif ( ! empty( $field['options'][ $defaultv ] ) ) { |
|
| 959 | - $default_output .= $field['options'][ $defaultv ] . ', '; |
|
| 960 | - } elseif ( ! empty( $field['options'][ $defaultk ] ) ) { |
|
| 961 | - $default_output .= $field['options'][ $defaultk ] . ', '; |
|
| 962 | - } elseif ( ! empty( $defaultv ) ) { |
|
| 963 | - if ( is_array( $defaultv ) ) { |
|
| 964 | - foreach ( $defaultv as $k => $v ) { |
|
| 965 | - if( is_array( $v ) ) { |
|
| 966 | - $defaultv = implode( ', ', $v ); |
|
| 967 | - } |
|
| 968 | - } |
|
| 969 | - |
|
| 970 | - if ( is_array( $defaultv ) ) { |
|
| 971 | - $defaultv = implode( ', ', $defaultv ); |
|
| 972 | - } |
|
| 973 | - } |
|
| 974 | - |
|
| 975 | - $default_output .= $defaultv . ', '; |
|
| 976 | - } |
|
| 977 | - } |
|
| 978 | - } |
|
| 979 | - |
|
| 980 | - if ( ! empty( $default_output ) ) { |
|
| 981 | - $default_output = esc_html__( 'Default', 'redux-framework' ) . ': ' . substr( $default_output, 0, - 2 ); |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - if ( ! empty( $default_output ) ) { |
|
| 985 | - $default_output = '<span class="showDefaults">' . esc_html( $default_output ) . '</span><br class="default_br" />'; |
|
| 986 | - } |
|
| 987 | - |
|
| 988 | - return $default_output; |
|
| 989 | - } |
|
| 990 | - |
|
| 991 | - /** |
|
| 992 | - * Return Section Menu HTML. |
|
| 993 | - * |
|
| 994 | - * @param int|string $k Section index. |
|
| 995 | - * @param array $section Section array. |
|
| 996 | - * @param string $suffix Optional suffix. |
|
| 997 | - * @param array $sections Sections array. |
|
| 998 | - * |
|
| 999 | - * @return string |
|
| 1000 | - * @since 3.1.5 |
|
| 1001 | - * @access public |
|
| 1002 | - */ |
|
| 1003 | - public function section_menu( $k, array $section, string $suffix = '', array $sections = array() ): string { |
|
| 1004 | - $function_count = 0; |
|
| 1005 | - |
|
| 1006 | - $core = $this->core(); |
|
| 1007 | - |
|
| 1008 | - $display = true; |
|
| 1009 | - |
|
| 1010 | - $section['class'] = isset( $section['class'] ) ? ' ' . $section['class'] : ''; |
|
| 1011 | - |
|
| 1012 | - if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 1013 | - if ( isset( $section['panel'] ) && false === $section['panel'] ) { |
|
| 1014 | - $display = false; |
|
| 1015 | - } |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - if ( ! $display ) { |
|
| 1019 | - return ''; |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - if ( empty( $sections ) ) { |
|
| 1023 | - $sections = $core->sections; |
|
| 1024 | - $function_count = $k; |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - $string = ''; |
|
| 1028 | - if ( ( ( isset( $core->args['icon_type'] ) && 'image' === $core->args['icon_type'] ) || ( isset( $section['icon_type'] ) && 'image' === $section['icon_type'] ) ) || ( isset( $section['icon'] ) && false !== strpos( $section['icon'], '/' ) ) ) { |
|
| 1029 | - // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- No image/icon to enqueue. |
|
| 1030 | - $icon = ( ! isset( $section['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $section['icon'] ) . '" /> '; |
|
| 1031 | - } else { |
|
| 1032 | - if ( ! empty( $section['icon_class'] ) ) { |
|
| 1033 | - $icon_class = ' ' . $section['icon_class']; |
|
| 1034 | - } elseif ( ! empty( $core->args['default_icon_class'] ) ) { |
|
| 1035 | - $icon_class = ' ' . $core->args['default_icon_class']; |
|
| 1036 | - } else { |
|
| 1037 | - $icon_class = ''; |
|
| 1038 | - } |
|
| 1039 | - $icon = ( ! isset( $section['icon'] ) ) ? '<i class="el el-cog' . esc_attr( $icon_class ) . '"></i> ' : '<i class="' . esc_attr( $section['icon'] ) . esc_attr( $icon_class ) . '"></i> '; |
|
| 1040 | - } |
|
| 1041 | - if ( strpos( $icon, 'el-icon-' ) !== false ) { |
|
| 1042 | - $icon = str_replace( 'el-icon-', 'el el-', $icon ); |
|
| 1043 | - } |
|
| 1044 | - |
|
| 1045 | - $hide_section = ''; |
|
| 1046 | - if ( isset( $section['hidden'] ) ) { |
|
| 1047 | - $hide_section = ( true === $section['hidden'] ) ? ' hidden ' : ''; |
|
| 1048 | - } |
|
| 1049 | - |
|
| 1050 | - $can_be_subsection = $k > 0 && ( ! isset( $sections[ ( $k ) ]['type'] ) || 'divide' !== $sections[ ( $k ) ]['type'] ); |
|
| 1051 | - |
|
| 1052 | - if ( ! $can_be_subsection && isset( $section['subsection'] ) && true === $section['subsection'] ) { |
|
| 1053 | - unset( $section['subsection'] ); |
|
| 1054 | - } |
|
| 1055 | - |
|
| 1056 | - if ( isset( $section['type'] ) && 'divide' === $section['type'] ) { |
|
| 1057 | - $string .= '<li class="divide' . esc_attr( $section['class'] ) . '"> </li>'; |
|
| 1058 | - } elseif ( ! isset( $section['subsection'] ) || true !== $section['subsection'] ) { |
|
| 1059 | - $subsections = isset( $sections[ ( $k + 1 ) ]['subsection'] ) && true === $sections[ ( $k + 1 ) ]['subsection']; |
|
| 1060 | - $subsections_class = $subsections ? ' hasSubSections' : ''; |
|
| 1061 | - $subsections_class .= ( empty( $section['fields'] ) ) ? ' empty_section' : ''; |
|
| 1062 | - $rotate = true === $core->args['flyout_submenus'] ? ' el-rotate' : ''; |
|
| 1063 | - $extra_icon = $subsections ? '<span class="extraIconSubsections"><i class="el el-chevron-down' . $rotate . '"> </i></span>' : ''; |
|
| 1064 | - $string .= '<li id="' . esc_attr( $k . $suffix ) . '_section_group_li" class="redux-group-tab-link-li' . esc_attr( $hide_section ) . esc_attr( $section['class'] ) . esc_attr( $subsections_class ) . '">'; |
|
| 1065 | - $string .= '<a href="javascript:void(0);" id="' . esc_attr( $k . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $k ) . '" data-rel="' . esc_attr( $k . $suffix ) . '">' . $extra_icon . $icon . '<span class="group_title">' . wp_kses_post( $section['title'] ) . '</span></a>'; |
|
| 1066 | - |
|
| 1067 | - $next_k = $k; |
|
| 1068 | - |
|
| 1069 | - // Make sure you can make this a subsection. |
|
| 1070 | - if ( $subsections ) { |
|
| 1071 | - $string .= '<ul id="' . esc_attr( $next_k . $suffix ) . '_section_group_li_subsections" class="subsection">'; |
|
| 1072 | - |
|
| 1073 | - $do_loop = true; |
|
| 1074 | - |
|
| 1075 | - while ( $do_loop ) { |
|
| 1076 | - ++$next_k; |
|
| 1077 | - ++$function_count; |
|
| 1078 | - |
|
| 1079 | - $display = true; |
|
| 1080 | - |
|
| 1081 | - if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 1082 | - if ( isset( $sections[ $next_k ]['panel'] ) && false === $sections[ $next_k ]['panel'] ) { |
|
| 1083 | - $display = false; |
|
| 1084 | - } |
|
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - if ( count( $sections ) < $function_count || ! isset( $sections[ $next_k ] ) || ! isset( $sections[ $next_k ]['subsection'] ) || true !== $sections[ $next_k ]['subsection'] ) { |
|
| 1088 | - $do_loop = false; |
|
| 1089 | - } else { |
|
| 1090 | - if ( ! $display ) { |
|
| 1091 | - continue; |
|
| 1092 | - } |
|
| 1093 | - |
|
| 1094 | - $hide_sub = ''; |
|
| 1095 | - if ( isset( $sections[ $next_k ]['hidden'] ) ) { |
|
| 1096 | - $hide_sub = ( true === $sections[ $next_k ]['hidden'] ) ? ' hidden ' : ''; |
|
| 1097 | - } |
|
| 1098 | - |
|
| 1099 | - if ( ( isset( $core->args['icon_type'] ) && 'image' === $core->args['icon_type'] ) || ( isset( $sections[ $next_k ]['icon_type'] ) && 'image' === $sections[ $next_k ]['icon_type'] ) ) { |
|
| 1100 | - // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- No image/icon to enqueue. |
|
| 1101 | - $icon = ( ! isset( $sections[ $next_k ]['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $sections[ $next_k ]['icon'] ) . '" /> '; |
|
| 1102 | - } else { |
|
| 1103 | - if ( ! empty( $sections[ $next_k ]['icon_class'] ) ) { |
|
| 1104 | - $icon_class = ' ' . $sections[ $next_k ]['icon_class']; |
|
| 1105 | - } elseif ( ! empty( $core->args['default_icon_class'] ) ) { |
|
| 1106 | - $icon_class = ' ' . $core->args['default_icon_class']; |
|
| 1107 | - } else { |
|
| 1108 | - $icon_class = ''; |
|
| 1109 | - } |
|
| 1110 | - $icon = ( ! isset( $sections[ $next_k ]['icon'] ) ) ? '' : '<i class="' . esc_attr( $sections[ $next_k ]['icon'] ) . esc_attr( $icon_class ) . '"></i> '; |
|
| 1111 | - } |
|
| 1112 | - if ( strpos( $icon, 'el-icon-' ) !== false ) { |
|
| 1113 | - $icon = str_replace( 'el-icon-', 'el el-', $icon ); |
|
| 1114 | - } |
|
| 1115 | - |
|
| 1116 | - $sections[ $next_k ]['class'] = $sections[ $next_k ]['class'] ?? ''; |
|
| 1117 | - $section[ $next_k ]['class'] = $section[ $next_k ]['class'] ?? $sections[ $next_k ]['class']; |
|
| 1118 | - $string .= '<li id="' . esc_attr( $next_k . $suffix ) . '_section_group_li" class="redux-group-tab-link-li ' . esc_attr( $hide_sub ) . esc_attr( $section[ $next_k ]['class'] ) . ( $icon ? ' hasIcon' : '' ) . '">'; |
|
| 1119 | - $string .= '<a href="javascript:void(0);" id="' . esc_attr( $next_k . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $next_k ) . '" data-rel="' . esc_attr( $next_k . $suffix ) . '">' . $icon . '<span class="group_title">' . wp_kses_post( $sections[ $next_k ]['title'] ) . '</span></a>'; |
|
| 1120 | - $string .= '</li>'; |
|
| 1121 | - } |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - $string .= '</ul>'; |
|
| 1125 | - } |
|
| 1126 | - |
|
| 1127 | - $string .= '</li>'; |
|
| 1128 | - } |
|
| 1129 | - |
|
| 1130 | - return $string; |
|
| 1131 | - } |
|
| 1132 | - } |
|
| 16 | + /** |
|
| 17 | + * Class Redux_Page_Render |
|
| 18 | + */ |
|
| 19 | + class Redux_Page_Render extends Redux_Class { |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Flag to show or hide hints in a panel. |
|
| 23 | + * |
|
| 24 | + * @var bool |
|
| 25 | + * @access private |
|
| 26 | + */ |
|
| 27 | + private $show_hints = false; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Creates page's hook suffix. |
|
| 31 | + * |
|
| 32 | + * @var false|string |
|
| 33 | + * @access private |
|
| 34 | + */ |
|
| 35 | + private $page = ''; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Redux_Page_Render constructor. |
|
| 39 | + * |
|
| 40 | + * @param object $redux ReduxFramework pointer. |
|
| 41 | + */ |
|
| 42 | + public function __construct( $redux ) { |
|
| 43 | + parent::__construct( $redux ); |
|
| 44 | + |
|
| 45 | + // phpcs:ignore Generic.Strings.UnnecessaryStringConcat |
|
| 46 | + add_action( 'admin' . '_bar' . '_menu', array( $this, 'add_menu' ), $redux->args['admin_bar_priority'] ); |
|
| 47 | + |
|
| 48 | + // Options page. |
|
| 49 | + add_action( 'admin_menu', array( $this, 'options_page' ) ); |
|
| 50 | + |
|
| 51 | + // Add a network menu. |
|
| 52 | + if ( 'network' === $redux->args['database'] && $redux->args['network_admin'] ) { |
|
| 53 | + add_action( 'network_admin_menu', array( $this, 'options_page' ) ); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Class Options Page Function, creates main options page. |
|
| 59 | + * |
|
| 60 | + * @since 1.0.0 |
|
| 61 | + * @access public |
|
| 62 | + * @return void |
|
| 63 | + */ |
|
| 64 | + public function options_page() { |
|
| 65 | + $core = $this->core(); |
|
| 66 | + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement |
|
| 67 | + if ( 'hidden' === $core->args['menu_type'] ) { |
|
| 68 | + // No menu to add! |
|
| 69 | + } elseif ( 'submenu' === $core->args['menu_type'] ) { |
|
| 70 | + $this->submenu( $core ); |
|
| 71 | + } else { |
|
| 72 | + // Theme-Check notice is displayed for WP.org theme devs, informing them to NOT use this. |
|
| 73 | + $this->page = call_user_func( |
|
| 74 | + 'add_menu_page', |
|
| 75 | + $core->args['page_title'], |
|
| 76 | + $core->args['menu_title'], |
|
| 77 | + $core->args['page_permissions'], |
|
| 78 | + $core->args['page_slug'], |
|
| 79 | + array( |
|
| 80 | + $this, |
|
| 81 | + 'generate_panel', |
|
| 82 | + ), |
|
| 83 | + $core->args['menu_icon'], |
|
| 84 | + (int) $core->args['page_priority'] |
|
| 85 | + ); |
|
| 86 | + |
|
| 87 | + if ( true === $core->args['allow_sub_menu'] ) { |
|
| 88 | + foreach ( $core->sections as $k => $section ) { |
|
| 89 | + $can_be_subsection = $k > 0 && ( ! isset( $core->sections[ ( $k ) ]['type'] ) || 'divide' !== $core->sections[ ( $k ) ]['type'] ); |
|
| 90 | + |
|
| 91 | + if ( ! isset( $section['title'] ) || ( $can_be_subsection && ( isset( $section['subsection'] ) && true === $section['subsection'] ) ) ) { |
|
| 92 | + continue; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if ( isset( $section['submenu'] ) && false === $section['submenu'] ) { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if ( isset( $section['customizer_only'] ) && true === $section['customizer_only'] ) { |
|
| 100 | + continue; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if ( isset( $section['hidden'] ) && true === $section['hidden'] ) { |
|
| 104 | + continue; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ( isset( $section['permissions'] ) && ! Redux_Helpers::current_user_can( $section['permissions'] ) ) { |
|
| 108 | + continue; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // ONLY for non-wp.org themes OR plugins. Theme-Check alert shown if used and IS theme. |
|
| 112 | + call_user_func( |
|
| 113 | + 'add_submenu_page', |
|
| 114 | + $core->args['page_slug'], |
|
| 115 | + $section['title'], |
|
| 116 | + $section['title'], |
|
| 117 | + $core->args['page_permissions'], |
|
| 118 | + $core->args['page_slug'] . '&tab=' . $k, |
|
| 119 | + '__return_null' |
|
| 120 | + ); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // Remove parent submenu item instead of adding null item. |
|
| 124 | + remove_submenu_page( $core->args['page_slug'], $core->args['page_slug'] ); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + add_action( "load-$this->page", array( $this, 'load_page' ) ); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Show page help |
|
| 133 | + * |
|
| 134 | + * @since 1.0.0 |
|
| 135 | + * @access public |
|
| 136 | + * @return void |
|
| 137 | + */ |
|
| 138 | + public function load_page() { |
|
| 139 | + $core = $this->core(); |
|
| 140 | + |
|
| 141 | + // Do admin head action for this page. |
|
| 142 | + add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
| 143 | + |
|
| 144 | + // Do admin footer text hook. |
|
| 145 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
| 146 | + |
|
| 147 | + $screen = get_current_screen(); |
|
| 148 | + |
|
| 149 | + if ( is_array( $core->args['help_tabs'] ) ) { |
|
| 150 | + foreach ( $core->args['help_tabs'] as $tab ) { |
|
| 151 | + $screen->add_help_tab( $tab ); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // If hint argument is set, display hint tab. |
|
| 156 | + if ( true === $this->show_hints ) { |
|
| 157 | + global $current_user; |
|
| 158 | + |
|
| 159 | + $cur_page = ''; |
|
| 160 | + |
|
| 161 | + // Users enable/disable hint choice. |
|
| 162 | + $hint_status = get_user_meta( $current_user->ID, 'ignore_hints' ) ? get_user_meta( $current_user->ID, 'ignore_hints', true ) : 'true'; |
|
| 163 | + |
|
| 164 | + // current page parameters. |
|
| 165 | + if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 166 | + $cur_page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + $cur_tab = '0'; |
|
| 170 | + if ( isset( $_GET['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 171 | + $cur_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // Default url values for enabling hints. |
|
| 175 | + $dismiss = 'true'; |
|
| 176 | + $s = esc_html__( 'Enable', 'redux-framework' ); |
|
| 177 | + |
|
| 178 | + // Values for disabling hints. |
|
| 179 | + if ( 'true' === $hint_status ) { |
|
| 180 | + $dismiss = 'false'; |
|
| 181 | + $s = esc_html__( 'Disable', 'redux-framework' ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Make URL. |
|
| 185 | + $nonce = wp_create_nonce( 'redux_hint_toggle' ); |
|
| 186 | + $url = '<a class="redux_hint_status" href="?nonce=' . $nonce . '&dismiss=' . $dismiss . '&id=hints&page=' . esc_attr( $cur_page ) . '&tab=' . esc_attr( $cur_tab ) . '">' . $s . ' hints</a>'; |
|
| 187 | + |
|
| 188 | + $event = esc_html__( 'moving the mouse over', 'redux-framework' ); |
|
| 189 | + if ( 'click' === $core->args['hints']['tip_effect']['show']['event'] ) { |
|
| 190 | + $event = esc_html__( 'clicking', 'redux-framework' ); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + // Construct message. |
|
| 194 | + // translators: %1$s: Mouse action. %2$s: Hint status. |
|
| 195 | + $msg = sprintf( esc_html__( 'Hints are tooltips that popup when %1$s the hint icon, offering addition information about the field in which they appear. They can be %2$s by using the link below.', 'redux-framework' ), $event, Redux_Core::strtolower( $s ) ) . '<br/><br/>' . $url; |
|
| 196 | + |
|
| 197 | + // Construct hint tab. |
|
| 198 | + $tab = array( |
|
| 199 | + 'id' => 'redux-hint-tab', |
|
| 200 | + 'title' => esc_html__( 'Hints', 'redux-framework' ), |
|
| 201 | + 'content' => '<p>' . $msg . '</p>', |
|
| 202 | + ); |
|
| 203 | + |
|
| 204 | + $screen->add_help_tab( $tab ); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + // Sidebar text. |
|
| 208 | + if ( '' !== $core->args['help_sidebar'] ) { |
|
| 209 | + |
|
| 210 | + // Specify user's text from arguments. |
|
| 211 | + $screen->set_help_sidebar( $core->args['help_sidebar'] ); |
|
| 212 | + } elseif ( true === $this->show_hints ) { |
|
| 213 | + // If a sidebar text is empty and hints are active, display text |
|
| 214 | + // about hints. |
|
| 215 | + |
|
| 216 | + $screen->set_help_sidebar( '<p><strong>Redux Framework</strong><br/><br/>' . esc_html__( 'Hint Tooltip Preferences', 'redux-framework' ) . '</p>' ); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Action 'redux/page/{opt_name}/load' |
|
| 221 | + * |
|
| 222 | + * @param object $screen WP_Screen |
|
| 223 | + */ |
|
| 224 | + |
|
| 225 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 226 | + do_action( "redux/page/{$core->args['opt_name']}/load", $screen ); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Class Add Sub Menu Function, creates option submenu in WordPress admin area. |
|
| 231 | + * |
|
| 232 | + * @param object $core ReduxFramework core pointer. |
|
| 233 | + * |
|
| 234 | + * @since 3.1.9 |
|
| 235 | + * @access private |
|
| 236 | + * @return void |
|
| 237 | + */ |
|
| 238 | + private function submenu( $core ) { |
|
| 239 | + global $submenu; |
|
| 240 | + |
|
| 241 | + $page_parent = $core->args['page_parent']; |
|
| 242 | + $page_title = $core->args['page_title']; |
|
| 243 | + $menu_title = $core->args['menu_title']; |
|
| 244 | + $page_permissions = $core->args['page_permissions']; |
|
| 245 | + $page_slug = $core->args['page_slug']; |
|
| 246 | + |
|
| 247 | + // Just in case. One never knows. |
|
| 248 | + $page_parent = Redux_Core::strtolower( $page_parent ); |
|
| 249 | + |
|
| 250 | + $test = array( |
|
| 251 | + 'index.php' => 'dashboard', |
|
| 252 | + 'edit.php' => 'posts', |
|
| 253 | + 'upload.php' => 'media', |
|
| 254 | + 'link-manager.php' => 'links', |
|
| 255 | + 'edit.php?post_type=page' => 'pages', |
|
| 256 | + 'edit-comments.php' => 'comments', |
|
| 257 | + 'themes.php' => 'theme', |
|
| 258 | + 'plugins.php' => 'plugins', |
|
| 259 | + 'users.php' => 'users', |
|
| 260 | + 'tools.php' => 'management', |
|
| 261 | + 'options-general.php' => 'options', |
|
| 262 | + ); |
|
| 263 | + |
|
| 264 | + if ( isset( $test[ $page_parent ] ) ) { |
|
| 265 | + $function = 'add_' . $test[ $page_parent ] . '_page'; |
|
| 266 | + $this->page = $function( |
|
| 267 | + $page_title, |
|
| 268 | + $menu_title, |
|
| 269 | + $page_permissions, |
|
| 270 | + $page_slug, |
|
| 271 | + array( $this, 'generate_panel' ) |
|
| 272 | + ); |
|
| 273 | + } else { |
|
| 274 | + // Network settings and Post type menus. These do not have |
|
| 275 | + // wrappers and need to be appended to using add_submenu_page. |
|
| 276 | + // Okay, since we've left the post-type menu appending |
|
| 277 | + // as default, we need to validate it, so anything that |
|
| 278 | + // isn't post_type=<post_type> doesn't get through and mess |
|
| 279 | + // things up. |
|
| 280 | + $add_menu = false; |
|
| 281 | + if ( 'settings.php' !== $page_parent ) { |
|
| 282 | + // Establish the needle. |
|
| 283 | + $needle = '?post_type='; |
|
| 284 | + |
|
| 285 | + // Check if it exists in the page_parent (how I miss instr). |
|
| 286 | + $needle_pos = strrpos( $page_parent, $needle ); |
|
| 287 | + |
|
| 288 | + // It's there, so... |
|
| 289 | + if ( $needle_pos > 0 ) { |
|
| 290 | + |
|
| 291 | + // Get the post-type. |
|
| 292 | + $post_type = substr( $page_parent, $needle_pos + strlen( $needle ) ); |
|
| 293 | + |
|
| 294 | + // Ensure it exists. |
|
| 295 | + if ( post_type_exists( $post_type ) ) { |
|
| 296 | + // Set the flag to add the menu page. |
|
| 297 | + $add_menu = true; |
|
| 298 | + } |
|
| 299 | + // custom menu. |
|
| 300 | + } elseif ( isset( $submenu[ $core->args['page_parent'] ] ) ) { |
|
| 301 | + $add_menu = true; |
|
| 302 | + } else { |
|
| 303 | + global $menu; |
|
| 304 | + |
|
| 305 | + foreach ( $menu as $menuitem ) { |
|
| 306 | + $needle_menu_slug = isset( $menuitem ) ? $menuitem[2] : false; |
|
| 307 | + if ( false !== $needle_menu_slug ) { |
|
| 308 | + |
|
| 309 | + // check if the current needle menu equals page_parent. |
|
| 310 | + if ( 0 === strcasecmp( $needle_menu_slug, $page_parent ) ) { |
|
| 311 | + |
|
| 312 | + // found an empty parent menu. |
|
| 313 | + $add_menu = true; |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + } else { |
|
| 319 | + // The page_parent was settings.php, so set menu add flag to true. |
|
| 320 | + $add_menu = true; |
|
| 321 | + } |
|
| 322 | + // Add the submenu if it's permitted. |
|
| 323 | + if ( true === $add_menu ) { |
|
| 324 | + // ONLY for non-wp.org themes OR plugins. Theme-Check alert shown if used and IS theme. |
|
| 325 | + $this->page = call_user_func( |
|
| 326 | + 'add_submenu_page', |
|
| 327 | + $page_parent, |
|
| 328 | + $page_title, |
|
| 329 | + $menu_title, |
|
| 330 | + $page_permissions, |
|
| 331 | + $page_slug, |
|
| 332 | + array( |
|
| 333 | + $this, |
|
| 334 | + 'generate_panel', |
|
| 335 | + ) |
|
| 336 | + ); |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Output the option panel. |
|
| 343 | + */ |
|
| 344 | + public function generate_panel() { |
|
| 345 | + $core = $this->core(); |
|
| 346 | + |
|
| 347 | + $panel = new Redux_Panel( $core ); |
|
| 348 | + $panel->init(); |
|
| 349 | + $core->transient_class->set(); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * Section HTML OUTPUT. |
|
| 354 | + * |
|
| 355 | + * @param array $section Sections array. |
|
| 356 | + * |
|
| 357 | + * @return void |
|
| 358 | + * @since 1.0.0 |
|
| 359 | + * @access public |
|
| 360 | + */ |
|
| 361 | + public function section_desc( array $section ) { |
|
| 362 | + $core = $this->core(); |
|
| 363 | + |
|
| 364 | + $id = rtrim( $section['id'], '_section' ); |
|
| 365 | + $id = str_replace( $core->args['opt_name'], '', $id ); |
|
| 366 | + |
|
| 367 | + if ( isset( $core->sections[ $id ]['desc'] ) && ! empty( $core->sections[ $id ]['desc'] ) ) { |
|
| 368 | + echo '<div class="redux-section-desc">' . wp_kses_post( $core->sections[ $id ]['desc'] ) . '</div>'; |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Field HTML OUTPUT. |
|
| 374 | + * Gets an option from an option array, then calls the specific field type class - allows extending by other devs |
|
| 375 | + * |
|
| 376 | + * @param array $field Field array. |
|
| 377 | + * @param string|array|null $v Values. |
|
| 378 | + * |
|
| 379 | + * @return void |
|
| 380 | + * @since 1.0.0 |
|
| 381 | + */ |
|
| 382 | + public function field_input( array $field, $v = null ) { |
|
| 383 | + $core = $this->core(); |
|
| 384 | + |
|
| 385 | + if ( isset( $field['callback'] ) && ( is_callable( $field['callback'] ) || ( is_string( $field['callback'] ) && function_exists( $field['callback'] ) ) ) ) { |
|
| 386 | + |
|
| 387 | + $value = ( isset( $core->options[ $field['id'] ] ) ) ? $core->options[ $field['id'] ] : ''; |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Action 'redux/field/{opt_name}/{field.type}/callback/before' |
|
| 391 | + * |
|
| 392 | + * @param array $field field data |
|
| 393 | + * @param string $value field.id |
|
| 394 | + */ |
|
| 395 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 396 | + do_action_ref_array( |
|
| 397 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 398 | + "redux/field/{$core->args['opt_name']}/{$field['type']}/callback/before", |
|
| 399 | + array( |
|
| 400 | + &$field, |
|
| 401 | + &$value, |
|
| 402 | + ) |
|
| 403 | + ); |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Action 'redux/field/{opt_name}/callback/before' |
|
| 407 | + * |
|
| 408 | + * @param array $field field data |
|
| 409 | + * @param string $value field.id |
|
| 410 | + */ |
|
| 411 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 412 | + do_action_ref_array( |
|
| 413 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 414 | + "redux/field/{$core->args['opt_name']}/callback/before", |
|
| 415 | + array( |
|
| 416 | + &$field, |
|
| 417 | + &$value, |
|
| 418 | + ) |
|
| 419 | + ); |
|
| 420 | + |
|
| 421 | + call_user_func( $field['callback'], $field, $value ); |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * Action 'redux/field/{opt_name}/{field.type}/callback/after' |
|
| 425 | + * |
|
| 426 | + * @param array $field field data |
|
| 427 | + * @param string $value field.id |
|
| 428 | + */ |
|
| 429 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 430 | + do_action_ref_array( |
|
| 431 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 432 | + "redux/field/{$core->args['opt_name']}/{$field['type']}/callback/after", |
|
| 433 | + array( |
|
| 434 | + &$field, |
|
| 435 | + &$value, |
|
| 436 | + ) |
|
| 437 | + ); |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * Action 'redux/field/{opt_name}/callback/after' |
|
| 441 | + * |
|
| 442 | + * @param array $field field data |
|
| 443 | + * @param string $value field.id |
|
| 444 | + */ |
|
| 445 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 446 | + do_action_ref_array( |
|
| 447 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 448 | + "redux/field/{$core->args['opt_name']}/callback/after", |
|
| 449 | + array( |
|
| 450 | + &$field, |
|
| 451 | + &$value, |
|
| 452 | + ) |
|
| 453 | + ); |
|
| 454 | + |
|
| 455 | + return; |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + if ( isset( $field['type'] ) ) { |
|
| 459 | + // If the field is set not to display in the panel. |
|
| 460 | + $display = true; |
|
| 461 | + |
|
| 462 | + if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 463 | + if ( isset( $field['panel'] ) && false === $field['panel'] ) { |
|
| 464 | + $display = false; |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + if ( ! $display ) { |
|
| 469 | + return; |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + $field_type = str_replace( '_', '-', $field['type'] ); |
|
| 473 | + $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/class-redux-$field_type.php"; |
|
| 474 | + |
|
| 475 | + // Shim for v3 extension class names. |
|
| 476 | + if ( ! file_exists( $core_path ) ) { |
|
| 477 | + $core_path = Redux_Core::$dir . "inc/fields/{$field['type']}/field_{$field['type']}.php"; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + $filter_path = $core_path; |
|
| 481 | + |
|
| 482 | + $field_class = ''; |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * Filter 'redux/{opt_name}/field/class/{field.type}' |
|
| 486 | + * |
|
| 487 | + * @param string $path Field class file path. |
|
| 488 | + * @param array $field field data |
|
| 489 | + */ |
|
| 490 | + |
|
| 491 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 492 | + $class_file = apply_filters( "redux/{$core->args['opt_name']}/field/class/{$field['type']}", $filter_path, $field ); |
|
| 493 | + |
|
| 494 | + if ( $class_file ) { |
|
| 495 | + $field_classes = array( 'Redux_' . $field['type'], 'ReduxFramework_' . $field['type'] ); |
|
| 496 | + |
|
| 497 | + $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 498 | + |
|
| 499 | + if ( ! class_exists( $field_class ) ) { |
|
| 500 | + if ( file_exists( $class_file ) ) { |
|
| 501 | + require_once $class_file; |
|
| 502 | + $field_class = Redux_Functions::class_exists_ex( $field_classes ); |
|
| 503 | + } else { |
|
| 504 | + // translators: %1$s is the field ID, %2$s is the field type. |
|
| 505 | + printf( esc_html__( 'Field %1$s could not be displayed. Field type %2$s was not found.', 'redux-framework' ), '<code>' . esc_attr( $field['id'] ) . '</code>', '<code>' . esc_attr( $field['type'] ) . '</code>' ); |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + if ( class_exists( $field_class ) ) { |
|
| 511 | + $value = $core->options[ $field['id'] ] ?? ''; |
|
| 512 | + |
|
| 513 | + if ( null !== $v ) { |
|
| 514 | + $value = $v; |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + /** |
|
| 518 | + * Action 'redux/field/{opt_name}/{field.type}/render/before' |
|
| 519 | + * |
|
| 520 | + * @param array $field field data |
|
| 521 | + * @param string $value field id |
|
| 522 | + */ |
|
| 523 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 524 | + do_action_ref_array( |
|
| 525 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 526 | + "redux/field/{$core->args['opt_name']}/{$field['type']}/render/before", |
|
| 527 | + array( |
|
| 528 | + &$field, |
|
| 529 | + &$value, |
|
| 530 | + ) |
|
| 531 | + ); |
|
| 532 | + |
|
| 533 | + /** |
|
| 534 | + * Action 'redux/field/{$this->args['opt_name']}/render/before' |
|
| 535 | + * |
|
| 536 | + * @param array $field field data |
|
| 537 | + * @param string $value field id |
|
| 538 | + */ |
|
| 539 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 540 | + do_action_ref_array( |
|
| 541 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 542 | + "redux/field/{$core->args['opt_name']}/render/before", |
|
| 543 | + array( |
|
| 544 | + &$field, |
|
| 545 | + &$value, |
|
| 546 | + ) |
|
| 547 | + ); |
|
| 548 | + |
|
| 549 | + if ( ! isset( $field['name_suffix'] ) ) { |
|
| 550 | + $field['name_suffix'] = ''; |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + $render = new $field_class( $field, $value, $core ); |
|
| 554 | + |
|
| 555 | + ob_start(); |
|
| 556 | + |
|
| 557 | + try { |
|
| 558 | + $render->render(); |
|
| 559 | + } catch ( Error $e ) { |
|
| 560 | + echo 'Field failed to render: ', esc_html( $e->getMessage() ), "\n"; |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + /** |
|
| 564 | + * Filter 'redux/field/{opt_name}' |
|
| 565 | + * |
|
| 566 | + * @param string $content Rendered field markup. |
|
| 567 | + * @param array $field field data |
|
| 568 | + */ |
|
| 569 | + |
|
| 570 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 571 | + $_render = apply_filters( "redux/field/{$core->args['opt_name']}", ob_get_contents(), $field ); |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * Filter 'redux/field/{opt_name}/{field.type}/render/after' |
|
| 575 | + * |
|
| 576 | + * @param string $content Rendered field markup. |
|
| 577 | + * @param array $field Field data |
|
| 578 | + */ |
|
| 579 | + |
|
| 580 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 581 | + $_render = apply_filters( "redux/field/{$core->args['opt_name']}/{$field['type']}/render/after", $_render, $field ); |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * Filter 'redux/field/{opt_name}/render/after' |
|
| 585 | + * |
|
| 586 | + * @param string $content Rendered field markup. |
|
| 587 | + * @param array $field Field data |
|
| 588 | + */ |
|
| 589 | + |
|
| 590 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 591 | + $_render = apply_filters( "redux/field/{$core->args['opt_name']}/render/after", $_render, $field ); |
|
| 592 | + |
|
| 593 | + ob_end_clean(); |
|
| 594 | + |
|
| 595 | + // create default data und class string and checks the dependencies of an object. |
|
| 596 | + $class_string = ''; |
|
| 597 | + |
|
| 598 | + $core->required_class->check_dependencies( $field ); |
|
| 599 | + |
|
| 600 | + /** |
|
| 601 | + * Action 'redux/field/{opt_name}/{field.type}/fieldset/before/{opt_name}' |
|
| 602 | + * |
|
| 603 | + * @param array $field field data |
|
| 604 | + * @param string $value field id |
|
| 605 | + */ |
|
| 606 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 607 | + do_action_ref_array( |
|
| 608 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 609 | + "redux/field/{$core->args['opt_name']}/{$field['type']}/fieldset/before/{$core->args['opt_name']}", |
|
| 610 | + array( |
|
| 611 | + &$field, |
|
| 612 | + &$value, |
|
| 613 | + ) |
|
| 614 | + ); |
|
| 615 | + |
|
| 616 | + /** |
|
| 617 | + * Action 'redux/field/{opt_name}/fieldset/before/{opt_name}' |
|
| 618 | + * |
|
| 619 | + * @param array $field field data |
|
| 620 | + * @param string $value field id |
|
| 621 | + */ |
|
| 622 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 623 | + do_action_ref_array( |
|
| 624 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 625 | + "redux/field/{$core->args['opt_name']}/fieldset/before/{$core->args['opt_name']}", |
|
| 626 | + array( |
|
| 627 | + &$field, |
|
| 628 | + &$value, |
|
| 629 | + ) |
|
| 630 | + ); |
|
| 631 | + |
|
| 632 | + $hidden = ''; |
|
| 633 | + if ( isset( $field['hidden'] ) && $field['hidden'] ) { |
|
| 634 | + $hidden = 'hidden '; |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + $disabled = ''; |
|
| 638 | + if ( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
| 639 | + $disabled = 'disabled '; |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + if ( isset( $field['full_width'] ) && true === $field['full_width'] ) { |
|
| 643 | + $class_string .= 'redux_remove_th'; |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + if ( isset( $field['fieldset_class'] ) && ! empty( $field['fieldset_class'] ) ) { |
|
| 647 | + $class_string .= ' ' . $field['fieldset_class']; |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + echo '<fieldset id="' . esc_attr( $core->args['opt_name'] . '-' . $field['id'] ) . '" class="' . esc_attr( $hidden . esc_attr( $disabled ) . 'redux-field-container redux-field redux-field-init redux-container-' . $field['type'] . ' ' . $class_string ) . '" data-id="' . esc_attr( $field['id'] ) . '" data-type="' . esc_attr( $field['type'] ) . '">'; |
|
| 651 | + echo $_render; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 652 | + |
|
| 653 | + if ( ! empty( $field['desc'] ) ) { |
|
| 654 | + $field['description'] = $field['desc']; |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + echo ( isset( $field['description'] ) && 'info' !== $field['type'] && 'section' !== $field['type'] && ! empty( $field['description'] ) ) ? '<div class="description field-desc">' . wp_kses_post( $field['description'] ) . '</div>' : ''; |
|
| 658 | + echo '</fieldset>'; |
|
| 659 | + |
|
| 660 | + /** |
|
| 661 | + * Action 'redux/field/{opt_name}/{field.type}/fieldset/after/{opt_name}' |
|
| 662 | + * |
|
| 663 | + * @param array $field field data |
|
| 664 | + * @param string $value field id |
|
| 665 | + */ |
|
| 666 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 667 | + do_action_ref_array( |
|
| 668 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 669 | + "redux/field/{$core->args['opt_name']}/{$field['type']}/fieldset/after/{$core->args['opt_name']}", |
|
| 670 | + array( |
|
| 671 | + &$field, |
|
| 672 | + &$value, |
|
| 673 | + ) |
|
| 674 | + ); |
|
| 675 | + |
|
| 676 | + /** |
|
| 677 | + * Action 'redux/field/{opt_name}/fieldset/after/{opt_name}' |
|
| 678 | + * |
|
| 679 | + * @param array $field field data |
|
| 680 | + * @param string $value field id |
|
| 681 | + */ |
|
| 682 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 683 | + do_action_ref_array( |
|
| 684 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 685 | + "redux/field/{$core->args['opt_name']}/fieldset/after/{$core->args['opt_name']}", |
|
| 686 | + array( |
|
| 687 | + &$field, |
|
| 688 | + &$value, |
|
| 689 | + ) |
|
| 690 | + ); |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + } |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * Add admin bar menu. |
|
| 697 | + * |
|
| 698 | + * @since 3.1.5.16 |
|
| 699 | + * @access public |
|
| 700 | + * @global $menu , $submenu, $wp_admin_bar |
|
| 701 | + * @return void |
|
| 702 | + */ |
|
| 703 | + public function add_menu() { |
|
| 704 | + global $menu, $submenu, $wp_admin_bar; |
|
| 705 | + |
|
| 706 | + $core = $this->core(); |
|
| 707 | + |
|
| 708 | + if ( ! is_super_admin() || ! is_admin_bar_showing() || ! $core->args['admin_bar'] || 'hidden' === $core->args['menu_type'] ) { |
|
| 709 | + return; |
|
| 710 | + } |
|
| 711 | + |
|
| 712 | + if ( $menu ) { |
|
| 713 | + foreach ( $menu as $menu_item ) { |
|
| 714 | + if ( isset( $menu_item[2] ) && $menu_item[2] === $core->args['page_slug'] ) { |
|
| 715 | + |
|
| 716 | + // Fetch the title. |
|
| 717 | + $title = empty( $core->args['admin_bar_icon'] ) ? $menu_item[0] : '<span class="ab-icon ' . esc_attr( $core->args['admin_bar_icon'] ) . '"></span>' . esc_html( $menu_item[0] ); |
|
| 718 | + |
|
| 719 | + $nodeargs = array( |
|
| 720 | + 'id' => $menu_item[2], |
|
| 721 | + 'title' => $title, |
|
| 722 | + 'href' => admin_url( 'admin.php?page=' . $menu_item[2] ), |
|
| 723 | + 'meta' => array(), |
|
| 724 | + ); |
|
| 725 | + |
|
| 726 | + $wp_admin_bar->add_node( $nodeargs ); |
|
| 727 | + |
|
| 728 | + break; |
|
| 729 | + } |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + if ( isset( $submenu[ $core->args['page_slug'] ] ) && is_array( $submenu[ $core->args['page_slug'] ] ) ) { |
|
| 733 | + foreach ( $submenu[ $core->args['page_slug'] ] as $index => $redux_options_submenu ) { |
|
| 734 | + $subnodeargs = array( |
|
| 735 | + 'id' => esc_html( $core->args['page_slug'] . '_' . $index ), |
|
| 736 | + 'title' => esc_html( $redux_options_submenu[0] ), |
|
| 737 | + 'parent' => esc_html( $core->args['page_slug'] ), |
|
| 738 | + 'href' => esc_url( admin_url( 'admin.php?page=' . $redux_options_submenu[2] ) ), |
|
| 739 | + ); |
|
| 740 | + |
|
| 741 | + $wp_admin_bar->add_node( $subnodeargs ); |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + // Let's deal with external links. |
|
| 746 | + if ( isset( $core->args['admin_bar_links'] ) ) { |
|
| 747 | + if ( ! $core->args['dev_mode'] && $core->args_class->omit_items ) { |
|
| 748 | + return; |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + // Group for Main Root Menu (External Group). |
|
| 752 | + $wp_admin_bar->add_node( |
|
| 753 | + array( |
|
| 754 | + 'id' => esc_html( $core->args['page_slug'] . '-external' ), |
|
| 755 | + 'parent' => esc_html( $core->args['page_slug'] ), |
|
| 756 | + 'group' => true, |
|
| 757 | + 'meta' => array( 'class' => 'ab-sub-secondary' ), |
|
| 758 | + ) |
|
| 759 | + ); |
|
| 760 | + |
|
| 761 | + // Add Child Menus to External Group Menu. |
|
| 762 | + foreach ( $core->args['admin_bar_links'] as $link ) { |
|
| 763 | + if ( ! isset( $link['id'] ) ) { |
|
| 764 | + $link['id'] = $core->args['page_slug'] . '-sub-' . sanitize_html_class( $link['title'] ); |
|
| 765 | + } |
|
| 766 | + |
|
| 767 | + $externalnodeargs = array( |
|
| 768 | + 'id' => esc_html( $link['id'] ), |
|
| 769 | + 'title' => esc_html( $link['title'] ), |
|
| 770 | + 'parent' => esc_html( $core->args['page_slug'] . '-external' ), |
|
| 771 | + 'href' => esc_url( $link['href'] ), |
|
| 772 | + 'meta' => array( 'target' => '_blank' ), |
|
| 773 | + ); |
|
| 774 | + |
|
| 775 | + $wp_admin_bar->add_node( $externalnodeargs ); |
|
| 776 | + } |
|
| 777 | + } |
|
| 778 | + } else { |
|
| 779 | + // Fetch the title. |
|
| 780 | + $title = empty( $core->args['admin_bar_icon'] ) ? $core->args['menu_title'] : '<span class="ab-icon ' . esc_attr( $core->args['admin_bar_icon'] ) . '"></span>' . esc_html( $core->args['menu_title'] ); |
|
| 781 | + |
|
| 782 | + $nodeargs = array( |
|
| 783 | + 'id' => esc_html( $core->args['page_slug'] ), |
|
| 784 | + 'title' => $title, |
|
| 785 | + 'href' => esc_url( admin_url( 'admin.php?page=' . $core->args['page_slug'] ) ), |
|
| 786 | + 'meta' => array(), |
|
| 787 | + ); |
|
| 788 | + |
|
| 789 | + $wp_admin_bar->add_node( $nodeargs ); |
|
| 790 | + } |
|
| 791 | + } |
|
| 792 | + |
|
| 793 | + /** |
|
| 794 | + * Do action redux-admin-head for option page |
|
| 795 | + * |
|
| 796 | + * @since 1.0.0 |
|
| 797 | + * @access public |
|
| 798 | + * @return void |
|
| 799 | + */ |
|
| 800 | + public function admin_head() { |
|
| 801 | + $core = $this->core(); |
|
| 802 | + |
|
| 803 | + /** |
|
| 804 | + * Action 'redux/page/{opt_name}/header' |
|
| 805 | + * |
|
| 806 | + * @param object $this ReduxFramework |
|
| 807 | + */ |
|
| 808 | + |
|
| 809 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 810 | + do_action( "redux/page/{$core->args['opt_name']}/header", $core ); |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + /** |
|
| 814 | + * Return footer text |
|
| 815 | + * |
|
| 816 | + * @since 2.0.0 |
|
| 817 | + * @access public |
|
| 818 | + * @return string $this->args['footer_credit'] |
|
| 819 | + */ |
|
| 820 | + public function admin_footer_text(): string { |
|
| 821 | + $core = $this->core(); |
|
| 822 | + |
|
| 823 | + return $core->args['footer_credit']; |
|
| 824 | + } |
|
| 825 | + |
|
| 826 | + /** |
|
| 827 | + * Generate field header HTML |
|
| 828 | + * |
|
| 829 | + * @param array $field Field array. |
|
| 830 | + * |
|
| 831 | + * @return string |
|
| 832 | + */ |
|
| 833 | + public function get_header_html( array $field ): string { |
|
| 834 | + global $current_user; |
|
| 835 | + |
|
| 836 | + $core = $this->core(); |
|
| 837 | + |
|
| 838 | + // Set to empty string to avoid warnings. |
|
| 839 | + $hint = ''; |
|
| 840 | + $th = ''; |
|
| 841 | + |
|
| 842 | + if ( isset( $field['title'] ) && isset( $field['type'] ) && 'info' !== $field['type'] && 'section' !== $field['type'] ) { |
|
| 843 | + $default_mark = ( ! empty( $field['default'] ) && isset( $core->options[ $field['id'] ] ) && $field['default'] === $core->options[ $field['id'] ] && ! empty( $core->args['default_mark'] ) ) ? $core->args['default_mark'] : ''; |
|
| 844 | + |
|
| 845 | + // If a hint is specified in the field, process it. |
|
| 846 | + if ( isset( $field['hint'] ) && ! empty( $field['hint'] ) ) { |
|
| 847 | + |
|
| 848 | + // Set the show_hints flag to true, so the help tab will be displayed. |
|
| 849 | + $this->show_hints = true; |
|
| 850 | + |
|
| 851 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 852 | + $hint = apply_filters( 'redux/hints/html', $hint, $field, $core->args ); |
|
| 853 | + |
|
| 854 | + // Get user pref for displaying hints. |
|
| 855 | + $meta_val = get_user_meta( $current_user->ID, 'ignore_hints', true ); |
|
| 856 | + |
|
| 857 | + if ( 'true' === $meta_val || empty( $meta_val ) && empty( $hint ) ) { |
|
| 858 | + |
|
| 859 | + // Set hand cursor for clickable hints. |
|
| 860 | + $pointer = ''; |
|
| 861 | + if ( isset( $core->args['hints']['tip_effect']['show']['event'] ) && 'click' === $core->args['hints']['tip_effect']['show']['event'] ) { |
|
| 862 | + $pointer = 'pointer'; |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + $size = '16px'; |
|
| 866 | + if ( 'large' === $core->args['hints']['icon_size'] ) { |
|
| 867 | + $size = '18px'; |
|
| 868 | + } |
|
| 869 | + |
|
| 870 | + // In case docs are ignored. |
|
| 871 | + $title_param = $field['hint']['title'] ?? ''; |
|
| 872 | + $content_param = $field['hint']['content'] ?? ''; |
|
| 873 | + |
|
| 874 | + $hint_color = $core->args['hints']['icon_color'] ?? '#d3d3d3'; |
|
| 875 | + |
|
| 876 | + // Set hint html with appropriate position css. |
|
| 877 | + $hint = '<div class="redux-hint-qtip" style="float:' . esc_attr( $core->args['hints']['icon_position'] ) . '; font-size: ' . esc_attr( $size ) . '; color:' . esc_attr( $hint_color ) . '; cursor: ' . $pointer . ';" qtip-title="' . esc_attr( $title_param ) . '" qtip-content="' . wp_kses_post( $content_param ) . '"> <i class="' . ( isset( $core->args['hints']['icon'] ) ? esc_attr( $core->args['hints']['icon'] ) : '' ) . '"></i></div>'; |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + if ( ! empty( $field['title'] ) ) { |
|
| 882 | + if ( 'left' === $core->args['hints']['icon_position'] ) { |
|
| 883 | + $th = $hint . wp_kses_post( $field['title'] ) . $default_mark . ' '; |
|
| 884 | + } else { |
|
| 885 | + $th = wp_kses_post( $field['title'] ) . $default_mark . ' ' . $hint; |
|
| 886 | + } |
|
| 887 | + } |
|
| 888 | + |
|
| 889 | + if ( isset( $field['subtitle'] ) ) { |
|
| 890 | + $th .= '<span class="description">' . wp_kses_post( $field['subtitle'] ) . '</span>'; |
|
| 891 | + } |
|
| 892 | + } |
|
| 893 | + |
|
| 894 | + if ( ! empty( $th ) ) { |
|
| 895 | + $th = '<div class="redux_field_th">' . $th . '</div>'; |
|
| 896 | + } |
|
| 897 | + |
|
| 898 | + $filter_arr = array( |
|
| 899 | + 'editor', |
|
| 900 | + 'ace_editor', |
|
| 901 | + 'info', |
|
| 902 | + 'section', |
|
| 903 | + 'repeater', |
|
| 904 | + 'tabbed', |
|
| 905 | + 'color_scheme', |
|
| 906 | + 'social_profiles', |
|
| 907 | + 'css_layout', |
|
| 908 | + ); |
|
| 909 | + |
|
| 910 | + if ( true === $core->args['default_show'] && isset( $field['default'] ) && isset( $core->options[ $field['id'] ] ) && $field['default'] !== $core->options[ $field['id'] ] && ! in_array( $field['type'], $filter_arr, true ) ) { |
|
| 911 | + $th .= $this->get_default_output_string( $field ); |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + return $th; |
|
| 915 | + } |
|
| 916 | + |
|
| 917 | + /** |
|
| 918 | + * Return default output string for use in a panel |
|
| 919 | + * |
|
| 920 | + * @param array $field Field array. |
|
| 921 | + * |
|
| 922 | + * @return string default_output |
|
| 923 | + * @since 3.1.5 |
|
| 924 | + * @access public |
|
| 925 | + */ |
|
| 926 | + private function get_default_output_string( array $field ): string { |
|
| 927 | + $default_output = ''; |
|
| 928 | + |
|
| 929 | + if ( ! isset( $field['default'] ) ) { |
|
| 930 | + $field['default'] = ''; |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + if ( ! is_array( $field['default'] ) ) { |
|
| 934 | + if ( ! empty( $field['options'][ $field['default'] ] ) ) { |
|
| 935 | + if ( ! empty( $field['options'][ $field['default'] ]['alt'] ) ) { |
|
| 936 | + $default_output .= $field['options'][ $field['default'] ]['alt'] . ', '; |
|
| 937 | + } elseif ( ! is_array( $field['options'][ $field['default'] ] ) ) { |
|
| 938 | + $default_output .= $field['options'][ $field['default'] ] . ', '; |
|
| 939 | + } else { |
|
| 940 | + $default_output .= maybe_serialize( $field['options'][ $field['default'] ] ) . ', '; |
|
| 941 | + } |
|
| 942 | + } elseif ( ! empty( $field['options'][ $field['default'] ] ) ) { |
|
| 943 | + $default_output .= $field['options'][ $field['default'] ] . ', '; |
|
| 944 | + } elseif ( ! empty( $field['default'] ) ) { |
|
| 945 | + if ( 'switch' === $field['type'] && isset( $field['on'] ) && isset( $field['off'] ) ) { |
|
| 946 | + $default_output .= ( 1 === $field['default'] ? $field['on'] : $field['off'] ) . ', '; |
|
| 947 | + } else { |
|
| 948 | + $default_output .= $field['default'] . ', '; |
|
| 949 | + } |
|
| 950 | + } |
|
| 951 | + } else { |
|
| 952 | + foreach ( $field['default'] as $defaultk => $defaultv ) { |
|
| 953 | + $defaultk = is_numeric( $defaultk ) ? (string) $defaultk : $defaultk; |
|
| 954 | + $defaultv = is_numeric( $defaultv ) ? (string) $defaultv : $defaultv; |
|
| 955 | + |
|
| 956 | + if ( ! empty( $field['options'][ $defaultv ]['alt'] ) ) { |
|
| 957 | + $default_output .= $field['options'][ $defaultv ]['alt'] . ', '; |
|
| 958 | + } elseif ( ! empty( $field['options'][ $defaultv ] ) ) { |
|
| 959 | + $default_output .= $field['options'][ $defaultv ] . ', '; |
|
| 960 | + } elseif ( ! empty( $field['options'][ $defaultk ] ) ) { |
|
| 961 | + $default_output .= $field['options'][ $defaultk ] . ', '; |
|
| 962 | + } elseif ( ! empty( $defaultv ) ) { |
|
| 963 | + if ( is_array( $defaultv ) ) { |
|
| 964 | + foreach ( $defaultv as $k => $v ) { |
|
| 965 | + if( is_array( $v ) ) { |
|
| 966 | + $defaultv = implode( ', ', $v ); |
|
| 967 | + } |
|
| 968 | + } |
|
| 969 | + |
|
| 970 | + if ( is_array( $defaultv ) ) { |
|
| 971 | + $defaultv = implode( ', ', $defaultv ); |
|
| 972 | + } |
|
| 973 | + } |
|
| 974 | + |
|
| 975 | + $default_output .= $defaultv . ', '; |
|
| 976 | + } |
|
| 977 | + } |
|
| 978 | + } |
|
| 979 | + |
|
| 980 | + if ( ! empty( $default_output ) ) { |
|
| 981 | + $default_output = esc_html__( 'Default', 'redux-framework' ) . ': ' . substr( $default_output, 0, - 2 ); |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + if ( ! empty( $default_output ) ) { |
|
| 985 | + $default_output = '<span class="showDefaults">' . esc_html( $default_output ) . '</span><br class="default_br" />'; |
|
| 986 | + } |
|
| 987 | + |
|
| 988 | + return $default_output; |
|
| 989 | + } |
|
| 990 | + |
|
| 991 | + /** |
|
| 992 | + * Return Section Menu HTML. |
|
| 993 | + * |
|
| 994 | + * @param int|string $k Section index. |
|
| 995 | + * @param array $section Section array. |
|
| 996 | + * @param string $suffix Optional suffix. |
|
| 997 | + * @param array $sections Sections array. |
|
| 998 | + * |
|
| 999 | + * @return string |
|
| 1000 | + * @since 3.1.5 |
|
| 1001 | + * @access public |
|
| 1002 | + */ |
|
| 1003 | + public function section_menu( $k, array $section, string $suffix = '', array $sections = array() ): string { |
|
| 1004 | + $function_count = 0; |
|
| 1005 | + |
|
| 1006 | + $core = $this->core(); |
|
| 1007 | + |
|
| 1008 | + $display = true; |
|
| 1009 | + |
|
| 1010 | + $section['class'] = isset( $section['class'] ) ? ' ' . $section['class'] : ''; |
|
| 1011 | + |
|
| 1012 | + if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 1013 | + if ( isset( $section['panel'] ) && false === $section['panel'] ) { |
|
| 1014 | + $display = false; |
|
| 1015 | + } |
|
| 1016 | + } |
|
| 1017 | + |
|
| 1018 | + if ( ! $display ) { |
|
| 1019 | + return ''; |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + if ( empty( $sections ) ) { |
|
| 1023 | + $sections = $core->sections; |
|
| 1024 | + $function_count = $k; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + $string = ''; |
|
| 1028 | + if ( ( ( isset( $core->args['icon_type'] ) && 'image' === $core->args['icon_type'] ) || ( isset( $section['icon_type'] ) && 'image' === $section['icon_type'] ) ) || ( isset( $section['icon'] ) && false !== strpos( $section['icon'], '/' ) ) ) { |
|
| 1029 | + // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- No image/icon to enqueue. |
|
| 1030 | + $icon = ( ! isset( $section['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $section['icon'] ) . '" /> '; |
|
| 1031 | + } else { |
|
| 1032 | + if ( ! empty( $section['icon_class'] ) ) { |
|
| 1033 | + $icon_class = ' ' . $section['icon_class']; |
|
| 1034 | + } elseif ( ! empty( $core->args['default_icon_class'] ) ) { |
|
| 1035 | + $icon_class = ' ' . $core->args['default_icon_class']; |
|
| 1036 | + } else { |
|
| 1037 | + $icon_class = ''; |
|
| 1038 | + } |
|
| 1039 | + $icon = ( ! isset( $section['icon'] ) ) ? '<i class="el el-cog' . esc_attr( $icon_class ) . '"></i> ' : '<i class="' . esc_attr( $section['icon'] ) . esc_attr( $icon_class ) . '"></i> '; |
|
| 1040 | + } |
|
| 1041 | + if ( strpos( $icon, 'el-icon-' ) !== false ) { |
|
| 1042 | + $icon = str_replace( 'el-icon-', 'el el-', $icon ); |
|
| 1043 | + } |
|
| 1044 | + |
|
| 1045 | + $hide_section = ''; |
|
| 1046 | + if ( isset( $section['hidden'] ) ) { |
|
| 1047 | + $hide_section = ( true === $section['hidden'] ) ? ' hidden ' : ''; |
|
| 1048 | + } |
|
| 1049 | + |
|
| 1050 | + $can_be_subsection = $k > 0 && ( ! isset( $sections[ ( $k ) ]['type'] ) || 'divide' !== $sections[ ( $k ) ]['type'] ); |
|
| 1051 | + |
|
| 1052 | + if ( ! $can_be_subsection && isset( $section['subsection'] ) && true === $section['subsection'] ) { |
|
| 1053 | + unset( $section['subsection'] ); |
|
| 1054 | + } |
|
| 1055 | + |
|
| 1056 | + if ( isset( $section['type'] ) && 'divide' === $section['type'] ) { |
|
| 1057 | + $string .= '<li class="divide' . esc_attr( $section['class'] ) . '"> </li>'; |
|
| 1058 | + } elseif ( ! isset( $section['subsection'] ) || true !== $section['subsection'] ) { |
|
| 1059 | + $subsections = isset( $sections[ ( $k + 1 ) ]['subsection'] ) && true === $sections[ ( $k + 1 ) ]['subsection']; |
|
| 1060 | + $subsections_class = $subsections ? ' hasSubSections' : ''; |
|
| 1061 | + $subsections_class .= ( empty( $section['fields'] ) ) ? ' empty_section' : ''; |
|
| 1062 | + $rotate = true === $core->args['flyout_submenus'] ? ' el-rotate' : ''; |
|
| 1063 | + $extra_icon = $subsections ? '<span class="extraIconSubsections"><i class="el el-chevron-down' . $rotate . '"> </i></span>' : ''; |
|
| 1064 | + $string .= '<li id="' . esc_attr( $k . $suffix ) . '_section_group_li" class="redux-group-tab-link-li' . esc_attr( $hide_section ) . esc_attr( $section['class'] ) . esc_attr( $subsections_class ) . '">'; |
|
| 1065 | + $string .= '<a href="javascript:void(0);" id="' . esc_attr( $k . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $k ) . '" data-rel="' . esc_attr( $k . $suffix ) . '">' . $extra_icon . $icon . '<span class="group_title">' . wp_kses_post( $section['title'] ) . '</span></a>'; |
|
| 1066 | + |
|
| 1067 | + $next_k = $k; |
|
| 1068 | + |
|
| 1069 | + // Make sure you can make this a subsection. |
|
| 1070 | + if ( $subsections ) { |
|
| 1071 | + $string .= '<ul id="' . esc_attr( $next_k . $suffix ) . '_section_group_li_subsections" class="subsection">'; |
|
| 1072 | + |
|
| 1073 | + $do_loop = true; |
|
| 1074 | + |
|
| 1075 | + while ( $do_loop ) { |
|
| 1076 | + ++$next_k; |
|
| 1077 | + ++$function_count; |
|
| 1078 | + |
|
| 1079 | + $display = true; |
|
| 1080 | + |
|
| 1081 | + if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 1082 | + if ( isset( $sections[ $next_k ]['panel'] ) && false === $sections[ $next_k ]['panel'] ) { |
|
| 1083 | + $display = false; |
|
| 1084 | + } |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + if ( count( $sections ) < $function_count || ! isset( $sections[ $next_k ] ) || ! isset( $sections[ $next_k ]['subsection'] ) || true !== $sections[ $next_k ]['subsection'] ) { |
|
| 1088 | + $do_loop = false; |
|
| 1089 | + } else { |
|
| 1090 | + if ( ! $display ) { |
|
| 1091 | + continue; |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + $hide_sub = ''; |
|
| 1095 | + if ( isset( $sections[ $next_k ]['hidden'] ) ) { |
|
| 1096 | + $hide_sub = ( true === $sections[ $next_k ]['hidden'] ) ? ' hidden ' : ''; |
|
| 1097 | + } |
|
| 1098 | + |
|
| 1099 | + if ( ( isset( $core->args['icon_type'] ) && 'image' === $core->args['icon_type'] ) || ( isset( $sections[ $next_k ]['icon_type'] ) && 'image' === $sections[ $next_k ]['icon_type'] ) ) { |
|
| 1100 | + // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- No image/icon to enqueue. |
|
| 1101 | + $icon = ( ! isset( $sections[ $next_k ]['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $sections[ $next_k ]['icon'] ) . '" /> '; |
|
| 1102 | + } else { |
|
| 1103 | + if ( ! empty( $sections[ $next_k ]['icon_class'] ) ) { |
|
| 1104 | + $icon_class = ' ' . $sections[ $next_k ]['icon_class']; |
|
| 1105 | + } elseif ( ! empty( $core->args['default_icon_class'] ) ) { |
|
| 1106 | + $icon_class = ' ' . $core->args['default_icon_class']; |
|
| 1107 | + } else { |
|
| 1108 | + $icon_class = ''; |
|
| 1109 | + } |
|
| 1110 | + $icon = ( ! isset( $sections[ $next_k ]['icon'] ) ) ? '' : '<i class="' . esc_attr( $sections[ $next_k ]['icon'] ) . esc_attr( $icon_class ) . '"></i> '; |
|
| 1111 | + } |
|
| 1112 | + if ( strpos( $icon, 'el-icon-' ) !== false ) { |
|
| 1113 | + $icon = str_replace( 'el-icon-', 'el el-', $icon ); |
|
| 1114 | + } |
|
| 1115 | + |
|
| 1116 | + $sections[ $next_k ]['class'] = $sections[ $next_k ]['class'] ?? ''; |
|
| 1117 | + $section[ $next_k ]['class'] = $section[ $next_k ]['class'] ?? $sections[ $next_k ]['class']; |
|
| 1118 | + $string .= '<li id="' . esc_attr( $next_k . $suffix ) . '_section_group_li" class="redux-group-tab-link-li ' . esc_attr( $hide_sub ) . esc_attr( $section[ $next_k ]['class'] ) . ( $icon ? ' hasIcon' : '' ) . '">'; |
|
| 1119 | + $string .= '<a href="javascript:void(0);" id="' . esc_attr( $next_k . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $next_k ) . '" data-rel="' . esc_attr( $next_k . $suffix ) . '">' . $icon . '<span class="group_title">' . wp_kses_post( $sections[ $next_k ]['title'] ) . '</span></a>'; |
|
| 1120 | + $string .= '</li>'; |
|
| 1121 | + } |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + $string .= '</ul>'; |
|
| 1125 | + } |
|
| 1126 | + |
|
| 1127 | + $string .= '</li>'; |
|
| 1128 | + } |
|
| 1129 | + |
|
| 1130 | + return $string; |
|
| 1131 | + } |
|
| 1132 | + } |
|
| 1133 | 1133 | } |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | 'generate_panel', |
| 82 | 82 | ), |
| 83 | 83 | $core->args['menu_icon'], |
| 84 | - (int) $core->args['page_priority'] |
|
| 84 | + ( int ) $core->args['page_priority'] |
|
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | if ( true === $core->args['allow_sub_menu'] ) { |
| 88 | 88 | foreach ( $core->sections as $k => $section ) { |
| 89 | - $can_be_subsection = $k > 0 && ( ! isset( $core->sections[ ( $k ) ]['type'] ) || 'divide' !== $core->sections[ ( $k ) ]['type'] ); |
|
| 89 | + $can_be_subsection = $k > 0 && ( ! isset( $core->sections[( $k )]['type'] ) || 'divide' !== $core->sections[( $k )]['type'] ); |
|
| 90 | 90 | |
| 91 | 91 | if ( ! isset( $section['title'] ) || ( $can_be_subsection && ( isset( $section['subsection'] ) && true === $section['subsection'] ) ) ) { |
| 92 | 92 | continue; |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | 'options-general.php' => 'options', |
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | - if ( isset( $test[ $page_parent ] ) ) { |
|
| 265 | - $function = 'add_' . $test[ $page_parent ] . '_page'; |
|
| 264 | + if ( isset( $test[$page_parent] ) ) { |
|
| 265 | + $function = 'add_' . $test[$page_parent] . '_page'; |
|
| 266 | 266 | $this->page = $function( |
| 267 | 267 | $page_title, |
| 268 | 268 | $menu_title, |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | $add_menu = true; |
| 298 | 298 | } |
| 299 | 299 | // custom menu. |
| 300 | - } elseif ( isset( $submenu[ $core->args['page_parent'] ] ) ) { |
|
| 300 | + } elseif ( isset( $submenu[$core->args['page_parent']] ) ) { |
|
| 301 | 301 | $add_menu = true; |
| 302 | 302 | } else { |
| 303 | 303 | global $menu; |
@@ -364,8 +364,8 @@ discard block |
||
| 364 | 364 | $id = rtrim( $section['id'], '_section' ); |
| 365 | 365 | $id = str_replace( $core->args['opt_name'], '', $id ); |
| 366 | 366 | |
| 367 | - if ( isset( $core->sections[ $id ]['desc'] ) && ! empty( $core->sections[ $id ]['desc'] ) ) { |
|
| 368 | - echo '<div class="redux-section-desc">' . wp_kses_post( $core->sections[ $id ]['desc'] ) . '</div>'; |
|
| 367 | + if ( isset( $core->sections[$id]['desc'] ) && ! empty( $core->sections[$id]['desc'] ) ) { |
|
| 368 | + echo '<div class="redux-section-desc">' . wp_kses_post( $core->sections[$id]['desc'] ) . '</div>'; |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | if ( isset( $field['callback'] ) && ( is_callable( $field['callback'] ) || ( is_string( $field['callback'] ) && function_exists( $field['callback'] ) ) ) ) { |
| 386 | 386 | |
| 387 | - $value = ( isset( $core->options[ $field['id'] ] ) ) ? $core->options[ $field['id'] ] : ''; |
|
| 387 | + $value = ( isset( $core->options[$field['id']] ) ) ? $core->options[$field['id']] : ''; |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * Action 'redux/field/{opt_name}/{field.type}/callback/before' |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | if ( class_exists( $field_class ) ) { |
| 511 | - $value = $core->options[ $field['id'] ] ?? ''; |
|
| 511 | + $value = $core->options[$field['id']] ?? ''; |
|
| 512 | 512 | |
| 513 | 513 | if ( null !== $v ) { |
| 514 | 514 | $value = $v; |
@@ -729,8 +729,8 @@ discard block |
||
| 729 | 729 | } |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - if ( isset( $submenu[ $core->args['page_slug'] ] ) && is_array( $submenu[ $core->args['page_slug'] ] ) ) { |
|
| 733 | - foreach ( $submenu[ $core->args['page_slug'] ] as $index => $redux_options_submenu ) { |
|
| 732 | + if ( isset( $submenu[$core->args['page_slug']] ) && is_array( $submenu[$core->args['page_slug']] ) ) { |
|
| 733 | + foreach ( $submenu[$core->args['page_slug']] as $index => $redux_options_submenu ) { |
|
| 734 | 734 | $subnodeargs = array( |
| 735 | 735 | 'id' => esc_html( $core->args['page_slug'] . '_' . $index ), |
| 736 | 736 | 'title' => esc_html( $redux_options_submenu[0] ), |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | $th = ''; |
| 841 | 841 | |
| 842 | 842 | if ( isset( $field['title'] ) && isset( $field['type'] ) && 'info' !== $field['type'] && 'section' !== $field['type'] ) { |
| 843 | - $default_mark = ( ! empty( $field['default'] ) && isset( $core->options[ $field['id'] ] ) && $field['default'] === $core->options[ $field['id'] ] && ! empty( $core->args['default_mark'] ) ) ? $core->args['default_mark'] : ''; |
|
| 843 | + $default_mark = ( ! empty( $field['default'] ) && isset( $core->options[$field['id']] ) && $field['default'] === $core->options[$field['id']] && ! empty( $core->args['default_mark'] ) ) ? $core->args['default_mark'] : ''; |
|
| 844 | 844 | |
| 845 | 845 | // If a hint is specified in the field, process it. |
| 846 | 846 | if ( isset( $field['hint'] ) && ! empty( $field['hint'] ) ) { |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | 'css_layout', |
| 908 | 908 | ); |
| 909 | 909 | |
| 910 | - if ( true === $core->args['default_show'] && isset( $field['default'] ) && isset( $core->options[ $field['id'] ] ) && $field['default'] !== $core->options[ $field['id'] ] && ! in_array( $field['type'], $filter_arr, true ) ) { |
|
| 910 | + if ( true === $core->args['default_show'] && isset( $field['default'] ) && isset( $core->options[$field['id']] ) && $field['default'] !== $core->options[$field['id']] && ! in_array( $field['type'], $filter_arr, true ) ) { |
|
| 911 | 911 | $th .= $this->get_default_output_string( $field ); |
| 912 | 912 | } |
| 913 | 913 | |
@@ -931,16 +931,16 @@ discard block |
||
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | if ( ! is_array( $field['default'] ) ) { |
| 934 | - if ( ! empty( $field['options'][ $field['default'] ] ) ) { |
|
| 935 | - if ( ! empty( $field['options'][ $field['default'] ]['alt'] ) ) { |
|
| 936 | - $default_output .= $field['options'][ $field['default'] ]['alt'] . ', '; |
|
| 937 | - } elseif ( ! is_array( $field['options'][ $field['default'] ] ) ) { |
|
| 938 | - $default_output .= $field['options'][ $field['default'] ] . ', '; |
|
| 934 | + if ( ! empty( $field['options'][$field['default']] ) ) { |
|
| 935 | + if ( ! empty( $field['options'][$field['default']]['alt'] ) ) { |
|
| 936 | + $default_output .= $field['options'][$field['default']]['alt'] . ', '; |
|
| 937 | + } elseif ( ! is_array( $field['options'][$field['default']] ) ) { |
|
| 938 | + $default_output .= $field['options'][$field['default']] . ', '; |
|
| 939 | 939 | } else { |
| 940 | - $default_output .= maybe_serialize( $field['options'][ $field['default'] ] ) . ', '; |
|
| 940 | + $default_output .= maybe_serialize( $field['options'][$field['default']] ) . ', '; |
|
| 941 | 941 | } |
| 942 | - } elseif ( ! empty( $field['options'][ $field['default'] ] ) ) { |
|
| 943 | - $default_output .= $field['options'][ $field['default'] ] . ', '; |
|
| 942 | + } elseif ( ! empty( $field['options'][$field['default']] ) ) { |
|
| 943 | + $default_output .= $field['options'][$field['default']] . ', '; |
|
| 944 | 944 | } elseif ( ! empty( $field['default'] ) ) { |
| 945 | 945 | if ( 'switch' === $field['type'] && isset( $field['on'] ) && isset( $field['off'] ) ) { |
| 946 | 946 | $default_output .= ( 1 === $field['default'] ? $field['on'] : $field['off'] ) . ', '; |
@@ -950,19 +950,19 @@ discard block |
||
| 950 | 950 | } |
| 951 | 951 | } else { |
| 952 | 952 | foreach ( $field['default'] as $defaultk => $defaultv ) { |
| 953 | - $defaultk = is_numeric( $defaultk ) ? (string) $defaultk : $defaultk; |
|
| 954 | - $defaultv = is_numeric( $defaultv ) ? (string) $defaultv : $defaultv; |
|
| 955 | - |
|
| 956 | - if ( ! empty( $field['options'][ $defaultv ]['alt'] ) ) { |
|
| 957 | - $default_output .= $field['options'][ $defaultv ]['alt'] . ', '; |
|
| 958 | - } elseif ( ! empty( $field['options'][ $defaultv ] ) ) { |
|
| 959 | - $default_output .= $field['options'][ $defaultv ] . ', '; |
|
| 960 | - } elseif ( ! empty( $field['options'][ $defaultk ] ) ) { |
|
| 961 | - $default_output .= $field['options'][ $defaultk ] . ', '; |
|
| 953 | + $defaultk = is_numeric( $defaultk ) ? ( string ) $defaultk : $defaultk; |
|
| 954 | + $defaultv = is_numeric( $defaultv ) ? ( string ) $defaultv : $defaultv; |
|
| 955 | + |
|
| 956 | + if ( ! empty( $field['options'][$defaultv]['alt'] ) ) { |
|
| 957 | + $default_output .= $field['options'][$defaultv]['alt'] . ', '; |
|
| 958 | + } elseif ( ! empty( $field['options'][$defaultv] ) ) { |
|
| 959 | + $default_output .= $field['options'][$defaultv] . ', '; |
|
| 960 | + } elseif ( ! empty( $field['options'][$defaultk] ) ) { |
|
| 961 | + $default_output .= $field['options'][$defaultk] . ', '; |
|
| 962 | 962 | } elseif ( ! empty( $defaultv ) ) { |
| 963 | 963 | if ( is_array( $defaultv ) ) { |
| 964 | 964 | foreach ( $defaultv as $k => $v ) { |
| 965 | - if( is_array( $v ) ) { |
|
| 965 | + if ( is_array( $v ) ) { |
|
| 966 | 966 | $defaultv = implode( ', ', $v ); |
| 967 | 967 | } |
| 968 | 968 | } |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | $hide_section = ( true === $section['hidden'] ) ? ' hidden ' : ''; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - $can_be_subsection = $k > 0 && ( ! isset( $sections[ ( $k ) ]['type'] ) || 'divide' !== $sections[ ( $k ) ]['type'] ); |
|
| 1050 | + $can_be_subsection = $k > 0 && ( ! isset( $sections[( $k )]['type'] ) || 'divide' !== $sections[( $k )]['type'] ); |
|
| 1051 | 1051 | |
| 1052 | 1052 | if ( ! $can_be_subsection && isset( $section['subsection'] ) && true === $section['subsection'] ) { |
| 1053 | 1053 | unset( $section['subsection'] ); |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | if ( isset( $section['type'] ) && 'divide' === $section['type'] ) { |
| 1057 | 1057 | $string .= '<li class="divide' . esc_attr( $section['class'] ) . '"> </li>'; |
| 1058 | 1058 | } elseif ( ! isset( $section['subsection'] ) || true !== $section['subsection'] ) { |
| 1059 | - $subsections = isset( $sections[ ( $k + 1 ) ]['subsection'] ) && true === $sections[ ( $k + 1 ) ]['subsection']; |
|
| 1059 | + $subsections = isset( $sections[( $k + 1 )]['subsection'] ) && true === $sections[( $k + 1 )]['subsection']; |
|
| 1060 | 1060 | $subsections_class = $subsections ? ' hasSubSections' : ''; |
| 1061 | 1061 | $subsections_class .= ( empty( $section['fields'] ) ) ? ' empty_section' : ''; |
| 1062 | 1062 | $rotate = true === $core->args['flyout_submenus'] ? ' el-rotate' : ''; |
@@ -1079,12 +1079,12 @@ discard block |
||
| 1079 | 1079 | $display = true; |
| 1080 | 1080 | |
| 1081 | 1081 | if ( isset( $_GET['page'] ) && $core->args['page_slug'] === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 1082 | - if ( isset( $sections[ $next_k ]['panel'] ) && false === $sections[ $next_k ]['panel'] ) { |
|
| 1082 | + if ( isset( $sections[$next_k]['panel'] ) && false === $sections[$next_k]['panel'] ) { |
|
| 1083 | 1083 | $display = false; |
| 1084 | 1084 | } |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | - if ( count( $sections ) < $function_count || ! isset( $sections[ $next_k ] ) || ! isset( $sections[ $next_k ]['subsection'] ) || true !== $sections[ $next_k ]['subsection'] ) { |
|
| 1087 | + if ( count( $sections ) < $function_count || ! isset( $sections[$next_k] ) || ! isset( $sections[$next_k]['subsection'] ) || true !== $sections[$next_k]['subsection'] ) { |
|
| 1088 | 1088 | $do_loop = false; |
| 1089 | 1089 | } else { |
| 1090 | 1090 | if ( ! $display ) { |
@@ -1092,31 +1092,31 @@ discard block |
||
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | $hide_sub = ''; |
| 1095 | - if ( isset( $sections[ $next_k ]['hidden'] ) ) { |
|
| 1096 | - $hide_sub = ( true === $sections[ $next_k ]['hidden'] ) ? ' hidden ' : ''; |
|
| 1095 | + if ( isset( $sections[$next_k]['hidden'] ) ) { |
|
| 1096 | + $hide_sub = ( true === $sections[$next_k]['hidden'] ) ? ' hidden ' : ''; |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - if ( ( isset( $core->args['icon_type'] ) && 'image' === $core->args['icon_type'] ) || ( isset( $sections[ $next_k ]['icon_type'] ) && 'image' === $sections[ $next_k ]['icon_type'] ) ) { |
|
| 1099 | + if ( ( isset( $core->args['icon_type'] ) && 'image' === $core->args['icon_type'] ) || ( isset( $sections[$next_k]['icon_type'] ) && 'image' === $sections[$next_k]['icon_type'] ) ) { |
|
| 1100 | 1100 | // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- No image/icon to enqueue. |
| 1101 | - $icon = ( ! isset( $sections[ $next_k ]['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $sections[ $next_k ]['icon'] ) . '" /> '; |
|
| 1101 | + $icon = ( ! isset( $sections[$next_k]['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $sections[$next_k]['icon'] ) . '" /> '; |
|
| 1102 | 1102 | } else { |
| 1103 | - if ( ! empty( $sections[ $next_k ]['icon_class'] ) ) { |
|
| 1104 | - $icon_class = ' ' . $sections[ $next_k ]['icon_class']; |
|
| 1103 | + if ( ! empty( $sections[$next_k]['icon_class'] ) ) { |
|
| 1104 | + $icon_class = ' ' . $sections[$next_k]['icon_class']; |
|
| 1105 | 1105 | } elseif ( ! empty( $core->args['default_icon_class'] ) ) { |
| 1106 | 1106 | $icon_class = ' ' . $core->args['default_icon_class']; |
| 1107 | 1107 | } else { |
| 1108 | 1108 | $icon_class = ''; |
| 1109 | 1109 | } |
| 1110 | - $icon = ( ! isset( $sections[ $next_k ]['icon'] ) ) ? '' : '<i class="' . esc_attr( $sections[ $next_k ]['icon'] ) . esc_attr( $icon_class ) . '"></i> '; |
|
| 1110 | + $icon = ( ! isset( $sections[$next_k]['icon'] ) ) ? '' : '<i class="' . esc_attr( $sections[$next_k]['icon'] ) . esc_attr( $icon_class ) . '"></i> '; |
|
| 1111 | 1111 | } |
| 1112 | 1112 | if ( strpos( $icon, 'el-icon-' ) !== false ) { |
| 1113 | 1113 | $icon = str_replace( 'el-icon-', 'el el-', $icon ); |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - $sections[ $next_k ]['class'] = $sections[ $next_k ]['class'] ?? ''; |
|
| 1117 | - $section[ $next_k ]['class'] = $section[ $next_k ]['class'] ?? $sections[ $next_k ]['class']; |
|
| 1118 | - $string .= '<li id="' . esc_attr( $next_k . $suffix ) . '_section_group_li" class="redux-group-tab-link-li ' . esc_attr( $hide_sub ) . esc_attr( $section[ $next_k ]['class'] ) . ( $icon ? ' hasIcon' : '' ) . '">'; |
|
| 1119 | - $string .= '<a href="javascript:void(0);" id="' . esc_attr( $next_k . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $next_k ) . '" data-rel="' . esc_attr( $next_k . $suffix ) . '">' . $icon . '<span class="group_title">' . wp_kses_post( $sections[ $next_k ]['title'] ) . '</span></a>'; |
|
| 1116 | + $sections[$next_k]['class'] = $sections[$next_k]['class'] ?? ''; |
|
| 1117 | + $section[$next_k]['class'] = $section[$next_k]['class'] ?? $sections[$next_k]['class']; |
|
| 1118 | + $string .= '<li id="' . esc_attr( $next_k . $suffix ) . '_section_group_li" class="redux-group-tab-link-li ' . esc_attr( $hide_sub ) . esc_attr( $section[$next_k]['class'] ) . ( $icon ? ' hasIcon' : '' ) . '">'; |
|
| 1119 | + $string .= '<a href="javascript:void(0);" id="' . esc_attr( $next_k . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $next_k ) . '" data-rel="' . esc_attr( $next_k . $suffix ) . '">' . $icon . '<span class="group_title">' . wp_kses_post( $sections[$next_k]['title'] ) . '</span></a>'; |
|
| 1120 | 1120 | $string .= '</li>'; |
| 1121 | 1121 | } |
| 1122 | 1122 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | // phpcs:disabled |
| 10 | 10 | if ( ! class_exists( 'Redux' ) ) { |
| 11 | - return null; |
|
| 11 | + return null; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // This is your option name where all the Redux data is stored. |
@@ -27,184 +27,184 @@ discard block |
||
| 27 | 27 | $theme = wp_get_theme(); // For use with some settings. Not necessary. |
| 28 | 28 | |
| 29 | 29 | $args = array( |
| 30 | - // REQUIRED!! Change these values as you need/desire. |
|
| 31 | - 'opt_name' => $opt_name, |
|
| 30 | + // REQUIRED!! Change these values as you need/desire. |
|
| 31 | + 'opt_name' => $opt_name, |
|
| 32 | 32 | |
| 33 | - // Name that appears at the top of your panel. |
|
| 34 | - 'display_name' => $theme->get( 'Name' ), |
|
| 33 | + // Name that appears at the top of your panel. |
|
| 34 | + 'display_name' => $theme->get( 'Name' ), |
|
| 35 | 35 | |
| 36 | - // Version that appears at the top of your panel. |
|
| 37 | - 'display_version' => $theme->get( 'Version' ), |
|
| 36 | + // Version that appears at the top of your panel. |
|
| 37 | + 'display_version' => $theme->get( 'Version' ), |
|
| 38 | 38 | |
| 39 | - // Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only). |
|
| 40 | - 'menu_type' => 'menu', |
|
| 39 | + // Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only). |
|
| 40 | + 'menu_type' => 'menu', |
|
| 41 | 41 | |
| 42 | - // Show the sections below the admin menu item or not. |
|
| 43 | - 'allow_sub_menu' => true, |
|
| 42 | + // Show the sections below the admin menu item or not. |
|
| 43 | + 'allow_sub_menu' => true, |
|
| 44 | 44 | |
| 45 | - 'menu_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 46 | - 'page_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 45 | + 'menu_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 46 | + 'page_title' => esc_html__( 'Sample Options', 'your-textdomain-here' ), |
|
| 47 | 47 | |
| 48 | - // Disable this in case you want to create your own Google fonts loader. |
|
| 49 | - 'disable_google_fonts_link' => false, |
|
| 48 | + // Disable this in case you want to create your own Google fonts loader. |
|
| 49 | + 'disable_google_fonts_link' => false, |
|
| 50 | 50 | |
| 51 | - // Show the panel pages on the admin bar. |
|
| 52 | - 'admin_bar' => true, |
|
| 51 | + // Show the panel pages on the admin bar. |
|
| 52 | + 'admin_bar' => true, |
|
| 53 | 53 | |
| 54 | - // Choose an icon for the admin bar menu. |
|
| 55 | - 'admin_bar_icon' => 'dashicons-portfolio', |
|
| 54 | + // Choose an icon for the admin bar menu. |
|
| 55 | + 'admin_bar_icon' => 'dashicons-portfolio', |
|
| 56 | 56 | |
| 57 | - // Choose a priority for the admin bar menu. |
|
| 58 | - 'admin_bar_priority' => 50, |
|
| 57 | + // Choose a priority for the admin bar menu. |
|
| 58 | + 'admin_bar_priority' => 50, |
|
| 59 | 59 | |
| 60 | - // Set a different name for your global variable other than the opt_name. |
|
| 61 | - 'global_variable' => '', |
|
| 60 | + // Set a different name for your global variable other than the opt_name. |
|
| 61 | + 'global_variable' => '', |
|
| 62 | 62 | |
| 63 | - // Show the time the page took to load, etc. |
|
| 64 | - 'dev_mode' => true, |
|
| 63 | + // Show the time the page took to load, etc. |
|
| 64 | + 'dev_mode' => true, |
|
| 65 | 65 | |
| 66 | - // Enable basic customizer support. |
|
| 67 | - 'customizer' => true, |
|
| 66 | + // Enable basic customizer support. |
|
| 67 | + 'customizer' => true, |
|
| 68 | 68 | |
| 69 | - // Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning. |
|
| 70 | - 'page_priority' => null, |
|
| 69 | + // Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning. |
|
| 70 | + 'page_priority' => null, |
|
| 71 | 71 | |
| 72 | - // For a full list of options, visit: @link https://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters. |
|
| 73 | - 'page_parent' => 'themes.php', |
|
| 72 | + // For a full list of options, visit: @link https://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters. |
|
| 73 | + 'page_parent' => 'themes.php', |
|
| 74 | 74 | |
| 75 | - // Permissions needed to access the options panel. |
|
| 76 | - 'page_permissions' => 'manage_options', |
|
| 75 | + // Permissions needed to access the options panel. |
|
| 76 | + 'page_permissions' => 'manage_options', |
|
| 77 | 77 | |
| 78 | - // Specify a custom URL to an icon. |
|
| 79 | - 'menu_icon' => '', |
|
| 78 | + // Specify a custom URL to an icon. |
|
| 79 | + 'menu_icon' => '', |
|
| 80 | 80 | |
| 81 | - // Force your panel to always open to a specific tab (by id). |
|
| 82 | - 'last_tab' => '', |
|
| 81 | + // Force your panel to always open to a specific tab (by id). |
|
| 82 | + 'last_tab' => '', |
|
| 83 | 83 | |
| 84 | - // Icon displayed in the admin panel next to your menu_title. |
|
| 85 | - 'page_icon' => 'icon-themes', |
|
| 84 | + // Icon displayed in the admin panel next to your menu_title. |
|
| 85 | + 'page_icon' => 'icon-themes', |
|
| 86 | 86 | |
| 87 | - // Page slug used to denote the panel. |
|
| 88 | - 'page_slug' => '_options', |
|
| 87 | + // Page slug used to denote the panel. |
|
| 88 | + 'page_slug' => '_options', |
|
| 89 | 89 | |
| 90 | - // On load save the defaults to DB before user clicks save or not. |
|
| 91 | - 'save_defaults' => true, |
|
| 90 | + // On load save the defaults to DB before user clicks save or not. |
|
| 91 | + 'save_defaults' => true, |
|
| 92 | 92 | |
| 93 | - // If true, shows the default value next to each field that is not the default value. |
|
| 94 | - 'default_show' => false, |
|
| 93 | + // If true, shows the default value next to each field that is not the default value. |
|
| 94 | + 'default_show' => false, |
|
| 95 | 95 | |
| 96 | - // What to print by the field's title if the value shown is default. Suggested: *. |
|
| 97 | - 'default_mark' => '', |
|
| 96 | + // What to print by the field's title if the value shown is default. Suggested: *. |
|
| 97 | + 'default_mark' => '', |
|
| 98 | 98 | |
| 99 | - // Shows the Import/Export panel when not used as a field. |
|
| 100 | - 'show_import_export' => true, |
|
| 99 | + // Shows the Import/Export panel when not used as a field. |
|
| 100 | + 'show_import_export' => true, |
|
| 101 | 101 | |
| 102 | - // CAREFUL: These options are for advanced use only. |
|
| 103 | - 'transient_time' => 60 * MINUTE_IN_SECONDS, |
|
| 102 | + // CAREFUL: These options are for advanced use only. |
|
| 103 | + 'transient_time' => 60 * MINUTE_IN_SECONDS, |
|
| 104 | 104 | |
| 105 | - // Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output. |
|
| 106 | - 'output' => true, |
|
| 105 | + // Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output. |
|
| 106 | + 'output' => true, |
|
| 107 | 107 | |
| 108 | - // Allows dynamic CSS to be generated for customizer and google fonts, but stops the dynamic CSS from going to the head. |
|
| 109 | - 'output_tag' => true, |
|
| 108 | + // Allows dynamic CSS to be generated for customizer and google fonts, but stops the dynamic CSS from going to the head. |
|
| 109 | + 'output_tag' => true, |
|
| 110 | 110 | |
| 111 | - // FUTURE → Not in use yet, but reserved or partially implemented. |
|
| 112 | - // Use at your own risk. |
|
| 113 | - // Possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning! |
|
| 114 | - 'database' => '', |
|
| 111 | + // FUTURE → Not in use yet, but reserved or partially implemented. |
|
| 112 | + // Use at your own risk. |
|
| 113 | + // Possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning! |
|
| 114 | + 'database' => '', |
|
| 115 | 115 | |
| 116 | - 'compiler' => true, |
|
| 116 | + 'compiler' => true, |
|
| 117 | 117 | |
| 118 | - // Enable or disable flyout menus when hovering over a menu with submenus. |
|
| 119 | - 'flyout_submenus' => true, |
|
| 118 | + // Enable or disable flyout menus when hovering over a menu with submenus. |
|
| 119 | + 'flyout_submenus' => true, |
|
| 120 | 120 | |
| 121 | - // Mode to display fonts (auto|block|swap|fallback|optional) |
|
| 122 | - // See: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display . |
|
| 123 | - 'font_display' => 'swap', |
|
| 121 | + // Mode to display fonts (auto|block|swap|fallback|optional) |
|
| 122 | + // See: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display . |
|
| 123 | + 'font_display' => 'swap', |
|
| 124 | 124 | |
| 125 | - // HINTS. |
|
| 126 | - 'hints' => array( |
|
| 127 | - 'icon' => 'el el-question-sign', |
|
| 128 | - 'icon_position' => 'right', |
|
| 129 | - 'icon_color' => 'lightgray', |
|
| 130 | - 'icon_size' => 'normal', |
|
| 131 | - 'tip_style' => array( |
|
| 132 | - 'color' => 'light', |
|
| 133 | - 'shadow' => true, |
|
| 134 | - 'rounded' => false, |
|
| 135 | - 'style' => '', |
|
| 136 | - ), |
|
| 137 | - 'tip_position' => array( |
|
| 138 | - 'my' => 'top left', |
|
| 139 | - 'at' => 'bottom right', |
|
| 140 | - ), |
|
| 141 | - 'tip_effect' => array( |
|
| 142 | - 'show' => array( |
|
| 143 | - 'effect' => 'slide', |
|
| 144 | - 'duration' => '500', |
|
| 145 | - 'event' => 'mouseover', |
|
| 146 | - ), |
|
| 147 | - 'hide' => array( |
|
| 148 | - 'effect' => 'slide', |
|
| 149 | - 'duration' => '500', |
|
| 150 | - 'event' => 'click mouseleave', |
|
| 151 | - ), |
|
| 152 | - ), |
|
| 153 | - ), |
|
| 125 | + // HINTS. |
|
| 126 | + 'hints' => array( |
|
| 127 | + 'icon' => 'el el-question-sign', |
|
| 128 | + 'icon_position' => 'right', |
|
| 129 | + 'icon_color' => 'lightgray', |
|
| 130 | + 'icon_size' => 'normal', |
|
| 131 | + 'tip_style' => array( |
|
| 132 | + 'color' => 'light', |
|
| 133 | + 'shadow' => true, |
|
| 134 | + 'rounded' => false, |
|
| 135 | + 'style' => '', |
|
| 136 | + ), |
|
| 137 | + 'tip_position' => array( |
|
| 138 | + 'my' => 'top left', |
|
| 139 | + 'at' => 'bottom right', |
|
| 140 | + ), |
|
| 141 | + 'tip_effect' => array( |
|
| 142 | + 'show' => array( |
|
| 143 | + 'effect' => 'slide', |
|
| 144 | + 'duration' => '500', |
|
| 145 | + 'event' => 'mouseover', |
|
| 146 | + ), |
|
| 147 | + 'hide' => array( |
|
| 148 | + 'effect' => 'slide', |
|
| 149 | + 'duration' => '500', |
|
| 150 | + 'event' => 'click mouseleave', |
|
| 151 | + ), |
|
| 152 | + ), |
|
| 153 | + ), |
|
| 154 | 154 | ); |
| 155 | 155 | |
| 156 | 156 | // ADMIN BAR LINKS → Set up custom links in the admin bar menu as external items. |
| 157 | 157 | $args['admin_bar_links'][] = array( |
| 158 | - 'id' => 'redux-docs', |
|
| 159 | - 'href' => '//devs.redux.io/', |
|
| 160 | - 'title' => esc_html__( 'Documentation', 'your-textdomain-here' ), |
|
| 158 | + 'id' => 'redux-docs', |
|
| 159 | + 'href' => '//devs.redux.io/', |
|
| 160 | + 'title' => esc_html__( 'Documentation', 'your-textdomain-here' ), |
|
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | 163 | $args['admin_bar_links'][] = array( |
| 164 | - 'id' => 'redux-support', |
|
| 165 | - 'href' => '//github.com/ReduxFramework/redux-framework/issues', |
|
| 166 | - 'title' => esc_html__( 'Support', 'your-textdomain-here' ), |
|
| 164 | + 'id' => 'redux-support', |
|
| 165 | + 'href' => '//github.com/ReduxFramework/redux-framework/issues', |
|
| 166 | + 'title' => esc_html__( 'Support', 'your-textdomain-here' ), |
|
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | $args['admin_bar_links'][] = array( |
| 170 | - 'id' => 'redux-extensions', |
|
| 171 | - 'href' => 'redux.io/extensions', |
|
| 172 | - 'title' => esc_html__( 'Extensions', 'your-textdomain-here' ), |
|
| 170 | + 'id' => 'redux-extensions', |
|
| 171 | + 'href' => 'redux.io/extensions', |
|
| 172 | + 'title' => esc_html__( 'Extensions', 'your-textdomain-here' ), |
|
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | // SOCIAL ICONS → Set up custom links in the footer for quick links in your panel footer icons. |
| 176 | 176 | $args['share_icons'][] = array( |
| 177 | - 'url' => '//github.com/ReduxFramework/ReduxFramework', |
|
| 178 | - 'title' => 'Visit us on GitHub', |
|
| 179 | - 'icon' => 'el el-github', |
|
| 177 | + 'url' => '//github.com/ReduxFramework/ReduxFramework', |
|
| 178 | + 'title' => 'Visit us on GitHub', |
|
| 179 | + 'icon' => 'el el-github', |
|
| 180 | 180 | ); |
| 181 | 181 | $args['share_icons'][] = array( |
| 182 | - 'url' => '//www.facebook.com/pages/Redux-Framework/243141545850368', |
|
| 183 | - 'title' => esc_html__( 'Like us on Facebook', 'your-textdomain-here' ), |
|
| 184 | - 'icon' => 'el el-facebook', |
|
| 182 | + 'url' => '//www.facebook.com/pages/Redux-Framework/243141545850368', |
|
| 183 | + 'title' => esc_html__( 'Like us on Facebook', 'your-textdomain-here' ), |
|
| 184 | + 'icon' => 'el el-facebook', |
|
| 185 | 185 | ); |
| 186 | 186 | $args['share_icons'][] = array( |
| 187 | - 'url' => '//twitter.com/reduxframework', |
|
| 188 | - 'title' => esc_html__( 'Follow us on Twitter', 'your-textdomain-here' ), |
|
| 189 | - 'icon' => 'el el-twitter', |
|
| 187 | + 'url' => '//twitter.com/reduxframework', |
|
| 188 | + 'title' => esc_html__( 'Follow us on Twitter', 'your-textdomain-here' ), |
|
| 189 | + 'icon' => 'el el-twitter', |
|
| 190 | 190 | ); |
| 191 | 191 | $args['share_icons'][] = array( |
| 192 | - 'url' => '//www.linkedin.com/company/redux-framework', |
|
| 193 | - 'title' => esc_html__( 'Find us on LinkedIn', 'your-textdomain-here' ), |
|
| 194 | - 'icon' => 'el el-linkedin', |
|
| 192 | + 'url' => '//www.linkedin.com/company/redux-framework', |
|
| 193 | + 'title' => esc_html__( 'Find us on LinkedIn', 'your-textdomain-here' ), |
|
| 194 | + 'icon' => 'el el-linkedin', |
|
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | 197 | // Panel Intro text → before the form. |
| 198 | 198 | if ( false !== $args['global_variable'] ) { |
| 199 | - if ( ! empty( $args['global_variable'] ) ) { |
|
| 200 | - $v = $args['global_variable']; |
|
| 201 | - } else { |
|
| 202 | - $v = str_replace( '-', '_', $args['opt_name'] ); |
|
| 203 | - } |
|
| 199 | + if ( ! empty( $args['global_variable'] ) ) { |
|
| 200 | + $v = $args['global_variable']; |
|
| 201 | + } else { |
|
| 202 | + $v = str_replace( '-', '_', $args['opt_name'] ); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - $args['intro_text'] = '<p>' . sprintf( __( '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: $s', 'your-textdomain-here' ) . '</p>', '<strong>' . $v . '</strong>' ); |
|
| 205 | + $args['intro_text'] = '<p>' . sprintf( __( '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: $s', 'your-textdomain-here' ) . '</p>', '<strong>' . $v . '</strong>' ); |
|
| 206 | 206 | } else { |
| 207 | - $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>'; |
|
| 207 | + $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>'; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Add content after the form. |
@@ -221,17 +221,17 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | |
| 223 | 223 | $help_tabs = array( |
| 224 | - array( |
|
| 225 | - 'id' => 'redux-help-tab-1', |
|
| 226 | - 'title' => esc_html__( 'Theme Information 1', 'your-textdomain-here' ), |
|
| 227 | - 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 228 | - ), |
|
| 229 | - |
|
| 230 | - array( |
|
| 231 | - 'id' => 'redux-help-tab-2', |
|
| 232 | - 'title' => esc_html__( 'Theme Information 2', 'your-textdomain-here' ), |
|
| 233 | - 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 234 | - ), |
|
| 224 | + array( |
|
| 225 | + 'id' => 'redux-help-tab-1', |
|
| 226 | + 'title' => esc_html__( 'Theme Information 1', 'your-textdomain-here' ), |
|
| 227 | + 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 228 | + ), |
|
| 229 | + |
|
| 230 | + array( |
|
| 231 | + 'id' => 'redux-help-tab-2', |
|
| 232 | + 'title' => esc_html__( 'Theme Information 2', 'your-textdomain-here' ), |
|
| 233 | + 'content' => '<p>' . esc_html__( 'This is the tab content, HTML is allowed.', 'your-textdomain-here' ) . '</p>', |
|
| 234 | + ), |
|
| 235 | 235 | ); |
| 236 | 236 | |
| 237 | 237 | Redux::set_help_tab( $opt_name, $help_tabs ); |
@@ -255,77 +255,77 @@ discard block |
||
| 255 | 255 | /* -> START Basic Fields. */ |
| 256 | 256 | |
| 257 | 257 | $kses_exceptions = array( |
| 258 | - 'a' => array( |
|
| 259 | - 'href' => array(), |
|
| 260 | - ), |
|
| 261 | - 'strong' => array(), |
|
| 262 | - 'br' => array(), |
|
| 258 | + 'a' => array( |
|
| 259 | + 'href' => array(), |
|
| 260 | + ), |
|
| 261 | + 'strong' => array(), |
|
| 262 | + 'br' => array(), |
|
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | 265 | $section = array( |
| 266 | - 'title' => esc_html__( 'Basic Field', 'your-textdomain-here' ), |
|
| 267 | - 'id' => 'basic', |
|
| 268 | - 'desc' => esc_html__( 'Basic field with no subsections.', 'your-textdomain-here' ), |
|
| 269 | - 'icon' => 'el el-home', |
|
| 270 | - 'fields' => array( |
|
| 271 | - array( |
|
| 272 | - 'id' => 'opt-text', |
|
| 273 | - 'type' => 'text', |
|
| 274 | - 'title' => esc_html__( 'Example Text', 'your-textdomain-here' ), |
|
| 275 | - 'desc' => esc_html__( 'Example description.', 'your-textdomain-here' ), |
|
| 276 | - 'subtitle' => esc_html__( 'Example subtitle.', 'your-textdomain-here' ), |
|
| 277 | - 'hint' => array( |
|
| 278 | - 'content' => wp_kses( __( 'This is a <strong>hint</strong> tool-tip for the text field.<br/><br/>Add any HTML-based text you like here.', 'your-textdomain-here' ), $kses_exceptions ), |
|
| 279 | - ), |
|
| 280 | - ), |
|
| 281 | - ), |
|
| 266 | + 'title' => esc_html__( 'Basic Field', 'your-textdomain-here' ), |
|
| 267 | + 'id' => 'basic', |
|
| 268 | + 'desc' => esc_html__( 'Basic field with no subsections.', 'your-textdomain-here' ), |
|
| 269 | + 'icon' => 'el el-home', |
|
| 270 | + 'fields' => array( |
|
| 271 | + array( |
|
| 272 | + 'id' => 'opt-text', |
|
| 273 | + 'type' => 'text', |
|
| 274 | + 'title' => esc_html__( 'Example Text', 'your-textdomain-here' ), |
|
| 275 | + 'desc' => esc_html__( 'Example description.', 'your-textdomain-here' ), |
|
| 276 | + 'subtitle' => esc_html__( 'Example subtitle.', 'your-textdomain-here' ), |
|
| 277 | + 'hint' => array( |
|
| 278 | + 'content' => wp_kses( __( 'This is a <strong>hint</strong> tool-tip for the text field.<br/><br/>Add any HTML-based text you like here.', 'your-textdomain-here' ), $kses_exceptions ), |
|
| 279 | + ), |
|
| 280 | + ), |
|
| 281 | + ), |
|
| 282 | 282 | ); |
| 283 | 283 | |
| 284 | 284 | Redux::set_section( $opt_name, $section ); |
| 285 | 285 | |
| 286 | 286 | $section = array( |
| 287 | - 'title' => __( 'Basic Fields', 'your-textdomain-here' ), |
|
| 288 | - 'id' => 'basic', |
|
| 289 | - 'desc' => __( 'Basic fields as subsections.', 'your-textdomain-here' ), |
|
| 290 | - 'icon' => 'el el-home', |
|
| 287 | + 'title' => __( 'Basic Fields', 'your-textdomain-here' ), |
|
| 288 | + 'id' => 'basic', |
|
| 289 | + 'desc' => __( 'Basic fields as subsections.', 'your-textdomain-here' ), |
|
| 290 | + 'icon' => 'el el-home', |
|
| 291 | 291 | ); |
| 292 | 292 | |
| 293 | 293 | Redux::set_section( $opt_name, $section ); |
| 294 | 294 | |
| 295 | 295 | $section = array( |
| 296 | - 'title' => esc_html__( 'Text', 'your-textdomain-here' ), |
|
| 297 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/text.html" target="_blank">https://devs.redux.io/core-fields/text.html</a>', |
|
| 298 | - 'id' => 'opt-text-subsection', |
|
| 299 | - 'subsection' => true, |
|
| 300 | - 'fields' => array( |
|
| 301 | - array( |
|
| 302 | - 'id' => 'text-example', |
|
| 303 | - 'type' => 'text', |
|
| 304 | - 'title' => esc_html__( 'Text Field', 'your-textdomain-here' ), |
|
| 305 | - 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 306 | - 'desc' => esc_html__( 'Field Description', 'your-textdomain-here' ), |
|
| 307 | - 'default' => 'Default Text', |
|
| 308 | - ), |
|
| 309 | - ), |
|
| 296 | + 'title' => esc_html__( 'Text', 'your-textdomain-here' ), |
|
| 297 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/text.html" target="_blank">https://devs.redux.io/core-fields/text.html</a>', |
|
| 298 | + 'id' => 'opt-text-subsection', |
|
| 299 | + 'subsection' => true, |
|
| 300 | + 'fields' => array( |
|
| 301 | + array( |
|
| 302 | + 'id' => 'text-example', |
|
| 303 | + 'type' => 'text', |
|
| 304 | + 'title' => esc_html__( 'Text Field', 'your-textdomain-here' ), |
|
| 305 | + 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 306 | + 'desc' => esc_html__( 'Field Description', 'your-textdomain-here' ), |
|
| 307 | + 'default' => 'Default Text', |
|
| 308 | + ), |
|
| 309 | + ), |
|
| 310 | 310 | ); |
| 311 | 311 | |
| 312 | 312 | Redux::set_section( $opt_name, $section ); |
| 313 | 313 | |
| 314 | 314 | $section = array( |
| 315 | - 'title' => esc_html__( 'Text Area', 'your-textdomain-here' ), |
|
| 316 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/textarea.html" target="_blank">https://devs.redux.io/core-fields/textarea.html</a>', |
|
| 317 | - 'id' => 'opt-textarea-subsection', |
|
| 318 | - 'subsection' => true, |
|
| 319 | - 'fields' => array( |
|
| 320 | - array( |
|
| 321 | - 'id' => 'textarea-example', |
|
| 322 | - 'type' => 'textarea', |
|
| 323 | - 'title' => esc_html__( 'Text Area Field', 'your-textdomain-here' ), |
|
| 324 | - 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 325 | - 'desc' => esc_html__( 'Field Description', 'your-textdomain-here' ), |
|
| 326 | - 'default' => 'Default Text', |
|
| 327 | - ), |
|
| 328 | - ), |
|
| 315 | + 'title' => esc_html__( 'Text Area', 'your-textdomain-here' ), |
|
| 316 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/textarea.html" target="_blank">https://devs.redux.io/core-fields/textarea.html</a>', |
|
| 317 | + 'id' => 'opt-textarea-subsection', |
|
| 318 | + 'subsection' => true, |
|
| 319 | + 'fields' => array( |
|
| 320 | + array( |
|
| 321 | + 'id' => 'textarea-example', |
|
| 322 | + 'type' => 'textarea', |
|
| 323 | + 'title' => esc_html__( 'Text Area Field', 'your-textdomain-here' ), |
|
| 324 | + 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 325 | + 'desc' => esc_html__( 'Field Description', 'your-textdomain-here' ), |
|
| 326 | + 'default' => 'Default Text', |
|
| 327 | + ), |
|
| 328 | + ), |
|
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | 331 | Redux::set_section( $opt_name, $section ); |
@@ -12,218 +12,218 @@ |
||
| 12 | 12 | defined( 'ABSPATH' ) || exit; |
| 13 | 13 | |
| 14 | 14 | if ( ! class_exists( 'Redux_Metaboxes' ) ) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | Redux_Metaboxes::set_box( |
| 19 | - $opt_name, |
|
| 20 | - array( |
|
| 21 | - 'id' => 'opt-metaboxes', |
|
| 22 | - 'title' => esc_html__( 'Metabox Options', 'your-textdomain-here' ), |
|
| 23 | - 'post_types' => array( 'page', 'post' ), |
|
| 24 | - 'position' => 'normal', // normal, advanced, side. |
|
| 25 | - 'priority' => 'high', // high, core, default, low. |
|
| 26 | - 'sections' => array( |
|
| 27 | - array( |
|
| 28 | - 'title' => esc_html__( 'Basic Fields', 'your-textdomain-here' ), |
|
| 29 | - 'id' => 'opt-basic-fields', |
|
| 30 | - 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 31 | - 'icon' => 'el-icon-cogs', |
|
| 32 | - 'fields' => array( |
|
| 33 | - array( |
|
| 34 | - 'id' => 'opt-checkbox', |
|
| 35 | - 'type' => 'checkbox', |
|
| 36 | - 'title' => esc_html__( 'Checkbox', 'your-textdomain-here' ), |
|
| 37 | - 'subtitle' => esc_html__( 'Basic Checkbox field.', 'your-textdomain-here' ), |
|
| 38 | - 'default' => true, |
|
| 39 | - ), |
|
| 40 | - array( |
|
| 41 | - 'id' => 'opt-radio', |
|
| 42 | - 'type' => 'radio', |
|
| 43 | - 'title' => esc_html__( 'Radio Button', 'your-textdomain-here' ), |
|
| 44 | - 'subtitle' => esc_html__( 'Basic Radio Button field.', 'your-textdomain-here' ), |
|
| 45 | - 'options' => array( |
|
| 46 | - '1' => esc_html__( 'Option 1', 'your-textdomain-here' ), |
|
| 47 | - '2' => esc_html__( 'Option 2', 'your-textdomain-here' ), |
|
| 48 | - '3' => esc_html__( 'Option 3', 'your-textdomain-here' ), |
|
| 49 | - ), |
|
| 50 | - 'default' => '2', |
|
| 51 | - ), |
|
| 52 | - array( |
|
| 53 | - 'id' => 'opt-media', |
|
| 54 | - 'type' => 'media', |
|
| 55 | - 'url' => true, |
|
| 56 | - 'title' => esc_html__( 'Media w/ URL', 'your-textdomain-here' ), |
|
| 57 | - 'compiler' => 'true', |
|
| 58 | - 'desc' => esc_html__( 'Basic media uploader with disabled URL input field.', 'your-textdomain-here' ), |
|
| 59 | - 'subtitle' => esc_html__( 'Upload any media using the WordPress native uploader', 'your-textdomain-here' ), |
|
| 60 | - 'default' => array( 'url' => 'https://s.wordpress.org/style/images/codeispoetry.png' ), |
|
| 61 | - ), |
|
| 62 | - array( |
|
| 63 | - 'id' => 'gallery', |
|
| 64 | - 'type' => 'gallery', |
|
| 65 | - 'title' => esc_html__( 'Add/Edit Gallery', 'your-textdomain-here' ), |
|
| 66 | - 'subtitle' => esc_html__( 'Create a new Gallery by selecting existing or uploading new images using the WordPress native uploader', 'your-textdomain-here' ), |
|
| 67 | - 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), |
|
| 68 | - ), |
|
| 69 | - array( |
|
| 70 | - 'id' => 'opt-slider', |
|
| 71 | - 'type' => 'slider', |
|
| 72 | - 'title' => esc_html__( 'JQuery UI Slider Example 2 w/ Steps (5)', 'your-textdomain-here' ), |
|
| 73 | - 'desc' => esc_html__( 'JQuery UI slider description. Min: 0, max: 300, step: 5, default value: 75', 'your-textdomain-here' ), |
|
| 74 | - 'default' => '0', |
|
| 75 | - 'min' => '0', |
|
| 76 | - 'step' => '5', |
|
| 77 | - 'max' => '300', |
|
| 78 | - ), |
|
| 79 | - array( |
|
| 80 | - 'id' => 'opt-spinner', |
|
| 81 | - 'type' => 'spinner', |
|
| 82 | - 'title' => esc_html__( 'JQuery UI Spinner Example 1', 'your-textdomain-here' ), |
|
| 83 | - 'desc' => esc_html__( 'JQuery UI spinner description. Min:20, max: 100, step:20, default value: 40', 'your-textdomain-here' ), |
|
| 84 | - 'default' => '40', |
|
| 85 | - 'min' => '20', |
|
| 86 | - 'step' => '20', |
|
| 87 | - 'max' => '100', |
|
| 88 | - ), |
|
| 19 | + $opt_name, |
|
| 20 | + array( |
|
| 21 | + 'id' => 'opt-metaboxes', |
|
| 22 | + 'title' => esc_html__( 'Metabox Options', 'your-textdomain-here' ), |
|
| 23 | + 'post_types' => array( 'page', 'post' ), |
|
| 24 | + 'position' => 'normal', // normal, advanced, side. |
|
| 25 | + 'priority' => 'high', // high, core, default, low. |
|
| 26 | + 'sections' => array( |
|
| 27 | + array( |
|
| 28 | + 'title' => esc_html__( 'Basic Fields', 'your-textdomain-here' ), |
|
| 29 | + 'id' => 'opt-basic-fields', |
|
| 30 | + 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 31 | + 'icon' => 'el-icon-cogs', |
|
| 32 | + 'fields' => array( |
|
| 33 | + array( |
|
| 34 | + 'id' => 'opt-checkbox', |
|
| 35 | + 'type' => 'checkbox', |
|
| 36 | + 'title' => esc_html__( 'Checkbox', 'your-textdomain-here' ), |
|
| 37 | + 'subtitle' => esc_html__( 'Basic Checkbox field.', 'your-textdomain-here' ), |
|
| 38 | + 'default' => true, |
|
| 39 | + ), |
|
| 40 | + array( |
|
| 41 | + 'id' => 'opt-radio', |
|
| 42 | + 'type' => 'radio', |
|
| 43 | + 'title' => esc_html__( 'Radio Button', 'your-textdomain-here' ), |
|
| 44 | + 'subtitle' => esc_html__( 'Basic Radio Button field.', 'your-textdomain-here' ), |
|
| 45 | + 'options' => array( |
|
| 46 | + '1' => esc_html__( 'Option 1', 'your-textdomain-here' ), |
|
| 47 | + '2' => esc_html__( 'Option 2', 'your-textdomain-here' ), |
|
| 48 | + '3' => esc_html__( 'Option 3', 'your-textdomain-here' ), |
|
| 49 | + ), |
|
| 50 | + 'default' => '2', |
|
| 51 | + ), |
|
| 52 | + array( |
|
| 53 | + 'id' => 'opt-media', |
|
| 54 | + 'type' => 'media', |
|
| 55 | + 'url' => true, |
|
| 56 | + 'title' => esc_html__( 'Media w/ URL', 'your-textdomain-here' ), |
|
| 57 | + 'compiler' => 'true', |
|
| 58 | + 'desc' => esc_html__( 'Basic media uploader with disabled URL input field.', 'your-textdomain-here' ), |
|
| 59 | + 'subtitle' => esc_html__( 'Upload any media using the WordPress native uploader', 'your-textdomain-here' ), |
|
| 60 | + 'default' => array( 'url' => 'https://s.wordpress.org/style/images/codeispoetry.png' ), |
|
| 61 | + ), |
|
| 62 | + array( |
|
| 63 | + 'id' => 'gallery', |
|
| 64 | + 'type' => 'gallery', |
|
| 65 | + 'title' => esc_html__( 'Add/Edit Gallery', 'your-textdomain-here' ), |
|
| 66 | + 'subtitle' => esc_html__( 'Create a new Gallery by selecting existing or uploading new images using the WordPress native uploader', 'your-textdomain-here' ), |
|
| 67 | + 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), |
|
| 68 | + ), |
|
| 69 | + array( |
|
| 70 | + 'id' => 'opt-slider', |
|
| 71 | + 'type' => 'slider', |
|
| 72 | + 'title' => esc_html__( 'JQuery UI Slider Example 2 w/ Steps (5)', 'your-textdomain-here' ), |
|
| 73 | + 'desc' => esc_html__( 'JQuery UI slider description. Min: 0, max: 300, step: 5, default value: 75', 'your-textdomain-here' ), |
|
| 74 | + 'default' => '0', |
|
| 75 | + 'min' => '0', |
|
| 76 | + 'step' => '5', |
|
| 77 | + 'max' => '300', |
|
| 78 | + ), |
|
| 79 | + array( |
|
| 80 | + 'id' => 'opt-spinner', |
|
| 81 | + 'type' => 'spinner', |
|
| 82 | + 'title' => esc_html__( 'JQuery UI Spinner Example 1', 'your-textdomain-here' ), |
|
| 83 | + 'desc' => esc_html__( 'JQuery UI spinner description. Min:20, max: 100, step:20, default value: 40', 'your-textdomain-here' ), |
|
| 84 | + 'default' => '40', |
|
| 85 | + 'min' => '20', |
|
| 86 | + 'step' => '20', |
|
| 87 | + 'max' => '100', |
|
| 88 | + ), |
|
| 89 | 89 | |
| 90 | - array( |
|
| 91 | - 'id' => 'switch-on', |
|
| 92 | - 'type' => 'switch', |
|
| 93 | - 'title' => esc_html__( 'Switch On', 'your-textdomain-here' ), |
|
| 94 | - 'subtitle' => esc_html__( 'Look, it\'s on!', 'your-textdomain-here' ), |
|
| 95 | - 'default' => 1, |
|
| 96 | - ), |
|
| 97 | - ), |
|
| 98 | - ), |
|
| 90 | + array( |
|
| 91 | + 'id' => 'switch-on', |
|
| 92 | + 'type' => 'switch', |
|
| 93 | + 'title' => esc_html__( 'Switch On', 'your-textdomain-here' ), |
|
| 94 | + 'subtitle' => esc_html__( 'Look, it\'s on!', 'your-textdomain-here' ), |
|
| 95 | + 'default' => 1, |
|
| 96 | + ), |
|
| 97 | + ), |
|
| 98 | + ), |
|
| 99 | 99 | |
| 100 | - array( |
|
| 101 | - 'title' => esc_html__( 'Text Fields', 'your-textdomain-here' ), |
|
| 102 | - 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 103 | - 'icon' => 'el-icon-cog', |
|
| 104 | - 'id' => 'opt-text-fields', |
|
| 105 | - 'subsection' => true, |
|
| 106 | - 'fields' => array( |
|
| 107 | - array( |
|
| 108 | - 'title' => esc_html__( 'Text Field', 'your-textdomain-here' ), |
|
| 109 | - 'id' => 'opt-text', |
|
| 110 | - 'type' => 'text', |
|
| 111 | - ), |
|
| 112 | - array( |
|
| 113 | - 'title' => esc_html__( 'Textarea Field', 'your-textdomain-here' ), |
|
| 114 | - 'id' => 'opt-textarea', |
|
| 115 | - 'type' => 'textarea', |
|
| 116 | - ), |
|
| 117 | - ), |
|
| 118 | - ), |
|
| 100 | + array( |
|
| 101 | + 'title' => esc_html__( 'Text Fields', 'your-textdomain-here' ), |
|
| 102 | + 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 103 | + 'icon' => 'el-icon-cog', |
|
| 104 | + 'id' => 'opt-text-fields', |
|
| 105 | + 'subsection' => true, |
|
| 106 | + 'fields' => array( |
|
| 107 | + array( |
|
| 108 | + 'title' => esc_html__( 'Text Field', 'your-textdomain-here' ), |
|
| 109 | + 'id' => 'opt-text', |
|
| 110 | + 'type' => 'text', |
|
| 111 | + ), |
|
| 112 | + array( |
|
| 113 | + 'title' => esc_html__( 'Textarea Field', 'your-textdomain-here' ), |
|
| 114 | + 'id' => 'opt-textarea', |
|
| 115 | + 'type' => 'textarea', |
|
| 116 | + ), |
|
| 117 | + ), |
|
| 118 | + ), |
|
| 119 | 119 | |
| 120 | - array( |
|
| 121 | - 'title' => esc_html__( 'Color Field', 'your-textdomain-here' ), |
|
| 122 | - 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 123 | - 'icon' => 'el-icon-pencil', |
|
| 124 | - 'id' => 'color-section', |
|
| 125 | - 'fields' => array( |
|
| 126 | - array( |
|
| 127 | - 'id' => 'opt-color', |
|
| 128 | - 'type' => 'color', |
|
| 129 | - 'title' => esc_html__( 'Color Field', 'your-textdomain-here' ), |
|
| 130 | - 'default' => '#333333', |
|
| 131 | - 'required' => array( 'opt-layout', '=', 'on' ), |
|
| 132 | - ), |
|
| 133 | - ), |
|
| 134 | - ), |
|
| 135 | - array( |
|
| 136 | - 'title' => esc_html__( 'Layout', 'your-textdomain-here' ), |
|
| 137 | - 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 138 | - 'icon' => 'el-icon-pencil', |
|
| 139 | - 'id' => 'home-layout', |
|
| 140 | - 'fields' => array( |
|
| 141 | - array( |
|
| 142 | - 'id' => 'homepage_blocks', |
|
| 143 | - 'type' => 'sorter', |
|
| 144 | - 'title' => 'Homepage Layout Manager', |
|
| 145 | - 'desc' => 'Organize how you want the layout to appear on the homepage', |
|
| 146 | - 'compiler' => 'true', |
|
| 147 | - 'required' => array( 'layout', '=', '1' ), |
|
| 148 | - 'options' => array( |
|
| 149 | - 'enabled' => array( |
|
| 150 | - 'placebo' => 'placebo', |
|
| 151 | - 'highlights' => 'Highlights', |
|
| 152 | - 'slider' => 'Slider', |
|
| 153 | - 'staticpage' => 'Static Page', |
|
| 154 | - 'services' => 'Services', |
|
| 155 | - ), |
|
| 156 | - 'disabled' => array( |
|
| 157 | - 'placebo' => 'placebo', |
|
| 158 | - ), |
|
| 159 | - ), |
|
| 160 | - ), |
|
| 161 | - array( |
|
| 162 | - 'id' => 'slides', |
|
| 163 | - 'type' => 'slides', |
|
| 164 | - 'title' => esc_html__( 'Slides Options', 'your-textdomain-here' ), |
|
| 165 | - 'subtitle' => esc_html__( 'Unlimited slides with drag and drop sorting.', 'your-textdomain-here' ), |
|
| 166 | - 'desc' => esc_html__( 'This field will store all slides values into a multidimensional array to use into a foreach loop.', 'your-textdomain-here' ), |
|
| 167 | - ), |
|
| 168 | - ), |
|
| 169 | - ), |
|
| 170 | - ), |
|
| 171 | - ) |
|
| 120 | + array( |
|
| 121 | + 'title' => esc_html__( 'Color Field', 'your-textdomain-here' ), |
|
| 122 | + 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 123 | + 'icon' => 'el-icon-pencil', |
|
| 124 | + 'id' => 'color-section', |
|
| 125 | + 'fields' => array( |
|
| 126 | + array( |
|
| 127 | + 'id' => 'opt-color', |
|
| 128 | + 'type' => 'color', |
|
| 129 | + 'title' => esc_html__( 'Color Field', 'your-textdomain-here' ), |
|
| 130 | + 'default' => '#333333', |
|
| 131 | + 'required' => array( 'opt-layout', '=', 'on' ), |
|
| 132 | + ), |
|
| 133 | + ), |
|
| 134 | + ), |
|
| 135 | + array( |
|
| 136 | + 'title' => esc_html__( 'Layout', 'your-textdomain-here' ), |
|
| 137 | + 'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>', |
|
| 138 | + 'icon' => 'el-icon-pencil', |
|
| 139 | + 'id' => 'home-layout', |
|
| 140 | + 'fields' => array( |
|
| 141 | + array( |
|
| 142 | + 'id' => 'homepage_blocks', |
|
| 143 | + 'type' => 'sorter', |
|
| 144 | + 'title' => 'Homepage Layout Manager', |
|
| 145 | + 'desc' => 'Organize how you want the layout to appear on the homepage', |
|
| 146 | + 'compiler' => 'true', |
|
| 147 | + 'required' => array( 'layout', '=', '1' ), |
|
| 148 | + 'options' => array( |
|
| 149 | + 'enabled' => array( |
|
| 150 | + 'placebo' => 'placebo', |
|
| 151 | + 'highlights' => 'Highlights', |
|
| 152 | + 'slider' => 'Slider', |
|
| 153 | + 'staticpage' => 'Static Page', |
|
| 154 | + 'services' => 'Services', |
|
| 155 | + ), |
|
| 156 | + 'disabled' => array( |
|
| 157 | + 'placebo' => 'placebo', |
|
| 158 | + ), |
|
| 159 | + ), |
|
| 160 | + ), |
|
| 161 | + array( |
|
| 162 | + 'id' => 'slides', |
|
| 163 | + 'type' => 'slides', |
|
| 164 | + 'title' => esc_html__( 'Slides Options', 'your-textdomain-here' ), |
|
| 165 | + 'subtitle' => esc_html__( 'Unlimited slides with drag and drop sorting.', 'your-textdomain-here' ), |
|
| 166 | + 'desc' => esc_html__( 'This field will store all slides values into a multidimensional array to use into a foreach loop.', 'your-textdomain-here' ), |
|
| 167 | + ), |
|
| 168 | + ), |
|
| 169 | + ), |
|
| 170 | + ), |
|
| 171 | + ) |
|
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | 174 | |
| 175 | 175 | Redux_Metaboxes::set_box( |
| 176 | - $opt_name, |
|
| 177 | - array( |
|
| 178 | - 'id' => 'opt-metaboxes-2', |
|
| 179 | - 'post_types' => array( 'page', 'post' ), |
|
| 180 | - 'position' => 'side', // normal, advanced, side. |
|
| 181 | - 'priority' => 'high', // high, core, default, low. |
|
| 182 | - 'sections' => array( |
|
| 183 | - array( |
|
| 184 | - 'icon_class' => 'icon-large', |
|
| 185 | - 'icon' => 'el-icon-home', |
|
| 186 | - 'fields' => array( |
|
| 187 | - array( |
|
| 188 | - 'title' => esc_html__( 'Cross Box Required', 'your-textdomain-here' ), |
|
| 189 | - 'desc' => esc_html__( 'Required arguments work across metaboxes! Click on Color Field under Metabox Options then adjust this field to see the fields within show or hide.', 'your-textdomain-here' ), |
|
| 190 | - 'id' => 'opt-layout', |
|
| 191 | - 'type' => 'radio', |
|
| 192 | - 'options' => array( |
|
| 193 | - 'on' => esc_html__( 'On', 'your-textdomain-here' ), |
|
| 194 | - 'off' => esc_html__( 'Off', 'your-textdomain-here' ), |
|
| 195 | - ), |
|
| 196 | - 'default' => 'on', |
|
| 197 | - ), |
|
| 198 | - ), |
|
| 199 | - ), |
|
| 200 | - ), |
|
| 201 | - ) |
|
| 176 | + $opt_name, |
|
| 177 | + array( |
|
| 178 | + 'id' => 'opt-metaboxes-2', |
|
| 179 | + 'post_types' => array( 'page', 'post' ), |
|
| 180 | + 'position' => 'side', // normal, advanced, side. |
|
| 181 | + 'priority' => 'high', // high, core, default, low. |
|
| 182 | + 'sections' => array( |
|
| 183 | + array( |
|
| 184 | + 'icon_class' => 'icon-large', |
|
| 185 | + 'icon' => 'el-icon-home', |
|
| 186 | + 'fields' => array( |
|
| 187 | + array( |
|
| 188 | + 'title' => esc_html__( 'Cross Box Required', 'your-textdomain-here' ), |
|
| 189 | + 'desc' => esc_html__( 'Required arguments work across metaboxes! Click on Color Field under Metabox Options then adjust this field to see the fields within show or hide.', 'your-textdomain-here' ), |
|
| 190 | + 'id' => 'opt-layout', |
|
| 191 | + 'type' => 'radio', |
|
| 192 | + 'options' => array( |
|
| 193 | + 'on' => esc_html__( 'On', 'your-textdomain-here' ), |
|
| 194 | + 'off' => esc_html__( 'Off', 'your-textdomain-here' ), |
|
| 195 | + ), |
|
| 196 | + 'default' => 'on', |
|
| 197 | + ), |
|
| 198 | + ), |
|
| 199 | + ), |
|
| 200 | + ), |
|
| 201 | + ) |
|
| 202 | 202 | ); |
| 203 | 203 | |
| 204 | 204 | Redux_Metaboxes::set_box( |
| 205 | - $opt_name, |
|
| 206 | - array( |
|
| 207 | - 'id' => 'opt-metaboxes-3', |
|
| 208 | - 'post_types' => array( 'page', 'post' ), |
|
| 209 | - 'position' => 'side', // normal, advanced, side. |
|
| 210 | - 'priority' => 'high', // high, core, default, low. |
|
| 211 | - 'sections' => array( |
|
| 212 | - array( |
|
| 213 | - 'icon_class' => 'icon-large', |
|
| 214 | - 'icon' => 'el-icon-home', |
|
| 215 | - 'fields' => array( |
|
| 216 | - array( |
|
| 217 | - 'id' => 'sidebar', |
|
| 218 | - 'title' => esc_html__( 'Sidebar', 'your-textdomain-here' ), |
|
| 219 | - 'desc' => esc_html__( 'Please select the sidebar you would like to display on this page. Note: You must first create the sidebar under Appearance > Widgets.', 'your-textdomain-here' ), |
|
| 220 | - 'type' => 'select', |
|
| 221 | - 'data' => 'sidebars', |
|
| 222 | - 'default' => 'None', |
|
| 223 | - ), |
|
| 224 | - ), |
|
| 225 | - ), |
|
| 226 | - ), |
|
| 227 | - ) |
|
| 205 | + $opt_name, |
|
| 206 | + array( |
|
| 207 | + 'id' => 'opt-metaboxes-3', |
|
| 208 | + 'post_types' => array( 'page', 'post' ), |
|
| 209 | + 'position' => 'side', // normal, advanced, side. |
|
| 210 | + 'priority' => 'high', // high, core, default, low. |
|
| 211 | + 'sections' => array( |
|
| 212 | + array( |
|
| 213 | + 'icon_class' => 'icon-large', |
|
| 214 | + 'icon' => 'el-icon-home', |
|
| 215 | + 'fields' => array( |
|
| 216 | + array( |
|
| 217 | + 'id' => 'sidebar', |
|
| 218 | + 'title' => esc_html__( 'Sidebar', 'your-textdomain-here' ), |
|
| 219 | + 'desc' => esc_html__( 'Please select the sidebar you would like to display on this page. Note: You must first create the sidebar under Appearance > Widgets.', 'your-textdomain-here' ), |
|
| 220 | + 'type' => 'select', |
|
| 221 | + 'data' => 'sidebars', |
|
| 222 | + 'default' => 'None', |
|
| 223 | + ), |
|
| 224 | + ), |
|
| 225 | + ), |
|
| 226 | + ), |
|
| 227 | + ) |
|
| 228 | 228 | ); |
| 229 | 229 | // phpcs:enable |
@@ -21,47 +21,47 @@ |
||
| 21 | 21 | // Don't duplicate me! |
| 22 | 22 | if ( ! class_exists( 'Redux_Extension_My_Extension', false ) ) { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Class Redux_Extension_My_Extension |
|
| 26 | - */ |
|
| 27 | - class Redux_Extension_My_Extension extends Redux_Extension_Abstract { |
|
| 28 | - /** |
|
| 29 | - * Set extension version. |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public static string $version = '1.0.0'; |
|
| 24 | + /** |
|
| 25 | + * Class Redux_Extension_My_Extension |
|
| 26 | + */ |
|
| 27 | + class Redux_Extension_My_Extension extends Redux_Extension_Abstract { |
|
| 28 | + /** |
|
| 29 | + * Set extension version. |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public static string $version = '1.0.0'; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Set the friendly name of the extension. This is for display purposes. No underscores or dashes are required. |
|
| 37 | - * |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - private $extension_name = 'My Extension'; |
|
| 35 | + /** |
|
| 36 | + * Set the friendly name of the extension. This is for display purposes. No underscores or dashes are required. |
|
| 37 | + * |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + private $extension_name = 'My Extension'; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set the minimum required version of Redux here (optional). |
|
| 44 | - * |
|
| 45 | - * Leave blank to require no minimum version. This allows you to specify a minimum required version of |
|
| 46 | - * Redux in the event you do not want to support older versions. |
|
| 47 | - * |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 50 | - private $minimum_redux_version = '4.0.0'; |
|
| 42 | + /** |
|
| 43 | + * Set the minimum required version of Redux here (optional). |
|
| 44 | + * |
|
| 45 | + * Leave blank to require no minimum version. This allows you to specify a minimum required version of |
|
| 46 | + * Redux in the event you do not want to support older versions. |
|
| 47 | + * |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | + private $minimum_redux_version = '4.0.0'; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Redux_Extension_my_extension constructor. |
|
| 54 | - * |
|
| 55 | - * @param ReduxFramework $redux ReduxFramework pointer. |
|
| 56 | - */ |
|
| 57 | - public function __construct( $redux ) { |
|
| 58 | - parent::__construct( $redux, __FILE__ ); |
|
| 52 | + /** |
|
| 53 | + * Redux_Extension_my_extension constructor. |
|
| 54 | + * |
|
| 55 | + * @param ReduxFramework $redux ReduxFramework pointer. |
|
| 56 | + */ |
|
| 57 | + public function __construct( $redux ) { |
|
| 58 | + parent::__construct( $redux, __FILE__ ); |
|
| 59 | 59 | |
| 60 | - if ( is_admin() && ! $this->is_minimum_version( $this->minimum_redux_version, self::$version, $this->extension_name ) ) { |
|
| 61 | - return; |
|
| 62 | - } |
|
| 60 | + if ( is_admin() && ! $this->is_minimum_version( $this->minimum_redux_version, self::$version, $this->extension_name ) ) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $this->add_field( 'my_field' ); |
|
| 65 | - } |
|
| 66 | - } |
|
| 64 | + $this->add_field( 'my_field' ); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | } |