@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function bootstrap() { |
16 | 16 | |
17 | - add_action( 'plugins_loaded', __NAMESPACE__ . '\\load_textdomain' ); |
|
18 | - add_action( 'plugins_loaded', __NAMESPACE__ . '\\load_plugin' ); |
|
17 | + add_action('plugins_loaded', __NAMESPACE__ . '\\load_textdomain'); |
|
18 | + add_action('plugins_loaded', __NAMESPACE__ . '\\load_plugin'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | load_plugin_textdomain( |
27 | 27 | 'cmb2-brightcove-video-field', |
28 | 28 | false, |
29 | - basename( plugin_dir_url( __DIR__ ) ) . '/languages' |
|
29 | + basename(plugin_dir_url(__DIR__)) . '/languages' |
|
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | function is_dependency_loaded() { |
37 | 37 | |
38 | 38 | return ( |
39 | - defined( 'CMB2_LOADED' ) |
|
40 | - && ! empty( constant( 'CMB2_LOADED' ) ) |
|
41 | - && defined( 'BRIGHTCOVE_URL' ) |
|
42 | - && ! empty( constant( 'BRIGHTCOVE_URL' ) ) |
|
39 | + defined('CMB2_LOADED') |
|
40 | + && ! empty(constant('CMB2_LOADED')) |
|
41 | + && defined('BRIGHTCOVE_URL') |
|
42 | + && ! empty(constant('BRIGHTCOVE_URL')) |
|
43 | 43 | ); |
44 | 44 | } |
45 | 45 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function load_plugin() { |
50 | 50 | |
51 | - if ( ! is_dependency_loaded() ) { |
|
52 | - add_action( 'admin_notices', __NAMESPACE__ . '\\dependency_admin_notice' ); |
|
53 | - add_action( 'network_admin_notices', __NAMESPACE__ . '\\dependency_admin_notice' ); |
|
51 | + if ( ! is_dependency_loaded()) { |
|
52 | + add_action('admin_notices', __NAMESPACE__ . '\\dependency_admin_notice'); |
|
53 | + add_action('network_admin_notices', __NAMESPACE__ . '\\dependency_admin_notice'); |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | function dependency_admin_notice() { |
64 | 64 | |
65 | 65 | echo '<div class="error"><p>'; |
66 | - esc_html_e( '"CMB2 BrightCove Video Field" plugin can\'t be loaded, It requires following plugins to be installed and activated.', 'cmb2-brightcove-video-field' ); |
|
66 | + esc_html_e('"CMB2 BrightCove Video Field" plugin can\'t be loaded, It requires following plugins to be installed and activated.', 'cmb2-brightcove-video-field'); |
|
67 | 67 | echo '<ol>'; |
68 | 68 | printf( |
69 | 69 | '<li><a href="https://wordpress.org/plugins/cmb2/" target="_blank">%s</a></li>', |
70 | - esc_html__( 'CMB2', 'cmb2-brightcove-video-field' ) |
|
70 | + esc_html__('CMB2', 'cmb2-brightcove-video-field') |
|
71 | 71 | ); |
72 | 72 | printf( |
73 | 73 | ' <li><a href="https://wordpress.org/plugins/brightcove-video-connect" target="_blank">%s</a></li>', |
74 | - esc_html__( 'Brightcove Video Connect', 'cmb2-brightcove-video-field' ) |
|
74 | + esc_html__('Brightcove Video Connect', 'cmb2-brightcove-video-field') |
|
75 | 75 | ); |
76 | 76 | echo '</ol>'; |
77 | - esc_html_e( 'Please verify the dependency to enable this field type.', 'cmb2-brightcove-video-field' ); |
|
77 | + esc_html_e('Please verify the dependency to enable this field type.', 'cmb2-brightcove-video-field'); |
|
78 | 78 | echo '</p></div>'; |
79 | 79 | } |
80 | 80 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function add_brightcove_video_field() { |
85 | 85 | |
86 | - add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\enqueue_scripts', 11 ); |
|
87 | - add_action( 'cmb2_render_brightcove_video', __NAMESPACE__ . '\\cmb2_render_callback_for_brightcove_video', 10, 5 ); |
|
88 | - add_action( 'admin_footer', __NAMESPACE__ . '\\js_wp_templates' ); |
|
86 | + add_action('admin_enqueue_scripts', __NAMESPACE__ . '\\enqueue_scripts', 11); |
|
87 | + add_action('cmb2_render_brightcove_video', __NAMESPACE__ . '\\cmb2_render_callback_for_brightcove_video', 10, 5); |
|
88 | + add_action('admin_footer', __NAMESPACE__ . '\\js_wp_templates'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,22 +93,22 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param string $hook Hook for the current page in the admin. |
95 | 95 | */ |
96 | -function enqueue_scripts( $hook ) { |
|
96 | +function enqueue_scripts($hook) { |
|
97 | 97 | |
98 | - if ( ! in_array( $hook, [ 'post.php', 'post-new.php' ], true ) ) { |
|
98 | + if ( ! in_array($hook, ['post.php', 'post-new.php'], true)) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | 102 | wp_enqueue_style( |
103 | 103 | 'cmb2-brightcove-video-field-css', |
104 | - plugin_dir_url( __FILE__ ) . 'assets/css/brightcove-video-field.css', |
|
104 | + plugin_dir_url(__FILE__) . 'assets/css/brightcove-video-field.css', |
|
105 | 105 | [], |
106 | 106 | VERSION |
107 | 107 | ); |
108 | 108 | |
109 | 109 | wp_enqueue_script( |
110 | 110 | 'cmb2-brightcove-video-field-js', |
111 | - plugin_dir_url( __FILE__ ) . 'assets/js/brightcove-video-field.js', |
|
111 | + plugin_dir_url(__FILE__) . 'assets/js/brightcove-video-field.js', |
|
112 | 112 | [ |
113 | 113 | 'wp-util', |
114 | 114 | 'brightcove-admin', |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $object_type Field object type, ex: post type, user, option-page etc. |
129 | 129 | * @param \CMB2_Types $field_type_object `CMB2_Types` object. |
130 | 130 | */ |
131 | -function cmb2_render_callback_for_brightcove_video( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
131 | +function cmb2_render_callback_for_brightcove_video($field, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
132 | 132 | |
133 | 133 | $field_id = $field->id(); |
134 | 134 | |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | 'padding_top' => '10', // Adding min 10 padding since by-default it's adding 56.25% padding even with 0 padding. |
147 | 147 | ]; |
148 | 148 | |
149 | - $bc_video_args = wp_parse_args( $bc_video_values, $bc_video_args ); |
|
149 | + $bc_video_args = wp_parse_args($bc_video_values, $bc_video_args); |
|
150 | 150 | |
151 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
151 | + $allowed_html = wp_kses_allowed_html('post'); |
|
152 | 152 | $allowed_html['iframe'] = [ |
153 | 153 | 'src' => true, |
154 | 154 | 'webkitallowfullscreen' => true, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'mozallowfullscreen' => true, |
157 | 157 | 'style' => true, |
158 | 158 | ]; |
159 | - $allowed_html['input'] = [ |
|
159 | + $allowed_html['input'] = [ |
|
160 | 160 | 'type' => true, |
161 | 161 | 'class' => true, |
162 | 162 | 'name' => true, |
@@ -167,28 +167,28 @@ discard block |
||
167 | 167 | |
168 | 168 | // Remove jetpack shortcode module filters which is converting this shortcode to anchor tag when jetpack is enabled. |
169 | 169 | // ref: https://github.com/Automattic/jetpack/blob/cb04cfc4479515f12945256555bbab1192711c57/modules/shortcodes/class.filter-embedded-html-objects.php#L11-L12. |
170 | - if ( class_exists( 'Filter_Embedded_HTML_Objects' ) ) { |
|
171 | - remove_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'filter' ], 11 ); |
|
172 | - remove_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ], 100 ); |
|
170 | + if (class_exists('Filter_Embedded_HTML_Objects')) { |
|
171 | + remove_filter('pre_kses', ['Filter_Embedded_HTML_Objects', 'filter'], 11); |
|
172 | + remove_filter('pre_kses', ['Filter_Embedded_HTML_Objects', 'maybe_create_links'], 100); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | ?> |
176 | 176 | <div class="cmb2-brightcove-video-metabox"> |
177 | 177 | <button type="button" class="button brightcove-add-media-btn"> |
178 | 178 | <?php |
179 | - $button_title = __( 'Select Brightcove Video', 'cmb2-brightcove-video-field' ); |
|
179 | + $button_title = __('Select Brightcove Video', 'cmb2-brightcove-video-field'); |
|
180 | 180 | printf( |
181 | 181 | '<img class="bc-button-icon" src="%s" alt="%s" />%s', |
182 | - esc_url( BRIGHTCOVE_URL . 'images/menu-icon.svg' ), |
|
183 | - esc_attr( $button_title ), |
|
184 | - esc_html( $button_title ) |
|
182 | + esc_url(BRIGHTCOVE_URL . 'images/menu-icon.svg'), |
|
183 | + esc_attr($button_title), |
|
184 | + esc_html($button_title) |
|
185 | 185 | ); |
186 | 186 | ?> |
187 | 187 | </button> |
188 | 188 | <div class="brightcove-video-preview"> |
189 | 189 | <?php |
190 | - if( ! empty( $bc_video_args['video_id'] ) ) { |
|
191 | - echo wp_kses( BC_Video_Shortcode::bc_video( $bc_video_args ), $allowed_html ); |
|
190 | + if ( ! empty($bc_video_args['video_id'])) { |
|
191 | + echo wp_kses(BC_Video_Shortcode::bc_video($bc_video_args), $allowed_html); |
|
192 | 192 | echo '<a href="#" class="bc-remove-video">Remove brightcove video</a>'; |
193 | 193 | } |
194 | 194 | ?> |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | $field_type_object->input( |
200 | 200 | [ |
201 | 201 | 'type' => 'hidden', |
202 | - 'id' => esc_attr( $field_id . '_bc_video_id' ), |
|
202 | + 'id' => esc_attr($field_id . '_bc_video_id'), |
|
203 | 203 | 'class' => 'bc_video_id', |
204 | - 'name' => esc_attr( $field_id . '[bc_video_id]' ), |
|
205 | - 'value' => esc_attr( $bc_video_values['video_id'] ) ?? '', |
|
204 | + 'name' => esc_attr($field_id . '[bc_video_id]'), |
|
205 | + 'value' => esc_attr($bc_video_values['video_id']) ?? '', |
|
206 | 206 | ] |
207 | 207 | ), |
208 | 208 | $allowed_html |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | $field_type_object->input( |
212 | 212 | [ |
213 | 213 | 'type' => 'hidden', |
214 | - 'id' => esc_attr( $field_id . '_bc_video_duration' ), |
|
214 | + 'id' => esc_attr($field_id . '_bc_video_duration'), |
|
215 | 215 | 'class' => 'bc_video_duration', |
216 | - 'name' => esc_attr( $field_id . '[bc_video_duration]' ), |
|
217 | - 'value' => esc_attr( $bc_video_values['video_duration'] ) ?? '', |
|
216 | + 'name' => esc_attr($field_id . '[bc_video_duration]'), |
|
217 | + 'value' => esc_attr($bc_video_values['video_duration']) ?? '', |
|
218 | 218 | ] |
219 | 219 | ), |
220 | 220 | $allowed_html |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | $field_type_object->input( |
224 | 224 | [ |
225 | 225 | 'type' => 'hidden', |
226 | - 'id' => esc_attr( $field_id . '_bc_player_id' ), |
|
226 | + 'id' => esc_attr($field_id . '_bc_player_id'), |
|
227 | 227 | 'class' => 'bc_player_id', |
228 | - 'name' => esc_attr( $field_id . '[bc_player_id]' ), |
|
229 | - 'value' => esc_attr( $bc_video_values['player_id'] ) ?? '', |
|
228 | + 'name' => esc_attr($field_id . '[bc_player_id]'), |
|
229 | + 'value' => esc_attr($bc_video_values['player_id']) ?? '', |
|
230 | 230 | ] |
231 | 231 | ), |
232 | 232 | $allowed_html |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | $field_type_object->input( |
236 | 236 | [ |
237 | 237 | 'type' => 'hidden', |
238 | - 'id' => esc_attr( $field_id . '_bc_account_id' ), |
|
238 | + 'id' => esc_attr($field_id . '_bc_account_id'), |
|
239 | 239 | 'class' => 'bc_account_id', |
240 | - 'name' => esc_attr( $field_id . '[bc_account_id]' ), |
|
241 | - 'value' => esc_attr( $bc_video_values['account_id'] ) ?? '', |
|
240 | + 'name' => esc_attr($field_id . '[bc_account_id]'), |
|
241 | + 'value' => esc_attr($bc_video_values['account_id']) ?? '', |
|
242 | 242 | ] |
243 | 243 | ), |
244 | 244 | $allowed_html |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | <?php |
249 | 249 | |
250 | 250 | // Enable jetpack embed filter. |
251 | - if ( class_exists( 'Filter_Embedded_HTML_Objects' ) ) { |
|
252 | - add_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'filter' ], 11 ); |
|
253 | - add_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ], 100 ); |
|
251 | + if (class_exists('Filter_Embedded_HTML_Objects')) { |
|
252 | + add_filter('pre_kses', ['Filter_Embedded_HTML_Objects', 'filter'], 11); |
|
253 | + add_filter('pre_kses', ['Filter_Embedded_HTML_Objects', 'maybe_create_links'], 100); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 |