@@ -18,159 +18,159 @@ |
||
18 | 18 | */ |
19 | 19 | abstract class Wordlift_Admin_Select_Element implements Wordlift_Admin_Element { |
20 | 20 | |
21 | - /** |
|
22 | - * @inheritdoc |
|
23 | - */ |
|
24 | - public function render( $args ) { |
|
25 | - // Some select fields may need custom script/styles to work. |
|
26 | - $this->enqueue_resources(); |
|
27 | - |
|
28 | - // Parse the arguments and merge with default values. |
|
29 | - $params = wp_parse_args( |
|
30 | - $args, |
|
31 | - array( |
|
32 | - 'id' => uniqid( 'wl-input-' ), |
|
33 | - 'name' => uniqid( 'wl-input-' ), |
|
34 | - 'value' => '', |
|
35 | - 'class' => '', |
|
36 | - 'notice' => '', |
|
37 | - 'description' => false, |
|
38 | - 'data' => array(), |
|
39 | - 'options' => array(), |
|
40 | - ) |
|
41 | - ); |
|
42 | - ?> |
|
21 | + /** |
|
22 | + * @inheritdoc |
|
23 | + */ |
|
24 | + public function render( $args ) { |
|
25 | + // Some select fields may need custom script/styles to work. |
|
26 | + $this->enqueue_resources(); |
|
27 | + |
|
28 | + // Parse the arguments and merge with default values. |
|
29 | + $params = wp_parse_args( |
|
30 | + $args, |
|
31 | + array( |
|
32 | + 'id' => uniqid( 'wl-input-' ), |
|
33 | + 'name' => uniqid( 'wl-input-' ), |
|
34 | + 'value' => '', |
|
35 | + 'class' => '', |
|
36 | + 'notice' => '', |
|
37 | + 'description' => false, |
|
38 | + 'data' => array(), |
|
39 | + 'options' => array(), |
|
40 | + ) |
|
41 | + ); |
|
42 | + ?> |
|
43 | 43 | <select |
44 | 44 | id="<?php echo esc_attr( $params['id'] ); ?>" |
45 | 45 | name="<?php echo esc_attr( $params['name'] ); ?>" |
46 | 46 | class="<?php echo esc_attr( $params['class'] ); ?>" |
47 | 47 | <?php |
48 | - echo $this->get_data_attributes( $params['data'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Printing additional attributes, attributes are escaped in `get_data_attributes`. |
|
49 | - ?> |
|
48 | + echo $this->get_data_attributes( $params['data'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Printing additional attributes, attributes are escaped in `get_data_attributes`. |
|
49 | + ?> |
|
50 | 50 | > |
51 | 51 | <?php $this->render_options( $params ); ?> |
52 | 52 | </select> |
53 | 53 | |
54 | 54 | <?php |
55 | - // Print the notice message if there is such. |
|
56 | - $this->print_notice( $params['notice'] ); |
|
57 | - |
|
58 | - // Print the field description. |
|
59 | - echo wp_kses( $this->get_description( $params['description'] ), array( 'p' => array() ) ); |
|
60 | - |
|
61 | - return $this; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Returns html escaped description string. |
|
66 | - * Note: Only `a` tags are allowed with only `href` attributes. |
|
67 | - * |
|
68 | - * @param string|bool $description The field description or false if not set. |
|
69 | - * |
|
70 | - * @return string|void The description or null if not set. |
|
71 | - * @since 3.18.0 |
|
72 | - */ |
|
73 | - public function get_description( $description ) { |
|
74 | - // Bail if the description is not set. |
|
75 | - if ( empty( $description ) ) { |
|
76 | - return; |
|
77 | - } |
|
78 | - |
|
79 | - // Remove all characters except links. |
|
80 | - $filtered_descrption = wp_kses( |
|
81 | - $description, |
|
82 | - array( |
|
83 | - 'a' => array( |
|
84 | - 'href' => array(), |
|
85 | - ), |
|
86 | - ) |
|
87 | - ); |
|
88 | - |
|
89 | - return wpautop( $filtered_descrption ); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Prints the field notice that will be shown on error. |
|
94 | - * |
|
95 | - * @param string $notice The notice to add. |
|
96 | - * |
|
97 | - * @return void |
|
98 | - * @since 3.18.0 |
|
99 | - */ |
|
100 | - public function print_notice( $notice ) { |
|
101 | - // Bail if the notice is empty. |
|
102 | - if ( empty( $notice ) ) { |
|
103 | - return; |
|
104 | - } |
|
105 | - |
|
106 | - // Print the notice message. |
|
107 | - printf( |
|
108 | - '<small class="wl-select-notices">%s</small>', |
|
109 | - esc_html( $notice ) |
|
110 | - ); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Adds data attributes to select element. |
|
115 | - * |
|
116 | - * We need to use method here, because different select elements |
|
117 | - * may have different data attributes. |
|
118 | - * |
|
119 | - * @param array $pre_attributes Array of all data attributes. |
|
120 | - * |
|
121 | - * @return string $output The data attributes or empty string |
|
122 | - * @since 3.18.0 |
|
123 | - */ |
|
124 | - private function get_data_attributes( $pre_attributes ) { |
|
125 | - // The output. |
|
126 | - $output = ''; |
|
127 | - |
|
128 | - /** |
|
129 | - * Filter: 'wl_admin_select_element_data_attributes' - Allow third |
|
130 | - * parties to modify the field data attrbutes. |
|
131 | - * |
|
132 | - * @param array $pre_attributes Array of the field data attributes. |
|
133 | - * |
|
134 | - * @since 3.18.0 |
|
135 | - */ |
|
136 | - $attributes = apply_filters( 'wl_admin_select_element_data_attributes', $pre_attributes ); |
|
137 | - |
|
138 | - // Bail is there are no data attributes. |
|
139 | - if ( empty( $attributes ) ) { |
|
140 | - return $output; |
|
141 | - } |
|
142 | - |
|
143 | - // Loop throught all data attributes and build the output string. |
|
144 | - foreach ( $attributes as $name => $value ) { |
|
145 | - $output .= sprintf( |
|
146 | - 'data-%s="%s" ', |
|
147 | - esc_html( $name ), |
|
148 | - esc_attr( $value ) |
|
149 | - ); |
|
150 | - } |
|
151 | - |
|
152 | - // Finally return the output escaped. |
|
153 | - return $output; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Prints specific resources(scripts/styles) if the select requires them. |
|
158 | - * |
|
159 | - * @return void |
|
160 | - * @since 3.18.0 |
|
161 | - */ |
|
162 | - protected function enqueue_resources() { |
|
163 | - |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Abstract method that renders the select options. |
|
168 | - * |
|
169 | - * @param array $params Select params. |
|
170 | - * |
|
171 | - * @return Prints the select options. |
|
172 | - * @since 3.18.0 |
|
173 | - */ |
|
174 | - abstract public function render_options( $params ); |
|
55 | + // Print the notice message if there is such. |
|
56 | + $this->print_notice( $params['notice'] ); |
|
57 | + |
|
58 | + // Print the field description. |
|
59 | + echo wp_kses( $this->get_description( $params['description'] ), array( 'p' => array() ) ); |
|
60 | + |
|
61 | + return $this; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Returns html escaped description string. |
|
66 | + * Note: Only `a` tags are allowed with only `href` attributes. |
|
67 | + * |
|
68 | + * @param string|bool $description The field description or false if not set. |
|
69 | + * |
|
70 | + * @return string|void The description or null if not set. |
|
71 | + * @since 3.18.0 |
|
72 | + */ |
|
73 | + public function get_description( $description ) { |
|
74 | + // Bail if the description is not set. |
|
75 | + if ( empty( $description ) ) { |
|
76 | + return; |
|
77 | + } |
|
78 | + |
|
79 | + // Remove all characters except links. |
|
80 | + $filtered_descrption = wp_kses( |
|
81 | + $description, |
|
82 | + array( |
|
83 | + 'a' => array( |
|
84 | + 'href' => array(), |
|
85 | + ), |
|
86 | + ) |
|
87 | + ); |
|
88 | + |
|
89 | + return wpautop( $filtered_descrption ); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Prints the field notice that will be shown on error. |
|
94 | + * |
|
95 | + * @param string $notice The notice to add. |
|
96 | + * |
|
97 | + * @return void |
|
98 | + * @since 3.18.0 |
|
99 | + */ |
|
100 | + public function print_notice( $notice ) { |
|
101 | + // Bail if the notice is empty. |
|
102 | + if ( empty( $notice ) ) { |
|
103 | + return; |
|
104 | + } |
|
105 | + |
|
106 | + // Print the notice message. |
|
107 | + printf( |
|
108 | + '<small class="wl-select-notices">%s</small>', |
|
109 | + esc_html( $notice ) |
|
110 | + ); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Adds data attributes to select element. |
|
115 | + * |
|
116 | + * We need to use method here, because different select elements |
|
117 | + * may have different data attributes. |
|
118 | + * |
|
119 | + * @param array $pre_attributes Array of all data attributes. |
|
120 | + * |
|
121 | + * @return string $output The data attributes or empty string |
|
122 | + * @since 3.18.0 |
|
123 | + */ |
|
124 | + private function get_data_attributes( $pre_attributes ) { |
|
125 | + // The output. |
|
126 | + $output = ''; |
|
127 | + |
|
128 | + /** |
|
129 | + * Filter: 'wl_admin_select_element_data_attributes' - Allow third |
|
130 | + * parties to modify the field data attrbutes. |
|
131 | + * |
|
132 | + * @param array $pre_attributes Array of the field data attributes. |
|
133 | + * |
|
134 | + * @since 3.18.0 |
|
135 | + */ |
|
136 | + $attributes = apply_filters( 'wl_admin_select_element_data_attributes', $pre_attributes ); |
|
137 | + |
|
138 | + // Bail is there are no data attributes. |
|
139 | + if ( empty( $attributes ) ) { |
|
140 | + return $output; |
|
141 | + } |
|
142 | + |
|
143 | + // Loop throught all data attributes and build the output string. |
|
144 | + foreach ( $attributes as $name => $value ) { |
|
145 | + $output .= sprintf( |
|
146 | + 'data-%s="%s" ', |
|
147 | + esc_html( $name ), |
|
148 | + esc_attr( $value ) |
|
149 | + ); |
|
150 | + } |
|
151 | + |
|
152 | + // Finally return the output escaped. |
|
153 | + return $output; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Prints specific resources(scripts/styles) if the select requires them. |
|
158 | + * |
|
159 | + * @return void |
|
160 | + * @since 3.18.0 |
|
161 | + */ |
|
162 | + protected function enqueue_resources() { |
|
163 | + |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Abstract method that renders the select options. |
|
168 | + * |
|
169 | + * @param array $params Select params. |
|
170 | + * |
|
171 | + * @return Prints the select options. |
|
172 | + * @since 3.18.0 |
|
173 | + */ |
|
174 | + abstract public function render_options( $params ); |
|
175 | 175 | |
176 | 176 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @inheritdoc |
23 | 23 | */ |
24 | - public function render( $args ) { |
|
24 | + public function render($args) { |
|
25 | 25 | // Some select fields may need custom script/styles to work. |
26 | 26 | $this->enqueue_resources(); |
27 | 27 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | $params = wp_parse_args( |
30 | 30 | $args, |
31 | 31 | array( |
32 | - 'id' => uniqid( 'wl-input-' ), |
|
33 | - 'name' => uniqid( 'wl-input-' ), |
|
32 | + 'id' => uniqid('wl-input-'), |
|
33 | + 'name' => uniqid('wl-input-'), |
|
34 | 34 | 'value' => '', |
35 | 35 | 'class' => '', |
36 | 36 | 'notice' => '', |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | ); |
42 | 42 | ?> |
43 | 43 | <select |
44 | - id="<?php echo esc_attr( $params['id'] ); ?>" |
|
45 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
46 | - class="<?php echo esc_attr( $params['class'] ); ?>" |
|
44 | + id="<?php echo esc_attr($params['id']); ?>" |
|
45 | + name="<?php echo esc_attr($params['name']); ?>" |
|
46 | + class="<?php echo esc_attr($params['class']); ?>" |
|
47 | 47 | <?php |
48 | - echo $this->get_data_attributes( $params['data'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Printing additional attributes, attributes are escaped in `get_data_attributes`. |
|
48 | + echo $this->get_data_attributes($params['data']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Printing additional attributes, attributes are escaped in `get_data_attributes`. |
|
49 | 49 | ?> |
50 | 50 | > |
51 | - <?php $this->render_options( $params ); ?> |
|
51 | + <?php $this->render_options($params); ?> |
|
52 | 52 | </select> |
53 | 53 | |
54 | 54 | <?php |
55 | 55 | // Print the notice message if there is such. |
56 | - $this->print_notice( $params['notice'] ); |
|
56 | + $this->print_notice($params['notice']); |
|
57 | 57 | |
58 | 58 | // Print the field description. |
59 | - echo wp_kses( $this->get_description( $params['description'] ), array( 'p' => array() ) ); |
|
59 | + echo wp_kses($this->get_description($params['description']), array('p' => array())); |
|
60 | 60 | |
61 | 61 | return $this; |
62 | 62 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @return string|void The description or null if not set. |
71 | 71 | * @since 3.18.0 |
72 | 72 | */ |
73 | - public function get_description( $description ) { |
|
73 | + public function get_description($description) { |
|
74 | 74 | // Bail if the description is not set. |
75 | - if ( empty( $description ) ) { |
|
75 | + if (empty($description)) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | ) |
87 | 87 | ); |
88 | 88 | |
89 | - return wpautop( $filtered_descrption ); |
|
89 | + return wpautop($filtered_descrption); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -97,16 +97,16 @@ discard block |
||
97 | 97 | * @return void |
98 | 98 | * @since 3.18.0 |
99 | 99 | */ |
100 | - public function print_notice( $notice ) { |
|
100 | + public function print_notice($notice) { |
|
101 | 101 | // Bail if the notice is empty. |
102 | - if ( empty( $notice ) ) { |
|
102 | + if (empty($notice)) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Print the notice message. |
107 | 107 | printf( |
108 | 108 | '<small class="wl-select-notices">%s</small>', |
109 | - esc_html( $notice ) |
|
109 | + esc_html($notice) |
|
110 | 110 | ); |
111 | 111 | } |
112 | 112 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return string $output The data attributes or empty string |
122 | 122 | * @since 3.18.0 |
123 | 123 | */ |
124 | - private function get_data_attributes( $pre_attributes ) { |
|
124 | + private function get_data_attributes($pre_attributes) { |
|
125 | 125 | // The output. |
126 | 126 | $output = ''; |
127 | 127 | |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @since 3.18.0 |
135 | 135 | */ |
136 | - $attributes = apply_filters( 'wl_admin_select_element_data_attributes', $pre_attributes ); |
|
136 | + $attributes = apply_filters('wl_admin_select_element_data_attributes', $pre_attributes); |
|
137 | 137 | |
138 | 138 | // Bail is there are no data attributes. |
139 | - if ( empty( $attributes ) ) { |
|
139 | + if (empty($attributes)) { |
|
140 | 140 | return $output; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Loop throught all data attributes and build the output string. |
144 | - foreach ( $attributes as $name => $value ) { |
|
144 | + foreach ($attributes as $name => $value) { |
|
145 | 145 | $output .= sprintf( |
146 | 146 | 'data-%s="%s" ', |
147 | - esc_html( $name ), |
|
148 | - esc_attr( $value ) |
|
147 | + esc_html($name), |
|
148 | + esc_attr($value) |
|
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
@@ -171,6 +171,6 @@ discard block |
||
171 | 171 | * @return Prints the select options. |
172 | 172 | * @since 3.18.0 |
173 | 173 | */ |
174 | - abstract public function render_options( $params ); |
|
174 | + abstract public function render_options($params); |
|
175 | 175 | |
176 | 176 | } |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Wordlift_Related_Entities_Cloud_Widget extends Wordlift_Widget { |
18 | 18 | |
19 | - /** |
|
20 | - * Create an {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
21 | - * |
|
22 | - * @since 3.11.0 |
|
23 | - */ |
|
24 | - public function __construct() { |
|
25 | - parent::__construct( |
|
26 | - 'wl_related_entities_cloud', |
|
27 | - __( 'WordLift Entities Cloud', 'wordlift' ), |
|
28 | - array( |
|
29 | - 'classname' => 'wl_related_entities_cloud', |
|
30 | - 'description' => __( 'Display entities related to the current post/entity in a tag cloud.', 'wordlift' ), |
|
31 | - ) |
|
32 | - ); |
|
33 | - |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * @inheritdoc |
|
38 | - */ |
|
39 | - public function form( $instance ) { |
|
40 | - $title_id = $this->get_field_id( 'title' ); |
|
41 | - $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
|
42 | - ?> |
|
19 | + /** |
|
20 | + * Create an {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
21 | + * |
|
22 | + * @since 3.11.0 |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | + parent::__construct( |
|
26 | + 'wl_related_entities_cloud', |
|
27 | + __( 'WordLift Entities Cloud', 'wordlift' ), |
|
28 | + array( |
|
29 | + 'classname' => 'wl_related_entities_cloud', |
|
30 | + 'description' => __( 'Display entities related to the current post/entity in a tag cloud.', 'wordlift' ), |
|
31 | + ) |
|
32 | + ); |
|
33 | + |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * @inheritdoc |
|
38 | + */ |
|
39 | + public function form( $instance ) { |
|
40 | + $title_id = $this->get_field_id( 'title' ); |
|
41 | + $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
|
42 | + ?> |
|
43 | 43 | |
44 | 44 | <p><label for="<?php echo esc_attr( $title_id ); ?>"> |
45 | 45 | <?php |
46 | - esc_html_e( 'Title:', 'wordlift' ); |
|
47 | - ?> |
|
46 | + esc_html_e( 'Title:', 'wordlift' ); |
|
47 | + ?> |
|
48 | 48 | </label> |
49 | 49 | <input type="text" class="widefat" |
50 | 50 | id="<?php echo esc_attr( $title_id ); ?>" |
@@ -54,67 +54,67 @@ discard block |
||
54 | 54 | |
55 | 55 | <?php |
56 | 56 | |
57 | - return 'wl_related_entities_cloud_form'; |
|
58 | - } |
|
57 | + return 'wl_related_entities_cloud_form'; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @inheritdoc |
|
62 | - */ |
|
63 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
64 | - public function update( $new_instance, $old_instance ) { |
|
60 | + /** |
|
61 | + * @inheritdoc |
|
62 | + */ |
|
63 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
64 | + public function update( $new_instance, $old_instance ) { |
|
65 | 65 | |
66 | - return array( 'title' => sanitize_text_field( $new_instance['title'] ) ); |
|
67 | - } |
|
66 | + return array( 'title' => sanitize_text_field( $new_instance['title'] ) ); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @inheritdoc |
|
71 | - */ |
|
72 | - public function widget( $args, $instance ) { |
|
69 | + /** |
|
70 | + * @inheritdoc |
|
71 | + */ |
|
72 | + public function widget( $args, $instance ) { |
|
73 | 73 | |
74 | - /* |
|
74 | + /* |
|
75 | 75 | * Use the shortcode to calculate the HTML required to show the cloud |
76 | 76 | * if there is no such html do not render the widget at all. |
77 | 77 | */ |
78 | - $cloud_html = do_shortcode( '[wl_cloud]' ); |
|
79 | - if ( empty( $cloud_html ) ) { |
|
80 | - return false; |
|
81 | - } |
|
82 | - |
|
83 | - // The widget title. |
|
84 | - $title = empty( $instance['title'] ) ? __( 'Related Entities', 'wordlift' ) : $instance['title']; |
|
85 | - |
|
86 | - // Standard filter all widgets should apply |
|
87 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
88 | - |
|
89 | - echo wp_kses( $args['before_widget'], wp_kses_allowed_html( 'post' ) ); |
|
90 | - |
|
91 | - if ( $title ) { |
|
92 | - echo wp_kses( $args['before_title'], wp_kses_allowed_html( 'post' ) ); |
|
93 | - echo esc_html( $title ); |
|
94 | - echo wp_kses( $args['after_title'], wp_kses_allowed_html( 'post' ) ); |
|
95 | - } |
|
96 | - |
|
97 | - echo wp_kses( |
|
98 | - $cloud_html, |
|
99 | - array( |
|
100 | - 'div' => array( 'class' => array() ), |
|
101 | - 'span' => array( 'class' => array() ), |
|
102 | - 'a' => array( |
|
103 | - 'href' => array(), |
|
104 | - 'class' => array(), |
|
105 | - 'style' => array(), |
|
106 | - 'aria-label' => array(), |
|
107 | - ), |
|
108 | - 'ul' => array( |
|
109 | - 'class' => array(), |
|
110 | - 'role' => array(), |
|
111 | - ), |
|
112 | - 'li' => array(), |
|
113 | - ) |
|
114 | - ); |
|
115 | - |
|
116 | - echo wp_kses( $args['after_widget'], wp_kses_allowed_html( 'post' ) ); |
|
117 | - |
|
118 | - } |
|
78 | + $cloud_html = do_shortcode( '[wl_cloud]' ); |
|
79 | + if ( empty( $cloud_html ) ) { |
|
80 | + return false; |
|
81 | + } |
|
82 | + |
|
83 | + // The widget title. |
|
84 | + $title = empty( $instance['title'] ) ? __( 'Related Entities', 'wordlift' ) : $instance['title']; |
|
85 | + |
|
86 | + // Standard filter all widgets should apply |
|
87 | + $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
88 | + |
|
89 | + echo wp_kses( $args['before_widget'], wp_kses_allowed_html( 'post' ) ); |
|
90 | + |
|
91 | + if ( $title ) { |
|
92 | + echo wp_kses( $args['before_title'], wp_kses_allowed_html( 'post' ) ); |
|
93 | + echo esc_html( $title ); |
|
94 | + echo wp_kses( $args['after_title'], wp_kses_allowed_html( 'post' ) ); |
|
95 | + } |
|
96 | + |
|
97 | + echo wp_kses( |
|
98 | + $cloud_html, |
|
99 | + array( |
|
100 | + 'div' => array( 'class' => array() ), |
|
101 | + 'span' => array( 'class' => array() ), |
|
102 | + 'a' => array( |
|
103 | + 'href' => array(), |
|
104 | + 'class' => array(), |
|
105 | + 'style' => array(), |
|
106 | + 'aria-label' => array(), |
|
107 | + ), |
|
108 | + 'ul' => array( |
|
109 | + 'class' => array(), |
|
110 | + 'role' => array(), |
|
111 | + ), |
|
112 | + 'li' => array(), |
|
113 | + ) |
|
114 | + ); |
|
115 | + |
|
116 | + echo wp_kses( $args['after_widget'], wp_kses_allowed_html( 'post' ) ); |
|
117 | + |
|
118 | + } |
|
119 | 119 | |
120 | 120 | } |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | public function __construct() { |
25 | 25 | parent::__construct( |
26 | 26 | 'wl_related_entities_cloud', |
27 | - __( 'WordLift Entities Cloud', 'wordlift' ), |
|
27 | + __('WordLift Entities Cloud', 'wordlift'), |
|
28 | 28 | array( |
29 | 29 | 'classname' => 'wl_related_entities_cloud', |
30 | - 'description' => __( 'Display entities related to the current post/entity in a tag cloud.', 'wordlift' ), |
|
30 | + 'description' => __('Display entities related to the current post/entity in a tag cloud.', 'wordlift'), |
|
31 | 31 | ) |
32 | 32 | ); |
33 | 33 | |
@@ -36,20 +36,20 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @inheritdoc |
38 | 38 | */ |
39 | - public function form( $instance ) { |
|
40 | - $title_id = $this->get_field_id( 'title' ); |
|
41 | - $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
|
39 | + public function form($instance) { |
|
40 | + $title_id = $this->get_field_id('title'); |
|
41 | + $instance['title'] = ! empty($instance['title']) ? esc_attr($instance['title']) : ''; |
|
42 | 42 | ?> |
43 | 43 | |
44 | - <p><label for="<?php echo esc_attr( $title_id ); ?>"> |
|
44 | + <p><label for="<?php echo esc_attr($title_id); ?>"> |
|
45 | 45 | <?php |
46 | - esc_html_e( 'Title:', 'wordlift' ); |
|
46 | + esc_html_e('Title:', 'wordlift'); |
|
47 | 47 | ?> |
48 | 48 | </label> |
49 | 49 | <input type="text" class="widefat" |
50 | - id="<?php echo esc_attr( $title_id ); ?>" |
|
51 | - name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" |
|
52 | - value="<?php echo esc_attr( $instance['title'] ); ?>"/> |
|
50 | + id="<?php echo esc_attr($title_id); ?>" |
|
51 | + name="<?php echo esc_attr($this->get_field_name('title')); ?>" |
|
52 | + value="<?php echo esc_attr($instance['title']); ?>"/> |
|
53 | 53 | </p> |
54 | 54 | |
55 | 55 | <?php |
@@ -61,44 +61,44 @@ discard block |
||
61 | 61 | * @inheritdoc |
62 | 62 | */ |
63 | 63 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
64 | - public function update( $new_instance, $old_instance ) { |
|
64 | + public function update($new_instance, $old_instance) { |
|
65 | 65 | |
66 | - return array( 'title' => sanitize_text_field( $new_instance['title'] ) ); |
|
66 | + return array('title' => sanitize_text_field($new_instance['title'])); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @inheritdoc |
71 | 71 | */ |
72 | - public function widget( $args, $instance ) { |
|
72 | + public function widget($args, $instance) { |
|
73 | 73 | |
74 | 74 | /* |
75 | 75 | * Use the shortcode to calculate the HTML required to show the cloud |
76 | 76 | * if there is no such html do not render the widget at all. |
77 | 77 | */ |
78 | - $cloud_html = do_shortcode( '[wl_cloud]' ); |
|
79 | - if ( empty( $cloud_html ) ) { |
|
78 | + $cloud_html = do_shortcode('[wl_cloud]'); |
|
79 | + if (empty($cloud_html)) { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
83 | 83 | // The widget title. |
84 | - $title = empty( $instance['title'] ) ? __( 'Related Entities', 'wordlift' ) : $instance['title']; |
|
84 | + $title = empty($instance['title']) ? __('Related Entities', 'wordlift') : $instance['title']; |
|
85 | 85 | |
86 | 86 | // Standard filter all widgets should apply |
87 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
87 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
88 | 88 | |
89 | - echo wp_kses( $args['before_widget'], wp_kses_allowed_html( 'post' ) ); |
|
89 | + echo wp_kses($args['before_widget'], wp_kses_allowed_html('post')); |
|
90 | 90 | |
91 | - if ( $title ) { |
|
92 | - echo wp_kses( $args['before_title'], wp_kses_allowed_html( 'post' ) ); |
|
93 | - echo esc_html( $title ); |
|
94 | - echo wp_kses( $args['after_title'], wp_kses_allowed_html( 'post' ) ); |
|
91 | + if ($title) { |
|
92 | + echo wp_kses($args['before_title'], wp_kses_allowed_html('post')); |
|
93 | + echo esc_html($title); |
|
94 | + echo wp_kses($args['after_title'], wp_kses_allowed_html('post')); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | echo wp_kses( |
98 | 98 | $cloud_html, |
99 | 99 | array( |
100 | - 'div' => array( 'class' => array() ), |
|
101 | - 'span' => array( 'class' => array() ), |
|
100 | + 'div' => array('class' => array()), |
|
101 | + 'span' => array('class' => array()), |
|
102 | 102 | 'a' => array( |
103 | 103 | 'href' => array(), |
104 | 104 | 'class' => array(), |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | |
116 | - echo wp_kses( $args['after_widget'], wp_kses_allowed_html( 'post' ) ); |
|
116 | + echo wp_kses($args['after_widget'], wp_kses_allowed_html('post')); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 |
@@ -17,124 +17,124 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class Wordlift_Faceted_Search_Shortcode extends Wordlift_Shortcode { |
19 | 19 | |
20 | - /** |
|
21 | - * {@inheritdoc} |
|
22 | - */ |
|
23 | - const SHORTCODE = 'wl_faceted_search'; |
|
24 | - |
|
25 | - public function __construct() { |
|
26 | - parent::__construct(); |
|
27 | - $this->register_block_type(); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - public function render( $atts ) { |
|
34 | - |
|
35 | - return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts ) |
|
36 | - : $this->web_shortcode( $atts ); |
|
37 | - } |
|
38 | - |
|
39 | - private function register_block_type() { |
|
40 | - |
|
41 | - $scope = $this; |
|
42 | - |
|
43 | - add_action( |
|
44 | - 'init', |
|
45 | - function () use ( $scope ) { |
|
46 | - if ( ! function_exists( 'register_block_type' ) ) { |
|
47 | - // Gutenberg is not active. |
|
48 | - return; |
|
49 | - } |
|
50 | - |
|
51 | - register_block_type( |
|
52 | - 'wordlift/faceted-search', |
|
53 | - array( |
|
54 | - 'editor_script' => 'wl-block-editor', |
|
55 | - 'render_callback' => function ( $attributes ) use ( $scope ) { |
|
56 | - $attr_code = ''; |
|
57 | - foreach ( $attributes as $key => $value ) { |
|
58 | - $attr_code .= $key . '="' . htmlentities( $value ) . '" '; |
|
59 | - } |
|
60 | - |
|
61 | - return '[' . $scope::SHORTCODE . ' ' . $attr_code . ']'; |
|
62 | - }, |
|
63 | - |
|
64 | - 'attributes' => $scope->get_block_attributes(), |
|
65 | - ) |
|
66 | - ); |
|
67 | - } |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Shared function used by web_shortcode and amp_shortcode |
|
73 | - * Bootstrap logic for attributes extraction and boolean filtering |
|
74 | - * |
|
75 | - * @param array $atts Shortcode attributes. |
|
76 | - * |
|
77 | - * @return array $shortcode_atts |
|
78 | - * @since 3.20.0 |
|
79 | - */ |
|
80 | - private function make_shortcode_atts( $atts ) { |
|
81 | - |
|
82 | - // Extract attributes and set default values. |
|
83 | - $shortcode_atts = shortcode_atts( |
|
84 | - array( |
|
85 | - 'title' => __( 'Related articles', 'wordlift' ), |
|
86 | - 'limit' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
87 | - 'post_id' => '', |
|
88 | - 'template_id' => '', |
|
89 | - 'uniqid' => uniqid( 'wl-faceted-widget-' ), |
|
90 | - 'post_types' => '', |
|
91 | - ), |
|
92 | - $atts |
|
93 | - ); |
|
94 | - |
|
95 | - return $shortcode_atts; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Function in charge of diplaying the [wl-faceted-search] in web mode. |
|
100 | - * |
|
101 | - * @param array $atts Shortcode attributes. |
|
102 | - * |
|
103 | - * @return string Shortcode HTML for web |
|
104 | - * @since 3.20.0 |
|
105 | - */ |
|
106 | - private function web_shortcode( $atts ) { |
|
107 | - |
|
108 | - // attributes extraction and boolean filtering |
|
109 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
110 | - |
|
111 | - // avoid building the widget when no post_id is specified and there is a list of posts. |
|
112 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
113 | - return; |
|
114 | - } |
|
115 | - |
|
116 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
117 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
118 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
119 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
120 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
121 | - |
|
122 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
123 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
124 | - $rest_url = $this->get_rest_url( $post, $delimiter, $limit, $shortcode_atts['post_types'] ); |
|
125 | - $rest_url = esc_attr( $rest_url ); |
|
126 | - |
|
127 | - // avoid building the widget when no valid $rest_url |
|
128 | - if ( ! $rest_url ) { |
|
129 | - return; |
|
130 | - } |
|
131 | - |
|
132 | - wp_enqueue_script( 'wordlift-cloud' ); |
|
133 | - $template_url = get_rest_url( null, '/wordlift/v1/faceted-search/template' ); |
|
134 | - |
|
135 | - return wp_kses( |
|
136 | - sprintf( |
|
137 | - ' |
|
20 | + /** |
|
21 | + * {@inheritdoc} |
|
22 | + */ |
|
23 | + const SHORTCODE = 'wl_faceted_search'; |
|
24 | + |
|
25 | + public function __construct() { |
|
26 | + parent::__construct(); |
|
27 | + $this->register_block_type(); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + public function render( $atts ) { |
|
34 | + |
|
35 | + return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts ) |
|
36 | + : $this->web_shortcode( $atts ); |
|
37 | + } |
|
38 | + |
|
39 | + private function register_block_type() { |
|
40 | + |
|
41 | + $scope = $this; |
|
42 | + |
|
43 | + add_action( |
|
44 | + 'init', |
|
45 | + function () use ( $scope ) { |
|
46 | + if ( ! function_exists( 'register_block_type' ) ) { |
|
47 | + // Gutenberg is not active. |
|
48 | + return; |
|
49 | + } |
|
50 | + |
|
51 | + register_block_type( |
|
52 | + 'wordlift/faceted-search', |
|
53 | + array( |
|
54 | + 'editor_script' => 'wl-block-editor', |
|
55 | + 'render_callback' => function ( $attributes ) use ( $scope ) { |
|
56 | + $attr_code = ''; |
|
57 | + foreach ( $attributes as $key => $value ) { |
|
58 | + $attr_code .= $key . '="' . htmlentities( $value ) . '" '; |
|
59 | + } |
|
60 | + |
|
61 | + return '[' . $scope::SHORTCODE . ' ' . $attr_code . ']'; |
|
62 | + }, |
|
63 | + |
|
64 | + 'attributes' => $scope->get_block_attributes(), |
|
65 | + ) |
|
66 | + ); |
|
67 | + } |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Shared function used by web_shortcode and amp_shortcode |
|
73 | + * Bootstrap logic for attributes extraction and boolean filtering |
|
74 | + * |
|
75 | + * @param array $atts Shortcode attributes. |
|
76 | + * |
|
77 | + * @return array $shortcode_atts |
|
78 | + * @since 3.20.0 |
|
79 | + */ |
|
80 | + private function make_shortcode_atts( $atts ) { |
|
81 | + |
|
82 | + // Extract attributes and set default values. |
|
83 | + $shortcode_atts = shortcode_atts( |
|
84 | + array( |
|
85 | + 'title' => __( 'Related articles', 'wordlift' ), |
|
86 | + 'limit' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
87 | + 'post_id' => '', |
|
88 | + 'template_id' => '', |
|
89 | + 'uniqid' => uniqid( 'wl-faceted-widget-' ), |
|
90 | + 'post_types' => '', |
|
91 | + ), |
|
92 | + $atts |
|
93 | + ); |
|
94 | + |
|
95 | + return $shortcode_atts; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Function in charge of diplaying the [wl-faceted-search] in web mode. |
|
100 | + * |
|
101 | + * @param array $atts Shortcode attributes. |
|
102 | + * |
|
103 | + * @return string Shortcode HTML for web |
|
104 | + * @since 3.20.0 |
|
105 | + */ |
|
106 | + private function web_shortcode( $atts ) { |
|
107 | + |
|
108 | + // attributes extraction and boolean filtering |
|
109 | + $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
110 | + |
|
111 | + // avoid building the widget when no post_id is specified and there is a list of posts. |
|
112 | + if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
113 | + return; |
|
114 | + } |
|
115 | + |
|
116 | + $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
117 | + $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
118 | + $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
119 | + $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
120 | + $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
121 | + |
|
122 | + $permalink_structure = get_option( 'permalink_structure' ); |
|
123 | + $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
124 | + $rest_url = $this->get_rest_url( $post, $delimiter, $limit, $shortcode_atts['post_types'] ); |
|
125 | + $rest_url = esc_attr( $rest_url ); |
|
126 | + |
|
127 | + // avoid building the widget when no valid $rest_url |
|
128 | + if ( ! $rest_url ) { |
|
129 | + return; |
|
130 | + } |
|
131 | + |
|
132 | + wp_enqueue_script( 'wordlift-cloud' ); |
|
133 | + $template_url = get_rest_url( null, '/wordlift/v1/faceted-search/template' ); |
|
134 | + |
|
135 | + return wp_kses( |
|
136 | + sprintf( |
|
137 | + ' |
|
138 | 138 | <div id="%s" |
139 | 139 | class="wl-faceted" |
140 | 140 | data-rest-url="%s" |
@@ -142,77 +142,77 @@ discard block |
||
142 | 142 | data-template-id="%s" |
143 | 143 | data-template-url="%s"></div> |
144 | 144 | ', |
145 | - esc_attr( $faceted_id ), |
|
146 | - esc_attr( $rest_url ), |
|
147 | - esc_attr( $title ), |
|
148 | - esc_attr( $template_id ), |
|
149 | - esc_url( $template_url ) |
|
150 | - ), |
|
151 | - array( |
|
152 | - 'div' => array( |
|
153 | - 'id' => array(), |
|
154 | - 'class' => array(), |
|
155 | - 'data-rest-url' => array(), |
|
156 | - 'data-title' => array(), |
|
157 | - 'data-template-id' => array(), |
|
158 | - 'data-template-url' => array(), |
|
159 | - ), |
|
160 | - ) |
|
161 | - ); |
|
162 | - |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Function in charge of diplaying the [wl-faceted-search] in amp mode. |
|
167 | - * |
|
168 | - * @param array $atts Shortcode attributes. |
|
169 | - * |
|
170 | - * @return string Shortcode HTML for amp |
|
171 | - * @since 3.20.0 |
|
172 | - */ |
|
173 | - private function amp_shortcode( $atts ) { |
|
174 | - |
|
175 | - // attributes extraction and boolean filtering |
|
176 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
177 | - |
|
178 | - // avoid building the widget when no post_id is specified and there is a list of posts. |
|
179 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
180 | - return; |
|
181 | - } |
|
182 | - |
|
183 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
184 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
185 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
186 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
187 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
188 | - |
|
189 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
190 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
191 | - $rest_url = $post ? rest_url( |
|
192 | - WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( |
|
193 | - array( |
|
194 | - 'amp' => 1, |
|
195 | - 'post_id' => $post->ID, |
|
196 | - 'limit' => $limit, |
|
197 | - ) |
|
198 | - ) |
|
199 | - ) : false; |
|
200 | - |
|
201 | - // avoid building the widget when no valid $rest_url |
|
202 | - if ( ! $rest_url ) { |
|
203 | - return; |
|
204 | - } |
|
205 | - |
|
206 | - // Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS. |
|
207 | - // This is a hackish way, but this works for http and https URLs |
|
208 | - $rest_url = str_replace( array( 'http:', 'https:' ), '', $rest_url ); |
|
209 | - |
|
210 | - if ( empty( $template_id ) ) { |
|
211 | - $template_id = 'template-' . $faceted_id; |
|
212 | - wp_enqueue_style( 'wordlift-amp-custom', plugin_dir_url( __DIR__ ) . '/css/wordlift-amp-custom.min.css', array(), WORDLIFT_VERSION ); |
|
213 | - } |
|
214 | - |
|
215 | - return <<<HTML |
|
145 | + esc_attr( $faceted_id ), |
|
146 | + esc_attr( $rest_url ), |
|
147 | + esc_attr( $title ), |
|
148 | + esc_attr( $template_id ), |
|
149 | + esc_url( $template_url ) |
|
150 | + ), |
|
151 | + array( |
|
152 | + 'div' => array( |
|
153 | + 'id' => array(), |
|
154 | + 'class' => array(), |
|
155 | + 'data-rest-url' => array(), |
|
156 | + 'data-title' => array(), |
|
157 | + 'data-template-id' => array(), |
|
158 | + 'data-template-url' => array(), |
|
159 | + ), |
|
160 | + ) |
|
161 | + ); |
|
162 | + |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Function in charge of diplaying the [wl-faceted-search] in amp mode. |
|
167 | + * |
|
168 | + * @param array $atts Shortcode attributes. |
|
169 | + * |
|
170 | + * @return string Shortcode HTML for amp |
|
171 | + * @since 3.20.0 |
|
172 | + */ |
|
173 | + private function amp_shortcode( $atts ) { |
|
174 | + |
|
175 | + // attributes extraction and boolean filtering |
|
176 | + $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
177 | + |
|
178 | + // avoid building the widget when no post_id is specified and there is a list of posts. |
|
179 | + if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
180 | + return; |
|
181 | + } |
|
182 | + |
|
183 | + $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
184 | + $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
185 | + $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
186 | + $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
187 | + $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
188 | + |
|
189 | + $permalink_structure = get_option( 'permalink_structure' ); |
|
190 | + $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
191 | + $rest_url = $post ? rest_url( |
|
192 | + WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( |
|
193 | + array( |
|
194 | + 'amp' => 1, |
|
195 | + 'post_id' => $post->ID, |
|
196 | + 'limit' => $limit, |
|
197 | + ) |
|
198 | + ) |
|
199 | + ) : false; |
|
200 | + |
|
201 | + // avoid building the widget when no valid $rest_url |
|
202 | + if ( ! $rest_url ) { |
|
203 | + return; |
|
204 | + } |
|
205 | + |
|
206 | + // Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS. |
|
207 | + // This is a hackish way, but this works for http and https URLs |
|
208 | + $rest_url = str_replace( array( 'http:', 'https:' ), '', $rest_url ); |
|
209 | + |
|
210 | + if ( empty( $template_id ) ) { |
|
211 | + $template_id = 'template-' . $faceted_id; |
|
212 | + wp_enqueue_style( 'wordlift-amp-custom', plugin_dir_url( __DIR__ ) . '/css/wordlift-amp-custom.min.css', array(), WORDLIFT_VERSION ); |
|
213 | + } |
|
214 | + |
|
215 | + return <<<HTML |
|
216 | 216 | <div id="{$faceted_id}" class="wl-amp-faceted"> |
217 | 217 | <h2 class="wl-headline">{$title}</h2> |
218 | 218 | <amp-state id="referencedPosts"> |
@@ -278,66 +278,66 @@ discard block |
||
278 | 278 | </section> |
279 | 279 | </div> |
280 | 280 | HTML; |
281 | - } |
|
282 | - |
|
283 | - public function get_block_attributes() { |
|
284 | - return array( |
|
285 | - 'title' => array( |
|
286 | - 'type' => 'string', |
|
287 | - 'default' => __( 'Related articles', 'wordlift' ), |
|
288 | - ), |
|
289 | - 'template_id' => array( |
|
290 | - 'type' => 'string', |
|
291 | - 'default' => '', |
|
292 | - ), |
|
293 | - 'post_id' => array( |
|
294 | - 'type' => 'number', |
|
295 | - 'default' => '', |
|
296 | - ), |
|
297 | - 'uniqid' => array( |
|
298 | - 'type' => 'string', |
|
299 | - 'default' => '', |
|
300 | - ), |
|
301 | - 'limit' => array( |
|
302 | - 'type' => 'number', |
|
303 | - 'default' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
304 | - ), |
|
305 | - 'preview' => array( |
|
306 | - 'type' => 'boolean', |
|
307 | - 'default' => false, |
|
308 | - ), |
|
309 | - 'preview_src' => array( |
|
310 | - 'type' => 'string', |
|
311 | - 'default' => WP_CONTENT_URL . '/plugins/wordlift/images/block-previews/faceted-search.png', |
|
312 | - ), |
|
313 | - 'post_types' => array( |
|
314 | - 'type' => 'string', |
|
315 | - 'default' => '', |
|
316 | - ), |
|
317 | - ); |
|
318 | - } |
|
319 | - |
|
320 | - /** |
|
321 | - * @param $post |
|
322 | - * @param $delimiter |
|
323 | - * @param $limit |
|
324 | - * |
|
325 | - * @param $post_types |
|
326 | - * |
|
327 | - * @return bool|string |
|
328 | - */ |
|
329 | - public function get_rest_url( $post, $delimiter, $limit, $post_types ) { |
|
330 | - $rest_url = $post ? rest_url( |
|
331 | - WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( |
|
332 | - array( |
|
333 | - 'post_id' => $post->ID, |
|
334 | - 'limit' => $limit, |
|
335 | - 'post_types' => $post_types, |
|
336 | - ) |
|
337 | - ) |
|
338 | - ) : false; |
|
339 | - |
|
340 | - return $rest_url; |
|
341 | - } |
|
281 | + } |
|
282 | + |
|
283 | + public function get_block_attributes() { |
|
284 | + return array( |
|
285 | + 'title' => array( |
|
286 | + 'type' => 'string', |
|
287 | + 'default' => __( 'Related articles', 'wordlift' ), |
|
288 | + ), |
|
289 | + 'template_id' => array( |
|
290 | + 'type' => 'string', |
|
291 | + 'default' => '', |
|
292 | + ), |
|
293 | + 'post_id' => array( |
|
294 | + 'type' => 'number', |
|
295 | + 'default' => '', |
|
296 | + ), |
|
297 | + 'uniqid' => array( |
|
298 | + 'type' => 'string', |
|
299 | + 'default' => '', |
|
300 | + ), |
|
301 | + 'limit' => array( |
|
302 | + 'type' => 'number', |
|
303 | + 'default' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
304 | + ), |
|
305 | + 'preview' => array( |
|
306 | + 'type' => 'boolean', |
|
307 | + 'default' => false, |
|
308 | + ), |
|
309 | + 'preview_src' => array( |
|
310 | + 'type' => 'string', |
|
311 | + 'default' => WP_CONTENT_URL . '/plugins/wordlift/images/block-previews/faceted-search.png', |
|
312 | + ), |
|
313 | + 'post_types' => array( |
|
314 | + 'type' => 'string', |
|
315 | + 'default' => '', |
|
316 | + ), |
|
317 | + ); |
|
318 | + } |
|
319 | + |
|
320 | + /** |
|
321 | + * @param $post |
|
322 | + * @param $delimiter |
|
323 | + * @param $limit |
|
324 | + * |
|
325 | + * @param $post_types |
|
326 | + * |
|
327 | + * @return bool|string |
|
328 | + */ |
|
329 | + public function get_rest_url( $post, $delimiter, $limit, $post_types ) { |
|
330 | + $rest_url = $post ? rest_url( |
|
331 | + WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( |
|
332 | + array( |
|
333 | + 'post_id' => $post->ID, |
|
334 | + 'limit' => $limit, |
|
335 | + 'post_types' => $post_types, |
|
336 | + ) |
|
337 | + ) |
|
338 | + ) : false; |
|
339 | + |
|
340 | + return $rest_url; |
|
341 | + } |
|
342 | 342 | |
343 | 343 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * {@inheritdoc} |
32 | 32 | */ |
33 | - public function render( $atts ) { |
|
33 | + public function render($atts) { |
|
34 | 34 | |
35 | - return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts ) |
|
36 | - : $this->web_shortcode( $atts ); |
|
35 | + return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode($atts) |
|
36 | + : $this->web_shortcode($atts); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | private function register_block_type() { |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | |
43 | 43 | add_action( |
44 | 44 | 'init', |
45 | - function () use ( $scope ) { |
|
46 | - if ( ! function_exists( 'register_block_type' ) ) { |
|
45 | + function() use ($scope) { |
|
46 | + if ( ! function_exists('register_block_type')) { |
|
47 | 47 | // Gutenberg is not active. |
48 | 48 | return; |
49 | 49 | } |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | 'wordlift/faceted-search', |
53 | 53 | array( |
54 | 54 | 'editor_script' => 'wl-block-editor', |
55 | - 'render_callback' => function ( $attributes ) use ( $scope ) { |
|
55 | + 'render_callback' => function($attributes) use ($scope) { |
|
56 | 56 | $attr_code = ''; |
57 | - foreach ( $attributes as $key => $value ) { |
|
58 | - $attr_code .= $key . '="' . htmlentities( $value ) . '" '; |
|
57 | + foreach ($attributes as $key => $value) { |
|
58 | + $attr_code .= $key.'="'.htmlentities($value).'" '; |
|
59 | 59 | } |
60 | 60 | |
61 | - return '[' . $scope::SHORTCODE . ' ' . $attr_code . ']'; |
|
61 | + return '['.$scope::SHORTCODE.' '.$attr_code.']'; |
|
62 | 62 | }, |
63 | 63 | |
64 | 64 | 'attributes' => $scope->get_block_attributes(), |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | * @return array $shortcode_atts |
78 | 78 | * @since 3.20.0 |
79 | 79 | */ |
80 | - private function make_shortcode_atts( $atts ) { |
|
80 | + private function make_shortcode_atts($atts) { |
|
81 | 81 | |
82 | 82 | // Extract attributes and set default values. |
83 | 83 | $shortcode_atts = shortcode_atts( |
84 | 84 | array( |
85 | - 'title' => __( 'Related articles', 'wordlift' ), |
|
86 | - 'limit' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
85 | + 'title' => __('Related articles', 'wordlift'), |
|
86 | + 'limit' => apply_filters('wl_faceted_search_default_limit', 10), |
|
87 | 87 | 'post_id' => '', |
88 | 88 | 'template_id' => '', |
89 | - 'uniqid' => uniqid( 'wl-faceted-widget-' ), |
|
89 | + 'uniqid' => uniqid('wl-faceted-widget-'), |
|
90 | 90 | 'post_types' => '', |
91 | 91 | ), |
92 | 92 | $atts |
@@ -103,34 +103,34 @@ discard block |
||
103 | 103 | * @return string Shortcode HTML for web |
104 | 104 | * @since 3.20.0 |
105 | 105 | */ |
106 | - private function web_shortcode( $atts ) { |
|
106 | + private function web_shortcode($atts) { |
|
107 | 107 | |
108 | 108 | // attributes extraction and boolean filtering |
109 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
109 | + $shortcode_atts = $this->make_shortcode_atts($atts); |
|
110 | 110 | |
111 | 111 | // avoid building the widget when no post_id is specified and there is a list of posts. |
112 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
112 | + if (empty($shortcode_atts['post_id']) && ! is_singular()) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | 115 | |
116 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
117 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
118 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
119 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
120 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
116 | + $post = ! empty($shortcode_atts['post_id']) ? get_post(intval(sanitize_text_field($shortcode_atts['post_id']))) : get_post(); |
|
117 | + $title = esc_attr(sanitize_text_field($shortcode_atts['title'])); |
|
118 | + $template_id = esc_attr(sanitize_text_field($shortcode_atts['template_id'])); |
|
119 | + $limit = esc_attr(sanitize_text_field($shortcode_atts['limit'])); |
|
120 | + $faceted_id = ! empty($shortcode_atts['uniqid']) ? esc_attr(sanitize_text_field($shortcode_atts['uniqid'])) : uniqid('wl-faceted-widget-'); |
|
121 | 121 | |
122 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
123 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
124 | - $rest_url = $this->get_rest_url( $post, $delimiter, $limit, $shortcode_atts['post_types'] ); |
|
125 | - $rest_url = esc_attr( $rest_url ); |
|
122 | + $permalink_structure = get_option('permalink_structure'); |
|
123 | + $delimiter = empty($permalink_structure) ? '&' : '?'; |
|
124 | + $rest_url = $this->get_rest_url($post, $delimiter, $limit, $shortcode_atts['post_types']); |
|
125 | + $rest_url = esc_attr($rest_url); |
|
126 | 126 | |
127 | 127 | // avoid building the widget when no valid $rest_url |
128 | - if ( ! $rest_url ) { |
|
128 | + if ( ! $rest_url) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | - wp_enqueue_script( 'wordlift-cloud' ); |
|
133 | - $template_url = get_rest_url( null, '/wordlift/v1/faceted-search/template' ); |
|
132 | + wp_enqueue_script('wordlift-cloud'); |
|
133 | + $template_url = get_rest_url(null, '/wordlift/v1/faceted-search/template'); |
|
134 | 134 | |
135 | 135 | return wp_kses( |
136 | 136 | sprintf( |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | data-template-id="%s" |
143 | 143 | data-template-url="%s"></div> |
144 | 144 | ', |
145 | - esc_attr( $faceted_id ), |
|
146 | - esc_attr( $rest_url ), |
|
147 | - esc_attr( $title ), |
|
148 | - esc_attr( $template_id ), |
|
149 | - esc_url( $template_url ) |
|
145 | + esc_attr($faceted_id), |
|
146 | + esc_attr($rest_url), |
|
147 | + esc_attr($title), |
|
148 | + esc_attr($template_id), |
|
149 | + esc_url($template_url) |
|
150 | 150 | ), |
151 | 151 | array( |
152 | 152 | 'div' => array( |
@@ -170,26 +170,26 @@ discard block |
||
170 | 170 | * @return string Shortcode HTML for amp |
171 | 171 | * @since 3.20.0 |
172 | 172 | */ |
173 | - private function amp_shortcode( $atts ) { |
|
173 | + private function amp_shortcode($atts) { |
|
174 | 174 | |
175 | 175 | // attributes extraction and boolean filtering |
176 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
176 | + $shortcode_atts = $this->make_shortcode_atts($atts); |
|
177 | 177 | |
178 | 178 | // avoid building the widget when no post_id is specified and there is a list of posts. |
179 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
179 | + if (empty($shortcode_atts['post_id']) && ! is_singular()) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
183 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
184 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
185 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
186 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
187 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
183 | + $post = ! empty($shortcode_atts['post_id']) ? get_post(intval(sanitize_text_field($shortcode_atts['post_id']))) : get_post(); |
|
184 | + $title = esc_attr(sanitize_text_field($shortcode_atts['title'])); |
|
185 | + $template_id = esc_attr(sanitize_text_field($shortcode_atts['template_id'])); |
|
186 | + $limit = esc_attr(sanitize_text_field($shortcode_atts['limit'])); |
|
187 | + $faceted_id = ! empty($shortcode_atts['uniqid']) ? esc_attr(sanitize_text_field($shortcode_atts['uniqid'])) : uniqid('wl-faceted-widget-'); |
|
188 | 188 | |
189 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
190 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
189 | + $permalink_structure = get_option('permalink_structure'); |
|
190 | + $delimiter = empty($permalink_structure) ? '&' : '?'; |
|
191 | 191 | $rest_url = $post ? rest_url( |
192 | - WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( |
|
192 | + WL_REST_ROUTE_DEFAULT_NAMESPACE.'/faceted-search'.$delimiter.build_query( |
|
193 | 193 | array( |
194 | 194 | 'amp' => 1, |
195 | 195 | 'post_id' => $post->ID, |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | ) : false; |
200 | 200 | |
201 | 201 | // avoid building the widget when no valid $rest_url |
202 | - if ( ! $rest_url ) { |
|
202 | + if ( ! $rest_url) { |
|
203 | 203 | return; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS. |
207 | 207 | // This is a hackish way, but this works for http and https URLs |
208 | - $rest_url = str_replace( array( 'http:', 'https:' ), '', $rest_url ); |
|
208 | + $rest_url = str_replace(array('http:', 'https:'), '', $rest_url); |
|
209 | 209 | |
210 | - if ( empty( $template_id ) ) { |
|
211 | - $template_id = 'template-' . $faceted_id; |
|
212 | - wp_enqueue_style( 'wordlift-amp-custom', plugin_dir_url( __DIR__ ) . '/css/wordlift-amp-custom.min.css', array(), WORDLIFT_VERSION ); |
|
210 | + if (empty($template_id)) { |
|
211 | + $template_id = 'template-'.$faceted_id; |
|
212 | + wp_enqueue_style('wordlift-amp-custom', plugin_dir_url(__DIR__).'/css/wordlift-amp-custom.min.css', array(), WORDLIFT_VERSION); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | return <<<HTML |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | return array( |
285 | 285 | 'title' => array( |
286 | 286 | 'type' => 'string', |
287 | - 'default' => __( 'Related articles', 'wordlift' ), |
|
287 | + 'default' => __('Related articles', 'wordlift'), |
|
288 | 288 | ), |
289 | 289 | 'template_id' => array( |
290 | 290 | 'type' => 'string', |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | ), |
301 | 301 | 'limit' => array( |
302 | 302 | 'type' => 'number', |
303 | - 'default' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
303 | + 'default' => apply_filters('wl_faceted_search_default_limit', 10), |
|
304 | 304 | ), |
305 | 305 | 'preview' => array( |
306 | 306 | 'type' => 'boolean', |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | ), |
309 | 309 | 'preview_src' => array( |
310 | 310 | 'type' => 'string', |
311 | - 'default' => WP_CONTENT_URL . '/plugins/wordlift/images/block-previews/faceted-search.png', |
|
311 | + 'default' => WP_CONTENT_URL.'/plugins/wordlift/images/block-previews/faceted-search.png', |
|
312 | 312 | ), |
313 | 313 | 'post_types' => array( |
314 | 314 | 'type' => 'string', |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return bool|string |
328 | 328 | */ |
329 | - public function get_rest_url( $post, $delimiter, $limit, $post_types ) { |
|
329 | + public function get_rest_url($post, $delimiter, $limit, $post_types) { |
|
330 | 330 | $rest_url = $post ? rest_url( |
331 | - WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( |
|
331 | + WL_REST_ROUTE_DEFAULT_NAMESPACE.'/faceted-search'.$delimiter.build_query( |
|
332 | 332 | array( |
333 | 333 | 'post_id' => $post->ID, |
334 | 334 | 'limit' => $limit, |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | private $custom_fields; |
10 | 10 | |
11 | - public function __construct( $schema_type, $custom_fields ) { |
|
11 | + public function __construct($schema_type, $custom_fields) { |
|
12 | 12 | $this->schema_type = $schema_type; |
13 | 13 | $this->custom_fields = $custom_fields; |
14 | 14 | } |
@@ -4,27 +4,27 @@ |
||
4 | 4 | |
5 | 5 | class Schema_Field_Group { |
6 | 6 | |
7 | - private $schema_type; |
|
8 | - |
|
9 | - private $custom_fields; |
|
10 | - |
|
11 | - public function __construct( $schema_type, $custom_fields ) { |
|
12 | - $this->schema_type = $schema_type; |
|
13 | - $this->custom_fields = $custom_fields; |
|
14 | - } |
|
15 | - |
|
16 | - /** |
|
17 | - * @return mixed |
|
18 | - */ |
|
19 | - public function get_schema_type() { |
|
20 | - return $this->schema_type; |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @return mixed |
|
25 | - */ |
|
26 | - public function get_custom_fields() { |
|
27 | - return $this->custom_fields; |
|
28 | - } |
|
7 | + private $schema_type; |
|
8 | + |
|
9 | + private $custom_fields; |
|
10 | + |
|
11 | + public function __construct( $schema_type, $custom_fields ) { |
|
12 | + $this->schema_type = $schema_type; |
|
13 | + $this->custom_fields = $custom_fields; |
|
14 | + } |
|
15 | + |
|
16 | + /** |
|
17 | + * @return mixed |
|
18 | + */ |
|
19 | + public function get_schema_type() { |
|
20 | + return $this->schema_type; |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @return mixed |
|
25 | + */ |
|
26 | + public function get_custom_fields() { |
|
27 | + return $this->custom_fields; |
|
28 | + } |
|
29 | 29 | |
30 | 30 | } |
@@ -7,6 +7,6 @@ |
||
7 | 7 | exit(1); |
8 | 8 | } |
9 | 9 | |
10 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
10 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
11 | 11 | |
12 | 12 | return ComposerAutoloaderInit1fa7477671b8ce4e96024c7b54cda86e::getLoader(); |
@@ -4,23 +4,23 @@ |
||
4 | 4 | |
5 | 5 | $issues = array(); |
6 | 6 | |
7 | -if (!(PHP_VERSION_ID >= 50600)) { |
|
8 | - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.'; |
|
7 | +if ( ! (PHP_VERSION_ID >= 50600)) { |
|
8 | + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running '.PHP_VERSION.'.'; |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | if ($issues) { |
12 | - if (!headers_sent()) { |
|
12 | + if ( ! headers_sent()) { |
|
13 | 13 | header('HTTP/1.1 500 Internal Server Error'); |
14 | 14 | } |
15 | - if (!ini_get('display_errors')) { |
|
15 | + if ( ! ini_get('display_errors')) { |
|
16 | 16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
17 | - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); |
|
18 | - } elseif (!headers_sent()) { |
|
19 | - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; |
|
17 | + fwrite(STDERR, 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.implode(PHP_EOL, $issues).PHP_EOL.PHP_EOL); |
|
18 | + } elseif ( ! headers_sent()) { |
|
19 | + echo 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)).PHP_EOL.PHP_EOL; |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | trigger_error( |
23 | - 'Composer detected issues in your platform: ' . implode(' ', $issues), |
|
23 | + 'Composer detected issues in your platform: '.implode(' ', $issues), |
|
24 | 24 | E_USER_ERROR |
25 | 25 | ); |
26 | 26 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | |
8 | 8 | return array( |
9 | - 'Wordlift\\Modules\\Pods\\' => array($baseDir . '/includes'), |
|
9 | + 'Wordlift\\Modules\\Pods\\' => array($baseDir.'/includes'), |
|
10 | 10 | ); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'reference' => 'b333eb73cb4a7848d2797684071cc0f7264565da', |
7 | 7 | 'type' => 'wordpress-plugin', |
8 | - 'install_path' => __DIR__ . '/../../', |
|
8 | + 'install_path' => __DIR__.'/../../', |
|
9 | 9 | 'aliases' => array(), |
10 | 10 | 'dev' => true, |
11 | 11 | ), |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | 'version' => 'dev-master', |
16 | 16 | 'reference' => 'b333eb73cb4a7848d2797684071cc0f7264565da', |
17 | 17 | 'type' => 'wordpress-plugin', |
18 | - 'install_path' => __DIR__ . '/../../', |
|
18 | + 'install_path' => __DIR__.'/../../', |
|
19 | 19 | 'aliases' => array(), |
20 | 20 | 'dev_requirement' => false, |
21 | 21 | ), |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static function loadClassLoader($class) |
10 | 10 | { |
11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | + require __DIR__.'/ClassLoader.php'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | return self::$loader; |
23 | 23 | } |
24 | 24 | |
25 | - require __DIR__ . '/platform_check.php'; |
|
25 | + require __DIR__.'/platform_check.php'; |
|
26 | 26 | |
27 | 27 | spl_autoload_register(array('ComposerAutoloaderInit1fa7477671b8ce4e96024c7b54cda86e', 'loadClassLoader'), true, true); |
28 | 28 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
29 | 29 | spl_autoload_unregister(array('ComposerAutoloaderInit1fa7477671b8ce4e96024c7b54cda86e', 'loadClassLoader')); |
30 | 30 | |
31 | - require __DIR__ . '/autoload_static.php'; |
|
31 | + require __DIR__.'/autoload_static.php'; |
|
32 | 32 | call_user_func(\Composer\Autoload\ComposerStaticInit1fa7477671b8ce4e96024c7b54cda86e::getInitializer($loader)); |
33 | 33 | |
34 | 34 | $loader->register(true); |