@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
54 | 54 | * @return array |
55 | 55 | */ |
56 | - public function filter_setting_args( $args, $wp_customize ) { |
|
57 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
58 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
56 | + public function filter_setting_args($args, $wp_customize) { |
|
57 | + if ($args['settings'] === $this->args['settings']) { |
|
58 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
59 | 59 | |
60 | 60 | // Set the sanitize-callback if none is defined. |
61 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
61 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
62 | 62 | $args['sanitize_callback'] = 'wp_kses_post'; |
63 | 63 | } |
64 | 64 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function filter_control_args( $args, $wp_customize ) { |
|
78 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
77 | + public function filter_control_args($args, $wp_customize) { |
|
78 | + if ($args['settings'] === $this->args['settings']) { |
|
79 | + $args = parent::filter_control_args($args, $wp_customize); |
|
80 | 80 | $args['type'] = 'kirki-editor'; |
81 | 81 | } |
82 | 82 | return $args; |
@@ -61,10 +61,10 @@ |
||
61 | 61 | parent::enqueue(); |
62 | 62 | |
63 | 63 | // Enqueue the script. |
64 | - wp_enqueue_script( 'kirki-control-editor', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false ); |
|
64 | + wp_enqueue_script('kirki-control-editor', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-base', 'kirki-control-base'], self::$control_ver, false); |
|
65 | 65 | |
66 | 66 | // Enqueue the style. |
67 | - wp_enqueue_style( 'kirki-control-editor-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
67 | + wp_enqueue_style('kirki-control-editor-style', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
58 | + public function filter_setting_args($args, $wp_customize) { |
|
59 | + if ($args['settings'] === $this->args['settings']) { |
|
60 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
61 | 61 | |
62 | 62 | // Set the sanitize-callback if none is defined. |
63 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
63 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
64 | 64 | $args['sanitize_callback'] = 'sanitize_text_field'; |
65 | 65 | } |
66 | 66 | } |
@@ -76,9 +76,9 @@ 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 ) { |
|
80 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
79 | + public function filter_control_args($args, $wp_customize) { |
|
80 | + if ($args['settings'] === $this->args['settings']) { |
|
81 | + $args = parent::filter_control_args($args, $wp_customize); |
|
82 | 82 | $args['type'] = 'kirki-date'; |
83 | 83 | } |
84 | 84 | return $args; |
@@ -50,10 +50,10 @@ |
||
50 | 50 | parent::enqueue(); |
51 | 51 | |
52 | 52 | // Enqueue the script. |
53 | - wp_enqueue_script( 'kirki-control-date', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base', 'jquery-ui-datepicker' ], self::$control_ver, false ); |
|
53 | + wp_enqueue_script('kirki-control-date', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-base', 'kirki-control-base', 'jquery-ui-datepicker'], self::$control_ver, false); |
|
54 | 54 | |
55 | 55 | // Enqueue the style. |
56 | - wp_enqueue_style( 'kirki-control-date-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
56 | + wp_enqueue_style('kirki-control-date-style', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @since 3.0.0 |
78 | 78 | */ |
79 | 79 | public function __construct() { |
80 | - add_action( 'admin_init', [ $this, 'init' ] ); |
|
80 | + add_action('admin_init', [$this, 'init']); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * @since 3.0.35 |
104 | 104 | */ |
105 | 105 | protected function add_hooks() { |
106 | - if ( ! $this->is_disabled() ) { |
|
107 | - add_action( 'enqueue_block_editor_assets', [ $this->modules_css, 'enqueue_styles' ], 999 ); |
|
108 | - add_action( 'after_setup_theme', [ $this, 'add_theme_support' ], 999 ); |
|
106 | + if (!$this->is_disabled()) { |
|
107 | + add_action('enqueue_block_editor_assets', [$this->modules_css, 'enqueue_styles'], 999); |
|
108 | + add_action('after_setup_theme', [$this, 'add_theme_support'], 999); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @since 3.0.35 |
120 | 120 | */ |
121 | 121 | public function add_theme_support() { |
122 | - if ( true !== get_theme_support( 'editor-styles' ) ) { |
|
123 | - add_theme_support( 'editor-styles' ); |
|
122 | + if (true !== get_theme_support('editor-styles')) { |
|
123 | + add_theme_support('editor-styles'); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return bool $disabled Is gutenberg integration feature disabled? |
138 | 138 | */ |
139 | - private function is_disabled( $args = [] ) { |
|
140 | - if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) { |
|
139 | + private function is_disabled($args = []) { |
|
140 | + if (defined('KIRKI_NO_OUTPUT') && true === KIRKI_NO_OUTPUT) { |
|
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * We would prefer to use "KIRKI_GUTENBERG_OUTPUT" instead. |
146 | 146 | * For consistency however, we will use "KIRKI_NO_GUTENBERG_OUTPUT". |
147 | 147 | */ |
148 | - if ( defined( 'KIRKI_NO_GUTENBERG_OUTPUT' ) && true === KIRKI_NO_GUTENBERG_OUTPUT ) { |
|
148 | + if (defined('KIRKI_NO_GUTENBERG_OUTPUT') && true === KIRKI_NO_GUTENBERG_OUTPUT) { |
|
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @since 3.0.35 |
171 | 171 | */ |
172 | 172 | private function set_enabled() { |
173 | - $this->enabled = ! $this->is_disabled(); |
|
173 | + $this->enabled = !$this->is_disabled(); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace Kirki\Util; |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if (!defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | * @param array $array1 The second array. |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | - public static function array_replace_recursive( $array, $array1 ) { |
|
35 | - if ( function_exists( 'array_replace_recursive' ) ) { |
|
36 | - return array_replace_recursive( $array, $array1 ); |
|
34 | + public static function array_replace_recursive($array, $array1) { |
|
35 | + if (function_exists('array_replace_recursive')) { |
|
36 | + return array_replace_recursive($array, $array1); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | */ |
48 | 48 | $args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue |
49 | 49 | $array = $args[0]; |
50 | - if ( ! is_array( $array ) ) { |
|
50 | + if (!is_array($array)) { |
|
51 | 51 | return $array; |
52 | 52 | } |
53 | - $count = count( $args ); |
|
54 | - for ( $i = 1; $i < $count; $i++ ) { |
|
55 | - if ( is_array( $args[ $i ] ) ) { |
|
56 | - $array = self::recurse( $array, $args[ $i ] ); |
|
53 | + $count = count($args); |
|
54 | + for ($i = 1; $i < $count; $i++) { |
|
55 | + if (is_array($args[$i])) { |
|
56 | + $array = self::recurse($array, $args[$i]); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | return $array; |
@@ -68,19 +68,19 @@ discard block |
||
68 | 68 | * @param array $array1 The second array. |
69 | 69 | * @return array |
70 | 70 | */ |
71 | - public static function recurse( $array, $array1 ) { |
|
72 | - foreach ( $array1 as $key => $value ) { |
|
71 | + public static function recurse($array, $array1) { |
|
72 | + foreach ($array1 as $key => $value) { |
|
73 | 73 | |
74 | 74 | // Create new key in $array, if it is empty or not an array. |
75 | - if ( ! isset( $array[ $key ] ) || ( isset( $array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) { |
|
76 | - $array[ $key ] = []; |
|
75 | + if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key]))) { |
|
76 | + $array[$key] = []; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | // Overwrite the value in the base array. |
80 | - if ( is_array( $value ) ) { |
|
81 | - $value = self::recurse( $array[ $key ], $value ); |
|
80 | + if (is_array($value)) { |
|
81 | + $value = self::recurse($array[$key], $value); |
|
82 | 82 | } |
83 | - $array[ $key ] = $value; |
|
83 | + $array[$key] = $value; |
|
84 | 84 | } |
85 | 85 | return $array; |
86 | 86 | } |
@@ -95,32 +95,32 @@ discard block |
||
95 | 95 | public static function init_filesystem() { |
96 | 96 | $credentials = []; |
97 | 97 | |
98 | - if ( ! defined( 'FS_METHOD' ) ) { |
|
99 | - define( 'FS_METHOD', 'direct' ); |
|
98 | + if (!defined('FS_METHOD')) { |
|
99 | + define('FS_METHOD', 'direct'); |
|
100 | 100 | } |
101 | 101 | |
102 | - $method = defined( 'FS_METHOD' ) ? FS_METHOD : false; |
|
102 | + $method = defined('FS_METHOD') ? FS_METHOD : false; |
|
103 | 103 | |
104 | - if ( 'ftpext' === $method ) { |
|
104 | + if ('ftpext' === $method) { |
|
105 | 105 | // If defined, set it to that, Else, set to NULL. |
106 | - $credentials['hostname'] = defined( 'FTP_HOST' ) ? preg_replace( '|\w+://|', '', FTP_HOST ) : null; |
|
107 | - $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : null; |
|
108 | - $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : null; |
|
106 | + $credentials['hostname'] = defined('FTP_HOST') ? preg_replace('|\w+://|', '', FTP_HOST) : null; |
|
107 | + $credentials['username'] = defined('FTP_USER') ? FTP_USER : null; |
|
108 | + $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : null; |
|
109 | 109 | |
110 | 110 | // Set FTP port. |
111 | - if ( strpos( $credentials['hostname'], ':' ) && null !== $credentials['hostname'] ) { |
|
112 | - list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 ); |
|
113 | - if ( ! is_numeric( $credentials['port'] ) ) { |
|
114 | - unset( $credentials['port'] ); |
|
111 | + if (strpos($credentials['hostname'], ':') && null !== $credentials['hostname']) { |
|
112 | + list($credentials['hostname'], $credentials['port']) = explode(':', $credentials['hostname'], 2); |
|
113 | + if (!is_numeric($credentials['port'])) { |
|
114 | + unset($credentials['port']); |
|
115 | 115 | } |
116 | 116 | } else { |
117 | - unset( $credentials['port'] ); |
|
117 | + unset($credentials['port']); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Set connection type. |
121 | - if ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' === $method ) { |
|
121 | + if ((defined('FTP_SSL') && FTP_SSL) && 'ftpext' === $method) { |
|
122 | 122 | $credentials['connection_type'] = 'ftps'; |
123 | - } elseif ( ! array_filter( $credentials ) ) { |
|
123 | + } elseif (!array_filter($credentials)) { |
|
124 | 124 | $credentials['connection_type'] = null; |
125 | 125 | } else { |
126 | 126 | $credentials['connection_type'] = 'ftp'; |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | // The WordPress filesystem. |
131 | 131 | global $wp_filesystem; |
132 | 132 | |
133 | - if ( empty( $wp_filesystem ) ) { |
|
134 | - require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
135 | - WP_Filesystem( $credentials ); |
|
133 | + if (empty($wp_filesystem)) { |
|
134 | + require_once wp_normalize_path(ABSPATH . '/wp-admin/includes/file.php'); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
135 | + WP_Filesystem($credentials); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return $wp_filesystem; |
@@ -147,19 +147,19 @@ discard block |
||
147 | 147 | * @param string $url URL to the image. |
148 | 148 | * @return int|string Numeric ID of the attachement. |
149 | 149 | */ |
150 | - public static function get_image_id( $url ) { |
|
150 | + public static function get_image_id($url) { |
|
151 | 151 | global $wpdb; |
152 | - if ( empty( $url ) ) { |
|
152 | + if (empty($url)) { |
|
153 | 153 | return 0; |
154 | 154 | } |
155 | 155 | |
156 | - $attachment = wp_cache_get( 'kirki_image_id_' . md5( $url ), null ); |
|
157 | - if ( false === $attachment ) { |
|
158 | - $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid = %s;", $url ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery |
|
159 | - wp_cache_add( 'kirki_image_id_' . md5( $url ), $attachment, null ); |
|
156 | + $attachment = wp_cache_get('kirki_image_id_' . md5($url), null); |
|
157 | + if (false === $attachment) { |
|
158 | + $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid = %s;", $url)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery |
|
159 | + wp_cache_add('kirki_image_id_' . md5($url), $attachment, null); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! empty( $attachment ) ) { |
|
162 | + if (!empty($attachment)) { |
|
163 | 163 | return $attachment[0]; |
164 | 164 | } |
165 | 165 | return 0; |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | * @param string $url URL to the image. |
172 | 172 | * @return array |
173 | 173 | */ |
174 | - public static function get_image_from_url( $url ) { |
|
175 | - $image_id = self::get_image_id( $url ); |
|
176 | - $image = wp_get_attachment_image_src( $image_id, 'full' ); |
|
174 | + public static function get_image_from_url($url) { |
|
175 | + $image_id = self::get_image_id($url); |
|
176 | + $image = wp_get_attachment_image_src($image_id, 'full'); |
|
177 | 177 | |
178 | 178 | return [ |
179 | 179 | 'url' => $image[0], |
@@ -191,25 +191,25 @@ discard block |
||
191 | 191 | * @param array $args Define arguments for the get_posts function. |
192 | 192 | * @return array |
193 | 193 | */ |
194 | - public static function get_posts( $args ) { |
|
195 | - if ( is_string( $args ) ) { |
|
194 | + public static function get_posts($args) { |
|
195 | + if (is_string($args)) { |
|
196 | 196 | $args = add_query_arg( |
197 | 197 | [ |
198 | 198 | 'suppress_filters' => false, |
199 | 199 | ] |
200 | 200 | ); |
201 | - } elseif ( is_array( $args ) && ! isset( $args['suppress_filters'] ) ) { |
|
201 | + } elseif (is_array($args) && !isset($args['suppress_filters'])) { |
|
202 | 202 | $args['suppress_filters'] = false; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Get the posts. |
206 | 206 | // TODO: WordPress.VIP.RestrictedFunctions.get_posts_get_posts. |
207 | - $posts = get_posts( $args ); |
|
207 | + $posts = get_posts($args); |
|
208 | 208 | |
209 | 209 | // Properly format the array. |
210 | 210 | $items = []; |
211 | - foreach ( $posts as $post ) { |
|
212 | - $items[ $post->ID ] = $post->post_title; |
|
211 | + foreach ($posts as $post) { |
|
212 | + $items[$post->ID] = $post->post_title; |
|
213 | 213 | } |
214 | 214 | wp_reset_postdata(); |
215 | 215 | |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | ); |
235 | 235 | |
236 | 236 | // Build the array. |
237 | - foreach ( $taxonomies as $taxonomy ) { |
|
237 | + foreach ($taxonomies as $taxonomy) { |
|
238 | 238 | $id = $taxonomy; |
239 | - $taxonomy = get_taxonomy( $taxonomy ); |
|
240 | - $items[ $id ] = $taxonomy->labels->name; |
|
239 | + $taxonomy = get_taxonomy($taxonomy); |
|
240 | + $items[$id] = $taxonomy->labels->name; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | return $items; |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | ); |
263 | 263 | |
264 | 264 | // Build the array. |
265 | - foreach ( $post_types as $post_type ) { |
|
266 | - $items[ $post_type->name ] = $post_type->labels->name; |
|
265 | + foreach ($post_types as $post_type) { |
|
266 | + $items[$post_type->name] = $post_type->labels->name; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | return $items; |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | * @param string|array $taxonomies See https://developer.wordpress.org/reference/functions/get_terms/ for details. |
278 | 278 | * @return array |
279 | 279 | */ |
280 | - public static function get_terms( $taxonomies ) { |
|
280 | + public static function get_terms($taxonomies) { |
|
281 | 281 | $items = []; |
282 | 282 | |
283 | 283 | // Get the post types. |
284 | - $terms = get_terms( $taxonomies ); |
|
284 | + $terms = get_terms($taxonomies); |
|
285 | 285 | |
286 | 286 | // Build the array. |
287 | - foreach ( $terms as $term ) { |
|
288 | - $items[ $term->term_id ] = $term->name; |
|
287 | + foreach ($terms as $term) { |
|
288 | + $items[$term->term_id] = $term->name; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | return $items; |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | * @param string $value_field The value to be stored in options. Accepted values: id|slug. |
299 | 299 | * @return array |
300 | 300 | */ |
301 | - public static function get_nav_menus( $value_field = 'id' ) { |
|
301 | + public static function get_nav_menus($value_field = 'id') { |
|
302 | 302 | $choices = []; |
303 | 303 | $nav_menus = wp_get_nav_menus(); |
304 | 304 | |
305 | - foreach ( $nav_menus as $term ) { |
|
306 | - $choices[ 'slug' === $value_field ? $term->slug : $term->term_id ] = $term->name; |
|
305 | + foreach ($nav_menus as $term) { |
|
306 | + $choices['slug' === $value_field ? $term->slug : $term->term_id] = $term->name; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | return $choices; |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | * @param string $context Allows us to get subsets of the palette. |
318 | 318 | * @return array |
319 | 319 | */ |
320 | - public static function get_material_design_colors( $context = 'primary' ) { |
|
321 | - return \Kirki\Util\MaterialColors::get_colors( $context ); |
|
320 | + public static function get_material_design_colors($context = 'primary') { |
|
321 | + return \Kirki\Util\MaterialColors::get_colors($context); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @return array |
330 | 330 | */ |
331 | 331 | public static function get_dashicons() { |
332 | - if ( class_exists( '\Kirki\Util\Dashicons' ) ) { |
|
332 | + if (class_exists('\Kirki\Util\Dashicons')) { |
|
333 | 333 | return \Kirki\Util\Dashicons::get_icons(); |
334 | 334 | } |
335 | 335 | return []; |
@@ -343,47 +343,47 @@ discard block |
||
343 | 343 | * @param string $operator The operator we'll use for the comparison. |
344 | 344 | * @return boolean whether The comparison has succeded (true) or failed (false). |
345 | 345 | */ |
346 | - public static function compare_values( $value1, $value2, $operator ) { |
|
347 | - if ( '===' === $operator ) { |
|
346 | + public static function compare_values($value1, $value2, $operator) { |
|
347 | + if ('===' === $operator) { |
|
348 | 348 | return $value1 === $value2; |
349 | 349 | } |
350 | - if ( '!==' === $operator ) { |
|
350 | + if ('!==' === $operator) { |
|
351 | 351 | return $value1 !== $value2; |
352 | 352 | } |
353 | - if ( ( '!=' === $operator || 'not equal' === $operator ) ) { |
|
353 | + if (('!=' === $operator || 'not equal' === $operator)) { |
|
354 | 354 | return $value1 != $value2; // phpcs:ignore WordPress.PHP.StrictComparisons |
355 | 355 | } |
356 | - if ( ( '>=' === $operator || 'greater or equal' === $operator || 'equal or greater' === $operator ) ) { |
|
356 | + if (('>=' === $operator || 'greater or equal' === $operator || 'equal or greater' === $operator)) { |
|
357 | 357 | return $value2 >= $value1; |
358 | 358 | } |
359 | - if ( ( '<=' === $operator || 'smaller or equal' === $operator || 'equal or smaller' === $operator ) ) { |
|
359 | + if (('<=' === $operator || 'smaller or equal' === $operator || 'equal or smaller' === $operator)) { |
|
360 | 360 | return $value2 <= $value1; |
361 | 361 | } |
362 | - if ( ( '>' === $operator || 'greater' === $operator ) ) { |
|
362 | + if (('>' === $operator || 'greater' === $operator)) { |
|
363 | 363 | return $value2 > $value1; |
364 | 364 | } |
365 | - if ( ( '<' === $operator || 'smaller' === $operator ) ) { |
|
365 | + if (('<' === $operator || 'smaller' === $operator)) { |
|
366 | 366 | return $value2 < $value1; |
367 | 367 | } |
368 | - if ( 'contains' === $operator || 'in' === $operator ) { |
|
369 | - if ( is_array( $value1 ) && is_array( $value2 ) ) { |
|
370 | - foreach ( $value2 as $val ) { |
|
371 | - if ( in_array( $val, $value1 ) ) { // phpcs:ignore WordPress.PHP.StrictInArray |
|
368 | + if ('contains' === $operator || 'in' === $operator) { |
|
369 | + if (is_array($value1) && is_array($value2)) { |
|
370 | + foreach ($value2 as $val) { |
|
371 | + if (in_array($val, $value1)) { // phpcs:ignore WordPress.PHP.StrictInArray |
|
372 | 372 | return true; |
373 | 373 | } |
374 | 374 | } |
375 | 375 | return false; |
376 | 376 | } |
377 | - if ( is_array( $value1 ) && ! is_array( $value2 ) ) { |
|
378 | - return in_array( $value2, $value1 ); // phpcs:ignore WordPress.PHP.StrictInArray |
|
377 | + if (is_array($value1) && !is_array($value2)) { |
|
378 | + return in_array($value2, $value1); // phpcs:ignore WordPress.PHP.StrictInArray |
|
379 | 379 | } |
380 | - if ( is_array( $value2 ) && ! is_array( $value1 ) ) { |
|
381 | - return in_array( $value1, $value2 ); // phpcs:ignore WordPress.PHP.StrictInArray |
|
380 | + if (is_array($value2) && !is_array($value1)) { |
|
381 | + return in_array($value1, $value2); // phpcs:ignore WordPress.PHP.StrictInArray |
|
382 | 382 | } |
383 | - return ( false !== strrpos( $value1, $value2 ) || false !== strpos( $value2, $value1 ) ); |
|
383 | + return (false !== strrpos($value1, $value2) || false !== strpos($value2, $value1)); |
|
384 | 384 | } |
385 | - if ( 'does not contain' === $operator || 'not in' === $operator ) { |
|
386 | - return ! self::compare_values( $value1, $value2, $operator ); |
|
385 | + if ('does not contain' === $operator || 'not in' === $operator) { |
|
386 | + return !self::compare_values($value1, $value2, $operator); |
|
387 | 387 | } |
388 | 388 | return $value1 == $value2; // phpcs:ignore WordPress.PHP.StrictComparisons |
389 | 389 | } |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | * @param array $values The data which can be either a single or multi-dimensional array. |
397 | 397 | * @return array |
398 | 398 | */ |
399 | - public static function prepare_php_array_for_js( $values ) { |
|
399 | + public static function prepare_php_array_for_js($values) { |
|
400 | 400 | |
401 | - foreach ( $values as $key => $value ) { |
|
402 | - if ( ! is_scalar( $value ) ) { |
|
401 | + foreach ($values as $key => $value) { |
|
402 | + if (!is_scalar($value)) { |
|
403 | 403 | continue; |
404 | 404 | } |
405 | 405 | |
406 | - $values[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
406 | + $values[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | return $values; |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param mixed $default Value to return if root does not exist. |
35 | 35 | * @return mixed |
36 | 36 | */ |
37 | - protected function get_root_value( $default = null ) { |
|
38 | - return get_site_option( $this->id_data['base'], $default ); |
|
37 | + protected function get_root_value($default = null) { |
|
38 | + return get_site_option($this->id_data['base'], $default); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param mixed $value Value to set as root of multidimensional setting. |
47 | 47 | * @return bool Whether the multidimensional root was updated successfully. |
48 | 48 | */ |
49 | - protected function set_root_value( $value ) { |
|
50 | - return update_site_option( $this->id_data['base'], $value ); |
|
49 | + protected function set_root_value($value) { |
|
50 | + return update_site_option($this->id_data['base'], $value); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @param mixed $value The value to update. |
59 | 59 | * @return bool The result of saving the value. |
60 | 60 | */ |
61 | - protected function update( $value ) { |
|
62 | - return $this->set_root_value( $value ); |
|
61 | + protected function update($value) { |
|
62 | + return $this->set_root_value($value); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -70,6 +70,6 @@ discard block |
||
70 | 70 | * @return mixed The value. |
71 | 71 | */ |
72 | 72 | public function value() { |
73 | - return $this->get_root_value( $this->default ); |
|
73 | + return $this->get_root_value($this->default); |
|
74 | 74 | } |
75 | 75 | } |
@@ -34,18 +34,18 @@ discard block |
||
34 | 34 | * @param mixed $default Value to return if root does not exist. |
35 | 35 | * @return mixed |
36 | 36 | */ |
37 | - protected function get_root_value( $default = null ) { |
|
37 | + protected function get_root_value($default = null) { |
|
38 | 38 | $id_base = $this->id_data['base']; |
39 | 39 | |
40 | 40 | // Get all user-meta. |
41 | 41 | // We'll use this to check if the value is set or not, |
42 | 42 | // in order to figure out if we need to return the default value. |
43 | - $user_meta = get_user_meta( get_current_user_id() ); |
|
43 | + $user_meta = get_user_meta(get_current_user_id()); |
|
44 | 44 | |
45 | 45 | // Get the single meta. |
46 | - $single_meta = get_user_meta( get_current_user_id(), $id_base, true ); |
|
46 | + $single_meta = get_user_meta(get_current_user_id(), $id_base, true); |
|
47 | 47 | |
48 | - if ( isset( $user_meta[ $id_base ] ) ) { |
|
48 | + if (isset($user_meta[$id_base])) { |
|
49 | 49 | return $single_meta; |
50 | 50 | } |
51 | 51 | return $default; |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | * @param mixed $value Value to set as root of multidimensional setting. |
60 | 60 | * @return bool Whether the multidimensional root was updated successfully. |
61 | 61 | */ |
62 | - protected function set_root_value( $value ) { |
|
62 | + protected function set_root_value($value) { |
|
63 | 63 | $id_base = $this->id_data['base']; |
64 | 64 | |
65 | 65 | // First delete the current user-meta. |
66 | 66 | // We're doing this to avoid duplicate entries. |
67 | - delete_user_meta( get_current_user_id(), $id_base ); |
|
67 | + delete_user_meta(get_current_user_id(), $id_base); |
|
68 | 68 | |
69 | 69 | // Update the user-meta. |
70 | - return update_user_meta( get_current_user_id(), $id_base, $value ); |
|
70 | + return update_user_meta(get_current_user_id(), $id_base, $value); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param mixed $value The value to update. |
79 | 79 | * @return bool The result of saving the value. |
80 | 80 | */ |
81 | - protected function update( $value ) { |
|
82 | - return $this->set_root_value( $value ); |
|
81 | + protected function update($value) { |
|
82 | + return $this->set_root_value($value); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -90,6 +90,6 @@ discard block |
||
90 | 90 | * @return mixed The value. |
91 | 91 | */ |
92 | 92 | public function value() { |
93 | - return $this->get_root_value( $this->default ); |
|
93 | + return $this->get_root_value($this->default); |
|
94 | 94 | } |
95 | 95 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @access public |
35 | 35 | */ |
36 | 36 | public function __construct() { |
37 | - add_filter( 'http_request_args', [ $this, 'http_request' ], 10, 2 ); |
|
38 | - add_action( 'kirki_field_init', [ $this, 'field_init_variables' ], 10, 2 ); |
|
37 | + add_filter('http_request_args', [$this, 'http_request'], 10, 2); |
|
38 | + add_action('kirki_field_init', [$this, 'field_init_variables'], 10, 2); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -48,22 +48,22 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function is_plugin() { |
50 | 50 | $is_plugin = false; |
51 | - if ( ! function_exists( 'get_plugins' ) ) { |
|
51 | + if (!function_exists('get_plugins')) { |
|
52 | 52 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Get all plugins. |
56 | 56 | $plugins = get_plugins(); |
57 | 57 | $_plugin = ''; |
58 | - foreach ( $plugins as $plugin => $args ) { |
|
59 | - if ( ! $is_plugin && isset( $args['Name'] ) && ( 'Kirki' === $args['Name'] || 'Kirki Toolkit' === $args['Name'] ) ) { |
|
58 | + foreach ($plugins as $plugin => $args) { |
|
59 | + if (!$is_plugin && isset($args['Name']) && ('Kirki' === $args['Name'] || 'Kirki Toolkit' === $args['Name'])) { |
|
60 | 60 | $is_plugin = true; |
61 | 61 | $_plugin = $plugin; |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | 65 | // No need to proceed any further if Kirki wasn't found in the list of plugins. |
66 | - if ( ! $is_plugin ) { |
|
66 | + if (!$is_plugin) { |
|
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
72 | 72 | |
73 | 73 | // Extra logic in case the plugin is installed but not activated. |
74 | - if ( $_plugin && is_plugin_inactive( $_plugin ) ) { |
|
74 | + if ($_plugin && is_plugin_inactive($_plugin)) { |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | return $is_plugin; |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param Object $object The field object. |
87 | 87 | * @return void |
88 | 88 | */ |
89 | - public function field_init_variables( $args, $object ) { |
|
90 | - if ( isset( $args['variables'] ) ) { |
|
89 | + public function field_init_variables($args, $object) { |
|
90 | + if (isset($args['variables'])) { |
|
91 | 91 | self::$variables_fields[] = $args; |
92 | 92 | } |
93 | 93 | } |
@@ -110,46 +110,46 @@ discard block |
||
110 | 110 | * If the Kirki class exists, check for fields inside it |
111 | 111 | * and add them to our fields array. |
112 | 112 | */ |
113 | - if ( class_exists( '\Kirki\Compatibility\Kirki' ) ) { |
|
114 | - $fields = array_merge( \Kirki\Compatibility\Kirki::$fields, $fields ); |
|
113 | + if (class_exists('\Kirki\Compatibility\Kirki')) { |
|
114 | + $fields = array_merge(\Kirki\Compatibility\Kirki::$fields, $fields); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // Loop through all fields. |
118 | - foreach ( $fields as $field ) { |
|
118 | + foreach ($fields as $field) { |
|
119 | 119 | |
120 | 120 | // Skip if this field doesn't have variables. |
121 | - if ( ! isset( $field['variables'] ) || ! $field['variables'] || empty( $field['variables'] ) ) { |
|
121 | + if (!isset($field['variables']) || !$field['variables'] || empty($field['variables'])) { |
|
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
125 | - $option_type = ( isset( $field['option_type'] ) ) ? $field['option_type'] : 'theme_mod'; |
|
126 | - $default = ( isset( $field['default'] ) ) ? $field['default'] : ''; |
|
127 | - $value = apply_filters( 'kirki_get_value', get_theme_mod( $field['settings'], $default ), $field['settings'], $default, $option_type ); |
|
125 | + $option_type = (isset($field['option_type'])) ? $field['option_type'] : 'theme_mod'; |
|
126 | + $default = (isset($field['default'])) ? $field['default'] : ''; |
|
127 | + $value = apply_filters('kirki_get_value', get_theme_mod($field['settings'], $default), $field['settings'], $default, $option_type); |
|
128 | 128 | |
129 | 129 | // Loop through the array of variables. |
130 | - foreach ( $field['variables'] as $field_variable ) { |
|
130 | + foreach ($field['variables'] as $field_variable) { |
|
131 | 131 | |
132 | 132 | // Is the variable ['name'] defined? If yes, then we can proceed. |
133 | - if ( isset( $field_variable['name'] ) ) { |
|
133 | + if (isset($field_variable['name'])) { |
|
134 | 134 | |
135 | 135 | // Do we have a callback function defined? If not then set $variable_callback to false. |
136 | - $variable_callback = ( isset( $field_variable['callback'] ) && is_callable( $field_variable['callback'] ) ) ? $field_variable['callback'] : false; |
|
136 | + $variable_callback = (isset($field_variable['callback']) && is_callable($field_variable['callback'])) ? $field_variable['callback'] : false; |
|
137 | 137 | |
138 | 138 | /** |
139 | 139 | * If we have a variable_callback defined then get the value of the option |
140 | 140 | * and run it through the callback function. |
141 | 141 | * If no callback is defined (false) then just get the value. |
142 | 142 | */ |
143 | - $variables[ $field_variable['name'] ] = $value; |
|
144 | - if ( $variable_callback ) { |
|
145 | - $variables[ $field_variable['name'] ] = call_user_func( $field_variable['callback'], $value ); |
|
143 | + $variables[$field_variable['name']] = $value; |
|
144 | + if ($variable_callback) { |
|
145 | + $variables[$field_variable['name']] = call_user_func($field_variable['callback'], $value); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Pass the variables through a filter ('kirki_variable') and return the array of variables. |
152 | - return apply_filters( 'kirki_variable', $variables ); |
|
152 | + return apply_filters('kirki_variable', $variables); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -161,38 +161,38 @@ discard block |
||
161 | 161 | * @param string $url The request URL. |
162 | 162 | * @return array |
163 | 163 | */ |
164 | - public function http_request( $request = [], $url = '' ) { |
|
164 | + public function http_request($request = [], $url = '') { |
|
165 | 165 | |
166 | 166 | // Early exit if installed as a plugin or not a request to wordpress.org, |
167 | 167 | // or finally if we don't have everything we need. |
168 | 168 | if ( |
169 | 169 | self::is_plugin() || |
170 | - false === strpos( $url, 'wordpress.org' ) || ( |
|
171 | - ! isset( $request['body'] ) || |
|
172 | - ! isset( $request['body']['plugins'] ) || |
|
173 | - ! isset( $request['body']['translations'] ) || |
|
174 | - ! isset( $request['body']['locale'] ) || |
|
175 | - ! isset( $request['body']['all'] ) |
|
170 | + false === strpos($url, 'wordpress.org') || ( |
|
171 | + !isset($request['body']) || |
|
172 | + !isset($request['body']['plugins']) || |
|
173 | + !isset($request['body']['translations']) || |
|
174 | + !isset($request['body']['locale']) || |
|
175 | + !isset($request['body']['all']) |
|
176 | 176 | ) |
177 | 177 | ) { |
178 | 178 | return $request; |
179 | 179 | } |
180 | 180 | |
181 | - $plugins = json_decode( $request['body']['plugins'], true ); |
|
182 | - if ( ! isset( $plugins['plugins'] ) ) { |
|
181 | + $plugins = json_decode($request['body']['plugins'], true); |
|
182 | + if (!isset($plugins['plugins'])) { |
|
183 | 183 | return $request; |
184 | 184 | } |
185 | 185 | $exists = false; |
186 | - foreach ( $plugins['plugins'] as $plugin ) { |
|
187 | - if ( isset( $plugin['Name'] ) && 'Kirki Toolkit' === $plugin['Name'] ) { |
|
186 | + foreach ($plugins['plugins'] as $plugin) { |
|
187 | + if (isset($plugin['Name']) && 'Kirki Toolkit' === $plugin['Name']) { |
|
188 | 188 | $exists = true; |
189 | 189 | } |
190 | 190 | } |
191 | 191 | // Inject data. |
192 | - if ( ! $exists && defined( 'KIRKI_PLUGIN_FILE' ) ) { |
|
193 | - $plugins['plugins']['kirki/kirki.php'] = get_plugin_data( KIRKI_PLUGIN_FILE ); |
|
192 | + if (!$exists && defined('KIRKI_PLUGIN_FILE')) { |
|
193 | + $plugins['plugins']['kirki/kirki.php'] = get_plugin_data(KIRKI_PLUGIN_FILE); |
|
194 | 194 | } |
195 | - $request['body']['plugins'] = wp_json_encode( $plugins ); |
|
195 | + $request['body']['plugins'] = wp_json_encode($plugins); |
|
196 | 196 | return $request; |
197 | 197 | } |
198 | 198 | |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | * @return int|string Returns integer when getting the 'major' version. |
207 | 207 | * Returns string when getting the 'minor' version. |
208 | 208 | */ |
209 | - public static function get_wp_version( $context = 'minor' ) { |
|
209 | + public static function get_wp_version($context = 'minor') { |
|
210 | 210 | global $wp_version; |
211 | 211 | |
212 | 212 | // We only need the major version. |
213 | - if ( 'major' === $context ) { |
|
214 | - $version_parts = explode( '.', $wp_version ); |
|
213 | + if ('major' === $context) { |
|
214 | + $version_parts = explode('.', $wp_version); |
|
215 | 215 | return $version_parts[0]; |
216 | 216 | } |
217 | 217 |