@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -15,79 +15,79 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class LSX_WC_Widget_Recent_Reviews extends WC_Widget { |
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - $this->widget_cssclass = 'woocommerce widget_recent_reviews'; |
|
23 | - $this->widget_description = __( 'Display a list of your most recent reviews on your site.', 'lsx' ); |
|
24 | - $this->widget_id = 'woocommerce_recent_reviews'; |
|
25 | - $this->widget_name = __( 'WooCommerce recent reviews', 'lsx' ); |
|
26 | - $this->settings = array( |
|
27 | - 'title' => array( |
|
28 | - 'type' => 'text', |
|
29 | - 'std' => __( 'Recent reviews', 'lsx' ), |
|
30 | - 'label' => __( 'Title', 'lsx' ), |
|
31 | - ), |
|
32 | - 'number' => array( |
|
33 | - 'type' => 'number', |
|
34 | - 'step' => 1, |
|
35 | - 'min' => 1, |
|
36 | - 'max' => '', |
|
37 | - 'std' => 10, |
|
38 | - 'label' => __( 'Number of reviews to show', 'lsx' ), |
|
39 | - ), |
|
40 | - ); |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + $this->widget_cssclass = 'woocommerce widget_recent_reviews'; |
|
23 | + $this->widget_description = __( 'Display a list of your most recent reviews on your site.', 'lsx' ); |
|
24 | + $this->widget_id = 'woocommerce_recent_reviews'; |
|
25 | + $this->widget_name = __( 'WooCommerce recent reviews', 'lsx' ); |
|
26 | + $this->settings = array( |
|
27 | + 'title' => array( |
|
28 | + 'type' => 'text', |
|
29 | + 'std' => __( 'Recent reviews', 'lsx' ), |
|
30 | + 'label' => __( 'Title', 'lsx' ), |
|
31 | + ), |
|
32 | + 'number' => array( |
|
33 | + 'type' => 'number', |
|
34 | + 'step' => 1, |
|
35 | + 'min' => 1, |
|
36 | + 'max' => '', |
|
37 | + 'std' => 10, |
|
38 | + 'label' => __( 'Number of reviews to show', 'lsx' ), |
|
39 | + ), |
|
40 | + ); |
|
41 | 41 | |
42 | - parent::__construct(); |
|
43 | - } |
|
42 | + parent::__construct(); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Output widget. |
|
47 | - * |
|
48 | - * @see WP_Widget |
|
49 | - * |
|
50 | - * @param array $args |
|
51 | - * @param array $instance |
|
52 | - */ |
|
53 | - public function widget( $args, $instance ) { |
|
54 | - if ( $this->get_cached_widget( $args ) ) { |
|
55 | - return; |
|
56 | - } |
|
57 | - ob_start(); |
|
58 | - $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; |
|
59 | - $comments = get_comments( |
|
60 | - array( |
|
61 | - 'number' => $number, |
|
62 | - 'status' => 'approve', |
|
63 | - 'post_status' => 'publish', |
|
64 | - 'post_type' => 'product', |
|
65 | - 'parent' => 0, |
|
66 | - ) |
|
67 | - ); |
|
45 | + /** |
|
46 | + * Output widget. |
|
47 | + * |
|
48 | + * @see WP_Widget |
|
49 | + * |
|
50 | + * @param array $args |
|
51 | + * @param array $instance |
|
52 | + */ |
|
53 | + public function widget( $args, $instance ) { |
|
54 | + if ( $this->get_cached_widget( $args ) ) { |
|
55 | + return; |
|
56 | + } |
|
57 | + ob_start(); |
|
58 | + $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; |
|
59 | + $comments = get_comments( |
|
60 | + array( |
|
61 | + 'number' => $number, |
|
62 | + 'status' => 'approve', |
|
63 | + 'post_status' => 'publish', |
|
64 | + 'post_type' => 'product', |
|
65 | + 'parent' => 0, |
|
66 | + ) |
|
67 | + ); |
|
68 | 68 | |
69 | - if ( $comments ) { |
|
70 | - $this->widget_start( $args, $instance ); |
|
69 | + if ( $comments ) { |
|
70 | + $this->widget_start( $args, $instance ); |
|
71 | 71 | |
72 | - echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ) ); |
|
72 | + echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ) ); |
|
73 | 73 | |
74 | - global $stored_comment, $_product, $rating; |
|
74 | + global $stored_comment, $_product, $rating; |
|
75 | 75 | |
76 | - the_comment(); |
|
77 | - foreach ( (array) $comments as $comment ) { |
|
78 | - $_product = wc_get_product( $comment->comment_post_ID ); |
|
79 | - $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ); |
|
80 | - $stored_comment = $comment; |
|
76 | + the_comment(); |
|
77 | + foreach ( (array) $comments as $comment ) { |
|
78 | + $_product = wc_get_product( $comment->comment_post_ID ); |
|
79 | + $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ); |
|
80 | + $stored_comment = $comment; |
|
81 | 81 | |
82 | - wc_get_template( 'content-widget-review.php' ); |
|
83 | - } |
|
82 | + wc_get_template( 'content-widget-review.php' ); |
|
83 | + } |
|
84 | 84 | |
85 | - echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ) ); |
|
85 | + echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ) ); |
|
86 | 86 | |
87 | - $this->widget_end( $args ); |
|
88 | - } |
|
89 | - $content = ob_get_clean(); |
|
90 | - echo wp_kses_post( $content ); |
|
91 | - $this->cache_widget( $args, $content ); |
|
92 | - } |
|
87 | + $this->widget_end( $args ); |
|
88 | + } |
|
89 | + $content = ob_get_clean(); |
|
90 | + echo wp_kses_post( $content ); |
|
91 | + $this->cache_widget( $args, $content ); |
|
92 | + } |
|
93 | 93 | } |
@@ -8,74 +8,74 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; |
|
11 | + exit; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | if ( ! class_exists( 'Walker_Nav_Menu' ) ) { |
15 | - return; |
|
15 | + return; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if ( ! class_exists( 'LSX_Nav_Walker' ) ) : |
19 | 19 | |
20 | - /** |
|
21 | - * Cleaner walker for wp_nav_menu() |
|
22 | - * |
|
23 | - * Walker_Nav_Menu (WordPress default) example output: |
|
24 | - * <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8"><a href="/">Home</a></li> |
|
25 | - * <li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9"><a href="/sample-page/">Sample Page</a></l |
|
26 | - * |
|
27 | - * LSX_Nav_Walker example output: |
|
28 | - * <li class="menu-home"><a href="/">Home</a></li> |
|
29 | - * <li class="menu-sample-page"><a href="/sample-page/">Sample Page</a></li> |
|
30 | - * |
|
31 | - * @package lsx |
|
32 | - * @subpackage navigation |
|
33 | - * @category bootstrap-walker |
|
34 | - */ |
|
35 | - class LSX_Nav_Walker extends Walker_Nav_Menu { |
|
20 | + /** |
|
21 | + * Cleaner walker for wp_nav_menu() |
|
22 | + * |
|
23 | + * Walker_Nav_Menu (WordPress default) example output: |
|
24 | + * <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8"><a href="/">Home</a></li> |
|
25 | + * <li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9"><a href="/sample-page/">Sample Page</a></l |
|
26 | + * |
|
27 | + * LSX_Nav_Walker example output: |
|
28 | + * <li class="menu-home"><a href="/">Home</a></li> |
|
29 | + * <li class="menu-sample-page"><a href="/sample-page/">Sample Page</a></li> |
|
30 | + * |
|
31 | + * @package lsx |
|
32 | + * @subpackage navigation |
|
33 | + * @category bootstrap-walker |
|
34 | + */ |
|
35 | + class LSX_Nav_Walker extends Walker_Nav_Menu { |
|
36 | 36 | |
37 | - function check_current( $classes ) { |
|
38 | - return preg_match( '/^(current[-_])|active|dropdown$/', $classes ); |
|
39 | - } |
|
37 | + function check_current( $classes ) { |
|
38 | + return preg_match( '/^(current[-_])|active|dropdown$/', $classes ); |
|
39 | + } |
|
40 | 40 | |
41 | - function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
42 | - $output .= "\n<ul class=\"dropdown-menu\">\n"; |
|
43 | - } |
|
41 | + function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
42 | + $output .= "\n<ul class=\"dropdown-menu\">\n"; |
|
43 | + } |
|
44 | 44 | |
45 | - function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
46 | - $item_html = ''; |
|
45 | + function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
46 | + $item_html = ''; |
|
47 | 47 | |
48 | - if ( isset( $item->title ) ) { |
|
49 | - parent::start_el( $item_html, $item, $depth, $args ); |
|
48 | + if ( isset( $item->title ) ) { |
|
49 | + parent::start_el( $item_html, $item, $depth, $args ); |
|
50 | 50 | |
51 | - if ( $item->is_dropdown && ( 0 === $depth ) ) { |
|
52 | - $item_html = str_replace( '<a', '<a class="dropdown-toggle" data-target="#"', $item_html ); |
|
53 | - $item_html = str_replace( '</a>', ' <b class="caret"></b></a>', $item_html ); |
|
54 | - } elseif ( stristr( $item_html, 'li class="divider"' ) ) { |
|
55 | - $item_html = preg_replace( '/<a[^>]*>.*?<\/a>/iU', '', $item_html ); |
|
56 | - } elseif ( stristr( $item_html, 'li class="dropdown-header"' ) ) { |
|
57 | - $item_html = preg_replace( '/<a[^>]*>(.*)<\/a>/iU', '$1', $item_html ); |
|
58 | - } |
|
51 | + if ( $item->is_dropdown && ( 0 === $depth ) ) { |
|
52 | + $item_html = str_replace( '<a', '<a class="dropdown-toggle" data-target="#"', $item_html ); |
|
53 | + $item_html = str_replace( '</a>', ' <b class="caret"></b></a>', $item_html ); |
|
54 | + } elseif ( stristr( $item_html, 'li class="divider"' ) ) { |
|
55 | + $item_html = preg_replace( '/<a[^>]*>.*?<\/a>/iU', '', $item_html ); |
|
56 | + } elseif ( stristr( $item_html, 'li class="dropdown-header"' ) ) { |
|
57 | + $item_html = preg_replace( '/<a[^>]*>(.*)<\/a>/iU', '$1', $item_html ); |
|
58 | + } |
|
59 | 59 | |
60 | - $item_html = apply_filters( 'lsx_wp_nav_menu_item', $item_html ); |
|
61 | - $output .= $item_html; |
|
62 | - } |
|
63 | - } |
|
60 | + $item_html = apply_filters( 'lsx_wp_nav_menu_item', $item_html ); |
|
61 | + $output .= $item_html; |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | - function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { |
|
66 | - $element->is_dropdown = ( ( ! empty( $children_elements[ $element->ID ] ) && ( ( $depth + 1 ) < $max_depth || ( 0 === $max_depth ) ) ) ); |
|
65 | + function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { |
|
66 | + $element->is_dropdown = ( ( ! empty( $children_elements[ $element->ID ] ) && ( ( $depth + 1 ) < $max_depth || ( 0 === $max_depth ) ) ) ); |
|
67 | 67 | |
68 | - if ( $element->is_dropdown ) { |
|
69 | - if ( $depth > 0 ) { |
|
70 | - $element->classes[] = 'dropdown-submenu'; |
|
71 | - } else { |
|
72 | - $element->classes[] = 'dropdown'; |
|
73 | - } |
|
74 | - } |
|
68 | + if ( $element->is_dropdown ) { |
|
69 | + if ( $depth > 0 ) { |
|
70 | + $element->classes[] = 'dropdown-submenu'; |
|
71 | + } else { |
|
72 | + $element->classes[] = 'dropdown'; |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
|
77 | - } |
|
76 | + parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
|
77 | + } |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | endif; |
@@ -8,78 +8,78 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; |
|
11 | + exit; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | if ( ! class_exists( 'WP_Customize_Control' ) ) { |
15 | - return; |
|
15 | + return; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if ( ! class_exists( 'LSX_Customize_Mobile_Header_Layout_Control' ) ) : |
19 | 19 | |
20 | - /** |
|
21 | - * LSX_Customize_Mobile_Header_Layout_Control Class |
|
22 | - * |
|
23 | - * @package lsx |
|
24 | - * @subpackage customizer |
|
25 | - * @category mobile-header-layout |
|
26 | - */ |
|
27 | - class LSX_Customize_Mobile_Header_Layout_Control extends WP_Customize_Control { |
|
20 | + /** |
|
21 | + * LSX_Customize_Mobile_Header_Layout_Control Class |
|
22 | + * |
|
23 | + * @package lsx |
|
24 | + * @subpackage customizer |
|
25 | + * @category mobile-header-layout |
|
26 | + */ |
|
27 | + class LSX_Customize_Mobile_Header_Layout_Control extends WP_Customize_Control { |
|
28 | 28 | |
29 | - public $type = 'layout'; |
|
30 | - public $statuses; |
|
31 | - public $layouts = array(); |
|
29 | + public $type = 'layout'; |
|
30 | + public $statuses; |
|
31 | + public $layouts = array(); |
|
32 | 32 | |
33 | - public function __construct( $manager, $id, $args = array() ) { |
|
34 | - parent::__construct( $manager, $id, $args ); |
|
33 | + public function __construct( $manager, $id, $args = array() ) { |
|
34 | + parent::__construct( $manager, $id, $args ); |
|
35 | 35 | |
36 | - if ( ! empty( $args['choices'] ) ) { |
|
37 | - $this->layouts = $args['choices']; |
|
38 | - } |
|
39 | - } |
|
36 | + if ( ! empty( $args['choices'] ) ) { |
|
37 | + $this->layouts = $args['choices']; |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Enqueue scripts/styles for the color picker. |
|
43 | - */ |
|
44 | - public function enqueue() { |
|
45 | - wp_enqueue_script( 'lsx-mobile-header-layout-control', get_template_directory_uri() . '/assets/js/admin/customizer-mobile-header-layout.js', array( 'jquery' ), LSX_VERSION, true ); |
|
46 | - } |
|
41 | + /** |
|
42 | + * Enqueue scripts/styles for the color picker. |
|
43 | + */ |
|
44 | + public function enqueue() { |
|
45 | + wp_enqueue_script( 'lsx-mobile-header-layout-control', get_template_directory_uri() . '/assets/js/admin/customizer-mobile-header-layout.js', array( 'jquery' ), LSX_VERSION, true ); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Render output. |
|
50 | - */ |
|
51 | - public function render_content() { |
|
52 | - $post_id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); |
|
53 | - $class = 'customize-control customize-control-' . $this->type; |
|
54 | - $value = $this->value(); |
|
55 | - ?> |
|
48 | + /** |
|
49 | + * Render output. |
|
50 | + */ |
|
51 | + public function render_content() { |
|
52 | + $post_id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); |
|
53 | + $class = 'customize-control customize-control-' . $this->type; |
|
54 | + $value = $this->value(); |
|
55 | + ?> |
|
56 | 56 | <label> |
57 | 57 | <?php |
58 | - if ( ! empty( $this->label ) ) { |
|
59 | - ?> |
|
58 | + if ( ! empty( $this->label ) ) { |
|
59 | + ?> |
|
60 | 60 | <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
61 | 61 | <?php |
62 | - } |
|
63 | - if ( ! empty( $this->description ) ) { |
|
64 | - ?> |
|
62 | + } |
|
63 | + if ( ! empty( $this->description ) ) { |
|
64 | + ?> |
|
65 | 65 | <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> |
66 | 66 | <?php } ?> |
67 | 67 | <div class="mobile-header-layouts-selector"> |
68 | 68 | <?php |
69 | - foreach ( $this->layouts as $layout ) { |
|
70 | - $sel = 'border: 1px solid transparent;'; |
|
71 | - if ( $value === $layout ) { |
|
72 | - $sel = 'border: 1px solid rgb(43, 166, 203);'; |
|
73 | - } |
|
74 | - echo '<img class="mobile-header-layout-button" style="max-width:180px;padding:2px;' . esc_attr( $sel ) . '" src="' . esc_attr( get_template_directory_uri() ) . '/assets/images/admin/header-' . esc_attr( $layout ) . '.png" data-option="' . esc_attr( $layout ) . '">'; |
|
75 | - } |
|
76 | - ?> |
|
69 | + foreach ( $this->layouts as $layout ) { |
|
70 | + $sel = 'border: 1px solid transparent;'; |
|
71 | + if ( $value === $layout ) { |
|
72 | + $sel = 'border: 1px solid rgb(43, 166, 203);'; |
|
73 | + } |
|
74 | + echo '<img class="mobile-header-layout-button" style="max-width:180px;padding:2px;' . esc_attr( $sel ) . '" src="' . esc_attr( get_template_directory_uri() ) . '/assets/images/admin/header-' . esc_attr( $layout ) . '.png" data-option="' . esc_attr( $layout ) . '">'; |
|
75 | + } |
|
76 | + ?> |
|
77 | 77 | <input <?php $this->link(); ?> class="selected-mobile-header-layout <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $post_id ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>" <?php $this->input_attrs(); ?>> |
78 | 78 | </div> |
79 | 79 | </label> |
80 | 80 | <?php |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | endif; |
@@ -8,78 +8,78 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; |
|
11 | + exit; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | if ( ! class_exists( 'WP_Customize_Control' ) ) { |
15 | - return; |
|
15 | + return; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if ( ! class_exists( 'LSX_Customize_Header_Layout_Control' ) ) : |
19 | 19 | |
20 | - /** |
|
21 | - * LSX_Customize_Header_Layout_Control Class |
|
22 | - * |
|
23 | - * @package lsx |
|
24 | - * @subpackage customizer |
|
25 | - * @category header-layout |
|
26 | - */ |
|
27 | - class LSX_Customize_Header_Layout_Control extends WP_Customize_Control { |
|
20 | + /** |
|
21 | + * LSX_Customize_Header_Layout_Control Class |
|
22 | + * |
|
23 | + * @package lsx |
|
24 | + * @subpackage customizer |
|
25 | + * @category header-layout |
|
26 | + */ |
|
27 | + class LSX_Customize_Header_Layout_Control extends WP_Customize_Control { |
|
28 | 28 | |
29 | - public $type = 'layout'; |
|
30 | - public $statuses; |
|
31 | - public $layouts = array(); |
|
29 | + public $type = 'layout'; |
|
30 | + public $statuses; |
|
31 | + public $layouts = array(); |
|
32 | 32 | |
33 | - public function __construct( $manager, $id, $args = array() ) { |
|
34 | - parent::__construct( $manager, $id, $args ); |
|
33 | + public function __construct( $manager, $id, $args = array() ) { |
|
34 | + parent::__construct( $manager, $id, $args ); |
|
35 | 35 | |
36 | - if ( ! empty( $args['choices'] ) ) { |
|
37 | - $this->layouts = $args['choices']; |
|
38 | - } |
|
39 | - } |
|
36 | + if ( ! empty( $args['choices'] ) ) { |
|
37 | + $this->layouts = $args['choices']; |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Enqueue scripts/styles for the color picker. |
|
43 | - */ |
|
44 | - public function enqueue() { |
|
45 | - wp_enqueue_script( 'lsx-header-layout-control', get_template_directory_uri() . '/assets/js/admin/customizer-header-layout.js', array( 'jquery' ), LSX_VERSION, true ); |
|
46 | - } |
|
41 | + /** |
|
42 | + * Enqueue scripts/styles for the color picker. |
|
43 | + */ |
|
44 | + public function enqueue() { |
|
45 | + wp_enqueue_script( 'lsx-header-layout-control', get_template_directory_uri() . '/assets/js/admin/customizer-header-layout.js', array( 'jquery' ), LSX_VERSION, true ); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Render output. |
|
50 | - */ |
|
51 | - public function render_content() { |
|
52 | - $post_id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); |
|
53 | - $class = 'customize-control customize-control-' . $this->type; |
|
54 | - $value = $this->value(); |
|
55 | - ?> |
|
48 | + /** |
|
49 | + * Render output. |
|
50 | + */ |
|
51 | + public function render_content() { |
|
52 | + $post_id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); |
|
53 | + $class = 'customize-control customize-control-' . $this->type; |
|
54 | + $value = $this->value(); |
|
55 | + ?> |
|
56 | 56 | <label> |
57 | 57 | <?php |
58 | - if ( ! empty( $this->label ) ) { |
|
59 | - ?> |
|
58 | + if ( ! empty( $this->label ) ) { |
|
59 | + ?> |
|
60 | 60 | <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
61 | 61 | <?php |
62 | - } |
|
63 | - if ( ! empty( $this->description ) ) { |
|
64 | - ?> |
|
62 | + } |
|
63 | + if ( ! empty( $this->description ) ) { |
|
64 | + ?> |
|
65 | 65 | <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> |
66 | 66 | <?php } ?> |
67 | 67 | <div class="header-layouts-selector"> |
68 | 68 | <?php |
69 | - foreach ( $this->layouts as $layout ) { |
|
70 | - $sel = 'border: 1px solid transparent;'; |
|
71 | - if ( $value === $layout ) { |
|
72 | - $sel = 'border: 1px solid rgb(43, 166, 203);'; |
|
73 | - } |
|
74 | - echo '<img class="header-layout-button" style="padding:2px;' . esc_attr( $sel ) . '" src="' . esc_attr( get_template_directory_uri() ) . '/assets/images/admin/header-' . esc_attr( $layout ) . '.png" data-option="' . esc_attr( $layout ) . '">'; |
|
75 | - } |
|
76 | - ?> |
|
69 | + foreach ( $this->layouts as $layout ) { |
|
70 | + $sel = 'border: 1px solid transparent;'; |
|
71 | + if ( $value === $layout ) { |
|
72 | + $sel = 'border: 1px solid rgb(43, 166, 203);'; |
|
73 | + } |
|
74 | + echo '<img class="header-layout-button" style="padding:2px;' . esc_attr( $sel ) . '" src="' . esc_attr( get_template_directory_uri() ) . '/assets/images/admin/header-' . esc_attr( $layout ) . '.png" data-option="' . esc_attr( $layout ) . '">'; |
|
75 | + } |
|
76 | + ?> |
|
77 | 77 | <input <?php $this->link(); ?> class="selected-header-layout <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $post_id ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>" <?php $this->input_attrs(); ?>> |
78 | 78 | </div> |
79 | 79 | </label> |
80 | 80 | <?php |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | endif; |
@@ -7,61 +7,61 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if ( ! class_exists( 'Walker_Comment' ) ) { |
14 | - return; |
|
14 | + return; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | if ( ! class_exists( 'LSX_Walker_Comment' ) ) : |
18 | 18 | |
19 | - /** |
|
20 | - * Use Bootstrap's media object for listing comments. |
|
21 | - * |
|
22 | - * @link http://getbootstrap.com/components/#media |
|
23 | - * |
|
24 | - * @package lsx |
|
25 | - * @subpackage comment |
|
26 | - */ |
|
27 | - class LSX_Walker_Comment extends Walker_Comment { |
|
19 | + /** |
|
20 | + * Use Bootstrap's media object for listing comments. |
|
21 | + * |
|
22 | + * @link http://getbootstrap.com/components/#media |
|
23 | + * |
|
24 | + * @package lsx |
|
25 | + * @subpackage comment |
|
26 | + */ |
|
27 | + class LSX_Walker_Comment extends Walker_Comment { |
|
28 | 28 | |
29 | - function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
30 | - $GLOBALS['comment_depth'] = $depth + 1; ?> |
|
29 | + function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
30 | + $GLOBALS['comment_depth'] = $depth + 1; ?> |
|
31 | 31 | <ul <?php comment_class( 'media media-reply unstyled list-unstyled comment-' . get_comment_ID() ); ?>> |
32 | 32 | <?php |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - function end_lvl( &$output, $depth = 0, $args = array() ) { |
|
36 | - $GLOBALS['comment_depth'] = $depth + 1; |
|
37 | - echo '</ul>'; |
|
38 | - } |
|
35 | + function end_lvl( &$output, $depth = 0, $args = array() ) { |
|
36 | + $GLOBALS['comment_depth'] = $depth + 1; |
|
37 | + echo '</ul>'; |
|
38 | + } |
|
39 | 39 | |
40 | - function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) { |
|
41 | - ++$depth; |
|
42 | - $GLOBALS['comment_depth'] = $depth; |
|
43 | - $GLOBALS['comment'] = $comment; |
|
40 | + function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) { |
|
41 | + ++$depth; |
|
42 | + $GLOBALS['comment_depth'] = $depth; |
|
43 | + $GLOBALS['comment'] = $comment; |
|
44 | 44 | |
45 | - if ( ! empty( $args['callback'] ) ) { |
|
46 | - call_user_func( $args['callback'], $comment, $args, $depth ); |
|
47 | - return; |
|
48 | - } |
|
49 | - ?> |
|
45 | + if ( ! empty( $args['callback'] ) ) { |
|
46 | + call_user_func( $args['callback'], $comment, $args, $depth ); |
|
47 | + return; |
|
48 | + } |
|
49 | + ?> |
|
50 | 50 | |
51 | 51 | <li id="comment-<?php comment_ID(); ?>" <?php comment_class( 'media comment-' . get_comment_ID() ); ?>> |
52 | 52 | <?php get_template_part( 'comment' ); ?> |
53 | 53 | <?php |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - function end_el( &$output, $comment, $depth = 0, $args = array() ) { |
|
57 | - if ( ! empty( $args['end-callback'] ) ) { |
|
58 | - call_user_func( $args['end-callback'], $comment, $args, $depth ); |
|
59 | - return; |
|
60 | - } |
|
56 | + function end_el( &$output, $comment, $depth = 0, $args = array() ) { |
|
57 | + if ( ! empty( $args['end-callback'] ) ) { |
|
58 | + call_user_func( $args['end-callback'], $comment, $args, $depth ); |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - echo "</div></li>\n"; |
|
63 | - } |
|
62 | + echo "</div></li>\n"; |
|
63 | + } |
|
64 | 64 | |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | endif; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -14,67 +14,67 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class LSX_Optimisation { |
16 | 16 | |
17 | - /** |
|
18 | - * Holds class instance |
|
19 | - * |
|
20 | - * @since 1.0.0 |
|
21 | - * @var object |
|
22 | - */ |
|
23 | - protected static $instance = null; |
|
17 | + /** |
|
18 | + * Holds class instance |
|
19 | + * |
|
20 | + * @since 1.0.0 |
|
21 | + * @var object |
|
22 | + */ |
|
23 | + protected static $instance = null; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Constructor. |
|
27 | - */ |
|
28 | - public function __construct() { |
|
29 | - //add_filter( 'style_loader_tag', array( $this, 'preload_css' ), 100, 4 ); |
|
30 | - //add_filter( 'script_loader_tag', array( $this, 'defer_parsing_of_js' ), 100, 3 ); |
|
31 | - add_action( 'init', array( $this, 'pum_remove_admin_bar_tools' ), 100 ); |
|
32 | - } |
|
33 | - /** |
|
34 | - * Return an instance of this class. |
|
35 | - * |
|
36 | - * @since 1.0.0 |
|
37 | - * @return object A single instance of this class. |
|
38 | - */ |
|
39 | - public static function get_instance() { |
|
40 | - // If the single instance hasn't been set, set it now. |
|
41 | - if ( null === self::$instance ) { |
|
42 | - self::$instance = new self; |
|
43 | - } |
|
44 | - return self::$instance; |
|
45 | - } |
|
25 | + /** |
|
26 | + * Constructor. |
|
27 | + */ |
|
28 | + public function __construct() { |
|
29 | + //add_filter( 'style_loader_tag', array( $this, 'preload_css' ), 100, 4 ); |
|
30 | + //add_filter( 'script_loader_tag', array( $this, 'defer_parsing_of_js' ), 100, 3 ); |
|
31 | + add_action( 'init', array( $this, 'pum_remove_admin_bar_tools' ), 100 ); |
|
32 | + } |
|
33 | + /** |
|
34 | + * Return an instance of this class. |
|
35 | + * |
|
36 | + * @since 1.0.0 |
|
37 | + * @return object A single instance of this class. |
|
38 | + */ |
|
39 | + public static function get_instance() { |
|
40 | + // If the single instance hasn't been set, set it now. |
|
41 | + if ( null === self::$instance ) { |
|
42 | + self::$instance = new self; |
|
43 | + } |
|
44 | + return self::$instance; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Defers the JS loading till Last |
|
49 | - * |
|
50 | - * @param string $url The url to check and defer. |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function preload_css( $tag, $handle, $href, $media ) { |
|
54 | - if ( 'lsx_fonts' === $handle || 'fontawesome' === $handle ) { |
|
55 | - $tag = str_replace( 'href', ' preload href', $tag ); |
|
56 | - } |
|
57 | - return $tag; |
|
58 | - } |
|
47 | + /** |
|
48 | + * Defers the JS loading till Last |
|
49 | + * |
|
50 | + * @param string $url The url to check and defer. |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function preload_css( $tag, $handle, $href, $media ) { |
|
54 | + if ( 'lsx_fonts' === $handle || 'fontawesome' === $handle ) { |
|
55 | + $tag = str_replace( 'href', ' preload href', $tag ); |
|
56 | + } |
|
57 | + return $tag; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Defers the JS loading till Last |
|
62 | - * |
|
63 | - * @param string $url The url to check and defer. |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function defer_parsing_of_js( $tag, $handle, $href ) { |
|
67 | - $skip_defer = apply_filters( 'lsx_defer_parsing_of_js', false, $tag, $handle, $href ); |
|
68 | - if ( ! is_admin() && false !== stripos( $href, '.js' ) && false === stripos( $href, 'jquery.js' ) && false === $skip_defer ) { |
|
69 | - $tag = str_replace( 'src=', ' defer src=', $tag ); |
|
70 | - } |
|
71 | - return $tag; |
|
72 | - } |
|
60 | + /** |
|
61 | + * Defers the JS loading till Last |
|
62 | + * |
|
63 | + * @param string $url The url to check and defer. |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function defer_parsing_of_js( $tag, $handle, $href ) { |
|
67 | + $skip_defer = apply_filters( 'lsx_defer_parsing_of_js', false, $tag, $handle, $href ); |
|
68 | + if ( ! is_admin() && false !== stripos( $href, '.js' ) && false === stripos( $href, 'jquery.js' ) && false === $skip_defer ) { |
|
69 | + $tag = str_replace( 'src=', ' defer src=', $tag ); |
|
70 | + } |
|
71 | + return $tag; |
|
72 | + } |
|
73 | 73 | |
74 | - public function pum_remove_admin_bar_tools() { |
|
75 | - remove_action( 'admin_bar_menu', array( 'PUM_Modules_Admin_Bar', 'toolbar_links' ), 999 ); |
|
76 | - remove_action( 'wp_footer', array( 'PUM_Modules_Admin_Bar', 'admin_bar_styles' ), 999 ); |
|
77 | - remove_action( 'init', array( 'PUM_Modules_Admin_Bar', 'show_debug_bar' ) ); |
|
78 | - } |
|
74 | + public function pum_remove_admin_bar_tools() { |
|
75 | + remove_action( 'admin_bar_menu', array( 'PUM_Modules_Admin_Bar', 'toolbar_links' ), 999 ); |
|
76 | + remove_action( 'wp_footer', array( 'PUM_Modules_Admin_Bar', 'admin_bar_styles' ), 999 ); |
|
77 | + remove_action( 'init', array( 'PUM_Modules_Admin_Bar', 'show_debug_bar' ) ); |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | LSX_Optimisation::get_instance(); |
@@ -8,47 +8,47 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; |
|
11 | + exit; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | if ( ! class_exists( 'WP_Customize_Control' ) ) { |
15 | - return; |
|
15 | + return; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if ( ! class_exists( 'LSX_Customize_Core_Control' ) ) : |
19 | 19 | |
20 | - /** |
|
21 | - * LSX_Customize_Core_Control Class |
|
22 | - * |
|
23 | - * @package lsx |
|
24 | - * @subpackage customizer |
|
25 | - * @category core |
|
26 | - */ |
|
27 | - class LSX_Customize_Core_Control extends WP_Customize_Control { |
|
28 | - |
|
29 | - public $type = 'core'; |
|
30 | - |
|
31 | - /** |
|
32 | - * Render output. |
|
33 | - */ |
|
34 | - public function render_content() { |
|
35 | - ?> |
|
20 | + /** |
|
21 | + * LSX_Customize_Core_Control Class |
|
22 | + * |
|
23 | + * @package lsx |
|
24 | + * @subpackage customizer |
|
25 | + * @category core |
|
26 | + */ |
|
27 | + class LSX_Customize_Core_Control extends WP_Customize_Control { |
|
28 | + |
|
29 | + public $type = 'core'; |
|
30 | + |
|
31 | + /** |
|
32 | + * Render output. |
|
33 | + */ |
|
34 | + public function render_content() { |
|
35 | + ?> |
|
36 | 36 | <label> |
37 | 37 | <?php |
38 | - if ( ! empty( $this->label ) ) { |
|
39 | - ?> |
|
38 | + if ( ! empty( $this->label ) ) { |
|
39 | + ?> |
|
40 | 40 | <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
41 | 41 | <?php |
42 | - } |
|
43 | - if ( ! empty( $this->description ) ) { |
|
44 | - ?> |
|
42 | + } |
|
43 | + if ( ! empty( $this->description ) ) { |
|
44 | + ?> |
|
45 | 45 | <span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> |
46 | 46 | <?php } ?> |
47 | 47 | <input <?php $this->link(); ?> type="checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->input_attrs(); ?>> |
48 | 48 | </label> |
49 | 49 | <?php |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - } |
|
52 | + } |
|
53 | 53 | |
54 | 54 | endif; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -14,69 +14,69 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class LSX_Rest_Helper { |
16 | 16 | |
17 | - /** |
|
18 | - * Holds class instance |
|
19 | - * |
|
20 | - * @since 1.0.0 |
|
21 | - * @var object |
|
22 | - */ |
|
23 | - protected static $instance = null; |
|
17 | + /** |
|
18 | + * Holds class instance |
|
19 | + * |
|
20 | + * @since 1.0.0 |
|
21 | + * @var object |
|
22 | + */ |
|
23 | + protected static $instance = null; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Holds the conditional. |
|
27 | - * |
|
28 | - * @var boolean |
|
29 | - */ |
|
30 | - protected $is_rest_request = false; |
|
25 | + /** |
|
26 | + * Holds the conditional. |
|
27 | + * |
|
28 | + * @var boolean |
|
29 | + */ |
|
30 | + protected $is_rest_request = false; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor. |
|
34 | - */ |
|
35 | - public function __construct() { |
|
36 | - add_filter( 'tribe_events_views_v2_rest_params', array( $this, 'check_event_request' ), 10, 2 ); |
|
37 | - } |
|
38 | - /** |
|
39 | - * Return an instance of this class. |
|
40 | - * |
|
41 | - * @since 1.0.0 |
|
42 | - * @return object A single instance of this class. |
|
43 | - */ |
|
44 | - public static function get_instance() { |
|
45 | - // If the single instance hasn't been set, set it now. |
|
46 | - if ( null === self::$instance ) { |
|
47 | - self::$instance = new self; |
|
48 | - } |
|
49 | - return self::$instance; |
|
50 | - } |
|
32 | + /** |
|
33 | + * Constructor. |
|
34 | + */ |
|
35 | + public function __construct() { |
|
36 | + add_filter( 'tribe_events_views_v2_rest_params', array( $this, 'check_event_request' ), 10, 2 ); |
|
37 | + } |
|
38 | + /** |
|
39 | + * Return an instance of this class. |
|
40 | + * |
|
41 | + * @since 1.0.0 |
|
42 | + * @return object A single instance of this class. |
|
43 | + */ |
|
44 | + public static function get_instance() { |
|
45 | + // If the single instance hasn't been set, set it now. |
|
46 | + if ( null === self::$instance ) { |
|
47 | + self::$instance = new self; |
|
48 | + } |
|
49 | + return self::$instance; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * This will set the 'is_rest_request' variable as true if it runs. Tribe has already done the checkes for us. |
|
54 | - * |
|
55 | - * @param array $params |
|
56 | - * @param array $request |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function check_event_request( $params, $request ) { |
|
60 | - $this->is_rest_request = true; |
|
61 | - return $params; |
|
62 | - } |
|
52 | + /** |
|
53 | + * This will set the 'is_rest_request' variable as true if it runs. Tribe has already done the checkes for us. |
|
54 | + * |
|
55 | + * @param array $params |
|
56 | + * @param array $request |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function check_event_request( $params, $request ) { |
|
60 | + $this->is_rest_request = true; |
|
61 | + return $params; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Determines if the request is an REST API request. |
|
66 | - * |
|
67 | - * @return bool True if it's a REST API request, false otherwise. |
|
68 | - */ |
|
69 | - public function is_rest_api_request() { |
|
70 | - if ( true === $this->is_rest_request ) { |
|
71 | - return $this->is_rest_request; |
|
72 | - } |
|
64 | + /** |
|
65 | + * Determines if the request is an REST API request. |
|
66 | + * |
|
67 | + * @return bool True if it's a REST API request, false otherwise. |
|
68 | + */ |
|
69 | + public function is_rest_api_request() { |
|
70 | + if ( true === $this->is_rest_request ) { |
|
71 | + return $this->is_rest_request; |
|
72 | + } |
|
73 | 73 | |
74 | - if ( empty( $_SERVER['REQUEST_URI'] ) ) { |
|
75 | - return false; |
|
76 | - } |
|
77 | - $rest_prefix = trailingslashit( rest_get_url_prefix() ); |
|
78 | - $this->is_rest_request = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) ); |
|
79 | - return $this->is_rest_request; |
|
80 | - } |
|
74 | + if ( empty( $_SERVER['REQUEST_URI'] ) ) { |
|
75 | + return false; |
|
76 | + } |
|
77 | + $rest_prefix = trailingslashit( rest_get_url_prefix() ); |
|
78 | + $this->is_rest_request = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) ); |
|
79 | + return $this->is_rest_request; |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | $rest_helper = LSX_Rest_Helper::get_instance(); |
@@ -7,217 +7,217 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if ( ! class_exists( 'LSX_Theme_Customizer' ) ) : |
14 | 14 | |
15 | - /** |
|
16 | - * Customizer Configuration File |
|
17 | - * |
|
18 | - * @package lsx |
|
19 | - * @subpackage customizer |
|
20 | - */ |
|
21 | - class LSX_Theme_Customizer { |
|
22 | - |
|
23 | - public $post_types = array(); |
|
24 | - private $controls = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * Initialize the plugin by setting localization and loading public scripts and styles. |
|
28 | - */ |
|
29 | - public function __construct( $controls ) { |
|
30 | - require get_template_directory() . '/includes/classes/class-lsx-customize-core-control.php'; |
|
31 | - require get_template_directory() . '/includes/classes/class-lsx-customize-layout-control.php'; |
|
32 | - require get_template_directory() . '/includes/classes/class-lsx-customize-header-layout-control.php'; |
|
33 | - require get_template_directory() . '/includes/classes/class-lsx-customize-mobile-header-layout-control.php'; |
|
34 | - |
|
35 | - $this->controls = $controls; |
|
36 | - |
|
37 | - add_action( 'customize_preview_init', array( $this, 'customize_preview_js' ), 20 ); |
|
38 | - add_action( 'customize_register', array( $this, 'customizer' ), 11 ); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. |
|
43 | - */ |
|
44 | - public function customize_preview_js() { |
|
45 | - wp_enqueue_script( 'lsx_customizer', get_template_directory_uri() . '/assets/js/admin/customizer.js', array( 'customize-preview' ), LSX_VERSION, true ); |
|
46 | - |
|
47 | - wp_localize_script( |
|
48 | - 'lsx_customizer', |
|
49 | - 'lsx_customizer_params', |
|
50 | - array( |
|
51 | - 'template_directory' => get_template_directory_uri(), |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Create customiser controls. |
|
58 | - */ |
|
59 | - public function customizer( $wp_customize ) { |
|
60 | - // Start panels. |
|
61 | - if ( ! empty( $this->controls['panels'] ) ) { |
|
62 | - foreach ( $this->controls['panels'] as $panel_slug => $args ) { |
|
63 | - $this->add_panel( $panel_slug, $args, $wp_customize ); |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - // Start sections. |
|
68 | - if ( ! empty( $this->controls['sections'] ) ) { |
|
69 | - foreach ( $this->controls['sections'] as $section_slug => $args ) { |
|
70 | - $this->add_section( $section_slug, $args, $wp_customize ); |
|
71 | - } |
|
72 | - } |
|
73 | - |
|
74 | - // Start settings. |
|
75 | - if ( ! empty( $this->controls['settings'] ) ) { |
|
76 | - foreach ( $this->controls['settings'] as $settings_slug => $args ) { |
|
77 | - $this->add_setting( $settings_slug, $args, $wp_customize ); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - // Start fields. |
|
82 | - if ( ! empty( $this->controls['fields'] ) ) { |
|
83 | - foreach ( $this->controls['fields'] as $field_slug => $args ) { |
|
84 | - $this->add_control( $field_slug, $args, $wp_customize ); |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - // Start selective refresh. |
|
89 | - if ( ! empty( $this->controls['selective_refresh'] ) ) { |
|
90 | - foreach ( $this->controls['selective_refresh'] as $field_slug => $args ) { |
|
91 | - $this->add_selective_refresh( $field_slug, $args, $wp_customize ); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; |
|
96 | - $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; |
|
97 | - $wp_customize->get_setting( 'background_color' )->transport = 'postMessage'; |
|
98 | - |
|
99 | - $wp_customize->selective_refresh->add_partial( |
|
100 | - 'blogname', |
|
101 | - array( |
|
102 | - 'selector' => 'h1.site-title a', |
|
103 | - 'render_callback' => function() { |
|
104 | - bloginfo( 'name' ); |
|
105 | - }, |
|
106 | - ) |
|
107 | - ); |
|
108 | - |
|
109 | - $wp_customize->selective_refresh->add_partial( |
|
110 | - 'blogdescription', |
|
111 | - array( |
|
112 | - 'selector' => '.site-description', |
|
113 | - 'render_callback' => function() { |
|
114 | - bloginfo( 'description' ); |
|
115 | - }, |
|
116 | - ) |
|
117 | - ); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Create a panel. |
|
122 | - */ |
|
123 | - private function add_panel( $slug, $args, $wp_customize ) { |
|
124 | - $default_args = array( |
|
125 | - 'title' => null, |
|
126 | - 'description' => null, |
|
127 | - ); |
|
128 | - |
|
129 | - $wp_customize->add_panel( |
|
130 | - $slug, |
|
131 | - array_merge( $default_args, $args ) |
|
132 | - ); |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Create a section. |
|
137 | - */ |
|
138 | - private function add_section( $slug, $args, $wp_customize ) { |
|
139 | - $default_args = array( |
|
140 | - 'capability' => 'edit_theme_options', |
|
141 | - 'description' => null, |
|
142 | - ); |
|
143 | - |
|
144 | - $wp_customize->add_section( $slug, array_merge( $default_args, $args ) ); |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Create a setting. |
|
149 | - */ |
|
150 | - private function add_setting( $slug, $args, $wp_customize ) { |
|
151 | - $wp_customize->add_setting( |
|
152 | - $slug, |
|
153 | - array_merge( |
|
154 | - array( |
|
155 | - 'default' => null, |
|
156 | - 'type' => 'theme_mod', |
|
157 | - 'capability' => 'edit_theme_options', |
|
158 | - 'transport' => 'postMessage', |
|
159 | - 'sanitize_callback' => 'lsx_sanitize_choices', |
|
160 | - ), |
|
161 | - $args |
|
162 | - ) |
|
163 | - ); |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Create a control. |
|
168 | - */ |
|
169 | - private function add_control( $slug, $args, $wp_customize ) { |
|
170 | - $default_args = array(); |
|
171 | - |
|
172 | - if ( isset( $args['control'] ) && class_exists( $args['control'] ) ) { |
|
173 | - $control_class = $args['control']; |
|
174 | - unset( $args['control'] ); |
|
175 | - |
|
176 | - $control = new $control_class( $wp_customize, $slug, array_merge( $default_args, $args ) ); |
|
177 | - $wp_customize->add_control( $control ); |
|
178 | - } else { |
|
179 | - if ( isset( $args['control'] ) ) { |
|
180 | - unset( $args['control'] ); |
|
181 | - } |
|
182 | - |
|
183 | - $wp_customize->add_control( |
|
184 | - $slug, |
|
185 | - array_merge( $default_args, $args ) |
|
186 | - ); |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Create a selective refresh. |
|
192 | - */ |
|
193 | - private function add_selective_refresh( $slug, $args, $wp_customize ) { |
|
194 | - $default_args = array( |
|
195 | - 'selector' => null, |
|
196 | - 'render_callback' => null, |
|
197 | - ); |
|
198 | - |
|
199 | - $wp_customize->selective_refresh->add_partial( |
|
200 | - $slug, |
|
201 | - array_merge( $default_args, $args ) |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * Returns a registered field. |
|
207 | - */ |
|
208 | - public function get_control( $id ) { |
|
209 | - $field = $this->controls['fields'][ $id ]; |
|
210 | - return $field; |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Returns a registered setting. |
|
215 | - */ |
|
216 | - public function get_setting( $id ) { |
|
217 | - $setting = $this->controls['settings'][ $id ]; |
|
218 | - return $setting; |
|
219 | - } |
|
220 | - |
|
221 | - } |
|
15 | + /** |
|
16 | + * Customizer Configuration File |
|
17 | + * |
|
18 | + * @package lsx |
|
19 | + * @subpackage customizer |
|
20 | + */ |
|
21 | + class LSX_Theme_Customizer { |
|
22 | + |
|
23 | + public $post_types = array(); |
|
24 | + private $controls = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * Initialize the plugin by setting localization and loading public scripts and styles. |
|
28 | + */ |
|
29 | + public function __construct( $controls ) { |
|
30 | + require get_template_directory() . '/includes/classes/class-lsx-customize-core-control.php'; |
|
31 | + require get_template_directory() . '/includes/classes/class-lsx-customize-layout-control.php'; |
|
32 | + require get_template_directory() . '/includes/classes/class-lsx-customize-header-layout-control.php'; |
|
33 | + require get_template_directory() . '/includes/classes/class-lsx-customize-mobile-header-layout-control.php'; |
|
34 | + |
|
35 | + $this->controls = $controls; |
|
36 | + |
|
37 | + add_action( 'customize_preview_init', array( $this, 'customize_preview_js' ), 20 ); |
|
38 | + add_action( 'customize_register', array( $this, 'customizer' ), 11 ); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. |
|
43 | + */ |
|
44 | + public function customize_preview_js() { |
|
45 | + wp_enqueue_script( 'lsx_customizer', get_template_directory_uri() . '/assets/js/admin/customizer.js', array( 'customize-preview' ), LSX_VERSION, true ); |
|
46 | + |
|
47 | + wp_localize_script( |
|
48 | + 'lsx_customizer', |
|
49 | + 'lsx_customizer_params', |
|
50 | + array( |
|
51 | + 'template_directory' => get_template_directory_uri(), |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Create customiser controls. |
|
58 | + */ |
|
59 | + public function customizer( $wp_customize ) { |
|
60 | + // Start panels. |
|
61 | + if ( ! empty( $this->controls['panels'] ) ) { |
|
62 | + foreach ( $this->controls['panels'] as $panel_slug => $args ) { |
|
63 | + $this->add_panel( $panel_slug, $args, $wp_customize ); |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + // Start sections. |
|
68 | + if ( ! empty( $this->controls['sections'] ) ) { |
|
69 | + foreach ( $this->controls['sections'] as $section_slug => $args ) { |
|
70 | + $this->add_section( $section_slug, $args, $wp_customize ); |
|
71 | + } |
|
72 | + } |
|
73 | + |
|
74 | + // Start settings. |
|
75 | + if ( ! empty( $this->controls['settings'] ) ) { |
|
76 | + foreach ( $this->controls['settings'] as $settings_slug => $args ) { |
|
77 | + $this->add_setting( $settings_slug, $args, $wp_customize ); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + // Start fields. |
|
82 | + if ( ! empty( $this->controls['fields'] ) ) { |
|
83 | + foreach ( $this->controls['fields'] as $field_slug => $args ) { |
|
84 | + $this->add_control( $field_slug, $args, $wp_customize ); |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + // Start selective refresh. |
|
89 | + if ( ! empty( $this->controls['selective_refresh'] ) ) { |
|
90 | + foreach ( $this->controls['selective_refresh'] as $field_slug => $args ) { |
|
91 | + $this->add_selective_refresh( $field_slug, $args, $wp_customize ); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; |
|
96 | + $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; |
|
97 | + $wp_customize->get_setting( 'background_color' )->transport = 'postMessage'; |
|
98 | + |
|
99 | + $wp_customize->selective_refresh->add_partial( |
|
100 | + 'blogname', |
|
101 | + array( |
|
102 | + 'selector' => 'h1.site-title a', |
|
103 | + 'render_callback' => function() { |
|
104 | + bloginfo( 'name' ); |
|
105 | + }, |
|
106 | + ) |
|
107 | + ); |
|
108 | + |
|
109 | + $wp_customize->selective_refresh->add_partial( |
|
110 | + 'blogdescription', |
|
111 | + array( |
|
112 | + 'selector' => '.site-description', |
|
113 | + 'render_callback' => function() { |
|
114 | + bloginfo( 'description' ); |
|
115 | + }, |
|
116 | + ) |
|
117 | + ); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Create a panel. |
|
122 | + */ |
|
123 | + private function add_panel( $slug, $args, $wp_customize ) { |
|
124 | + $default_args = array( |
|
125 | + 'title' => null, |
|
126 | + 'description' => null, |
|
127 | + ); |
|
128 | + |
|
129 | + $wp_customize->add_panel( |
|
130 | + $slug, |
|
131 | + array_merge( $default_args, $args ) |
|
132 | + ); |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Create a section. |
|
137 | + */ |
|
138 | + private function add_section( $slug, $args, $wp_customize ) { |
|
139 | + $default_args = array( |
|
140 | + 'capability' => 'edit_theme_options', |
|
141 | + 'description' => null, |
|
142 | + ); |
|
143 | + |
|
144 | + $wp_customize->add_section( $slug, array_merge( $default_args, $args ) ); |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Create a setting. |
|
149 | + */ |
|
150 | + private function add_setting( $slug, $args, $wp_customize ) { |
|
151 | + $wp_customize->add_setting( |
|
152 | + $slug, |
|
153 | + array_merge( |
|
154 | + array( |
|
155 | + 'default' => null, |
|
156 | + 'type' => 'theme_mod', |
|
157 | + 'capability' => 'edit_theme_options', |
|
158 | + 'transport' => 'postMessage', |
|
159 | + 'sanitize_callback' => 'lsx_sanitize_choices', |
|
160 | + ), |
|
161 | + $args |
|
162 | + ) |
|
163 | + ); |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Create a control. |
|
168 | + */ |
|
169 | + private function add_control( $slug, $args, $wp_customize ) { |
|
170 | + $default_args = array(); |
|
171 | + |
|
172 | + if ( isset( $args['control'] ) && class_exists( $args['control'] ) ) { |
|
173 | + $control_class = $args['control']; |
|
174 | + unset( $args['control'] ); |
|
175 | + |
|
176 | + $control = new $control_class( $wp_customize, $slug, array_merge( $default_args, $args ) ); |
|
177 | + $wp_customize->add_control( $control ); |
|
178 | + } else { |
|
179 | + if ( isset( $args['control'] ) ) { |
|
180 | + unset( $args['control'] ); |
|
181 | + } |
|
182 | + |
|
183 | + $wp_customize->add_control( |
|
184 | + $slug, |
|
185 | + array_merge( $default_args, $args ) |
|
186 | + ); |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Create a selective refresh. |
|
192 | + */ |
|
193 | + private function add_selective_refresh( $slug, $args, $wp_customize ) { |
|
194 | + $default_args = array( |
|
195 | + 'selector' => null, |
|
196 | + 'render_callback' => null, |
|
197 | + ); |
|
198 | + |
|
199 | + $wp_customize->selective_refresh->add_partial( |
|
200 | + $slug, |
|
201 | + array_merge( $default_args, $args ) |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * Returns a registered field. |
|
207 | + */ |
|
208 | + public function get_control( $id ) { |
|
209 | + $field = $this->controls['fields'][ $id ]; |
|
210 | + return $field; |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Returns a registered setting. |
|
215 | + */ |
|
216 | + public function get_setting( $id ) { |
|
217 | + $setting = $this->controls['settings'][ $id ]; |
|
218 | + return $setting; |
|
219 | + } |
|
220 | + |
|
221 | + } |
|
222 | 222 | |
223 | 223 | endif; |