@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | 40 | |
41 | - add_action( 'customize_controls_print_footer_scripts', [ $this, 'customize_controls_print_footer_scripts' ] ); |
|
42 | - add_filter( 'kirki_field_add_control_args', [ $this, 'filter_control_args' ], 10, 2 ); |
|
41 | + add_action('customize_controls_print_footer_scripts', [$this, 'customize_controls_print_footer_scripts']); |
|
42 | + add_filter('kirki_field_add_control_args', [$this, 'filter_control_args'], 10, 2); |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function customize_controls_print_footer_scripts() { |
53 | 53 | |
54 | - wp_enqueue_style( 'kirki-tooltip', URL::get_from_path( dirname( __DIR__ ) . '/dist/control.css' ), [], '1.0.10' ); |
|
54 | + wp_enqueue_style('kirki-tooltip', URL::get_from_path(dirname(__DIR__) . '/dist/control.css'), [], '1.0.10'); |
|
55 | 55 | |
56 | - wp_enqueue_script( 'kirki-tooltip', URL::get_from_path( dirname( __DIR__ ) . '/dist/control.js' ), [ 'jquery' ], '1.0.10', false ); |
|
57 | - wp_localize_script( 'kirki-tooltip', 'kirkiTooltips', $this->tooltips_content ); |
|
56 | + wp_enqueue_script('kirki-tooltip', URL::get_from_path(dirname(__DIR__) . '/dist/control.js'), ['jquery'], '1.0.10', false); |
|
57 | + wp_localize_script('kirki-tooltip', 'kirkiTooltips', $this->tooltips_content); |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
68 | 68 | * @return array |
69 | 69 | */ |
70 | - public function filter_control_args( $args, $wp_customize ) { |
|
71 | - if ( isset( $args['tooltip'] ) && $args['tooltip'] ) { |
|
72 | - $this->tooltips_content[ $args['settings'] ] = [ |
|
73 | - 'id' => sanitize_key( $args['settings'] ), |
|
74 | - 'content' => wp_kses_post( $args['tooltip'] ), |
|
70 | + public function filter_control_args($args, $wp_customize) { |
|
71 | + if (isset($args['tooltip']) && $args['tooltip']) { |
|
72 | + $this->tooltips_content[$args['settings']] = [ |
|
73 | + 'id' => sanitize_key($args['settings']), |
|
74 | + 'content' => wp_kses_post($args['tooltip']), |
|
75 | 75 | ]; |
76 | 76 | } |
77 | 77 | return $args; |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @since 1.0.0 |
45 | 45 | */ |
46 | 46 | public function __construct() { |
47 | - add_action( 'wp_ajax_kirki_fonts_google_all_get', [ $this, 'print_googlefonts_json' ] ); |
|
48 | - add_action( 'wp_ajax_nopriv_kirki_fonts_google_all_get', [ $this, 'print_googlefonts_json' ] ); |
|
47 | + add_action('wp_ajax_kirki_fonts_google_all_get', [$this, 'print_googlefonts_json']); |
|
48 | + add_action('wp_ajax_nopriv_kirki_fonts_google_all_get', [$this, 'print_googlefonts_json']); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @param bool $die Whether the script should exit or not. |
56 | 56 | * @return void |
57 | 57 | */ |
58 | - public function print_googlefonts_json( $die = true ) { |
|
58 | + public function print_googlefonts_json($die = true) { |
|
59 | 59 | include 'webfonts.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
60 | - if ( function_exists( 'wp_die' ) && $die ) { |
|
60 | + if (function_exists('wp_die') && $die) { |
|
61 | 61 | wp_die(); |
62 | 62 | } |
63 | 63 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function get_array() { |
72 | 72 | ob_start(); |
73 | 73 | include 'webfonts.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
74 | - return json_decode( ob_get_clean(), true ); |
|
74 | + return json_decode(ob_get_clean(), true); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function get_names_array() { |
84 | 84 | ob_start(); |
85 | 85 | include 'webfont-names.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
86 | - return json_decode( ob_get_clean(), true ); |
|
86 | + return json_decode(ob_get_clean(), true); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | public function get_google_fonts() { |
97 | 97 | |
98 | 98 | // Get fonts from cache. |
99 | - self::$google_fonts = get_site_transient( 'kirki_googlefonts_cache' ); |
|
99 | + self::$google_fonts = get_site_transient('kirki_googlefonts_cache'); |
|
100 | 100 | |
101 | 101 | // If cache is populated, return cached fonts array. |
102 | - if ( self::$google_fonts ) { |
|
102 | + if (self::$google_fonts) { |
|
103 | 103 | return self::$google_fonts; |
104 | 104 | } |
105 | 105 | |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | $fonts = $this->get_array(); |
108 | 108 | |
109 | 109 | self::$google_fonts = []; |
110 | - if ( is_array( $fonts ) ) { |
|
111 | - foreach ( $fonts['items'] as $font ) { |
|
112 | - self::$google_fonts[ $font['family'] ] = [ |
|
110 | + if (is_array($fonts)) { |
|
111 | + foreach ($fonts['items'] as $font) { |
|
112 | + self::$google_fonts[$font['family']] = [ |
|
113 | 113 | 'label' => $font['family'], |
114 | 114 | 'variants' => $font['variants'], |
115 | 115 | 'category' => $font['category'], |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | // Apply the 'kirki_fonts_google_fonts' filter. |
121 | - self::$google_fonts = apply_filters( 'kirki_fonts_google_fonts', self::$google_fonts ); |
|
121 | + self::$google_fonts = apply_filters('kirki_fonts_google_fonts', self::$google_fonts); |
|
122 | 122 | |
123 | 123 | // Save the array in cache. |
124 | - $cache_time = apply_filters( 'kirki_googlefonts_transient_time', HOUR_IN_SECONDS ); |
|
125 | - set_site_transient( 'kirki_googlefonts_cache', self::$google_fonts, $cache_time ); |
|
124 | + $cache_time = apply_filters('kirki_googlefonts_transient_time', HOUR_IN_SECONDS); |
|
125 | + set_site_transient('kirki_googlefonts_cache', self::$google_fonts, $cache_time); |
|
126 | 126 | |
127 | 127 | return self::$google_fonts; |
128 | 128 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | public function get_google_font_names() { |
138 | 138 | |
139 | 139 | // Get fonts from cache. |
140 | - self::$google_font_names = get_site_transient( 'kirki_googlefont_names_cache' ); |
|
140 | + self::$google_font_names = get_site_transient('kirki_googlefont_names_cache'); |
|
141 | 141 | |
142 | 142 | // If cache is populated, return cached fonts array. |
143 | - if ( self::$google_font_names ) { |
|
143 | + if (self::$google_font_names) { |
|
144 | 144 | return self::$google_font_names; |
145 | 145 | } |
146 | 146 | |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | self::$google_font_names = $this->get_names_array(); |
149 | 149 | |
150 | 150 | // Apply the 'kirki_fonts_google_font_names' filter. |
151 | - self::$google_font_names = apply_filters( 'kirki_fonts_google_font_names', self::$google_font_names ); |
|
151 | + self::$google_font_names = apply_filters('kirki_fonts_google_font_names', self::$google_font_names); |
|
152 | 152 | |
153 | 153 | // Save the array in cache. |
154 | - $cache_time = apply_filters( 'kirki_googlefont_names_transient_time', HOUR_IN_SECONDS ); |
|
155 | - set_site_transient( 'kirki_googlefont_names_cache', self::$google_font_names, $cache_time ); |
|
154 | + $cache_time = apply_filters('kirki_googlefont_names_transient_time', HOUR_IN_SECONDS); |
|
155 | + set_site_transient('kirki_googlefont_names_cache', self::$google_font_names, $cache_time); |
|
156 | 156 | |
157 | 157 | return self::$google_font_names; |
158 | 158 | } |
@@ -165,23 +165,23 @@ discard block |
||
165 | 165 | * @param array $args The arguments. |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - public function get_google_fonts_by_args( $args = [] ) { |
|
169 | - $cache_name = 'kirki_googlefonts_' . md5( wp_json_encode( $args ) ); |
|
170 | - $cache = get_site_transient( $cache_name ); |
|
171 | - if ( $cache ) { |
|
168 | + public function get_google_fonts_by_args($args = []) { |
|
169 | + $cache_name = 'kirki_googlefonts_' . md5(wp_json_encode($args)); |
|
170 | + $cache = get_site_transient($cache_name); |
|
171 | + if ($cache) { |
|
172 | 172 | return $cache; |
173 | 173 | } |
174 | 174 | |
175 | - $args['sort'] = isset( $args['sort'] ) ? $args['sort'] : 'alpha'; |
|
175 | + $args['sort'] = isset($args['sort']) ? $args['sort'] : 'alpha'; |
|
176 | 176 | |
177 | 177 | $fonts = $this->get_array(); |
178 | - $ordered_fonts = $fonts['order'][ $args['sort'] ]; |
|
179 | - if ( isset( $args['count'] ) ) { |
|
180 | - $ordered_fonts = array_slice( $ordered_fonts, 0, $args['count'] ); |
|
181 | - set_site_transient( $cache_name, $ordered_fonts, HOUR_IN_SECONDS ); |
|
178 | + $ordered_fonts = $fonts['order'][$args['sort']]; |
|
179 | + if (isset($args['count'])) { |
|
180 | + $ordered_fonts = array_slice($ordered_fonts, 0, $args['count']); |
|
181 | + set_site_transient($cache_name, $ordered_fonts, HOUR_IN_SECONDS); |
|
182 | 182 | return $ordered_fonts; |
183 | 183 | } |
184 | - set_site_transient( $cache_name, $ordered_fonts, HOUR_IN_SECONDS ); |
|
184 | + set_site_transient($cache_name, $ordered_fonts, HOUR_IN_SECONDS); |
|
185 | 185 | return $ordered_fonts; |
186 | 186 | } |
187 | 187 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function __construct() { |
37 | 37 | |
38 | - add_action( 'customize_controls_enqueue_scripts', [ $this, 'field_dependencies' ] ); |
|
39 | - add_filter( 'kirki_field_add_control_args', [ $this, 'field_add_control_args' ] ); |
|
38 | + add_action('customize_controls_enqueue_scripts', [$this, 'field_dependencies']); |
|
39 | + add_filter('kirki_field_add_control_args', [$this, 'field_add_control_args']); |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
@@ -48,43 +48,43 @@ discard block |
||
48 | 48 | * @param array $args The field arguments. |
49 | 49 | * @return array |
50 | 50 | */ |
51 | - public function field_add_control_args( $args ) { |
|
51 | + public function field_add_control_args($args) { |
|
52 | 52 | |
53 | - if ( isset( $args['active_callback'] ) ) { |
|
54 | - if ( is_array( $args['active_callback'] ) ) { |
|
55 | - if ( ! is_callable( $args['active_callback'] ) ) { |
|
53 | + if (isset($args['active_callback'])) { |
|
54 | + if (is_array($args['active_callback'])) { |
|
55 | + if (!is_callable($args['active_callback'])) { |
|
56 | 56 | |
57 | 57 | // Bugfix for https://github.com/aristath/kirki/issues/1961. |
58 | - foreach ( $args['active_callback'] as $key => $val ) { |
|
59 | - if ( is_callable( $val ) ) { |
|
60 | - unset( $args['active_callback'][ $key ] ); |
|
58 | + foreach ($args['active_callback'] as $key => $val) { |
|
59 | + if (is_callable($val)) { |
|
60 | + unset($args['active_callback'][$key]); |
|
61 | 61 | } |
62 | 62 | } |
63 | - if ( isset( $args['active_callback'][0] ) ) { |
|
63 | + if (isset($args['active_callback'][0])) { |
|
64 | 64 | $args['required'] = $args['active_callback']; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - if ( ! empty( $args['required'] ) ) { |
|
70 | - $this->dependencies[ $args['settings'] ] = $args['required']; |
|
69 | + if (!empty($args['required'])) { |
|
70 | + $this->dependencies[$args['settings']] = $args['required']; |
|
71 | 71 | $args['active_callback'] = '__return_true'; |
72 | 72 | return $args; |
73 | 73 | } |
74 | 74 | |
75 | 75 | // No need to proceed any further if we're using the default value. |
76 | - if ( '__return_true' === $args['active_callback'] ) { |
|
76 | + if ('__return_true' === $args['active_callback']) { |
|
77 | 77 | return $args; |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Make sure the function is callable, otherwise fallback to __return_true. |
81 | - if ( ! is_callable( $args['active_callback'] ) ) { |
|
81 | + if (!is_callable($args['active_callback'])) { |
|
82 | 82 | $args['active_callback'] = '__return_true'; |
83 | 83 | } |
84 | 84 | } else { |
85 | 85 | // The ReactSelect field triggered from Background field doesn't have $args['active_callback'] argument. |
86 | - if ( ! empty( $args['required'] ) ) { |
|
87 | - $this->dependencies[ $args['settings'] ] = $args['required']; |
|
86 | + if (!empty($args['required'])) { |
|
87 | + $this->dependencies[$args['settings']] = $args['required']; |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function field_dependencies() { |
104 | 104 | |
105 | - wp_enqueue_script( 'kirki_field_dependencies', URL::get_from_path( dirname( __DIR__ ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'customize-controls' ], '4.0', true ); |
|
106 | - wp_localize_script( 'kirki_field_dependencies', 'kirkiControlDependencies', $this->dependencies ); |
|
105 | + wp_enqueue_script('kirki_field_dependencies', URL::get_from_path(dirname(__DIR__) . '/dist/control.js'), ['jquery', 'customize-base', 'customize-controls'], '4.0', true); |
|
106 | + wp_localize_script('kirki_field_dependencies', 'kirkiControlDependencies', $this->dependencies); |
|
107 | 107 | |
108 | 108 | } |
109 | 109 | } |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | * @param string $path Absolute path to a file. |
79 | 79 | * @return URL An instance of this object. |
80 | 80 | */ |
81 | - public static function get_instance( $path ) { |
|
82 | - $path = \wp_normalize_path( $path ); |
|
83 | - if ( ! isset( self::$instances[ $path ] ) ) { |
|
84 | - self::$instances[ $path ] = new self( $path ); |
|
81 | + public static function get_instance($path) { |
|
82 | + $path = \wp_normalize_path($path); |
|
83 | + if (!isset(self::$instances[$path])) { |
|
84 | + self::$instances[$path] = new self($path); |
|
85 | 85 | } |
86 | - return self::$instances[ $path ]; |
|
86 | + return self::$instances[$path]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @since 1.0 |
94 | 94 | * @param string $path Absolute path to a file. |
95 | 95 | */ |
96 | - private function __construct( $path ) { |
|
97 | - $this->path = ( $path ); |
|
96 | + private function __construct($path) { |
|
97 | + $this->path = ($path); |
|
98 | 98 | $this->set_content_url(); |
99 | 99 | $this->set_content_path(); |
100 | 100 | } |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param string $path The file path. |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - public static function get_from_path( $path ) { |
|
112 | - return self::get_instance( $path )->get_url(); |
|
111 | + public static function get_from_path($path) { |
|
112 | + return self::get_instance($path)->get_url(); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -125,32 +125,32 @@ discard block |
||
125 | 125 | * Start by replacing ABSPATH with site_url. |
126 | 126 | * This is not accurate at all and only serves as a fallback in case everything else fails. |
127 | 127 | */ |
128 | - $this->url = \str_replace( ABSPATH, \trailingslashit( \site_url() ), $this->path ); |
|
128 | + $this->url = \str_replace(ABSPATH, \trailingslashit(\site_url()), $this->path); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * If the file-path is inside wp-content replace the content-path with the content-url. |
132 | 132 | * This serves as a fallback in case the other tests below fail. |
133 | 133 | */ |
134 | - if ( false !== \strpos( $this->path, self::$content_path ) ) { |
|
135 | - $this->url = \str_replace( self::$content_path, self::$content_url, $this->path ); |
|
134 | + if (false !== \strpos($this->path, self::$content_path)) { |
|
135 | + $this->url = \str_replace(self::$content_path, self::$content_url, $this->path); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * If the file is in a parent theme use the template directory. |
140 | 140 | */ |
141 | - if ( $this->in_parent_theme() ) { |
|
142 | - $this->url = \get_template_directory_uri() . \str_replace( \get_template_directory(), '', $this->path ); |
|
141 | + if ($this->in_parent_theme()) { |
|
142 | + $this->url = \get_template_directory_uri() . \str_replace(\get_template_directory(), '', $this->path); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * If the file is in a child-theme use the stylesheet directory. |
147 | 147 | */ |
148 | - if ( ! $this->in_parent_theme() && $this->in_child_theme() ) { |
|
149 | - $this->url = \get_stylesheet_directory_uri() . \str_replace( \get_stylesheet_directory(), '', $this->path ); |
|
148 | + if (!$this->in_parent_theme() && $this->in_child_theme()) { |
|
149 | + $this->url = \get_stylesheet_directory_uri() . \str_replace(\get_stylesheet_directory(), '', $this->path); |
|
150 | 150 | } |
151 | 151 | |
152 | - $this->url = \set_url_scheme( $this->url ); |
|
153 | - return \apply_filters( 'kirki_path_url', $this->url, $this->path ); |
|
152 | + $this->url = \set_url_scheme($this->url); |
|
153 | + return \apply_filters('kirki_path_url', $this->url, $this->path); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @return bool |
162 | 162 | */ |
163 | 163 | public function in_parent_theme() { |
164 | - return ( 0 === \strpos( $this->path, \get_template_directory() ) ); |
|
164 | + return (0 === \strpos($this->path, \get_template_directory())); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return bool |
173 | 173 | */ |
174 | 174 | public function in_child_theme() { |
175 | - return ( 0 === \strpos( $this->path, \get_stylesheet_directory() ) ); |
|
175 | + return (0 === \strpos($this->path, \get_stylesheet_directory())); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | * @return void |
184 | 184 | */ |
185 | 185 | private function set_content_url() { |
186 | - if ( ! self::$content_url ) { |
|
187 | - self::$content_url = \untrailingslashit( \content_url() ); |
|
186 | + if (!self::$content_url) { |
|
187 | + self::$content_url = \untrailingslashit(\content_url()); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @return void |
197 | 197 | */ |
198 | 198 | private function set_content_path() { |
199 | - if ( ! self::$content_path ) { |
|
200 | - self::$content_path = \wp_normalize_path( \untrailingslashit( WP_CONTENT_DIR ) ); |
|
199 | + if (!self::$content_path) { |
|
200 | + self::$content_path = \wp_normalize_path(\untrailingslashit(WP_CONTENT_DIR)); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return array $args The maybe-filtered arguments. |
55 | 55 | */ |
56 | - public function filter_setting_args( $args, $wp_customize ) { |
|
56 | + public function filter_setting_args($args, $wp_customize) { |
|
57 | 57 | |
58 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
59 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
58 | + if ($args['settings'] === $this->args['settings']) { |
|
59 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
60 | 60 | |
61 | 61 | // Set the sanitize_callback if none is defined. |
62 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
63 | - $args['sanitize_callback'] = [ __CLASS__, 'sanitize' ]; |
|
62 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
63 | + $args['sanitize_callback'] = [__CLASS__, 'sanitize']; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array $args The maybe-filtered arguments. |
78 | 78 | */ |
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
79 | + public function filter_control_args($args, $wp_customize) { |
|
80 | 80 | |
81 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
82 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
81 | + if ($args['settings'] === $this->args['settings']) { |
|
82 | + $args = parent::filter_control_args($args, $wp_customize); |
|
83 | 83 | $args['type'] = 'kirki-color-palette'; |
84 | 84 | } |
85 | 85 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param string $value The color. |
97 | 97 | * @return string |
98 | 98 | */ |
99 | - public static function sanitize( $value ) { |
|
99 | + public static function sanitize($value) { |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * This pattern will check and match 3/6/8-character hex, rgb, rgba, hsl, hsla, hsv, and hsva colors. |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | */ |
128 | 128 | $pattern = '/^(\#[\da-f]{3}|\#[\da-f]{6}|\#[\da-f]{8}|rgba\(((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*,\s*){2}((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*)(,\s*(0\.\d+|1))\)|rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|hsla\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsl\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\)|hsva\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsv\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\))$/'; |
129 | 129 | |
130 | - \preg_match( $pattern, $value, $matches ); |
|
130 | + \preg_match($pattern, $value, $matches); |
|
131 | 131 | |
132 | 132 | // Return the 1st match found. |
133 | - if ( isset( $matches[0] ) ) { |
|
134 | - if ( is_string( $matches[0] ) ) { |
|
133 | + if (isset($matches[0])) { |
|
134 | + if (is_string($matches[0])) { |
|
135 | 135 | return $matches[0]; |
136 | 136 | } |
137 | 137 | |
138 | - if ( is_array( $matches[0] ) && isset( $matches[0][0] ) ) { |
|
138 | + if (is_array($matches[0]) && isset($matches[0][0])) { |
|
139 | 139 | return $matches[0][0]; |
140 | 140 | } |
141 | 141 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | parent::enqueue(); |
51 | 51 | |
52 | 52 | // Enqueue the style. |
53 | - wp_enqueue_style( 'kirki-color-palette-control', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
53 | + wp_enqueue_style('kirki-color-palette-control', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
54 | 54 | |
55 | 55 | // Enqueue the script. |
56 | - wp_enqueue_script( 'kirki-color-palette-control', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-controls', 'customize-base', 'react-dom' ], self::$control_ver, false ); |
|
56 | + wp_enqueue_script('kirki-color-palette-control', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-controls', 'customize-base', 'react-dom'], self::$control_ver, false); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | |
70 | 70 | parent::to_json(); |
71 | 71 | |
72 | - if ( isset( $this->json['label'] ) ) { |
|
73 | - $this->json['label'] = html_entity_decode( $this->json['label'] ); |
|
72 | + if (isset($this->json['label'])) { |
|
73 | + $this->json['label'] = html_entity_decode($this->json['label']); |
|
74 | 74 | } |
75 | 75 | |
76 | - if ( isset( $this->json['description'] ) ) { |
|
77 | - $this->json['description'] = html_entity_decode( $this->json['description'] ); |
|
76 | + if (isset($this->json['description'])) { |
|
77 | + $this->json['description'] = html_entity_decode($this->json['description']); |
|
78 | 78 | } |
79 | 79 | |
80 | - $this->json['value'] = strtolower( $this->json['value'] ); |
|
80 | + $this->json['value'] = strtolower($this->json['value']); |
|
81 | 81 | |
82 | 82 | $choices = $this->json['choices']; |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | ] |
91 | 91 | ); |
92 | 92 | |
93 | - $this->json['choices']['colors'] = array_map( 'strtolower', $this->json['choices']['colors'] ); |
|
93 | + $this->json['choices']['colors'] = array_map('strtolower', $this->json['choices']['colors']); |
|
94 | 94 | |
95 | - if ( isset( $choices['style'] ) && ! empty( $choices['style'] ) ) { |
|
96 | - if ( ! isset( $choices['shape'] ) || empty( $choices['shape'] ) ) { |
|
95 | + if (isset($choices['style']) && !empty($choices['style'])) { |
|
96 | + if (!isset($choices['shape']) || empty($choices['shape'])) { |
|
97 | 97 | $this->json['choices']['shape'] = $choices['style']; |
98 | 98 | } |
99 | 99 | |
100 | - unset( $this->json['choices']['style'] ); |
|
100 | + unset($this->json['choices']['style']); |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( ! is_numeric( $this->json['choices']['size'] ) ) { |
|
103 | + if (!is_numeric($this->json['choices']['size'])) { |
|
104 | 104 | $this->json['choices']['size'] = 28; |
105 | 105 | } |
106 | 106 |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function __construct() { |
55 | 55 | |
56 | - add_action( 'customize_controls_enqueue_scripts', [ $this, 'customize_controls_enqueue_scripts' ], 99 ); |
|
57 | - add_action( 'kirki_panel_added', [ $this, 'panel_added' ], 10, 2 ); |
|
58 | - add_action( 'kirki_section_added', [ $this, 'section_added' ], 10, 2 ); |
|
56 | + add_action('customize_controls_enqueue_scripts', [$this, 'customize_controls_enqueue_scripts'], 99); |
|
57 | + add_action('kirki_panel_added', [$this, 'panel_added'], 10, 2); |
|
58 | + add_action('kirki_section_added', [$this, 'section_added'], 10, 2); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * @param string $icon The icon to add. |
69 | 69 | * @param string $context Lowercase 'section' or 'panel'. |
70 | 70 | */ |
71 | - public function add_icon( $id, $icon, $context = 'section' ) { |
|
71 | + public function add_icon($id, $icon, $context = 'section') { |
|
72 | 72 | |
73 | - self::$icons[ $context ][ $id ] = trim( $icon ); |
|
73 | + self::$icons[$context][$id] = trim($icon); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @param string $id The panel ID. |
83 | 83 | * @param array $args The panel arguments. |
84 | 84 | */ |
85 | - public function panel_added( $id, $args ) { |
|
85 | + public function panel_added($id, $args) { |
|
86 | 86 | |
87 | - if ( isset( $args['icon'] ) ) { |
|
87 | + if (isset($args['icon'])) { |
|
88 | 88 | $args['id'] = $id; |
89 | 89 | $this->panels[] = $args; |
90 | 90 | } |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * @param string $id The section ID. |
100 | 100 | * @param array $args The section arguments. |
101 | 101 | */ |
102 | - public function section_added( $id, $args ) { |
|
102 | + public function section_added($id, $args) { |
|
103 | 103 | |
104 | - if ( isset( $args['icon'] ) ) { |
|
104 | + if (isset($args['icon'])) { |
|
105 | 105 | $args['id'] = $id; |
106 | 106 | $this->sections[] = $args; |
107 | 107 | } |
@@ -114,17 +114,17 @@ discard block |
||
114 | 114 | public function customize_controls_enqueue_scripts() { |
115 | 115 | |
116 | 116 | // Parse panels and find ones with icons. |
117 | - foreach ( $this->panels as $panel ) { |
|
118 | - $this->add_icon( $panel['id'], $panel['icon'], 'panel' ); |
|
117 | + foreach ($this->panels as $panel) { |
|
118 | + $this->add_icon($panel['id'], $panel['icon'], 'panel'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // Parse sections and find ones with icons. |
122 | - foreach ( $this->sections as $section ) { |
|
123 | - $this->add_icon( $section['id'], $section['icon'], 'section' ); |
|
122 | + foreach ($this->sections as $section) { |
|
123 | + $this->add_icon($section['id'], $section['icon'], 'section'); |
|
124 | 124 | } |
125 | 125 | |
126 | - wp_enqueue_script( 'kirki_panel_and_section_icons', URL::get_from_path( __DIR__ . '/icons.js' ), [ 'jquery', 'customize-base', 'customize-controls' ], '1.0', true ); |
|
127 | - wp_localize_script( 'kirki_panel_and_section_icons', 'kirkiIcons', self::$icons ); |
|
126 | + wp_enqueue_script('kirki_panel_and_section_icons', URL::get_from_path(__DIR__ . '/icons.js'), ['jquery', 'customize-base', 'customize-controls'], '1.0', true); |
|
127 | + wp_localize_script('kirki_panel_and_section_icons', 'kirkiIcons', self::$icons); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 |
@@ -33,15 +33,15 @@ |
||
33 | 33 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
34 | 34 | * @return array |
35 | 35 | */ |
36 | - public function filter_control_args( $args, $wp_customize ) { |
|
37 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
38 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
36 | + public function filter_control_args($args, $wp_customize) { |
|
37 | + if ($args['settings'] === $this->args['settings']) { |
|
38 | + $args = parent::filter_control_args($args, $wp_customize); |
|
39 | 39 | |
40 | 40 | // Set the control-type. |
41 | 41 | $args['type'] = 'kirki-generic'; |
42 | 42 | |
43 | 43 | // Choices. |
44 | - $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
44 | + $args['choices'] = isset($args['choices']) ? $args['choices'] : []; |
|
45 | 45 | $args['choices']['element'] = 'textarea'; |
46 | 46 | $args['choices']['rows'] = '5'; |
47 | 47 | } |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
36 | 36 | * @return array |
37 | 37 | */ |
38 | - public function filter_setting_args( $args, $wp_customize ) { |
|
38 | + public function filter_setting_args($args, $wp_customize) { |
|
39 | 39 | |
40 | - if ( $args['settings'] !== $this->args['settings'] ) { |
|
40 | + if ($args['settings'] !== $this->args['settings']) { |
|
41 | 41 | return $args; |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Set the sanitize-callback if none is defined. |
45 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
45 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
46 | 46 | |
47 | - $args['sanitize_callback'] = function( $value ) use ( $args ) { |
|
48 | - $value = filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
47 | + $args['sanitize_callback'] = function($value) use ($args) { |
|
48 | + $value = filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
49 | 49 | |
50 | - if ( isset( $args['choices'] ) && isset( $args['choices']['min'] ) && isset( $args['choices']['max'] ) ) { |
|
50 | + if (isset($args['choices']) && isset($args['choices']['min']) && isset($args['choices']['max'])) { |
|
51 | 51 | // Make sure min & max are all numeric. |
52 | - $min = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
53 | - $max = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
52 | + $min = filter_var($args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
53 | + $max = filter_var($args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
54 | 54 | |
55 | - if ( $value < $min ) { |
|
55 | + if ($value < $min) { |
|
56 | 56 | $value = $min; |
57 | - } elseif ( $value > $max ) { |
|
57 | + } elseif ($value > $max) { |
|
58 | 58 | $value = $max; |
59 | 59 | } |
60 | 60 | } |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
77 | 77 | * @return array |
78 | 78 | */ |
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
79 | + public function filter_control_args($args, $wp_customize) { |
|
80 | 80 | |
81 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
82 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
81 | + if ($args['settings'] === $this->args['settings']) { |
|
82 | + $args = parent::filter_control_args($args, $wp_customize); |
|
83 | 83 | |
84 | 84 | // Set the control-type. |
85 | 85 | $args['type'] = 'kirki-generic'; |
86 | 86 | |
87 | 87 | // Choices. |
88 | - $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
88 | + $args['choices'] = isset($args['choices']) ? $args['choices'] : []; |
|
89 | 89 | $args['choices']['element'] = 'input'; |
90 | 90 | $args['choices']['type'] = 'number'; |
91 | 91 | $args['choices'] = wp_parse_args( |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | ); |
99 | 99 | |
100 | 100 | // Make sure min, max & step are all numeric. |
101 | - $args['choices']['min'] = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
102 | - $args['choices']['max'] = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
103 | - $args['choices']['step'] = filter_var( $args['choices']['step'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
101 | + $args['choices']['min'] = filter_var($args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
102 | + $args['choices']['max'] = filter_var($args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
103 | + $args['choices']['step'] = filter_var($args['choices']['step'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | return $args; |