@@ -44,16 +44,19 @@ discard block |
||
44 | 44 | public function prepare_items() { |
45 | 45 | $themes = wp_get_themes( array( 'allowed' => true ) ); |
46 | 46 | |
47 | - if ( ! empty( $_REQUEST['s'] ) ) |
|
48 | - $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); |
|
47 | + if ( ! empty( $_REQUEST['s'] ) ) { |
|
48 | + $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); |
|
49 | + } |
|
49 | 50 | |
50 | - if ( ! empty( $_REQUEST['features'] ) ) |
|
51 | - $this->features = $_REQUEST['features']; |
|
51 | + if ( ! empty( $_REQUEST['features'] ) ) { |
|
52 | + $this->features = $_REQUEST['features']; |
|
53 | + } |
|
52 | 54 | |
53 | 55 | if ( $this->search_terms || $this->features ) { |
54 | 56 | foreach ( $themes as $key => $theme ) { |
55 | - if ( ! $this->search_theme( $theme ) ) |
|
56 | - unset( $themes[ $key ] ); |
|
57 | + if ( ! $this->search_theme( $theme ) ) { |
|
58 | + unset( $themes[ $key ] ); |
|
59 | + } |
|
57 | 60 | } |
58 | 61 | } |
59 | 62 | |
@@ -109,8 +112,9 @@ discard block |
||
109 | 112 | * @param string $which |
110 | 113 | */ |
111 | 114 | public function tablenav( $which = 'top' ) { |
112 | - if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) |
|
113 | - return; |
|
115 | + if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) { |
|
116 | + return; |
|
117 | + } |
|
114 | 118 | ?> |
115 | 119 | <div class="tablenav themes <?php echo $which; ?>"> |
116 | 120 | <?php $this->pagination( $which ); ?> |
@@ -183,10 +187,11 @@ discard block |
||
183 | 187 | . __( 'Live Preview' ) . '</a>'; |
184 | 188 | } |
185 | 189 | |
186 | - if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) |
|
187 | - $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) |
|
190 | + if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) { |
|
191 | + $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) |
|
188 | 192 | . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ) |
189 | 193 | . "' );" . '">' . __( 'Delete' ) . '</a>'; |
194 | + } |
|
190 | 195 | |
191 | 196 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
192 | 197 | $actions = apply_filters( 'theme_action_links', $actions, $theme ); |
@@ -245,14 +250,16 @@ discard block |
||
245 | 250 | public function search_theme( $theme ) { |
246 | 251 | // Search the features |
247 | 252 | foreach ( $this->features as $word ) { |
248 | - if ( ! in_array( $word, $theme->get('Tags') ) ) |
|
249 | - return false; |
|
253 | + if ( ! in_array( $word, $theme->get('Tags') ) ) { |
|
254 | + return false; |
|
255 | + } |
|
250 | 256 | } |
251 | 257 | |
252 | 258 | // Match all phrases |
253 | 259 | foreach ( $this->search_terms as $word ) { |
254 | - if ( in_array( $word, $theme->get('Tags') ) ) |
|
255 | - continue; |
|
260 | + if ( in_array( $word, $theme->get('Tags') ) ) { |
|
261 | + continue; |
|
262 | + } |
|
256 | 263 | |
257 | 264 | foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { |
258 | 265 | // Don't mark up; Do translate. |
@@ -261,11 +268,13 @@ discard block |
||
261 | 268 | } |
262 | 269 | } |
263 | 270 | |
264 | - if ( false !== stripos( $theme->get_stylesheet(), $word ) ) |
|
265 | - continue; |
|
271 | + if ( false !== stripos( $theme->get_stylesheet(), $word ) ) { |
|
272 | + continue; |
|
273 | + } |
|
266 | 274 | |
267 | - if ( false !== stripos( $theme->get_template(), $word ) ) |
|
268 | - continue; |
|
275 | + if ( false !== stripos( $theme->get_template(), $word ) ) { |
|
276 | + continue; |
|
277 | + } |
|
269 | 278 | |
270 | 279 | return false; |
271 | 280 | } |
@@ -291,8 +300,9 @@ discard block |
||
291 | 300 | 'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1, |
292 | 301 | ); |
293 | 302 | |
294 | - if ( is_array( $extra_args ) ) |
|
295 | - $args = array_merge( $args, $extra_args ); |
|
303 | + if ( is_array( $extra_args ) ) { |
|
304 | + $args = array_merge( $args, $extra_args ); |
|
305 | + } |
|
296 | 306 | |
297 | 307 | printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) ); |
298 | 308 | parent::_js_vars(); |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @param array $args An associative array of arguments. |
32 | 32 | */ |
33 | - public function __construct( $args = array() ) { |
|
34 | - parent::__construct( array( |
|
33 | + public function __construct($args = array()) { |
|
34 | + parent::__construct(array( |
|
35 | 35 | 'ajax' => true, |
36 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
37 | - ) ); |
|
36 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
37 | + )); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,86 +43,86 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function ajax_user_can() { |
45 | 45 | // Do not check edit_theme_options here. Ajax calls for available themes require switch_themes. |
46 | - return current_user_can( 'switch_themes' ); |
|
46 | + return current_user_can('switch_themes'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @access public |
51 | 51 | */ |
52 | 52 | public function prepare_items() { |
53 | - $themes = wp_get_themes( array( 'allowed' => true ) ); |
|
53 | + $themes = wp_get_themes(array('allowed' => true)); |
|
54 | 54 | |
55 | - if ( ! empty( $_REQUEST['s'] ) ) |
|
56 | - $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); |
|
55 | + if ( ! empty($_REQUEST['s'])) |
|
56 | + $this->search_terms = array_unique(array_filter(array_map('trim', explode(',', strtolower(wp_unslash($_REQUEST['s'])))))); |
|
57 | 57 | |
58 | - if ( ! empty( $_REQUEST['features'] ) ) |
|
58 | + if ( ! empty($_REQUEST['features'])) |
|
59 | 59 | $this->features = $_REQUEST['features']; |
60 | 60 | |
61 | - if ( $this->search_terms || $this->features ) { |
|
62 | - foreach ( $themes as $key => $theme ) { |
|
63 | - if ( ! $this->search_theme( $theme ) ) |
|
64 | - unset( $themes[ $key ] ); |
|
61 | + if ($this->search_terms || $this->features) { |
|
62 | + foreach ($themes as $key => $theme) { |
|
63 | + if ( ! $this->search_theme($theme)) |
|
64 | + unset($themes[$key]); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - unset( $themes[ get_option( 'stylesheet' ) ] ); |
|
69 | - WP_Theme::sort_by_name( $themes ); |
|
68 | + unset($themes[get_option('stylesheet')]); |
|
69 | + WP_Theme::sort_by_name($themes); |
|
70 | 70 | |
71 | 71 | $per_page = 36; |
72 | 72 | $page = $this->get_pagenum(); |
73 | 73 | |
74 | - $start = ( $page - 1 ) * $per_page; |
|
74 | + $start = ($page - 1) * $per_page; |
|
75 | 75 | |
76 | - $this->items = array_slice( $themes, $start, $per_page, true ); |
|
76 | + $this->items = array_slice($themes, $start, $per_page, true); |
|
77 | 77 | |
78 | - $this->set_pagination_args( array( |
|
79 | - 'total_items' => count( $themes ), |
|
78 | + $this->set_pagination_args(array( |
|
79 | + 'total_items' => count($themes), |
|
80 | 80 | 'per_page' => $per_page, |
81 | 81 | 'infinite_scroll' => true, |
82 | - ) ); |
|
82 | + )); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @access public |
87 | 87 | */ |
88 | 88 | public function no_items() { |
89 | - if ( $this->search_terms || $this->features ) { |
|
90 | - _e( 'No items found.' ); |
|
89 | + if ($this->search_terms || $this->features) { |
|
90 | + _e('No items found.'); |
|
91 | 91 | return; |
92 | 92 | } |
93 | 93 | |
94 | 94 | $blog_id = get_current_blog_id(); |
95 | - if ( is_multisite() ) { |
|
96 | - if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { |
|
97 | - printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ), network_admin_url( 'theme-install.php' ) ); |
|
95 | + if (is_multisite()) { |
|
96 | + if (current_user_can('install_themes') && current_user_can('manage_network_themes')) { |
|
97 | + printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.'), network_admin_url('site-themes.php?id='.$blog_id), network_admin_url('theme-install.php')); |
|
98 | 98 | |
99 | 99 | return; |
100 | - } elseif ( current_user_can( 'manage_network_themes' ) ) { |
|
101 | - printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ) ); |
|
100 | + } elseif (current_user_can('manage_network_themes')) { |
|
101 | + printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.'), network_admin_url('site-themes.php?id='.$blog_id)); |
|
102 | 102 | |
103 | 103 | return; |
104 | 104 | } |
105 | 105 | // Else, fallthrough. install_themes doesn't help if you can't enable it. |
106 | 106 | } else { |
107 | - if ( current_user_can( 'install_themes' ) ) { |
|
108 | - printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), admin_url( 'theme-install.php' ) ); |
|
107 | + if (current_user_can('install_themes')) { |
|
108 | + printf(__('You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.'), admin_url('theme-install.php')); |
|
109 | 109 | |
110 | 110 | return; |
111 | 111 | } |
112 | 112 | } |
113 | 113 | // Fallthrough. |
114 | - printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) ); |
|
114 | + printf(__('Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.'), get_site_option('site_name')); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @param string $which |
119 | 119 | */ |
120 | - public function tablenav( $which = 'top' ) { |
|
121 | - if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) |
|
120 | + public function tablenav($which = 'top') { |
|
121 | + if ($this->get_pagination_arg('total_pages') <= 1) |
|
122 | 122 | return; |
123 | 123 | ?> |
124 | 124 | <div class="tablenav themes <?php echo $which; ?>"> |
125 | - <?php $this->pagination( $which ); ?> |
|
125 | + <?php $this->pagination($which); ?> |
|
126 | 126 | <span class="spinner"></span> |
127 | 127 | <br class="clear" /> |
128 | 128 | </div> |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | * @access public |
134 | 134 | */ |
135 | 135 | public function display() { |
136 | - wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); |
|
136 | + wp_nonce_field("fetch-list-".get_class($this), '_ajax_fetch_list_nonce'); |
|
137 | 137 | ?> |
138 | - <?php $this->tablenav( 'top' ); ?> |
|
138 | + <?php $this->tablenav('top'); ?> |
|
139 | 139 | |
140 | 140 | <div id="availablethemes"> |
141 | 141 | <?php $this->display_rows_or_placeholder(); ?> |
142 | 142 | </div> |
143 | 143 | |
144 | - <?php $this->tablenav( 'bottom' ); ?> |
|
144 | + <?php $this->tablenav('bottom'); ?> |
|
145 | 145 | <?php |
146 | 146 | } |
147 | 147 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @access public |
158 | 158 | */ |
159 | 159 | public function display_rows_or_placeholder() { |
160 | - if ( $this->has_items() ) { |
|
160 | + if ($this->has_items()) { |
|
161 | 161 | $this->display_rows(); |
162 | 162 | } else { |
163 | 163 | echo '<div class="no-items">'; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function display_rows() { |
173 | 173 | $themes = $this->items; |
174 | 174 | |
175 | - foreach ( $themes as $theme ): |
|
175 | + foreach ($themes as $theme): |
|
176 | 176 | ?><div class="available-theme"><?php |
177 | 177 | |
178 | 178 | $template = $theme->get_template(); |
@@ -181,64 +181,64 @@ discard block |
||
181 | 181 | $version = $theme->display('Version'); |
182 | 182 | $author = $theme->display('Author'); |
183 | 183 | |
184 | - $activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); |
|
184 | + $activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_'.$stylesheet); |
|
185 | 185 | |
186 | 186 | $actions = array(); |
187 | - $actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="' |
|
188 | - . esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>'; |
|
187 | + $actions['activate'] = '<a href="'.$activate_link.'" class="activatelink" title="' |
|
188 | + . esc_attr(sprintf(__('Activate “%s”'), $title)).'">'.__('Activate').'</a>'; |
|
189 | 189 | |
190 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
191 | - $actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="load-customize hide-if-no-customize">' |
|
192 | - . __( 'Live Preview' ) . '</a>'; |
|
190 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
191 | + $actions['preview'] .= '<a href="'.wp_customize_url($stylesheet).'" class="load-customize hide-if-no-customize">' |
|
192 | + . __('Live Preview').'</a>'; |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) |
|
196 | - $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) |
|
197 | - . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ) |
|
198 | - . "' );" . '">' . __( 'Delete' ) . '</a>'; |
|
195 | + if ( ! is_multisite() && current_user_can('delete_themes')) |
|
196 | + $actions['delete'] = '<a class="submitdelete deletion" href="'.wp_nonce_url('themes.php?action=delete&stylesheet='.urlencode($stylesheet), 'delete-theme_'.$stylesheet) |
|
197 | + . '" onclick="'."return confirm( '".esc_js(sprintf(__("You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete."), $title)) |
|
198 | + . "' );".'">'.__('Delete').'</a>'; |
|
199 | 199 | |
200 | 200 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
201 | - $actions = apply_filters( 'theme_action_links', $actions, $theme ); |
|
201 | + $actions = apply_filters('theme_action_links', $actions, $theme); |
|
202 | 202 | |
203 | 203 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
204 | - $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme ); |
|
205 | - $delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : ''; |
|
206 | - unset( $actions['delete'] ); |
|
204 | + $actions = apply_filters("theme_action_links_$stylesheet", $actions, $theme); |
|
205 | + $delete_action = isset($actions['delete']) ? '<div class="delete-theme">'.$actions['delete'].'</div>' : ''; |
|
206 | + unset($actions['delete']); |
|
207 | 207 | |
208 | 208 | ?> |
209 | 209 | |
210 | 210 | <span class="screenshot hide-if-customize"> |
211 | - <?php if ( $screenshot = $theme->get_screenshot() ) : ?> |
|
212 | - <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
|
211 | + <?php if ($screenshot = $theme->get_screenshot()) : ?> |
|
212 | + <img src="<?php echo esc_url($screenshot); ?>" alt="" /> |
|
213 | 213 | <?php endif; ?> |
214 | 214 | </span> |
215 | - <a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize"> |
|
216 | - <?php if ( $screenshot = $theme->get_screenshot() ) : ?> |
|
217 | - <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
|
215 | + <a href="<?php echo wp_customize_url($stylesheet); ?>" class="screenshot load-customize hide-if-no-customize"> |
|
216 | + <?php if ($screenshot = $theme->get_screenshot()) : ?> |
|
217 | + <img src="<?php echo esc_url($screenshot); ?>" alt="" /> |
|
218 | 218 | <?php endif; ?> |
219 | 219 | </a> |
220 | 220 | |
221 | 221 | <h3><?php echo $title; ?></h3> |
222 | - <div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div> |
|
222 | + <div class="theme-author"><?php printf(__('By %s'), $author); ?></div> |
|
223 | 223 | <div class="action-links"> |
224 | 224 | <ul> |
225 | - <?php foreach ( $actions as $action ): ?> |
|
225 | + <?php foreach ($actions as $action): ?> |
|
226 | 226 | <li><?php echo $action; ?></li> |
227 | 227 | <?php endforeach; ?> |
228 | 228 | <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details') ?></a></li> |
229 | 229 | </ul> |
230 | 230 | <?php echo $delete_action; ?> |
231 | 231 | |
232 | - <?php theme_update_available( $theme ); ?> |
|
232 | + <?php theme_update_available($theme); ?> |
|
233 | 233 | </div> |
234 | 234 | |
235 | 235 | <div class="themedetaildiv hide-if-js"> |
236 | 236 | <p><strong><?php _e('Version:'); ?></strong> <?php echo $version; ?></p> |
237 | 237 | <p><?php echo $theme->display('Description'); ?></p> |
238 | - <?php if ( $theme->parent() ) { |
|
239 | - printf( ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>', |
|
240 | - __( 'https://codex.wordpress.org/Child_Themes' ), |
|
241 | - $theme->parent()->display( 'Name' ) ); |
|
238 | + <?php if ($theme->parent()) { |
|
239 | + printf(' <p class="howto">'.__('This <a href="%1$s">child theme</a> requires its parent theme, %2$s.').'</p>', |
|
240 | + __('https://codex.wordpress.org/Child_Themes'), |
|
241 | + $theme->parent()->display('Name')); |
|
242 | 242 | } ?> |
243 | 243 | </div> |
244 | 244 | |
@@ -251,29 +251,29 @@ discard block |
||
251 | 251 | * @param WP_Theme $theme |
252 | 252 | * @return bool |
253 | 253 | */ |
254 | - public function search_theme( $theme ) { |
|
254 | + public function search_theme($theme) { |
|
255 | 255 | // Search the features |
256 | - foreach ( $this->features as $word ) { |
|
257 | - if ( ! in_array( $word, $theme->get('Tags') ) ) |
|
256 | + foreach ($this->features as $word) { |
|
257 | + if ( ! in_array($word, $theme->get('Tags'))) |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | |
261 | 261 | // Match all phrases |
262 | - foreach ( $this->search_terms as $word ) { |
|
263 | - if ( in_array( $word, $theme->get('Tags') ) ) |
|
262 | + foreach ($this->search_terms as $word) { |
|
263 | + if (in_array($word, $theme->get('Tags'))) |
|
264 | 264 | continue; |
265 | 265 | |
266 | - foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { |
|
266 | + foreach (array('Name', 'Description', 'Author', 'AuthorURI') as $header) { |
|
267 | 267 | // Don't mark up; Do translate. |
268 | - if ( false !== stripos( strip_tags( $theme->display( $header, false, true ) ), $word ) ) { |
|
268 | + if (false !== stripos(strip_tags($theme->display($header, false, true)), $word)) { |
|
269 | 269 | continue 2; |
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | - if ( false !== stripos( $theme->get_stylesheet(), $word ) ) |
|
273 | + if (false !== stripos($theme->get_stylesheet(), $word)) |
|
274 | 274 | continue; |
275 | 275 | |
276 | - if ( false !== stripos( $theme->get_template(), $word ) ) |
|
276 | + if (false !== stripos($theme->get_template(), $word)) |
|
277 | 277 | continue; |
278 | 278 | |
279 | 279 | return false; |
@@ -290,20 +290,20 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param array $extra_args |
292 | 292 | */ |
293 | - public function _js_vars( $extra_args = array() ) { |
|
294 | - $search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
293 | + public function _js_vars($extra_args = array()) { |
|
294 | + $search_string = isset($_REQUEST['s']) ? esc_attr(wp_unslash($_REQUEST['s'])) : ''; |
|
295 | 295 | |
296 | 296 | $args = array( |
297 | 297 | 'search' => $search_string, |
298 | 298 | 'features' => $this->features, |
299 | 299 | 'paged' => $this->get_pagenum(), |
300 | - 'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1, |
|
300 | + 'total_pages' => ! empty($this->_pagination_args['total_pages']) ? $this->_pagination_args['total_pages'] : 1, |
|
301 | 301 | ); |
302 | 302 | |
303 | - if ( is_array( $extra_args ) ) |
|
304 | - $args = array_merge( $args, $extra_args ); |
|
303 | + if (is_array($extra_args)) |
|
304 | + $args = array_merge($args, $extra_args); |
|
305 | 305 | |
306 | - printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) ); |
|
306 | + printf("<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode($args)); |
|
307 | 307 | parent::_js_vars(); |
308 | 308 | } |
309 | 309 | } |
@@ -1039,7 +1039,7 @@ |
||
1039 | 1039 | * @since 4.2.0 |
1040 | 1040 | * @access public |
1041 | 1041 | * |
1042 | - * @param array $data The site's data. |
|
1042 | + * @param array $data The site's data. |
|
1043 | 1043 | * @return string Discovered canonical URL, or empty |
1044 | 1044 | */ |
1045 | 1045 | public function get_canonical_link( $data ) { |
@@ -449,8 +449,9 @@ |
||
449 | 449 | private function _limit_embed( $src ) { |
450 | 450 | $src = $this->_limit_url( $src ); |
451 | 451 | |
452 | - if ( empty( $src ) ) |
|
453 | - return ''; |
|
452 | + if ( empty( $src ) ) { |
|
453 | + return ''; |
|
454 | + } |
|
454 | 455 | |
455 | 456 | if ( preg_match( '/\/\/(m|www)\.youtube\.com\/(embed|v)\/([^\?]+)\?.+$/', $src, $src_matches ) ) { |
456 | 457 | // Embedded Youtube videos (www or mobile) |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @param bool $redirect Whether to redirect in parent window or not. Default false. |
50 | 50 | */ |
51 | - 'redirInParent' => apply_filters( 'press_this_redirect_in_parent', false ), |
|
51 | + 'redirInParent' => apply_filters('press_this_redirect_in_parent', false), |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
@@ -62,37 +62,37 @@ discard block |
||
62 | 62 | * @param string $content Optional. Current expected markup for Press This. Expects slashed. Default empty. |
63 | 63 | * @return string New markup with old image URLs replaced with the local attachment ones if swapped. |
64 | 64 | */ |
65 | - public function side_load_images( $post_id, $content = '' ) { |
|
66 | - $content = wp_unslash( $content ); |
|
65 | + public function side_load_images($post_id, $content = '') { |
|
66 | + $content = wp_unslash($content); |
|
67 | 67 | |
68 | - if ( preg_match_all( '/<img [^>]+>/', $content, $matches ) && current_user_can( 'upload_files' ) ) { |
|
69 | - foreach ( (array) $matches[0] as $image ) { |
|
68 | + if (preg_match_all('/<img [^>]+>/', $content, $matches) && current_user_can('upload_files')) { |
|
69 | + foreach ((array) $matches[0] as $image) { |
|
70 | 70 | // This is inserted from our JS so HTML attributes should always be in double quotes. |
71 | - if ( ! preg_match( '/src="([^"]+)"/', $image, $url_matches ) ) { |
|
71 | + if ( ! preg_match('/src="([^"]+)"/', $image, $url_matches)) { |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $image_src = $url_matches[1]; |
76 | 76 | |
77 | 77 | // Don't try to sideload a file without a file extension, leads to WP upload error. |
78 | - if ( ! preg_match( '/[^\?]+\.(?:jpe?g|jpe|gif|png)(?:\?|$)/i', $image_src ) ) { |
|
78 | + if ( ! preg_match('/[^\?]+\.(?:jpe?g|jpe|gif|png)(?:\?|$)/i', $image_src)) { |
|
79 | 79 | continue; |
80 | 80 | } |
81 | 81 | |
82 | 82 | // Sideload image, which gives us a new image src. |
83 | - $new_src = media_sideload_image( $image_src, $post_id, null, 'src' ); |
|
83 | + $new_src = media_sideload_image($image_src, $post_id, null, 'src'); |
|
84 | 84 | |
85 | - if ( ! is_wp_error( $new_src ) ) { |
|
85 | + if ( ! is_wp_error($new_src)) { |
|
86 | 86 | // Replace the POSTED content <img> with correct uploaded ones. |
87 | 87 | // Need to do it in two steps so we don't replace links to the original image if any. |
88 | - $new_image = str_replace( $image_src, $new_src, $image ); |
|
89 | - $content = str_replace( $image, $new_image, $content ); |
|
88 | + $new_image = str_replace($image_src, $new_src, $image); |
|
89 | + $content = str_replace($image, $new_image, $content); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Expected slashed |
95 | - return wp_slash( $content ); |
|
95 | + return wp_slash($content); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,36 +102,36 @@ discard block |
||
102 | 102 | * @access public |
103 | 103 | */ |
104 | 104 | public function save_post() { |
105 | - if ( empty( $_POST['post_ID'] ) || ! $post_id = (int) $_POST['post_ID'] ) { |
|
106 | - wp_send_json_error( array( 'errorMessage' => __( 'Missing post ID.' ) ) ); |
|
105 | + if (empty($_POST['post_ID']) || ! $post_id = (int) $_POST['post_ID']) { |
|
106 | + wp_send_json_error(array('errorMessage' => __('Missing post ID.'))); |
|
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-post_' . $post_id ) || |
|
110 | - ! current_user_can( 'edit_post', $post_id ) ) { |
|
109 | + if (empty($_POST['_wpnonce']) || ! wp_verify_nonce($_POST['_wpnonce'], 'update-post_'.$post_id) || |
|
110 | + ! current_user_can('edit_post', $post_id)) { |
|
111 | 111 | |
112 | - wp_send_json_error( array( 'errorMessage' => __( 'Invalid post.' ) ) ); |
|
112 | + wp_send_json_error(array('errorMessage' => __('Invalid post.'))); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $post_data = array( |
116 | 116 | 'ID' => $post_id, |
117 | - 'post_title' => ( ! empty( $_POST['post_title'] ) ) ? sanitize_text_field( trim( $_POST['post_title'] ) ) : '', |
|
118 | - 'post_content' => ( ! empty( $_POST['post_content'] ) ) ? trim( $_POST['post_content'] ) : '', |
|
117 | + 'post_title' => ( ! empty($_POST['post_title'])) ? sanitize_text_field(trim($_POST['post_title'])) : '', |
|
118 | + 'post_content' => ( ! empty($_POST['post_content'])) ? trim($_POST['post_content']) : '', |
|
119 | 119 | 'post_type' => 'post', |
120 | 120 | 'post_status' => 'draft', |
121 | - 'post_format' => ( ! empty( $_POST['post_format'] ) ) ? sanitize_text_field( $_POST['post_format'] ) : '', |
|
122 | - 'tax_input' => ( ! empty( $_POST['tax_input'] ) ) ? $_POST['tax_input'] : array(), |
|
123 | - 'post_category' => ( ! empty( $_POST['post_category'] ) ) ? $_POST['post_category'] : array(), |
|
121 | + 'post_format' => ( ! empty($_POST['post_format'])) ? sanitize_text_field($_POST['post_format']) : '', |
|
122 | + 'tax_input' => ( ! empty($_POST['tax_input'])) ? $_POST['tax_input'] : array(), |
|
123 | + 'post_category' => ( ! empty($_POST['post_category'])) ? $_POST['post_category'] : array(), |
|
124 | 124 | ); |
125 | 125 | |
126 | - if ( ! empty( $_POST['post_status'] ) && 'publish' === $_POST['post_status'] ) { |
|
127 | - if ( current_user_can( 'publish_posts' ) ) { |
|
126 | + if ( ! empty($_POST['post_status']) && 'publish' === $_POST['post_status']) { |
|
127 | + if (current_user_can('publish_posts')) { |
|
128 | 128 | $post_data['post_status'] = 'publish'; |
129 | 129 | } else { |
130 | 130 | $post_data['post_status'] = 'pending'; |
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - $post_data['post_content'] = $this->side_load_images( $post_id, $post_data['post_content'] ); |
|
134 | + $post_data['post_content'] = $this->side_load_images($post_id, $post_data['post_content']); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Filters the post data of a Press This post before saving/updating. |
@@ -142,28 +142,28 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @param array $post_data The post data. |
144 | 144 | */ |
145 | - $post_data = apply_filters( 'press_this_save_post', $post_data ); |
|
145 | + $post_data = apply_filters('press_this_save_post', $post_data); |
|
146 | 146 | |
147 | - $updated = wp_update_post( $post_data, true ); |
|
147 | + $updated = wp_update_post($post_data, true); |
|
148 | 148 | |
149 | - if ( is_wp_error( $updated ) ) { |
|
150 | - wp_send_json_error( array( 'errorMessage' => $updated->get_error_message() ) ); |
|
149 | + if (is_wp_error($updated)) { |
|
150 | + wp_send_json_error(array('errorMessage' => $updated->get_error_message())); |
|
151 | 151 | } else { |
152 | - if ( isset( $post_data['post_format'] ) ) { |
|
153 | - if ( current_theme_supports( 'post-formats', $post_data['post_format'] ) ) { |
|
154 | - set_post_format( $post_id, $post_data['post_format'] ); |
|
155 | - } elseif ( $post_data['post_format'] ) { |
|
156 | - set_post_format( $post_id, false ); |
|
152 | + if (isset($post_data['post_format'])) { |
|
153 | + if (current_theme_supports('post-formats', $post_data['post_format'])) { |
|
154 | + set_post_format($post_id, $post_data['post_format']); |
|
155 | + } elseif ($post_data['post_format']) { |
|
156 | + set_post_format($post_id, false); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | 160 | $forceRedirect = false; |
161 | 161 | |
162 | - if ( 'publish' === get_post_status( $post_id ) ) { |
|
163 | - $redirect = get_post_permalink( $post_id ); |
|
164 | - } elseif ( isset( $_POST['pt-force-redirect'] ) && $_POST['pt-force-redirect'] === 'true' ) { |
|
162 | + if ('publish' === get_post_status($post_id)) { |
|
163 | + $redirect = get_post_permalink($post_id); |
|
164 | + } elseif (isset($_POST['pt-force-redirect']) && $_POST['pt-force-redirect'] === 'true') { |
|
165 | 165 | $forceRedirect = true; |
166 | - $redirect = get_edit_post_link( $post_id, 'js' ); |
|
166 | + $redirect = get_edit_post_link($post_id, 'js'); |
|
167 | 167 | } else { |
168 | 168 | $redirect = false; |
169 | 169 | } |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | * @param int $post_id Post ID. |
179 | 179 | * @param string $status Post status. |
180 | 180 | */ |
181 | - $redirect = apply_filters( 'press_this_save_redirect', $redirect, $post_id, $post_data['post_status'] ); |
|
181 | + $redirect = apply_filters('press_this_save_redirect', $redirect, $post_id, $post_data['post_status']); |
|
182 | 182 | |
183 | - if ( $redirect ) { |
|
184 | - wp_send_json_success( array( 'redirect' => $redirect, 'force' => $forceRedirect ) ); |
|
183 | + if ($redirect) { |
|
184 | + wp_send_json_success(array('redirect' => $redirect, 'force' => $forceRedirect)); |
|
185 | 185 | } else { |
186 | - wp_send_json_success( array( 'postSaved' => true ) ); |
|
186 | + wp_send_json_success(array('postSaved' => true)); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | } |
@@ -195,57 +195,57 @@ discard block |
||
195 | 195 | * @access public |
196 | 196 | */ |
197 | 197 | public function add_category() { |
198 | - if ( false === wp_verify_nonce( $_POST['new_cat_nonce'], 'add-category' ) ) { |
|
198 | + if (false === wp_verify_nonce($_POST['new_cat_nonce'], 'add-category')) { |
|
199 | 199 | wp_send_json_error(); |
200 | 200 | } |
201 | 201 | |
202 | - $taxonomy = get_taxonomy( 'category' ); |
|
202 | + $taxonomy = get_taxonomy('category'); |
|
203 | 203 | |
204 | - if ( ! current_user_can( $taxonomy->cap->edit_terms ) || empty( $_POST['name'] ) ) { |
|
204 | + if ( ! current_user_can($taxonomy->cap->edit_terms) || empty($_POST['name'])) { |
|
205 | 205 | wp_send_json_error(); |
206 | 206 | } |
207 | 207 | |
208 | - $parent = isset( $_POST['parent'] ) && (int) $_POST['parent'] > 0 ? (int) $_POST['parent'] : 0; |
|
209 | - $names = explode( ',', $_POST['name'] ); |
|
208 | + $parent = isset($_POST['parent']) && (int) $_POST['parent'] > 0 ? (int) $_POST['parent'] : 0; |
|
209 | + $names = explode(',', $_POST['name']); |
|
210 | 210 | $added = $data = array(); |
211 | 211 | |
212 | - foreach ( $names as $cat_name ) { |
|
213 | - $cat_name = trim( $cat_name ); |
|
214 | - $cat_nicename = sanitize_title( $cat_name ); |
|
212 | + foreach ($names as $cat_name) { |
|
213 | + $cat_name = trim($cat_name); |
|
214 | + $cat_nicename = sanitize_title($cat_name); |
|
215 | 215 | |
216 | - if ( empty( $cat_nicename ) ) { |
|
216 | + if (empty($cat_nicename)) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // @todo Find a more performant way to check existence, maybe get_term() with a separate parent check. |
221 | - if ( term_exists( $cat_name, $taxonomy->name, $parent ) ) { |
|
222 | - if ( count( $names ) === 1 ) { |
|
223 | - wp_send_json_error( array( 'errorMessage' => __( 'This category already exists.' ) ) ); |
|
221 | + if (term_exists($cat_name, $taxonomy->name, $parent)) { |
|
222 | + if (count($names) === 1) { |
|
223 | + wp_send_json_error(array('errorMessage' => __('This category already exists.'))); |
|
224 | 224 | } else { |
225 | 225 | continue; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); |
|
229 | + $cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent)); |
|
230 | 230 | |
231 | - if ( is_wp_error( $cat_id ) ) { |
|
231 | + if (is_wp_error($cat_id)) { |
|
232 | 232 | continue; |
233 | - } elseif ( is_array( $cat_id ) ) { |
|
233 | + } elseif (is_array($cat_id)) { |
|
234 | 234 | $cat_id = $cat_id['term_id']; |
235 | 235 | } |
236 | 236 | |
237 | 237 | $added[] = $cat_id; |
238 | 238 | } |
239 | 239 | |
240 | - if ( empty( $added ) ) { |
|
241 | - wp_send_json_error( array( 'errorMessage' => __( 'This category cannot be added. Please change the name and try again.' ) ) ); |
|
240 | + if (empty($added)) { |
|
241 | + wp_send_json_error(array('errorMessage' => __('This category cannot be added. Please change the name and try again.'))); |
|
242 | 242 | } |
243 | 243 | |
244 | - foreach ( $added as $new_cat_id ) { |
|
245 | - $new_cat = get_category( $new_cat_id ); |
|
244 | + foreach ($added as $new_cat_id) { |
|
245 | + $new_cat = get_category($new_cat_id); |
|
246 | 246 | |
247 | - if ( is_wp_error( $new_cat ) ) { |
|
248 | - wp_send_json_error( array( 'errorMessage' => __( 'Error while adding the category. Please try again later.' ) ) ); |
|
247 | + if (is_wp_error($new_cat)) { |
|
248 | + wp_send_json_error(array('errorMessage' => __('Error while adding the category. Please try again later.'))); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | $data[] = array( |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | 'parent' => $new_cat->parent, |
255 | 255 | ); |
256 | 256 | } |
257 | - wp_send_json_success( $data ); |
|
257 | + wp_send_json_success($data); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -266,18 +266,18 @@ discard block |
||
266 | 266 | * @param string $url URL to scan. |
267 | 267 | * @return string Source's HTML sanitized markup |
268 | 268 | */ |
269 | - public function fetch_source_html( $url ) { |
|
270 | - if ( empty( $url ) ) { |
|
271 | - return new WP_Error( 'invalid-url', __( 'A valid URL was not provided.' ) ); |
|
269 | + public function fetch_source_html($url) { |
|
270 | + if (empty($url)) { |
|
271 | + return new WP_Error('invalid-url', __('A valid URL was not provided.')); |
|
272 | 272 | } |
273 | 273 | |
274 | - $remote_url = wp_safe_remote_get( $url, array( |
|
274 | + $remote_url = wp_safe_remote_get($url, array( |
|
275 | 275 | 'timeout' => 30, |
276 | 276 | // Use an explicit user-agent for Press This |
277 | - 'user-agent' => 'Press This (WordPress/' . get_bloginfo( 'version' ) . '); ' . get_bloginfo( 'url' ) |
|
278 | - ) ); |
|
277 | + 'user-agent' => 'Press This (WordPress/'.get_bloginfo('version').'); '.get_bloginfo('url') |
|
278 | + )); |
|
279 | 279 | |
280 | - if ( is_wp_error( $remote_url ) ) { |
|
280 | + if (is_wp_error($remote_url)) { |
|
281 | 281 | return $remote_url; |
282 | 282 | } |
283 | 283 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | ) |
303 | 303 | ); |
304 | 304 | |
305 | - $source_content = wp_remote_retrieve_body( $remote_url ); |
|
306 | - $source_content = wp_kses( $source_content, $allowed_elements ); |
|
305 | + $source_content = wp_remote_retrieve_body($remote_url); |
|
306 | + $source_content = wp_kses($source_content, $allowed_elements); |
|
307 | 307 | |
308 | 308 | return $source_content; |
309 | 309 | } |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | * @param array $value Array to limit. |
318 | 318 | * @return array Original array if fewer than 50 values, limited array, empty array otherwise. |
319 | 319 | */ |
320 | - private function _limit_array( $value ) { |
|
321 | - if ( is_array( $value ) ) { |
|
322 | - if ( count( $value ) > 50 ) { |
|
323 | - return array_slice( $value, 0, 50 ); |
|
320 | + private function _limit_array($value) { |
|
321 | + if (is_array($value)) { |
|
322 | + if (count($value) > 50) { |
|
323 | + return array_slice($value, 0, 50); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $value; |
@@ -340,20 +340,20 @@ discard block |
||
340 | 340 | * if fewer than 5,000 characters, a truncated version, otherwise an |
341 | 341 | * empty string. |
342 | 342 | */ |
343 | - private function _limit_string( $value ) { |
|
343 | + private function _limit_string($value) { |
|
344 | 344 | $return = ''; |
345 | 345 | |
346 | - if ( is_numeric( $value ) || is_bool( $value ) ) { |
|
346 | + if (is_numeric($value) || is_bool($value)) { |
|
347 | 347 | $return = $value; |
348 | - } else if ( is_string( $value ) ) { |
|
349 | - if ( mb_strlen( $value ) > 5000 ) { |
|
350 | - $return = mb_substr( $value, 0, 5000 ); |
|
348 | + } else if (is_string($value)) { |
|
349 | + if (mb_strlen($value) > 5000) { |
|
350 | + $return = mb_substr($value, 0, 5000); |
|
351 | 351 | } else { |
352 | 352 | $return = $value; |
353 | 353 | } |
354 | 354 | |
355 | - $return = html_entity_decode( $return, ENT_QUOTES, 'UTF-8' ); |
|
356 | - $return = sanitize_text_field( trim( $return ) ); |
|
355 | + $return = html_entity_decode($return, ENT_QUOTES, 'UTF-8'); |
|
356 | + $return = sanitize_text_field(trim($return)); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | return $return; |
@@ -368,32 +368,32 @@ discard block |
||
368 | 368 | * @param string $url URL to check for length and validity. |
369 | 369 | * @return string Escaped URL if of valid length (< 2048) and makeup. Empty string otherwise. |
370 | 370 | */ |
371 | - private function _limit_url( $url ) { |
|
372 | - if ( ! is_string( $url ) ) { |
|
371 | + private function _limit_url($url) { |
|
372 | + if ( ! is_string($url)) { |
|
373 | 373 | return ''; |
374 | 374 | } |
375 | 375 | |
376 | 376 | // HTTP 1.1 allows 8000 chars but the "de-facto" standard supported in all current browsers is 2048. |
377 | - if ( strlen( $url ) > 2048 ) { |
|
377 | + if (strlen($url) > 2048) { |
|
378 | 378 | return ''; // Return empty rather than a truncated/invalid URL |
379 | 379 | } |
380 | 380 | |
381 | 381 | // Does not look like a URL. |
382 | - if ( ! preg_match( '/^([!#$&-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/', $url ) ) { |
|
382 | + if ( ! preg_match('/^([!#$&-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/', $url)) { |
|
383 | 383 | return ''; |
384 | 384 | } |
385 | 385 | |
386 | 386 | // If the URL is root-relative, prepend the protocol and domain name |
387 | - if ( $url && $this->domain && preg_match( '%^/[^/]+%', $url ) ) { |
|
388 | - $url = $this->domain . $url; |
|
387 | + if ($url && $this->domain && preg_match('%^/[^/]+%', $url)) { |
|
388 | + $url = $this->domain.$url; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | // Not absolute or protocol-relative URL. |
392 | - if ( ! preg_match( '%^(?:https?:)?//[^/]+%', $url ) ) { |
|
392 | + if ( ! preg_match('%^(?:https?:)?//[^/]+%', $url)) { |
|
393 | 393 | return ''; |
394 | 394 | } |
395 | 395 | |
396 | - return esc_url_raw( $url, array( 'http', 'https' ) ); |
|
396 | + return esc_url_raw($url, array('http', 'https')); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -408,34 +408,34 @@ discard block |
||
408 | 408 | * @param string $src Image source URL. |
409 | 409 | * @return string If not matched an excluded URL type, the original URL, empty string otherwise. |
410 | 410 | */ |
411 | - private function _limit_img( $src ) { |
|
412 | - $src = $this->_limit_url( $src ); |
|
411 | + private function _limit_img($src) { |
|
412 | + $src = $this->_limit_url($src); |
|
413 | 413 | |
414 | - if ( preg_match( '!/ad[sx]?/!i', $src ) ) { |
|
414 | + if (preg_match('!/ad[sx]?/!i', $src)) { |
|
415 | 415 | // Ads |
416 | 416 | return ''; |
417 | - } else if ( preg_match( '!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src ) ) { |
|
417 | + } else if (preg_match('!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src)) { |
|
418 | 418 | // Share-this type button |
419 | 419 | return ''; |
420 | - } else if ( preg_match( '!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src ) ) { |
|
420 | + } else if (preg_match('!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src)) { |
|
421 | 421 | // Loaders, spinners, spacers |
422 | 422 | return ''; |
423 | - } else if ( preg_match( '!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src ) ) { |
|
423 | + } else if (preg_match('!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src)) { |
|
424 | 424 | // Fancy loaders, spinners, spacers |
425 | 425 | return ''; |
426 | - } else if ( preg_match( '!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src ) ) { |
|
426 | + } else if (preg_match('!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src)) { |
|
427 | 427 | // Thumbnails, too small, usually irrelevant to context |
428 | 428 | return ''; |
429 | - } else if ( false !== stripos( $src, '/wp-includes/' ) ) { |
|
429 | + } else if (false !== stripos($src, '/wp-includes/')) { |
|
430 | 430 | // Classic WordPress interface images |
431 | 431 | return ''; |
432 | - } else if ( preg_match( '![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src ) ) { |
|
432 | + } else if (preg_match('![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src)) { |
|
433 | 433 | // Most often tiny buttons/thumbs (< 100px wide) |
434 | 434 | return ''; |
435 | - } else if ( preg_match( '!/pixel\.(mathtag|quantserve)\.com!i', $src ) ) { |
|
435 | + } else if (preg_match('!/pixel\.(mathtag|quantserve)\.com!i', $src)) { |
|
436 | 436 | // See mathtag.com and https://www.quantcast.com/how-we-do-it/iab-standard-measurement/how-we-collect-data/ |
437 | 437 | return ''; |
438 | - } else if ( preg_match( '!/[gb]\.gif(\?.+)?$!i', $src ) ) { |
|
438 | + } else if (preg_match('!/[gb]\.gif(\?.+)?$!i', $src)) { |
|
439 | 439 | // WordPress.com stats gif |
440 | 440 | return ''; |
441 | 441 | } |
@@ -455,31 +455,31 @@ discard block |
||
455 | 455 | * @param string $src Embed source URL. |
456 | 456 | * @return string If not from a supported provider, an empty string. Otherwise, a reformattd embed URL. |
457 | 457 | */ |
458 | - private function _limit_embed( $src ) { |
|
459 | - $src = $this->_limit_url( $src ); |
|
458 | + private function _limit_embed($src) { |
|
459 | + $src = $this->_limit_url($src); |
|
460 | 460 | |
461 | - if ( empty( $src ) ) |
|
461 | + if (empty($src)) |
|
462 | 462 | return ''; |
463 | 463 | |
464 | - if ( preg_match( '!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches ) ) { |
|
464 | + if (preg_match('!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches)) { |
|
465 | 465 | // Embedded Youtube videos (www or mobile) |
466 | - $src = 'https://www.youtube.com/watch?v=' . $src_matches[3]; |
|
467 | - } else if ( preg_match( '!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches ) ) { |
|
466 | + $src = 'https://www.youtube.com/watch?v='.$src_matches[3]; |
|
467 | + } else if (preg_match('!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches)) { |
|
468 | 468 | // Embedded Vimeo iframe videos |
469 | - $src = 'https://vimeo.com/' . (int) $src_matches[1]; |
|
470 | - } else if ( preg_match( '!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches ) ) { |
|
469 | + $src = 'https://vimeo.com/'.(int) $src_matches[1]; |
|
470 | + } else if (preg_match('!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches)) { |
|
471 | 471 | // Embedded Vimeo Flash videos |
472 | - $src = 'https://vimeo.com/' . (int) $src_matches[1]; |
|
473 | - } else if ( preg_match( '!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches ) ) { |
|
472 | + $src = 'https://vimeo.com/'.(int) $src_matches[1]; |
|
473 | + } else if (preg_match('!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches)) { |
|
474 | 474 | // Embedded Vine videos |
475 | - $src = 'https://vine.co/v/' . $src_matches[1]; |
|
476 | - } else if ( preg_match( '!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches ) ) { |
|
475 | + $src = 'https://vine.co/v/'.$src_matches[1]; |
|
476 | + } else if (preg_match('!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches)) { |
|
477 | 477 | // Embedded Daily Motion videos |
478 | - $src = 'https://www.dailymotion.com/video/' . $src_matches[2]; |
|
478 | + $src = 'https://www.dailymotion.com/video/'.$src_matches[2]; |
|
479 | 479 | } else { |
480 | 480 | $oembed = _wp_oembed_get_object(); |
481 | 481 | |
482 | - if ( ! $oembed->get_provider( $src, array( 'discover' => false ) ) ) { |
|
482 | + if ( ! $oembed->get_provider($src, array('discover' => false))) { |
|
483 | 483 | $src = ''; |
484 | 484 | } |
485 | 485 | } |
@@ -498,21 +498,21 @@ discard block |
||
498 | 498 | * @param array $data Associative array of source data. |
499 | 499 | * @return array Processed data array. |
500 | 500 | */ |
501 | - private function _process_meta_entry( $meta_name, $meta_value, $data ) { |
|
502 | - if ( preg_match( '/:?(title|description|keywords|site_name)$/', $meta_name ) ) { |
|
503 | - $data['_meta'][ $meta_name ] = $meta_value; |
|
501 | + private function _process_meta_entry($meta_name, $meta_value, $data) { |
|
502 | + if (preg_match('/:?(title|description|keywords|site_name)$/', $meta_name)) { |
|
503 | + $data['_meta'][$meta_name] = $meta_value; |
|
504 | 504 | } else { |
505 | - switch ( $meta_name ) { |
|
505 | + switch ($meta_name) { |
|
506 | 506 | case 'og:url': |
507 | 507 | case 'og:video': |
508 | 508 | case 'og:video:secure_url': |
509 | - $meta_value = $this->_limit_embed( $meta_value ); |
|
509 | + $meta_value = $this->_limit_embed($meta_value); |
|
510 | 510 | |
511 | - if ( ! isset( $data['_embeds'] ) ) { |
|
511 | + if ( ! isset($data['_embeds'])) { |
|
512 | 512 | $data['_embeds'] = array(); |
513 | 513 | } |
514 | 514 | |
515 | - if ( ! empty( $meta_value ) && ! in_array( $meta_value, $data['_embeds'] ) ) { |
|
515 | + if ( ! empty($meta_value) && ! in_array($meta_value, $data['_embeds'])) { |
|
516 | 516 | $data['_embeds'][] = $meta_value; |
517 | 517 | } |
518 | 518 | |
@@ -523,13 +523,13 @@ discard block |
||
523 | 523 | case 'twitter:image0': |
524 | 524 | case 'twitter:image:src': |
525 | 525 | case 'twitter:image': |
526 | - $meta_value = $this->_limit_img( $meta_value ); |
|
526 | + $meta_value = $this->_limit_img($meta_value); |
|
527 | 527 | |
528 | - if ( ! isset( $data['_images'] ) ) { |
|
528 | + if ( ! isset($data['_images'])) { |
|
529 | 529 | $data['_images'] = array(); |
530 | 530 | } |
531 | 531 | |
532 | - if ( ! empty( $meta_value ) && ! in_array( $meta_value, $data['_images'] ) ) { |
|
532 | + if ( ! empty($meta_value) && ! in_array($meta_value, $data['_images'])) { |
|
533 | 533 | $data['_images'][] = $meta_value; |
534 | 534 | } |
535 | 535 | |
@@ -550,58 +550,58 @@ discard block |
||
550 | 550 | * @param array $data Optional. Existing data array if you have one. Default empty array. |
551 | 551 | * @return array New data array. |
552 | 552 | */ |
553 | - public function source_data_fetch_fallback( $url, $data = array() ) { |
|
554 | - if ( empty( $url ) ) { |
|
553 | + public function source_data_fetch_fallback($url, $data = array()) { |
|
554 | + if (empty($url)) { |
|
555 | 555 | return array(); |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Download source page to tmp file. |
559 | - $source_content = $this->fetch_source_html( $url ); |
|
560 | - if ( is_wp_error( $source_content ) ) { |
|
561 | - return array( 'errors' => $source_content->get_error_messages() ); |
|
559 | + $source_content = $this->fetch_source_html($url); |
|
560 | + if (is_wp_error($source_content)) { |
|
561 | + return array('errors' => $source_content->get_error_messages()); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | // Fetch and gather <meta> data first, so discovered media is offered 1st to user. |
565 | - if ( empty( $data['_meta'] ) ) { |
|
565 | + if (empty($data['_meta'])) { |
|
566 | 566 | $data['_meta'] = array(); |
567 | 567 | } |
568 | 568 | |
569 | - if ( preg_match_all( '/<meta [^>]+>/', $source_content, $matches ) ) { |
|
570 | - $items = $this->_limit_array( $matches[0] ); |
|
569 | + if (preg_match_all('/<meta [^>]+>/', $source_content, $matches)) { |
|
570 | + $items = $this->_limit_array($matches[0]); |
|
571 | 571 | |
572 | - foreach ( $items as $value ) { |
|
573 | - if ( preg_match( '/(property|name)="([^"]+)"[^>]+content="([^"]+)"/', $value, $new_matches ) ) { |
|
574 | - $meta_name = $this->_limit_string( $new_matches[2] ); |
|
575 | - $meta_value = $this->_limit_string( $new_matches[3] ); |
|
572 | + foreach ($items as $value) { |
|
573 | + if (preg_match('/(property|name)="([^"]+)"[^>]+content="([^"]+)"/', $value, $new_matches)) { |
|
574 | + $meta_name = $this->_limit_string($new_matches[2]); |
|
575 | + $meta_value = $this->_limit_string($new_matches[3]); |
|
576 | 576 | |
577 | 577 | // Sanity check. $key is usually things like 'title', 'description', 'keywords', etc. |
578 | - if ( strlen( $meta_name ) > 100 ) { |
|
578 | + if (strlen($meta_name) > 100) { |
|
579 | 579 | continue; |
580 | 580 | } |
581 | 581 | |
582 | - $data = $this->_process_meta_entry( $meta_name, $meta_value, $data ); |
|
582 | + $data = $this->_process_meta_entry($meta_name, $meta_value, $data); |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | 587 | // Fetch and gather <img> data. |
588 | - if ( empty( $data['_images'] ) ) { |
|
588 | + if (empty($data['_images'])) { |
|
589 | 589 | $data['_images'] = array(); |
590 | 590 | } |
591 | 591 | |
592 | - if ( preg_match_all( '/<img [^>]+>/', $source_content, $matches ) ) { |
|
593 | - $items = $this->_limit_array( $matches[0] ); |
|
592 | + if (preg_match_all('/<img [^>]+>/', $source_content, $matches)) { |
|
593 | + $items = $this->_limit_array($matches[0]); |
|
594 | 594 | |
595 | - foreach ( $items as $value ) { |
|
596 | - if ( ( preg_match( '/width=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 256 ) || |
|
597 | - ( preg_match( '/height=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 128 ) ) { |
|
595 | + foreach ($items as $value) { |
|
596 | + if ((preg_match('/width=(\'|")(\d+)\\1/i', $value, $new_matches) && $new_matches[2] < 256) || |
|
597 | + (preg_match('/height=(\'|")(\d+)\\1/i', $value, $new_matches) && $new_matches[2] < 128)) { |
|
598 | 598 | |
599 | 599 | continue; |
600 | 600 | } |
601 | 601 | |
602 | - if ( preg_match( '/src=(\'|")([^\'"]+)\\1/i', $value, $new_matches ) ) { |
|
603 | - $src = $this->_limit_img( $new_matches[2] ); |
|
604 | - if ( ! empty( $src ) && ! in_array( $src, $data['_images'] ) ) { |
|
602 | + if (preg_match('/src=(\'|")([^\'"]+)\\1/i', $value, $new_matches)) { |
|
603 | + $src = $this->_limit_img($new_matches[2]); |
|
604 | + if ( ! empty($src) && ! in_array($src, $data['_images'])) { |
|
605 | 605 | $data['_images'][] = $src; |
606 | 606 | } |
607 | 607 | } |
@@ -609,18 +609,18 @@ discard block |
||
609 | 609 | } |
610 | 610 | |
611 | 611 | // Fetch and gather <iframe> data. |
612 | - if ( empty( $data['_embeds'] ) ) { |
|
612 | + if (empty($data['_embeds'])) { |
|
613 | 613 | $data['_embeds'] = array(); |
614 | 614 | } |
615 | 615 | |
616 | - if ( preg_match_all( '/<iframe [^>]+>/', $source_content, $matches ) ) { |
|
617 | - $items = $this->_limit_array( $matches[0] ); |
|
616 | + if (preg_match_all('/<iframe [^>]+>/', $source_content, $matches)) { |
|
617 | + $items = $this->_limit_array($matches[0]); |
|
618 | 618 | |
619 | - foreach ( $items as $value ) { |
|
620 | - if ( preg_match( '/src=(\'|")([^\'"]+)\\1/', $value, $new_matches ) ) { |
|
621 | - $src = $this->_limit_embed( $new_matches[2] ); |
|
619 | + foreach ($items as $value) { |
|
620 | + if (preg_match('/src=(\'|")([^\'"]+)\\1/', $value, $new_matches)) { |
|
621 | + $src = $this->_limit_embed($new_matches[2]); |
|
622 | 622 | |
623 | - if ( ! empty( $src ) && ! in_array( $src, $data['_embeds'] ) ) { |
|
623 | + if ( ! empty($src) && ! in_array($src, $data['_embeds'])) { |
|
624 | 624 | $data['_embeds'][] = $src; |
625 | 625 | } |
626 | 626 | } |
@@ -628,20 +628,20 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | // Fetch and gather <link> data. |
631 | - if ( empty( $data['_links'] ) ) { |
|
631 | + if (empty($data['_links'])) { |
|
632 | 632 | $data['_links'] = array(); |
633 | 633 | } |
634 | 634 | |
635 | - if ( preg_match_all( '/<link [^>]+>/', $source_content, $matches ) ) { |
|
636 | - $items = $this->_limit_array( $matches[0] ); |
|
635 | + if (preg_match_all('/<link [^>]+>/', $source_content, $matches)) { |
|
636 | + $items = $this->_limit_array($matches[0]); |
|
637 | 637 | |
638 | - foreach ( $items as $value ) { |
|
639 | - if ( preg_match( '/rel=["\'](canonical|shortlink|icon)["\']/i', $value, $matches_rel ) && preg_match( '/href=[\'"]([^\'" ]+)[\'"]/i', $value, $matches_url ) ) { |
|
638 | + foreach ($items as $value) { |
|
639 | + if (preg_match('/rel=["\'](canonical|shortlink|icon)["\']/i', $value, $matches_rel) && preg_match('/href=[\'"]([^\'" ]+)[\'"]/i', $value, $matches_url)) { |
|
640 | 640 | $rel = $matches_rel[1]; |
641 | - $url = $this->_limit_url( $matches_url[1] ); |
|
641 | + $url = $this->_limit_url($matches_url[1]); |
|
642 | 642 | |
643 | - if ( ! empty( $url ) && empty( $data['_links'][ $rel ] ) ) { |
|
644 | - $data['_links'][ $rel ] = $url; |
|
643 | + if ( ! empty($url) && empty($data['_links'][$rel])) { |
|
644 | + $data['_links'][$rel] = $url; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | } |
@@ -663,27 +663,27 @@ discard block |
||
663 | 663 | $data = array(); |
664 | 664 | |
665 | 665 | // Only instantiate the keys we want. Sanity check and sanitize each one. |
666 | - foreach ( array( 'u', 's', 't', 'v' ) as $key ) { |
|
667 | - if ( ! empty( $_POST[ $key ] ) ) { |
|
668 | - $value = wp_unslash( $_POST[ $key ] ); |
|
669 | - } else if ( ! empty( $_GET[ $key ] ) ) { |
|
670 | - $value = wp_unslash( $_GET[ $key ] ); |
|
666 | + foreach (array('u', 's', 't', 'v') as $key) { |
|
667 | + if ( ! empty($_POST[$key])) { |
|
668 | + $value = wp_unslash($_POST[$key]); |
|
669 | + } else if ( ! empty($_GET[$key])) { |
|
670 | + $value = wp_unslash($_GET[$key]); |
|
671 | 671 | } else { |
672 | 672 | continue; |
673 | 673 | } |
674 | 674 | |
675 | - if ( 'u' === $key ) { |
|
676 | - $value = $this->_limit_url( $value ); |
|
675 | + if ('u' === $key) { |
|
676 | + $value = $this->_limit_url($value); |
|
677 | 677 | |
678 | - if ( preg_match( '%^(?:https?:)?//[^/]+%i', $value, $domain_match ) ) { |
|
678 | + if (preg_match('%^(?:https?:)?//[^/]+%i', $value, $domain_match)) { |
|
679 | 679 | $this->domain = $domain_match[0]; |
680 | 680 | } |
681 | 681 | } else { |
682 | - $value = $this->_limit_string( $value ); |
|
682 | + $value = $this->_limit_string($value); |
|
683 | 683 | } |
684 | 684 | |
685 | - if ( ! empty( $value ) ) { |
|
686 | - $data[ $key ] = $value; |
|
685 | + if ( ! empty($value)) { |
|
686 | + $data[$key] = $value; |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
@@ -694,58 +694,58 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @param bool $enable Whether to enable media discovery. |
696 | 696 | */ |
697 | - if ( apply_filters( 'enable_press_this_media_discovery', true ) ) { |
|
697 | + if (apply_filters('enable_press_this_media_discovery', true)) { |
|
698 | 698 | /* |
699 | 699 | * If no title, _images, _embed, and _meta was passed via $_POST, fetch data from source as fallback, |
700 | 700 | * making PT fully backward compatible with the older bookmarklet. |
701 | 701 | */ |
702 | - if ( empty( $_POST ) && ! empty( $data['u'] ) ) { |
|
703 | - $data = $this->source_data_fetch_fallback( $data['u'], $data ); |
|
702 | + if (empty($_POST) && ! empty($data['u'])) { |
|
703 | + $data = $this->source_data_fetch_fallback($data['u'], $data); |
|
704 | 704 | } else { |
705 | - foreach ( array( '_images', '_embeds' ) as $type ) { |
|
706 | - if ( empty( $_POST[ $type ] ) ) { |
|
705 | + foreach (array('_images', '_embeds') as $type) { |
|
706 | + if (empty($_POST[$type])) { |
|
707 | 707 | continue; |
708 | 708 | } |
709 | 709 | |
710 | - $data[ $type ] = array(); |
|
711 | - $items = $this->_limit_array( $_POST[ $type ] ); |
|
710 | + $data[$type] = array(); |
|
711 | + $items = $this->_limit_array($_POST[$type]); |
|
712 | 712 | |
713 | - foreach ( $items as $key => $value ) { |
|
714 | - if ( $type === '_images' ) { |
|
715 | - $value = $this->_limit_img( wp_unslash( $value ) ); |
|
713 | + foreach ($items as $key => $value) { |
|
714 | + if ($type === '_images') { |
|
715 | + $value = $this->_limit_img(wp_unslash($value)); |
|
716 | 716 | } else { |
717 | - $value = $this->_limit_embed( wp_unslash( $value ) ); |
|
717 | + $value = $this->_limit_embed(wp_unslash($value)); |
|
718 | 718 | } |
719 | 719 | |
720 | - if ( ! empty( $value ) ) { |
|
721 | - $data[ $type ][] = $value; |
|
720 | + if ( ! empty($value)) { |
|
721 | + $data[$type][] = $value; |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | } |
725 | 725 | |
726 | - foreach ( array( '_meta', '_links' ) as $type ) { |
|
727 | - if ( empty( $_POST[ $type ] ) ) { |
|
726 | + foreach (array('_meta', '_links') as $type) { |
|
727 | + if (empty($_POST[$type])) { |
|
728 | 728 | continue; |
729 | 729 | } |
730 | 730 | |
731 | - $data[ $type ] = array(); |
|
732 | - $items = $this->_limit_array( $_POST[ $type ] ); |
|
731 | + $data[$type] = array(); |
|
732 | + $items = $this->_limit_array($_POST[$type]); |
|
733 | 733 | |
734 | - foreach ( $items as $key => $value ) { |
|
734 | + foreach ($items as $key => $value) { |
|
735 | 735 | // Sanity check. These are associative arrays, $key is usually things like 'title', 'description', 'keywords', etc. |
736 | - if ( empty( $key ) || strlen( $key ) > 100 ) { |
|
736 | + if (empty($key) || strlen($key) > 100) { |
|
737 | 737 | continue; |
738 | 738 | } |
739 | 739 | |
740 | - if ( $type === '_meta' ) { |
|
741 | - $value = $this->_limit_string( wp_unslash( $value ) ); |
|
740 | + if ($type === '_meta') { |
|
741 | + $value = $this->_limit_string(wp_unslash($value)); |
|
742 | 742 | |
743 | - if ( ! empty( $value ) ) { |
|
744 | - $data = $this->_process_meta_entry( $key, $value, $data ); |
|
743 | + if ( ! empty($value)) { |
|
744 | + $data = $this->_process_meta_entry($key, $value, $data); |
|
745 | 745 | } |
746 | 746 | } else { |
747 | - if ( in_array( $key, array( 'canonical', 'shortlink', 'icon' ), true ) ) { |
|
748 | - $data[ $type ][ $key ] = $this->_limit_url( wp_unslash( $value ) ); |
|
747 | + if (in_array($key, array('canonical', 'shortlink', 'icon'), true)) { |
|
748 | + $data[$type][$key] = $this->_limit_url(wp_unslash($value)); |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | } |
@@ -753,11 +753,11 @@ discard block |
||
753 | 753 | } |
754 | 754 | |
755 | 755 | // Support passing a single image src as `i` |
756 | - if ( ! empty( $_REQUEST['i'] ) && ( $img_src = $this->_limit_img( wp_unslash( $_REQUEST['i'] ) ) ) ) { |
|
757 | - if ( empty( $data['_images'] ) ) { |
|
758 | - $data['_images'] = array( $img_src ); |
|
759 | - } elseif ( ! in_array( $img_src, $data['_images'], true ) ) { |
|
760 | - array_unshift( $data['_images'], $img_src ); |
|
756 | + if ( ! empty($_REQUEST['i']) && ($img_src = $this->_limit_img(wp_unslash($_REQUEST['i'])))) { |
|
757 | + if (empty($data['_images'])) { |
|
758 | + $data['_images'] = array($img_src); |
|
759 | + } elseif ( ! in_array($img_src, $data['_images'], true)) { |
|
760 | + array_unshift($data['_images'], $img_src); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | * |
770 | 770 | * @param array $data Press This Data array. |
771 | 771 | */ |
772 | - return apply_filters( 'press_this_data', $data ); |
|
772 | + return apply_filters('press_this_data', $data); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
@@ -781,17 +781,17 @@ discard block |
||
781 | 781 | * @param string $styles URL to editor stylesheet. |
782 | 782 | * @return string Possibly modified stylesheets list. |
783 | 783 | */ |
784 | - public function add_editor_style( $styles ) { |
|
785 | - if ( ! empty( $styles ) ) { |
|
784 | + public function add_editor_style($styles) { |
|
785 | + if ( ! empty($styles)) { |
|
786 | 786 | $styles .= ','; |
787 | 787 | } |
788 | 788 | |
789 | - $press_this = admin_url( 'css/press-this-editor.css' ); |
|
790 | - if ( is_rtl() ) { |
|
791 | - $press_this = str_replace( '.css', '-rtl.css', $press_this ); |
|
789 | + $press_this = admin_url('css/press-this-editor.css'); |
|
790 | + if (is_rtl()) { |
|
791 | + $press_this = str_replace('.css', '-rtl.css', $press_this); |
|
792 | 792 | } |
793 | 793 | |
794 | - return $styles . $press_this; |
|
794 | + return $styles.$press_this; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
@@ -802,35 +802,35 @@ discard block |
||
802 | 802 | * |
803 | 803 | * @param WP_Post $post Post object. |
804 | 804 | */ |
805 | - public function post_formats_html( $post ) { |
|
806 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
807 | - $post_formats = get_theme_support( 'post-formats' ); |
|
805 | + public function post_formats_html($post) { |
|
806 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) { |
|
807 | + $post_formats = get_theme_support('post-formats'); |
|
808 | 808 | |
809 | - if ( is_array( $post_formats[0] ) ) { |
|
810 | - $post_format = get_post_format( $post->ID ); |
|
809 | + if (is_array($post_formats[0])) { |
|
810 | + $post_format = get_post_format($post->ID); |
|
811 | 811 | |
812 | - if ( ! $post_format ) { |
|
812 | + if ( ! $post_format) { |
|
813 | 813 | $post_format = '0'; |
814 | 814 | } |
815 | 815 | |
816 | 816 | // Add in the current one if it isn't there yet, in case the current theme doesn't support it. |
817 | - if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) { |
|
817 | + if ($post_format && ! in_array($post_format, $post_formats[0])) { |
|
818 | 818 | $post_formats[0][] = $post_format; |
819 | 819 | } |
820 | 820 | |
821 | 821 | ?> |
822 | 822 | <div id="post-formats-select"> |
823 | - <fieldset><legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend> |
|
824 | - <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> |
|
825 | - <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label> |
|
823 | + <fieldset><legend class="screen-reader-text"><?php _e('Post Formats'); ?></legend> |
|
824 | + <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked($post_format, '0'); ?> /> |
|
825 | + <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string('standard'); ?></label> |
|
826 | 826 | <?php |
827 | 827 | |
828 | - foreach ( $post_formats[0] as $format ) { |
|
829 | - $attr_format = esc_attr( $format ); |
|
828 | + foreach ($post_formats[0] as $format) { |
|
829 | + $attr_format = esc_attr($format); |
|
830 | 830 | ?> |
831 | 831 | <br /> |
832 | - <input type="radio" name="post_format" class="post-format" id="post-format-<?php echo $attr_format; ?>" value="<?php echo $attr_format; ?>" <?php checked( $post_format, $format ); ?> /> |
|
833 | - <label for="post-format-<?php echo $attr_format ?>" class="post-format-icon post-format-<?php echo $attr_format; ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label> |
|
832 | + <input type="radio" name="post_format" class="post-format" id="post-format-<?php echo $attr_format; ?>" value="<?php echo $attr_format; ?>" <?php checked($post_format, $format); ?> /> |
|
833 | + <label for="post-format-<?php echo $attr_format ?>" class="post-format-icon post-format-<?php echo $attr_format; ?>"><?php echo esc_html(get_post_format_string($format)); ?></label> |
|
834 | 834 | <?php |
835 | 835 | } |
836 | 836 | |
@@ -850,45 +850,45 @@ discard block |
||
850 | 850 | * |
851 | 851 | * @param WP_Post $post Post object. |
852 | 852 | */ |
853 | - public function categories_html( $post ) { |
|
854 | - $taxonomy = get_taxonomy( 'category' ); |
|
853 | + public function categories_html($post) { |
|
854 | + $taxonomy = get_taxonomy('category'); |
|
855 | 855 | |
856 | - if ( current_user_can( $taxonomy->cap->edit_terms ) ) { |
|
856 | + if (current_user_can($taxonomy->cap->edit_terms)) { |
|
857 | 857 | ?> |
858 | 858 | <button type="button" class="add-cat-toggle button-link" aria-expanded="false"> |
859 | - <span class="dashicons dashicons-plus"></span><span class="screen-reader-text"><?php _e( 'Toggle add category' ); ?></span> |
|
859 | + <span class="dashicons dashicons-plus"></span><span class="screen-reader-text"><?php _e('Toggle add category'); ?></span> |
|
860 | 860 | </button> |
861 | 861 | <div class="add-category is-hidden"> |
862 | 862 | <label class="screen-reader-text" for="new-category"><?php echo $taxonomy->labels->add_new_item; ?></label> |
863 | - <input type="text" id="new-category" class="add-category-name" placeholder="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" value="" aria-required="true"> |
|
863 | + <input type="text" id="new-category" class="add-category-name" placeholder="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" value="" aria-required="true"> |
|
864 | 864 | <label class="screen-reader-text" for="new-category-parent"><?php echo $taxonomy->labels->parent_item_colon; ?></label> |
865 | 865 | <div class="postform-wrapper"> |
866 | 866 | <?php |
867 | - wp_dropdown_categories( array( |
|
867 | + wp_dropdown_categories(array( |
|
868 | 868 | 'taxonomy' => 'category', |
869 | 869 | 'hide_empty' => 0, |
870 | 870 | 'name' => 'new-category-parent', |
871 | 871 | 'orderby' => 'name', |
872 | 872 | 'hierarchical' => 1, |
873 | - 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —' |
|
874 | - ) ); |
|
873 | + 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —' |
|
874 | + )); |
|
875 | 875 | ?> |
876 | 876 | </div> |
877 | - <button type="button" class="add-cat-submit"><?php _e( 'Add' ); ?></button> |
|
877 | + <button type="button" class="add-cat-submit"><?php _e('Add'); ?></button> |
|
878 | 878 | </div> |
879 | 879 | <?php |
880 | 880 | |
881 | 881 | } |
882 | 882 | ?> |
883 | 883 | <div class="categories-search-wrapper"> |
884 | - <input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e( 'Search categories by name' ) ?>"> |
|
884 | + <input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e('Search categories by name') ?>"> |
|
885 | 885 | <label for="categories-search"> |
886 | - <span class="dashicons dashicons-search"></span><span class="screen-reader-text"><?php _e( 'Search categories' ); ?></span> |
|
886 | + <span class="dashicons dashicons-search"></span><span class="screen-reader-text"><?php _e('Search categories'); ?></span> |
|
887 | 887 | </label> |
888 | 888 | </div> |
889 | - <div aria-label="<?php esc_attr_e( 'Categories' ); ?>"> |
|
889 | + <div aria-label="<?php esc_attr_e('Categories'); ?>"> |
|
890 | 890 | <ul class="categories-select"> |
891 | - <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'category', 'list_only' => true ) ); ?> |
|
891 | + <?php wp_terms_checklist($post->ID, array('taxonomy' => 'category', 'list_only' => true)); ?> |
|
892 | 892 | </ul> |
893 | 893 | </div> |
894 | 894 | <?php |
@@ -902,12 +902,12 @@ discard block |
||
902 | 902 | * |
903 | 903 | * @param WP_Post $post Post object. |
904 | 904 | */ |
905 | - public function tags_html( $post ) { |
|
906 | - $taxonomy = get_taxonomy( 'post_tag' ); |
|
907 | - $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); |
|
908 | - $esc_tags = get_terms_to_edit( $post->ID, 'post_tag' ); |
|
905 | + public function tags_html($post) { |
|
906 | + $taxonomy = get_taxonomy('post_tag'); |
|
907 | + $user_can_assign_terms = current_user_can($taxonomy->cap->assign_terms); |
|
908 | + $esc_tags = get_terms_to_edit($post->ID, 'post_tag'); |
|
909 | 909 | |
910 | - if ( ! $esc_tags || is_wp_error( $esc_tags ) ) { |
|
910 | + if ( ! $esc_tags || is_wp_error($esc_tags)) { |
|
911 | 911 | $esc_tags = ''; |
912 | 912 | } |
913 | 913 | |
@@ -917,13 +917,13 @@ discard block |
||
917 | 917 | <input type="hidden" name="tax_input[post_tag]" class="the-tags" value="<?php echo $esc_tags; // escaped in get_terms_to_edit() ?>"> |
918 | 918 | <?php |
919 | 919 | |
920 | - if ( $user_can_assign_terms ) { |
|
920 | + if ($user_can_assign_terms) { |
|
921 | 921 | ?> |
922 | 922 | <div class="ajaxtag hide-if-no-js"> |
923 | - <label class="screen-reader-text" for="new-tag-post_tag"><?php _e( 'Tags' ); ?></label> |
|
923 | + <label class="screen-reader-text" for="new-tag-post_tag"><?php _e('Tags'); ?></label> |
|
924 | 924 | <p> |
925 | 925 | <input type="text" id="new-tag-post_tag" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" aria-describedby="new-tag-desc" /> |
926 | - <button type="button" class="tagadd"><?php _e( 'Add' ); ?></button> |
|
926 | + <button type="button" class="tagadd"><?php _e('Add'); ?></button> |
|
927 | 927 | </p> |
928 | 928 | </div> |
929 | 929 | <p class="howto" id="new-tag-desc"> |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | </div> |
939 | 939 | <?php |
940 | 940 | |
941 | - if ( $user_can_assign_terms ) { |
|
941 | + if ($user_can_assign_terms) { |
|
942 | 942 | ?> |
943 | 943 | <button type="button" class="button-link tagcloud-link" id="link-post_tag" aria-expanded="false"><?php echo $taxonomy->labels->choose_from_most_used; ?></button> |
944 | 944 | <?php |
@@ -954,19 +954,19 @@ discard block |
||
954 | 954 | * @param array $data The site's data. |
955 | 955 | * @return array Embeds selected to be available. |
956 | 956 | */ |
957 | - public function get_embeds( $data ) { |
|
957 | + public function get_embeds($data) { |
|
958 | 958 | $selected_embeds = array(); |
959 | 959 | |
960 | 960 | // Make sure to add the Pressed page if it's a valid oembed itself |
961 | - if ( ! empty ( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) { |
|
961 | + if ( ! empty ($data['u']) && $this->_limit_embed($data['u'])) { |
|
962 | 962 | $data['_embeds'][] = $data['u']; |
963 | 963 | } |
964 | 964 | |
965 | - if ( ! empty( $data['_embeds'] ) ) { |
|
966 | - foreach ( $data['_embeds'] as $src ) { |
|
967 | - $prot_relative_src = preg_replace( '/^https?:/', '', $src ); |
|
965 | + if ( ! empty($data['_embeds'])) { |
|
966 | + foreach ($data['_embeds'] as $src) { |
|
967 | + $prot_relative_src = preg_replace('/^https?:/', '', $src); |
|
968 | 968 | |
969 | - if ( in_array( $prot_relative_src, $this->embeds ) ) { |
|
969 | + if (in_array($prot_relative_src, $this->embeds)) { |
|
970 | 970 | continue; |
971 | 971 | } |
972 | 972 | |
@@ -987,19 +987,19 @@ discard block |
||
987 | 987 | * @param array $data The site's data. |
988 | 988 | * @return array |
989 | 989 | */ |
990 | - public function get_images( $data ) { |
|
990 | + public function get_images($data) { |
|
991 | 991 | $selected_images = array(); |
992 | 992 | |
993 | - if ( ! empty( $data['_images'] ) ) { |
|
994 | - foreach ( $data['_images'] as $src ) { |
|
995 | - if ( false !== strpos( $src, 'gravatar.com' ) ) { |
|
996 | - $src = preg_replace( '%http://[\d]+\.gravatar\.com/%', 'https://secure.gravatar.com/', $src ); |
|
993 | + if ( ! empty($data['_images'])) { |
|
994 | + foreach ($data['_images'] as $src) { |
|
995 | + if (false !== strpos($src, 'gravatar.com')) { |
|
996 | + $src = preg_replace('%http://[\d]+\.gravatar\.com/%', 'https://secure.gravatar.com/', $src); |
|
997 | 997 | } |
998 | 998 | |
999 | - $prot_relative_src = preg_replace( '/^https?:/', '', $src ); |
|
999 | + $prot_relative_src = preg_replace('/^https?:/', '', $src); |
|
1000 | 1000 | |
1001 | - if ( in_array( $prot_relative_src, $this->images ) || |
|
1002 | - ( false !== strpos( $src, 'avatar' ) && count( $this->images ) > 15 ) ) { |
|
1001 | + if (in_array($prot_relative_src, $this->images) || |
|
1002 | + (false !== strpos($src, 'avatar') && count($this->images) > 15)) { |
|
1003 | 1003 | // Skip: already selected or some type of avatar and we've already gathered more than 15 images. |
1004 | 1004 | continue; |
1005 | 1005 | } |
@@ -1021,22 +1021,22 @@ discard block |
||
1021 | 1021 | * @param array $data The site's data. |
1022 | 1022 | * @return string Discovered canonical URL, or empty |
1023 | 1023 | */ |
1024 | - public function get_canonical_link( $data ) { |
|
1024 | + public function get_canonical_link($data) { |
|
1025 | 1025 | $link = ''; |
1026 | 1026 | |
1027 | - if ( ! empty( $data['_links']['canonical'] ) ) { |
|
1027 | + if ( ! empty($data['_links']['canonical'])) { |
|
1028 | 1028 | $link = $data['_links']['canonical']; |
1029 | - } elseif ( ! empty( $data['u'] ) ) { |
|
1029 | + } elseif ( ! empty($data['u'])) { |
|
1030 | 1030 | $link = $data['u']; |
1031 | - } elseif ( ! empty( $data['_meta'] ) ) { |
|
1032 | - if ( ! empty( $data['_meta']['twitter:url'] ) ) { |
|
1031 | + } elseif ( ! empty($data['_meta'])) { |
|
1032 | + if ( ! empty($data['_meta']['twitter:url'])) { |
|
1033 | 1033 | $link = $data['_meta']['twitter:url']; |
1034 | - } else if ( ! empty( $data['_meta']['og:url'] ) ) { |
|
1034 | + } else if ( ! empty($data['_meta']['og:url'])) { |
|
1035 | 1035 | $link = $data['_meta']['og:url']; |
1036 | 1036 | } |
1037 | 1037 | } |
1038 | 1038 | |
1039 | - if ( empty( $link ) && ! empty( $data['_links']['shortlink'] ) ) { |
|
1039 | + if (empty($link) && ! empty($data['_links']['shortlink'])) { |
|
1040 | 1040 | $link = $data['_links']['shortlink']; |
1041 | 1041 | } |
1042 | 1042 | |
@@ -1052,13 +1052,13 @@ discard block |
||
1052 | 1052 | * @param array $data The site's data. |
1053 | 1053 | * @return string Discovered site name, or empty |
1054 | 1054 | */ |
1055 | - public function get_source_site_name( $data ) { |
|
1055 | + public function get_source_site_name($data) { |
|
1056 | 1056 | $name = ''; |
1057 | 1057 | |
1058 | - if ( ! empty( $data['_meta'] ) ) { |
|
1059 | - if ( ! empty( $data['_meta']['og:site_name'] ) ) { |
|
1058 | + if ( ! empty($data['_meta'])) { |
|
1059 | + if ( ! empty($data['_meta']['og:site_name'])) { |
|
1060 | 1060 | $name = $data['_meta']['og:site_name']; |
1061 | - } else if ( ! empty( $data['_meta']['application-name'] ) ) { |
|
1061 | + } else if ( ! empty($data['_meta']['application-name'])) { |
|
1062 | 1062 | $name = $data['_meta']['application-name']; |
1063 | 1063 | } |
1064 | 1064 | } |
@@ -1075,17 +1075,17 @@ discard block |
||
1075 | 1075 | * @param array $data The site's data. |
1076 | 1076 | * @return string Discovered page title, or empty |
1077 | 1077 | */ |
1078 | - public function get_suggested_title( $data ) { |
|
1078 | + public function get_suggested_title($data) { |
|
1079 | 1079 | $title = ''; |
1080 | 1080 | |
1081 | - if ( ! empty( $data['t'] ) ) { |
|
1081 | + if ( ! empty($data['t'])) { |
|
1082 | 1082 | $title = $data['t']; |
1083 | - } elseif ( ! empty( $data['_meta'] ) ) { |
|
1084 | - if ( ! empty( $data['_meta']['twitter:title'] ) ) { |
|
1083 | + } elseif ( ! empty($data['_meta'])) { |
|
1084 | + if ( ! empty($data['_meta']['twitter:title'])) { |
|
1085 | 1085 | $title = $data['_meta']['twitter:title']; |
1086 | - } else if ( ! empty( $data['_meta']['og:title'] ) ) { |
|
1086 | + } else if ( ! empty($data['_meta']['og:title'])) { |
|
1087 | 1087 | $title = $data['_meta']['og:title']; |
1088 | - } else if ( ! empty( $data['_meta']['title'] ) ) { |
|
1088 | + } else if ( ! empty($data['_meta']['title'])) { |
|
1089 | 1089 | $title = $data['_meta']['title']; |
1090 | 1090 | } |
1091 | 1091 | } |
@@ -1104,38 +1104,38 @@ discard block |
||
1104 | 1104 | * @param array $data The site's data. |
1105 | 1105 | * @return string Discovered content, or empty |
1106 | 1106 | */ |
1107 | - public function get_suggested_content( $data ) { |
|
1107 | + public function get_suggested_content($data) { |
|
1108 | 1108 | $content = $text = ''; |
1109 | 1109 | |
1110 | - if ( ! empty( $data['s'] ) ) { |
|
1110 | + if ( ! empty($data['s'])) { |
|
1111 | 1111 | $text = $data['s']; |
1112 | - } else if ( ! empty( $data['_meta'] ) ) { |
|
1113 | - if ( ! empty( $data['_meta']['twitter:description'] ) ) { |
|
1112 | + } else if ( ! empty($data['_meta'])) { |
|
1113 | + if ( ! empty($data['_meta']['twitter:description'])) { |
|
1114 | 1114 | $text = $data['_meta']['twitter:description']; |
1115 | - } else if ( ! empty( $data['_meta']['og:description'] ) ) { |
|
1115 | + } else if ( ! empty($data['_meta']['og:description'])) { |
|
1116 | 1116 | $text = $data['_meta']['og:description']; |
1117 | - } else if ( ! empty( $data['_meta']['description'] ) ) { |
|
1117 | + } else if ( ! empty($data['_meta']['description'])) { |
|
1118 | 1118 | $text = $data['_meta']['description']; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | // If there is an ellipsis at the end, the description is very likely auto-generated. Better to ignore it. |
1122 | - if ( $text && substr( $text, -3 ) === '...' ) { |
|
1122 | + if ($text && substr($text, -3) === '...') { |
|
1123 | 1123 | $text = ''; |
1124 | 1124 | } |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - $default_html = array( 'quote' => '', 'link' => '', 'embed' => '' ); |
|
1127 | + $default_html = array('quote' => '', 'link' => '', 'embed' => ''); |
|
1128 | 1128 | |
1129 | - if ( ! empty( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) { |
|
1130 | - $default_html['embed'] = '<p>[embed]' . $data['u'] . '[/embed]</p>'; |
|
1129 | + if ( ! empty($data['u']) && $this->_limit_embed($data['u'])) { |
|
1130 | + $default_html['embed'] = '<p>[embed]'.$data['u'].'[/embed]</p>'; |
|
1131 | 1131 | |
1132 | - if ( ! empty( $data['s'] ) ) { |
|
1132 | + if ( ! empty($data['s'])) { |
|
1133 | 1133 | // If the user has selected some text, do quote it. |
1134 | 1134 | $default_html['quote'] = '<blockquote>%1$s</blockquote>'; |
1135 | 1135 | } |
1136 | 1136 | } else { |
1137 | 1137 | $default_html['quote'] = '<blockquote>%1$s</blockquote>'; |
1138 | - $default_html['link'] = '<p>' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) . |
|
1138 | + $default_html['link'] = '<p>'._x('Source:', 'Used in Press This to indicate where the content comes from.'). |
|
1139 | 1139 | ' <em><a href="%1$s">%2$s</a></em></p>'; |
1140 | 1140 | } |
1141 | 1141 | |
@@ -1152,28 +1152,28 @@ discard block |
||
1152 | 1152 | * - 'embed' which contains an [embed] shortcode when the source page offers embeddable content. |
1153 | 1153 | * @param array $data Associative array containing the data from the source page. |
1154 | 1154 | */ |
1155 | - $default_html = apply_filters( 'press_this_suggested_html', $default_html, $data ); |
|
1155 | + $default_html = apply_filters('press_this_suggested_html', $default_html, $data); |
|
1156 | 1156 | |
1157 | - if ( ! empty( $default_html['embed'] ) ) { |
|
1157 | + if ( ! empty($default_html['embed'])) { |
|
1158 | 1158 | $content .= $default_html['embed']; |
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | // Wrap suggested content in the specified HTML. |
1162 | - if ( ! empty( $default_html['quote'] ) && $text ) { |
|
1163 | - $content .= sprintf( $default_html['quote'], $text ); |
|
1162 | + if ( ! empty($default_html['quote']) && $text) { |
|
1163 | + $content .= sprintf($default_html['quote'], $text); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | // Add source attribution if there is one available. |
1167 | - if ( ! empty( $default_html['link'] ) ) { |
|
1168 | - $title = $this->get_suggested_title( $data ); |
|
1169 | - $url = $this->get_canonical_link( $data ); |
|
1167 | + if ( ! empty($default_html['link'])) { |
|
1168 | + $title = $this->get_suggested_title($data); |
|
1169 | + $url = $this->get_canonical_link($data); |
|
1170 | 1170 | |
1171 | - if ( ! $title ) { |
|
1172 | - $title = $this->get_source_site_name( $data ); |
|
1171 | + if ( ! $title) { |
|
1172 | + $title = $this->get_source_site_name($data); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | - if ( $url && $title ) { |
|
1176 | - $content .= sprintf( $default_html['link'], $url, $title ); |
|
1175 | + if ($url && $title) { |
|
1176 | + $content .= sprintf($default_html['link'], $url, $title); |
|
1177 | 1177 | } |
1178 | 1178 | } |
1179 | 1179 | |
@@ -1192,46 +1192,46 @@ discard block |
||
1192 | 1192 | public function html() { |
1193 | 1193 | global $wp_locale; |
1194 | 1194 | |
1195 | - $wp_version = get_bloginfo( 'version' ); |
|
1195 | + $wp_version = get_bloginfo('version'); |
|
1196 | 1196 | |
1197 | 1197 | // Get data, new (POST) and old (GET). |
1198 | 1198 | $data = $this->merge_or_fetch_data(); |
1199 | 1199 | |
1200 | - $post_title = $this->get_suggested_title( $data ); |
|
1200 | + $post_title = $this->get_suggested_title($data); |
|
1201 | 1201 | |
1202 | - $post_content = $this->get_suggested_content( $data ); |
|
1202 | + $post_content = $this->get_suggested_content($data); |
|
1203 | 1203 | |
1204 | 1204 | // Get site settings array/data. |
1205 | 1205 | $site_settings = $this->site_settings(); |
1206 | 1206 | |
1207 | 1207 | // Pass the images and embeds |
1208 | - $images = $this->get_images( $data ); |
|
1209 | - $embeds = $this->get_embeds( $data ); |
|
1208 | + $images = $this->get_images($data); |
|
1209 | + $embeds = $this->get_embeds($data); |
|
1210 | 1210 | |
1211 | 1211 | $site_data = array( |
1212 | - 'v' => ! empty( $data['v'] ) ? $data['v'] : '', |
|
1213 | - 'u' => ! empty( $data['u'] ) ? $data['u'] : '', |
|
1214 | - 'hasData' => ! empty( $data ), |
|
1212 | + 'v' => ! empty($data['v']) ? $data['v'] : '', |
|
1213 | + 'u' => ! empty($data['u']) ? $data['u'] : '', |
|
1214 | + 'hasData' => ! empty($data), |
|
1215 | 1215 | ); |
1216 | 1216 | |
1217 | - if ( ! empty( $images ) ) { |
|
1217 | + if ( ! empty($images)) { |
|
1218 | 1218 | $site_data['_images'] = $images; |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - if ( ! empty( $embeds ) ) { |
|
1221 | + if ( ! empty($embeds)) { |
|
1222 | 1222 | $site_data['_embeds'] = $embeds; |
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | // Add press-this-editor.css and remove theme's editor-style.css, if any. |
1226 | 1226 | remove_editor_styles(); |
1227 | 1227 | |
1228 | - add_filter( 'mce_css', array( $this, 'add_editor_style' ) ); |
|
1228 | + add_filter('mce_css', array($this, 'add_editor_style')); |
|
1229 | 1229 | |
1230 | - if ( ! empty( $GLOBALS['is_IE'] ) ) { |
|
1231 | - @header( 'X-UA-Compatible: IE=edge' ); |
|
1230 | + if ( ! empty($GLOBALS['is_IE'])) { |
|
1231 | + @header('X-UA-Compatible: IE=edge'); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | - @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
|
1234 | + @header('Content-Type: '.get_option('html_type').'; charset='.get_option('blog_charset')); |
|
1235 | 1235 | |
1236 | 1236 | ?> |
1237 | 1237 | <!DOCTYPE html> |
@@ -1239,22 +1239,22 @@ discard block |
||
1239 | 1239 | <!--[if IE 8]> <html class="lt-ie9" <?php language_attributes(); ?>> <![endif]--> |
1240 | 1240 | <!--[if gt IE 8]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> |
1241 | 1241 | <head> |
1242 | - <meta http-equiv="Content-Type" content="<?php echo esc_attr( get_bloginfo( 'html_type' ) ); ?>; charset=<?php echo esc_attr( get_option( 'blog_charset' ) ); ?>" /> |
|
1242 | + <meta http-equiv="Content-Type" content="<?php echo esc_attr(get_bloginfo('html_type')); ?>; charset=<?php echo esc_attr(get_option('blog_charset')); ?>" /> |
|
1243 | 1243 | <meta name="viewport" content="width=device-width"> |
1244 | - <title><?php esc_html_e( 'Press This!' ) ?></title> |
|
1244 | + <title><?php esc_html_e('Press This!') ?></title> |
|
1245 | 1245 | |
1246 | 1246 | <script> |
1247 | - window.wpPressThisData = <?php echo wp_json_encode( $site_data ); ?>; |
|
1248 | - window.wpPressThisConfig = <?php echo wp_json_encode( $site_settings ); ?>; |
|
1247 | + window.wpPressThisData = <?php echo wp_json_encode($site_data); ?>; |
|
1248 | + window.wpPressThisConfig = <?php echo wp_json_encode($site_settings); ?>; |
|
1249 | 1249 | </script> |
1250 | 1250 | |
1251 | 1251 | <script type="text/javascript"> |
1252 | - var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>', |
|
1252 | + var ajaxurl = '<?php echo esc_js(admin_url('admin-ajax.php', 'relative')); ?>', |
|
1253 | 1253 | pagenow = 'press-this', |
1254 | 1254 | typenow = 'post', |
1255 | 1255 | adminpage = 'press-this-php', |
1256 | - thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', |
|
1257 | - decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', |
|
1256 | + thousandsSeparator = '<?php echo addslashes($wp_locale->number_format['thousands_sep']); ?>', |
|
1257 | + decimalPoint = '<?php echo addslashes($wp_locale->number_format['decimal_point']); ?>', |
|
1258 | 1258 | isRtl = <?php echo (int) is_rtl(); ?>; |
1259 | 1259 | </script> |
1260 | 1260 | |
@@ -1263,82 +1263,82 @@ discard block |
||
1263 | 1263 | * $post->ID is needed for the embed shortcode so we can show oEmbed previews in the editor. |
1264 | 1264 | * Maybe find a way without it. |
1265 | 1265 | */ |
1266 | - $post = get_default_post_to_edit( 'post', true ); |
|
1266 | + $post = get_default_post_to_edit('post', true); |
|
1267 | 1267 | $post_ID = (int) $post->ID; |
1268 | 1268 | |
1269 | - wp_enqueue_media( array( 'post' => $post_ID ) ); |
|
1270 | - wp_enqueue_style( 'press-this' ); |
|
1271 | - wp_enqueue_script( 'press-this' ); |
|
1272 | - wp_enqueue_script( 'json2' ); |
|
1273 | - wp_enqueue_script( 'editor' ); |
|
1269 | + wp_enqueue_media(array('post' => $post_ID)); |
|
1270 | + wp_enqueue_style('press-this'); |
|
1271 | + wp_enqueue_script('press-this'); |
|
1272 | + wp_enqueue_script('json2'); |
|
1273 | + wp_enqueue_script('editor'); |
|
1274 | 1274 | |
1275 | 1275 | $supports_formats = false; |
1276 | 1276 | $post_format = 0; |
1277 | 1277 | |
1278 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
1278 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) { |
|
1279 | 1279 | $supports_formats = true; |
1280 | 1280 | |
1281 | - if ( ! ( $post_format = get_post_format( $post_ID ) ) ) { |
|
1281 | + if ( ! ($post_format = get_post_format($post_ID))) { |
|
1282 | 1282 | $post_format = 0; |
1283 | 1283 | } |
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | /** This action is documented in wp-admin/admin-header.php */ |
1287 | - do_action( 'admin_enqueue_scripts', 'press-this.php' ); |
|
1287 | + do_action('admin_enqueue_scripts', 'press-this.php'); |
|
1288 | 1288 | |
1289 | 1289 | /** This action is documented in wp-admin/admin-header.php */ |
1290 | - do_action( 'admin_print_styles-press-this.php' ); |
|
1290 | + do_action('admin_print_styles-press-this.php'); |
|
1291 | 1291 | |
1292 | 1292 | /** This action is documented in wp-admin/admin-header.php */ |
1293 | - do_action( 'admin_print_styles' ); |
|
1293 | + do_action('admin_print_styles'); |
|
1294 | 1294 | |
1295 | 1295 | /** This action is documented in wp-admin/admin-header.php */ |
1296 | - do_action( 'admin_print_scripts-press-this.php' ); |
|
1296 | + do_action('admin_print_scripts-press-this.php'); |
|
1297 | 1297 | |
1298 | 1298 | /** This action is documented in wp-admin/admin-header.php */ |
1299 | - do_action( 'admin_print_scripts' ); |
|
1299 | + do_action('admin_print_scripts'); |
|
1300 | 1300 | |
1301 | 1301 | /** This action is documented in wp-admin/admin-header.php */ |
1302 | - do_action( 'admin_head-press-this.php' ); |
|
1302 | + do_action('admin_head-press-this.php'); |
|
1303 | 1303 | |
1304 | 1304 | /** This action is documented in wp-admin/admin-header.php */ |
1305 | - do_action( 'admin_head' ); |
|
1305 | + do_action('admin_head'); |
|
1306 | 1306 | ?> |
1307 | 1307 | </head> |
1308 | 1308 | <?php |
1309 | 1309 | |
1310 | 1310 | $admin_body_class = 'press-this'; |
1311 | - $admin_body_class .= ( is_rtl() ) ? ' rtl' : ''; |
|
1312 | - $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) ); |
|
1313 | - $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) ); |
|
1314 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
1315 | - $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); |
|
1311 | + $admin_body_class .= (is_rtl()) ? ' rtl' : ''; |
|
1312 | + $admin_body_class .= ' branch-'.str_replace(array('.', ','), '-', floatval($wp_version)); |
|
1313 | + $admin_body_class .= ' version-'.str_replace('.', '-', preg_replace('/^([.0-9]+).*/', '$1', $wp_version)); |
|
1314 | + $admin_body_class .= ' admin-color-'.sanitize_html_class(get_user_option('admin_color'), 'fresh'); |
|
1315 | + $admin_body_class .= ' locale-'.sanitize_html_class(strtolower(str_replace('_', '-', get_user_locale()))); |
|
1316 | 1316 | |
1317 | 1317 | /** This filter is documented in wp-admin/admin-header.php */ |
1318 | - $admin_body_classes = apply_filters( 'admin_body_class', '' ); |
|
1318 | + $admin_body_classes = apply_filters('admin_body_class', ''); |
|
1319 | 1319 | |
1320 | 1320 | ?> |
1321 | -<body class="wp-admin wp-core-ui <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>"> |
|
1321 | +<body class="wp-admin wp-core-ui <?php echo $admin_body_classes.' '.$admin_body_class; ?>"> |
|
1322 | 1322 | <div id="adminbar" class="adminbar"> |
1323 | 1323 | <h1 id="current-site" class="current-site"> |
1324 | - <a class="current-site-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank" rel="home"> |
|
1324 | + <a class="current-site-link" href="<?php echo esc_url(home_url('/')); ?>" target="_blank" rel="home"> |
|
1325 | 1325 | <span class="dashicons dashicons-wordpress"></span> |
1326 | - <span class="current-site-name"><?php bloginfo( 'name' ); ?></span> |
|
1326 | + <span class="current-site-name"><?php bloginfo('name'); ?></span> |
|
1327 | 1327 | </a> |
1328 | 1328 | </h1> |
1329 | 1329 | <button type="button" class="options button-link closed"> |
1330 | 1330 | <span class="dashicons dashicons-tag on-closed"></span> |
1331 | - <span class="screen-reader-text on-closed"><?php _e( 'Show post options' ); ?></span> |
|
1332 | - <span aria-hidden="true" class="on-open"><?php _e( 'Done' ); ?></span> |
|
1333 | - <span class="screen-reader-text on-open"><?php _e( 'Hide post options' ); ?></span> |
|
1331 | + <span class="screen-reader-text on-closed"><?php _e('Show post options'); ?></span> |
|
1332 | + <span aria-hidden="true" class="on-open"><?php _e('Done'); ?></span> |
|
1333 | + <span class="screen-reader-text on-open"><?php _e('Hide post options'); ?></span> |
|
1334 | 1334 | </button> |
1335 | 1335 | </div> |
1336 | 1336 | |
1337 | 1337 | <div id="scanbar" class="scan"> |
1338 | 1338 | <form method="GET"> |
1339 | - <label for="url-scan" class="screen-reader-text"><?php _e( 'Scan site for content' ); ?></label> |
|
1340 | - <input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php esc_attr_e( 'Enter a URL to scan' ) ?>" /> |
|
1341 | - <input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php esc_attr_e( 'Scan' ) ?>" /> |
|
1339 | + <label for="url-scan" class="screen-reader-text"><?php _e('Scan site for content'); ?></label> |
|
1340 | + <input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php esc_attr_e('Enter a URL to scan') ?>" /> |
|
1341 | + <input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php esc_attr_e('Scan') ?>" /> |
|
1342 | 1342 | </form> |
1343 | 1343 | </div> |
1344 | 1344 | |
@@ -1351,8 +1351,8 @@ discard block |
||
1351 | 1351 | <input type="hidden" name="pt-force-redirect" id="pt-force-redirect" value="" /> |
1352 | 1352 | <?php |
1353 | 1353 | |
1354 | - wp_nonce_field( 'update-post_' . $post_ID, '_wpnonce', false ); |
|
1355 | - wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); |
|
1354 | + wp_nonce_field('update-post_'.$post_ID, '_wpnonce', false); |
|
1355 | + wp_nonce_field('add-category', '_ajax_nonce-add-category', false); |
|
1356 | 1356 | |
1357 | 1357 | ?> |
1358 | 1358 | |
@@ -1361,10 +1361,10 @@ discard block |
||
1361 | 1361 | <div class="alerts" role="alert" aria-live="assertive" aria-relevant="all" aria-atomic="true"> |
1362 | 1362 | <?php |
1363 | 1363 | |
1364 | - if ( isset( $data['v'] ) && $this->version > $data['v'] ) { |
|
1364 | + if (isset($data['v']) && $this->version > $data['v']) { |
|
1365 | 1365 | ?> |
1366 | 1366 | <p class="alert is-notice"> |
1367 | - <?php printf( __( 'You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!' ), admin_url( 'tools.php' ) ); ?> |
|
1367 | + <?php printf(__('You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!'), admin_url('tools.php')); ?> |
|
1368 | 1368 | </p> |
1369 | 1369 | <?php |
1370 | 1370 | } |
@@ -1373,18 +1373,18 @@ discard block |
||
1373 | 1373 | </div> |
1374 | 1374 | |
1375 | 1375 | <div id="app-container" class="editor"> |
1376 | - <span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e( 'Post title' ); ?></span> |
|
1377 | - <h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php esc_attr_e( 'Post title' ); ?>" tabindex="0"><?php echo esc_html( $post_title ); ?></h2> |
|
1376 | + <span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e('Post title'); ?></span> |
|
1377 | + <h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php esc_attr_e('Post title'); ?>" tabindex="0"><?php echo esc_html($post_title); ?></h2> |
|
1378 | 1378 | |
1379 | 1379 | <div class="media-list-container"> |
1380 | 1380 | <div class="media-list-inner-container"> |
1381 | - <h2 class="screen-reader-text"><?php _e( 'Suggested media' ); ?></h2> |
|
1381 | + <h2 class="screen-reader-text"><?php _e('Suggested media'); ?></h2> |
|
1382 | 1382 | <ul class="media-list"></ul> |
1383 | 1383 | </div> |
1384 | 1384 | </div> |
1385 | 1385 | |
1386 | 1386 | <?php |
1387 | - wp_editor( $post_content, 'pressthis', array( |
|
1387 | + wp_editor($post_content, 'pressthis', array( |
|
1388 | 1388 | 'drag_drop_upload' => true, |
1389 | 1389 | 'editor_height' => 600, |
1390 | 1390 | 'media_buttons' => false, |
@@ -1404,7 +1404,7 @@ discard block |
||
1404 | 1404 | 'quicktags' => array( |
1405 | 1405 | 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,more', |
1406 | 1406 | ), |
1407 | - ) ); |
|
1407 | + )); |
|
1408 | 1408 | |
1409 | 1409 | ?> |
1410 | 1410 | </div> |
@@ -1414,55 +1414,55 @@ discard block |
||
1414 | 1414 | <div class="options-panel is-off-screen is-hidden" tabindex="-1"> |
1415 | 1415 | <div class="post-options"> |
1416 | 1416 | |
1417 | - <?php if ( $supports_formats ) : ?> |
|
1417 | + <?php if ($supports_formats) : ?> |
|
1418 | 1418 | <button type="button" class="button-link post-option"> |
1419 | 1419 | <span class="dashicons dashicons-admin-post"></span> |
1420 | - <span class="post-option-title"><?php _ex( 'Format', 'post format' ); ?></span> |
|
1421 | - <span class="post-option-contents" id="post-option-post-format"><?php echo esc_html( get_post_format_string( $post_format ) ); ?></span> |
|
1420 | + <span class="post-option-title"><?php _ex('Format', 'post format'); ?></span> |
|
1421 | + <span class="post-option-contents" id="post-option-post-format"><?php echo esc_html(get_post_format_string($post_format)); ?></span> |
|
1422 | 1422 | <span class="dashicons post-option-forward"></span> |
1423 | 1423 | </button> |
1424 | 1424 | <?php endif; ?> |
1425 | 1425 | |
1426 | 1426 | <button type="button" class="button-link post-option"> |
1427 | 1427 | <span class="dashicons dashicons-category"></span> |
1428 | - <span class="post-option-title"><?php _e( 'Categories' ); ?></span> |
|
1428 | + <span class="post-option-title"><?php _e('Categories'); ?></span> |
|
1429 | 1429 | <span class="dashicons post-option-forward"></span> |
1430 | 1430 | </button> |
1431 | 1431 | |
1432 | 1432 | <button type="button" class="button-link post-option"> |
1433 | 1433 | <span class="dashicons dashicons-tag"></span> |
1434 | - <span class="post-option-title"><?php _e( 'Tags' ); ?></span> |
|
1434 | + <span class="post-option-title"><?php _e('Tags'); ?></span> |
|
1435 | 1435 | <span class="dashicons post-option-forward"></span> |
1436 | 1436 | </button> |
1437 | 1437 | </div> |
1438 | 1438 | |
1439 | - <?php if ( $supports_formats ) : ?> |
|
1439 | + <?php if ($supports_formats) : ?> |
|
1440 | 1440 | <div class="setting-modal is-off-screen is-hidden"> |
1441 | 1441 | <button type="button" class="button-link modal-close"> |
1442 | 1442 | <span class="dashicons post-option-back"></span> |
1443 | - <span class="setting-title" aria-hidden="true"><?php _ex( 'Format', 'post format' ); ?></span> |
|
1444 | - <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> |
|
1443 | + <span class="setting-title" aria-hidden="true"><?php _ex('Format', 'post format'); ?></span> |
|
1444 | + <span class="screen-reader-text"><?php _e('Back to post options') ?></span> |
|
1445 | 1445 | </button> |
1446 | - <?php $this->post_formats_html( $post ); ?> |
|
1446 | + <?php $this->post_formats_html($post); ?> |
|
1447 | 1447 | </div> |
1448 | 1448 | <?php endif; ?> |
1449 | 1449 | |
1450 | 1450 | <div class="setting-modal is-off-screen is-hidden"> |
1451 | 1451 | <button type="button" class="button-link modal-close"> |
1452 | 1452 | <span class="dashicons post-option-back"></span> |
1453 | - <span class="setting-title" aria-hidden="true"><?php _e( 'Categories' ); ?></span> |
|
1454 | - <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> |
|
1453 | + <span class="setting-title" aria-hidden="true"><?php _e('Categories'); ?></span> |
|
1454 | + <span class="screen-reader-text"><?php _e('Back to post options') ?></span> |
|
1455 | 1455 | </button> |
1456 | - <?php $this->categories_html( $post ); ?> |
|
1456 | + <?php $this->categories_html($post); ?> |
|
1457 | 1457 | </div> |
1458 | 1458 | |
1459 | 1459 | <div class="setting-modal tags is-off-screen is-hidden"> |
1460 | 1460 | <button type="button" class="button-link modal-close"> |
1461 | 1461 | <span class="dashicons post-option-back"></span> |
1462 | - <span class="setting-title" aria-hidden="true"><?php _e( 'Tags' ); ?></span> |
|
1463 | - <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> |
|
1462 | + <span class="setting-title" aria-hidden="true"><?php _e('Tags'); ?></span> |
|
1463 | + <span class="screen-reader-text"><?php _e('Back to post options') ?></span> |
|
1464 | 1464 | </button> |
1465 | - <?php $this->tags_html( $post ); ?> |
|
1465 | + <?php $this->tags_html($post); ?> |
|
1466 | 1466 | </div> |
1467 | 1467 | </div><!-- .options-panel --> |
1468 | 1468 | </div><!-- .wrapper --> |
@@ -1471,7 +1471,7 @@ discard block |
||
1471 | 1471 | <div class="pressthis-media-buttons"> |
1472 | 1472 | <button type="button" class="insert-media button-link" data-editor="pressthis"> |
1473 | 1473 | <span class="dashicons dashicons-admin-media"></span> |
1474 | - <span class="screen-reader-text"><?php _e( 'Add Media' ); ?></span> |
|
1474 | + <span class="screen-reader-text"><?php _e('Add Media'); ?></span> |
|
1475 | 1475 | </button> |
1476 | 1476 | </div> |
1477 | 1477 | <div class="post-actions"> |
@@ -1479,17 +1479,17 @@ discard block |
||
1479 | 1479 | <div class="split-button"> |
1480 | 1480 | <div class="split-button-head"> |
1481 | 1481 | <button type="button" class="publish-button split-button-primary" aria-live="polite"> |
1482 | - <span class="publish"><?php echo ( current_user_can( 'publish_posts' ) ) ? __( 'Publish' ) : __( 'Submit for Review' ); ?></span> |
|
1483 | - <span class="saving-draft"><?php _e( 'Saving…' ); ?></span> |
|
1482 | + <span class="publish"><?php echo (current_user_can('publish_posts')) ? __('Publish') : __('Submit for Review'); ?></span> |
|
1483 | + <span class="saving-draft"><?php _e('Saving…'); ?></span> |
|
1484 | 1484 | </button><button type="button" class="split-button-toggle" aria-haspopup="true" aria-expanded="false"> |
1485 | 1485 | <i class="dashicons dashicons-arrow-down-alt2"></i> |
1486 | 1486 | <span class="screen-reader-text"><?php _e('More actions'); ?></span> |
1487 | 1487 | </button> |
1488 | 1488 | </div> |
1489 | 1489 | <ul class="split-button-body"> |
1490 | - <li><button type="button" class="button-link draft-button split-button-option"><?php _e( 'Save Draft' ); ?></button></li> |
|
1491 | - <li><button type="button" class="button-link standard-editor-button split-button-option"><?php _e( 'Standard Editor' ); ?></button></li> |
|
1492 | - <li><button type="button" class="button-link preview-button split-button-option"><?php _e( 'Preview' ); ?></button></li> |
|
1490 | + <li><button type="button" class="button-link draft-button split-button-option"><?php _e('Save Draft'); ?></button></li> |
|
1491 | + <li><button type="button" class="button-link standard-editor-button split-button-option"><?php _e('Standard Editor'); ?></button></li> |
|
1492 | + <li><button type="button" class="button-link preview-button split-button-option"><?php _e('Preview'); ?></button></li> |
|
1493 | 1493 | </ul> |
1494 | 1494 | </div> |
1495 | 1495 | </div> |
@@ -1498,16 +1498,16 @@ discard block |
||
1498 | 1498 | |
1499 | 1499 | <?php |
1500 | 1500 | /** This action is documented in wp-admin/admin-footer.php */ |
1501 | - do_action( 'admin_footer' ); |
|
1501 | + do_action('admin_footer'); |
|
1502 | 1502 | |
1503 | 1503 | /** This action is documented in wp-admin/admin-footer.php */ |
1504 | - do_action( 'admin_print_footer_scripts-press-this.php' ); |
|
1504 | + do_action('admin_print_footer_scripts-press-this.php'); |
|
1505 | 1505 | |
1506 | 1506 | /** This action is documented in wp-admin/admin-footer.php */ |
1507 | - do_action( 'admin_print_footer_scripts' ); |
|
1507 | + do_action('admin_print_footer_scripts'); |
|
1508 | 1508 | |
1509 | 1509 | /** This action is documented in wp-admin/admin-footer.php */ |
1510 | - do_action( 'admin_footer-press-this.php' ); |
|
1510 | + do_action('admin_footer-press-this.php'); |
|
1511 | 1511 | ?> |
1512 | 1512 | </body> |
1513 | 1513 | </html> |
@@ -28,9 +28,10 @@ |
||
28 | 28 | function wpmu_checkAvailableSpace() { |
29 | 29 | _deprecated_function(__FUNCTION__, '3.0', 'is_upload_space_available()' ); |
30 | 30 | |
31 | - if ( !is_upload_space_available() ) |
|
32 | - wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
33 | -} |
|
31 | + if ( !is_upload_space_available() ) { |
|
32 | + wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
33 | + } |
|
34 | + } |
|
34 | 35 | |
35 | 36 | /** |
36 | 37 | * WPMU options. |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @deprecated 3.0.0 |
17 | 17 | */ |
18 | 18 | function wpmu_menu() { |
19 | - _deprecated_function(__FUNCTION__, '3.0.0' ); |
|
19 | + _deprecated_function(__FUNCTION__, '3.0.0'); |
|
20 | 20 | // Deprecated. See #11763. |
21 | 21 | } |
22 | 22 | |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @see is_upload_space_available() |
28 | 28 | */ |
29 | 29 | function wpmu_checkAvailableSpace() { |
30 | - _deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()' ); |
|
30 | + _deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()'); |
|
31 | 31 | |
32 | - if ( !is_upload_space_available() ) |
|
33 | - wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
32 | + if ( ! is_upload_space_available()) |
|
33 | + wp_die(__('Sorry, you must delete files before you can upload any more.')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @deprecated 3.0.0 |
40 | 40 | */ |
41 | -function mu_options( $options ) { |
|
42 | - _deprecated_function(__FUNCTION__, '3.0.0' ); |
|
41 | +function mu_options($options) { |
|
42 | + _deprecated_function(__FUNCTION__, '3.0.0'); |
|
43 | 43 | return $options; |
44 | 44 | } |
45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @see activate_plugin() |
51 | 51 | */ |
52 | 52 | function activate_sitewide_plugin() { |
53 | - _deprecated_function(__FUNCTION__, '3.0.0', 'activate_plugin()' ); |
|
53 | + _deprecated_function(__FUNCTION__, '3.0.0', 'activate_plugin()'); |
|
54 | 54 | return false; |
55 | 55 | } |
56 | 56 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @deprecated 3.0.0 Use deactivate_sitewide_plugin() |
61 | 61 | * @see deactivate_sitewide_plugin() |
62 | 62 | */ |
63 | -function deactivate_sitewide_plugin( $plugin = false ) { |
|
64 | - _deprecated_function(__FUNCTION__, '3.0.0', 'deactivate_plugin()' ); |
|
63 | +function deactivate_sitewide_plugin($plugin = false) { |
|
64 | + _deprecated_function(__FUNCTION__, '3.0.0', 'deactivate_plugin()'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @deprecated 3.0.0 Use is_network_only_plugin() |
71 | 71 | * @see is_network_only_plugin() |
72 | 72 | */ |
73 | -function is_wpmu_sitewide_plugin( $file ) { |
|
74 | - _deprecated_function(__FUNCTION__, '3.0.0', 'is_network_only_plugin()' ); |
|
75 | - return is_network_only_plugin( $file ); |
|
73 | +function is_wpmu_sitewide_plugin($file) { |
|
74 | + _deprecated_function(__FUNCTION__, '3.0.0', 'is_network_only_plugin()'); |
|
75 | + return is_network_only_plugin($file); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @see WP_Theme::get_allowed_on_network() |
83 | 83 | */ |
84 | 84 | function get_site_allowed_themes() { |
85 | - _deprecated_function( __FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_network()' ); |
|
86 | - return array_map( 'intval', WP_Theme::get_allowed_on_network() ); |
|
85 | + _deprecated_function(__FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_network()'); |
|
86 | + return array_map('intval', WP_Theme::get_allowed_on_network()); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * @deprecated 3.4.0 Use WP_Theme::get_allowed_on_site() |
93 | 93 | * @see WP_Theme::get_allowed_on_site() |
94 | 94 | */ |
95 | -function wpmu_get_blog_allowedthemes( $blog_id = 0 ) { |
|
96 | - _deprecated_function( __FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_site()' ); |
|
97 | - return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) ); |
|
95 | +function wpmu_get_blog_allowedthemes($blog_id = 0) { |
|
96 | + _deprecated_function(__FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_site()'); |
|
97 | + return array_map('intval', WP_Theme::get_allowed_on_site($blog_id)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -75,10 +75,14 @@ discard block |
||
75 | 75 | $this->PushError($fnction,'Read failed'); |
76 | 76 | } else { |
77 | 77 | $this->_message.=$tmp; |
78 | - if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false; |
|
78 | + if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) { |
|
79 | + $go=false; |
|
80 | + } |
|
79 | 81 | } |
80 | 82 | } while($go); |
81 | - if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; |
|
83 | + if($this->LocalEcho) { |
|
84 | + echo "GET < ".rtrim($this->_message, CRLF).CRLF; |
|
85 | + } |
|
82 | 86 | $this->_code=(int)$regs[1]; |
83 | 87 | return $result; |
84 | 88 | } |
@@ -88,19 +92,25 @@ discard block |
||
88 | 92 | $this->PushError($fnction,'Connect first'); |
89 | 93 | return FALSE; |
90 | 94 | } |
91 | - if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; |
|
95 | + if($this->LocalEcho) { |
|
96 | + echo "PUT > ",$cmd,CRLF; |
|
97 | + } |
|
92 | 98 | $status=@fputs($this->_ftp_control_sock, $cmd.CRLF); |
93 | 99 | if($status===false) { |
94 | 100 | $this->PushError($fnction,'socket write failed'); |
95 | 101 | return FALSE; |
96 | 102 | } |
97 | 103 | $this->_lastaction=time(); |
98 | - if(!$this->_readmsg($fnction)) return FALSE; |
|
104 | + if(!$this->_readmsg($fnction)) { |
|
105 | + return FALSE; |
|
106 | + } |
|
99 | 107 | return TRUE; |
100 | 108 | } |
101 | 109 | |
102 | 110 | function _data_prepare($mode=FTP_ASCII) { |
103 | - if(!$this->_settype($mode)) return FALSE; |
|
111 | + if(!$this->_settype($mode)) { |
|
112 | + return FALSE; |
|
113 | + } |
|
104 | 114 | if($this->_passive) { |
105 | 115 | if(!$this->_exec("PASV", "pasv")) { |
106 | 116 | $this->_data_close(); |
@@ -119,8 +129,9 @@ discard block |
||
119 | 129 | $this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")"); |
120 | 130 | $this->_data_close(); |
121 | 131 | return FALSE; |
132 | + } else { |
|
133 | + $this->_ftp_data_sock; |
|
122 | 134 | } |
123 | - else $this->_ftp_data_sock; |
|
124 | 135 | } else { |
125 | 136 | $this->SendMSG("Only passive connections available!"); |
126 | 137 | return FALSE; |
@@ -129,24 +140,35 @@ discard block |
||
129 | 140 | } |
130 | 141 | |
131 | 142 | function _data_read($mode=FTP_ASCII, $fp=NULL) { |
132 | - if(is_resource($fp)) $out=0; |
|
133 | - else $out=""; |
|
143 | + if(is_resource($fp)) { |
|
144 | + $out=0; |
|
145 | + } else { |
|
146 | + $out=""; |
|
147 | + } |
|
134 | 148 | if(!$this->_passive) { |
135 | 149 | $this->SendMSG("Only passive connections available!"); |
136 | 150 | return FALSE; |
137 | 151 | } |
138 | 152 | while (!feof($this->_ftp_data_sock)) { |
139 | 153 | $block=fread($this->_ftp_data_sock, $this->_ftp_buff_size); |
140 | - if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); |
|
141 | - if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); |
|
142 | - else $out.=$block; |
|
154 | + if($mode!=FTP_BINARY) { |
|
155 | + $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); |
|
156 | + } |
|
157 | + if(is_resource($fp)) { |
|
158 | + $out+=fwrite($fp, $block, strlen($block)); |
|
159 | + } else { |
|
160 | + $out.=$block; |
|
161 | + } |
|
143 | 162 | } |
144 | 163 | return $out; |
145 | 164 | } |
146 | 165 | |
147 | 166 | function _data_write($mode=FTP_ASCII, $fp=NULL) { |
148 | - if(is_resource($fp)) $out=0; |
|
149 | - else $out=""; |
|
167 | + if(is_resource($fp)) { |
|
168 | + $out=0; |
|
169 | + } else { |
|
170 | + $out=""; |
|
171 | + } |
|
150 | 172 | if(!$this->_passive) { |
151 | 173 | $this->SendMSG("Only passive connections available!"); |
152 | 174 | return FALSE; |
@@ -154,14 +176,20 @@ discard block |
||
154 | 176 | if(is_resource($fp)) { |
155 | 177 | while(!feof($fp)) { |
156 | 178 | $block=fread($fp, $this->_ftp_buff_size); |
157 | - if(!$this->_data_write_block($mode, $block)) return false; |
|
179 | + if(!$this->_data_write_block($mode, $block)) { |
|
180 | + return false; |
|
181 | + } |
|
158 | 182 | } |
159 | - } elseif(!$this->_data_write_block($mode, $fp)) return false; |
|
183 | + } elseif(!$this->_data_write_block($mode, $fp)) { |
|
184 | + return false; |
|
185 | + } |
|
160 | 186 | return TRUE; |
161 | 187 | } |
162 | 188 | |
163 | 189 | function _data_write_block($mode, $block) { |
164 | - if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); |
|
190 | + if($mode!=FTP_BINARY) { |
|
191 | + $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); |
|
192 | + } |
|
165 | 193 | do { |
166 | 194 | if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) { |
167 | 195 | $this->PushError("_data_write","Can't write to socket"); |
@@ -94,6 +94,9 @@ |
||
94 | 94 | return $result; |
95 | 95 | } |
96 | 96 | |
97 | + /** |
|
98 | + * @param string $cmd |
|
99 | + */ |
|
97 | 100 | function _exec($cmd, $fnction="_exec") { |
98 | 101 | if(!$this->_ready) { |
99 | 102 | $this->PushError($fnction,'Connect first'); |
@@ -112,7 +112,7 @@ |
||
112 | 112 | } |
113 | 113 | $ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message)); |
114 | 114 | $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; |
115 | - $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); |
|
115 | + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); |
|
116 | 116 | $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); |
117 | 117 | $this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout); |
118 | 118 | if(!$this->_ftp_data_sock) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | class ftp_pure extends ftp_base { |
29 | 29 | |
30 | - function __construct($verb=FALSE, $le=FALSE) { |
|
30 | + function __construct($verb = FALSE, $le = FALSE) { |
|
31 | 31 | parent::__construct(false, $verb, $le); |
32 | 32 | } |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | // <!-- --------------------------------------------------------------------------------------- --> |
37 | 37 | |
38 | 38 | function _settimeout($sock) { |
39 | - if(!@stream_set_timeout($sock, $this->_timeout)) { |
|
40 | - $this->PushError('_settimeout','socket set send timeout'); |
|
39 | + if ( ! @stream_set_timeout($sock, $this->_timeout)) { |
|
40 | + $this->PushError('_settimeout', 'socket set send timeout'); |
|
41 | 41 | $this->_quit(); |
42 | 42 | return FALSE; |
43 | 43 | } |
@@ -47,72 +47,72 @@ discard block |
||
47 | 47 | function _connect($host, $port) { |
48 | 48 | $this->SendMSG("Creating socket"); |
49 | 49 | $sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); |
50 | - if (!$sock) { |
|
51 | - $this->PushError('_connect','socket connect failed', $errstr." (".$errno.")"); |
|
50 | + if ( ! $sock) { |
|
51 | + $this->PushError('_connect', 'socket connect failed', $errstr." (".$errno.")"); |
|
52 | 52 | return FALSE; |
53 | 53 | } |
54 | - $this->_connected=true; |
|
54 | + $this->_connected = true; |
|
55 | 55 | return $sock; |
56 | 56 | } |
57 | 57 | |
58 | - function _readmsg($fnction="_readmsg"){ |
|
59 | - if(!$this->_connected) { |
|
58 | + function _readmsg($fnction = "_readmsg") { |
|
59 | + if ( ! $this->_connected) { |
|
60 | 60 | $this->PushError($fnction, 'Connect first'); |
61 | 61 | return FALSE; |
62 | 62 | } |
63 | - $result=true; |
|
64 | - $this->_message=""; |
|
65 | - $this->_code=0; |
|
66 | - $go=true; |
|
63 | + $result = true; |
|
64 | + $this->_message = ""; |
|
65 | + $this->_code = 0; |
|
66 | + $go = true; |
|
67 | 67 | do { |
68 | - $tmp=@fgets($this->_ftp_control_sock, 512); |
|
69 | - if($tmp===false) { |
|
70 | - $go=$result=false; |
|
71 | - $this->PushError($fnction,'Read failed'); |
|
68 | + $tmp = @fgets($this->_ftp_control_sock, 512); |
|
69 | + if ($tmp === false) { |
|
70 | + $go = $result = false; |
|
71 | + $this->PushError($fnction, 'Read failed'); |
|
72 | 72 | } else { |
73 | - $this->_message.=$tmp; |
|
74 | - if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false; |
|
73 | + $this->_message .= $tmp; |
|
74 | + if (preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go = false; |
|
75 | 75 | } |
76 | - } while($go); |
|
77 | - if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; |
|
78 | - $this->_code=(int)$regs[1]; |
|
76 | + } while ($go); |
|
77 | + if ($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; |
|
78 | + $this->_code = (int) $regs[1]; |
|
79 | 79 | return $result; |
80 | 80 | } |
81 | 81 | |
82 | - function _exec($cmd, $fnction="_exec") { |
|
83 | - if(!$this->_ready) { |
|
84 | - $this->PushError($fnction,'Connect first'); |
|
82 | + function _exec($cmd, $fnction = "_exec") { |
|
83 | + if ( ! $this->_ready) { |
|
84 | + $this->PushError($fnction, 'Connect first'); |
|
85 | 85 | return FALSE; |
86 | 86 | } |
87 | - if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; |
|
88 | - $status=@fputs($this->_ftp_control_sock, $cmd.CRLF); |
|
89 | - if($status===false) { |
|
90 | - $this->PushError($fnction,'socket write failed'); |
|
87 | + if ($this->LocalEcho) echo "PUT > ", $cmd, CRLF; |
|
88 | + $status = @fputs($this->_ftp_control_sock, $cmd.CRLF); |
|
89 | + if ($status === false) { |
|
90 | + $this->PushError($fnction, 'socket write failed'); |
|
91 | 91 | return FALSE; |
92 | 92 | } |
93 | - $this->_lastaction=time(); |
|
94 | - if(!$this->_readmsg($fnction)) return FALSE; |
|
93 | + $this->_lastaction = time(); |
|
94 | + if ( ! $this->_readmsg($fnction)) return FALSE; |
|
95 | 95 | return TRUE; |
96 | 96 | } |
97 | 97 | |
98 | - function _data_prepare($mode=FTP_ASCII) { |
|
99 | - if(!$this->_settype($mode)) return FALSE; |
|
100 | - if($this->_passive) { |
|
101 | - if(!$this->_exec("PASV", "pasv")) { |
|
98 | + function _data_prepare($mode = FTP_ASCII) { |
|
99 | + if ( ! $this->_settype($mode)) return FALSE; |
|
100 | + if ($this->_passive) { |
|
101 | + if ( ! $this->_exec("PASV", "pasv")) { |
|
102 | 102 | $this->_data_close(); |
103 | 103 | return FALSE; |
104 | 104 | } |
105 | - if(!$this->_checkCode()) { |
|
105 | + if ( ! $this->_checkCode()) { |
|
106 | 106 | $this->_data_close(); |
107 | 107 | return FALSE; |
108 | 108 | } |
109 | 109 | $ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message)); |
110 | - $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; |
|
111 | - $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); |
|
110 | + $this->_datahost = $ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; |
|
111 | + $this->_dataport = (((int) $ip_port[4]) << 8) + ((int) $ip_port[5]); |
|
112 | 112 | $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); |
113 | - $this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout); |
|
114 | - if(!$this->_ftp_data_sock) { |
|
115 | - $this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")"); |
|
113 | + $this->_ftp_data_sock = @fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout); |
|
114 | + if ( ! $this->_ftp_data_sock) { |
|
115 | + $this->PushError("_data_prepare", "fsockopen fails", $errstr." (".$errno.")"); |
|
116 | 116 | $this->_data_close(); |
117 | 117 | return FALSE; |
118 | 118 | } |
@@ -124,47 +124,47 @@ discard block |
||
124 | 124 | return TRUE; |
125 | 125 | } |
126 | 126 | |
127 | - function _data_read($mode=FTP_ASCII, $fp=NULL) { |
|
128 | - if(is_resource($fp)) $out=0; |
|
129 | - else $out=""; |
|
130 | - if(!$this->_passive) { |
|
127 | + function _data_read($mode = FTP_ASCII, $fp = NULL) { |
|
128 | + if (is_resource($fp)) $out = 0; |
|
129 | + else $out = ""; |
|
130 | + if ( ! $this->_passive) { |
|
131 | 131 | $this->SendMSG("Only passive connections available!"); |
132 | 132 | return FALSE; |
133 | 133 | } |
134 | - while (!feof($this->_ftp_data_sock)) { |
|
135 | - $block=fread($this->_ftp_data_sock, $this->_ftp_buff_size); |
|
136 | - if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); |
|
137 | - if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); |
|
138 | - else $out.=$block; |
|
134 | + while ( ! feof($this->_ftp_data_sock)) { |
|
135 | + $block = fread($this->_ftp_data_sock, $this->_ftp_buff_size); |
|
136 | + if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); |
|
137 | + if (is_resource($fp)) $out += fwrite($fp, $block, strlen($block)); |
|
138 | + else $out .= $block; |
|
139 | 139 | } |
140 | 140 | return $out; |
141 | 141 | } |
142 | 142 | |
143 | - function _data_write($mode=FTP_ASCII, $fp=NULL) { |
|
144 | - if(is_resource($fp)) $out=0; |
|
145 | - else $out=""; |
|
146 | - if(!$this->_passive) { |
|
143 | + function _data_write($mode = FTP_ASCII, $fp = NULL) { |
|
144 | + if (is_resource($fp)) $out = 0; |
|
145 | + else $out = ""; |
|
146 | + if ( ! $this->_passive) { |
|
147 | 147 | $this->SendMSG("Only passive connections available!"); |
148 | 148 | return FALSE; |
149 | 149 | } |
150 | - if(is_resource($fp)) { |
|
151 | - while(!feof($fp)) { |
|
152 | - $block=fread($fp, $this->_ftp_buff_size); |
|
153 | - if(!$this->_data_write_block($mode, $block)) return false; |
|
150 | + if (is_resource($fp)) { |
|
151 | + while ( ! feof($fp)) { |
|
152 | + $block = fread($fp, $this->_ftp_buff_size); |
|
153 | + if ( ! $this->_data_write_block($mode, $block)) return false; |
|
154 | 154 | } |
155 | - } elseif(!$this->_data_write_block($mode, $fp)) return false; |
|
155 | + } elseif ( ! $this->_data_write_block($mode, $fp)) return false; |
|
156 | 156 | return TRUE; |
157 | 157 | } |
158 | 158 | |
159 | 159 | function _data_write_block($mode, $block) { |
160 | - if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); |
|
160 | + if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); |
|
161 | 161 | do { |
162 | - if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) { |
|
163 | - $this->PushError("_data_write","Can't write to socket"); |
|
162 | + if (($t = @fwrite($this->_ftp_data_sock, $block)) === FALSE) { |
|
163 | + $this->PushError("_data_write", "Can't write to socket"); |
|
164 | 164 | return FALSE; |
165 | 165 | } |
166 | - $block=substr($block, $t); |
|
167 | - } while(!empty($block)); |
|
166 | + $block = substr($block, $t); |
|
167 | + } while ( ! empty($block)); |
|
168 | 168 | return true; |
169 | 169 | } |
170 | 170 | |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | return TRUE; |
175 | 175 | } |
176 | 176 | |
177 | - function _quit($force=FALSE) { |
|
178 | - if($this->_connected or $force) { |
|
177 | + function _quit($force = FALSE) { |
|
178 | + if ($this->_connected or $force) { |
|
179 | 179 | @fclose($this->_ftp_control_sock); |
180 | - $this->_connected=false; |
|
180 | + $this->_connected = false; |
|
181 | 181 | $this->SendMSG("Socket closed"); |
182 | 182 | } |
183 | 183 | } |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function category_exists( $cat_name, $parent = null ) { |
25 | 25 | $id = term_exists($cat_name, 'category', $parent); |
26 | - if ( is_array($id) ) |
|
27 | - $id = $id['term_id']; |
|
26 | + if ( is_array($id) ) { |
|
27 | + $id = $id['term_id']; |
|
28 | + } |
|
28 | 29 | return $id; |
29 | 30 | } |
30 | 31 | |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | * @return int|WP_Error |
53 | 54 | */ |
54 | 55 | function wp_create_category( $cat_name, $parent = 0 ) { |
55 | - if ( $id = category_exists($cat_name, $parent) ) |
|
56 | - return $id; |
|
56 | + if ( $id = category_exists($cat_name, $parent) ) { |
|
57 | + return $id; |
|
58 | + } |
|
57 | 59 | |
58 | 60 | return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) ); |
59 | 61 | } |
@@ -77,8 +79,9 @@ discard block |
||
77 | 79 | } |
78 | 80 | } |
79 | 81 | |
80 | - if ( $post_id ) |
|
81 | - wp_set_post_categories($post_id, $cat_ids); |
|
82 | + if ( $post_id ) { |
|
83 | + wp_set_post_categories($post_id, $cat_ids); |
|
84 | + } |
|
82 | 85 | |
83 | 86 | return $cat_ids; |
84 | 87 | } |
@@ -168,8 +171,9 @@ discard block |
||
168 | 171 | function wp_update_category($catarr) { |
169 | 172 | $cat_ID = (int) $catarr['cat_ID']; |
170 | 173 | |
171 | - if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) |
|
172 | - return false; |
|
174 | + if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) { |
|
175 | + return false; |
|
176 | + } |
|
173 | 177 | |
174 | 178 | // First, get all of the original fields |
175 | 179 | $category = get_term( $cat_ID, 'category', ARRAY_A ); |
@@ -236,8 +240,9 @@ discard block |
||
236 | 240 | */ |
237 | 241 | function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { |
238 | 242 | $post_id = (int) $post_id; |
239 | - if ( !$post_id ) |
|
240 | - return false; |
|
243 | + if ( !$post_id ) { |
|
244 | + return false; |
|
245 | + } |
|
241 | 246 | |
242 | 247 | $terms = get_object_term_cache( $post_id, $taxonomy ); |
243 | 248 | if ( false === $terms ) { |
@@ -283,8 +288,9 @@ discard block |
||
283 | 288 | * @return array|WP_Error |
284 | 289 | */ |
285 | 290 | function wp_create_term($tag_name, $taxonomy = 'post_tag') { |
286 | - if ( $id = term_exists($tag_name, $taxonomy) ) |
|
287 | - return $id; |
|
291 | + if ( $id = term_exists($tag_name, $taxonomy) ) { |
|
292 | + return $id; |
|
293 | + } |
|
288 | 294 | |
289 | 295 | return wp_insert_term($tag_name, $taxonomy); |
290 | 296 | } |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * @param int $parent Optional. ID of parent term. |
22 | 22 | * @return mixed |
23 | 23 | */ |
24 | -function category_exists( $cat_name, $parent = null ) { |
|
24 | +function category_exists($cat_name, $parent = null) { |
|
25 | 25 | $id = term_exists($cat_name, 'category', $parent); |
26 | - if ( is_array($id) ) |
|
26 | + if (is_array($id)) |
|
27 | 27 | $id = $id['term_id']; |
28 | 28 | return $id; |
29 | 29 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * @param int $id |
37 | 37 | * @return object |
38 | 38 | */ |
39 | -function get_category_to_edit( $id ) { |
|
40 | - $category = get_term( $id, 'category', OBJECT, 'edit' ); |
|
41 | - _make_cat_compat( $category ); |
|
39 | +function get_category_to_edit($id) { |
|
40 | + $category = get_term($id, 'category', OBJECT, 'edit'); |
|
41 | + _make_cat_compat($category); |
|
42 | 42 | return $category; |
43 | 43 | } |
44 | 44 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * @param int $parent |
52 | 52 | * @return int|WP_Error |
53 | 53 | */ |
54 | -function wp_create_category( $cat_name, $parent = 0 ) { |
|
55 | - if ( $id = category_exists($cat_name, $parent) ) |
|
54 | +function wp_create_category($cat_name, $parent = 0) { |
|
55 | + if ($id = category_exists($cat_name, $parent)) |
|
56 | 56 | return $id; |
57 | 57 | |
58 | - return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) ); |
|
58 | + return wp_insert_category(array('cat_name' => $cat_name, 'category_parent' => $parent)); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | * @param int $post_id Optional. The post ID. Default empty. |
68 | 68 | * @return array List of categories to create for the given post. |
69 | 69 | */ |
70 | -function wp_create_categories( $categories, $post_id = '' ) { |
|
71 | - $cat_ids = array (); |
|
72 | - foreach ( $categories as $category ) { |
|
73 | - if ( $id = category_exists( $category ) ) { |
|
70 | +function wp_create_categories($categories, $post_id = '') { |
|
71 | + $cat_ids = array(); |
|
72 | + foreach ($categories as $category) { |
|
73 | + if ($id = category_exists($category)) { |
|
74 | 74 | $cat_ids[] = $id; |
75 | - } elseif ( $id = wp_create_category( $category ) ) { |
|
75 | + } elseif ($id = wp_create_category($category)) { |
|
76 | 76 | $cat_ids[] = $id; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - if ( $post_id ) |
|
80 | + if ($post_id) |
|
81 | 81 | wp_set_post_categories($post_id, $cat_ids); |
82 | 82 | |
83 | 83 | return $cat_ids; |
@@ -105,47 +105,47 @@ discard block |
||
105 | 105 | * @return int|object The ID number of the new or updated Category on success. Zero or a WP_Error on failure, |
106 | 106 | * depending on param $wp_error. |
107 | 107 | */ |
108 | -function wp_insert_category( $catarr, $wp_error = false ) { |
|
109 | - $cat_defaults = array( 'cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '' ); |
|
110 | - $catarr = wp_parse_args( $catarr, $cat_defaults ); |
|
108 | +function wp_insert_category($catarr, $wp_error = false) { |
|
109 | + $cat_defaults = array('cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => ''); |
|
110 | + $catarr = wp_parse_args($catarr, $cat_defaults); |
|
111 | 111 | |
112 | - if ( trim( $catarr['cat_name'] ) == '' ) { |
|
113 | - if ( ! $wp_error ) { |
|
112 | + if (trim($catarr['cat_name']) == '') { |
|
113 | + if ( ! $wp_error) { |
|
114 | 114 | return 0; |
115 | 115 | } else { |
116 | - return new WP_Error( 'cat_name', __( 'You did not enter a category name.' ) ); |
|
116 | + return new WP_Error('cat_name', __('You did not enter a category name.')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | $catarr['cat_ID'] = (int) $catarr['cat_ID']; |
121 | 121 | |
122 | 122 | // Are we updating or creating? |
123 | - $update = ! empty ( $catarr['cat_ID'] ); |
|
123 | + $update = ! empty ($catarr['cat_ID']); |
|
124 | 124 | |
125 | 125 | $name = $catarr['cat_name']; |
126 | 126 | $description = $catarr['category_description']; |
127 | 127 | $slug = $catarr['category_nicename']; |
128 | 128 | $parent = (int) $catarr['category_parent']; |
129 | - if ( $parent < 0 ) { |
|
129 | + if ($parent < 0) { |
|
130 | 130 | $parent = 0; |
131 | 131 | } |
132 | 132 | |
133 | - if ( empty( $parent ) |
|
134 | - || ! term_exists( $parent, $catarr['taxonomy'] ) |
|
135 | - || ( $catarr['cat_ID'] && term_is_ancestor_of( $catarr['cat_ID'], $parent, $catarr['taxonomy'] ) ) ) { |
|
133 | + if (empty($parent) |
|
134 | + || ! term_exists($parent, $catarr['taxonomy']) |
|
135 | + || ($catarr['cat_ID'] && term_is_ancestor_of($catarr['cat_ID'], $parent, $catarr['taxonomy']))) { |
|
136 | 136 | $parent = 0; |
137 | 137 | } |
138 | 138 | |
139 | 139 | $args = compact('name', 'slug', 'parent', 'description'); |
140 | 140 | |
141 | - if ( $update ) { |
|
142 | - $catarr['cat_ID'] = wp_update_term( $catarr['cat_ID'], $catarr['taxonomy'], $args ); |
|
141 | + if ($update) { |
|
142 | + $catarr['cat_ID'] = wp_update_term($catarr['cat_ID'], $catarr['taxonomy'], $args); |
|
143 | 143 | } else { |
144 | - $catarr['cat_ID'] = wp_insert_term( $catarr['cat_name'], $catarr['taxonomy'], $args ); |
|
144 | + $catarr['cat_ID'] = wp_insert_term($catarr['cat_name'], $catarr['taxonomy'], $args); |
|
145 | 145 | } |
146 | 146 | |
147 | - if ( is_wp_error( $catarr['cat_ID'] ) ) { |
|
148 | - if ( $wp_error ) { |
|
147 | + if (is_wp_error($catarr['cat_ID'])) { |
|
148 | + if ($wp_error) { |
|
149 | 149 | return $catarr['cat_ID']; |
150 | 150 | } else { |
151 | 151 | return 0; |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | function wp_update_category($catarr) { |
169 | 169 | $cat_ID = (int) $catarr['cat_ID']; |
170 | 170 | |
171 | - if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) |
|
171 | + if (isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent'])) |
|
172 | 172 | return false; |
173 | 173 | |
174 | 174 | // First, get all of the original fields |
175 | - $category = get_term( $cat_ID, 'category', ARRAY_A ); |
|
176 | - _make_cat_compat( $category ); |
|
175 | + $category = get_term($cat_ID, 'category', ARRAY_A); |
|
176 | + _make_cat_compat($category); |
|
177 | 177 | |
178 | 178 | // Escape data pulled from DB. |
179 | 179 | $category = wp_slash($category); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return array|WP_Error |
210 | 210 | */ |
211 | 211 | function wp_create_tag($tag_name) { |
212 | - return wp_create_term( $tag_name, 'post_tag'); |
|
212 | + return wp_create_term($tag_name, 'post_tag'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. |
222 | 222 | * @return string|bool|WP_Error |
223 | 223 | */ |
224 | -function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { |
|
225 | - return get_terms_to_edit( $post_id, $taxonomy); |
|
224 | +function get_tags_to_edit($post_id, $taxonomy = 'post_tag') { |
|
225 | + return get_terms_to_edit($post_id, $taxonomy); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -234,29 +234,29 @@ discard block |
||
234 | 234 | * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. |
235 | 235 | * @return string|bool|WP_Error |
236 | 236 | */ |
237 | -function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { |
|
237 | +function get_terms_to_edit($post_id, $taxonomy = 'post_tag') { |
|
238 | 238 | $post_id = (int) $post_id; |
239 | - if ( !$post_id ) |
|
239 | + if ( ! $post_id) |
|
240 | 240 | return false; |
241 | 241 | |
242 | - $terms = get_object_term_cache( $post_id, $taxonomy ); |
|
243 | - if ( false === $terms ) { |
|
244 | - $terms = wp_get_object_terms( $post_id, $taxonomy ); |
|
245 | - wp_cache_add( $post_id, wp_list_pluck( $terms, 'term_id' ), $taxonomy . '_relationships' ); |
|
242 | + $terms = get_object_term_cache($post_id, $taxonomy); |
|
243 | + if (false === $terms) { |
|
244 | + $terms = wp_get_object_terms($post_id, $taxonomy); |
|
245 | + wp_cache_add($post_id, wp_list_pluck($terms, 'term_id'), $taxonomy.'_relationships'); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( ! $terms ) { |
|
248 | + if ( ! $terms) { |
|
249 | 249 | return false; |
250 | 250 | } |
251 | - if ( is_wp_error( $terms ) ) { |
|
251 | + if (is_wp_error($terms)) { |
|
252 | 252 | return $terms; |
253 | 253 | } |
254 | 254 | $term_names = array(); |
255 | - foreach ( $terms as $term ) { |
|
255 | + foreach ($terms as $term) { |
|
256 | 256 | $term_names[] = $term->name; |
257 | 257 | } |
258 | 258 | |
259 | - $terms_to_edit = esc_attr( join( ',', $term_names ) ); |
|
259 | + $terms_to_edit = esc_attr(join(',', $term_names)); |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Filters the comma-separated list of terms available to edit. |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @param array $terms_to_edit An array of terms. |
269 | 269 | * @param string $taxonomy The taxonomy for which to retrieve terms. Default 'post_tag'. |
270 | 270 | */ |
271 | - $terms_to_edit = apply_filters( 'terms_to_edit', $terms_to_edit, $taxonomy ); |
|
271 | + $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy); |
|
272 | 272 | |
273 | 273 | return $terms_to_edit; |
274 | 274 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return array|WP_Error |
284 | 284 | */ |
285 | 285 | function wp_create_term($tag_name, $taxonomy = 'post_tag') { |
286 | - if ( $id = term_exists($tag_name, $taxonomy) ) |
|
286 | + if ($id = term_exists($tag_name, $taxonomy)) |
|
287 | 287 | return $id; |
288 | 288 | |
289 | 289 | return wp_insert_term($tag_name, $taxonomy); |
@@ -48,14 +48,18 @@ discard block |
||
48 | 48 | |
49 | 49 | $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); |
50 | 50 | |
51 | - if ( 'all' != $cat_id ) |
|
52 | - $args['category'] = $cat_id; |
|
53 | - if ( !empty( $s ) ) |
|
54 | - $args['search'] = $s; |
|
55 | - if ( !empty( $orderby ) ) |
|
56 | - $args['orderby'] = $orderby; |
|
57 | - if ( !empty( $order ) ) |
|
58 | - $args['order'] = $order; |
|
51 | + if ( 'all' != $cat_id ) { |
|
52 | + $args['category'] = $cat_id; |
|
53 | + } |
|
54 | + if ( !empty( $s ) ) { |
|
55 | + $args['search'] = $s; |
|
56 | + } |
|
57 | + if ( !empty( $orderby ) ) { |
|
58 | + $args['orderby'] = $orderby; |
|
59 | + } |
|
60 | + if ( !empty( $order ) ) { |
|
61 | + $args['order'] = $order; |
|
62 | + } |
|
59 | 63 | |
60 | 64 | $this->items = get_bookmarks( $args ); |
61 | 65 | } |
@@ -86,9 +90,10 @@ discard block |
||
86 | 90 | protected function extra_tablenav( $which ) { |
87 | 91 | global $cat_id; |
88 | 92 | |
89 | - if ( 'top' != $which ) |
|
90 | - return; |
|
91 | -?> |
|
93 | + if ( 'top' != $which ) { |
|
94 | + return; |
|
95 | + } |
|
96 | + ?> |
|
92 | 97 | <div class="alignleft actions"> |
93 | 98 | <?php |
94 | 99 | $dropdown_options = array( |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @param array $args An associative array of arguments. |
29 | 29 | */ |
30 | - public function __construct( $args = array() ) { |
|
31 | - parent::__construct( array( |
|
30 | + public function __construct($args = array()) { |
|
31 | + parent::__construct(array( |
|
32 | 32 | 'plural' => 'bookmarks', |
33 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
34 | - ) ); |
|
33 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
34 | + )); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @return bool |
40 | 40 | */ |
41 | 41 | public function ajax_user_can() { |
42 | - return current_user_can( 'manage_links' ); |
|
42 | + return current_user_can('manage_links'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -52,27 +52,27 @@ discard block |
||
52 | 52 | public function prepare_items() { |
53 | 53 | global $cat_id, $s, $orderby, $order; |
54 | 54 | |
55 | - wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); |
|
55 | + wp_reset_vars(array('action', 'cat_id', 'link_id', 'orderby', 'order', 's')); |
|
56 | 56 | |
57 | - $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); |
|
57 | + $args = array('hide_invisible' => 0, 'hide_empty' => 0); |
|
58 | 58 | |
59 | - if ( 'all' != $cat_id ) |
|
59 | + if ('all' != $cat_id) |
|
60 | 60 | $args['category'] = $cat_id; |
61 | - if ( !empty( $s ) ) |
|
61 | + if ( ! empty($s)) |
|
62 | 62 | $args['search'] = $s; |
63 | - if ( !empty( $orderby ) ) |
|
63 | + if ( ! empty($orderby)) |
|
64 | 64 | $args['orderby'] = $orderby; |
65 | - if ( !empty( $order ) ) |
|
65 | + if ( ! empty($order)) |
|
66 | 66 | $args['order'] = $order; |
67 | 67 | |
68 | - $this->items = get_bookmarks( $args ); |
|
68 | + $this->items = get_bookmarks($args); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @access public |
73 | 73 | */ |
74 | 74 | public function no_items() { |
75 | - _e( 'No links found.' ); |
|
75 | + _e('No links found.'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function get_bulk_actions() { |
83 | 83 | $actions = array(); |
84 | - $actions['delete'] = __( 'Delete' ); |
|
84 | + $actions['delete'] = __('Delete'); |
|
85 | 85 | |
86 | 86 | return $actions; |
87 | 87 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * @global int $cat_id |
92 | 92 | * @param string $which |
93 | 93 | */ |
94 | - protected function extra_tablenav( $which ) { |
|
94 | + protected function extra_tablenav($which) { |
|
95 | 95 | global $cat_id; |
96 | 96 | |
97 | - if ( 'top' != $which ) |
|
97 | + if ('top' != $which) |
|
98 | 98 | return; |
99 | 99 | ?> |
100 | 100 | <div class="alignleft actions"> |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | 'selected' => $cat_id, |
104 | 104 | 'name' => 'cat_id', |
105 | 105 | 'taxonomy' => 'link_category', |
106 | - 'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items, |
|
106 | + 'show_option_all' => get_taxonomy('link_category')->labels->all_items, |
|
107 | 107 | 'hide_empty' => true, |
108 | 108 | 'hierarchical' => 1, |
109 | 109 | 'show_count' => 0, |
110 | 110 | 'orderby' => 'name', |
111 | 111 | ); |
112 | 112 | |
113 | - echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>'; |
|
114 | - wp_dropdown_categories( $dropdown_options ); |
|
115 | - submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
113 | + echo '<label class="screen-reader-text" for="cat_id">'.__('Filter by category').'</label>'; |
|
114 | + wp_dropdown_categories($dropdown_options); |
|
115 | + submit_button(__('Filter'), '', 'filter_action', false, array('id' => 'post-query-submit')); |
|
116 | 116 | ?> |
117 | 117 | </div> |
118 | 118 | <?php |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | public function get_columns() { |
126 | 126 | return array( |
127 | 127 | 'cb' => '<input type="checkbox" />', |
128 | - 'name' => _x( 'Name', 'link name' ), |
|
129 | - 'url' => __( 'URL' ), |
|
130 | - 'categories' => __( 'Categories' ), |
|
131 | - 'rel' => __( 'Relationship' ), |
|
132 | - 'visible' => __( 'Visible' ), |
|
133 | - 'rating' => __( 'Rating' ) |
|
128 | + 'name' => _x('Name', 'link name'), |
|
129 | + 'url' => __('URL'), |
|
130 | + 'categories' => __('Categories'), |
|
131 | + 'rel' => __('Relationship'), |
|
132 | + 'visible' => __('Visible'), |
|
133 | + 'rating' => __('Rating') |
|
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @param object $link The current link object. |
169 | 169 | */ |
170 | - public function column_cb( $link ) { |
|
170 | + public function column_cb($link) { |
|
171 | 171 | ?> |
172 | - <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label> |
|
173 | - <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> |
|
172 | + <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf(__('Select %s'), $link->link_name); ?></label> |
|
173 | + <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr($link->link_id); ?>" /> |
|
174 | 174 | <?php |
175 | 175 | } |
176 | 176 | |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @param object $link The current link object. |
184 | 184 | */ |
185 | - public function column_name( $link ) { |
|
186 | - $edit_link = get_edit_bookmark_link( $link ); |
|
187 | - printf( '<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>', |
|
185 | + public function column_name($link) { |
|
186 | + $edit_link = get_edit_bookmark_link($link); |
|
187 | + printf('<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>', |
|
188 | 188 | $edit_link, |
189 | 189 | /* translators: %s: link name */ |
190 | - esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ), |
|
190 | + esc_attr(sprintf(__('Edit “%s”'), $link->link_name)), |
|
191 | 191 | $link->link_name |
192 | 192 | ); |
193 | 193 | } |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $link The current link object. |
202 | 202 | */ |
203 | - public function column_url( $link ) { |
|
204 | - $short_url = url_shorten( $link->link_url ); |
|
203 | + public function column_url($link) { |
|
204 | + $short_url = url_shorten($link->link_url); |
|
205 | 205 | echo "<a href='$link->link_url'>$short_url</a>"; |
206 | 206 | } |
207 | 207 | |
@@ -215,22 +215,22 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @param object $link The current link object. |
217 | 217 | */ |
218 | - public function column_categories( $link ) { |
|
218 | + public function column_categories($link) { |
|
219 | 219 | global $cat_id; |
220 | 220 | |
221 | 221 | $cat_names = array(); |
222 | - foreach ( $link->link_category as $category ) { |
|
223 | - $cat = get_term( $category, 'link_category', OBJECT, 'display' ); |
|
224 | - if ( is_wp_error( $cat ) ) { |
|
222 | + foreach ($link->link_category as $category) { |
|
223 | + $cat = get_term($category, 'link_category', OBJECT, 'display'); |
|
224 | + if (is_wp_error($cat)) { |
|
225 | 225 | echo $cat->get_error_message(); |
226 | 226 | } |
227 | 227 | $cat_name = $cat->name; |
228 | - if ( $cat_id != $category ) { |
|
228 | + if ($cat_id != $category) { |
|
229 | 229 | $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; |
230 | 230 | } |
231 | 231 | $cat_names[] = $cat_name; |
232 | 232 | } |
233 | - echo implode( ', ', $cat_names ); |
|
233 | + echo implode(', ', $cat_names); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param object $link The current link object. |
243 | 243 | */ |
244 | - public function column_rel( $link ) { |
|
245 | - echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; |
|
244 | + public function column_rel($link) { |
|
245 | + echo empty($link->link_rel) ? '<br />' : $link->link_rel; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param object $link The current link object. |
255 | 255 | */ |
256 | - public function column_visible( $link ) { |
|
257 | - if ( 'Y' === $link->link_visible ) { |
|
258 | - _e( 'Yes' ); |
|
256 | + public function column_visible($link) { |
|
257 | + if ('Y' === $link->link_visible) { |
|
258 | + _e('Yes'); |
|
259 | 259 | } else { |
260 | - _e( 'No' ); |
|
260 | + _e('No'); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @param object $link The current link object. |
271 | 271 | */ |
272 | - public function column_rating( $link ) { |
|
272 | + public function column_rating($link) { |
|
273 | 273 | echo $link->link_rating; |
274 | 274 | } |
275 | 275 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param object $link Link object. |
283 | 283 | * @param string $column_name Current column name. |
284 | 284 | */ |
285 | - public function column_default( $link, $column_name ) { |
|
285 | + public function column_default($link, $column_name) { |
|
286 | 286 | /** |
287 | 287 | * Fires for each registered custom link column. |
288 | 288 | * |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | * @param string $column_name Name of the custom column. |
292 | 292 | * @param int $link_id Link ID. |
293 | 293 | */ |
294 | - do_action( 'manage_link_custom_column', $column_name, $link->link_id ); |
|
294 | + do_action('manage_link_custom_column', $column_name, $link->link_id); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | public function display_rows() { |
298 | - foreach ( $this->items as $link ) { |
|
299 | - $link = sanitize_bookmark( $link ); |
|
300 | - $link->link_name = esc_attr( $link->link_name ); |
|
301 | - $link->link_category = wp_get_link_cats( $link->link_id ); |
|
298 | + foreach ($this->items as $link) { |
|
299 | + $link = sanitize_bookmark($link); |
|
300 | + $link->link_name = esc_attr($link->link_name); |
|
301 | + $link->link_category = wp_get_link_cats($link->link_id); |
|
302 | 302 | ?> |
303 | 303 | <tr id="link-<?php echo $link->link_id; ?>"> |
304 | - <?php $this->single_row_columns( $link ) ?> |
|
304 | + <?php $this->single_row_columns($link) ?> |
|
305 | 305 | </tr> |
306 | 306 | <?php |
307 | 307 | } |
@@ -318,16 +318,16 @@ discard block |
||
318 | 318 | * @param string $primary Primary column name. |
319 | 319 | * @return string Row action output for links. |
320 | 320 | */ |
321 | - protected function handle_row_actions( $link, $column_name, $primary ) { |
|
322 | - if ( $primary !== $column_name ) { |
|
321 | + protected function handle_row_actions($link, $column_name, $primary) { |
|
322 | + if ($primary !== $column_name) { |
|
323 | 323 | return ''; |
324 | 324 | } |
325 | 325 | |
326 | - $edit_link = get_edit_bookmark_link( $link ); |
|
326 | + $edit_link = get_edit_bookmark_link($link); |
|
327 | 327 | |
328 | 328 | $actions = array(); |
329 | - $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; |
|
330 | - $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>"; |
|
331 | - return $this->row_actions( $actions ); |
|
329 | + $actions['edit'] = '<a href="'.$edit_link.'">'.__('Edit').'</a>'; |
|
330 | + $actions['delete'] = "<a class='submitdelete' href='".wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_'.$link->link_id)."' onclick=\"if ( confirm( '".esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name))."' ) ) { return true;}return false;\">".__('Delete')."</a>"; |
|
331 | + return $this->row_actions($actions); |
|
332 | 332 | } |
333 | 333 | } |
@@ -7,6 +7,6 @@ |
||
7 | 7 | * @since 3.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -wp_redirect( network_admin_url('settings.php') ); |
|
12 | +wp_redirect(network_admin_url('settings.php')); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @since 3.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -wp_redirect( network_admin_url() ); |
|
12 | +wp_redirect(network_admin_url()); |
|
13 | 13 | exit; |
@@ -7,8 +7,9 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // don't load directly |
10 | -if ( !defined('ABSPATH') ) |
|
10 | +if ( !defined('ABSPATH') ) { |
|
11 | 11 | die('-1'); |
12 | +} |
|
12 | 13 | ?> |
13 | 14 | |
14 | 15 | <div class="clear"></div></div><!-- wpbody-content --> |
@@ -88,9 +89,10 @@ discard block |
||
88 | 89 | |
89 | 90 | // get_site_option() won't exist when auto upgrading from <= 2.7 |
90 | 91 | if ( function_exists('get_site_option') ) { |
91 | - if ( false === get_site_option('can_compress_scripts') ) |
|
92 | - compression_test(); |
|
93 | -} |
|
92 | + if ( false === get_site_option('can_compress_scripts') ) { |
|
93 | + compression_test(); |
|
94 | + } |
|
95 | + } |
|
94 | 96 | |
95 | 97 | ?> |
96 | 98 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // don't load directly |
10 | -if ( !defined('ABSPATH') ) |
|
10 | +if ( ! defined('ABSPATH')) |
|
11 | 11 | die('-1'); |
12 | 12 | |
13 | 13 | /** |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @since 2.5.0 |
29 | 29 | */ |
30 | - do_action( 'in_admin_footer' ); |
|
30 | + do_action('in_admin_footer'); |
|
31 | 31 | ?> |
32 | 32 | <p id="footer-left" class="alignleft"> |
33 | 33 | <?php |
34 | - $text = sprintf( __( 'Thank you for creating with <a href="%s">WordPress</a>.' ), __( 'https://wordpress.org/' ) ); |
|
34 | + $text = sprintf(__('Thank you for creating with <a href="%s">WordPress</a>.'), __('https://wordpress.org/')); |
|
35 | 35 | /** |
36 | 36 | * Filters the "Thank you" text displayed in the admin footer. |
37 | 37 | * |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param string $text The content that will be printed. |
41 | 41 | */ |
42 | - echo apply_filters( 'admin_footer_text', '<span id="footer-thankyou">' . $text . '</span>' ); |
|
42 | + echo apply_filters('admin_footer_text', '<span id="footer-thankyou">'.$text.'</span>'); |
|
43 | 43 | ?> |
44 | 44 | </p> |
45 | 45 | <p id="footer-upgrade" class="alignright"> |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param string $content The content that will be printed. |
58 | 58 | */ |
59 | - echo apply_filters( 'update_footer', '' ); |
|
59 | + echo apply_filters('update_footer', ''); |
|
60 | 60 | ?> |
61 | 61 | </p> |
62 | 62 | <div class="clear"></div> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @param string $data The data to print. |
71 | 71 | */ |
72 | -do_action( 'admin_footer', '' ); |
|
72 | +do_action('admin_footer', ''); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Prints scripts and data queued for the footer. |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param string $hook_suffix The current admin page. |
85 | 85 | */ |
86 | -do_action( "admin_print_footer_scripts-{$hook_suffix}" ); |
|
86 | +do_action("admin_print_footer_scripts-{$hook_suffix}"); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Prints any scripts and data queued for the footer. |
90 | 90 | * |
91 | 91 | * @since 2.8.0 |
92 | 92 | */ |
93 | -do_action( 'admin_print_footer_scripts' ); |
|
93 | +do_action('admin_print_footer_scripts'); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Prints scripts or data after the default footer scripts. |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @global string $hook_suffix |
104 | 104 | * @param string $hook_suffix The current admin page. |
105 | 105 | */ |
106 | -do_action( "admin_footer-{$hook_suffix}" ); |
|
106 | +do_action("admin_footer-{$hook_suffix}"); |
|
107 | 107 | |
108 | 108 | // get_site_option() won't exist when auto upgrading from <= 2.7 |
109 | -if ( function_exists('get_site_option') ) { |
|
110 | - if ( false === get_site_option('can_compress_scripts') ) |
|
109 | +if (function_exists('get_site_option')) { |
|
110 | + if (false === get_site_option('can_compress_scripts')) |
|
111 | 111 | compression_test(); |
112 | 112 | } |
113 | 113 |