@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | */ |
10 | 10 | _deprecated_file( |
11 | 11 | /* translators: %s: template name */ |
12 | - sprintf( __( 'Theme without %s' ), basename( __FILE__ ) ), |
|
12 | + sprintf(__('Theme without %s'), basename(__FILE__)), |
|
13 | 13 | '3.0', |
14 | 14 | null, |
15 | 15 | /* translators: %s: template name */ |
16 | - sprintf( __( 'Please include a %s template in your theme.' ), basename( __FILE__ ) ) |
|
16 | + sprintf(__('Please include a %s template in your theme.'), basename(__FILE__)) |
|
17 | 17 | ); |
18 | 18 | ?> |
19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | <?php |
25 | 25 | printf( |
26 | 26 | /* translators: 1: blog name, 2: WordPress */ |
27 | - __( '%1$s is proudly powered by %2$s' ), |
|
27 | + __('%1$s is proudly powered by %2$s'), |
|
28 | 28 | get_bloginfo('name'), |
29 | 29 | '<a href="https://wordpress.org/">WordPress</a>' |
30 | 30 | ); |
@@ -12,15 +12,15 @@ discard block |
||
12 | 12 | */ |
13 | 13 | ?> |
14 | 14 | <div class="wp-embed"> |
15 | - <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p> |
|
15 | + <p class="wp-embed-heading"><?php _e('Oops! That embed can’t be found.'); ?></p> |
|
16 | 16 | |
17 | 17 | <div class="wp-embed-excerpt"> |
18 | 18 | <p> |
19 | 19 | <?php |
20 | 20 | printf( |
21 | 21 | /* translators: %s: a link to the embedded site */ |
22 | - __( 'It looks like nothing was found at this location. Maybe try visiting %s directly?' ), |
|
23 | - '<strong><a href="' . esc_url( home_url() ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a></strong>' |
|
22 | + __('It looks like nothing was found at this location. Maybe try visiting %s directly?'), |
|
23 | + '<strong><a href="'.esc_url(home_url()).'">'.esc_html(get_bloginfo('name')).'</a></strong>' |
|
24 | 24 | ); |
25 | 25 | ?> |
26 | 26 | </p> |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | <?php |
30 | 30 | /** This filter is documented in wp-includes/theme-compat/embed-content.php */ |
31 | - do_action( 'embed_content' ); |
|
31 | + do_action('embed_content'); |
|
32 | 32 | ?> |
33 | 33 | |
34 | 34 | <div class="wp-embed-footer"> |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | * @since 4.5.0 |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! headers_sent() ) { |
|
15 | - header( 'X-WP-embed: true' ); |
|
14 | +if ( ! headers_sent()) { |
|
15 | + header('X-WP-embed: true'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @since 4.4.0 |
29 | 29 | */ |
30 | - do_action( 'embed_head' ); |
|
30 | + do_action('embed_head'); |
|
31 | 31 | ?> |
32 | 32 | </head> |
33 | 33 | <body <?php body_class(); ?>> |
@@ -9,17 +9,17 @@ discard block |
||
9 | 9 | */ |
10 | 10 | _deprecated_file( |
11 | 11 | /* translators: %s: template name */ |
12 | - sprintf( __( 'Theme without %s' ), basename( __FILE__ ) ), |
|
12 | + sprintf(__('Theme without %s'), basename(__FILE__)), |
|
13 | 13 | '3.0', |
14 | 14 | null, |
15 | 15 | /* translators: %s: template name */ |
16 | - sprintf( __( 'Please include a %s template in your theme.' ), basename( __FILE__ ) ) |
|
16 | + sprintf(__('Please include a %s template in your theme.'), basename(__FILE__)) |
|
17 | 17 | ); |
18 | 18 | ?> |
19 | 19 | <div id="sidebar" role="complementary"> |
20 | 20 | <ul> |
21 | 21 | <?php /* Widgetized sidebar, if you have the plugin installed. */ |
22 | - if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> |
|
22 | + if ( ! function_exists('dynamic_sidebar') || ! dynamic_sidebar()) : ?> |
|
23 | 23 | <li> |
24 | 24 | <?php get_search_form(); ?> |
25 | 25 | </li> |
@@ -30,54 +30,54 @@ discard block |
||
30 | 30 | </li> |
31 | 31 | --> |
32 | 32 | |
33 | - <?php if ( is_404() || is_category() || is_day() || is_month() || |
|
34 | - is_year() || is_search() || is_paged() ) : |
|
33 | + <?php if (is_404() || is_category() || is_day() || is_month() || |
|
34 | + is_year() || is_search() || is_paged()) : |
|
35 | 35 | ?> <li> |
36 | 36 | |
37 | - <?php if ( is_404() ) : /* If this is a 404 page */ ?> |
|
38 | - <?php elseif ( is_category() ) : /* If this is a category archive */ ?> |
|
37 | + <?php if (is_404()) : /* If this is a 404 page */ ?> |
|
38 | + <?php elseif (is_category()) : /* If this is a category archive */ ?> |
|
39 | 39 | <p><?php /* translators: %s: category name */ |
40 | - printf( __( 'You are currently browsing the archives for the %s category.' ), |
|
41 | - single_cat_title( '', false ) |
|
40 | + printf(__('You are currently browsing the archives for the %s category.'), |
|
41 | + single_cat_title('', false) |
|
42 | 42 | ); |
43 | 43 | ?></p> |
44 | 44 | |
45 | - <?php elseif ( is_day() ) : /* If this is a daily archive */ ?> |
|
45 | + <?php elseif (is_day()) : /* If this is a daily archive */ ?> |
|
46 | 46 | <p><?php /* translators: 1: site link, 2: archive date */ |
47 | - printf( __( 'You are currently browsing the %1$s blog archives for the day %2$s.' ), |
|
48 | - sprintf( '<a href="%1$s/">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ), |
|
49 | - get_the_time( __( 'l, F jS, Y' ) ) |
|
47 | + printf(__('You are currently browsing the %1$s blog archives for the day %2$s.'), |
|
48 | + sprintf('<a href="%1$s/">%2$s</a>', get_bloginfo('url'), get_bloginfo('name')), |
|
49 | + get_the_time(__('l, F jS, Y')) |
|
50 | 50 | ); |
51 | 51 | ?></p> |
52 | 52 | |
53 | - <?php elseif ( is_month() ) : /* If this is a monthly archive */ ?> |
|
53 | + <?php elseif (is_month()) : /* If this is a monthly archive */ ?> |
|
54 | 54 | <p><?php /* translators: 1: site link, 2: archive month */ |
55 | - printf( __( 'You are currently browsing the %1$s blog archives for %2$s.' ), |
|
56 | - sprintf( '<a href="%1$s/">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ), |
|
57 | - get_the_time( __( 'F, Y' ) ) |
|
55 | + printf(__('You are currently browsing the %1$s blog archives for %2$s.'), |
|
56 | + sprintf('<a href="%1$s/">%2$s</a>', get_bloginfo('url'), get_bloginfo('name')), |
|
57 | + get_the_time(__('F, Y')) |
|
58 | 58 | ); |
59 | 59 | ?></p> |
60 | 60 | |
61 | - <?php elseif ( is_year() ) : /* If this is a yearly archive */ ?> |
|
61 | + <?php elseif (is_year()) : /* If this is a yearly archive */ ?> |
|
62 | 62 | <p><?php /* translators: 1: site link, 2: archive year */ |
63 | - printf( __( 'You are currently browsing the %1$s blog archives for the year %2$s.' ), |
|
64 | - sprintf( '<a href="%1$s/">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ), |
|
65 | - get_the_time( 'Y' ) |
|
63 | + printf(__('You are currently browsing the %1$s blog archives for the year %2$s.'), |
|
64 | + sprintf('<a href="%1$s/">%2$s</a>', get_bloginfo('url'), get_bloginfo('name')), |
|
65 | + get_the_time('Y') |
|
66 | 66 | ); |
67 | 67 | ?></p> |
68 | 68 | |
69 | - <?php elseif ( is_search() ) : /* If this is a search result */ ?> |
|
69 | + <?php elseif (is_search()) : /* If this is a search result */ ?> |
|
70 | 70 | <p><?php /* translators: 1: site link, 2: search query */ |
71 | - printf( __( 'You have searched the %1$s blog archives for <strong>‘%2$s’</strong>. If you are unable to find anything in these search results, you can try one of these links.' ), |
|
72 | - sprintf( '<a href="%1$s/">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ), |
|
73 | - esc_html( get_search_query() ) |
|
71 | + printf(__('You have searched the %1$s blog archives for <strong>‘%2$s’</strong>. If you are unable to find anything in these search results, you can try one of these links.'), |
|
72 | + sprintf('<a href="%1$s/">%2$s</a>', get_bloginfo('url'), get_bloginfo('name')), |
|
73 | + esc_html(get_search_query()) |
|
74 | 74 | ); |
75 | 75 | ?></p> |
76 | 76 | |
77 | - <?php elseif ( isset( $_GET['paged'] ) && ! empty( $_GET['paged'] ) ) : /* If this set is paginated */ ?> |
|
77 | + <?php elseif (isset($_GET['paged']) && ! empty($_GET['paged'])) : /* If this set is paginated */ ?> |
|
78 | 78 | <p><?php /* translators: %s: site link */ |
79 | - printf( __( 'You are currently browsing the %s blog archives.' ), |
|
80 | - sprintf( '<a href="%1$s/">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ) |
|
79 | + printf(__('You are currently browsing the %s blog archives.'), |
|
80 | + sprintf('<a href="%1$s/">%2$s</a>', get_bloginfo('url'), get_bloginfo('name')) |
|
81 | 81 | ); |
82 | 82 | ?></p> |
83 | 83 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | <?php endif; ?> |
88 | 88 | </ul> |
89 | 89 | <ul role="navigation"> |
90 | - <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>' ); ?> |
|
90 | + <?php wp_list_pages('title_li=<h2>'.__('Pages').'</h2>'); ?> |
|
91 | 91 | |
92 | 92 | <li><h2><?php _e('Archives'); ?></h2> |
93 | 93 | <ul> |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | </ul> |
96 | 96 | </li> |
97 | 97 | |
98 | - <?php wp_list_categories(array('show_count' => 1, 'title_li' => '<h2>' . __('Categories') . '</h2>')); ?> |
|
98 | + <?php wp_list_categories(array('show_count' => 1, 'title_li' => '<h2>'.__('Categories').'</h2>')); ?> |
|
99 | 99 | </ul> |
100 | 100 | <ul> |
101 | - <?php if ( is_home() || is_page() ) { /* If this is the frontpage */ ?> |
|
101 | + <?php if (is_home() || is_page()) { /* If this is the frontpage */ ?> |
|
102 | 102 | <?php wp_list_bookmarks(); ?> |
103 | 103 | |
104 | 104 | <li><h2><?php _e('Meta'); ?></h2> |
@@ -10,14 +10,14 @@ |
||
10 | 10 | * @since 4.4.0 |
11 | 11 | */ |
12 | 12 | |
13 | -get_header( 'embed' ); |
|
13 | +get_header('embed'); |
|
14 | 14 | |
15 | -if ( have_posts() ) : |
|
16 | - while ( have_posts() ) : the_post(); |
|
17 | - get_template_part( 'embed', 'content' ); |
|
15 | +if (have_posts()) : |
|
16 | + while (have_posts()) : the_post(); |
|
17 | + get_template_part('embed', 'content'); |
|
18 | 18 | endwhile; |
19 | 19 | else : |
20 | - get_template_part( 'embed', '404' ); |
|
20 | + get_template_part('embed', '404'); |
|
21 | 21 | endif; |
22 | 22 | |
23 | -get_footer( 'embed' ); |
|
23 | +get_footer('embed'); |
@@ -16,8 +16,10 @@ |
||
16 | 16 | while ( have_posts() ) : the_post(); |
17 | 17 | get_template_part( 'embed', 'content' ); |
18 | 18 | endwhile; |
19 | -else : |
|
19 | +else { |
|
20 | + : |
|
20 | 21 | get_template_part( 'embed', '404' ); |
22 | +} |
|
21 | 23 | endif; |
22 | 24 | |
23 | 25 | get_footer( 'embed' ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @todo Decouple this |
29 | 29 | * @var array |
30 | 30 | */ |
31 | - public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); |
|
31 | + public $db_fields = array('parent' => 'parent', 'id' => 'term_id'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Start the element output. |
@@ -43,27 +43,27 @@ discard block |
||
43 | 43 | * See {@see wp_dropdown_categories()}. |
44 | 44 | * @param int $id Optional. ID of the current category. Default 0 (unused). |
45 | 45 | */ |
46 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
46 | + public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { |
|
47 | 47 | $pad = str_repeat(' ', $depth * 3); |
48 | 48 | |
49 | 49 | /** This filter is documented in wp-includes/category-template.php */ |
50 | - $cat_name = apply_filters( 'list_cats', $category->name, $category ); |
|
50 | + $cat_name = apply_filters('list_cats', $category->name, $category); |
|
51 | 51 | |
52 | - if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) { |
|
52 | + if (isset($args['value_field']) && isset($category->{$args['value_field']} )) { |
|
53 | 53 | $value_field = $args['value_field']; |
54 | 54 | } else { |
55 | 55 | $value_field = 'term_id'; |
56 | 56 | } |
57 | 57 | |
58 | - $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\""; |
|
58 | + $output .= "\t<option class=\"level-$depth\" value=\"".esc_attr($category->{$value_field} )."\""; |
|
59 | 59 | |
60 | 60 | // Type-juggling causes false matches, so we force everything to a string. |
61 | - if ( (string) $category->{$value_field} === (string) $args['selected'] ) |
|
61 | + if ((string) $category->{$value_field} === (string) $args['selected']) |
|
62 | 62 | $output .= ' selected="selected"'; |
63 | 63 | $output .= '>'; |
64 | 64 | $output .= $pad.$cat_name; |
65 | - if ( $args['show_count'] ) |
|
66 | - $output .= ' ('. number_format_i18n( $category->count ) .')'; |
|
65 | + if ($args['show_count']) |
|
66 | + $output .= ' ('.number_format_i18n($category->count).')'; |
|
67 | 67 | $output .= "</option>\n"; |
68 | 68 | } |
69 | 69 | } |
@@ -58,12 +58,14 @@ |
||
58 | 58 | $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\""; |
59 | 59 | |
60 | 60 | // Type-juggling causes false matches, so we force everything to a string. |
61 | - if ( (string) $category->{$value_field} === (string) $args['selected'] ) |
|
62 | - $output .= ' selected="selected"'; |
|
61 | + if ( (string) $category->{$value_field} === (string) $args['selected'] ) { |
|
62 | + $output .= ' selected="selected"'; |
|
63 | + } |
|
63 | 64 | $output .= '>'; |
64 | 65 | $output .= $pad.$cat_name; |
65 | - if ( $args['show_count'] ) |
|
66 | - $output .= ' ('. number_format_i18n( $category->count ) .')'; |
|
66 | + if ( $args['show_count'] ) { |
|
67 | + $output .= ' ('. number_format_i18n( $category->count ) .')'; |
|
68 | + } |
|
67 | 69 | $output .= "</option>\n"; |
68 | 70 | } |
69 | 71 | } |
@@ -382,21 +382,24 @@ discard block |
||
382 | 382 | $all_instances = $this->get_settings(); |
383 | 383 | |
384 | 384 | // We need to update the data |
385 | - if ( $this->updated ) |
|
386 | - return; |
|
385 | + if ( $this->updated ) { |
|
386 | + return; |
|
387 | + } |
|
387 | 388 | |
388 | 389 | if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { |
389 | 390 | // Delete the settings for this instance of the widget |
390 | - if ( isset($_POST['the-widget-id']) ) |
|
391 | - $del_id = $_POST['the-widget-id']; |
|
392 | - else |
|
393 | - return; |
|
391 | + if ( isset($_POST['the-widget-id']) ) { |
|
392 | + $del_id = $_POST['the-widget-id']; |
|
393 | + } else { |
|
394 | + return; |
|
395 | + } |
|
394 | 396 | |
395 | 397 | if ( isset($wp_registered_widgets[$del_id]['params'][0]['number']) ) { |
396 | 398 | $number = $wp_registered_widgets[$del_id]['params'][0]['number']; |
397 | 399 | |
398 | - if ( $this->id_base . '-' . $number == $del_id ) |
|
399 | - unset($all_instances[$number]); |
|
400 | + if ( $this->id_base . '-' . $number == $del_id ) { |
|
401 | + unset($all_instances[$number]); |
|
402 | + } |
|
400 | 403 | } |
401 | 404 | } else { |
402 | 405 | if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) { |
@@ -461,8 +464,9 @@ discard block |
||
461 | 464 | * @return string|null |
462 | 465 | */ |
463 | 466 | public function form_callback( $widget_args = 1 ) { |
464 | - if ( is_numeric($widget_args) ) |
|
465 | - $widget_args = array( 'number' => $widget_args ); |
|
467 | + if ( is_numeric($widget_args) ) { |
|
468 | + $widget_args = array( 'number' => $widget_args ); |
|
469 | + } |
|
466 | 470 | |
467 | 471 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
468 | 472 | $all_instances = $this->get_settings(); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * 'before_widget', and 'after_widget'. |
99 | 99 | * @param array $instance The settings for the particular instance of the widget. |
100 | 100 | */ |
101 | - public function widget( $args, $instance ) { |
|
101 | + public function widget($args, $instance) { |
|
102 | 102 | die('function WP_Widget::widget() must be over-ridden in a sub-class.'); |
103 | 103 | } |
104 | 104 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param array $old_instance Old settings for this instance. |
118 | 118 | * @return array Settings to save or bool false to cancel saving. |
119 | 119 | */ |
120 | - public function update( $new_instance, $old_instance ) { |
|
120 | + public function update($new_instance, $old_instance) { |
|
121 | 121 | return $new_instance; |
122 | 122 | } |
123 | 123 | |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | * @param array $instance Current settings. |
131 | 131 | * @return string Default return is 'noform'. |
132 | 132 | */ |
133 | - public function form( $instance ) { |
|
134 | - echo '<p class="no-options-widget">' . __('There are no options for this widget.') . '</p>'; |
|
133 | + public function form($instance) { |
|
134 | + echo '<p class="no-options-widget">'.__('There are no options for this widget.').'</p>'; |
|
135 | 135 | return 'noform'; |
136 | 136 | } |
137 | 137 | |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | * @param array $control_options Optional. Widget control options. See wp_register_widget_control() for |
152 | 152 | * information on accepted arguments. Default empty array. |
153 | 153 | */ |
154 | - public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) { |
|
155 | - $this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base); |
|
154 | + public function __construct($id_base, $name, $widget_options = array(), $control_options = array()) { |
|
155 | + $this->id_base = empty($id_base) ? preg_replace('/(wp_)?widget_/', '', strtolower(get_class($this))) : strtolower($id_base); |
|
156 | 156 | $this->name = $name; |
157 | - $this->option_name = 'widget_' . $this->id_base; |
|
158 | - $this->widget_options = wp_parse_args( $widget_options, array( 'classname' => $this->option_name, 'customize_selective_refresh' => false ) ); |
|
159 | - $this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) ); |
|
157 | + $this->option_name = 'widget_'.$this->id_base; |
|
158 | + $this->widget_options = wp_parse_args($widget_options, array('classname' => $this->option_name, 'customize_selective_refresh' => false)); |
|
159 | + $this->control_options = wp_parse_args($control_options, array('id_base' => $this->id_base)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | * @param array $widget_options |
168 | 168 | * @param array $control_options |
169 | 169 | */ |
170 | - public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) { |
|
171 | - _deprecated_constructor( 'WP_Widget', '4.3.0', get_class( $this ) ); |
|
172 | - WP_Widget::__construct( $id_base, $name, $widget_options, $control_options ); |
|
170 | + public function WP_Widget($id_base, $name, $widget_options = array(), $control_options = array()) { |
|
171 | + _deprecated_constructor('WP_Widget', '4.3.0', get_class($this)); |
|
172 | + WP_Widget::__construct($id_base, $name, $widget_options, $control_options); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @return string Name attribute for $field_name |
185 | 185 | */ |
186 | 186 | public function get_field_name($field_name) { |
187 | - if ( false === $pos = strpos( $field_name, '[' ) ) { |
|
188 | - return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; |
|
187 | + if (false === $pos = strpos($field_name, '[')) { |
|
188 | + return 'widget-'.$this->id_base.'['.$this->number.']['.$field_name.']'; |
|
189 | 189 | } else { |
190 | - return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); |
|
190 | + return 'widget-'.$this->id_base.'['.$this->number.']['.substr_replace($field_name, '][', $pos, strlen('[')); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * @param string $field_name Field name. |
205 | 205 | * @return string ID attribute for `$field_name`. |
206 | 206 | */ |
207 | - public function get_field_id( $field_name ) { |
|
208 | - return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' ); |
|
207 | + public function get_field_id($field_name) { |
|
208 | + return 'widget-'.$this->id_base.'-'.$this->number.'-'.trim(str_replace(array('[]', '[', ']'), array('', '-', ''), $field_name), '-'); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -219,23 +219,23 @@ discard block |
||
219 | 219 | $empty = true; |
220 | 220 | |
221 | 221 | // When $settings is an array-like object, get an intrinsic array for use with array_keys(). |
222 | - if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) { |
|
222 | + if ($settings instanceof ArrayObject || $settings instanceof ArrayIterator) { |
|
223 | 223 | $settings = $settings->getArrayCopy(); |
224 | 224 | } |
225 | 225 | |
226 | - if ( is_array( $settings ) ) { |
|
227 | - foreach ( array_keys( $settings ) as $number ) { |
|
228 | - if ( is_numeric( $number ) ) { |
|
229 | - $this->_set( $number ); |
|
230 | - $this->_register_one( $number ); |
|
226 | + if (is_array($settings)) { |
|
227 | + foreach (array_keys($settings) as $number) { |
|
228 | + if (is_numeric($number)) { |
|
229 | + $this->_set($number); |
|
230 | + $this->_register_one($number); |
|
231 | 231 | $empty = false; |
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - if ( $empty ) { |
|
236 | + if ($empty) { |
|
237 | 237 | // If there are none, we register the widget's existence with a generic template. |
238 | - $this->_set( 1 ); |
|
238 | + $this->_set(1); |
|
239 | 239 | $this->_register_one(); |
240 | 240 | } |
241 | 241 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function _set($number) { |
253 | 253 | $this->number = $number; |
254 | - $this->id = $this->id_base . '-' . $number; |
|
254 | + $this->id = $this->id_base.'-'.$number; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function is_preview() { |
306 | 306 | global $wp_customize; |
307 | - return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ; |
|
307 | + return (isset($wp_customize) && $wp_customize->is_preview()); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | * @type int $number Number increment used for multiples of the same widget. |
325 | 325 | * } |
326 | 326 | */ |
327 | - public function display_callback( $args, $widget_args = 1 ) { |
|
328 | - if ( is_numeric( $widget_args ) ) { |
|
329 | - $widget_args = array( 'number' => $widget_args ); |
|
327 | + public function display_callback($args, $widget_args = 1) { |
|
328 | + if (is_numeric($widget_args)) { |
|
329 | + $widget_args = array('number' => $widget_args); |
|
330 | 330 | } |
331 | 331 | |
332 | - $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
|
333 | - $this->_set( $widget_args['number'] ); |
|
332 | + $widget_args = wp_parse_args($widget_args, array('number' => -1)); |
|
333 | + $this->_set($widget_args['number']); |
|
334 | 334 | $instances = $this->get_settings(); |
335 | 335 | |
336 | - if ( array_key_exists( $this->number, $instances ) ) { |
|
337 | - $instance = $instances[ $this->number ]; |
|
336 | + if (array_key_exists($this->number, $instances)) { |
|
337 | + $instance = $instances[$this->number]; |
|
338 | 338 | |
339 | 339 | /** |
340 | 340 | * Filter the settings for a particular widget instance. |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | * @param WP_Widget $this The current widget instance. |
348 | 348 | * @param array $args An array of default widget arguments. |
349 | 349 | */ |
350 | - $instance = apply_filters( 'widget_display_callback', $instance, $this, $args ); |
|
350 | + $instance = apply_filters('widget_display_callback', $instance, $this, $args); |
|
351 | 351 | |
352 | - if ( false === $instance ) { |
|
352 | + if (false === $instance) { |
|
353 | 353 | return; |
354 | 354 | } |
355 | 355 | |
356 | 356 | $was_cache_addition_suspended = wp_suspend_cache_addition(); |
357 | - if ( $this->is_preview() && ! $was_cache_addition_suspended ) { |
|
358 | - wp_suspend_cache_addition( true ); |
|
357 | + if ($this->is_preview() && ! $was_cache_addition_suspended) { |
|
358 | + wp_suspend_cache_addition(true); |
|
359 | 359 | } |
360 | 360 | |
361 | - $this->widget( $args, $instance ); |
|
361 | + $this->widget($args, $instance); |
|
362 | 362 | |
363 | - if ( $this->is_preview() ) { |
|
364 | - wp_suspend_cache_addition( $was_cache_addition_suspended ); |
|
363 | + if ($this->is_preview()) { |
|
364 | + wp_suspend_cache_addition($was_cache_addition_suspended); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | } |
@@ -376,53 +376,53 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param int $deprecated Not used. |
378 | 378 | */ |
379 | - public function update_callback( $deprecated = 1 ) { |
|
379 | + public function update_callback($deprecated = 1) { |
|
380 | 380 | global $wp_registered_widgets; |
381 | 381 | |
382 | 382 | $all_instances = $this->get_settings(); |
383 | 383 | |
384 | 384 | // We need to update the data |
385 | - if ( $this->updated ) |
|
385 | + if ($this->updated) |
|
386 | 386 | return; |
387 | 387 | |
388 | - if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { |
|
388 | + if (isset($_POST['delete_widget']) && $_POST['delete_widget']) { |
|
389 | 389 | // Delete the settings for this instance of the widget |
390 | - if ( isset($_POST['the-widget-id']) ) |
|
390 | + if (isset($_POST['the-widget-id'])) |
|
391 | 391 | $del_id = $_POST['the-widget-id']; |
392 | 392 | else |
393 | 393 | return; |
394 | 394 | |
395 | - if ( isset($wp_registered_widgets[$del_id]['params'][0]['number']) ) { |
|
395 | + if (isset($wp_registered_widgets[$del_id]['params'][0]['number'])) { |
|
396 | 396 | $number = $wp_registered_widgets[$del_id]['params'][0]['number']; |
397 | 397 | |
398 | - if ( $this->id_base . '-' . $number == $del_id ) |
|
398 | + if ($this->id_base.'-'.$number == $del_id) |
|
399 | 399 | unset($all_instances[$number]); |
400 | 400 | } |
401 | 401 | } else { |
402 | - if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) { |
|
403 | - $settings = $_POST['widget-' . $this->id_base]; |
|
404 | - } elseif ( isset($_POST['id_base']) && $_POST['id_base'] == $this->id_base ) { |
|
402 | + if (isset($_POST['widget-'.$this->id_base]) && is_array($_POST['widget-'.$this->id_base])) { |
|
403 | + $settings = $_POST['widget-'.$this->id_base]; |
|
404 | + } elseif (isset($_POST['id_base']) && $_POST['id_base'] == $this->id_base) { |
|
405 | 405 | $num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number']; |
406 | - $settings = array( $num => array() ); |
|
406 | + $settings = array($num => array()); |
|
407 | 407 | } else { |
408 | 408 | return; |
409 | 409 | } |
410 | 410 | |
411 | - foreach ( $settings as $number => $new_instance ) { |
|
411 | + foreach ($settings as $number => $new_instance) { |
|
412 | 412 | $new_instance = stripslashes_deep($new_instance); |
413 | 413 | $this->_set($number); |
414 | 414 | |
415 | 415 | $old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array(); |
416 | 416 | |
417 | 417 | $was_cache_addition_suspended = wp_suspend_cache_addition(); |
418 | - if ( $this->is_preview() && ! $was_cache_addition_suspended ) { |
|
419 | - wp_suspend_cache_addition( true ); |
|
418 | + if ($this->is_preview() && ! $was_cache_addition_suspended) { |
|
419 | + wp_suspend_cache_addition(true); |
|
420 | 420 | } |
421 | 421 | |
422 | - $instance = $this->update( $new_instance, $old_instance ); |
|
422 | + $instance = $this->update($new_instance, $old_instance); |
|
423 | 423 | |
424 | - if ( $this->is_preview() ) { |
|
425 | - wp_suspend_cache_addition( $was_cache_addition_suspended ); |
|
424 | + if ($this->is_preview()) { |
|
425 | + wp_suspend_cache_addition($was_cache_addition_suspended); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param array $old_instance Array of old widget settings. |
439 | 439 | * @param WP_Widget $this The current widget instance. |
440 | 440 | */ |
441 | - $instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this ); |
|
442 | - if ( false !== $instance ) { |
|
441 | + $instance = apply_filters('widget_update_callback', $instance, $new_instance, $old_instance, $this); |
|
442 | + if (false !== $instance) { |
|
443 | 443 | $all_instances[$number] = $instance; |
444 | 444 | } |
445 | 445 | |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | * @param int|array $widget_args Widget instance number or array of widget arguments. |
461 | 461 | * @return string|null |
462 | 462 | */ |
463 | - public function form_callback( $widget_args = 1 ) { |
|
464 | - if ( is_numeric($widget_args) ) |
|
465 | - $widget_args = array( 'number' => $widget_args ); |
|
463 | + public function form_callback($widget_args = 1) { |
|
464 | + if (is_numeric($widget_args)) |
|
465 | + $widget_args = array('number' => $widget_args); |
|
466 | 466 | |
467 | - $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
|
467 | + $widget_args = wp_parse_args($widget_args, array('number' => -1)); |
|
468 | 468 | $all_instances = $this->get_settings(); |
469 | 469 | |
470 | 470 | if ( -1 == $widget_args['number'] ) { |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $instance = array(); |
474 | 474 | } else { |
475 | 475 | $this->_set($widget_args['number']); |
476 | - $instance = $all_instances[ $widget_args['number'] ]; |
|
476 | + $instance = $all_instances[$widget_args['number']]; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | * @param array $instance The current widget instance's settings. |
487 | 487 | * @param WP_Widget $this The current widget instance. |
488 | 488 | */ |
489 | - $instance = apply_filters( 'widget_form_callback', $instance, $this ); |
|
489 | + $instance = apply_filters('widget_form_callback', $instance, $this); |
|
490 | 490 | |
491 | 491 | $return = null; |
492 | - if ( false !== $instance ) { |
|
492 | + if (false !== $instance) { |
|
493 | 493 | $return = $this->form($instance); |
494 | 494 | |
495 | 495 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @param null $return Return null if new fields are added. |
509 | 509 | * @param array $instance An array of the widget's settings. |
510 | 510 | */ |
511 | - do_action_ref_array( 'in_widget_form', array( &$this, &$return, $instance ) ); |
|
511 | + do_action_ref_array('in_widget_form', array(&$this, &$return, $instance)); |
|
512 | 512 | } |
513 | 513 | return $return; |
514 | 514 | } |
@@ -522,10 +522,10 @@ discard block |
||
522 | 522 | * @param integer $number Optional. The unique order number of this widget instance |
523 | 523 | * compared to other instances of the same class. Default -1. |
524 | 524 | */ |
525 | - public function _register_one( $number = -1 ) { |
|
526 | - wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) ); |
|
527 | - _register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) ); |
|
528 | - _register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) ); |
|
525 | + public function _register_one($number = -1) { |
|
526 | + wp_register_sidebar_widget($this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array('number' => $number)); |
|
527 | + _register_widget_update_callback($this->id_base, $this->_get_update_callback(), $this->control_options, array('number' => -1)); |
|
528 | + _register_widget_form_callback($this->id, $this->name, $this->_get_form_callback(), $this->control_options, array('number' => $number)); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @param array $settings Multi-dimensional array of widget instance settings. |
538 | 538 | */ |
539 | - public function save_settings( $settings ) { |
|
539 | + public function save_settings($settings) { |
|
540 | 540 | $settings['_multiwidget'] = 1; |
541 | - update_option( $this->option_name, $settings ); |
|
541 | + update_option($this->option_name, $settings); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -551,27 +551,27 @@ discard block |
||
551 | 551 | */ |
552 | 552 | public function get_settings() { |
553 | 553 | |
554 | - $settings = get_option( $this->option_name ); |
|
554 | + $settings = get_option($this->option_name); |
|
555 | 555 | |
556 | - if ( false === $settings ) { |
|
557 | - if ( isset( $this->alt_option_name ) ) { |
|
558 | - $settings = get_option( $this->alt_option_name ); |
|
556 | + if (false === $settings) { |
|
557 | + if (isset($this->alt_option_name)) { |
|
558 | + $settings = get_option($this->alt_option_name); |
|
559 | 559 | } else { |
560 | 560 | // Save an option so it can be autoloaded next time. |
561 | - $this->save_settings( array() ); |
|
561 | + $this->save_settings(array()); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
565 | - if ( ! is_array( $settings ) && ! ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) ) { |
|
565 | + if ( ! is_array($settings) && ! ($settings instanceof ArrayObject || $settings instanceof ArrayIterator)) { |
|
566 | 566 | $settings = array(); |
567 | 567 | } |
568 | 568 | |
569 | - if ( ! empty( $settings ) && ! isset( $settings['_multiwidget'] ) ) { |
|
569 | + if ( ! empty($settings) && ! isset($settings['_multiwidget'])) { |
|
570 | 570 | // Old format, convert if single widget. |
571 | - $settings = wp_convert_widget_settings( $this->id_base, $this->option_name, $settings ); |
|
571 | + $settings = wp_convert_widget_settings($this->id_base, $this->option_name, $settings); |
|
572 | 572 | } |
573 | 573 | |
574 | - unset( $settings['_multiwidget'], $settings['__i__'] ); |
|
574 | + unset($settings['_multiwidget'], $settings['__i__']); |
|
575 | 575 | return $settings; |
576 | 576 | } |
577 | 577 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @param array $args Display arguments. See WP_Widget::widget() for information |
335 | 335 | * on accepted arguments. |
336 | - * @param int|array $widget_args { |
|
336 | + * @param integer $widget_args { |
|
337 | 337 | * Optional. Internal order number of the widget instance, or array of multi-widget arguments. |
338 | 338 | * Default 1. |
339 | 339 | * |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @since 2.8.0 |
474 | 474 | * @access public |
475 | 475 | * |
476 | - * @param int|array $widget_args { |
|
476 | + * @param integer $widget_args { |
|
477 | 477 | * Optional. Internal order number of the widget instance, or array of multi-widget arguments. |
478 | 478 | * Default 1. |
479 | 479 | * |
@@ -498,7 +498,7 @@ |
||
498 | 498 | |
499 | 499 | /** |
500 | 500 | * Determines script dependencies. |
501 | - * |
|
501 | + * |
|
502 | 502 | * @since 2.1.0 |
503 | 503 | * @access public |
504 | 504 | * |
@@ -222,11 +222,13 @@ discard block |
||
222 | 222 | * @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise. |
223 | 223 | */ |
224 | 224 | public function print_extra_script( $handle, $echo = true ) { |
225 | - if ( !$output = $this->get_data( $handle, 'data' ) ) |
|
226 | - return; |
|
225 | + if ( !$output = $this->get_data( $handle, 'data' ) ) { |
|
226 | + return; |
|
227 | + } |
|
227 | 228 | |
228 | - if ( !$echo ) |
|
229 | - return $output; |
|
229 | + if ( !$echo ) { |
|
230 | + return $output; |
|
231 | + } |
|
230 | 232 | |
231 | 233 | echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5 |
232 | 234 | echo "/* <![CDATA[ */\n"; |
@@ -251,16 +253,18 @@ discard block |
||
251 | 253 | * @return bool True on success, false on failure. |
252 | 254 | */ |
253 | 255 | public function do_item( $handle, $group = false ) { |
254 | - if ( !parent::do_item($handle) ) |
|
255 | - return false; |
|
256 | + if ( !parent::do_item($handle) ) { |
|
257 | + return false; |
|
258 | + } |
|
256 | 259 | |
257 | 260 | if ( 0 === $group && $this->groups[$handle] > 0 ) { |
258 | 261 | $this->in_footer[] = $handle; |
259 | 262 | return false; |
260 | 263 | } |
261 | 264 | |
262 | - if ( false === $group && in_array($handle, $this->in_footer, true) ) |
|
263 | - $this->in_footer = array_diff( $this->in_footer, (array) $handle ); |
|
265 | + if ( false === $group && in_array($handle, $this->in_footer, true) ) { |
|
266 | + $this->in_footer = array_diff( $this->in_footer, (array) $handle ); |
|
267 | + } |
|
264 | 268 | |
265 | 269 | $obj = $this->registered[$handle]; |
266 | 270 | |
@@ -270,8 +274,9 @@ discard block |
||
270 | 274 | $ver = $obj->ver ? $obj->ver : $this->default_version; |
271 | 275 | } |
272 | 276 | |
273 | - if ( isset($this->args[$handle]) ) |
|
274 | - $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; |
|
277 | + if ( isset($this->args[$handle]) ) { |
|
278 | + $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; |
|
279 | + } |
|
275 | 280 | |
276 | 281 | $src = $obj->src; |
277 | 282 | $cond_before = $cond_after = ''; |
@@ -340,14 +345,16 @@ discard block |
||
340 | 345 | $src = $this->base_url . $src; |
341 | 346 | } |
342 | 347 | |
343 | - if ( ! empty( $ver ) ) |
|
344 | - $src = add_query_arg( 'ver', $ver, $src ); |
|
348 | + if ( ! empty( $ver ) ) { |
|
349 | + $src = add_query_arg( 'ver', $ver, $src ); |
|
350 | + } |
|
345 | 351 | |
346 | 352 | /** This filter is documented in wp-includes/class.wp-scripts.php */ |
347 | 353 | $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); |
348 | 354 | |
349 | - if ( ! $src ) |
|
350 | - return true; |
|
355 | + if ( ! $src ) { |
|
356 | + return true; |
|
357 | + } |
|
351 | 358 | |
352 | 359 | $tag = "{$cond_before}{$before_handle}<script type='text/javascript' src='$src'></script>\n{$after_handle}{$cond_after}"; |
353 | 360 | |
@@ -443,8 +450,9 @@ discard block |
||
443 | 450 | * @return bool |
444 | 451 | */ |
445 | 452 | public function localize( $handle, $object_name, $l10n ) { |
446 | - if ( $handle === 'jquery' ) |
|
447 | - $handle = 'jquery-core'; |
|
453 | + if ( $handle === 'jquery' ) { |
|
454 | + $handle = 'jquery-core'; |
|
455 | + } |
|
448 | 456 | |
449 | 457 | if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present |
450 | 458 | $after = $l10n['l10n_print_after']; |
@@ -452,21 +460,24 @@ discard block |
||
452 | 460 | } |
453 | 461 | |
454 | 462 | foreach ( (array) $l10n as $key => $value ) { |
455 | - if ( !is_scalar($value) ) |
|
456 | - continue; |
|
463 | + if ( !is_scalar($value) ) { |
|
464 | + continue; |
|
465 | + } |
|
457 | 466 | |
458 | 467 | $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8'); |
459 | 468 | } |
460 | 469 | |
461 | 470 | $script = "var $object_name = " . wp_json_encode( $l10n ) . ';'; |
462 | 471 | |
463 | - if ( !empty($after) ) |
|
464 | - $script .= "\n$after;"; |
|
472 | + if ( !empty($after) ) { |
|
473 | + $script .= "\n$after;"; |
|
474 | + } |
|
465 | 475 | |
466 | 476 | $data = $this->get_data( $handle, 'data' ); |
467 | 477 | |
468 | - if ( !empty( $data ) ) |
|
469 | - $script = "$data\n$script"; |
|
478 | + if ( !empty( $data ) ) { |
|
479 | + $script = "$data\n$script"; |
|
480 | + } |
|
470 | 481 | |
471 | 482 | return $this->add_data( $handle, 'data', $script ); |
472 | 483 | } |
@@ -485,13 +496,15 @@ discard block |
||
485 | 496 | * @return bool Not already in the group or a lower group |
486 | 497 | */ |
487 | 498 | public function set_group( $handle, $recursion, $group = false ) { |
488 | - if ( isset( $this->registered[$handle]->args ) && $this->registered[$handle]->args === 1 ) |
|
489 | - $grp = 1; |
|
490 | - else |
|
491 | - $grp = (int) $this->get_data( $handle, 'group' ); |
|
499 | + if ( isset( $this->registered[$handle]->args ) && $this->registered[$handle]->args === 1 ) { |
|
500 | + $grp = 1; |
|
501 | + } else { |
|
502 | + $grp = (int) $this->get_data( $handle, 'group' ); |
|
503 | + } |
|
492 | 504 | |
493 | - if ( false !== $group && $grp > $group ) |
|
494 | - $grp = $group; |
|
505 | + if ( false !== $group && $grp > $group ) { |
|
506 | + $grp = $group; |
|
507 | + } |
|
495 | 508 | |
496 | 509 | return parent::set_group( $handle, $recursion, $grp ); |
497 | 510 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function __construct() { |
144 | 144 | $this->init(); |
145 | - add_action( 'init', array( $this, 'init' ), 0 ); |
|
145 | + add_action('init', array($this, 'init'), 0); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @param WP_Scripts &$this WP_Scripts instance, passed by reference. |
161 | 161 | */ |
162 | - do_action_ref_array( 'wp_default_scripts', array(&$this) ); |
|
162 | + do_action_ref_array('wp_default_scripts', array(&$this)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * Default false. |
178 | 178 | * @return array Scripts that have been printed. |
179 | 179 | */ |
180 | - public function print_scripts( $handles = false, $group = false ) { |
|
181 | - return $this->do_items( $handles, $group ); |
|
180 | + public function print_scripts($handles = false, $group = false) { |
|
181 | + return $this->do_items($handles, $group); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * Default true. |
197 | 197 | * @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise. |
198 | 198 | */ |
199 | - public function print_scripts_l10n( $handle, $echo = true ) { |
|
200 | - _deprecated_function( __FUNCTION__, '3.3.0', 'print_extra_script()' ); |
|
201 | - return $this->print_extra_script( $handle, $echo ); |
|
199 | + public function print_scripts_l10n($handle, $echo = true) { |
|
200 | + _deprecated_function(__FUNCTION__, '3.3.0', 'print_extra_script()'); |
|
201 | + return $this->print_extra_script($handle, $echo); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | * Default true. |
213 | 213 | * @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise. |
214 | 214 | */ |
215 | - public function print_extra_script( $handle, $echo = true ) { |
|
216 | - if ( !$output = $this->get_data( $handle, 'data' ) ) |
|
215 | + public function print_extra_script($handle, $echo = true) { |
|
216 | + if ( ! $output = $this->get_data($handle, 'data')) |
|
217 | 217 | return; |
218 | 218 | |
219 | - if ( !$echo ) |
|
219 | + if ( ! $echo) |
|
220 | 220 | return $output; |
221 | 221 | |
222 | 222 | echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5 |
@@ -241,50 +241,50 @@ discard block |
||
241 | 241 | * @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false. |
242 | 242 | * @return bool True on success, false on failure. |
243 | 243 | */ |
244 | - public function do_item( $handle, $group = false ) { |
|
245 | - if ( !parent::do_item($handle) ) |
|
244 | + public function do_item($handle, $group = false) { |
|
245 | + if ( ! parent::do_item($handle)) |
|
246 | 246 | return false; |
247 | 247 | |
248 | - if ( 0 === $group && $this->groups[$handle] > 0 ) { |
|
248 | + if (0 === $group && $this->groups[$handle] > 0) { |
|
249 | 249 | $this->in_footer[] = $handle; |
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | |
253 | - if ( false === $group && in_array($handle, $this->in_footer, true) ) |
|
254 | - $this->in_footer = array_diff( $this->in_footer, (array) $handle ); |
|
253 | + if (false === $group && in_array($handle, $this->in_footer, true)) |
|
254 | + $this->in_footer = array_diff($this->in_footer, (array) $handle); |
|
255 | 255 | |
256 | 256 | $obj = $this->registered[$handle]; |
257 | 257 | |
258 | - if ( null === $obj->ver ) { |
|
258 | + if (null === $obj->ver) { |
|
259 | 259 | $ver = ''; |
260 | 260 | } else { |
261 | 261 | $ver = $obj->ver ? $obj->ver : $this->default_version; |
262 | 262 | } |
263 | 263 | |
264 | - if ( isset($this->args[$handle]) ) |
|
265 | - $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; |
|
264 | + if (isset($this->args[$handle])) |
|
265 | + $ver = $ver ? $ver.'&'.$this->args[$handle] : $this->args[$handle]; |
|
266 | 266 | |
267 | 267 | $src = $obj->src; |
268 | 268 | $cond_before = $cond_after = ''; |
269 | - $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : ''; |
|
269 | + $conditional = isset($obj->extra['conditional']) ? $obj->extra['conditional'] : ''; |
|
270 | 270 | |
271 | - if ( $conditional ) { |
|
271 | + if ($conditional) { |
|
272 | 272 | $cond_before = "<!--[if {$conditional}]>\n"; |
273 | 273 | $cond_after = "<![endif]-->\n"; |
274 | 274 | } |
275 | 275 | |
276 | - $before_handle = $this->print_inline_script( $handle, 'before', false ); |
|
277 | - $after_handle = $this->print_inline_script( $handle, 'after', false ); |
|
276 | + $before_handle = $this->print_inline_script($handle, 'before', false); |
|
277 | + $after_handle = $this->print_inline_script($handle, 'after', false); |
|
278 | 278 | |
279 | - if ( $before_handle ) { |
|
280 | - $before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle ); |
|
279 | + if ($before_handle) { |
|
280 | + $before_handle = sprintf("<script type='text/javascript'>\n%s\n</script>\n", $before_handle); |
|
281 | 281 | } |
282 | 282 | |
283 | - if ( $after_handle ) { |
|
284 | - $after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle ); |
|
283 | + if ($after_handle) { |
|
284 | + $after_handle = sprintf("<script type='text/javascript'>\n%s\n</script>\n", $after_handle); |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( $this->do_concat ) { |
|
287 | + if ($this->do_concat) { |
|
288 | 288 | /** |
289 | 289 | * Filters the script loader source. |
290 | 290 | * |
@@ -293,16 +293,16 @@ discard block |
||
293 | 293 | * @param string $src Script loader source path. |
294 | 294 | * @param string $handle Script handle. |
295 | 295 | */ |
296 | - $srce = apply_filters( 'script_loader_src', $src, $handle ); |
|
296 | + $srce = apply_filters('script_loader_src', $src, $handle); |
|
297 | 297 | |
298 | - if ( $this->in_default_dir( $srce ) && ( $before_handle || $after_handle ) ) { |
|
298 | + if ($this->in_default_dir($srce) && ($before_handle || $after_handle)) { |
|
299 | 299 | $this->do_concat = false; |
300 | 300 | |
301 | 301 | // Have to print the so-far concatenated scripts right away to maintain the right order. |
302 | 302 | _print_scripts(); |
303 | 303 | $this->reset(); |
304 | - } elseif ( $this->in_default_dir( $srce ) && ! $conditional ) { |
|
305 | - $this->print_code .= $this->print_extra_script( $handle, false ); |
|
304 | + } elseif ($this->in_default_dir($srce) && ! $conditional) { |
|
305 | + $this->print_code .= $this->print_extra_script($handle, false); |
|
306 | 306 | $this->concat .= "$handle,"; |
307 | 307 | $this->concat_version .= "$handle$ver"; |
308 | 308 | return true; |
@@ -312,34 +312,34 @@ discard block |
||
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | - $has_conditional_data = $conditional && $this->get_data( $handle, 'data' ); |
|
315 | + $has_conditional_data = $conditional && $this->get_data($handle, 'data'); |
|
316 | 316 | |
317 | - if ( $has_conditional_data ) { |
|
317 | + if ($has_conditional_data) { |
|
318 | 318 | echo $cond_before; |
319 | 319 | } |
320 | 320 | |
321 | - $this->print_extra_script( $handle ); |
|
321 | + $this->print_extra_script($handle); |
|
322 | 322 | |
323 | - if ( $has_conditional_data ) { |
|
323 | + if ($has_conditional_data) { |
|
324 | 324 | echo $cond_after; |
325 | 325 | } |
326 | 326 | |
327 | 327 | // A single item may alias a set of items, by having dependencies, but no source. |
328 | - if ( ! $obj->src ) { |
|
328 | + if ( ! $obj->src) { |
|
329 | 329 | return true; |
330 | 330 | } |
331 | 331 | |
332 | - if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) { |
|
333 | - $src = $this->base_url . $src; |
|
332 | + if ( ! preg_match('|^(https?:)?//|', $src) && ! ($this->content_url && 0 === strpos($src, $this->content_url))) { |
|
333 | + $src = $this->base_url.$src; |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( ! empty( $ver ) ) |
|
337 | - $src = add_query_arg( 'ver', $ver, $src ); |
|
336 | + if ( ! empty($ver)) |
|
337 | + $src = add_query_arg('ver', $ver, $src); |
|
338 | 338 | |
339 | 339 | /** This filter is documented in wp-includes/class.wp-scripts.php */ |
340 | - $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); |
|
340 | + $src = esc_url(apply_filters('script_loader_src', $src, $handle)); |
|
341 | 341 | |
342 | - if ( ! $src ) |
|
342 | + if ( ! $src) |
|
343 | 343 | return true; |
344 | 344 | |
345 | 345 | $tag = "{$cond_before}{$before_handle}<script type='text/javascript' src='$src'></script>\n{$after_handle}{$cond_after}"; |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | * @param string $handle The script's registered handle. |
354 | 354 | * @param string $src The script's source URL. |
355 | 355 | */ |
356 | - $tag = apply_filters( 'script_loader_tag', $tag, $handle, $src ); |
|
356 | + $tag = apply_filters('script_loader_tag', $tag, $handle, $src); |
|
357 | 357 | |
358 | - if ( $this->do_concat ) { |
|
358 | + if ($this->do_concat) { |
|
359 | 359 | $this->print_html .= $tag; |
360 | 360 | } else { |
361 | 361 | echo $tag; |
@@ -376,19 +376,19 @@ discard block |
||
376 | 376 | * or after. Default 'after'. |
377 | 377 | * @return bool True on success, false on failure. |
378 | 378 | */ |
379 | - public function add_inline_script( $handle, $data, $position = 'after' ) { |
|
380 | - if ( ! $data ) { |
|
379 | + public function add_inline_script($handle, $data, $position = 'after') { |
|
380 | + if ( ! $data) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
384 | - if ( 'after' !== $position ) { |
|
384 | + if ('after' !== $position) { |
|
385 | 385 | $position = 'before'; |
386 | 386 | } |
387 | 387 | |
388 | - $script = (array) $this->get_data( $handle, $position ); |
|
388 | + $script = (array) $this->get_data($handle, $position); |
|
389 | 389 | $script[] = $data; |
390 | 390 | |
391 | - return $this->add_data( $handle, $position, $script ); |
|
391 | + return $this->add_data($handle, $position, $script); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -404,17 +404,17 @@ discard block |
||
404 | 404 | * Default true. |
405 | 405 | * @return string|false Script on success, false otherwise. |
406 | 406 | */ |
407 | - public function print_inline_script( $handle, $position = 'after', $echo = true ) { |
|
408 | - $output = $this->get_data( $handle, $position ); |
|
407 | + public function print_inline_script($handle, $position = 'after', $echo = true) { |
|
408 | + $output = $this->get_data($handle, $position); |
|
409 | 409 | |
410 | - if ( empty( $output ) ) { |
|
410 | + if (empty($output)) { |
|
411 | 411 | return false; |
412 | 412 | } |
413 | 413 | |
414 | - $output = trim( implode( "\n", $output ), "\n" ); |
|
414 | + $output = trim(implode("\n", $output), "\n"); |
|
415 | 415 | |
416 | - if ( $echo ) { |
|
417 | - printf( "<script type='text/javascript'>\n%s\n</script>\n", $output ); |
|
416 | + if ($echo) { |
|
417 | + printf("<script type='text/javascript'>\n%s\n</script>\n", $output); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | return $output; |
@@ -431,33 +431,33 @@ discard block |
||
431 | 431 | * @param array $l10n |
432 | 432 | * @return bool |
433 | 433 | */ |
434 | - public function localize( $handle, $object_name, $l10n ) { |
|
435 | - if ( $handle === 'jquery' ) |
|
434 | + public function localize($handle, $object_name, $l10n) { |
|
435 | + if ($handle === 'jquery') |
|
436 | 436 | $handle = 'jquery-core'; |
437 | 437 | |
438 | - if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present |
|
438 | + if (is_array($l10n) && isset($l10n['l10n_print_after'])) { // back compat, preserve the code in 'l10n_print_after' if present |
|
439 | 439 | $after = $l10n['l10n_print_after']; |
440 | 440 | unset($l10n['l10n_print_after']); |
441 | 441 | } |
442 | 442 | |
443 | - foreach ( (array) $l10n as $key => $value ) { |
|
444 | - if ( !is_scalar($value) ) |
|
443 | + foreach ((array) $l10n as $key => $value) { |
|
444 | + if ( ! is_scalar($value)) |
|
445 | 445 | continue; |
446 | 446 | |
447 | - $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8'); |
|
447 | + $l10n[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
448 | 448 | } |
449 | 449 | |
450 | - $script = "var $object_name = " . wp_json_encode( $l10n ) . ';'; |
|
450 | + $script = "var $object_name = ".wp_json_encode($l10n).';'; |
|
451 | 451 | |
452 | - if ( !empty($after) ) |
|
452 | + if ( ! empty($after)) |
|
453 | 453 | $script .= "\n$after;"; |
454 | 454 | |
455 | - $data = $this->get_data( $handle, 'data' ); |
|
455 | + $data = $this->get_data($handle, 'data'); |
|
456 | 456 | |
457 | - if ( !empty( $data ) ) |
|
457 | + if ( ! empty($data)) |
|
458 | 458 | $script = "$data\n$script"; |
459 | 459 | |
460 | - return $this->add_data( $handle, 'data', $script ); |
|
460 | + return $this->add_data($handle, 'data', $script); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -473,16 +473,16 @@ discard block |
||
473 | 473 | * @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false. |
474 | 474 | * @return bool Not already in the group or a lower group |
475 | 475 | */ |
476 | - public function set_group( $handle, $recursion, $group = false ) { |
|
477 | - if ( isset( $this->registered[$handle]->args ) && $this->registered[$handle]->args === 1 ) |
|
476 | + public function set_group($handle, $recursion, $group = false) { |
|
477 | + if (isset($this->registered[$handle]->args) && $this->registered[$handle]->args === 1) |
|
478 | 478 | $grp = 1; |
479 | 479 | else |
480 | - $grp = (int) $this->get_data( $handle, 'group' ); |
|
480 | + $grp = (int) $this->get_data($handle, 'group'); |
|
481 | 481 | |
482 | - if ( false !== $group && $grp > $group ) |
|
482 | + if (false !== $group && $grp > $group) |
|
483 | 483 | $grp = $group; |
484 | 484 | |
485 | - return parent::set_group( $handle, $recursion, $grp ); |
|
485 | + return parent::set_group($handle, $recursion, $grp); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false. |
499 | 499 | * @return bool True on success, false on failure. |
500 | 500 | */ |
501 | - public function all_deps( $handles, $recursion = false, $group = false ) { |
|
502 | - $r = parent::all_deps( $handles, $recursion, $group ); |
|
503 | - if ( ! $recursion ) { |
|
501 | + public function all_deps($handles, $recursion = false, $group = false) { |
|
502 | + $r = parent::all_deps($handles, $recursion, $group); |
|
503 | + if ( ! $recursion) { |
|
504 | 504 | /** |
505 | 505 | * Filters the list of script dependencies left to print. |
506 | 506 | * |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @param array $to_do An array of script dependencies. |
510 | 510 | */ |
511 | - $this->to_do = apply_filters( 'print_scripts_array', $this->to_do ); |
|
511 | + $this->to_do = apply_filters('print_scripts_array', $this->to_do); |
|
512 | 512 | } |
513 | 513 | return $r; |
514 | 514 | } |
@@ -552,17 +552,17 @@ discard block |
||
552 | 552 | * @param string $src The source of the enqueued script. |
553 | 553 | * @return bool True if found, false if not. |
554 | 554 | */ |
555 | - public function in_default_dir( $src ) { |
|
556 | - if ( ! $this->default_dirs ) { |
|
555 | + public function in_default_dir($src) { |
|
556 | + if ( ! $this->default_dirs) { |
|
557 | 557 | return true; |
558 | 558 | } |
559 | 559 | |
560 | - if ( 0 === strpos( $src, '/' . WPINC . '/js/l10n' ) ) { |
|
560 | + if (0 === strpos($src, '/'.WPINC.'/js/l10n')) { |
|
561 | 561 | return false; |
562 | 562 | } |
563 | 563 | |
564 | - foreach ( (array) $this->default_dirs as $test ) { |
|
565 | - if ( 0 === strpos( $src, $test ) ) { |
|
564 | + foreach ((array) $this->default_dirs as $test) { |
|
565 | + if (0 === strpos($src, $test)) { |
|
566 | 566 | return true; |
567 | 567 | } |
568 | 568 | } |
@@ -61,11 +61,13 @@ |
||
61 | 61 | * @return array Default embed parameters. |
62 | 62 | */ |
63 | 63 | function wp_embed_defaults( $url = '' ) { |
64 | - if ( ! empty( $GLOBALS['content_width'] ) ) |
|
65 | - $width = (int) $GLOBALS['content_width']; |
|
64 | + if ( ! empty( $GLOBALS['content_width'] ) ) { |
|
65 | + $width = (int) $GLOBALS['content_width']; |
|
66 | + } |
|
66 | 67 | |
67 | - if ( empty( $width ) ) |
|
68 | - $width = 500; |
|
68 | + if ( empty( $width ) ) { |
|
69 | + $width = 500; |
|
70 | + } |
|
69 | 71 | |
70 | 72 | $height = min( ceil( $width * 1.5 ), 1000 ); |
71 | 73 |
@@ -481,7 +481,7 @@ |
||
481 | 481 | * |
482 | 482 | * @param WP_Post|int $post Post object or ID. |
483 | 483 | * @param int $width The requested width. |
484 | - * @return array|false Response data on success, false if post doesn't exist. |
|
484 | + * @return string Response data on success, false if post doesn't exist. |
|
485 | 485 | */ |
486 | 486 | function get_oembed_response_data( $post, $width ) { |
487 | 487 | $post = get_post( $post ); |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param int $priority Optional. Used to specify the order in which the registered handlers will |
23 | 23 | * be tested. Default 10. |
24 | 24 | */ |
25 | -function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) { |
|
25 | +function wp_embed_register_handler($id, $regex, $callback, $priority = 10) { |
|
26 | 26 | global $wp_embed; |
27 | - $wp_embed->register_handler( $id, $regex, $callback, $priority ); |
|
27 | + $wp_embed->register_handler($id, $regex, $callback, $priority); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * @param string $id The handler ID that should be removed. |
38 | 38 | * @param int $priority Optional. The priority of the handler to be removed. Default 10. |
39 | 39 | */ |
40 | -function wp_embed_unregister_handler( $id, $priority = 10 ) { |
|
40 | +function wp_embed_unregister_handler($id, $priority = 10) { |
|
41 | 41 | global $wp_embed; |
42 | - $wp_embed->unregister_handler( $id, $priority ); |
|
42 | + $wp_embed->unregister_handler($id, $priority); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return array Default embed parameters. |
62 | 62 | */ |
63 | -function wp_embed_defaults( $url = '' ) { |
|
64 | - if ( ! empty( $GLOBALS['content_width'] ) ) |
|
63 | +function wp_embed_defaults($url = '') { |
|
64 | + if ( ! empty($GLOBALS['content_width'])) |
|
65 | 65 | $width = (int) $GLOBALS['content_width']; |
66 | 66 | |
67 | - if ( empty( $width ) ) |
|
67 | + if (empty($width)) |
|
68 | 68 | $width = 500; |
69 | 69 | |
70 | - $height = min( ceil( $width * 1.5 ), 1000 ); |
|
70 | + $height = min(ceil($width * 1.5), 1000); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Filters the default array of embed dimensions. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * in pixels (in that order). |
79 | 79 | * @param string $url The URL that should be embedded. |
80 | 80 | */ |
81 | - return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url ); |
|
81 | + return apply_filters('embed_defaults', compact('width', 'height'), $url); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * Default empty. |
94 | 94 | * @return false|string False on failure or the embed HTML on success. |
95 | 95 | */ |
96 | -function wp_oembed_get( $url, $args = '' ) { |
|
96 | +function wp_oembed_get($url, $args = '') { |
|
97 | 97 | $oembed = _wp_oembed_get_object(); |
98 | - return $oembed->get_html( $url, $args ); |
|
98 | + return $oembed->get_html($url, $args); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | function _wp_oembed_get_object() { |
112 | 112 | static $wp_oembed = null; |
113 | 113 | |
114 | - if ( is_null( $wp_oembed ) ) { |
|
114 | + if (is_null($wp_oembed)) { |
|
115 | 115 | $wp_oembed = new WP_oEmbed(); |
116 | 116 | } |
117 | 117 | return $wp_oembed; |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | * @param string $provider The URL to the oEmbed provider. |
130 | 130 | * @param boolean $regex Optional. Whether the `$format` parameter is in a RegEx format. Default false. |
131 | 131 | */ |
132 | -function wp_oembed_add_provider( $format, $provider, $regex = false ) { |
|
133 | - if ( did_action( 'plugins_loaded' ) ) { |
|
132 | +function wp_oembed_add_provider($format, $provider, $regex = false) { |
|
133 | + if (did_action('plugins_loaded')) { |
|
134 | 134 | $oembed = _wp_oembed_get_object(); |
135 | - $oembed->providers[$format] = array( $provider, $regex ); |
|
135 | + $oembed->providers[$format] = array($provider, $regex); |
|
136 | 136 | } else { |
137 | - WP_oEmbed::_add_provider_early( $format, $provider, $regex ); |
|
137 | + WP_oEmbed::_add_provider_early($format, $provider, $regex); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | * @param string $format The URL format for the oEmbed provider to remove. |
149 | 149 | * @return bool Was the provider removed successfully? |
150 | 150 | */ |
151 | -function wp_oembed_remove_provider( $format ) { |
|
152 | - if ( did_action( 'plugins_loaded' ) ) { |
|
151 | +function wp_oembed_remove_provider($format) { |
|
152 | + if (did_action('plugins_loaded')) { |
|
153 | 153 | $oembed = _wp_oembed_get_object(); |
154 | 154 | |
155 | - if ( isset( $oembed->providers[ $format ] ) ) { |
|
156 | - unset( $oembed->providers[ $format ] ); |
|
155 | + if (isset($oembed->providers[$format])) { |
|
156 | + unset($oembed->providers[$format]); |
|
157 | 157 | return true; |
158 | 158 | } |
159 | 159 | } else { |
160 | - WP_oEmbed::_remove_provider_early( $format ); |
|
160 | + WP_oEmbed::_remove_provider_early($format); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return false; |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param bool $maybe_load_embeds Whether to load the embeds library. Default true. |
185 | 185 | */ |
186 | - if ( ! apply_filters( 'load_default_embeds', true ) ) { |
|
186 | + if ( ! apply_filters('load_default_embeds', true)) { |
|
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
190 | - wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' ); |
|
190 | + wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube'); |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Filters the audio embed handler callback. |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @param callable $handler Audio embed handler callback function. |
198 | 198 | */ |
199 | - wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 ); |
|
199 | + wp_embed_register_handler('audio', '#^https?://.+?\.('.join('|', wp_get_audio_extensions()).')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Filters the video embed handler callback. |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @param callable $handler Video embed handler callback function. |
207 | 207 | */ |
208 | - wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 ); |
|
208 | + wp_embed_register_handler('video', '#^https?://.+?\.('.join('|', wp_get_video_extensions()).')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * @param array $rawattr The original unmodified attributes. |
225 | 225 | * @return string The embed HTML. |
226 | 226 | */ |
227 | -function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { |
|
227 | +function wp_embed_handler_youtube($matches, $attr, $url, $rawattr) { |
|
228 | 228 | global $wp_embed; |
229 | - $embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" ); |
|
229 | + $embed = $wp_embed->autoembed("https://youtube.com/watch?v={$matches[2]}"); |
|
230 | 230 | |
231 | 231 | /** |
232 | 232 | * Filters the YoutTube embed output. |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param string $url The original URL that was matched by the regex. |
241 | 241 | * @param array $rawattr The original unmodified attributes. |
242 | 242 | */ |
243 | - return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr ); |
|
243 | + return apply_filters('wp_embed_handler_youtube', $embed, $attr, $url, $rawattr); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | * @param array $rawattr The original unmodified attributes. |
255 | 255 | * @return string The embed HTML. |
256 | 256 | */ |
257 | -function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { |
|
258 | - $audio = sprintf( '[audio src="%s" /]', esc_url( $url ) ); |
|
257 | +function wp_embed_handler_audio($matches, $attr, $url, $rawattr) { |
|
258 | + $audio = sprintf('[audio src="%s" /]', esc_url($url)); |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Filters the audio embed output. |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param string $url The original URL that was matched by the regex. |
268 | 268 | * @param array $rawattr The original unmodified attributes. |
269 | 269 | */ |
270 | - return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr ); |
|
270 | + return apply_filters('wp_embed_handler_audio', $audio, $attr, $url, $rawattr); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | * @param array $rawattr The original unmodified attributes. |
282 | 282 | * @return string The embed HTML. |
283 | 283 | */ |
284 | -function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { |
|
284 | +function wp_embed_handler_video($matches, $attr, $url, $rawattr) { |
|
285 | 285 | $dimensions = ''; |
286 | - if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { |
|
287 | - $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); |
|
288 | - $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); |
|
286 | + if ( ! empty($rawattr['width']) && ! empty($rawattr['height'])) { |
|
287 | + $dimensions .= sprintf('width="%d" ', (int) $rawattr['width']); |
|
288 | + $dimensions .= sprintf('height="%d" ', (int) $rawattr['height']); |
|
289 | 289 | } |
290 | - $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); |
|
290 | + $video = sprintf('[video %s src="%s" /]', $dimensions, esc_url($url)); |
|
291 | 291 | |
292 | 292 | /** |
293 | 293 | * Filters the video embed output. |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param string $url The original URL that was matched by the regex. |
300 | 300 | * @param array $rawattr The original unmodified attributes. |
301 | 301 | */ |
302 | - return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr ); |
|
302 | + return apply_filters('wp_embed_handler_video', $video, $attr, $url, $rawattr); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | function wp_oembed_add_discovery_links() { |
321 | 321 | $output = ''; |
322 | 322 | |
323 | - if ( is_singular() ) { |
|
324 | - $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n"; |
|
323 | + if (is_singular()) { |
|
324 | + $output .= '<link rel="alternate" type="application/json+oembed" href="'.esc_url(get_oembed_endpoint_url(get_permalink())).'" />'."\n"; |
|
325 | 325 | |
326 | - if ( class_exists( 'SimpleXMLElement' ) ) { |
|
327 | - $output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n"; |
|
326 | + if (class_exists('SimpleXMLElement')) { |
|
327 | + $output .= '<link rel="alternate" type="text/xml+oembed" href="'.esc_url(get_oembed_endpoint_url(get_permalink(), 'xml')).'" />'."\n"; |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @param string $output HTML of the discovery links. |
337 | 337 | */ |
338 | - echo apply_filters( 'oembed_discovery_links', $output ); |
|
338 | + echo apply_filters('oembed_discovery_links', $output); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @since 4.4.0 |
345 | 345 | */ |
346 | 346 | function wp_oembed_add_host_js() { |
347 | - wp_enqueue_script( 'wp-embed' ); |
|
347 | + wp_enqueue_script('wp-embed'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -355,18 +355,18 @@ discard block |
||
355 | 355 | * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post. |
356 | 356 | * @return string|false The post embed URL on success, false if the post doesn't exist. |
357 | 357 | */ |
358 | -function get_post_embed_url( $post = null ) { |
|
359 | - $post = get_post( $post ); |
|
358 | +function get_post_embed_url($post = null) { |
|
359 | + $post = get_post($post); |
|
360 | 360 | |
361 | - if ( ! $post ) { |
|
361 | + if ( ! $post) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | |
365 | - $embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' ); |
|
366 | - $path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) ); |
|
365 | + $embed_url = trailingslashit(get_permalink($post)).user_trailingslashit('embed'); |
|
366 | + $path_conflict = get_page_by_path(str_replace(home_url(), '', $embed_url), OBJECT, get_post_types(array('public' => true))); |
|
367 | 367 | |
368 | - if ( ! get_option( 'permalink_structure' ) || $path_conflict ) { |
|
369 | - $embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) ); |
|
368 | + if ( ! get_option('permalink_structure') || $path_conflict) { |
|
369 | + $embed_url = add_query_arg(array('embed' => 'true'), get_permalink($post)); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @param string $embed_url The post embed URL. |
378 | 378 | * @param WP_Post $post The corresponding post object. |
379 | 379 | */ |
380 | - return esc_url_raw( apply_filters( 'post_embed_url', $embed_url, $post ) ); |
|
380 | + return esc_url_raw(apply_filters('post_embed_url', $embed_url, $post)); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | * @param string $format Optional. The requested response format. Default 'json'. |
392 | 392 | * @return string The oEmbed endpoint URL. |
393 | 393 | */ |
394 | -function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) { |
|
395 | - $url = rest_url( 'oembed/1.0/embed' ); |
|
396 | - |
|
397 | - if ( '' !== $permalink ) { |
|
398 | - $url = add_query_arg( array( |
|
399 | - 'url' => urlencode( $permalink ), |
|
400 | - 'format' => ( 'json' !== $format ) ? $format : false, |
|
401 | - ), $url ); |
|
394 | +function get_oembed_endpoint_url($permalink = '', $format = 'json') { |
|
395 | + $url = rest_url('oembed/1.0/embed'); |
|
396 | + |
|
397 | + if ('' !== $permalink) { |
|
398 | + $url = add_query_arg(array( |
|
399 | + 'url' => urlencode($permalink), |
|
400 | + 'format' => ('json' !== $format) ? $format : false, |
|
401 | + ), $url); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param string $permalink The permalink used for the `url` query arg. |
411 | 411 | * @param string $format The requested response format. |
412 | 412 | */ |
413 | - return apply_filters( 'oembed_endpoint_url', $url, $permalink, $format ); |
|
413 | + return apply_filters('oembed_endpoint_url', $url, $permalink, $format); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -423,21 +423,21 @@ discard block |
||
423 | 423 | * @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`. |
424 | 424 | * @return string|false Embed code on success, false if post doesn't exist. |
425 | 425 | */ |
426 | -function get_post_embed_html( $width, $height, $post = null ) { |
|
427 | - $post = get_post( $post ); |
|
426 | +function get_post_embed_html($width, $height, $post = null) { |
|
427 | + $post = get_post($post); |
|
428 | 428 | |
429 | - if ( ! $post ) { |
|
429 | + if ( ! $post) { |
|
430 | 430 | return false; |
431 | 431 | } |
432 | 432 | |
433 | - $embed_url = get_post_embed_url( $post ); |
|
433 | + $embed_url = get_post_embed_url($post); |
|
434 | 434 | |
435 | - $output = '<blockquote class="wp-embedded-content"><a href="' . esc_url( get_permalink( $post ) ) . '">' . get_the_title( $post ) . "</a></blockquote>\n"; |
|
435 | + $output = '<blockquote class="wp-embedded-content"><a href="'.esc_url(get_permalink($post)).'">'.get_the_title($post)."</a></blockquote>\n"; |
|
436 | 436 | |
437 | 437 | $output .= "<script type='text/javascript'>\n"; |
438 | 438 | $output .= "<!--//--><![CDATA[//><!--\n"; |
439 | - if ( SCRIPT_DEBUG ) { |
|
440 | - $output .= file_get_contents( ABSPATH . WPINC . '/js/wp-embed.js' ); |
|
439 | + if (SCRIPT_DEBUG) { |
|
440 | + $output .= file_get_contents(ABSPATH.WPINC.'/js/wp-embed.js'); |
|
441 | 441 | } else { |
442 | 442 | /* |
443 | 443 | * If you're looking at a src version of this file, you'll see an "include" |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG |
450 | 450 | * and edit wp-embed.js directly. |
451 | 451 | */ |
452 | - $output .=<<<JS |
|
452 | + $output .= <<<JS |
|
453 | 453 | include "js/wp-embed.min.js" |
454 | 454 | JS; |
455 | 455 | } |
@@ -458,15 +458,15 @@ discard block |
||
458 | 458 | |
459 | 459 | $output .= sprintf( |
460 | 460 | '<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>', |
461 | - esc_url( $embed_url ), |
|
462 | - absint( $width ), |
|
463 | - absint( $height ), |
|
461 | + esc_url($embed_url), |
|
462 | + absint($width), |
|
463 | + absint($height), |
|
464 | 464 | esc_attr( |
465 | 465 | sprintf( |
466 | 466 | /* translators: 1: post title, 2: site name */ |
467 | - __( '“%1$s” — %2$s' ), |
|
468 | - get_the_title( $post ), |
|
469 | - get_bloginfo( 'name' ) |
|
467 | + __('“%1$s” — %2$s'), |
|
468 | + get_the_title($post), |
|
469 | + get_bloginfo('name') |
|
470 | 470 | ) |
471 | 471 | ) |
472 | 472 | ); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | * @param int $width Width of the response. |
482 | 482 | * @param int $height Height of the response. |
483 | 483 | */ |
484 | - return apply_filters( 'embed_html', $output, $post, $width, $height ); |
|
484 | + return apply_filters('embed_html', $output, $post, $width, $height); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -493,15 +493,15 @@ discard block |
||
493 | 493 | * @param int $width The requested width. |
494 | 494 | * @return array|false Response data on success, false if post doesn't exist. |
495 | 495 | */ |
496 | -function get_oembed_response_data( $post, $width ) { |
|
497 | - $post = get_post( $post ); |
|
498 | - $width = absint( $width ); |
|
496 | +function get_oembed_response_data($post, $width) { |
|
497 | + $post = get_post($post); |
|
498 | + $width = absint($width); |
|
499 | 499 | |
500 | - if ( ! $post ) { |
|
500 | + if ( ! $post) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
504 | - if ( 'publish' !== get_post_status( $post ) ) { |
|
504 | + if ('publish' !== get_post_status($post)) { |
|
505 | 505 | return false; |
506 | 506 | } |
507 | 507 | |
@@ -517,29 +517,29 @@ discard block |
||
517 | 517 | * @type int $max Maximum width. Default 600. |
518 | 518 | * } |
519 | 519 | */ |
520 | - $min_max_width = apply_filters( 'oembed_min_max_width', array( |
|
520 | + $min_max_width = apply_filters('oembed_min_max_width', array( |
|
521 | 521 | 'min' => 200, |
522 | 522 | 'max' => 600 |
523 | - ) ); |
|
523 | + )); |
|
524 | 524 | |
525 | - $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); |
|
526 | - $height = max( ceil( $width / 16 * 9 ), 200 ); |
|
525 | + $width = min(max($min_max_width['min'], $width), $min_max_width['max']); |
|
526 | + $height = max(ceil($width / 16 * 9), 200); |
|
527 | 527 | |
528 | 528 | $data = array( |
529 | 529 | 'version' => '1.0', |
530 | - 'provider_name' => get_bloginfo( 'name' ), |
|
530 | + 'provider_name' => get_bloginfo('name'), |
|
531 | 531 | 'provider_url' => get_home_url(), |
532 | - 'author_name' => get_bloginfo( 'name' ), |
|
532 | + 'author_name' => get_bloginfo('name'), |
|
533 | 533 | 'author_url' => get_home_url(), |
534 | 534 | 'title' => $post->post_title, |
535 | 535 | 'type' => 'link', |
536 | 536 | ); |
537 | 537 | |
538 | - $author = get_userdata( $post->post_author ); |
|
538 | + $author = get_userdata($post->post_author); |
|
539 | 539 | |
540 | - if ( $author ) { |
|
540 | + if ($author) { |
|
541 | 541 | $data['author_name'] = $author->display_name; |
542 | - $data['author_url'] = get_author_posts_url( $author->ID ); |
|
542 | + $data['author_url'] = get_author_posts_url($author->ID); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @param int $width The requested width. |
553 | 553 | * @param int $height The calculated height. |
554 | 554 | */ |
555 | - return apply_filters( 'oembed_response_data', $data, $post, $width, $height ); |
|
555 | + return apply_filters('oembed_response_data', $data, $post, $width, $height); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -566,30 +566,30 @@ discard block |
||
566 | 566 | * @param int $height The calculated height. |
567 | 567 | * @return array The modified response data. |
568 | 568 | */ |
569 | -function get_oembed_response_data_rich( $data, $post, $width, $height ) { |
|
570 | - $data['width'] = absint( $width ); |
|
571 | - $data['height'] = absint( $height ); |
|
569 | +function get_oembed_response_data_rich($data, $post, $width, $height) { |
|
570 | + $data['width'] = absint($width); |
|
571 | + $data['height'] = absint($height); |
|
572 | 572 | $data['type'] = 'rich'; |
573 | - $data['html'] = get_post_embed_html( $width, $height, $post ); |
|
573 | + $data['html'] = get_post_embed_html($width, $height, $post); |
|
574 | 574 | |
575 | 575 | // Add post thumbnail to response if available. |
576 | 576 | $thumbnail_id = false; |
577 | 577 | |
578 | - if ( has_post_thumbnail( $post->ID ) ) { |
|
579 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
578 | + if (has_post_thumbnail($post->ID)) { |
|
579 | + $thumbnail_id = get_post_thumbnail_id($post->ID); |
|
580 | 580 | } |
581 | 581 | |
582 | - if ( 'attachment' === get_post_type( $post ) ) { |
|
583 | - if ( wp_attachment_is_image( $post ) ) { |
|
582 | + if ('attachment' === get_post_type($post)) { |
|
583 | + if (wp_attachment_is_image($post)) { |
|
584 | 584 | $thumbnail_id = $post->ID; |
585 | - } else if ( wp_attachment_is( 'video', $post ) ) { |
|
586 | - $thumbnail_id = get_post_thumbnail_id( $post ); |
|
585 | + } else if (wp_attachment_is('video', $post)) { |
|
586 | + $thumbnail_id = get_post_thumbnail_id($post); |
|
587 | 587 | $data['type'] = 'video'; |
588 | 588 | } |
589 | 589 | } |
590 | 590 | |
591 | - if ( $thumbnail_id ) { |
|
592 | - list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) ); |
|
591 | + if ($thumbnail_id) { |
|
592 | + list($thumbnail_url, $thumbnail_width, $thumbnail_height) = wp_get_attachment_image_src($thumbnail_id, array($width, 99999)); |
|
593 | 593 | $data['thumbnail_url'] = $thumbnail_url; |
594 | 594 | $data['thumbnail_width'] = $thumbnail_width; |
595 | 595 | $data['thumbnail_height'] = $thumbnail_height; |
@@ -606,8 +606,8 @@ discard block |
||
606 | 606 | * @param string $format The oEmbed response format. Accepts 'json' or 'xml'. |
607 | 607 | * @return string The format, either 'xml' or 'json'. Default 'json'. |
608 | 608 | */ |
609 | -function wp_oembed_ensure_format( $format ) { |
|
610 | - if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) { |
|
609 | +function wp_oembed_ensure_format($format) { |
|
610 | + if ( ! in_array($format, array('json', 'xml'), true)) { |
|
611 | 611 | return 'json'; |
612 | 612 | } |
613 | 613 | |
@@ -629,35 +629,35 @@ discard block |
||
629 | 629 | * @param WP_REST_Server $server Server instance. |
630 | 630 | * @return true |
631 | 631 | */ |
632 | -function _oembed_rest_pre_serve_request( $served, $result, $request, $server ) { |
|
632 | +function _oembed_rest_pre_serve_request($served, $result, $request, $server) { |
|
633 | 633 | $params = $request->get_params(); |
634 | 634 | |
635 | - if ( '/oembed/1.0/embed' !== $request->get_route() || 'GET' !== $request->get_method() ) { |
|
635 | + if ('/oembed/1.0/embed' !== $request->get_route() || 'GET' !== $request->get_method()) { |
|
636 | 636 | return $served; |
637 | 637 | } |
638 | 638 | |
639 | - if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) { |
|
639 | + if ( ! isset($params['format']) || 'xml' !== $params['format']) { |
|
640 | 640 | return $served; |
641 | 641 | } |
642 | 642 | |
643 | 643 | // Embed links inside the request. |
644 | - $data = $server->response_to_data( $result, false ); |
|
644 | + $data = $server->response_to_data($result, false); |
|
645 | 645 | |
646 | - if ( ! class_exists( 'SimpleXMLElement' ) ) { |
|
647 | - status_header( 501 ); |
|
648 | - die( get_status_header_desc( 501 ) ); |
|
646 | + if ( ! class_exists('SimpleXMLElement')) { |
|
647 | + status_header(501); |
|
648 | + die(get_status_header_desc(501)); |
|
649 | 649 | } |
650 | 650 | |
651 | - $result = _oembed_create_xml( $data ); |
|
651 | + $result = _oembed_create_xml($data); |
|
652 | 652 | |
653 | 653 | // Bail if there's no XML. |
654 | - if ( ! $result ) { |
|
655 | - status_header( 501 ); |
|
656 | - return get_status_header_desc( 501 ); |
|
654 | + if ( ! $result) { |
|
655 | + status_header(501); |
|
656 | + return get_status_header_desc(501); |
|
657 | 657 | } |
658 | 658 | |
659 | - if ( ! headers_sent() ) { |
|
660 | - $server->send_header( 'Content-Type', 'text/xml; charset=' . get_option( 'blog_charset' ) ); |
|
659 | + if ( ! headers_sent()) { |
|
660 | + $server->send_header('Content-Type', 'text/xml; charset='.get_option('blog_charset')); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | echo $result; |
@@ -675,25 +675,25 @@ discard block |
||
675 | 675 | * @param SimpleXMLElement $node Optional. XML node to append the result to recursively. |
676 | 676 | * @return string|false XML string on success, false on error. |
677 | 677 | */ |
678 | -function _oembed_create_xml( $data, $node = null ) { |
|
679 | - if ( ! is_array( $data ) || empty( $data ) ) { |
|
678 | +function _oembed_create_xml($data, $node = null) { |
|
679 | + if ( ! is_array($data) || empty($data)) { |
|
680 | 680 | return false; |
681 | 681 | } |
682 | 682 | |
683 | - if ( null === $node ) { |
|
684 | - $node = new SimpleXMLElement( '<oembed></oembed>' ); |
|
683 | + if (null === $node) { |
|
684 | + $node = new SimpleXMLElement('<oembed></oembed>'); |
|
685 | 685 | } |
686 | 686 | |
687 | - foreach ( $data as $key => $value ) { |
|
688 | - if ( is_numeric( $key ) ) { |
|
687 | + foreach ($data as $key => $value) { |
|
688 | + if (is_numeric($key)) { |
|
689 | 689 | $key = 'oembed'; |
690 | 690 | } |
691 | 691 | |
692 | - if ( is_array( $value ) ) { |
|
693 | - $item = $node->addChild( $key ); |
|
694 | - _oembed_create_xml( $value, $item ); |
|
692 | + if (is_array($value)) { |
|
693 | + $item = $node->addChild($key); |
|
694 | + _oembed_create_xml($value, $item); |
|
695 | 695 | } else { |
696 | - $node->addChild( $key, esc_html( $value ) ); |
|
696 | + $node->addChild($key, esc_html($value)); |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | |
@@ -715,15 +715,15 @@ discard block |
||
715 | 715 | * @param string $url The URL of the content to be embedded. |
716 | 716 | * @return string The filtered and sanitized oEmbed result. |
717 | 717 | */ |
718 | -function wp_filter_oembed_result( $result, $data, $url ) { |
|
719 | - if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ) ) ) { |
|
718 | +function wp_filter_oembed_result($result, $data, $url) { |
|
719 | + if (false === $result || ! in_array($data->type, array('rich', 'video'))) { |
|
720 | 720 | return $result; |
721 | 721 | } |
722 | 722 | |
723 | 723 | $wp_oembed = _wp_oembed_get_object(); |
724 | 724 | |
725 | 725 | // Don't modify the HTML for trusted providers. |
726 | - if ( false !== $wp_oembed->get_provider( $url, array( 'discover' => false ) ) ) { |
|
726 | + if (false !== $wp_oembed->get_provider($url, array('discover' => false))) { |
|
727 | 727 | return $result; |
728 | 728 | } |
729 | 729 | |
@@ -744,32 +744,32 @@ discard block |
||
744 | 744 | ), |
745 | 745 | ); |
746 | 746 | |
747 | - $html = wp_kses( $result, $allowed_html ); |
|
747 | + $html = wp_kses($result, $allowed_html); |
|
748 | 748 | |
749 | - preg_match( '|(<blockquote>.*?</blockquote>)?.*(<iframe.*?></iframe>)|ms', $html, $content ); |
|
749 | + preg_match('|(<blockquote>.*?</blockquote>)?.*(<iframe.*?></iframe>)|ms', $html, $content); |
|
750 | 750 | // We require at least the iframe to exist. |
751 | - if ( empty( $content[2] ) ) { |
|
751 | + if (empty($content[2])) { |
|
752 | 752 | return false; |
753 | 753 | } |
754 | - $html = $content[1] . $content[2]; |
|
754 | + $html = $content[1].$content[2]; |
|
755 | 755 | |
756 | - if ( ! empty( $content[1] ) ) { |
|
756 | + if ( ! empty($content[1])) { |
|
757 | 757 | // We have a blockquote to fall back on. Hide the iframe by default. |
758 | - $html = str_replace( '<iframe', '<iframe style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', $html ); |
|
759 | - $html = str_replace( '<blockquote', '<blockquote class="wp-embedded-content"', $html ); |
|
758 | + $html = str_replace('<iframe', '<iframe style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', $html); |
|
759 | + $html = str_replace('<blockquote', '<blockquote class="wp-embedded-content"', $html); |
|
760 | 760 | } |
761 | 761 | |
762 | - $html = str_replace( '<iframe', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $html ); |
|
762 | + $html = str_replace('<iframe', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $html); |
|
763 | 763 | |
764 | - preg_match( '/ src=[\'"]([^\'"]*)[\'"]/', $html, $results ); |
|
764 | + preg_match('/ src=[\'"]([^\'"]*)[\'"]/', $html, $results); |
|
765 | 765 | |
766 | - if ( ! empty( $results ) ) { |
|
767 | - $secret = wp_generate_password( 10, false ); |
|
766 | + if ( ! empty($results)) { |
|
767 | + $secret = wp_generate_password(10, false); |
|
768 | 768 | |
769 | - $url = esc_url( "{$results[1]}#?secret=$secret" ); |
|
769 | + $url = esc_url("{$results[1]}#?secret=$secret"); |
|
770 | 770 | |
771 | - $html = str_replace( $results[0], " src=\"$url\" data-secret=\"$secret\"", $html ); |
|
772 | - $html = str_replace( '<blockquote', "<blockquote data-secret=\"$secret\"", $html ); |
|
771 | + $html = str_replace($results[0], " src=\"$url\" data-secret=\"$secret\"", $html); |
|
772 | + $html = str_replace('<blockquote', "<blockquote data-secret=\"$secret\"", $html); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | return $html; |
@@ -786,17 +786,17 @@ discard block |
||
786 | 786 | * @param string $more_string Default 'more' string. |
787 | 787 | * @return string 'Continue reading' link prepended with an ellipsis. |
788 | 788 | */ |
789 | -function wp_embed_excerpt_more( $more_string ) { |
|
790 | - if ( ! is_embed() ) { |
|
789 | +function wp_embed_excerpt_more($more_string) { |
|
790 | + if ( ! is_embed()) { |
|
791 | 791 | return $more_string; |
792 | 792 | } |
793 | 793 | |
794 | - $link = sprintf( '<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>', |
|
795 | - esc_url( get_permalink() ), |
|
794 | + $link = sprintf('<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>', |
|
795 | + esc_url(get_permalink()), |
|
796 | 796 | /* translators: %s: Name of current post */ |
797 | - sprintf( __( 'Continue reading %s' ), '<span class="screen-reader-text">' . get_the_title() . '</span>' ) |
|
797 | + sprintf(__('Continue reading %s'), '<span class="screen-reader-text">'.get_the_title().'</span>') |
|
798 | 798 | ); |
799 | - return ' … ' . $link; |
|
799 | + return ' … '.$link; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | * |
817 | 817 | * @param string $output The current post excerpt. |
818 | 818 | */ |
819 | - echo apply_filters( 'the_excerpt_embed', $output ); |
|
819 | + echo apply_filters('the_excerpt_embed', $output); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -829,9 +829,9 @@ discard block |
||
829 | 829 | * @param string $content The current post excerpt. |
830 | 830 | * @return string The modified post excerpt. |
831 | 831 | */ |
832 | -function wp_embed_excerpt_attachment( $content ) { |
|
833 | - if ( is_attachment() ) { |
|
834 | - return prepend_attachment( '' ); |
|
832 | +function wp_embed_excerpt_attachment($content) { |
|
833 | + if (is_attachment()) { |
|
834 | + return prepend_attachment(''); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | return $content; |
@@ -848,14 +848,14 @@ discard block |
||
848 | 848 | * @since 4.4.0 |
849 | 849 | */ |
850 | 850 | function enqueue_embed_scripts() { |
851 | - wp_enqueue_style( 'wp-embed-template-ie' ); |
|
851 | + wp_enqueue_style('wp-embed-template-ie'); |
|
852 | 852 | |
853 | 853 | /** |
854 | 854 | * Fires when scripts and styles are enqueued for the embed iframe. |
855 | 855 | * |
856 | 856 | * @since 4.4.0 |
857 | 857 | */ |
858 | - do_action( 'enqueue_embed_scripts' ); |
|
858 | + do_action('enqueue_embed_scripts'); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -867,8 +867,8 @@ discard block |
||
867 | 867 | ?> |
868 | 868 | <style type="text/css"> |
869 | 869 | <?php |
870 | - if ( SCRIPT_DEBUG ) { |
|
871 | - readfile( ABSPATH . WPINC . "/css/wp-embed-template.css" ); |
|
870 | + if (SCRIPT_DEBUG) { |
|
871 | + readfile(ABSPATH.WPINC."/css/wp-embed-template.css"); |
|
872 | 872 | } else { |
873 | 873 | /* |
874 | 874 | * If you're looking at a src version of this file, you'll see an "include" |
@@ -898,8 +898,8 @@ discard block |
||
898 | 898 | ?> |
899 | 899 | <script type="text/javascript"> |
900 | 900 | <?php |
901 | - if ( SCRIPT_DEBUG ) { |
|
902 | - readfile( ABSPATH . WPINC . "/js/wp-embed-template.js" ); |
|
901 | + if (SCRIPT_DEBUG) { |
|
902 | + readfile(ABSPATH.WPINC."/js/wp-embed-template.js"); |
|
903 | 903 | } else { |
904 | 904 | /* |
905 | 905 | * If you're looking at a src version of this file, you'll see an "include" |
@@ -929,8 +929,8 @@ discard block |
||
929 | 929 | * @param string $content The content to filter. |
930 | 930 | * @return string The filtered content. |
931 | 931 | */ |
932 | -function _oembed_filter_feed_content( $content ) { |
|
933 | - return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content ); |
|
932 | +function _oembed_filter_feed_content($content) { |
|
933 | + return str_replace('<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content); |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | * @since 4.4.0 |
940 | 940 | */ |
941 | 941 | function print_embed_comments_button() { |
942 | - if ( is_404() || ! ( get_comments_number() || comments_open() ) ) { |
|
942 | + if (is_404() || ! (get_comments_number() || comments_open())) { |
|
943 | 943 | return; |
944 | 944 | } |
945 | 945 | ?> |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | '%s <span class="screen-reader-text">Comments</span>', |
954 | 954 | get_comments_number() |
955 | 955 | ), |
956 | - number_format_i18n( get_comments_number() ) |
|
956 | + number_format_i18n(get_comments_number()) |
|
957 | 957 | ); |
958 | 958 | ?> |
959 | 959 | </a> |
@@ -967,12 +967,12 @@ discard block |
||
967 | 967 | * @since 4.4.0 |
968 | 968 | */ |
969 | 969 | function print_embed_sharing_button() { |
970 | - if ( is_404() ) { |
|
970 | + if (is_404()) { |
|
971 | 971 | return; |
972 | 972 | } |
973 | 973 | ?> |
974 | 974 | <div class="wp-embed-share"> |
975 | - <button type="button" class="wp-embed-share-dialog-open" aria-label="<?php esc_attr_e( 'Open sharing dialog' ); ?>"> |
|
975 | + <button type="button" class="wp-embed-share-dialog-open" aria-label="<?php esc_attr_e('Open sharing dialog'); ?>"> |
|
976 | 976 | <span class="dashicons dashicons-share"></span> |
977 | 977 | </button> |
978 | 978 | </div> |
@@ -985,38 +985,38 @@ discard block |
||
985 | 985 | * @since 4.4.0 |
986 | 986 | */ |
987 | 987 | function print_embed_sharing_dialog() { |
988 | - if ( is_404() ) { |
|
988 | + if (is_404()) { |
|
989 | 989 | return; |
990 | 990 | } |
991 | 991 | ?> |
992 | - <div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e( 'Sharing options' ); ?>"> |
|
992 | + <div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e('Sharing options'); ?>"> |
|
993 | 993 | <div class="wp-embed-share-dialog-content"> |
994 | 994 | <div class="wp-embed-share-dialog-text"> |
995 | 995 | <ul class="wp-embed-share-tabs" role="tablist"> |
996 | 996 | <li class="wp-embed-share-tab-button wp-embed-share-tab-button-wordpress" role="presentation"> |
997 | - <button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button> |
|
997 | + <button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e('WordPress Embed'); ?></button> |
|
998 | 998 | </li> |
999 | 999 | <li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation"> |
1000 | - <button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button> |
|
1000 | + <button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e('HTML Embed'); ?></button> |
|
1001 | 1001 | </li> |
1002 | 1002 | </ul> |
1003 | 1003 | <div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false"> |
1004 | 1004 | <input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-describedby="wp-embed-share-description-wordpress" tabindex="0" readonly/> |
1005 | 1005 | |
1006 | 1006 | <p class="wp-embed-share-description" id="wp-embed-share-description-wordpress"> |
1007 | - <?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?> |
|
1007 | + <?php _e('Copy and paste this URL into your WordPress site to embed'); ?> |
|
1008 | 1008 | </p> |
1009 | 1009 | </div> |
1010 | 1010 | <div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true"> |
1011 | - <textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-description-html" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea> |
|
1011 | + <textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-description-html" tabindex="0" readonly><?php echo esc_textarea(get_post_embed_html(600, 400)); ?></textarea> |
|
1012 | 1012 | |
1013 | 1013 | <p class="wp-embed-share-description" id="wp-embed-share-description-html"> |
1014 | - <?php _e( 'Copy and paste this code into your site to embed' ); ?> |
|
1014 | + <?php _e('Copy and paste this code into your site to embed'); ?> |
|
1015 | 1015 | </p> |
1016 | 1016 | </div> |
1017 | 1017 | </div> |
1018 | 1018 | |
1019 | - <button type="button" class="wp-embed-share-dialog-close" aria-label="<?php esc_attr_e( 'Close sharing dialog' ); ?>"> |
|
1019 | + <button type="button" class="wp-embed-share-dialog-close" aria-label="<?php esc_attr_e('Close sharing dialog'); ?>"> |
|
1020 | 1020 | <span class="dashicons dashicons-no"></span> |
1021 | 1021 | </button> |
1022 | 1022 | </div> |
@@ -1032,13 +1032,13 @@ discard block |
||
1032 | 1032 | function the_embed_site_title() { |
1033 | 1033 | $site_title = sprintf( |
1034 | 1034 | '<a href="%s" target="_top"><img src="%s" srcset="%s 2x" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>', |
1035 | - esc_url( home_url() ), |
|
1036 | - esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ), |
|
1037 | - esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ), |
|
1038 | - esc_html( get_bloginfo( 'name' ) ) |
|
1035 | + esc_url(home_url()), |
|
1036 | + esc_url(get_site_icon_url(32, admin_url('images/w-logo-blue.png'))), |
|
1037 | + esc_url(get_site_icon_url(64, admin_url('images/w-logo-blue.png'))), |
|
1038 | + esc_html(get_bloginfo('name')) |
|
1039 | 1039 | ); |
1040 | 1040 | |
1041 | - $site_title = '<div class="wp-embed-site-title">' . $site_title . '</div>'; |
|
1041 | + $site_title = '<div class="wp-embed-site-title">'.$site_title.'</div>'; |
|
1042 | 1042 | |
1043 | 1043 | /** |
1044 | 1044 | * Filters the site title HTML in the embed footer. |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | * |
1048 | 1048 | * @param string $site_title The site title HTML. |
1049 | 1049 | */ |
1050 | - echo apply_filters( 'embed_site_title_html', $site_title ); |
|
1050 | + echo apply_filters('embed_site_title_html', $site_title); |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | /** |
@@ -1064,22 +1064,22 @@ discard block |
||
1064 | 1064 | * @return null|string The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. |
1065 | 1065 | * Null if the URL does not belong to the current site. |
1066 | 1066 | */ |
1067 | -function wp_filter_pre_oembed_result( $result, $url, $args ) { |
|
1068 | - $post_id = url_to_postid( $url ); |
|
1067 | +function wp_filter_pre_oembed_result($result, $url, $args) { |
|
1068 | + $post_id = url_to_postid($url); |
|
1069 | 1069 | |
1070 | 1070 | /** This filter is documented in wp-includes/class-wp-oembed-controller.php */ |
1071 | - $post_id = apply_filters( 'oembed_request_post_id', $post_id, $url ); |
|
1071 | + $post_id = apply_filters('oembed_request_post_id', $post_id, $url); |
|
1072 | 1072 | |
1073 | - if ( ! $post_id ) { |
|
1073 | + if ( ! $post_id) { |
|
1074 | 1074 | return $result; |
1075 | 1075 | } |
1076 | 1076 | |
1077 | - $width = isset( $args['width'] ) ? $args['width'] : 0; |
|
1077 | + $width = isset($args['width']) ? $args['width'] : 0; |
|
1078 | 1078 | |
1079 | - $data = get_oembed_response_data( $post_id, $width ); |
|
1080 | - $data = _wp_oembed_get_object()->data2html( (object) $data, $url ); |
|
1079 | + $data = get_oembed_response_data($post_id, $width); |
|
1080 | + $data = _wp_oembed_get_object()->data2html((object) $data, $url); |
|
1081 | 1081 | |
1082 | - if ( ! $data ) { |
|
1082 | + if ( ! $data) { |
|
1083 | 1083 | return $result; |
1084 | 1084 | } |
1085 | 1085 |