@@ -15,55 +15,55 @@ |
||
15 | 15 | */ |
16 | 16 | class Nested extends \WP_Customize_Section { |
17 | 17 | |
18 | - /** |
|
19 | - * The parent section. |
|
20 | - * |
|
21 | - * @access public |
|
22 | - * @since 1.0.0 |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - public $section; |
|
18 | + /** |
|
19 | + * The parent section. |
|
20 | + * |
|
21 | + * @access public |
|
22 | + * @since 1.0.0 |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + public $section; |
|
26 | 26 | |
27 | - /** |
|
28 | - * The section type. |
|
29 | - * |
|
30 | - * @access public |
|
31 | - * @since 1.0.0 |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - public $type = 'kirki-nested'; |
|
27 | + /** |
|
28 | + * The section type. |
|
29 | + * |
|
30 | + * @access public |
|
31 | + * @since 1.0.0 |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + public $type = 'kirki-nested'; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Gather the parameters passed to client JavaScript via JSON. |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @since 1.0.0 |
|
41 | - * @return array The array to be exported to the client as JSON. |
|
42 | - */ |
|
43 | - public function json() { |
|
44 | - $array = wp_array_slice_assoc( |
|
45 | - (array) $this, |
|
46 | - [ |
|
47 | - 'id', |
|
48 | - 'description', |
|
49 | - 'priority', |
|
50 | - 'panel', |
|
51 | - 'type', |
|
52 | - 'description_hidden', |
|
53 | - 'section', |
|
54 | - ] |
|
55 | - ); |
|
36 | + /** |
|
37 | + * Gather the parameters passed to client JavaScript via JSON. |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @since 1.0.0 |
|
41 | + * @return array The array to be exported to the client as JSON. |
|
42 | + */ |
|
43 | + public function json() { |
|
44 | + $array = wp_array_slice_assoc( |
|
45 | + (array) $this, |
|
46 | + [ |
|
47 | + 'id', |
|
48 | + 'description', |
|
49 | + 'priority', |
|
50 | + 'panel', |
|
51 | + 'type', |
|
52 | + 'description_hidden', |
|
53 | + 'section', |
|
54 | + ] |
|
55 | + ); |
|
56 | 56 | |
57 | - $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
58 | - $array['content'] = $this->get_content(); |
|
59 | - $array['active'] = $this->active(); |
|
60 | - $array['instanceNumber'] = $this->instance_number; |
|
57 | + $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
58 | + $array['content'] = $this->get_content(); |
|
59 | + $array['active'] = $this->active(); |
|
60 | + $array['instanceNumber'] = $this->instance_number; |
|
61 | 61 | |
62 | - $array['customizeAction'] = esc_html__( 'Customizing', 'kirki' ); |
|
63 | - if ( $this->panel ) { |
|
64 | - /* translators: The title. */ |
|
65 | - $array['customizeAction'] = sprintf( esc_html__( 'Customizing ▸ %s', 'kirki' ), esc_html( $this->manager->get_panel( $this->panel )->title ) ); |
|
66 | - } |
|
67 | - return $array; |
|
68 | - } |
|
62 | + $array['customizeAction'] = esc_html__( 'Customizing', 'kirki' ); |
|
63 | + if ( $this->panel ) { |
|
64 | + /* translators: The title. */ |
|
65 | + $array['customizeAction'] = sprintf( esc_html__( 'Customizing ▸ %s', 'kirki' ), esc_html( $this->manager->get_panel( $this->panel )->title ) ); |
|
66 | + } |
|
67 | + return $array; |
|
68 | + } |
|
69 | 69 | } |
@@ -54,15 +54,15 @@ |
||
54 | 54 | ] |
55 | 55 | ); |
56 | 56 | |
57 | - $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
57 | + $array['title'] = html_entity_decode($this->title, ENT_QUOTES, get_bloginfo('charset')); |
|
58 | 58 | $array['content'] = $this->get_content(); |
59 | 59 | $array['active'] = $this->active(); |
60 | 60 | $array['instanceNumber'] = $this->instance_number; |
61 | 61 | |
62 | - $array['customizeAction'] = esc_html__( 'Customizing', 'kirki' ); |
|
63 | - if ( $this->panel ) { |
|
62 | + $array['customizeAction'] = esc_html__('Customizing', 'kirki'); |
|
63 | + if ($this->panel) { |
|
64 | 64 | /* translators: The title. */ |
65 | - $array['customizeAction'] = sprintf( esc_html__( 'Customizing ▸ %s', 'kirki' ), esc_html( $this->manager->get_panel( $this->panel )->title ) ); |
|
65 | + $array['customizeAction'] = sprintf(esc_html__('Customizing ▸ %s', 'kirki'), esc_html($this->manager->get_panel($this->panel)->title)); |
|
66 | 66 | } |
67 | 67 | return $array; |
68 | 68 | } |
@@ -16,58 +16,58 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Link extends \WP_Customize_Section { |
18 | 18 | |
19 | - /** |
|
20 | - * The section type. |
|
21 | - * |
|
22 | - * @access public |
|
23 | - * @since 1.0.0 |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $type = 'kirki-link'; |
|
19 | + /** |
|
20 | + * The section type. |
|
21 | + * |
|
22 | + * @access public |
|
23 | + * @since 1.0.0 |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $type = 'kirki-link'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Button Text |
|
30 | - * |
|
31 | - * @access public |
|
32 | - * @since 1.0.0 |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $button_text = ''; |
|
28 | + /** |
|
29 | + * Button Text |
|
30 | + * |
|
31 | + * @access public |
|
32 | + * @since 1.0.0 |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $button_text = ''; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Button URL. |
|
39 | - * |
|
40 | - * @access public |
|
41 | - * @since 1.0.0 |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - public $button_url = ''; |
|
37 | + /** |
|
38 | + * Button URL. |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @since 1.0.0 |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + public $button_url = ''; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Gather the parameters passed to client JavaScript via JSON. |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @since 1.0.0 |
|
51 | - * @return array The array to be exported to the client as JSON. |
|
52 | - */ |
|
53 | - public function json() { |
|
54 | - $json = parent::json(); |
|
46 | + /** |
|
47 | + * Gather the parameters passed to client JavaScript via JSON. |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @since 1.0.0 |
|
51 | + * @return array The array to be exported to the client as JSON. |
|
52 | + */ |
|
53 | + public function json() { |
|
54 | + $json = parent::json(); |
|
55 | 55 | |
56 | - $json['button_text'] = $this->button_text; |
|
57 | - $json['button_url'] = $this->button_url; |
|
56 | + $json['button_text'] = $this->button_text; |
|
57 | + $json['button_url'] = $this->button_url; |
|
58 | 58 | |
59 | - return $json; |
|
60 | - } |
|
59 | + return $json; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Outputs the Underscore.js template. |
|
64 | - * |
|
65 | - * @access public |
|
66 | - * @since 1.0.0 |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - protected function render_template() { |
|
70 | - ?> |
|
62 | + /** |
|
63 | + * Outputs the Underscore.js template. |
|
64 | + * |
|
65 | + * @access public |
|
66 | + * @since 1.0.0 |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + protected function render_template() { |
|
70 | + ?> |
|
71 | 71 | <li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand"> |
72 | 72 | <h3 class="accordion-section-title"> |
73 | 73 | {{ data.title }} |
@@ -75,5 +75,5 @@ discard block |
||
75 | 75 | </h3> |
76 | 76 | </li> |
77 | 77 | <?php |
78 | - } |
|
78 | + } |
|
79 | 79 | } |
@@ -15,12 +15,12 @@ |
||
15 | 15 | */ |
16 | 16 | class Outer extends \WP_Customize_Section { |
17 | 17 | |
18 | - /** |
|
19 | - * The section type. |
|
20 | - * |
|
21 | - * @access public |
|
22 | - * @since 1.0.0 |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - public $type = 'kirki-outer'; |
|
18 | + /** |
|
19 | + * The section type. |
|
20 | + * |
|
21 | + * @access public |
|
22 | + * @since 1.0.0 |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + public $type = 'kirki-outer'; |
|
26 | 26 | } |
@@ -16,62 +16,62 @@ |
||
16 | 16 | */ |
17 | 17 | class Selective_Refresh { |
18 | 18 | |
19 | - /** |
|
20 | - * An array of fields with selective refreshes. |
|
21 | - * |
|
22 | - * @static |
|
23 | - * @access private |
|
24 | - * @since 1.0.0 |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - private static $fields = []; |
|
19 | + /** |
|
20 | + * An array of fields with selective refreshes. |
|
21 | + * |
|
22 | + * @static |
|
23 | + * @access private |
|
24 | + * @since 1.0.0 |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + private static $fields = []; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Adds any necessary actions & filters. |
|
31 | - * |
|
32 | - * @access public |
|
33 | - */ |
|
34 | - public function __construct() { |
|
35 | - add_filter( 'kirki_field_add_setting_args', [ $this, 'filter_setting_args' ], 10, 2 ); |
|
36 | - } |
|
29 | + /** |
|
30 | + * Adds any necessary actions & filters. |
|
31 | + * |
|
32 | + * @access public |
|
33 | + */ |
|
34 | + public function __construct() { |
|
35 | + add_filter( 'kirki_field_add_setting_args', [ $this, 'filter_setting_args' ], 10, 2 ); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Filter setting args. |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @since 1.0.0 |
|
43 | - * @param array $field The field arguments. |
|
44 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function filter_setting_args( $field, $wp_customize ) { |
|
38 | + /** |
|
39 | + * Filter setting args. |
|
40 | + * |
|
41 | + * @access public |
|
42 | + * @since 1.0.0 |
|
43 | + * @param array $field The field arguments. |
|
44 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function filter_setting_args( $field, $wp_customize ) { |
|
48 | 48 | |
49 | - // Abort if selective refresh is not available. |
|
50 | - if ( ! isset( $wp_customize->selective_refresh ) ) { |
|
51 | - return $field; |
|
52 | - } |
|
49 | + // Abort if selective refresh is not available. |
|
50 | + if ( ! isset( $wp_customize->selective_refresh ) ) { |
|
51 | + return $field; |
|
52 | + } |
|
53 | 53 | |
54 | - if ( isset( $field['partial_refresh'] ) && ! empty( $field['partial_refresh'] ) ) { |
|
54 | + if ( isset( $field['partial_refresh'] ) && ! empty( $field['partial_refresh'] ) ) { |
|
55 | 55 | |
56 | - // Start going through each item in the array of partial refreshes. |
|
57 | - foreach ( $field['partial_refresh'] as $partial_refresh => $partial_refresh_args ) { |
|
56 | + // Start going through each item in the array of partial refreshes. |
|
57 | + foreach ( $field['partial_refresh'] as $partial_refresh => $partial_refresh_args ) { |
|
58 | 58 | |
59 | - // If we have all we need, create the selective refresh call. |
|
60 | - if ( isset( $partial_refresh_args['render_callback'] ) && isset( $partial_refresh_args['selector'] ) ) { |
|
61 | - $partial_refresh_args = wp_parse_args( |
|
62 | - $partial_refresh_args, |
|
63 | - [ |
|
64 | - 'settings' => $field['settings'], |
|
65 | - ] |
|
66 | - ); |
|
67 | - $wp_customize->selective_refresh->add_partial( $partial_refresh, $partial_refresh_args ); |
|
59 | + // If we have all we need, create the selective refresh call. |
|
60 | + if ( isset( $partial_refresh_args['render_callback'] ) && isset( $partial_refresh_args['selector'] ) ) { |
|
61 | + $partial_refresh_args = wp_parse_args( |
|
62 | + $partial_refresh_args, |
|
63 | + [ |
|
64 | + 'settings' => $field['settings'], |
|
65 | + ] |
|
66 | + ); |
|
67 | + $wp_customize->selective_refresh->add_partial( $partial_refresh, $partial_refresh_args ); |
|
68 | 68 | |
69 | - // If partial refresh is set, change the transport to auto. |
|
70 | - $field['transport'] = 'postMessage'; |
|
71 | - } |
|
72 | - } |
|
73 | - } |
|
69 | + // If partial refresh is set, change the transport to auto. |
|
70 | + $field['transport'] = 'postMessage'; |
|
71 | + } |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - return $field; |
|
76 | - } |
|
75 | + return $field; |
|
76 | + } |
|
77 | 77 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @access public |
33 | 33 | */ |
34 | 34 | public function __construct() { |
35 | - add_filter( 'kirki_field_add_setting_args', [ $this, 'filter_setting_args' ], 10, 2 ); |
|
35 | + add_filter('kirki_field_add_setting_args', [$this, 'filter_setting_args'], 10, 2); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -44,27 +44,27 @@ discard block |
||
44 | 44 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
45 | 45 | * @return array |
46 | 46 | */ |
47 | - public function filter_setting_args( $field, $wp_customize ) { |
|
47 | + public function filter_setting_args($field, $wp_customize) { |
|
48 | 48 | |
49 | 49 | // Abort if selective refresh is not available. |
50 | - if ( ! isset( $wp_customize->selective_refresh ) ) { |
|
50 | + if (!isset($wp_customize->selective_refresh)) { |
|
51 | 51 | return $field; |
52 | 52 | } |
53 | 53 | |
54 | - if ( isset( $field['partial_refresh'] ) && ! empty( $field['partial_refresh'] ) ) { |
|
54 | + if (isset($field['partial_refresh']) && !empty($field['partial_refresh'])) { |
|
55 | 55 | |
56 | 56 | // Start going through each item in the array of partial refreshes. |
57 | - foreach ( $field['partial_refresh'] as $partial_refresh => $partial_refresh_args ) { |
|
57 | + foreach ($field['partial_refresh'] as $partial_refresh => $partial_refresh_args) { |
|
58 | 58 | |
59 | 59 | // If we have all we need, create the selective refresh call. |
60 | - if ( isset( $partial_refresh_args['render_callback'] ) && isset( $partial_refresh_args['selector'] ) ) { |
|
60 | + if (isset($partial_refresh_args['render_callback']) && isset($partial_refresh_args['selector'])) { |
|
61 | 61 | $partial_refresh_args = wp_parse_args( |
62 | 62 | $partial_refresh_args, |
63 | 63 | [ |
64 | 64 | 'settings' => $field['settings'], |
65 | 65 | ] |
66 | 66 | ); |
67 | - $wp_customize->selective_refresh->add_partial( $partial_refresh, $partial_refresh_args ); |
|
67 | + $wp_customize->selective_refresh->add_partial($partial_refresh, $partial_refresh_args); |
|
68 | 68 | |
69 | 69 | // If partial refresh is set, change the transport to auto. |
70 | 70 | $field['transport'] = 'postMessage'; |
@@ -21,59 +21,59 @@ |
||
21 | 21 | */ |
22 | 22 | class Tooltips { |
23 | 23 | |
24 | - /** |
|
25 | - * An array containing field identifieds and their tooltips. |
|
26 | - * |
|
27 | - * @access private |
|
28 | - * @since 1.0 |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - private $tooltips_content = []; |
|
24 | + /** |
|
25 | + * An array containing field identifieds and their tooltips. |
|
26 | + * |
|
27 | + * @access private |
|
28 | + * @since 1.0 |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + private $tooltips_content = []; |
|
32 | 32 | |
33 | - /** |
|
34 | - * The class constructor |
|
35 | - * |
|
36 | - * @access public |
|
37 | - * @since 1.0 |
|
38 | - */ |
|
39 | - public function __construct() { |
|
33 | + /** |
|
34 | + * The class constructor |
|
35 | + * |
|
36 | + * @access public |
|
37 | + * @since 1.0 |
|
38 | + */ |
|
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 | |
46 | - /** |
|
47 | - * Enqueue scripts. |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @since 1.0 |
|
51 | - */ |
|
52 | - public function customize_controls_print_footer_scripts() { |
|
46 | + /** |
|
47 | + * Enqueue scripts. |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @since 1.0 |
|
51 | + */ |
|
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 | |
61 | - /** |
|
62 | - * Filter control args. |
|
63 | - * |
|
64 | - * @access public |
|
65 | - * @since 1.0 |
|
66 | - * @param array $args The field arguments. |
|
67 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
68 | - * @return array |
|
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'] ), |
|
75 | - ]; |
|
76 | - } |
|
77 | - return $args; |
|
78 | - } |
|
61 | + /** |
|
62 | + * Filter control args. |
|
63 | + * |
|
64 | + * @access public |
|
65 | + * @since 1.0 |
|
66 | + * @param array $args The field arguments. |
|
67 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
68 | + * @return array |
|
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'] ), |
|
75 | + ]; |
|
76 | + } |
|
77 | + return $args; |
|
78 | + } |
|
79 | 79 | } |
@@ -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; |
@@ -17,171 +17,171 @@ |
||
17 | 17 | */ |
18 | 18 | final class GoogleFonts { |
19 | 19 | |
20 | - /** |
|
21 | - * An array of our google fonts. |
|
22 | - * |
|
23 | - * @static |
|
24 | - * @access public |
|
25 | - * @since 1.0.0 |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - public static $google_fonts; |
|
29 | - |
|
30 | - /** |
|
31 | - * An array of our google font names. |
|
32 | - * |
|
33 | - * @static |
|
34 | - * @access public |
|
35 | - * @since 1.0.2 |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - public static $google_font_names; |
|
39 | - |
|
40 | - /** |
|
41 | - * The class constructor. |
|
42 | - * |
|
43 | - * @access public |
|
44 | - * @since 1.0.0 |
|
45 | - */ |
|
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' ] ); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Prints the googlefonts JSON file. |
|
53 | - * |
|
54 | - * @since 1.0.0 |
|
55 | - * @param bool $die Whether the script should exit or not. |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function print_googlefonts_json( $die = true ) { |
|
59 | - include 'webfonts.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
60 | - if ( function_exists( 'wp_die' ) && $die ) { |
|
61 | - wp_die(); |
|
62 | - } |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Returns the array of googlefonts from the JSON file. |
|
67 | - * |
|
68 | - * @since 1.0.0 |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - public function get_array() { |
|
72 | - ob_start(); |
|
73 | - include 'webfonts.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
74 | - return json_decode( ob_get_clean(), true ); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Returns the array of googlefont names from the JSON file. |
|
79 | - * |
|
80 | - * @since 1.0.2 |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function get_names_array() { |
|
84 | - ob_start(); |
|
85 | - include 'webfont-names.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
86 | - return json_decode( ob_get_clean(), true ); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Return an array of all available Google Fonts. |
|
91 | - * |
|
92 | - * @access public |
|
93 | - * @since 1.0.0 |
|
94 | - * @return array All Google Fonts. |
|
95 | - */ |
|
96 | - public function get_google_fonts() { |
|
97 | - |
|
98 | - // Get fonts from cache. |
|
99 | - self::$google_fonts = get_site_transient( 'kirki_googlefonts_cache' ); |
|
100 | - |
|
101 | - // If cache is populated, return cached fonts array. |
|
102 | - if ( self::$google_fonts ) { |
|
103 | - return self::$google_fonts; |
|
104 | - } |
|
105 | - |
|
106 | - // If we got this far, cache was empty so we need to get from JSON. |
|
107 | - $fonts = $this->get_array(); |
|
108 | - |
|
109 | - self::$google_fonts = []; |
|
110 | - if ( is_array( $fonts ) ) { |
|
111 | - foreach ( $fonts['items'] as $font ) { |
|
112 | - self::$google_fonts[ $font['family'] ] = [ |
|
113 | - 'label' => $font['family'], |
|
114 | - 'variants' => $font['variants'], |
|
115 | - 'category' => $font['category'], |
|
116 | - ]; |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - // Apply the 'kirki_fonts_google_fonts' filter. |
|
121 | - self::$google_fonts = apply_filters( 'kirki_fonts_google_fonts', self::$google_fonts ); |
|
122 | - |
|
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 ); |
|
126 | - |
|
127 | - return self::$google_fonts; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Return an array of all available Google Font names. |
|
132 | - * |
|
133 | - * @access public |
|
134 | - * @since 1.0.2 |
|
135 | - * @return array All Google Font names. |
|
136 | - */ |
|
137 | - public function get_google_font_names() { |
|
138 | - |
|
139 | - // Get fonts from cache. |
|
140 | - self::$google_font_names = get_site_transient( 'kirki_googlefont_names_cache' ); |
|
141 | - |
|
142 | - // If cache is populated, return cached fonts array. |
|
143 | - if ( self::$google_font_names ) { |
|
144 | - return self::$google_font_names; |
|
145 | - } |
|
146 | - |
|
147 | - // If we got this far, cache was empty so we need to get from JSON. |
|
148 | - self::$google_font_names = $this->get_names_array(); |
|
149 | - |
|
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 ); |
|
152 | - |
|
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 ); |
|
156 | - |
|
157 | - return self::$google_font_names; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Returns an array of google-fonts matching our arguments. |
|
162 | - * |
|
163 | - * @access public |
|
164 | - * @since 1.0.0 |
|
165 | - * @param array $args The arguments. |
|
166 | - * @return array |
|
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 ) { |
|
172 | - return $cache; |
|
173 | - } |
|
174 | - |
|
175 | - $args['sort'] = isset( $args['sort'] ) ? $args['sort'] : 'alpha'; |
|
176 | - |
|
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 ); |
|
182 | - return $ordered_fonts; |
|
183 | - } |
|
184 | - set_site_transient( $cache_name, $ordered_fonts, HOUR_IN_SECONDS ); |
|
185 | - return $ordered_fonts; |
|
186 | - } |
|
20 | + /** |
|
21 | + * An array of our google fonts. |
|
22 | + * |
|
23 | + * @static |
|
24 | + * @access public |
|
25 | + * @since 1.0.0 |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + public static $google_fonts; |
|
29 | + |
|
30 | + /** |
|
31 | + * An array of our google font names. |
|
32 | + * |
|
33 | + * @static |
|
34 | + * @access public |
|
35 | + * @since 1.0.2 |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + public static $google_font_names; |
|
39 | + |
|
40 | + /** |
|
41 | + * The class constructor. |
|
42 | + * |
|
43 | + * @access public |
|
44 | + * @since 1.0.0 |
|
45 | + */ |
|
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' ] ); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Prints the googlefonts JSON file. |
|
53 | + * |
|
54 | + * @since 1.0.0 |
|
55 | + * @param bool $die Whether the script should exit or not. |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function print_googlefonts_json( $die = true ) { |
|
59 | + include 'webfonts.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
60 | + if ( function_exists( 'wp_die' ) && $die ) { |
|
61 | + wp_die(); |
|
62 | + } |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Returns the array of googlefonts from the JSON file. |
|
67 | + * |
|
68 | + * @since 1.0.0 |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + public function get_array() { |
|
72 | + ob_start(); |
|
73 | + include 'webfonts.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
74 | + return json_decode( ob_get_clean(), true ); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Returns the array of googlefont names from the JSON file. |
|
79 | + * |
|
80 | + * @since 1.0.2 |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function get_names_array() { |
|
84 | + ob_start(); |
|
85 | + include 'webfont-names.json'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
86 | + return json_decode( ob_get_clean(), true ); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Return an array of all available Google Fonts. |
|
91 | + * |
|
92 | + * @access public |
|
93 | + * @since 1.0.0 |
|
94 | + * @return array All Google Fonts. |
|
95 | + */ |
|
96 | + public function get_google_fonts() { |
|
97 | + |
|
98 | + // Get fonts from cache. |
|
99 | + self::$google_fonts = get_site_transient( 'kirki_googlefonts_cache' ); |
|
100 | + |
|
101 | + // If cache is populated, return cached fonts array. |
|
102 | + if ( self::$google_fonts ) { |
|
103 | + return self::$google_fonts; |
|
104 | + } |
|
105 | + |
|
106 | + // If we got this far, cache was empty so we need to get from JSON. |
|
107 | + $fonts = $this->get_array(); |
|
108 | + |
|
109 | + self::$google_fonts = []; |
|
110 | + if ( is_array( $fonts ) ) { |
|
111 | + foreach ( $fonts['items'] as $font ) { |
|
112 | + self::$google_fonts[ $font['family'] ] = [ |
|
113 | + 'label' => $font['family'], |
|
114 | + 'variants' => $font['variants'], |
|
115 | + 'category' => $font['category'], |
|
116 | + ]; |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + // Apply the 'kirki_fonts_google_fonts' filter. |
|
121 | + self::$google_fonts = apply_filters( 'kirki_fonts_google_fonts', self::$google_fonts ); |
|
122 | + |
|
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 ); |
|
126 | + |
|
127 | + return self::$google_fonts; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Return an array of all available Google Font names. |
|
132 | + * |
|
133 | + * @access public |
|
134 | + * @since 1.0.2 |
|
135 | + * @return array All Google Font names. |
|
136 | + */ |
|
137 | + public function get_google_font_names() { |
|
138 | + |
|
139 | + // Get fonts from cache. |
|
140 | + self::$google_font_names = get_site_transient( 'kirki_googlefont_names_cache' ); |
|
141 | + |
|
142 | + // If cache is populated, return cached fonts array. |
|
143 | + if ( self::$google_font_names ) { |
|
144 | + return self::$google_font_names; |
|
145 | + } |
|
146 | + |
|
147 | + // If we got this far, cache was empty so we need to get from JSON. |
|
148 | + self::$google_font_names = $this->get_names_array(); |
|
149 | + |
|
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 ); |
|
152 | + |
|
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 ); |
|
156 | + |
|
157 | + return self::$google_font_names; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Returns an array of google-fonts matching our arguments. |
|
162 | + * |
|
163 | + * @access public |
|
164 | + * @since 1.0.0 |
|
165 | + * @param array $args The arguments. |
|
166 | + * @return array |
|
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 ) { |
|
172 | + return $cache; |
|
173 | + } |
|
174 | + |
|
175 | + $args['sort'] = isset( $args['sort'] ) ? $args['sort'] : 'alpha'; |
|
176 | + |
|
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 ); |
|
182 | + return $ordered_fonts; |
|
183 | + } |
|
184 | + set_site_transient( $cache_name, $ordered_fonts, HOUR_IN_SECONDS ); |
|
185 | + return $ordered_fonts; |
|
186 | + } |
|
187 | 187 | } |
@@ -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 | } |
@@ -18,92 +18,92 @@ |
||
18 | 18 | */ |
19 | 19 | class Field_Dependencies { |
20 | 20 | |
21 | - /** |
|
22 | - * An array of field dependencies. |
|
23 | - * |
|
24 | - * @access private |
|
25 | - * @since 1.0.0 |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - private $dependencies = []; |
|
29 | - |
|
30 | - /** |
|
31 | - * Constructor. |
|
32 | - * |
|
33 | - * @access public |
|
34 | - * @since 1.0.0 |
|
35 | - */ |
|
36 | - public function __construct() { |
|
37 | - |
|
38 | - add_action( 'customize_controls_enqueue_scripts', [ $this, 'field_dependencies' ] ); |
|
39 | - add_filter( 'kirki_field_add_control_args', [ $this, 'field_add_control_args' ] ); |
|
40 | - |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Filter control arguments. |
|
45 | - * |
|
46 | - * @access public |
|
47 | - * @since 1.0.0 |
|
48 | - * @param array $args The field arguments. |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - public function field_add_control_args( $args ) { |
|
52 | - |
|
53 | - if ( isset( $args['active_callback'] ) ) { |
|
54 | - if ( is_array( $args['active_callback'] ) ) { |
|
55 | - if ( ! is_callable( $args['active_callback'] ) ) { |
|
56 | - |
|
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 ] ); |
|
61 | - } |
|
62 | - } |
|
63 | - if ( isset( $args['active_callback'][0] ) ) { |
|
64 | - $args['required'] = $args['active_callback']; |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - if ( ! empty( $args['required'] ) ) { |
|
70 | - $this->dependencies[ $args['settings'] ] = $args['required']; |
|
71 | - $args['active_callback'] = '__return_true'; |
|
72 | - return $args; |
|
73 | - } |
|
74 | - |
|
75 | - // No need to proceed any further if we're using the default value. |
|
76 | - if ( '__return_true' === $args['active_callback'] ) { |
|
77 | - return $args; |
|
78 | - } |
|
79 | - |
|
80 | - // Make sure the function is callable, otherwise fallback to __return_true. |
|
81 | - if ( ! is_callable( $args['active_callback'] ) ) { |
|
82 | - $args['active_callback'] = '__return_true'; |
|
83 | - } |
|
84 | - } else { |
|
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']; |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - return $args; |
|
92 | - |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Enqueues the field-dependencies script |
|
97 | - * and adds variables to it using the wp_localize_script function. |
|
98 | - * The rest is handled via JS. |
|
99 | - * |
|
100 | - * @access public |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - public function field_dependencies() { |
|
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 ); |
|
107 | - |
|
108 | - } |
|
21 | + /** |
|
22 | + * An array of field dependencies. |
|
23 | + * |
|
24 | + * @access private |
|
25 | + * @since 1.0.0 |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + private $dependencies = []; |
|
29 | + |
|
30 | + /** |
|
31 | + * Constructor. |
|
32 | + * |
|
33 | + * @access public |
|
34 | + * @since 1.0.0 |
|
35 | + */ |
|
36 | + public function __construct() { |
|
37 | + |
|
38 | + add_action( 'customize_controls_enqueue_scripts', [ $this, 'field_dependencies' ] ); |
|
39 | + add_filter( 'kirki_field_add_control_args', [ $this, 'field_add_control_args' ] ); |
|
40 | + |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Filter control arguments. |
|
45 | + * |
|
46 | + * @access public |
|
47 | + * @since 1.0.0 |
|
48 | + * @param array $args The field arguments. |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + public function field_add_control_args( $args ) { |
|
52 | + |
|
53 | + if ( isset( $args['active_callback'] ) ) { |
|
54 | + if ( is_array( $args['active_callback'] ) ) { |
|
55 | + if ( ! is_callable( $args['active_callback'] ) ) { |
|
56 | + |
|
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 ] ); |
|
61 | + } |
|
62 | + } |
|
63 | + if ( isset( $args['active_callback'][0] ) ) { |
|
64 | + $args['required'] = $args['active_callback']; |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + if ( ! empty( $args['required'] ) ) { |
|
70 | + $this->dependencies[ $args['settings'] ] = $args['required']; |
|
71 | + $args['active_callback'] = '__return_true'; |
|
72 | + return $args; |
|
73 | + } |
|
74 | + |
|
75 | + // No need to proceed any further if we're using the default value. |
|
76 | + if ( '__return_true' === $args['active_callback'] ) { |
|
77 | + return $args; |
|
78 | + } |
|
79 | + |
|
80 | + // Make sure the function is callable, otherwise fallback to __return_true. |
|
81 | + if ( ! is_callable( $args['active_callback'] ) ) { |
|
82 | + $args['active_callback'] = '__return_true'; |
|
83 | + } |
|
84 | + } else { |
|
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']; |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + return $args; |
|
92 | + |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Enqueues the field-dependencies script |
|
97 | + * and adds variables to it using the wp_localize_script function. |
|
98 | + * The rest is handled via JS. |
|
99 | + * |
|
100 | + * @access public |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + public function field_dependencies() { |
|
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 ); |
|
107 | + |
|
108 | + } |
|
109 | 109 | } |
@@ -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 | } |
@@ -18,186 +18,186 @@ |
||
18 | 18 | */ |
19 | 19 | class URL { |
20 | 20 | |
21 | - /** |
|
22 | - * An array of instances. |
|
23 | - * |
|
24 | - * Used for performance reasons in case we need |
|
25 | - * the same url over and over again. |
|
26 | - * |
|
27 | - * @static |
|
28 | - * @access private |
|
29 | - * @since 1.0.2 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - private static $instances = []; |
|
33 | - |
|
34 | - /** |
|
35 | - * The file path. |
|
36 | - * |
|
37 | - * @access private |
|
38 | - * @since 1.0 |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - private $path; |
|
42 | - |
|
43 | - /** |
|
44 | - * The content path. |
|
45 | - * |
|
46 | - * @static |
|
47 | - * @access private |
|
48 | - * @since 1.0 |
|
49 | - * @var string |
|
50 | - */ |
|
51 | - private static $content_path; |
|
52 | - |
|
53 | - /** |
|
54 | - * The content RL. |
|
55 | - * |
|
56 | - * @static |
|
57 | - * @access private |
|
58 | - * @since 1.0 |
|
59 | - * @var string |
|
60 | - */ |
|
61 | - private static $content_url; |
|
62 | - |
|
63 | - /** |
|
64 | - * The file URL. |
|
65 | - * |
|
66 | - * @access private |
|
67 | - * @since 1.0 |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - private $url; |
|
71 | - |
|
72 | - /** |
|
73 | - * Gets an instance based on the path. |
|
74 | - * |
|
75 | - * @static |
|
76 | - * @access public |
|
77 | - * @since 1.0.2 |
|
78 | - * @param string $path Absolute path to a file. |
|
79 | - * @return URL An instance of this object. |
|
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 ); |
|
85 | - } |
|
86 | - return self::$instances[ $path ]; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Constructor. |
|
91 | - * |
|
92 | - * @access private |
|
93 | - * @since 1.0 |
|
94 | - * @param string $path Absolute path to a file. |
|
95 | - */ |
|
96 | - private function __construct( $path ) { |
|
97 | - $this->path = ( $path ); |
|
98 | - $this->set_content_url(); |
|
99 | - $this->set_content_path(); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Get a URL from a path. |
|
104 | - * |
|
105 | - * @static |
|
106 | - * @access public |
|
107 | - * @since 1.0.2 |
|
108 | - * @param string $path The file path. |
|
109 | - * @return string |
|
110 | - */ |
|
111 | - public static function get_from_path( $path ) { |
|
112 | - return self::get_instance( $path )->get_url(); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Get the file URL. |
|
117 | - * |
|
118 | - * @access public |
|
119 | - * @since 1.0 |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function get_url() { |
|
123 | - |
|
124 | - /** |
|
125 | - * Start by replacing ABSPATH with site_url. |
|
126 | - * This is not accurate at all and only serves as a fallback in case everything else fails. |
|
127 | - */ |
|
128 | - $this->url = \str_replace( ABSPATH, \trailingslashit( \site_url() ), $this->path ); |
|
129 | - |
|
130 | - /** |
|
131 | - * If the file-path is inside wp-content replace the content-path with the content-url. |
|
132 | - * This serves as a fallback in case the other tests below fail. |
|
133 | - */ |
|
134 | - if ( false !== \strpos( $this->path, self::$content_path ) ) { |
|
135 | - $this->url = \str_replace( self::$content_path, self::$content_url, $this->path ); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * If the file is in a parent theme use the template directory. |
|
140 | - */ |
|
141 | - if ( $this->in_parent_theme() ) { |
|
142 | - $this->url = \get_template_directory_uri() . \str_replace( \get_template_directory(), '', $this->path ); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * If the file is in a child-theme use the stylesheet directory. |
|
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 ); |
|
150 | - } |
|
151 | - |
|
152 | - $this->url = \set_url_scheme( $this->url ); |
|
153 | - return \apply_filters( 'kirki_path_url', $this->url, $this->path ); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Check if the path is inside a parent theme. |
|
158 | - * |
|
159 | - * @access public |
|
160 | - * @since 1.0 |
|
161 | - * @return bool |
|
162 | - */ |
|
163 | - public function in_parent_theme() { |
|
164 | - return ( 0 === \strpos( $this->path, \get_template_directory() ) ); |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Check if the path is inside a child theme. |
|
169 | - * |
|
170 | - * @access public |
|
171 | - * @since 1.0 |
|
172 | - * @return bool |
|
173 | - */ |
|
174 | - public function in_child_theme() { |
|
175 | - return ( 0 === \strpos( $this->path, \get_stylesheet_directory() ) ); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Set the $content_url. |
|
180 | - * |
|
181 | - * @access private |
|
182 | - * @since 1.0 |
|
183 | - * @return void |
|
184 | - */ |
|
185 | - private function set_content_url() { |
|
186 | - if ( ! self::$content_url ) { |
|
187 | - self::$content_url = \untrailingslashit( \content_url() ); |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Set the $content_path. |
|
193 | - * |
|
194 | - * @access private |
|
195 | - * @since 1.0 |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - private function set_content_path() { |
|
199 | - if ( ! self::$content_path ) { |
|
200 | - self::$content_path = \wp_normalize_path( \untrailingslashit( WP_CONTENT_DIR ) ); |
|
201 | - } |
|
202 | - } |
|
21 | + /** |
|
22 | + * An array of instances. |
|
23 | + * |
|
24 | + * Used for performance reasons in case we need |
|
25 | + * the same url over and over again. |
|
26 | + * |
|
27 | + * @static |
|
28 | + * @access private |
|
29 | + * @since 1.0.2 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + private static $instances = []; |
|
33 | + |
|
34 | + /** |
|
35 | + * The file path. |
|
36 | + * |
|
37 | + * @access private |
|
38 | + * @since 1.0 |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + private $path; |
|
42 | + |
|
43 | + /** |
|
44 | + * The content path. |
|
45 | + * |
|
46 | + * @static |
|
47 | + * @access private |
|
48 | + * @since 1.0 |
|
49 | + * @var string |
|
50 | + */ |
|
51 | + private static $content_path; |
|
52 | + |
|
53 | + /** |
|
54 | + * The content RL. |
|
55 | + * |
|
56 | + * @static |
|
57 | + * @access private |
|
58 | + * @since 1.0 |
|
59 | + * @var string |
|
60 | + */ |
|
61 | + private static $content_url; |
|
62 | + |
|
63 | + /** |
|
64 | + * The file URL. |
|
65 | + * |
|
66 | + * @access private |
|
67 | + * @since 1.0 |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + private $url; |
|
71 | + |
|
72 | + /** |
|
73 | + * Gets an instance based on the path. |
|
74 | + * |
|
75 | + * @static |
|
76 | + * @access public |
|
77 | + * @since 1.0.2 |
|
78 | + * @param string $path Absolute path to a file. |
|
79 | + * @return URL An instance of this object. |
|
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 ); |
|
85 | + } |
|
86 | + return self::$instances[ $path ]; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Constructor. |
|
91 | + * |
|
92 | + * @access private |
|
93 | + * @since 1.0 |
|
94 | + * @param string $path Absolute path to a file. |
|
95 | + */ |
|
96 | + private function __construct( $path ) { |
|
97 | + $this->path = ( $path ); |
|
98 | + $this->set_content_url(); |
|
99 | + $this->set_content_path(); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Get a URL from a path. |
|
104 | + * |
|
105 | + * @static |
|
106 | + * @access public |
|
107 | + * @since 1.0.2 |
|
108 | + * @param string $path The file path. |
|
109 | + * @return string |
|
110 | + */ |
|
111 | + public static function get_from_path( $path ) { |
|
112 | + return self::get_instance( $path )->get_url(); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Get the file URL. |
|
117 | + * |
|
118 | + * @access public |
|
119 | + * @since 1.0 |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function get_url() { |
|
123 | + |
|
124 | + /** |
|
125 | + * Start by replacing ABSPATH with site_url. |
|
126 | + * This is not accurate at all and only serves as a fallback in case everything else fails. |
|
127 | + */ |
|
128 | + $this->url = \str_replace( ABSPATH, \trailingslashit( \site_url() ), $this->path ); |
|
129 | + |
|
130 | + /** |
|
131 | + * If the file-path is inside wp-content replace the content-path with the content-url. |
|
132 | + * This serves as a fallback in case the other tests below fail. |
|
133 | + */ |
|
134 | + if ( false !== \strpos( $this->path, self::$content_path ) ) { |
|
135 | + $this->url = \str_replace( self::$content_path, self::$content_url, $this->path ); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * If the file is in a parent theme use the template directory. |
|
140 | + */ |
|
141 | + if ( $this->in_parent_theme() ) { |
|
142 | + $this->url = \get_template_directory_uri() . \str_replace( \get_template_directory(), '', $this->path ); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * If the file is in a child-theme use the stylesheet directory. |
|
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 ); |
|
150 | + } |
|
151 | + |
|
152 | + $this->url = \set_url_scheme( $this->url ); |
|
153 | + return \apply_filters( 'kirki_path_url', $this->url, $this->path ); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Check if the path is inside a parent theme. |
|
158 | + * |
|
159 | + * @access public |
|
160 | + * @since 1.0 |
|
161 | + * @return bool |
|
162 | + */ |
|
163 | + public function in_parent_theme() { |
|
164 | + return ( 0 === \strpos( $this->path, \get_template_directory() ) ); |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Check if the path is inside a child theme. |
|
169 | + * |
|
170 | + * @access public |
|
171 | + * @since 1.0 |
|
172 | + * @return bool |
|
173 | + */ |
|
174 | + public function in_child_theme() { |
|
175 | + return ( 0 === \strpos( $this->path, \get_stylesheet_directory() ) ); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Set the $content_url. |
|
180 | + * |
|
181 | + * @access private |
|
182 | + * @since 1.0 |
|
183 | + * @return void |
|
184 | + */ |
|
185 | + private function set_content_url() { |
|
186 | + if ( ! self::$content_url ) { |
|
187 | + self::$content_url = \untrailingslashit( \content_url() ); |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Set the $content_path. |
|
193 | + * |
|
194 | + * @access private |
|
195 | + * @since 1.0 |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + private function set_content_path() { |
|
199 | + if ( ! self::$content_path ) { |
|
200 | + self::$content_path = \wp_normalize_path( \untrailingslashit( WP_CONTENT_DIR ) ); |
|
201 | + } |
|
202 | + } |
|
203 | 203 | } |
@@ -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 | } |
@@ -18,130 +18,130 @@ |
||
18 | 18 | */ |
19 | 19 | class Color_Palette extends Field { |
20 | 20 | |
21 | - /** |
|
22 | - * The field type. |
|
23 | - * |
|
24 | - * @since 1.0 |
|
25 | - * @access public |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $type = 'kirki-color-palette'; |
|
29 | - |
|
30 | - /** |
|
31 | - * The control class-name. |
|
32 | - * |
|
33 | - * @since 1.0 |
|
34 | - * @access protected |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $control_class = '\Kirki\Control\Color_Palette'; |
|
38 | - |
|
39 | - /** |
|
40 | - * Whether we should register the control class for JS-templating or not. |
|
41 | - * |
|
42 | - * @since 1.0 |
|
43 | - * @access protected |
|
44 | - * @var bool |
|
45 | - */ |
|
46 | - protected $control_has_js_template = true; |
|
47 | - |
|
48 | - /** |
|
49 | - * Filter arguments before creating the setting. |
|
50 | - * |
|
51 | - * @param array $args The field arguments. |
|
52 | - * @param \WP_Customize_Manager $wp_customize The customizer instance. |
|
53 | - * |
|
54 | - * @return array $args The maybe-filtered arguments. |
|
55 | - */ |
|
56 | - public function filter_setting_args( $args, $wp_customize ) { |
|
57 | - |
|
58 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
59 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
60 | - |
|
61 | - // Set the sanitize_callback if none is defined. |
|
62 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
63 | - $args['sanitize_callback'] = [ __CLASS__, 'sanitize' ]; |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - return $args; |
|
68 | - |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Filter arguments before creating the control. |
|
73 | - * |
|
74 | - * @param array $args The field arguments. |
|
75 | - * @param \WP_Customize_Manager $wp_customize The customizer instance. |
|
76 | - * |
|
77 | - * @return array $args The maybe-filtered arguments. |
|
78 | - */ |
|
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
80 | - |
|
81 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
82 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
83 | - $args['type'] = 'kirki-color-palette'; |
|
84 | - } |
|
85 | - |
|
86 | - return $args; |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Sanitize colors. |
|
92 | - * |
|
93 | - * @static |
|
94 | - * @access public |
|
95 | - * @since 1.0.2 |
|
96 | - * @param string $value The color. |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public static function sanitize( $value ) { |
|
100 | - |
|
101 | - /** |
|
102 | - * This pattern will check and match 3/6/8-character hex, rgb, rgba, hsl, hsla, hsv, and hsva colors. |
|
103 | - * |
|
104 | - * RGB regex: |
|
105 | - * @link https://stackoverflow.com/questions/9585973/javascript-regular-expression-for-rgb-values#answer-9586045 |
|
106 | - * |
|
107 | - * For testing it, you can use these links: |
|
108 | - * |
|
109 | - * @link https://regex101.com/ |
|
110 | - * @link https://regexr.com/ |
|
111 | - * @link https://www.regextester.com/ |
|
112 | - * |
|
113 | - * How to test it? |
|
114 | - * |
|
115 | - * Paste the following code to the test field (of course without the asterisks and spaces in front of them): |
|
116 | - * rgba(255, 255, 0, 0.9) |
|
117 | - * rgb(255, 255, 0) |
|
118 | - * #ff0 |
|
119 | - * #ffff00 |
|
120 | - * hsl(150, 25%, 25%) |
|
121 | - * hsla(250, 25%, 25%, 0.7) |
|
122 | - * hsv(125, 15%, 30%) |
|
123 | - * hsva(125, 15%, 30%, 0.5) |
|
124 | - * |
|
125 | - * And then paste the regex `$pattern` below (without the single quote's start and end) to the regular expression box. |
|
126 | - * Set the flag to use "global" and "multiline". |
|
127 | - */ |
|
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 | - |
|
130 | - \preg_match( $pattern, $value, $matches ); |
|
131 | - |
|
132 | - // Return the 1st match found. |
|
133 | - if ( isset( $matches[0] ) ) { |
|
134 | - if ( is_string( $matches[0] ) ) { |
|
135 | - return $matches[0]; |
|
136 | - } |
|
137 | - |
|
138 | - if ( is_array( $matches[0] ) && isset( $matches[0][0] ) ) { |
|
139 | - return $matches[0][0]; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - // If no match was found, return an empty string. |
|
144 | - return ''; |
|
145 | - } |
|
21 | + /** |
|
22 | + * The field type. |
|
23 | + * |
|
24 | + * @since 1.0 |
|
25 | + * @access public |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $type = 'kirki-color-palette'; |
|
29 | + |
|
30 | + /** |
|
31 | + * The control class-name. |
|
32 | + * |
|
33 | + * @since 1.0 |
|
34 | + * @access protected |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $control_class = '\Kirki\Control\Color_Palette'; |
|
38 | + |
|
39 | + /** |
|
40 | + * Whether we should register the control class for JS-templating or not. |
|
41 | + * |
|
42 | + * @since 1.0 |
|
43 | + * @access protected |
|
44 | + * @var bool |
|
45 | + */ |
|
46 | + protected $control_has_js_template = true; |
|
47 | + |
|
48 | + /** |
|
49 | + * Filter arguments before creating the setting. |
|
50 | + * |
|
51 | + * @param array $args The field arguments. |
|
52 | + * @param \WP_Customize_Manager $wp_customize The customizer instance. |
|
53 | + * |
|
54 | + * @return array $args The maybe-filtered arguments. |
|
55 | + */ |
|
56 | + public function filter_setting_args( $args, $wp_customize ) { |
|
57 | + |
|
58 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
59 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
60 | + |
|
61 | + // Set the sanitize_callback if none is defined. |
|
62 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
63 | + $args['sanitize_callback'] = [ __CLASS__, 'sanitize' ]; |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + return $args; |
|
68 | + |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Filter arguments before creating the control. |
|
73 | + * |
|
74 | + * @param array $args The field arguments. |
|
75 | + * @param \WP_Customize_Manager $wp_customize The customizer instance. |
|
76 | + * |
|
77 | + * @return array $args The maybe-filtered arguments. |
|
78 | + */ |
|
79 | + public function filter_control_args( $args, $wp_customize ) { |
|
80 | + |
|
81 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
82 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
83 | + $args['type'] = 'kirki-color-palette'; |
|
84 | + } |
|
85 | + |
|
86 | + return $args; |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Sanitize colors. |
|
92 | + * |
|
93 | + * @static |
|
94 | + * @access public |
|
95 | + * @since 1.0.2 |
|
96 | + * @param string $value The color. |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public static function sanitize( $value ) { |
|
100 | + |
|
101 | + /** |
|
102 | + * This pattern will check and match 3/6/8-character hex, rgb, rgba, hsl, hsla, hsv, and hsva colors. |
|
103 | + * |
|
104 | + * RGB regex: |
|
105 | + * @link https://stackoverflow.com/questions/9585973/javascript-regular-expression-for-rgb-values#answer-9586045 |
|
106 | + * |
|
107 | + * For testing it, you can use these links: |
|
108 | + * |
|
109 | + * @link https://regex101.com/ |
|
110 | + * @link https://regexr.com/ |
|
111 | + * @link https://www.regextester.com/ |
|
112 | + * |
|
113 | + * How to test it? |
|
114 | + * |
|
115 | + * Paste the following code to the test field (of course without the asterisks and spaces in front of them): |
|
116 | + * rgba(255, 255, 0, 0.9) |
|
117 | + * rgb(255, 255, 0) |
|
118 | + * #ff0 |
|
119 | + * #ffff00 |
|
120 | + * hsl(150, 25%, 25%) |
|
121 | + * hsla(250, 25%, 25%, 0.7) |
|
122 | + * hsv(125, 15%, 30%) |
|
123 | + * hsva(125, 15%, 30%, 0.5) |
|
124 | + * |
|
125 | + * And then paste the regex `$pattern` below (without the single quote's start and end) to the regular expression box. |
|
126 | + * Set the flag to use "global" and "multiline". |
|
127 | + */ |
|
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 | + |
|
130 | + \preg_match( $pattern, $value, $matches ); |
|
131 | + |
|
132 | + // Return the 1st match found. |
|
133 | + if ( isset( $matches[0] ) ) { |
|
134 | + if ( is_string( $matches[0] ) ) { |
|
135 | + return $matches[0]; |
|
136 | + } |
|
137 | + |
|
138 | + if ( is_array( $matches[0] ) && isset( $matches[0][0] ) ) { |
|
139 | + return $matches[0][0]; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + // If no match was found, return an empty string. |
|
144 | + return ''; |
|
145 | + } |
|
146 | 146 | |
147 | 147 | } |
@@ -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 | } |