@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | public function __construct() { |
36 | 36 | $widget_ops = array( |
37 | 37 | 'classname' => 'widget_calendar', |
38 | - 'description' => __( 'A calendar of your site’s Posts.' ), |
|
38 | + 'description' => __('A calendar of your site’s Posts.'), |
|
39 | 39 | 'customize_selective_refresh' => true, |
40 | 40 | ); |
41 | - parent::__construct( 'calendar', __( 'Calendar' ), $widget_ops ); |
|
41 | + parent::__construct('calendar', __('Calendar'), $widget_ops); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * 'before_widget', and 'after_widget'. |
52 | 52 | * @param array $instance The settings for the particular instance of the widget. |
53 | 53 | */ |
54 | - public function widget( $args, $instance ) { |
|
54 | + public function widget($args, $instance) { |
|
55 | 55 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
56 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
|
56 | + $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); |
|
57 | 57 | |
58 | 58 | echo $args['before_widget']; |
59 | - if ( $title ) { |
|
60 | - echo $args['before_title'] . $title . $args['after_title']; |
|
59 | + if ($title) { |
|
60 | + echo $args['before_title'].$title.$args['after_title']; |
|
61 | 61 | } |
62 | - if ( 0 === self::$instance ) { |
|
62 | + if (0 === self::$instance) { |
|
63 | 63 | echo '<div id="calendar_wrap" class="calendar_wrap">'; |
64 | 64 | } else { |
65 | 65 | echo '<div class="calendar_wrap">'; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @param array $old_instance Old settings for this instance. |
83 | 83 | * @return array Updated settings to save. |
84 | 84 | */ |
85 | - public function update( $new_instance, $old_instance ) { |
|
85 | + public function update($new_instance, $old_instance) { |
|
86 | 86 | $instance = $old_instance; |
87 | - $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
87 | + $instance['title'] = sanitize_text_field($new_instance['title']); |
|
88 | 88 | |
89 | 89 | return $instance; |
90 | 90 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param array $instance Current settings. |
99 | 99 | */ |
100 | - public function form( $instance ) { |
|
101 | - $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); |
|
102 | - $title = sanitize_text_field( $instance['title'] ); |
|
100 | + public function form($instance) { |
|
101 | + $instance = wp_parse_args((array) $instance, array('title' => '')); |
|
102 | + $title = sanitize_text_field($instance['title']); |
|
103 | 103 | ?> |
104 | 104 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> |
105 | 105 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function __construct() { |
26 | 26 | $widget_ops = array( |
27 | 27 | 'classname' => 'widget_archive', |
28 | - 'description' => __( 'A monthly archive of your site’s Posts.' ), |
|
28 | + 'description' => __('A monthly archive of your site’s Posts.'), |
|
29 | 29 | 'customize_selective_refresh' => true, |
30 | 30 | ); |
31 | 31 | parent::__construct('archives', __('Archives'), $widget_ops); |
@@ -41,23 +41,23 @@ discard block |
||
41 | 41 | * 'before_widget', and 'after_widget'. |
42 | 42 | * @param array $instance Settings for the current Archives widget instance. |
43 | 43 | */ |
44 | - public function widget( $args, $instance ) { |
|
45 | - $c = ! empty( $instance['count'] ) ? '1' : '0'; |
|
46 | - $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; |
|
44 | + public function widget($args, $instance) { |
|
45 | + $c = ! empty($instance['count']) ? '1' : '0'; |
|
46 | + $d = ! empty($instance['dropdown']) ? '1' : '0'; |
|
47 | 47 | |
48 | 48 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
49 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base ); |
|
49 | + $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base); |
|
50 | 50 | |
51 | 51 | echo $args['before_widget']; |
52 | - if ( $title ) { |
|
53 | - echo $args['before_title'] . $title . $args['after_title']; |
|
52 | + if ($title) { |
|
53 | + echo $args['before_title'].$title.$args['after_title']; |
|
54 | 54 | } |
55 | 55 | |
56 | - if ( $d ) { |
|
56 | + if ($d) { |
|
57 | 57 | $dropdown_id = "{$this->id_base}-dropdown-{$this->number}"; |
58 | 58 | ?> |
59 | - <label class="screen-reader-text" for="<?php echo esc_attr( $dropdown_id ); ?>"><?php echo $title; ?></label> |
|
60 | - <select id="<?php echo esc_attr( $dropdown_id ); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> |
|
59 | + <label class="screen-reader-text" for="<?php echo esc_attr($dropdown_id); ?>"><?php echo $title; ?></label> |
|
60 | + <select id="<?php echo esc_attr($dropdown_id); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> |
|
61 | 61 | <?php |
62 | 62 | /** |
63 | 63 | * Filter the arguments for the Archives widget drop-down. |
@@ -68,33 +68,33 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param array $args An array of Archives widget drop-down arguments. |
70 | 70 | */ |
71 | - $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array( |
|
71 | + $dropdown_args = apply_filters('widget_archives_dropdown_args', array( |
|
72 | 72 | 'type' => 'monthly', |
73 | 73 | 'format' => 'option', |
74 | 74 | 'show_post_count' => $c |
75 | - ) ); |
|
75 | + )); |
|
76 | 76 | |
77 | - switch ( $dropdown_args['type'] ) { |
|
77 | + switch ($dropdown_args['type']) { |
|
78 | 78 | case 'yearly': |
79 | - $label = __( 'Select Year' ); |
|
79 | + $label = __('Select Year'); |
|
80 | 80 | break; |
81 | 81 | case 'monthly': |
82 | - $label = __( 'Select Month' ); |
|
82 | + $label = __('Select Month'); |
|
83 | 83 | break; |
84 | 84 | case 'daily': |
85 | - $label = __( 'Select Day' ); |
|
85 | + $label = __('Select Day'); |
|
86 | 86 | break; |
87 | 87 | case 'weekly': |
88 | - $label = __( 'Select Week' ); |
|
88 | + $label = __('Select Week'); |
|
89 | 89 | break; |
90 | 90 | default: |
91 | - $label = __( 'Select Post' ); |
|
91 | + $label = __('Select Post'); |
|
92 | 92 | break; |
93 | 93 | } |
94 | 94 | ?> |
95 | 95 | |
96 | - <option value=""><?php echo esc_attr( $label ); ?></option> |
|
97 | - <?php wp_get_archives( $dropdown_args ); ?> |
|
96 | + <option value=""><?php echo esc_attr($label); ?></option> |
|
97 | + <?php wp_get_archives($dropdown_args); ?> |
|
98 | 98 | |
99 | 99 | </select> |
100 | 100 | <?php } else { ?> |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param array $args An array of Archives option arguments. |
111 | 111 | */ |
112 | - wp_get_archives( apply_filters( 'widget_archives_args', array( |
|
112 | + wp_get_archives(apply_filters('widget_archives_args', array( |
|
113 | 113 | 'type' => 'monthly', |
114 | 114 | 'show_post_count' => $c |
115 | - ) ) ); |
|
115 | + ))); |
|
116 | 116 | ?> |
117 | 117 | </ul> |
118 | 118 | <?php |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * @param array $old_instance Old settings for this instance. |
133 | 133 | * @return array Updated settings to save. |
134 | 134 | */ |
135 | - public function update( $new_instance, $old_instance ) { |
|
135 | + public function update($new_instance, $old_instance) { |
|
136 | 136 | $instance = $old_instance; |
137 | - $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); |
|
138 | - $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
137 | + $new_instance = wp_parse_args((array) $new_instance, array('title' => '', 'count' => 0, 'dropdown' => '')); |
|
138 | + $instance['title'] = sanitize_text_field($new_instance['title']); |
|
139 | 139 | $instance['count'] = $new_instance['count'] ? 1 : 0; |
140 | 140 | $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; |
141 | 141 | |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param array $instance Current settings. |
152 | 152 | */ |
153 | - public function form( $instance ) { |
|
154 | - $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); |
|
155 | - $title = sanitize_text_field( $instance['title'] ); |
|
153 | + public function form($instance) { |
|
154 | + $instance = wp_parse_args((array) $instance, array('title' => '', 'count' => 0, 'dropdown' => '')); |
|
155 | + $title = sanitize_text_field($instance['title']); |
|
156 | 156 | ?> |
157 | 157 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
158 | 158 | <p> |
159 | - <input class="checkbox" type="checkbox"<?php checked( $instance['dropdown'] ); ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label> |
|
159 | + <input class="checkbox" type="checkbox"<?php checked($instance['dropdown']); ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label> |
|
160 | 160 | <br/> |
161 | - <input class="checkbox" type="checkbox"<?php checked( $instance['count'] ); ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label> |
|
161 | + <input class="checkbox" type="checkbox"<?php checked($instance['count']); ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label> |
|
162 | 162 | </p> |
163 | 163 | <?php |
164 | 164 | } |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | * @param string $id_base The widget ID. |
53 | 53 | */ |
54 | 54 | if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 |
55 | - || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) |
|
56 | - return; |
|
55 | + || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { |
|
56 | + return; |
|
57 | + } |
|
57 | 58 | ?> |
58 | 59 | <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> |
59 | 60 | <?php |
@@ -70,8 +71,9 @@ discard block |
||
70 | 71 | * @param array $instance Settings for the current Recent Comments widget instance. |
71 | 72 | */ |
72 | 73 | public function widget( $args, $instance ) { |
73 | - if ( ! isset( $args['widget_id'] ) ) |
|
74 | - $args['widget_id'] = $this->id; |
|
74 | + if ( ! isset( $args['widget_id'] ) ) { |
|
75 | + $args['widget_id'] = $this->id; |
|
76 | + } |
|
75 | 77 | |
76 | 78 | $output = ''; |
77 | 79 | |
@@ -81,8 +83,9 @@ discard block |
||
81 | 83 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
82 | 84 | |
83 | 85 | $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; |
84 | - if ( ! $number ) |
|
85 | - $number = 5; |
|
86 | + if ( ! $number ) { |
|
87 | + $number = 5; |
|
88 | + } |
|
86 | 89 | |
87 | 90 | /** |
88 | 91 | * Filter the arguments for the Recent Comments widget. |
@@ -37,11 +37,11 @@ |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | - * Outputs the default styles for the Recent Comments widget. |
|
41 | - * |
|
42 | - * @since 2.8.0 |
|
43 | - * @access public |
|
44 | - */ |
|
40 | + * Outputs the default styles for the Recent Comments widget. |
|
41 | + * |
|
42 | + * @since 2.8.0 |
|
43 | + * @access public |
|
44 | + */ |
|
45 | 45 | public function recent_comments_style() { |
46 | 46 | /** |
47 | 47 | * Filters the Recent Comments default widget styles. |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | public function __construct() { |
26 | 26 | $widget_ops = array( |
27 | 27 | 'classname' => 'widget_recent_comments', |
28 | - 'description' => __( 'Your site’s most recent comments.' ), |
|
28 | + 'description' => __('Your site’s most recent comments.'), |
|
29 | 29 | 'customize_selective_refresh' => true, |
30 | 30 | ); |
31 | - parent::__construct( 'recent-comments', __( 'Recent Comments' ), $widget_ops ); |
|
31 | + parent::__construct('recent-comments', __('Recent Comments'), $widget_ops); |
|
32 | 32 | $this->alt_option_name = 'widget_recent_comments'; |
33 | 33 | |
34 | - if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) { |
|
35 | - add_action( 'wp_head', array( $this, 'recent_comments_style' ) ); |
|
34 | + if (is_active_widget(false, false, $this->id_base) || is_customize_preview()) { |
|
35 | + add_action('wp_head', array($this, 'recent_comments_style')); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @param bool $active Whether the widget is active. Default true. |
52 | 52 | * @param string $id_base The widget ID. |
53 | 53 | */ |
54 | - if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 |
|
55 | - || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) |
|
54 | + if ( ! current_theme_supports('widgets') // Temp hack #14876 |
|
55 | + || ! apply_filters('show_recent_comments_widget_style', true, $this->id_base)) |
|
56 | 56 | return; |
57 | 57 | ?> |
58 | 58 | <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | * 'before_widget', and 'after_widget'. |
70 | 70 | * @param array $instance Settings for the current Recent Comments widget instance. |
71 | 71 | */ |
72 | - public function widget( $args, $instance ) { |
|
73 | - if ( ! isset( $args['widget_id'] ) ) |
|
72 | + public function widget($args, $instance) { |
|
73 | + if ( ! isset($args['widget_id'])) |
|
74 | 74 | $args['widget_id'] = $this->id; |
75 | 75 | |
76 | 76 | $output = ''; |
77 | 77 | |
78 | - $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); |
|
78 | + $title = ( ! empty($instance['title'])) ? $instance['title'] : __('Recent Comments'); |
|
79 | 79 | |
80 | 80 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
81 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
81 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
82 | 82 | |
83 | - $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; |
|
84 | - if ( ! $number ) |
|
83 | + $number = ( ! empty($instance['number'])) ? absint($instance['number']) : 5; |
|
84 | + if ( ! $number) |
|
85 | 85 | $number = 5; |
86 | 86 | |
87 | 87 | /** |
@@ -93,29 +93,29 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param array $comment_args An array of arguments used to retrieve the recent comments. |
95 | 95 | */ |
96 | - $comments = get_comments( apply_filters( 'widget_comments_args', array( |
|
96 | + $comments = get_comments(apply_filters('widget_comments_args', array( |
|
97 | 97 | 'number' => $number, |
98 | 98 | 'status' => 'approve', |
99 | 99 | 'post_status' => 'publish' |
100 | - ) ) ); |
|
100 | + ))); |
|
101 | 101 | |
102 | 102 | $output .= $args['before_widget']; |
103 | - if ( $title ) { |
|
104 | - $output .= $args['before_title'] . $title . $args['after_title']; |
|
103 | + if ($title) { |
|
104 | + $output .= $args['before_title'].$title.$args['after_title']; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $output .= '<ul id="recentcomments">'; |
108 | - if ( is_array( $comments ) && $comments ) { |
|
108 | + if (is_array($comments) && $comments) { |
|
109 | 109 | // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.) |
110 | - $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) ); |
|
111 | - _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false ); |
|
110 | + $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID')); |
|
111 | + _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false); |
|
112 | 112 | |
113 | - foreach ( (array) $comments as $comment ) { |
|
113 | + foreach ((array) $comments as $comment) { |
|
114 | 114 | $output .= '<li class="recentcomments">'; |
115 | 115 | /* translators: comments widget: 1: comment author, 2: post link */ |
116 | - $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ), |
|
117 | - '<span class="comment-author-link">' . get_comment_author_link( $comment ) . '</span>', |
|
118 | - '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . get_the_title( $comment->comment_post_ID ) . '</a>' |
|
116 | + $output .= sprintf(_x('%1$s on %2$s', 'widgets'), |
|
117 | + '<span class="comment-author-link">'.get_comment_author_link($comment).'</span>', |
|
118 | + '<a href="'.esc_url(get_comment_link($comment)).'">'.get_the_title($comment->comment_post_ID).'</a>' |
|
119 | 119 | ); |
120 | 120 | $output .= '</li>'; |
121 | 121 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param array $old_instance Old settings for this instance. |
138 | 138 | * @return array Updated settings to save. |
139 | 139 | */ |
140 | - public function update( $new_instance, $old_instance ) { |
|
140 | + public function update($new_instance, $old_instance) { |
|
141 | 141 | $instance = $old_instance; |
142 | - $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
143 | - $instance['number'] = absint( $new_instance['number'] ); |
|
142 | + $instance['title'] = sanitize_text_field($new_instance['title']); |
|
143 | + $instance['number'] = absint($new_instance['number']); |
|
144 | 144 | return $instance; |
145 | 145 | } |
146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param array $instance Current settings. |
154 | 154 | */ |
155 | - public function form( $instance ) { |
|
156 | - $title = isset( $instance['title'] ) ? $instance['title'] : ''; |
|
157 | - $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; |
|
155 | + public function form($instance) { |
|
156 | + $title = isset($instance['title']) ? $instance['title'] : ''; |
|
157 | + $number = isset($instance['number']) ? absint($instance['number']) : 5; |
|
158 | 158 | ?> |
159 | - <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> |
|
160 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> |
|
159 | + <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> |
|
160 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
|
161 | 161 | |
162 | - <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label> |
|
163 | - <input class="tiny-text" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" step="1" min="1" value="<?php echo $number; ?>" size="3" /></p> |
|
162 | + <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of comments to show:'); ?></label> |
|
163 | + <input class="tiny-text" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="number" step="1" min="1" value="<?php echo $number; ?>" size="3" /></p> |
|
164 | 164 | <?php |
165 | 165 | } |
166 | 166 | |
@@ -173,6 +173,6 @@ discard block |
||
173 | 173 | * @deprecated 4.4.0 Fragment caching was removed in favor of split queries. |
174 | 174 | */ |
175 | 175 | public function flush_widget_cache() { |
176 | - _deprecated_function( __METHOD__, '4.4.0' ); |
|
176 | + _deprecated_function(__METHOD__, '4.4.0'); |
|
177 | 177 | } |
178 | 178 | } |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | public function __construct() { |
28 | 28 | $widget_ops = array( |
29 | 29 | 'classname' => 'widget_meta', |
30 | - 'description' => __( 'Login, RSS, & WordPress.org links.' ), |
|
30 | + 'description' => __('Login, RSS, & WordPress.org links.'), |
|
31 | 31 | 'customize_selective_refresh' => true, |
32 | 32 | ); |
33 | - parent::__construct( 'meta', __( 'Meta' ), $widget_ops ); |
|
33 | + parent::__construct('meta', __('Meta'), $widget_ops); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -43,20 +43,20 @@ discard block |
||
43 | 43 | * 'before_widget', and 'after_widget'. |
44 | 44 | * @param array $instance Settings for the current Meta widget instance. |
45 | 45 | */ |
46 | - public function widget( $args, $instance ) { |
|
46 | + public function widget($args, $instance) { |
|
47 | 47 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
48 | - $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base ); |
|
48 | + $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base); |
|
49 | 49 | |
50 | 50 | echo $args['before_widget']; |
51 | - if ( $title ) { |
|
52 | - echo $args['before_title'] . $title . $args['after_title']; |
|
51 | + if ($title) { |
|
52 | + echo $args['before_title'].$title.$args['after_title']; |
|
53 | 53 | } |
54 | 54 | ?> |
55 | 55 | <ul> |
56 | 56 | <?php wp_register(); ?> |
57 | 57 | <li><?php wp_loginout(); ?></li> |
58 | - <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
|
59 | - <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
|
58 | + <li><a href="<?php echo esc_url(get_bloginfo('rss2_url')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
|
59 | + <li><a href="<?php echo esc_url(get_bloginfo('comments_rss2_url')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
|
60 | 60 | <?php |
61 | 61 | /** |
62 | 62 | * Filter the "Powered by WordPress" text in the Meta widget. |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param string $title_text Default title text for the WordPress.org link. |
67 | 67 | */ |
68 | - echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>', |
|
69 | - esc_url( __( 'https://wordpress.org/' ) ), |
|
70 | - esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ), |
|
71 | - _x( 'WordPress.org', 'meta widget link text' ) |
|
72 | - ) ); |
|
68 | + echo apply_filters('widget_meta_poweredby', sprintf('<li><a href="%s" title="%s">%s</a></li>', |
|
69 | + esc_url(__('https://wordpress.org/')), |
|
70 | + esc_attr__('Powered by WordPress, state-of-the-art semantic personal publishing platform.'), |
|
71 | + _x('WordPress.org', 'meta widget link text') |
|
72 | + )); |
|
73 | 73 | |
74 | 74 | wp_meta(); |
75 | 75 | ?> |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * @param array $old_instance Old settings for this instance. |
90 | 90 | * @return array Updated settings to save. |
91 | 91 | */ |
92 | - public function update( $new_instance, $old_instance ) { |
|
92 | + public function update($new_instance, $old_instance) { |
|
93 | 93 | $instance = $old_instance; |
94 | - $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
94 | + $instance['title'] = sanitize_text_field($new_instance['title']); |
|
95 | 95 | |
96 | 96 | return $instance; |
97 | 97 | } |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @param array $instance Current settings. |
106 | 106 | */ |
107 | - public function form( $instance ) { |
|
108 | - $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); |
|
109 | - $title = sanitize_text_field( $instance['title'] ); |
|
107 | + public function form($instance) { |
|
108 | + $instance = wp_parse_args((array) $instance, array('title' => '')); |
|
109 | + $title = sanitize_text_field($instance['title']); |
|
110 | 110 | ?> |
111 | 111 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
112 | 112 | <?php |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | public function __construct() { |
26 | 26 | $widget_ops = array( |
27 | 27 | 'classname' => 'widget_search', |
28 | - 'description' => __( 'A search form for your site.' ), |
|
28 | + 'description' => __('A search form for your site.'), |
|
29 | 29 | 'customize_selective_refresh' => true, |
30 | 30 | ); |
31 | - parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops ); |
|
31 | + parent::__construct('search', _x('Search', 'Search widget'), $widget_ops); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | * 'before_widget', and 'after_widget'. |
42 | 42 | * @param array $instance Settings for the current Search widget instance. |
43 | 43 | */ |
44 | - public function widget( $args, $instance ) { |
|
44 | + public function widget($args, $instance) { |
|
45 | 45 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
46 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
|
46 | + $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); |
|
47 | 47 | |
48 | 48 | echo $args['before_widget']; |
49 | - if ( $title ) { |
|
50 | - echo $args['before_title'] . $title . $args['after_title']; |
|
49 | + if ($title) { |
|
50 | + echo $args['before_title'].$title.$args['after_title']; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Use current theme search form if it exists |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param array $instance Current settings. |
66 | 66 | */ |
67 | - public function form( $instance ) { |
|
68 | - $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); |
|
67 | + public function form($instance) { |
|
68 | + $instance = wp_parse_args((array) $instance, array('title' => '')); |
|
69 | 69 | $title = $instance['title']; |
70 | 70 | ?> |
71 | 71 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p> |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @param array $old_instance Old settings for this instance. |
84 | 84 | * @return array Updated settings. |
85 | 85 | */ |
86 | - public function update( $new_instance, $old_instance ) { |
|
86 | + public function update($new_instance, $old_instance) { |
|
87 | 87 | $instance = $old_instance; |
88 | - $new_instance = wp_parse_args((array) $new_instance, array( 'title' => '')); |
|
89 | - $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
88 | + $new_instance = wp_parse_args((array) $new_instance, array('title' => '')); |
|
89 | + $instance['title'] = sanitize_text_field($new_instance['title']); |
|
90 | 90 | return $instance; |
91 | 91 | } |
92 | 92 |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | public function __construct() { |
26 | 26 | $widget_ops = array( |
27 | 27 | 'classname' => 'widget_categories', |
28 | - 'description' => __( 'A list or dropdown of categories.' ), |
|
28 | + 'description' => __('A list or dropdown of categories.'), |
|
29 | 29 | 'customize_selective_refresh' => true, |
30 | 30 | ); |
31 | - parent::__construct( 'categories', __( 'Categories' ), $widget_ops ); |
|
31 | + parent::__construct('categories', __('Categories'), $widget_ops); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -41,19 +41,19 @@ discard block |
||
41 | 41 | * 'before_widget', and 'after_widget'. |
42 | 42 | * @param array $instance Settings for the current Categories widget instance. |
43 | 43 | */ |
44 | - public function widget( $args, $instance ) { |
|
44 | + public function widget($args, $instance) { |
|
45 | 45 | static $first_dropdown = true; |
46 | 46 | |
47 | 47 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
48 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); |
|
48 | + $title = apply_filters('widget_title', empty($instance['title']) ? __('Categories') : $instance['title'], $instance, $this->id_base); |
|
49 | 49 | |
50 | - $c = ! empty( $instance['count'] ) ? '1' : '0'; |
|
51 | - $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; |
|
52 | - $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; |
|
50 | + $c = ! empty($instance['count']) ? '1' : '0'; |
|
51 | + $h = ! empty($instance['hierarchical']) ? '1' : '0'; |
|
52 | + $d = ! empty($instance['dropdown']) ? '1' : '0'; |
|
53 | 53 | |
54 | 54 | echo $args['before_widget']; |
55 | - if ( $title ) { |
|
56 | - echo $args['before_title'] . $title . $args['after_title']; |
|
55 | + if ($title) { |
|
56 | + echo $args['before_title'].$title.$args['after_title']; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $cat_args = array( |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | 'hierarchical' => $h |
63 | 63 | ); |
64 | 64 | |
65 | - if ( $d ) { |
|
66 | - $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}"; |
|
65 | + if ($d) { |
|
66 | + $dropdown_id = ($first_dropdown) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}"; |
|
67 | 67 | $first_dropdown = false; |
68 | 68 | |
69 | - echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>'; |
|
69 | + echo '<label class="screen-reader-text" for="'.esc_attr($dropdown_id).'">'.$title.'</label>'; |
|
70 | 70 | |
71 | - $cat_args['show_option_none'] = __( 'Select Category' ); |
|
71 | + $cat_args['show_option_none'] = __('Select Category'); |
|
72 | 72 | $cat_args['id'] = $dropdown_id; |
73 | 73 | |
74 | 74 | /** |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $cat_args An array of Categories widget drop-down arguments. |
82 | 82 | */ |
83 | - wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args ) ); |
|
83 | + wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); |
|
84 | 84 | ?> |
85 | 85 | |
86 | 86 | <script type='text/javascript'> |
87 | 87 | /* <![CDATA[ */ |
88 | 88 | (function() { |
89 | - var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" ); |
|
89 | + var dropdown = document.getElementById( "<?php echo esc_js($dropdown_id); ?>" ); |
|
90 | 90 | function onCatChange() { |
91 | 91 | if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { |
92 | 92 | location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param array $cat_args An array of Categories widget options. |
113 | 113 | */ |
114 | - wp_list_categories( apply_filters( 'widget_categories_args', $cat_args ) ); |
|
114 | + wp_list_categories(apply_filters('widget_categories_args', $cat_args)); |
|
115 | 115 | ?> |
116 | 116 | </ul> |
117 | 117 | <?php |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | * @param array $old_instance Old settings for this instance. |
132 | 132 | * @return array Updated settings to save. |
133 | 133 | */ |
134 | - public function update( $new_instance, $old_instance ) { |
|
134 | + public function update($new_instance, $old_instance) { |
|
135 | 135 | $instance = $old_instance; |
136 | - $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
137 | - $instance['count'] = !empty($new_instance['count']) ? 1 : 0; |
|
138 | - $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0; |
|
139 | - $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; |
|
136 | + $instance['title'] = sanitize_text_field($new_instance['title']); |
|
137 | + $instance['count'] = ! empty($new_instance['count']) ? 1 : 0; |
|
138 | + $instance['hierarchical'] = ! empty($new_instance['hierarchical']) ? 1 : 0; |
|
139 | + $instance['dropdown'] = ! empty($new_instance['dropdown']) ? 1 : 0; |
|
140 | 140 | |
141 | 141 | return $instance; |
142 | 142 | } |
@@ -149,25 +149,25 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @param array $instance Current settings. |
151 | 151 | */ |
152 | - public function form( $instance ) { |
|
152 | + public function form($instance) { |
|
153 | 153 | //Defaults |
154 | - $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); |
|
155 | - $title = sanitize_text_field( $instance['title'] ); |
|
156 | - $count = isset($instance['count']) ? (bool) $instance['count'] :false; |
|
157 | - $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; |
|
158 | - $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; |
|
154 | + $instance = wp_parse_args((array) $instance, array('title' => '')); |
|
155 | + $title = sanitize_text_field($instance['title']); |
|
156 | + $count = isset($instance['count']) ? (bool) $instance['count'] : false; |
|
157 | + $hierarchical = isset($instance['hierarchical']) ? (bool) $instance['hierarchical'] : false; |
|
158 | + $dropdown = isset($instance['dropdown']) ? (bool) $instance['dropdown'] : false; |
|
159 | 159 | ?> |
160 | - <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> |
|
161 | - <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> |
|
160 | + <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> |
|
161 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
|
162 | 162 | |
163 | - <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> /> |
|
164 | - <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> |
|
163 | + <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked($dropdown); ?> /> |
|
164 | + <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label><br /> |
|
165 | 165 | |
166 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> /> |
|
167 | - <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br /> |
|
166 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked($count); ?> /> |
|
167 | + <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label><br /> |
|
168 | 168 | |
169 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> /> |
|
170 | - <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p> |
|
169 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked($hierarchical); ?> /> |
|
170 | + <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e('Show hierarchy'); ?></label></p> |
|
171 | 171 | <?php |
172 | 172 | } |
173 | 173 |
@@ -48,7 +48,7 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * @param string|array|WP_Error $data |
|
51 | + * @param string $data |
|
52 | 52 | */ |
53 | 53 | public function feedback( $data ) { |
54 | 54 | if ( is_wp_error( $data ) ) { |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * @param bool $allow_relaxed_file_ownership |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { |
|
30 | - if ( $context ) { |
|
29 | + public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false) { |
|
30 | + if ($context) { |
|
31 | 31 | $this->options['context'] = $context; |
32 | 32 | } |
33 | 33 | // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version |
34 | 34 | // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer |
35 | 35 | ob_start(); |
36 | - $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership ); |
|
36 | + $result = parent::request_filesystem_credentials($error, $context, $allow_relaxed_file_ownership); |
|
37 | 37 | ob_end_clean(); |
38 | 38 | return $result; |
39 | 39 | } |
@@ -50,37 +50,37 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @param string|array|WP_Error $data |
52 | 52 | */ |
53 | - public function feedback( $data ) { |
|
54 | - if ( is_wp_error( $data ) ) { |
|
53 | + public function feedback($data) { |
|
54 | + if (is_wp_error($data)) { |
|
55 | 55 | $string = $data->get_error_message(); |
56 | - } elseif ( is_array( $data ) ) { |
|
56 | + } elseif (is_array($data)) { |
|
57 | 57 | return; |
58 | 58 | } else { |
59 | 59 | $string = $data; |
60 | 60 | } |
61 | - if ( ! empty( $this->upgrader->strings[ $string ] ) ) |
|
62 | - $string = $this->upgrader->strings[ $string ]; |
|
61 | + if ( ! empty($this->upgrader->strings[$string])) |
|
62 | + $string = $this->upgrader->strings[$string]; |
|
63 | 63 | |
64 | - if ( strpos( $string, '%' ) !== false ) { |
|
64 | + if (strpos($string, '%') !== false) { |
|
65 | 65 | $args = func_get_args(); |
66 | - $args = array_splice( $args, 1 ); |
|
67 | - if ( ! empty( $args ) ) |
|
68 | - $string = vsprintf( $string, $args ); |
|
66 | + $args = array_splice($args, 1); |
|
67 | + if ( ! empty($args)) |
|
68 | + $string = vsprintf($string, $args); |
|
69 | 69 | } |
70 | 70 | |
71 | - $string = trim( $string ); |
|
71 | + $string = trim($string); |
|
72 | 72 | |
73 | 73 | // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output. |
74 | - $string = wp_kses( $string, array( |
|
74 | + $string = wp_kses($string, array( |
|
75 | 75 | 'a' => array( |
76 | 76 | 'href' => true |
77 | 77 | ), |
78 | 78 | 'br' => true, |
79 | 79 | 'em' => true, |
80 | 80 | 'strong' => true, |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - if ( empty( $string ) ) |
|
83 | + if (empty($string)) |
|
84 | 84 | return; |
85 | 85 | |
86 | 86 | $this->messages[] = $string; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function footer() { |
100 | 100 | $output = ob_get_clean(); |
101 | - if ( ! empty( $output ) ) |
|
102 | - $this->feedback( $output ); |
|
101 | + if ( ! empty($output)) |
|
102 | + $this->feedback($output); |
|
103 | 103 | } |
104 | 104 | } |
@@ -58,14 +58,16 @@ discard block |
||
58 | 58 | } else { |
59 | 59 | $string = $data; |
60 | 60 | } |
61 | - if ( ! empty( $this->upgrader->strings[ $string ] ) ) |
|
62 | - $string = $this->upgrader->strings[ $string ]; |
|
61 | + if ( ! empty( $this->upgrader->strings[ $string ] ) ) { |
|
62 | + $string = $this->upgrader->strings[ $string ]; |
|
63 | + } |
|
63 | 64 | |
64 | 65 | if ( strpos( $string, '%' ) !== false ) { |
65 | 66 | $args = func_get_args(); |
66 | 67 | $args = array_splice( $args, 1 ); |
67 | - if ( ! empty( $args ) ) |
|
68 | - $string = vsprintf( $string, $args ); |
|
68 | + if ( ! empty( $args ) ) { |
|
69 | + $string = vsprintf( $string, $args ); |
|
70 | + } |
|
69 | 71 | } |
70 | 72 | |
71 | 73 | $string = trim( $string ); |
@@ -80,8 +82,9 @@ discard block |
||
80 | 82 | 'strong' => true, |
81 | 83 | ) ); |
82 | 84 | |
83 | - if ( empty( $string ) ) |
|
84 | - return; |
|
85 | + if ( empty( $string ) ) { |
|
86 | + return; |
|
87 | + } |
|
85 | 88 | |
86 | 89 | $this->messages[] = $string; |
87 | 90 | } |
@@ -98,7 +101,8 @@ discard block |
||
98 | 101 | */ |
99 | 102 | public function footer() { |
100 | 103 | $output = ob_get_clean(); |
101 | - if ( ! empty( $output ) ) |
|
102 | - $this->feedback( $output ); |
|
104 | + if ( ! empty( $output ) ) { |
|
105 | + $this->feedback( $output ); |
|
106 | + } |
|
103 | 107 | } |
104 | 108 | } |
@@ -204,7 +204,7 @@ |
||
204 | 204 | * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. |
205 | 205 | * @access public |
206 | 206 | * |
207 | - * @param array $plugins Array of the basename paths of the plugins' main files. |
|
207 | + * @param string[] $plugins Array of the basename paths of the plugins' main files. |
|
208 | 208 | * @param array $args { |
209 | 209 | * Optional. Other arguments for upgrading several plugins at once. Default empty array. |
210 | 210 | * |
@@ -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 | * |
@@ -118,8 +118,9 @@ discard block |
||
118 | 118 | remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); |
119 | 119 | remove_filter('upgrader_source_selection', array($this, 'check_package') ); |
120 | 120 | |
121 | - if ( ! $this->result || is_wp_error($this->result) ) |
|
122 | - return $this->result; |
|
121 | + if ( ! $this->result || is_wp_error($this->result) ) { |
|
122 | + return $this->result; |
|
123 | + } |
|
123 | 124 | |
124 | 125 | // Force refresh of plugin update information |
125 | 126 | wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
@@ -188,8 +189,9 @@ discard block |
||
188 | 189 | remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade')); |
189 | 190 | remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); |
190 | 191 | |
191 | - if ( ! $this->result || is_wp_error($this->result) ) |
|
192 | - return $this->result; |
|
192 | + if ( ! $this->result || is_wp_error($this->result) ) { |
|
193 | + return $this->result; |
|
194 | + } |
|
193 | 195 | |
194 | 196 | // Force refresh of plugin update information |
195 | 197 | wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
@@ -247,10 +249,12 @@ discard block |
||
247 | 249 | * @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. |
248 | 250 | */ |
249 | 251 | $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
250 | - foreach ( $plugins as $plugin ) |
|
251 | - $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); |
|
252 | - if ( $maintenance ) |
|
253 | - $this->maintenance_mode(true); |
|
252 | + foreach ( $plugins as $plugin ) { |
|
253 | + $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); |
|
254 | + } |
|
255 | + if ( $maintenance ) { |
|
256 | + $this->maintenance_mode(true); |
|
257 | + } |
|
254 | 258 | |
255 | 259 | $results = array(); |
256 | 260 | |
@@ -288,8 +292,9 @@ discard block |
||
288 | 292 | $results[$plugin] = $this->result; |
289 | 293 | |
290 | 294 | // Prevent credentials auth screen from displaying multiple times |
291 | - if ( false === $result ) |
|
292 | - break; |
|
295 | + if ( false === $result ) { |
|
296 | + break; |
|
297 | + } |
|
293 | 298 | } //end foreach $plugins |
294 | 299 | |
295 | 300 | $this->maintenance_mode(false); |
@@ -334,12 +339,15 @@ discard block |
||
334 | 339 | public function check_package($source) { |
335 | 340 | global $wp_filesystem; |
336 | 341 | |
337 | - if ( is_wp_error($source) ) |
|
338 | - return $source; |
|
342 | + if ( is_wp_error($source) ) { |
|
343 | + return $source; |
|
344 | + } |
|
339 | 345 | |
340 | 346 | $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source); |
341 | - if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation. |
|
347 | + if ( ! is_dir($working_directory) ) { |
|
348 | + // Sanity check, if the above fails, let's not prevent installation. |
|
342 | 349 | return $source; |
350 | + } |
|
343 | 351 | |
344 | 352 | // Check the folder contains at least 1 valid plugin. |
345 | 353 | $plugins_found = false; |
@@ -354,8 +362,9 @@ discard block |
||
354 | 362 | } |
355 | 363 | } |
356 | 364 | |
357 | - if ( ! $plugins_found ) |
|
358 | - return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); |
|
365 | + if ( ! $plugins_found ) { |
|
366 | + return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); |
|
367 | + } |
|
359 | 368 | |
360 | 369 | return $source; |
361 | 370 | } |
@@ -371,14 +380,17 @@ discard block |
||
371 | 380 | * @return string|false The full path to the main plugin file, or false. |
372 | 381 | */ |
373 | 382 | public function plugin_info() { |
374 | - if ( ! is_array($this->result) ) |
|
375 | - return false; |
|
376 | - if ( empty($this->result['destination_name']) ) |
|
377 | - return false; |
|
383 | + if ( ! is_array($this->result) ) { |
|
384 | + return false; |
|
385 | + } |
|
386 | + if ( empty($this->result['destination_name']) ) { |
|
387 | + return false; |
|
388 | + } |
|
378 | 389 | |
379 | 390 | $plugin = get_plugins('/' . $this->result['destination_name']); //Ensure to pass with leading slash |
380 | - if ( empty($plugin) ) |
|
381 | - return false; |
|
391 | + if ( empty($plugin) ) { |
|
392 | + return false; |
|
393 | + } |
|
382 | 394 | |
383 | 395 | $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list |
384 | 396 | |
@@ -400,16 +412,20 @@ discard block |
||
400 | 412 | */ |
401 | 413 | public function deactivate_plugin_before_upgrade($return, $plugin) { |
402 | 414 | |
403 | - if ( is_wp_error($return) ) //Bypass. |
|
415 | + if ( is_wp_error($return) ) { |
|
416 | + //Bypass. |
|
404 | 417 | return $return; |
418 | + } |
|
405 | 419 | |
406 | 420 | // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it |
407 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) |
|
408 | - return $return; |
|
421 | + if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
422 | + return $return; |
|
423 | + } |
|
409 | 424 | |
410 | 425 | $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
411 | - if ( empty($plugin) ) |
|
412 | - return new WP_Error('bad_request', $this->strings['bad_request']); |
|
426 | + if ( empty($plugin) ) { |
|
427 | + return new WP_Error('bad_request', $this->strings['bad_request']); |
|
428 | + } |
|
413 | 429 | |
414 | 430 | if ( is_plugin_active($plugin) ) { |
415 | 431 | //Deactivate the plugin silently, Prevent deactivation hooks from running. |
@@ -439,27 +455,35 @@ discard block |
||
439 | 455 | public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { |
440 | 456 | global $wp_filesystem; |
441 | 457 | |
442 | - if ( is_wp_error($removed) ) |
|
443 | - return $removed; //Pass errors through. |
|
458 | + if ( is_wp_error($removed) ) { |
|
459 | + return $removed; |
|
460 | + } |
|
461 | + //Pass errors through. |
|
444 | 462 | |
445 | 463 | $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
446 | - if ( empty($plugin) ) |
|
447 | - return new WP_Error('bad_request', $this->strings['bad_request']); |
|
464 | + if ( empty($plugin) ) { |
|
465 | + return new WP_Error('bad_request', $this->strings['bad_request']); |
|
466 | + } |
|
448 | 467 | |
449 | 468 | $plugins_dir = $wp_filesystem->wp_plugins_dir(); |
450 | 469 | $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) ); |
451 | 470 | |
452 | - if ( ! $wp_filesystem->exists($this_plugin_dir) ) //If it's already vanished. |
|
471 | + if ( ! $wp_filesystem->exists($this_plugin_dir) ) { |
|
472 | + //If it's already vanished. |
|
453 | 473 | return $removed; |
474 | + } |
|
454 | 475 | |
455 | 476 | // If plugin is in its own directory, recursively delete the directory. |
456 | - if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
477 | + if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) { |
|
478 | + //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
457 | 479 | $deleted = $wp_filesystem->delete($this_plugin_dir, true); |
458 | - else |
|
459 | - $deleted = $wp_filesystem->delete($plugins_dir . $plugin); |
|
480 | + } else { |
|
481 | + $deleted = $wp_filesystem->delete($plugins_dir . $plugin); |
|
482 | + } |
|
460 | 483 | |
461 | - if ( ! $deleted ) |
|
462 | - return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']); |
|
484 | + if ( ! $deleted ) { |
|
485 | + return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']); |
|
486 | + } |
|
463 | 487 | |
464 | 488 | return true; |
465 | 489 | } |
@@ -90,23 +90,23 @@ discard block |
||
90 | 90 | * } |
91 | 91 | * @return bool|WP_Error True if the install was successful, false or a WP_Error otherwise. |
92 | 92 | */ |
93 | - public function install( $package, $args = array() ) { |
|
93 | + public function install($package, $args = array()) { |
|
94 | 94 | |
95 | 95 | $defaults = array( |
96 | 96 | 'clear_update_cache' => true, |
97 | 97 | ); |
98 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
98 | + $parsed_args = wp_parse_args($args, $defaults); |
|
99 | 99 | |
100 | 100 | $this->init(); |
101 | 101 | $this->install_strings(); |
102 | 102 | |
103 | - add_filter('upgrader_source_selection', array($this, 'check_package') ); |
|
104 | - if ( $parsed_args['clear_update_cache'] ) { |
|
103 | + add_filter('upgrader_source_selection', array($this, 'check_package')); |
|
104 | + if ($parsed_args['clear_update_cache']) { |
|
105 | 105 | // Clear cache so wp_update_plugins() knows about the new plugin. |
106 | - add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); |
|
106 | + add_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0); |
|
107 | 107 | } |
108 | 108 | |
109 | - $this->run( array( |
|
109 | + $this->run(array( |
|
110 | 110 | 'package' => $package, |
111 | 111 | 'destination' => WP_PLUGIN_DIR, |
112 | 112 | 'clear_destination' => false, // Do not overwrite files. |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | 'type' => 'plugin', |
116 | 116 | 'action' => 'install', |
117 | 117 | ) |
118 | - ) ); |
|
118 | + )); |
|
119 | 119 | |
120 | - remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); |
|
121 | - remove_filter('upgrader_source_selection', array($this, 'check_package') ); |
|
120 | + remove_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9); |
|
121 | + remove_filter('upgrader_source_selection', array($this, 'check_package')); |
|
122 | 122 | |
123 | - if ( ! $this->result || is_wp_error($this->result) ) |
|
123 | + if ( ! $this->result || is_wp_error($this->result)) |
|
124 | 124 | return $this->result; |
125 | 125 | |
126 | 126 | // Force refresh of plugin update information |
127 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
127 | + wp_clean_plugins_cache($parsed_args['clear_update_cache']); |
|
128 | 128 | |
129 | 129 | return true; |
130 | 130 | } |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | * } |
146 | 146 | * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. |
147 | 147 | */ |
148 | - public function upgrade( $plugin, $args = array() ) { |
|
148 | + public function upgrade($plugin, $args = array()) { |
|
149 | 149 | |
150 | 150 | $defaults = array( |
151 | 151 | 'clear_update_cache' => true, |
152 | 152 | ); |
153 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
153 | + $parsed_args = wp_parse_args($args, $defaults); |
|
154 | 154 | |
155 | 155 | $this->init(); |
156 | 156 | $this->upgrade_strings(); |
157 | 157 | |
158 | - $current = get_site_transient( 'update_plugins' ); |
|
159 | - if ( !isset( $current->response[ $plugin ] ) ) { |
|
158 | + $current = get_site_transient('update_plugins'); |
|
159 | + if ( ! isset($current->response[$plugin])) { |
|
160 | 160 | $this->skin->before(); |
161 | 161 | $this->skin->set_result(false); |
162 | 162 | $this->skin->error('up_to_date'); |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // Get the URL to the zip file |
168 | - $r = $current->response[ $plugin ]; |
|
168 | + $r = $current->response[$plugin]; |
|
169 | 169 | |
170 | 170 | add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2); |
171 | 171 | add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); |
172 | 172 | //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. |
173 | - if ( $parsed_args['clear_update_cache'] ) { |
|
173 | + if ($parsed_args['clear_update_cache']) { |
|
174 | 174 | // Clear cache so wp_update_plugins() knows about the new plugin. |
175 | - add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); |
|
175 | + add_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0); |
|
176 | 176 | } |
177 | 177 | |
178 | - $this->run( array( |
|
178 | + $this->run(array( |
|
179 | 179 | 'package' => $r->package, |
180 | 180 | 'destination' => WP_PLUGIN_DIR, |
181 | 181 | 'clear_destination' => true, |
@@ -185,18 +185,18 @@ discard block |
||
185 | 185 | 'type' => 'plugin', |
186 | 186 | 'action' => 'update', |
187 | 187 | ), |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | |
190 | 190 | // Cleanup our hooks, in case something else does a upgrade on this connection. |
191 | - remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); |
|
191 | + remove_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9); |
|
192 | 192 | remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade')); |
193 | 193 | remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); |
194 | 194 | |
195 | - if ( ! $this->result || is_wp_error($this->result) ) |
|
195 | + if ( ! $this->result || is_wp_error($this->result)) |
|
196 | 196 | return $this->result; |
197 | 197 | |
198 | 198 | // Force refresh of plugin update information |
199 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
199 | + wp_clean_plugins_cache($parsed_args['clear_update_cache']); |
|
200 | 200 | |
201 | 201 | return true; |
202 | 202 | } |
@@ -217,26 +217,26 @@ discard block |
||
217 | 217 | * } |
218 | 218 | * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem. |
219 | 219 | */ |
220 | - public function bulk_upgrade( $plugins, $args = array() ) { |
|
220 | + public function bulk_upgrade($plugins, $args = array()) { |
|
221 | 221 | |
222 | 222 | $defaults = array( |
223 | 223 | 'clear_update_cache' => true, |
224 | 224 | ); |
225 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
225 | + $parsed_args = wp_parse_args($args, $defaults); |
|
226 | 226 | |
227 | 227 | $this->init(); |
228 | 228 | $this->bulk = true; |
229 | 229 | $this->upgrade_strings(); |
230 | 230 | |
231 | - $current = get_site_transient( 'update_plugins' ); |
|
231 | + $current = get_site_transient('update_plugins'); |
|
232 | 232 | |
233 | 233 | add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); |
234 | 234 | |
235 | 235 | $this->skin->header(); |
236 | 236 | |
237 | 237 | // Connect to the Filesystem first. |
238 | - $res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) ); |
|
239 | - if ( ! $res ) { |
|
238 | + $res = $this->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR)); |
|
239 | + if ( ! $res) { |
|
240 | 240 | $this->skin->footer(); |
241 | 241 | return false; |
242 | 242 | } |
@@ -249,21 +249,21 @@ discard block |
||
249 | 249 | * - a plugin with an update available is currently active. |
250 | 250 | * @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. |
251 | 251 | */ |
252 | - $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
|
253 | - foreach ( $plugins as $plugin ) |
|
254 | - $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); |
|
255 | - if ( $maintenance ) |
|
252 | + $maintenance = (is_multisite() && ! empty($plugins)); |
|
253 | + foreach ($plugins as $plugin) |
|
254 | + $maintenance = $maintenance || (is_plugin_active($plugin) && isset($current->response[$plugin])); |
|
255 | + if ($maintenance) |
|
256 | 256 | $this->maintenance_mode(true); |
257 | 257 | |
258 | 258 | $results = array(); |
259 | 259 | |
260 | 260 | $this->update_count = count($plugins); |
261 | 261 | $this->update_current = 0; |
262 | - foreach ( $plugins as $plugin ) { |
|
262 | + foreach ($plugins as $plugin) { |
|
263 | 263 | $this->update_current++; |
264 | - $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); |
|
264 | + $this->skin->plugin_info = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin, false, true); |
|
265 | 265 | |
266 | - if ( !isset( $current->response[ $plugin ] ) ) { |
|
266 | + if ( ! isset($current->response[$plugin])) { |
|
267 | 267 | $this->skin->set_result('up_to_date'); |
268 | 268 | $this->skin->before(); |
269 | 269 | $this->skin->feedback('up_to_date'); |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | // Get the URL to the zip file. |
276 | - $r = $current->response[ $plugin ]; |
|
276 | + $r = $current->response[$plugin]; |
|
277 | 277 | |
278 | 278 | $this->skin->plugin_active = is_plugin_active($plugin); |
279 | 279 | |
280 | - $result = $this->run( array( |
|
280 | + $result = $this->run(array( |
|
281 | 281 | 'package' => $r->package, |
282 | 282 | 'destination' => WP_PLUGIN_DIR, |
283 | 283 | 'clear_destination' => true, |
@@ -286,27 +286,27 @@ discard block |
||
286 | 286 | 'hook_extra' => array( |
287 | 287 | 'plugin' => $plugin |
288 | 288 | ) |
289 | - ) ); |
|
289 | + )); |
|
290 | 290 | |
291 | 291 | $results[$plugin] = $this->result; |
292 | 292 | |
293 | 293 | // Prevent credentials auth screen from displaying multiple times |
294 | - if ( false === $result ) |
|
294 | + if (false === $result) |
|
295 | 295 | break; |
296 | 296 | } //end foreach $plugins |
297 | 297 | |
298 | 298 | $this->maintenance_mode(false); |
299 | 299 | |
300 | 300 | // Force refresh of plugin update information. |
301 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
301 | + wp_clean_plugins_cache($parsed_args['clear_update_cache']); |
|
302 | 302 | |
303 | 303 | /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ |
304 | - do_action( 'upgrader_process_complete', $this, array( |
|
304 | + do_action('upgrader_process_complete', $this, array( |
|
305 | 305 | 'action' => 'update', |
306 | 306 | 'type' => 'plugin', |
307 | 307 | 'bulk' => true, |
308 | 308 | 'plugins' => $plugins, |
309 | - ) ); |
|
309 | + )); |
|
310 | 310 | |
311 | 311 | $this->skin->bulk_footer(); |
312 | 312 | |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | public function check_package($source) { |
337 | 337 | global $wp_filesystem; |
338 | 338 | |
339 | - if ( is_wp_error($source) ) |
|
339 | + if (is_wp_error($source)) |
|
340 | 340 | return $source; |
341 | 341 | |
342 | - $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source); |
|
343 | - if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation. |
|
342 | + $working_directory = str_replace($wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source); |
|
343 | + if ( ! is_dir($working_directory)) // Sanity check, if the above fails, let's not prevent installation. |
|
344 | 344 | return $source; |
345 | 345 | |
346 | 346 | // Check the folder contains at least 1 valid plugin. |
347 | 347 | $plugins_found = false; |
348 | - $files = glob( $working_directory . '*.php' ); |
|
349 | - if ( $files ) { |
|
350 | - foreach ( $files as $file ) { |
|
351 | - $info = get_plugin_data( $file, false, false ); |
|
352 | - if ( ! empty( $info['Name'] ) ) { |
|
348 | + $files = glob($working_directory.'*.php'); |
|
349 | + if ($files) { |
|
350 | + foreach ($files as $file) { |
|
351 | + $info = get_plugin_data($file, false, false); |
|
352 | + if ( ! empty($info['Name'])) { |
|
353 | 353 | $plugins_found = true; |
354 | 354 | break; |
355 | 355 | } |
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - if ( ! $plugins_found ) |
|
360 | - return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); |
|
359 | + if ( ! $plugins_found) |
|
360 | + return new WP_Error('incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __('No valid plugins were found.')); |
|
361 | 361 | |
362 | 362 | return $source; |
363 | 363 | } |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | * @return string|false The full path to the main plugin file, or false. |
374 | 374 | */ |
375 | 375 | public function plugin_info() { |
376 | - if ( ! is_array($this->result) ) |
|
376 | + if ( ! is_array($this->result)) |
|
377 | 377 | return false; |
378 | - if ( empty($this->result['destination_name']) ) |
|
378 | + if (empty($this->result['destination_name'])) |
|
379 | 379 | return false; |
380 | 380 | |
381 | - $plugin = get_plugins('/' . $this->result['destination_name']); //Ensure to pass with leading slash |
|
382 | - if ( empty($plugin) ) |
|
381 | + $plugin = get_plugins('/'.$this->result['destination_name']); //Ensure to pass with leading slash |
|
382 | + if (empty($plugin)) |
|
383 | 383 | return false; |
384 | 384 | |
385 | 385 | $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list |
386 | 386 | |
387 | - return $this->result['destination_name'] . '/' . $pluginfiles[0]; |
|
387 | + return $this->result['destination_name'].'/'.$pluginfiles[0]; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -402,18 +402,18 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function deactivate_plugin_before_upgrade($return, $plugin) { |
404 | 404 | |
405 | - if ( is_wp_error($return) ) //Bypass. |
|
405 | + if (is_wp_error($return)) //Bypass. |
|
406 | 406 | return $return; |
407 | 407 | |
408 | 408 | // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it |
409 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) |
|
409 | + if (defined('DOING_CRON') && DOING_CRON) |
|
410 | 410 | return $return; |
411 | 411 | |
412 | 412 | $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
413 | - if ( empty($plugin) ) |
|
413 | + if (empty($plugin)) |
|
414 | 414 | return new WP_Error('bad_request', $this->strings['bad_request']); |
415 | 415 | |
416 | - if ( is_plugin_active($plugin) ) { |
|
416 | + if (is_plugin_active($plugin)) { |
|
417 | 417 | //Deactivate the plugin silently, Prevent deactivation hooks from running. |
418 | 418 | deactivate_plugins($plugin, true); |
419 | 419 | } |
@@ -441,26 +441,26 @@ discard block |
||
441 | 441 | public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { |
442 | 442 | global $wp_filesystem; |
443 | 443 | |
444 | - if ( is_wp_error($removed) ) |
|
444 | + if (is_wp_error($removed)) |
|
445 | 445 | return $removed; //Pass errors through. |
446 | 446 | |
447 | 447 | $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
448 | - if ( empty($plugin) ) |
|
448 | + if (empty($plugin)) |
|
449 | 449 | return new WP_Error('bad_request', $this->strings['bad_request']); |
450 | 450 | |
451 | 451 | $plugins_dir = $wp_filesystem->wp_plugins_dir(); |
452 | - $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) ); |
|
452 | + $this_plugin_dir = trailingslashit(dirname($plugins_dir.$plugin)); |
|
453 | 453 | |
454 | - if ( ! $wp_filesystem->exists($this_plugin_dir) ) //If it's already vanished. |
|
454 | + if ( ! $wp_filesystem->exists($this_plugin_dir)) //If it's already vanished. |
|
455 | 455 | return $removed; |
456 | 456 | |
457 | 457 | // If plugin is in its own directory, recursively delete the directory. |
458 | - if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
458 | + if (strpos($plugin, '/') && $this_plugin_dir != $plugins_dir) //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
459 | 459 | $deleted = $wp_filesystem->delete($this_plugin_dir, true); |
460 | 460 | else |
461 | - $deleted = $wp_filesystem->delete($plugins_dir . $plugin); |
|
461 | + $deleted = $wp_filesystem->delete($plugins_dir.$plugin); |
|
462 | 462 | |
463 | - if ( ! $deleted ) |
|
463 | + if ( ! $deleted) |
|
464 | 464 | return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']); |
465 | 465 | |
466 | 466 | return true; |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * |
18 | 18 | * @param string $class The type of the list table, which is the class name. |
19 | 19 | * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'. |
20 | - * @return object|bool Object on success, false if the class does not exist. |
|
20 | + * @return string Object on success, false if the class does not exist. |
|
21 | 21 | */ |
22 | 22 | function _get_list_table( $class, $args = array() ) { |
23 | 23 | $core_classes = array( |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'. |
20 | 20 | * @return object|bool Object on success, false if the class does not exist. |
21 | 21 | */ |
22 | -function _get_list_table( $class, $args = array() ) { |
|
22 | +function _get_list_table($class, $args = array()) { |
|
23 | 23 | $core_classes = array( |
24 | 24 | //Site Admin |
25 | 25 | 'WP_Posts_List_Table' => 'posts', |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | 'WP_Terms_List_Table' => 'terms', |
28 | 28 | 'WP_Users_List_Table' => 'users', |
29 | 29 | 'WP_Comments_List_Table' => 'comments', |
30 | - 'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ), |
|
30 | + 'WP_Post_Comments_List_Table' => array('comments', 'post-comments'), |
|
31 | 31 | 'WP_Links_List_Table' => 'links', |
32 | 32 | 'WP_Plugin_Install_List_Table' => 'plugin-install', |
33 | 33 | 'WP_Themes_List_Table' => 'themes', |
34 | - 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), |
|
34 | + 'WP_Theme_Install_List_Table' => array('themes', 'theme-install'), |
|
35 | 35 | 'WP_Plugins_List_Table' => 'plugins', |
36 | 36 | // Network Admin |
37 | 37 | 'WP_MS_Sites_List_Table' => 'ms-sites', |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | 'WP_MS_Themes_List_Table' => 'ms-themes', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( isset( $core_classes[ $class ] ) ) { |
|
43 | - foreach ( (array) $core_classes[ $class ] as $required ) |
|
44 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
|
42 | + if (isset($core_classes[$class])) { |
|
43 | + foreach ((array) $core_classes[$class] as $required) |
|
44 | + require_once(ABSPATH.'wp-admin/includes/class-wp-'.$required.'-list-table.php'); |
|
45 | 45 | |
46 | - if ( isset( $args['screen'] ) ) |
|
47 | - $args['screen'] = convert_to_screen( $args['screen'] ); |
|
48 | - elseif ( isset( $GLOBALS['hook_suffix'] ) ) |
|
46 | + if (isset($args['screen'])) |
|
47 | + $args['screen'] = convert_to_screen($args['screen']); |
|
48 | + elseif (isset($GLOBALS['hook_suffix'])) |
|
49 | 49 | $args['screen'] = get_current_screen(); |
50 | 50 | else |
51 | 51 | $args['screen'] = null; |
52 | 52 | |
53 | - return new $class( $args ); |
|
53 | + return new $class($args); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return false; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @see get_column_headers(), print_column_headers(), get_hidden_columns() |
67 | 67 | */ |
68 | 68 | function register_column_headers($screen, $columns) { |
69 | - new _WP_List_Table_Compat( $screen, $columns ); |
|
69 | + new _WP_List_Table_Compat($screen, $columns); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @param string|WP_Screen $screen The screen hook name or screen object. |
78 | 78 | * @param bool $with_id Whether to set the id attribute or not. |
79 | 79 | */ |
80 | -function print_column_headers( $screen, $with_id = true ) { |
|
80 | +function print_column_headers($screen, $with_id = true) { |
|
81 | 81 | $wp_list_table = new _WP_List_Table_Compat($screen); |
82 | 82 | |
83 | - $wp_list_table->print_column_headers( $with_id ); |
|
83 | + $wp_list_table->print_column_headers($with_id); |
|
84 | 84 | } |
@@ -40,15 +40,17 @@ |
||
40 | 40 | ); |
41 | 41 | |
42 | 42 | if ( isset( $core_classes[ $class ] ) ) { |
43 | - foreach ( (array) $core_classes[ $class ] as $required ) |
|
44 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
|
43 | + foreach ( (array) $core_classes[ $class ] as $required ) { |
|
44 | + require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
|
45 | + } |
|
45 | 46 | |
46 | - if ( isset( $args['screen'] ) ) |
|
47 | - $args['screen'] = convert_to_screen( $args['screen'] ); |
|
48 | - elseif ( isset( $GLOBALS['hook_suffix'] ) ) |
|
49 | - $args['screen'] = get_current_screen(); |
|
50 | - else |
|
51 | - $args['screen'] = null; |
|
47 | + if ( isset( $args['screen'] ) ) { |
|
48 | + $args['screen'] = convert_to_screen( $args['screen'] ); |
|
49 | + } elseif ( isset( $GLOBALS['hook_suffix'] ) ) { |
|
50 | + $args['screen'] = get_current_screen(); |
|
51 | + } else { |
|
52 | + $args['screen'] = null; |
|
53 | + } |
|
52 | 54 | |
53 | 55 | return new $class( $args ); |
54 | 56 | } |