@@ -12,41 +12,41 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Extension_Js_Button' ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_Extension_Js_Button extension class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Extension_Js_Button extends Redux_Extension_Abstract { |
|
| 15 | + /** |
|
| 16 | + * Main Redux_Extension_Js_Button extension class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Extension_Js_Button extends Redux_Extension_Abstract { |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Extension version. |
|
| 24 | - * |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - public static $version = '4.3.16'; |
|
| 22 | + /** |
|
| 23 | + * Extension version. |
|
| 24 | + * |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + public static $version = '4.3.16'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Extension friendly name. |
|
| 31 | - * |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - public string $extension_name = 'JS Button'; |
|
| 29 | + /** |
|
| 30 | + * Extension friendly name. |
|
| 31 | + * |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + public string $extension_name = 'JS Button'; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Class Constructor. Defines the args for the extensions class |
|
| 38 | - * |
|
| 39 | - * @since 1.0.0 |
|
| 40 | - * @access public |
|
| 41 | - * |
|
| 42 | - * @param ReduxFramework $redux Parent settings. |
|
| 43 | - * |
|
| 44 | - * @return void |
|
| 45 | - */ |
|
| 46 | - public function __construct( $redux ) { |
|
| 47 | - parent::__construct( $redux, __FILE__ ); |
|
| 36 | + /** |
|
| 37 | + * Class Constructor. Defines the args for the extensions class |
|
| 38 | + * |
|
| 39 | + * @since 1.0.0 |
|
| 40 | + * @access public |
|
| 41 | + * |
|
| 42 | + * @param ReduxFramework $redux Parent settings. |
|
| 43 | + * |
|
| 44 | + * @return void |
|
| 45 | + */ |
|
| 46 | + public function __construct( $redux ) { |
|
| 47 | + parent::__construct( $redux, __FILE__ ); |
|
| 48 | 48 | |
| 49 | - $this->add_field( 'js_button' ); |
|
| 50 | - } |
|
| 51 | - } |
|
| 49 | + $this->add_field( 'js_button' ); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -12,34 +12,34 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Extension_Google_Maps' ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class ReduxFramework_extension_google_maps |
|
| 17 | - */ |
|
| 18 | - class Redux_Extension_Google_Maps extends Redux_Extension_Abstract { |
|
| 15 | + /** |
|
| 16 | + * Class ReduxFramework_extension_google_maps |
|
| 17 | + */ |
|
| 18 | + class Redux_Extension_Google_Maps extends Redux_Extension_Abstract { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Extension version. |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - public static $version = '4.4.19'; |
|
| 20 | + /** |
|
| 21 | + * Extension version. |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + public static $version = '4.4.19'; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Extension friendly name. |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - public string $extension_name = 'Google Maps'; |
|
| 27 | + /** |
|
| 28 | + * Extension friendly name. |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + public string $extension_name = 'Google Maps'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * ReduxFramework_extension_google_maps constructor. |
|
| 36 | - * |
|
| 37 | - * @param ReduxFramework $redux ReduxFramework object. |
|
| 38 | - */ |
|
| 39 | - public function __construct( $redux ) { |
|
| 40 | - parent::__construct( $redux, __FILE__ ); |
|
| 34 | + /** |
|
| 35 | + * ReduxFramework_extension_google_maps constructor. |
|
| 36 | + * |
|
| 37 | + * @param ReduxFramework $redux ReduxFramework object. |
|
| 38 | + */ |
|
| 39 | + public function __construct( $redux ) { |
|
| 40 | + parent::__construct( $redux, __FILE__ ); |
|
| 41 | 41 | |
| 42 | - $this->add_field( 'google_maps' ); |
|
| 43 | - } |
|
| 44 | - } |
|
| 42 | + $this->add_field( 'google_maps' ); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -14,70 +14,70 @@ |
||
| 14 | 14 | // Don't duplicate me! |
| 15 | 15 | if ( ! class_exists( 'Redux_Extension_Multi_Media' ) ) { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Main Redux_Extension_multi_media extension class |
|
| 19 | - * |
|
| 20 | - * @since 1.0.0 |
|
| 21 | - */ |
|
| 22 | - class Redux_Extension_Multi_Media extends Redux_Extension_Abstract { |
|
| 17 | + /** |
|
| 18 | + * Main Redux_Extension_multi_media extension class |
|
| 19 | + * |
|
| 20 | + * @since 1.0.0 |
|
| 21 | + */ |
|
| 22 | + class Redux_Extension_Multi_Media extends Redux_Extension_Abstract { |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Extension version. |
|
| 26 | - * |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 29 | - public static $version = '4.4.1'; |
|
| 24 | + /** |
|
| 25 | + * Extension version. |
|
| 26 | + * |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | + public static $version = '4.4.1'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Extension name. |
|
| 33 | - * |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - public string $extension_name = 'Multi Media'; |
|
| 31 | + /** |
|
| 32 | + * Extension name. |
|
| 33 | + * |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + public string $extension_name = 'Multi Media'; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Class Constructor. Defines the args for the extensions class |
|
| 40 | - * |
|
| 41 | - * @since 1.0.0 |
|
| 42 | - * @access public |
|
| 43 | - * |
|
| 44 | - * @param ReduxFramework $redux Parent settings. |
|
| 45 | - * |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 48 | - public function __construct( $redux ) { |
|
| 49 | - parent::__construct( $redux, __FILE__ ); |
|
| 38 | + /** |
|
| 39 | + * Class Constructor. Defines the args for the extensions class |
|
| 40 | + * |
|
| 41 | + * @since 1.0.0 |
|
| 42 | + * @access public |
|
| 43 | + * |
|
| 44 | + * @param ReduxFramework $redux Parent settings. |
|
| 45 | + * |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | + public function __construct( $redux ) { |
|
| 49 | + parent::__construct( $redux, __FILE__ ); |
|
| 50 | 50 | |
| 51 | - $this->add_field( 'multi_media' ); |
|
| 52 | - } |
|
| 51 | + $this->add_field( 'multi_media' ); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get extended image data. |
|
| 56 | - * |
|
| 57 | - * @param int|string $id image ID. |
|
| 58 | - * |
|
| 59 | - * @return array|null |
|
| 60 | - * @depreacted Remove camelCase function name. |
|
| 61 | - */ |
|
| 62 | - public static function getExtendedData( $id ): ?array { |
|
| 63 | - _deprecated_function( 'getExtendedData', '4.3.15', 'Redux_Extension_Multi_Media::get_extended_data( $id )' ); |
|
| 54 | + /** |
|
| 55 | + * Get extended image data. |
|
| 56 | + * |
|
| 57 | + * @param int|string $id image ID. |
|
| 58 | + * |
|
| 59 | + * @return array|null |
|
| 60 | + * @depreacted Remove camelCase function name. |
|
| 61 | + */ |
|
| 62 | + public static function getExtendedData( $id ): ?array { |
|
| 63 | + _deprecated_function( 'getExtendedData', '4.3.15', 'Redux_Extension_Multi_Media::get_extended_data( $id )' ); |
|
| 64 | 64 | |
| 65 | - return self::get_extended_data( $id ); |
|
| 66 | - } |
|
| 65 | + return self::get_extended_data( $id ); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Get extended image data. |
|
| 70 | - * |
|
| 71 | - * @param int|string $id image ID. |
|
| 72 | - * |
|
| 73 | - * @return array|null |
|
| 74 | - */ |
|
| 75 | - public static function get_extended_data( $id ): ?array { |
|
| 76 | - if ( '' !== $id && is_numeric( $id ) ) { |
|
| 77 | - return wp_prepare_attachment_for_js( $id ); |
|
| 78 | - } |
|
| 68 | + /** |
|
| 69 | + * Get extended image data. |
|
| 70 | + * |
|
| 71 | + * @param int|string $id image ID. |
|
| 72 | + * |
|
| 73 | + * @return array|null |
|
| 74 | + */ |
|
| 75 | + public static function get_extended_data( $id ): ?array { |
|
| 76 | + if ( '' !== $id && is_numeric( $id ) ) { |
|
| 77 | + return wp_prepare_attachment_for_js( $id ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - return null; |
|
| 81 | - } |
|
| 82 | - } |
|
| 80 | + return null; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -14,46 +14,46 @@ |
||
| 14 | 14 | |
| 15 | 15 | if ( ! class_exists( 'Redux_Extension_Widget_Areas' ) ) { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Class Redux_Extension_Widget_Areas |
|
| 19 | - */ |
|
| 20 | - class Redux_Extension_Widget_Areas extends Redux_Extension_Abstract { |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Extension version. |
|
| 24 | - * |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - public static $version = '4.3.20'; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Extension Friendly name. |
|
| 31 | - * |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - public string $extension_name = 'Widget Areas'; |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Redux_Extension_Widget_Areas constructor. |
|
| 39 | - * |
|
| 40 | - * @param ReduxFramework $redux ReduxFramework object pointer. |
|
| 41 | - */ |
|
| 42 | - public function __construct( $redux ) { |
|
| 43 | - parent::__construct( $redux, __FILE__ ); |
|
| 44 | - |
|
| 45 | - $this->add_field( 'widget_areas' ); |
|
| 46 | - |
|
| 47 | - require_once __DIR__ . '/class-redux-widget-areas.php'; |
|
| 48 | - $widget_areas = new Redux_Widget_Areas( $this->parent ); |
|
| 49 | - |
|
| 50 | - // Allow users to extend if they want. |
|
| 51 | - // Phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 52 | - do_action( 'redux/widget_areas/' . $redux->args['opt_name'] . '/construct' ); |
|
| 53 | - |
|
| 54 | - add_action( 'wp_ajax_redux_delete_widget_area', array( $widget_areas, 'redux_delete_widget_area_area' ) ); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - class_alias( Redux_Extension_Widget_Areas::class, 'ReduxFramework_extension_widget_areas' ); |
|
| 17 | + /** |
|
| 18 | + * Class Redux_Extension_Widget_Areas |
|
| 19 | + */ |
|
| 20 | + class Redux_Extension_Widget_Areas extends Redux_Extension_Abstract { |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Extension version. |
|
| 24 | + * |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + public static $version = '4.3.20'; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Extension Friendly name. |
|
| 31 | + * |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + public string $extension_name = 'Widget Areas'; |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Redux_Extension_Widget_Areas constructor. |
|
| 39 | + * |
|
| 40 | + * @param ReduxFramework $redux ReduxFramework object pointer. |
|
| 41 | + */ |
|
| 42 | + public function __construct( $redux ) { |
|
| 43 | + parent::__construct( $redux, __FILE__ ); |
|
| 44 | + |
|
| 45 | + $this->add_field( 'widget_areas' ); |
|
| 46 | + |
|
| 47 | + require_once __DIR__ . '/class-redux-widget-areas.php'; |
|
| 48 | + $widget_areas = new Redux_Widget_Areas( $this->parent ); |
|
| 49 | + |
|
| 50 | + // Allow users to extend if they want. |
|
| 51 | + // Phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 52 | + do_action( 'redux/widget_areas/' . $redux->args['opt_name'] . '/construct' ); |
|
| 53 | + |
|
| 54 | + add_action( 'wp_ajax_redux_delete_widget_area', array( $widget_areas, 'redux_delete_widget_area_area' ) ); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + class_alias( Redux_Extension_Widget_Areas::class, 'ReduxFramework_extension_widget_areas' ); |
|
| 59 | 59 | } |
@@ -15,39 +15,39 @@ |
||
| 15 | 15 | if ( ! class_exists( 'Redux_Extension_Tabbed' ) ) { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Class Redux_Extension_Tabbed |
|
| 20 | - */ |
|
| 21 | - class Redux_Extension_Tabbed extends Redux_Extension_Abstract { |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Extension version. |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - public static $version = '4.4.8'; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Extension friendly name. |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public string $extension_name = 'Tabbed'; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Class Constructor. Defines the args for the extensions class |
|
| 39 | - * |
|
| 40 | - * @since 1.0.0 |
|
| 41 | - * @access public |
|
| 42 | - * |
|
| 43 | - * @param object $redux Parent settings. |
|
| 44 | - * |
|
| 45 | - * @return void |
|
| 46 | - */ |
|
| 47 | - public function __construct( $redux ) { |
|
| 48 | - parent::__construct( $redux, __FILE__ ); |
|
| 49 | - |
|
| 50 | - $this->add_field( 'tabbed' ); |
|
| 51 | - } |
|
| 52 | - } |
|
| 18 | + /** |
|
| 19 | + * Class Redux_Extension_Tabbed |
|
| 20 | + */ |
|
| 21 | + class Redux_Extension_Tabbed extends Redux_Extension_Abstract { |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Extension version. |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + public static $version = '4.4.8'; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Extension friendly name. |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public string $extension_name = 'Tabbed'; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Class Constructor. Defines the args for the extensions class |
|
| 39 | + * |
|
| 40 | + * @since 1.0.0 |
|
| 41 | + * @access public |
|
| 42 | + * |
|
| 43 | + * @param object $redux Parent settings. |
|
| 44 | + * |
|
| 45 | + * @return void |
|
| 46 | + */ |
|
| 47 | + public function __construct( $redux ) { |
|
| 48 | + parent::__construct( $redux, __FILE__ ); |
|
| 49 | + |
|
| 50 | + $this->add_field( 'tabbed' ); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -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 | } |