@@ -183,7 +183,7 @@ |
||
| 183 | 183 | * @access public |
| 184 | 184 | * |
| 185 | 185 | * @param string $name Property to check if set. |
| 186 | - * @return bool Whether the property is set. |
|
| 186 | + * @return boolean|null Whether the property is set. |
|
| 187 | 187 | */ |
| 188 | 188 | public function __isset( $name ) { |
| 189 | 189 | if ( in_array( $name, $this->compat_fields ) ) { |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Base class for displaying a list of items in an ajaxified HTML table. |
|
| 4 | - * |
|
| 5 | - * @since 3.1.0 |
|
| 6 | - * @access private |
|
| 7 | - * |
|
| 8 | - * @package WordPress |
|
| 9 | - * @subpackage List_Table |
|
| 10 | - */ |
|
| 3 | + * Base class for displaying a list of items in an ajaxified HTML table. |
|
| 4 | + * |
|
| 5 | + * @since 3.1.0 |
|
| 6 | + * @access private |
|
| 7 | + * |
|
| 8 | + * @package WordPress |
|
| 9 | + * @subpackage List_Table |
|
| 10 | + */ |
|
| 11 | 11 | class WP_List_Table { |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | protected $_column_headers; |
| 81 | 81 | |
| 82 | - protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' ); |
|
| 82 | + protected $compat_fields = array('_args', '_pagination_args', 'screen', '_actions', '_pagination'); |
|
| 83 | 83 | |
| 84 | - protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', |
|
| 84 | + protected $compat_methods = array('set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', |
|
| 85 | 85 | 'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination', |
| 86 | 86 | 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav', |
| 87 | - 'single_row_columns' ); |
|
| 87 | + 'single_row_columns'); |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * Constructor. |
@@ -112,35 +112,35 @@ discard block |
||
| 112 | 112 | * Default null. |
| 113 | 113 | * } |
| 114 | 114 | */ |
| 115 | - public function __construct( $args = array() ) { |
|
| 116 | - $args = wp_parse_args( $args, array( |
|
| 115 | + public function __construct($args = array()) { |
|
| 116 | + $args = wp_parse_args($args, array( |
|
| 117 | 117 | 'plural' => '', |
| 118 | 118 | 'singular' => '', |
| 119 | 119 | 'ajax' => false, |
| 120 | 120 | 'screen' => null, |
| 121 | - ) ); |
|
| 121 | + )); |
|
| 122 | 122 | |
| 123 | - $this->screen = convert_to_screen( $args['screen'] ); |
|
| 123 | + $this->screen = convert_to_screen($args['screen']); |
|
| 124 | 124 | |
| 125 | - add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
|
| 125 | + add_filter("manage_{$this->screen->id}_columns", array($this, 'get_columns'), 0); |
|
| 126 | 126 | |
| 127 | - if ( !$args['plural'] ) |
|
| 127 | + if ( ! $args['plural']) |
|
| 128 | 128 | $args['plural'] = $this->screen->base; |
| 129 | 129 | |
| 130 | - $args['plural'] = sanitize_key( $args['plural'] ); |
|
| 131 | - $args['singular'] = sanitize_key( $args['singular'] ); |
|
| 130 | + $args['plural'] = sanitize_key($args['plural']); |
|
| 131 | + $args['singular'] = sanitize_key($args['singular']); |
|
| 132 | 132 | |
| 133 | 133 | $this->_args = $args; |
| 134 | 134 | |
| 135 | - if ( $args['ajax'] ) { |
|
| 135 | + if ($args['ajax']) { |
|
| 136 | 136 | // wp_enqueue_script( 'list-table' ); |
| 137 | - add_action( 'admin_footer', array( $this, '_js_vars' ) ); |
|
| 137 | + add_action('admin_footer', array($this, '_js_vars')); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ( empty( $this->modes ) ) { |
|
| 140 | + if (empty($this->modes)) { |
|
| 141 | 141 | $this->modes = array( |
| 142 | - 'list' => __( 'List View' ), |
|
| 143 | - 'excerpt' => __( 'Excerpt View' ) |
|
| 142 | + 'list' => __('List View'), |
|
| 143 | + 'excerpt' => __('Excerpt View') |
|
| 144 | 144 | ); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | * @param string $name Property to get. |
| 155 | 155 | * @return mixed Property. |
| 156 | 156 | */ |
| 157 | - public function __get( $name ) { |
|
| 158 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 157 | + public function __get($name) { |
|
| 158 | + if (in_array($name, $this->compat_fields)) { |
|
| 159 | 159 | return $this->$name; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * @param mixed $value Property value. |
| 171 | 171 | * @return mixed Newly-set property. |
| 172 | 172 | */ |
| 173 | - public function __set( $name, $value ) { |
|
| 174 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 173 | + public function __set($name, $value) { |
|
| 174 | + if (in_array($name, $this->compat_fields)) { |
|
| 175 | 175 | return $this->$name = $value; |
| 176 | 176 | } |
| 177 | 177 | } |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | * @param string $name Property to check if set. |
| 186 | 186 | * @return bool Whether the property is set. |
| 187 | 187 | */ |
| 188 | - public function __isset( $name ) { |
|
| 189 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 190 | - return isset( $this->$name ); |
|
| 188 | + public function __isset($name) { |
|
| 189 | + if (in_array($name, $this->compat_fields)) { |
|
| 190 | + return isset($this->$name); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @param string $name Property to unset. |
| 201 | 201 | */ |
| 202 | - public function __unset( $name ) { |
|
| 203 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 204 | - unset( $this->$name ); |
|
| 202 | + public function __unset($name) { |
|
| 203 | + if (in_array($name, $this->compat_fields)) { |
|
| 204 | + unset($this->$name); |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | * @param array $arguments Arguments to pass when calling. |
| 216 | 216 | * @return mixed|bool Return value of the callback, false otherwise. |
| 217 | 217 | */ |
| 218 | - public function __call( $name, $arguments ) { |
|
| 219 | - if ( in_array( $name, $this->compat_methods ) ) { |
|
| 220 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 218 | + public function __call($name, $arguments) { |
|
| 219 | + if (in_array($name, $this->compat_methods)) { |
|
| 220 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 221 | 221 | } |
| 222 | 222 | return false; |
| 223 | 223 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @abstract |
| 231 | 231 | */ |
| 232 | 232 | public function ajax_user_can() { |
| 233 | - die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' ); |
|
| 233 | + die('function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.'); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @abstract |
| 243 | 243 | */ |
| 244 | 244 | public function prepare_items() { |
| 245 | - die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' ); |
|
| 245 | + die('function WP_List_Table::prepare_items() must be over-ridden in a sub-class.'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -253,19 +253,19 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param array|string $args |
| 255 | 255 | */ |
| 256 | - protected function set_pagination_args( $args ) { |
|
| 257 | - $args = wp_parse_args( $args, array( |
|
| 256 | + protected function set_pagination_args($args) { |
|
| 257 | + $args = wp_parse_args($args, array( |
|
| 258 | 258 | 'total_items' => 0, |
| 259 | 259 | 'total_pages' => 0, |
| 260 | 260 | 'per_page' => 0, |
| 261 | - ) ); |
|
| 261 | + )); |
|
| 262 | 262 | |
| 263 | - if ( !$args['total_pages'] && $args['per_page'] > 0 ) |
|
| 264 | - $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
| 263 | + if ( ! $args['total_pages'] && $args['per_page'] > 0) |
|
| 264 | + $args['total_pages'] = ceil($args['total_items'] / $args['per_page']); |
|
| 265 | 265 | |
| 266 | 266 | // Redirect if page number is invalid and headers are not already sent. |
| 267 | - if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
|
| 268 | - wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) ); |
|
| 267 | + if ( ! headers_sent() && ( ! defined('DOING_AJAX') || ! DOING_AJAX) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages']) { |
|
| 268 | + wp_redirect(add_query_arg('paged', $args['total_pages'])); |
|
| 269 | 269 | exit; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | * 'total_pages', 'per_page', or 'infinite_scroll'. |
| 283 | 283 | * @return int Number of items that correspond to the given pagination argument. |
| 284 | 284 | */ |
| 285 | - public function get_pagination_arg( $key ) { |
|
| 286 | - if ( 'page' == $key ) |
|
| 285 | + public function get_pagination_arg($key) { |
|
| 286 | + if ('page' == $key) |
|
| 287 | 287 | return $this->get_pagenum(); |
| 288 | 288 | |
| 289 | - if ( isset( $this->_pagination_args[$key] ) ) |
|
| 289 | + if (isset($this->_pagination_args[$key])) |
|
| 290 | 290 | return $this->_pagination_args[$key]; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return bool |
| 300 | 300 | */ |
| 301 | 301 | public function has_items() { |
| 302 | - return !empty( $this->items ); |
|
| 302 | + return ! empty($this->items); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @access public |
| 310 | 310 | */ |
| 311 | 311 | public function no_items() { |
| 312 | - _e( 'No items found.' ); |
|
| 312 | + _e('No items found.'); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -321,25 +321,25 @@ discard block |
||
| 321 | 321 | * @param string $text The search button text |
| 322 | 322 | * @param string $input_id The search input id |
| 323 | 323 | */ |
| 324 | - public function search_box( $text, $input_id ) { |
|
| 325 | - if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
|
| 324 | + public function search_box($text, $input_id) { |
|
| 325 | + if (empty($_REQUEST['s']) && ! $this->has_items()) |
|
| 326 | 326 | return; |
| 327 | 327 | |
| 328 | - $input_id = $input_id . '-search-input'; |
|
| 328 | + $input_id = $input_id.'-search-input'; |
|
| 329 | 329 | |
| 330 | - if ( ! empty( $_REQUEST['orderby'] ) ) |
|
| 331 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 332 | - if ( ! empty( $_REQUEST['order'] ) ) |
|
| 333 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 334 | - if ( ! empty( $_REQUEST['post_mime_type'] ) ) |
|
| 335 | - echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
| 336 | - if ( ! empty( $_REQUEST['detached'] ) ) |
|
| 337 | - echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
| 330 | + if ( ! empty($_REQUEST['orderby'])) |
|
| 331 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
| 332 | + if ( ! empty($_REQUEST['order'])) |
|
| 333 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
| 334 | + if ( ! empty($_REQUEST['post_mime_type'])) |
|
| 335 | + echo '<input type="hidden" name="post_mime_type" value="'.esc_attr($_REQUEST['post_mime_type']).'" />'; |
|
| 336 | + if ( ! empty($_REQUEST['detached'])) |
|
| 337 | + echo '<input type="hidden" name="detached" value="'.esc_attr($_REQUEST['detached']).'" />'; |
|
| 338 | 338 | ?> |
| 339 | 339 | <p class="search-box"> |
| 340 | 340 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
| 341 | 341 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
| 342 | - <?php submit_button( $text, 'button', '', false, array('id' => 'search-submit') ); ?> |
|
| 342 | + <?php submit_button($text, 'button', '', false, array('id' => 'search-submit')); ?> |
|
| 343 | 343 | </p> |
| 344 | 344 | <?php |
| 345 | 345 | } |
@@ -375,16 +375,16 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @param array $views An array of available list table views. |
| 377 | 377 | */ |
| 378 | - $views = apply_filters( "views_{$this->screen->id}", $views ); |
|
| 378 | + $views = apply_filters("views_{$this->screen->id}", $views); |
|
| 379 | 379 | |
| 380 | - if ( empty( $views ) ) |
|
| 380 | + if (empty($views)) |
|
| 381 | 381 | return; |
| 382 | 382 | |
| 383 | 383 | echo "<ul class='subsubsub'>\n"; |
| 384 | - foreach ( $views as $class => $view ) { |
|
| 385 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
| 384 | + foreach ($views as $class => $view) { |
|
| 385 | + $views[$class] = "\t<li class='$class'>$view"; |
|
| 386 | 386 | } |
| 387 | - echo implode( " |</li>\n", $views ) . "</li>\n"; |
|
| 387 | + echo implode(" |</li>\n", $views)."</li>\n"; |
|
| 388 | 388 | echo "</ul>"; |
| 389 | 389 | } |
| 390 | 390 | |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | * @param string $which The location of the bulk actions: 'top' or 'bottom'. |
| 411 | 411 | * This is designated as optional for backwards-compatibility. |
| 412 | 412 | */ |
| 413 | - protected function bulk_actions( $which = '' ) { |
|
| 414 | - if ( is_null( $this->_actions ) ) { |
|
| 413 | + protected function bulk_actions($which = '') { |
|
| 414 | + if (is_null($this->_actions)) { |
|
| 415 | 415 | $no_new_actions = $this->_actions = $this->get_bulk_actions(); |
| 416 | 416 | /** |
| 417 | 417 | * Filter the list table Bulk Actions drop-down. |
@@ -425,21 +425,21 @@ discard block |
||
| 425 | 425 | * |
| 426 | 426 | * @param array $actions An array of the available bulk actions. |
| 427 | 427 | */ |
| 428 | - $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); |
|
| 429 | - $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions ); |
|
| 428 | + $this->_actions = apply_filters("bulk_actions-{$this->screen->id}", $this->_actions); |
|
| 429 | + $this->_actions = array_intersect_assoc($this->_actions, $no_new_actions); |
|
| 430 | 430 | $two = ''; |
| 431 | 431 | } else { |
| 432 | 432 | $two = '2'; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - if ( empty( $this->_actions ) ) |
|
| 435 | + if (empty($this->_actions)) |
|
| 436 | 436 | return; |
| 437 | 437 | |
| 438 | - echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . __( 'Select bulk action' ) . "</label>"; |
|
| 439 | - echo "<select name='action$two' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n"; |
|
| 440 | - echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions' ) . "</option>\n"; |
|
| 438 | + echo "<label for='bulk-action-selector-".esc_attr($which)."' class='screen-reader-text'>".__('Select bulk action')."</label>"; |
|
| 439 | + echo "<select name='action$two' id='bulk-action-selector-".esc_attr($which)."'>\n"; |
|
| 440 | + echo "<option value='-1' selected='selected'>".__('Bulk Actions')."</option>\n"; |
|
| 441 | 441 | |
| 442 | - foreach ( $this->_actions as $name => $title ) { |
|
| 442 | + foreach ($this->_actions as $name => $title) { |
|
| 443 | 443 | $class = 'edit' == $name ? ' class="hide-if-no-js"' : ''; |
| 444 | 444 | |
| 445 | 445 | echo "\t<option value='$name'$class>$title</option>\n"; |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | echo "</select>\n"; |
| 449 | 449 | |
| 450 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
| 450 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
| 451 | 451 | echo "\n"; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -460,13 +460,13 @@ discard block |
||
| 460 | 460 | * @return string|false The action name or False if no action was selected |
| 461 | 461 | */ |
| 462 | 462 | public function current_action() { |
| 463 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) |
|
| 463 | + if (isset($_REQUEST['filter_action']) && ! empty($_REQUEST['filter_action'])) |
|
| 464 | 464 | return false; |
| 465 | 465 | |
| 466 | - if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) |
|
| 466 | + if (isset($_REQUEST['action']) && -1 != $_REQUEST['action']) |
|
| 467 | 467 | return $_REQUEST['action']; |
| 468 | 468 | |
| 469 | - if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) |
|
| 469 | + if (isset($_REQUEST['action2']) && -1 != $_REQUEST['action2']) |
|
| 470 | 470 | return $_REQUEST['action2']; |
| 471 | 471 | |
| 472 | 472 | return false; |
@@ -482,22 +482,22 @@ discard block |
||
| 482 | 482 | * @param bool $always_visible Whether the actions should be always visible |
| 483 | 483 | * @return string |
| 484 | 484 | */ |
| 485 | - protected function row_actions( $actions, $always_visible = false ) { |
|
| 486 | - $action_count = count( $actions ); |
|
| 485 | + protected function row_actions($actions, $always_visible = false) { |
|
| 486 | + $action_count = count($actions); |
|
| 487 | 487 | $i = 0; |
| 488 | 488 | |
| 489 | - if ( !$action_count ) |
|
| 489 | + if ( ! $action_count) |
|
| 490 | 490 | return ''; |
| 491 | 491 | |
| 492 | - $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
|
| 493 | - foreach ( $actions as $action => $link ) { |
|
| 492 | + $out = '<div class="'.($always_visible ? 'row-actions visible' : 'row-actions').'">'; |
|
| 493 | + foreach ($actions as $action => $link) { |
|
| 494 | 494 | ++$i; |
| 495 | - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
| 495 | + ($i == $action_count) ? $sep = '' : $sep = ' | '; |
|
| 496 | 496 | $out .= "<span class='$action'>$link$sep</span>"; |
| 497 | 497 | } |
| 498 | 498 | $out .= '</div>'; |
| 499 | 499 | |
| 500 | - $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>'; |
|
| 500 | + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>'; |
|
| 501 | 501 | |
| 502 | 502 | return $out; |
| 503 | 503 | } |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | * |
| 514 | 514 | * @param string $post_type |
| 515 | 515 | */ |
| 516 | - protected function months_dropdown( $post_type ) { |
|
| 516 | + protected function months_dropdown($post_type) { |
|
| 517 | 517 | global $wpdb, $wp_locale; |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -524,16 +524,16 @@ discard block |
||
| 524 | 524 | * @param bool $disable Whether to disable the drop-down. Default false. |
| 525 | 525 | * @param string $post_type The post type. |
| 526 | 526 | */ |
| 527 | - if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) { |
|
| 527 | + if (apply_filters('disable_months_dropdown', false, $post_type)) { |
|
| 528 | 528 | return; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - $months = $wpdb->get_results( $wpdb->prepare( " |
|
| 531 | + $months = $wpdb->get_results($wpdb->prepare(" |
|
| 532 | 532 | SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
| 533 | 533 | FROM $wpdb->posts |
| 534 | 534 | WHERE post_type = %s |
| 535 | 535 | ORDER BY post_date DESC |
| 536 | - ", $post_type ) ); |
|
| 536 | + ", $post_type)); |
|
| 537 | 537 | |
| 538 | 538 | /** |
| 539 | 539 | * Filter the 'Months' drop-down results. |
@@ -543,31 +543,31 @@ discard block |
||
| 543 | 543 | * @param object $months The months drop-down query results. |
| 544 | 544 | * @param string $post_type The post type. |
| 545 | 545 | */ |
| 546 | - $months = apply_filters( 'months_dropdown_results', $months, $post_type ); |
|
| 546 | + $months = apply_filters('months_dropdown_results', $months, $post_type); |
|
| 547 | 547 | |
| 548 | - $month_count = count( $months ); |
|
| 548 | + $month_count = count($months); |
|
| 549 | 549 | |
| 550 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
| 550 | + if ( ! $month_count || (1 == $month_count && 0 == $months[0]->month)) |
|
| 551 | 551 | return; |
| 552 | 552 | |
| 553 | - $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
|
| 553 | + $m = isset($_GET['m']) ? (int) $_GET['m'] : 0; |
|
| 554 | 554 | ?> |
| 555 | - <label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label> |
|
| 555 | + <label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date'); ?></label> |
|
| 556 | 556 | <select name="m" id="filter-by-date"> |
| 557 | - <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
|
| 557 | + <option<?php selected($m, 0); ?> value="0"><?php _e('All dates'); ?></option> |
|
| 558 | 558 | <?php |
| 559 | - foreach ( $months as $arc_row ) { |
|
| 560 | - if ( 0 == $arc_row->year ) |
|
| 559 | + foreach ($months as $arc_row) { |
|
| 560 | + if (0 == $arc_row->year) |
|
| 561 | 561 | continue; |
| 562 | 562 | |
| 563 | - $month = zeroise( $arc_row->month, 2 ); |
|
| 563 | + $month = zeroise($arc_row->month, 2); |
|
| 564 | 564 | $year = $arc_row->year; |
| 565 | 565 | |
| 566 | - printf( "<option %s value='%s'>%s</option>\n", |
|
| 567 | - selected( $m, $year . $month, false ), |
|
| 568 | - esc_attr( $arc_row->year . $month ), |
|
| 566 | + printf("<option %s value='%s'>%s</option>\n", |
|
| 567 | + selected($m, $year.$month, false), |
|
| 568 | + esc_attr($arc_row->year.$month), |
|
| 569 | 569 | /* translators: 1: month name, 2: 4-digit year */ |
| 570 | - sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) |
|
| 570 | + sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year) |
|
| 571 | 571 | ); |
| 572 | 572 | } |
| 573 | 573 | ?> |
@@ -583,19 +583,19 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @param string $current_mode |
| 585 | 585 | */ |
| 586 | - protected function view_switcher( $current_mode ) { |
|
| 586 | + protected function view_switcher($current_mode) { |
|
| 587 | 587 | ?> |
| 588 | - <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" /> |
|
| 588 | + <input type="hidden" name="mode" value="<?php echo esc_attr($current_mode); ?>" /> |
|
| 589 | 589 | <div class="view-switch"> |
| 590 | 590 | <?php |
| 591 | - foreach ( $this->modes as $mode => $title ) { |
|
| 592 | - $classes = array( 'view-' . $mode ); |
|
| 593 | - if ( $current_mode == $mode ) |
|
| 591 | + foreach ($this->modes as $mode => $title) { |
|
| 592 | + $classes = array('view-'.$mode); |
|
| 593 | + if ($current_mode == $mode) |
|
| 594 | 594 | $classes[] = 'current'; |
| 595 | 595 | printf( |
| 596 | 596 | "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
| 597 | - esc_url( add_query_arg( 'mode', $mode ) ), |
|
| 598 | - implode( ' ', $classes ), |
|
| 597 | + esc_url(add_query_arg('mode', $mode)), |
|
| 598 | + implode(' ', $classes), |
|
| 599 | 599 | $title |
| 600 | 600 | ); |
| 601 | 601 | } |
@@ -613,45 +613,45 @@ discard block |
||
| 613 | 613 | * @param int $post_id The post ID. |
| 614 | 614 | * @param int $pending_comments Number of pending comments. |
| 615 | 615 | */ |
| 616 | - protected function comments_bubble( $post_id, $pending_comments ) { |
|
| 616 | + protected function comments_bubble($post_id, $pending_comments) { |
|
| 617 | 617 | $approved_comments = get_comments_number(); |
| 618 | 618 | |
| 619 | - $approved_comments_number = number_format_i18n( $approved_comments ); |
|
| 620 | - $pending_comments_number = number_format_i18n( $pending_comments ); |
|
| 619 | + $approved_comments_number = number_format_i18n($approved_comments); |
|
| 620 | + $pending_comments_number = number_format_i18n($pending_comments); |
|
| 621 | 621 | |
| 622 | - $approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number ); |
|
| 623 | - $approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number ); |
|
| 624 | - $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number ); |
|
| 622 | + $approved_only_phrase = sprintf(_n('%s comment', '%s comments', $approved_comments), $approved_comments_number); |
|
| 623 | + $approved_phrase = sprintf(_n('%s approved comment', '%s approved comments', $approved_comments), $approved_comments_number); |
|
| 624 | + $pending_phrase = sprintf(_n('%s pending comment', '%s pending comments', $pending_comments), $pending_comments_number); |
|
| 625 | 625 | |
| 626 | 626 | // No comments at all. |
| 627 | - if ( ! $approved_comments && ! $pending_comments ) { |
|
| 628 | - printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', |
|
| 629 | - __( 'No comments' ) |
|
| 627 | + if ( ! $approved_comments && ! $pending_comments) { |
|
| 628 | + printf('<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', |
|
| 629 | + __('No comments') |
|
| 630 | 630 | ); |
| 631 | 631 | // Approved comments have different display depending on some conditions. |
| 632 | - } elseif ( $approved_comments ) { |
|
| 633 | - printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 634 | - esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ), |
|
| 632 | + } elseif ($approved_comments) { |
|
| 633 | + printf('<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 634 | + esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'approved'), admin_url('edit-comments.php'))), |
|
| 635 | 635 | $approved_comments_number, |
| 636 | 636 | $pending_comments ? $approved_phrase : $approved_only_phrase |
| 637 | 637 | ); |
| 638 | 638 | } else { |
| 639 | - printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 639 | + printf('<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 640 | 640 | $approved_comments_number, |
| 641 | - $pending_comments ? __( 'No approved comments' ) : __( 'No comments' ) |
|
| 641 | + $pending_comments ? __('No approved comments') : __('No comments') |
|
| 642 | 642 | ); |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - if ( $pending_comments ) { |
|
| 646 | - printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 647 | - esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ), |
|
| 645 | + if ($pending_comments) { |
|
| 646 | + printf('<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 647 | + esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'moderated'), admin_url('edit-comments.php'))), |
|
| 648 | 648 | $pending_comments_number, |
| 649 | 649 | $pending_phrase |
| 650 | 650 | ); |
| 651 | 651 | } else { |
| 652 | - printf( '<span class="post-com-count post-com-count-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 652 | + printf('<span class="post-com-count post-com-count-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 653 | 653 | $pending_comments_number, |
| 654 | - $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) |
|
| 654 | + $approved_comments ? __('No pending comments') : __('No comments') |
|
| 655 | 655 | ); |
| 656 | 656 | } |
| 657 | 657 | } |
@@ -665,12 +665,12 @@ discard block |
||
| 665 | 665 | * @return int |
| 666 | 666 | */ |
| 667 | 667 | public function get_pagenum() { |
| 668 | - $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; |
|
| 668 | + $pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0; |
|
| 669 | 669 | |
| 670 | - if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) |
|
| 670 | + if (isset($this->_pagination_args['total_pages']) && $pagenum > $this->_pagination_args['total_pages']) |
|
| 671 | 671 | $pagenum = $this->_pagination_args['total_pages']; |
| 672 | 672 | |
| 673 | - return max( 1, $pagenum ); |
|
| 673 | + return max(1, $pagenum); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
@@ -683,9 +683,9 @@ discard block |
||
| 683 | 683 | * @param int $default |
| 684 | 684 | * @return int |
| 685 | 685 | */ |
| 686 | - protected function get_items_per_page( $option, $default = 20 ) { |
|
| 687 | - $per_page = (int) get_user_option( $option ); |
|
| 688 | - if ( empty( $per_page ) || $per_page < 1 ) |
|
| 686 | + protected function get_items_per_page($option, $default = 20) { |
|
| 687 | + $per_page = (int) get_user_option($option); |
|
| 688 | + if (empty($per_page) || $per_page < 1) |
|
| 689 | 689 | $per_page = $default; |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | * |
| 702 | 702 | * @param int $per_page Number of items to be displayed. Default 20. |
| 703 | 703 | */ |
| 704 | - return (int) apply_filters( $option, $per_page ); |
|
| 704 | + return (int) apply_filters($option, $per_page); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -712,25 +712,25 @@ discard block |
||
| 712 | 712 | * |
| 713 | 713 | * @param string $which |
| 714 | 714 | */ |
| 715 | - protected function pagination( $which ) { |
|
| 716 | - if ( empty( $this->_pagination_args ) ) { |
|
| 715 | + protected function pagination($which) { |
|
| 716 | + if (empty($this->_pagination_args)) { |
|
| 717 | 717 | return; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | $total_items = $this->_pagination_args['total_items']; |
| 721 | 721 | $total_pages = $this->_pagination_args['total_pages']; |
| 722 | 722 | $infinite_scroll = false; |
| 723 | - if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { |
|
| 723 | + if (isset($this->_pagination_args['infinite_scroll'])) { |
|
| 724 | 724 | $infinite_scroll = $this->_pagination_args['infinite_scroll']; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>'; |
|
| 727 | + $output = '<span class="displaying-num">'.sprintf(_n('%s item', '%s items', $total_items), number_format_i18n($total_items)).'</span>'; |
|
| 728 | 728 | |
| 729 | 729 | $current = $this->get_pagenum(); |
| 730 | 730 | |
| 731 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 731 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
| 732 | 732 | |
| 733 | - $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ); |
|
| 733 | + $current_url = remove_query_arg(array('hotkeys_highlight_last', 'hotkeys_highlight_first'), $current_url); |
|
| 734 | 734 | |
| 735 | 735 | $page_links = array(); |
| 736 | 736 | |
@@ -739,81 +739,81 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | $disable_first = $disable_last = $disable_prev = $disable_next = false; |
| 741 | 741 | |
| 742 | - if ( $current == 1 ) { |
|
| 742 | + if ($current == 1) { |
|
| 743 | 743 | $disable_first = true; |
| 744 | 744 | $disable_prev = true; |
| 745 | 745 | } |
| 746 | - if ( $current == 2 ) { |
|
| 746 | + if ($current == 2) { |
|
| 747 | 747 | $disable_first = true; |
| 748 | 748 | } |
| 749 | - if ( $current == $total_pages ) { |
|
| 749 | + if ($current == $total_pages) { |
|
| 750 | 750 | $disable_last = true; |
| 751 | 751 | $disable_next = true; |
| 752 | 752 | } |
| 753 | - if ( $current == $total_pages - 1 ) { |
|
| 753 | + if ($current == $total_pages - 1) { |
|
| 754 | 754 | $disable_last = true; |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - if ( $disable_first ) { |
|
| 757 | + if ($disable_first) { |
|
| 758 | 758 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">«</span>'; |
| 759 | 759 | } else { |
| 760 | - $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 761 | - esc_url( remove_query_arg( 'paged', $current_url ) ), |
|
| 762 | - __( 'First page' ), |
|
| 760 | + $page_links[] = sprintf("<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 761 | + esc_url(remove_query_arg('paged', $current_url)), |
|
| 762 | + __('First page'), |
|
| 763 | 763 | '«' |
| 764 | 764 | ); |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | - if ( $disable_prev ) { |
|
| 767 | + if ($disable_prev) { |
|
| 768 | 768 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>'; |
| 769 | 769 | } else { |
| 770 | - $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 771 | - esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), |
|
| 772 | - __( 'Previous page' ), |
|
| 770 | + $page_links[] = sprintf("<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 771 | + esc_url(add_query_arg('paged', max(1, $current - 1), $current_url)), |
|
| 772 | + __('Previous page'), |
|
| 773 | 773 | '‹' |
| 774 | 774 | ); |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - if ( 'bottom' == $which ) { |
|
| 777 | + if ('bottom' == $which) { |
|
| 778 | 778 | $html_current_page = $current; |
| 779 | - $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input">'; |
|
| 779 | + $total_pages_before = '<span class="screen-reader-text">'.__('Current Page').'</span><span id="table-paging" class="paging-input">'; |
|
| 780 | 780 | } else { |
| 781 | - $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />", |
|
| 782 | - '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>', |
|
| 781 | + $html_current_page = sprintf("%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />", |
|
| 782 | + '<label for="current-page-selector" class="screen-reader-text">'.__('Current Page').'</label>', |
|
| 783 | 783 | $current, |
| 784 | - strlen( $total_pages ) |
|
| 784 | + strlen($total_pages) |
|
| 785 | 785 | ); |
| 786 | 786 | } |
| 787 | - $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
|
| 788 | - $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after; |
|
| 787 | + $html_total_pages = sprintf("<span class='total-pages'>%s</span>", number_format_i18n($total_pages)); |
|
| 788 | + $page_links[] = $total_pages_before.sprintf(_x('%1$s of %2$s', 'paging'), $html_current_page, $html_total_pages).$total_pages_after; |
|
| 789 | 789 | |
| 790 | - if ( $disable_next ) { |
|
| 790 | + if ($disable_next) { |
|
| 791 | 791 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>'; |
| 792 | 792 | } else { |
| 793 | - $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 794 | - esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), |
|
| 795 | - __( 'Next page' ), |
|
| 793 | + $page_links[] = sprintf("<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 794 | + esc_url(add_query_arg('paged', min($total_pages, $current + 1), $current_url)), |
|
| 795 | + __('Next page'), |
|
| 796 | 796 | '›' |
| 797 | 797 | ); |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - if ( $disable_last ) { |
|
| 800 | + if ($disable_last) { |
|
| 801 | 801 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">»</span>'; |
| 802 | 802 | } else { |
| 803 | - $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 804 | - esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), |
|
| 805 | - __( 'Last page' ), |
|
| 803 | + $page_links[] = sprintf("<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 804 | + esc_url(add_query_arg('paged', $total_pages, $current_url)), |
|
| 805 | + __('Last page'), |
|
| 806 | 806 | '»' |
| 807 | 807 | ); |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | $pagination_links_class = 'pagination-links'; |
| 811 | - if ( ! empty( $infinite_scroll ) ) { |
|
| 811 | + if ( ! empty($infinite_scroll)) { |
|
| 812 | 812 | $pagination_links_class = ' hide-if-js'; |
| 813 | 813 | } |
| 814 | - $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>'; |
|
| 814 | + $output .= "\n<span class='$pagination_links_class'>".join("\n", $page_links).'</span>'; |
|
| 815 | 815 | |
| 816 | - if ( $total_pages ) { |
|
| 816 | + if ($total_pages) { |
|
| 817 | 817 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 818 | 818 | } else { |
| 819 | 819 | $page_class = ' no-pages'; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | * @return array |
| 835 | 835 | */ |
| 836 | 836 | public function get_columns() { |
| 837 | - die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' ); |
|
| 837 | + die('function WP_List_Table::get_columns() must be over-ridden in a sub-class.'); |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | /** |
@@ -868,8 +868,8 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | // We need a primary defined so responsive views show something, |
| 870 | 870 | // so let's fall back to the first non-checkbox column. |
| 871 | - foreach( $columns as $col => $column_name ) { |
|
| 872 | - if ( 'cb' === $col ) { |
|
| 871 | + foreach ($columns as $col => $column_name) { |
|
| 872 | + if ('cb' === $col) { |
|
| 873 | 873 | continue; |
| 874 | 874 | } |
| 875 | 875 | |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | |
| 895 | 895 | // If the primary column doesn't exist fall back to the |
| 896 | 896 | // first non-checkbox column. |
| 897 | - if ( ! isset( $columns[ $default ] ) ) { |
|
| 897 | + if ( ! isset($columns[$default])) { |
|
| 898 | 898 | $default = WP_List_Table::get_default_primary_column_name(); |
| 899 | 899 | } |
| 900 | 900 | |
@@ -906,9 +906,9 @@ discard block |
||
| 906 | 906 | * @param string $default Column name default for the specific list table, e.g. 'name'. |
| 907 | 907 | * @param string $context Screen ID for specific list table, e.g. 'plugins'. |
| 908 | 908 | */ |
| 909 | - $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
|
| 909 | + $column = apply_filters('list_table_primary_column', $default, $this->screen->id); |
|
| 910 | 910 | |
| 911 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
| 911 | + if (empty($column) || ! isset($columns[$column])) { |
|
| 912 | 912 | $column = $default; |
| 913 | 913 | } |
| 914 | 914 | |
@@ -925,19 +925,19 @@ discard block |
||
| 925 | 925 | */ |
| 926 | 926 | protected function get_column_info() { |
| 927 | 927 | // $_column_headers is already set / cached |
| 928 | - if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { |
|
| 928 | + if (isset($this->_column_headers) && is_array($this->_column_headers)) { |
|
| 929 | 929 | // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. |
| 930 | 930 | // In 4.3, we added a fourth argument for primary column. |
| 931 | - $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
|
| 932 | - foreach ( $this->_column_headers as $key => $value ) { |
|
| 933 | - $column_headers[ $key ] = $value; |
|
| 931 | + $column_headers = array(array(), array(), array(), $this->get_primary_column_name()); |
|
| 932 | + foreach ($this->_column_headers as $key => $value) { |
|
| 933 | + $column_headers[$key] = $value; |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | return $column_headers; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - $columns = get_column_headers( $this->screen ); |
|
| 940 | - $hidden = get_hidden_columns( $this->screen ); |
|
| 939 | + $columns = get_column_headers($this->screen); |
|
| 940 | + $hidden = get_hidden_columns($this->screen); |
|
| 941 | 941 | |
| 942 | 942 | $sortable_columns = $this->get_sortable_columns(); |
| 943 | 943 | /** |
@@ -950,22 +950,22 @@ discard block |
||
| 950 | 950 | * |
| 951 | 951 | * @param array $sortable_columns An array of sortable columns. |
| 952 | 952 | */ |
| 953 | - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); |
|
| 953 | + $_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns); |
|
| 954 | 954 | |
| 955 | 955 | $sortable = array(); |
| 956 | - foreach ( $_sortable as $id => $data ) { |
|
| 957 | - if ( empty( $data ) ) |
|
| 956 | + foreach ($_sortable as $id => $data) { |
|
| 957 | + if (empty($data)) |
|
| 958 | 958 | continue; |
| 959 | 959 | |
| 960 | 960 | $data = (array) $data; |
| 961 | - if ( !isset( $data[1] ) ) |
|
| 961 | + if ( ! isset($data[1])) |
|
| 962 | 962 | $data[1] = false; |
| 963 | 963 | |
| 964 | 964 | $sortable[$id] = $data; |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | $primary = $this->get_primary_column_name(); |
| 968 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
| 968 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
| 969 | 969 | |
| 970 | 970 | return $this->_column_headers; |
| 971 | 971 | } |
@@ -979,9 +979,9 @@ discard block |
||
| 979 | 979 | * @return int |
| 980 | 980 | */ |
| 981 | 981 | public function get_column_count() { |
| 982 | - list ( $columns, $hidden ) = $this->get_column_info(); |
|
| 983 | - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); |
|
| 984 | - return count( $columns ) - count( $hidden ); |
|
| 982 | + list ($columns, $hidden) = $this->get_column_info(); |
|
| 983 | + $hidden = array_intersect(array_keys($columns), array_filter($hidden)); |
|
| 984 | + return count($columns) - count($hidden); |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | /** |
@@ -994,49 +994,49 @@ discard block |
||
| 994 | 994 | * |
| 995 | 995 | * @param bool $with_id Whether to set the id attribute or not |
| 996 | 996 | */ |
| 997 | - public function print_column_headers( $with_id = true ) { |
|
| 998 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
| 997 | + public function print_column_headers($with_id = true) { |
|
| 998 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
| 999 | 999 | |
| 1000 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 1001 | - $current_url = remove_query_arg( 'paged', $current_url ); |
|
| 1000 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
| 1001 | + $current_url = remove_query_arg('paged', $current_url); |
|
| 1002 | 1002 | |
| 1003 | - if ( isset( $_GET['orderby'] ) ) |
|
| 1003 | + if (isset($_GET['orderby'])) |
|
| 1004 | 1004 | $current_orderby = $_GET['orderby']; |
| 1005 | 1005 | else |
| 1006 | 1006 | $current_orderby = ''; |
| 1007 | 1007 | |
| 1008 | - if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) |
|
| 1008 | + if (isset($_GET['order']) && 'desc' == $_GET['order']) |
|
| 1009 | 1009 | $current_order = 'desc'; |
| 1010 | 1010 | else |
| 1011 | 1011 | $current_order = 'asc'; |
| 1012 | 1012 | |
| 1013 | - if ( ! empty( $columns['cb'] ) ) { |
|
| 1013 | + if ( ! empty($columns['cb'])) { |
|
| 1014 | 1014 | static $cb_counter = 1; |
| 1015 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
|
| 1016 | - . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
|
| 1015 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-'.$cb_counter.'">'.__('Select All').'</label>' |
|
| 1016 | + . '<input id="cb-select-all-'.$cb_counter.'" type="checkbox" />'; |
|
| 1017 | 1017 | $cb_counter++; |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | - foreach ( $columns as $column_key => $column_display_name ) { |
|
| 1021 | - $class = array( 'manage-column', "column-$column_key" ); |
|
| 1020 | + foreach ($columns as $column_key => $column_display_name) { |
|
| 1021 | + $class = array('manage-column', "column-$column_key"); |
|
| 1022 | 1022 | |
| 1023 | - if ( in_array( $column_key, $hidden ) ) { |
|
| 1023 | + if (in_array($column_key, $hidden)) { |
|
| 1024 | 1024 | $class[] = 'hidden'; |
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | - if ( 'cb' == $column_key ) |
|
| 1027 | + if ('cb' == $column_key) |
|
| 1028 | 1028 | $class[] = 'check-column'; |
| 1029 | - elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) |
|
| 1029 | + elseif (in_array($column_key, array('posts', 'comments', 'links'))) |
|
| 1030 | 1030 | $class[] = 'num'; |
| 1031 | 1031 | |
| 1032 | - if ( $column_key === $primary ) { |
|
| 1032 | + if ($column_key === $primary) { |
|
| 1033 | 1033 | $class[] = 'column-primary'; |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | - if ( isset( $sortable[$column_key] ) ) { |
|
| 1037 | - list( $orderby, $desc_first ) = $sortable[$column_key]; |
|
| 1036 | + if (isset($sortable[$column_key])) { |
|
| 1037 | + list($orderby, $desc_first) = $sortable[$column_key]; |
|
| 1038 | 1038 | |
| 1039 | - if ( $current_orderby == $orderby ) { |
|
| 1039 | + if ($current_orderby == $orderby) { |
|
| 1040 | 1040 | $order = 'asc' == $current_order ? 'desc' : 'asc'; |
| 1041 | 1041 | $class[] = 'sorted'; |
| 1042 | 1042 | $class[] = $current_order; |
@@ -1046,15 +1046,15 @@ discard block |
||
| 1046 | 1046 | $class[] = $desc_first ? 'asc' : 'desc'; |
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | - $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
|
| 1049 | + $column_display_name = '<a href="'.esc_url(add_query_arg(compact('orderby', 'order'), $current_url)).'"><span>'.$column_display_name.'</span><span class="sorting-indicator"></span></a>'; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
|
| 1053 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
|
| 1052 | + $tag = ('cb' === $column_key) ? 'td' : 'th'; |
|
| 1053 | + $scope = ('th' === $tag) ? 'scope="col"' : ''; |
|
| 1054 | 1054 | $id = $with_id ? "id='$column_key'" : ''; |
| 1055 | 1055 | |
| 1056 | - if ( !empty( $class ) ) |
|
| 1057 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
| 1056 | + if ( ! empty($class)) |
|
| 1057 | + $class = "class='".join(' ', $class)."'"; |
|
| 1058 | 1058 | |
| 1059 | 1059 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
| 1060 | 1060 | } |
@@ -1069,9 +1069,9 @@ discard block |
||
| 1069 | 1069 | public function display() { |
| 1070 | 1070 | $singular = $this->_args['singular']; |
| 1071 | 1071 | |
| 1072 | - $this->display_tablenav( 'top' ); |
|
| 1072 | + $this->display_tablenav('top'); |
|
| 1073 | 1073 | ?> |
| 1074 | -<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
| 1074 | +<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
| 1075 | 1075 | <thead> |
| 1076 | 1076 | <tr> |
| 1077 | 1077 | <?php $this->print_column_headers(); ?> |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | </thead> |
| 1080 | 1080 | |
| 1081 | 1081 | <tbody id="the-list"<?php |
| 1082 | - if ( $singular ) { |
|
| 1082 | + if ($singular) { |
|
| 1083 | 1083 | echo " data-wp-lists='list:$singular'"; |
| 1084 | 1084 | } ?>> |
| 1085 | 1085 | <?php $this->display_rows_or_placeholder(); ?> |
@@ -1087,13 +1087,13 @@ discard block |
||
| 1087 | 1087 | |
| 1088 | 1088 | <tfoot> |
| 1089 | 1089 | <tr> |
| 1090 | - <?php $this->print_column_headers( false ); ?> |
|
| 1090 | + <?php $this->print_column_headers(false); ?> |
|
| 1091 | 1091 | </tr> |
| 1092 | 1092 | </tfoot> |
| 1093 | 1093 | |
| 1094 | 1094 | </table> |
| 1095 | 1095 | <?php |
| 1096 | - $this->display_tablenav( 'bottom' ); |
|
| 1096 | + $this->display_tablenav('bottom'); |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | /** |
@@ -1105,7 +1105,7 @@ discard block |
||
| 1105 | 1105 | * @return array List of CSS classes for the table tag. |
| 1106 | 1106 | */ |
| 1107 | 1107 | protected function get_table_classes() { |
| 1108 | - return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] ); |
|
| 1108 | + return array('widefat', 'fixed', 'striped', $this->_args['plural']); |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | /** |
@@ -1115,18 +1115,18 @@ discard block |
||
| 1115 | 1115 | * @access protected |
| 1116 | 1116 | * @param string $which |
| 1117 | 1117 | */ |
| 1118 | - protected function display_tablenav( $which ) { |
|
| 1119 | - if ( 'top' == $which ) |
|
| 1120 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 1118 | + protected function display_tablenav($which) { |
|
| 1119 | + if ('top' == $which) |
|
| 1120 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 1121 | 1121 | ?> |
| 1122 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
| 1122 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
| 1123 | 1123 | |
| 1124 | 1124 | <div class="alignleft actions bulkactions"> |
| 1125 | - <?php $this->bulk_actions( $which ); ?> |
|
| 1125 | + <?php $this->bulk_actions($which); ?> |
|
| 1126 | 1126 | </div> |
| 1127 | 1127 | <?php |
| 1128 | - $this->extra_tablenav( $which ); |
|
| 1129 | - $this->pagination( $which ); |
|
| 1128 | + $this->extra_tablenav($which); |
|
| 1129 | + $this->pagination($which); |
|
| 1130 | 1130 | ?> |
| 1131 | 1131 | |
| 1132 | 1132 | <br class="clear" /> |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | * |
| 1143 | 1143 | * @param string $which |
| 1144 | 1144 | */ |
| 1145 | - protected function extra_tablenav( $which ) {} |
|
| 1145 | + protected function extra_tablenav($which) {} |
|
| 1146 | 1146 | |
| 1147 | 1147 | /** |
| 1148 | 1148 | * Generate the tbody element for the list table. |
@@ -1151,10 +1151,10 @@ discard block |
||
| 1151 | 1151 | * @access public |
| 1152 | 1152 | */ |
| 1153 | 1153 | public function display_rows_or_placeholder() { |
| 1154 | - if ( $this->has_items() ) { |
|
| 1154 | + if ($this->has_items()) { |
|
| 1155 | 1155 | $this->display_rows(); |
| 1156 | 1156 | } else { |
| 1157 | - echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
|
| 1157 | + echo '<tr class="no-items"><td class="colspanchange" colspan="'.$this->get_column_count().'">'; |
|
| 1158 | 1158 | $this->no_items(); |
| 1159 | 1159 | echo '</td></tr>'; |
| 1160 | 1160 | } |
@@ -1167,8 +1167,8 @@ discard block |
||
| 1167 | 1167 | * @access public |
| 1168 | 1168 | */ |
| 1169 | 1169 | public function display_rows() { |
| 1170 | - foreach ( $this->items as $item ) |
|
| 1171 | - $this->single_row( $item ); |
|
| 1170 | + foreach ($this->items as $item) |
|
| 1171 | + $this->single_row($item); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | /** |
@@ -1179,9 +1179,9 @@ discard block |
||
| 1179 | 1179 | * |
| 1180 | 1180 | * @param object $item The current item |
| 1181 | 1181 | */ |
| 1182 | - public function single_row( $item ) { |
|
| 1182 | + public function single_row($item) { |
|
| 1183 | 1183 | echo '<tr>'; |
| 1184 | - $this->single_row_columns( $item ); |
|
| 1184 | + $this->single_row_columns($item); |
|
| 1185 | 1185 | echo '</tr>'; |
| 1186 | 1186 | } |
| 1187 | 1187 | |
@@ -1190,13 +1190,13 @@ discard block |
||
| 1190 | 1190 | * @param object $item |
| 1191 | 1191 | * @param string $column_name |
| 1192 | 1192 | */ |
| 1193 | - protected function column_default( $item, $column_name ) {} |
|
| 1193 | + protected function column_default($item, $column_name) {} |
|
| 1194 | 1194 | |
| 1195 | 1195 | /** |
| 1196 | 1196 | * |
| 1197 | 1197 | * @param object $item |
| 1198 | 1198 | */ |
| 1199 | - protected function column_cb( $item ) {} |
|
| 1199 | + protected function column_cb($item) {} |
|
| 1200 | 1200 | |
| 1201 | 1201 | /** |
| 1202 | 1202 | * Generates the columns for a single row of the table |
@@ -1206,46 +1206,46 @@ discard block |
||
| 1206 | 1206 | * |
| 1207 | 1207 | * @param object $item The current item |
| 1208 | 1208 | */ |
| 1209 | - protected function single_row_columns( $item ) { |
|
| 1210 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
| 1209 | + protected function single_row_columns($item) { |
|
| 1210 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
| 1211 | 1211 | |
| 1212 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
| 1212 | + foreach ($columns as $column_name => $column_display_name) { |
|
| 1213 | 1213 | $classes = "$column_name column-$column_name"; |
| 1214 | - if ( $primary === $column_name ) { |
|
| 1214 | + if ($primary === $column_name) { |
|
| 1215 | 1215 | $classes .= ' has-row-actions column-primary'; |
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | - if ( in_array( $column_name, $hidden ) ) { |
|
| 1218 | + if (in_array($column_name, $hidden)) { |
|
| 1219 | 1219 | $classes .= ' hidden'; |
| 1220 | 1220 | } |
| 1221 | 1221 | |
| 1222 | 1222 | // Comments column uses HTML in the display name with screen reader text. |
| 1223 | 1223 | // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string. |
| 1224 | - $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
| 1224 | + $data = 'data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
| 1225 | 1225 | |
| 1226 | 1226 | $attributes = "class='$classes' $data"; |
| 1227 | 1227 | |
| 1228 | - if ( 'cb' == $column_name ) { |
|
| 1228 | + if ('cb' == $column_name) { |
|
| 1229 | 1229 | echo '<th scope="row" class="check-column">'; |
| 1230 | - echo $this->column_cb( $item ); |
|
| 1230 | + echo $this->column_cb($item); |
|
| 1231 | 1231 | echo '</th>'; |
| 1232 | - } elseif ( method_exists( $this, '_column_' . $column_name ) ) { |
|
| 1232 | + } elseif (method_exists($this, '_column_'.$column_name)) { |
|
| 1233 | 1233 | echo call_user_func( |
| 1234 | - array( $this, '_column_' . $column_name ), |
|
| 1234 | + array($this, '_column_'.$column_name), |
|
| 1235 | 1235 | $item, |
| 1236 | 1236 | $classes, |
| 1237 | 1237 | $data, |
| 1238 | 1238 | $primary |
| 1239 | 1239 | ); |
| 1240 | - } elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
| 1240 | + } elseif (method_exists($this, 'column_'.$column_name)) { |
|
| 1241 | 1241 | echo "<td $attributes>"; |
| 1242 | - echo call_user_func( array( $this, 'column_' . $column_name ), $item ); |
|
| 1243 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
| 1242 | + echo call_user_func(array($this, 'column_'.$column_name), $item); |
|
| 1243 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 1244 | 1244 | echo "</td>"; |
| 1245 | 1245 | } else { |
| 1246 | 1246 | echo "<td $attributes>"; |
| 1247 | - echo $this->column_default( $item, $column_name ); |
|
| 1248 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
| 1247 | + echo $this->column_default($item, $column_name); |
|
| 1248 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 1249 | 1249 | echo "</td>"; |
| 1250 | 1250 | } |
| 1251 | 1251 | } |
@@ -1262,8 +1262,8 @@ discard block |
||
| 1262 | 1262 | * @param string $primary Primary column name. |
| 1263 | 1263 | * @return string The row actions HTML, or an empty string if the current column is the primary column. |
| 1264 | 1264 | */ |
| 1265 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
| 1266 | - return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : ''; |
|
| 1265 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
| 1266 | + return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>' : ''; |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | /** |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | $this->prepare_items(); |
| 1277 | 1277 | |
| 1278 | 1278 | ob_start(); |
| 1279 | - if ( ! empty( $_REQUEST['no_placeholder'] ) ) { |
|
| 1279 | + if ( ! empty($_REQUEST['no_placeholder'])) { |
|
| 1280 | 1280 | $this->display_rows(); |
| 1281 | 1281 | } else { |
| 1282 | 1282 | $this->display_rows_or_placeholder(); |
@@ -1284,20 +1284,20 @@ discard block |
||
| 1284 | 1284 | |
| 1285 | 1285 | $rows = ob_get_clean(); |
| 1286 | 1286 | |
| 1287 | - $response = array( 'rows' => $rows ); |
|
| 1287 | + $response = array('rows' => $rows); |
|
| 1288 | 1288 | |
| 1289 | - if ( isset( $this->_pagination_args['total_items'] ) ) { |
|
| 1289 | + if (isset($this->_pagination_args['total_items'])) { |
|
| 1290 | 1290 | $response['total_items_i18n'] = sprintf( |
| 1291 | - _n( '%s item', '%s items', $this->_pagination_args['total_items'] ), |
|
| 1292 | - number_format_i18n( $this->_pagination_args['total_items'] ) |
|
| 1291 | + _n('%s item', '%s items', $this->_pagination_args['total_items']), |
|
| 1292 | + number_format_i18n($this->_pagination_args['total_items']) |
|
| 1293 | 1293 | ); |
| 1294 | 1294 | } |
| 1295 | - if ( isset( $this->_pagination_args['total_pages'] ) ) { |
|
| 1295 | + if (isset($this->_pagination_args['total_pages'])) { |
|
| 1296 | 1296 | $response['total_pages'] = $this->_pagination_args['total_pages']; |
| 1297 | - $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); |
|
| 1297 | + $response['total_pages_i18n'] = number_format_i18n($this->_pagination_args['total_pages']); |
|
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | - die( wp_json_encode( $response ) ); |
|
| 1300 | + die(wp_json_encode($response)); |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | /** |
@@ -1307,13 +1307,13 @@ discard block |
||
| 1307 | 1307 | */ |
| 1308 | 1308 | public function _js_vars() { |
| 1309 | 1309 | $args = array( |
| 1310 | - 'class' => get_class( $this ), |
|
| 1310 | + 'class' => get_class($this), |
|
| 1311 | 1311 | 'screen' => array( |
| 1312 | 1312 | 'id' => $this->screen->id, |
| 1313 | 1313 | 'base' => $this->screen->base, |
| 1314 | 1314 | ) |
| 1315 | 1315 | ); |
| 1316 | 1316 | |
| 1317 | - printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
|
| 1317 | + printf("<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode($args)); |
|
| 1318 | 1318 | } |
| 1319 | 1319 | } |
@@ -124,8 +124,9 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
| 126 | 126 | |
| 127 | - if ( !$args['plural'] ) |
|
| 128 | - $args['plural'] = $this->screen->base; |
|
| 127 | + if ( !$args['plural'] ) { |
|
| 128 | + $args['plural'] = $this->screen->base; |
|
| 129 | + } |
|
| 129 | 130 | |
| 130 | 131 | $args['plural'] = sanitize_key( $args['plural'] ); |
| 131 | 132 | $args['singular'] = sanitize_key( $args['singular'] ); |
@@ -260,8 +261,9 @@ discard block |
||
| 260 | 261 | 'per_page' => 0, |
| 261 | 262 | ) ); |
| 262 | 263 | |
| 263 | - if ( !$args['total_pages'] && $args['per_page'] > 0 ) |
|
| 264 | - $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
| 264 | + if ( !$args['total_pages'] && $args['per_page'] > 0 ) { |
|
| 265 | + $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
| 266 | + } |
|
| 265 | 267 | |
| 266 | 268 | // Redirect if page number is invalid and headers are not already sent. |
| 267 | 269 | if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
@@ -283,11 +285,13 @@ discard block |
||
| 283 | 285 | * @return int Number of items that correspond to the given pagination argument. |
| 284 | 286 | */ |
| 285 | 287 | public function get_pagination_arg( $key ) { |
| 286 | - if ( 'page' == $key ) |
|
| 287 | - return $this->get_pagenum(); |
|
| 288 | + if ( 'page' == $key ) { |
|
| 289 | + return $this->get_pagenum(); |
|
| 290 | + } |
|
| 288 | 291 | |
| 289 | - if ( isset( $this->_pagination_args[$key] ) ) |
|
| 290 | - return $this->_pagination_args[$key]; |
|
| 292 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
| 293 | + return $this->_pagination_args[$key]; |
|
| 294 | + } |
|
| 291 | 295 | } |
| 292 | 296 | |
| 293 | 297 | /** |
@@ -322,20 +326,25 @@ discard block |
||
| 322 | 326 | * @param string $input_id The search input id |
| 323 | 327 | */ |
| 324 | 328 | public function search_box( $text, $input_id ) { |
| 325 | - if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
|
| 326 | - return; |
|
| 329 | + if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) { |
|
| 330 | + return; |
|
| 331 | + } |
|
| 327 | 332 | |
| 328 | 333 | $input_id = $input_id . '-search-input'; |
| 329 | 334 | |
| 330 | - if ( ! empty( $_REQUEST['orderby'] ) ) |
|
| 331 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 332 | - if ( ! empty( $_REQUEST['order'] ) ) |
|
| 333 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 334 | - if ( ! empty( $_REQUEST['post_mime_type'] ) ) |
|
| 335 | - echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
| 336 | - if ( ! empty( $_REQUEST['detached'] ) ) |
|
| 337 | - echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
| 338 | -?> |
|
| 335 | + if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 336 | + echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 337 | + } |
|
| 338 | + if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 339 | + echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 340 | + } |
|
| 341 | + if ( ! empty( $_REQUEST['post_mime_type'] ) ) { |
|
| 342 | + echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
| 343 | + } |
|
| 344 | + if ( ! empty( $_REQUEST['detached'] ) ) { |
|
| 345 | + echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
| 346 | + } |
|
| 347 | + ?> |
|
| 339 | 348 | <p class="search-box"> |
| 340 | 349 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
| 341 | 350 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
@@ -377,8 +386,9 @@ discard block |
||
| 377 | 386 | */ |
| 378 | 387 | $views = apply_filters( "views_{$this->screen->id}", $views ); |
| 379 | 388 | |
| 380 | - if ( empty( $views ) ) |
|
| 381 | - return; |
|
| 389 | + if ( empty( $views ) ) { |
|
| 390 | + return; |
|
| 391 | + } |
|
| 382 | 392 | |
| 383 | 393 | echo "<ul class='subsubsub'>\n"; |
| 384 | 394 | foreach ( $views as $class => $view ) { |
@@ -432,8 +442,9 @@ discard block |
||
| 432 | 442 | $two = '2'; |
| 433 | 443 | } |
| 434 | 444 | |
| 435 | - if ( empty( $this->_actions ) ) |
|
| 436 | - return; |
|
| 445 | + if ( empty( $this->_actions ) ) { |
|
| 446 | + return; |
|
| 447 | + } |
|
| 437 | 448 | |
| 438 | 449 | echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . __( 'Select bulk action' ) . "</label>"; |
| 439 | 450 | echo "<select name='action$two' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n"; |
@@ -460,14 +471,17 @@ discard block |
||
| 460 | 471 | * @return string|false The action name or False if no action was selected |
| 461 | 472 | */ |
| 462 | 473 | public function current_action() { |
| 463 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) |
|
| 464 | - return false; |
|
| 474 | + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { |
|
| 475 | + return false; |
|
| 476 | + } |
|
| 465 | 477 | |
| 466 | - if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) |
|
| 467 | - return $_REQUEST['action']; |
|
| 478 | + if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { |
|
| 479 | + return $_REQUEST['action']; |
|
| 480 | + } |
|
| 468 | 481 | |
| 469 | - if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) |
|
| 470 | - return $_REQUEST['action2']; |
|
| 482 | + if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { |
|
| 483 | + return $_REQUEST['action2']; |
|
| 484 | + } |
|
| 471 | 485 | |
| 472 | 486 | return false; |
| 473 | 487 | } |
@@ -486,8 +500,9 @@ discard block |
||
| 486 | 500 | $action_count = count( $actions ); |
| 487 | 501 | $i = 0; |
| 488 | 502 | |
| 489 | - if ( !$action_count ) |
|
| 490 | - return ''; |
|
| 503 | + if ( !$action_count ) { |
|
| 504 | + return ''; |
|
| 505 | + } |
|
| 491 | 506 | |
| 492 | 507 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 493 | 508 | foreach ( $actions as $action => $link ) { |
@@ -547,8 +562,9 @@ discard block |
||
| 547 | 562 | |
| 548 | 563 | $month_count = count( $months ); |
| 549 | 564 | |
| 550 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
| 551 | - return; |
|
| 565 | + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { |
|
| 566 | + return; |
|
| 567 | + } |
|
| 552 | 568 | |
| 553 | 569 | $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
| 554 | 570 | ?> |
@@ -557,8 +573,9 @@ discard block |
||
| 557 | 573 | <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
| 558 | 574 | <?php |
| 559 | 575 | foreach ( $months as $arc_row ) { |
| 560 | - if ( 0 == $arc_row->year ) |
|
| 561 | - continue; |
|
| 576 | + if ( 0 == $arc_row->year ) { |
|
| 577 | + continue; |
|
| 578 | + } |
|
| 562 | 579 | |
| 563 | 580 | $month = zeroise( $arc_row->month, 2 ); |
| 564 | 581 | $year = $arc_row->year; |
@@ -590,8 +607,9 @@ discard block |
||
| 590 | 607 | <?php |
| 591 | 608 | foreach ( $this->modes as $mode => $title ) { |
| 592 | 609 | $classes = array( 'view-' . $mode ); |
| 593 | - if ( $current_mode == $mode ) |
|
| 594 | - $classes[] = 'current'; |
|
| 610 | + if ( $current_mode == $mode ) { |
|
| 611 | + $classes[] = 'current'; |
|
| 612 | + } |
|
| 595 | 613 | printf( |
| 596 | 614 | "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
| 597 | 615 | esc_url( add_query_arg( 'mode', $mode ) ), |
@@ -667,8 +685,9 @@ discard block |
||
| 667 | 685 | public function get_pagenum() { |
| 668 | 686 | $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; |
| 669 | 687 | |
| 670 | - if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) |
|
| 671 | - $pagenum = $this->_pagination_args['total_pages']; |
|
| 688 | + if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) { |
|
| 689 | + $pagenum = $this->_pagination_args['total_pages']; |
|
| 690 | + } |
|
| 672 | 691 | |
| 673 | 692 | return max( 1, $pagenum ); |
| 674 | 693 | } |
@@ -685,8 +704,9 @@ discard block |
||
| 685 | 704 | */ |
| 686 | 705 | protected function get_items_per_page( $option, $default = 20 ) { |
| 687 | 706 | $per_page = (int) get_user_option( $option ); |
| 688 | - if ( empty( $per_page ) || $per_page < 1 ) |
|
| 689 | - $per_page = $default; |
|
| 707 | + if ( empty( $per_page ) || $per_page < 1 ) { |
|
| 708 | + $per_page = $default; |
|
| 709 | + } |
|
| 690 | 710 | |
| 691 | 711 | /** |
| 692 | 712 | * Filter the number of items to be displayed on each page of the list table. |
@@ -954,12 +974,14 @@ discard block |
||
| 954 | 974 | |
| 955 | 975 | $sortable = array(); |
| 956 | 976 | foreach ( $_sortable as $id => $data ) { |
| 957 | - if ( empty( $data ) ) |
|
| 958 | - continue; |
|
| 977 | + if ( empty( $data ) ) { |
|
| 978 | + continue; |
|
| 979 | + } |
|
| 959 | 980 | |
| 960 | 981 | $data = (array) $data; |
| 961 | - if ( !isset( $data[1] ) ) |
|
| 962 | - $data[1] = false; |
|
| 982 | + if ( !isset( $data[1] ) ) { |
|
| 983 | + $data[1] = false; |
|
| 984 | + } |
|
| 963 | 985 | |
| 964 | 986 | $sortable[$id] = $data; |
| 965 | 987 | } |
@@ -1000,15 +1022,17 @@ discard block |
||
| 1000 | 1022 | $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
| 1001 | 1023 | $current_url = remove_query_arg( 'paged', $current_url ); |
| 1002 | 1024 | |
| 1003 | - if ( isset( $_GET['orderby'] ) ) |
|
| 1004 | - $current_orderby = $_GET['orderby']; |
|
| 1005 | - else |
|
| 1006 | - $current_orderby = ''; |
|
| 1025 | + if ( isset( $_GET['orderby'] ) ) { |
|
| 1026 | + $current_orderby = $_GET['orderby']; |
|
| 1027 | + } else { |
|
| 1028 | + $current_orderby = ''; |
|
| 1029 | + } |
|
| 1007 | 1030 | |
| 1008 | - if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) |
|
| 1009 | - $current_order = 'desc'; |
|
| 1010 | - else |
|
| 1011 | - $current_order = 'asc'; |
|
| 1031 | + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { |
|
| 1032 | + $current_order = 'desc'; |
|
| 1033 | + } else { |
|
| 1034 | + $current_order = 'asc'; |
|
| 1035 | + } |
|
| 1012 | 1036 | |
| 1013 | 1037 | if ( ! empty( $columns['cb'] ) ) { |
| 1014 | 1038 | static $cb_counter = 1; |
@@ -1024,10 +1048,11 @@ discard block |
||
| 1024 | 1048 | $class[] = 'hidden'; |
| 1025 | 1049 | } |
| 1026 | 1050 | |
| 1027 | - if ( 'cb' == $column_key ) |
|
| 1028 | - $class[] = 'check-column'; |
|
| 1029 | - elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) |
|
| 1030 | - $class[] = 'num'; |
|
| 1051 | + if ( 'cb' == $column_key ) { |
|
| 1052 | + $class[] = 'check-column'; |
|
| 1053 | + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { |
|
| 1054 | + $class[] = 'num'; |
|
| 1055 | + } |
|
| 1031 | 1056 | |
| 1032 | 1057 | if ( $column_key === $primary ) { |
| 1033 | 1058 | $class[] = 'column-primary'; |
@@ -1053,8 +1078,9 @@ discard block |
||
| 1053 | 1078 | $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
| 1054 | 1079 | $id = $with_id ? "id='$column_key'" : ''; |
| 1055 | 1080 | |
| 1056 | - if ( !empty( $class ) ) |
|
| 1057 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
| 1081 | + if ( !empty( $class ) ) { |
|
| 1082 | + $class = "class='" . join( ' ', $class ) . "'"; |
|
| 1083 | + } |
|
| 1058 | 1084 | |
| 1059 | 1085 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
| 1060 | 1086 | } |
@@ -1116,9 +1142,10 @@ discard block |
||
| 1116 | 1142 | * @param string $which |
| 1117 | 1143 | */ |
| 1118 | 1144 | protected function display_tablenav( $which ) { |
| 1119 | - if ( 'top' == $which ) |
|
| 1120 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 1121 | -?> |
|
| 1145 | + if ( 'top' == $which ) { |
|
| 1146 | + wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 1147 | + } |
|
| 1148 | + ?> |
|
| 1122 | 1149 | <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
| 1123 | 1150 | |
| 1124 | 1151 | <div class="alignleft actions bulkactions"> |
@@ -1167,8 +1194,9 @@ discard block |
||
| 1167 | 1194 | * @access public |
| 1168 | 1195 | */ |
| 1169 | 1196 | public function display_rows() { |
| 1170 | - foreach ( $this->items as $item ) |
|
| 1171 | - $this->single_row( $item ); |
|
| 1197 | + foreach ( $this->items as $item ) { |
|
| 1198 | + $this->single_row( $item ); |
|
| 1199 | + } |
|
| 1172 | 1200 | } |
| 1173 | 1201 | |
| 1174 | 1202 | /** |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * |
| 52 | - * @return array |
|
| 52 | + * @return string[] |
|
| 53 | 53 | */ |
| 54 | 54 | protected function get_table_classes() { |
| 55 | 55 | // todo: remove and add CSS for .themes |
@@ -27,24 +27,24 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param array $args An associative array of arguments. |
| 29 | 29 | */ |
| 30 | - public function __construct( $args = array() ) { |
|
| 30 | + public function __construct($args = array()) { |
|
| 31 | 31 | global $status, $page; |
| 32 | 32 | |
| 33 | - parent::__construct( array( |
|
| 33 | + parent::__construct(array( |
|
| 34 | 34 | 'plural' => 'themes', |
| 35 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
| 36 | - ) ); |
|
| 35 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; |
|
| 39 | - if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) |
|
| 38 | + $status = isset($_REQUEST['theme_status']) ? $_REQUEST['theme_status'] : 'all'; |
|
| 39 | + if ( ! in_array($status, array('all', 'enabled', 'disabled', 'upgrade', 'search', 'broken'))) |
|
| 40 | 40 | $status = 'all'; |
| 41 | 41 | |
| 42 | 42 | $page = $this->get_pagenum(); |
| 43 | 43 | |
| 44 | - $this->is_site_themes = ( 'site-themes-network' == $this->screen->id ) ? true : false; |
|
| 44 | + $this->is_site_themes = ('site-themes-network' == $this->screen->id) ? true : false; |
|
| 45 | 45 | |
| 46 | - if ( $this->is_site_themes ) |
|
| 47 | - $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
|
| 46 | + if ($this->is_site_themes) |
|
| 47 | + $this->site_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | protected function get_table_classes() { |
| 55 | 55 | // todo: remove and add CSS for .themes |
| 56 | - return array( 'widefat', 'plugins' ); |
|
| 56 | + return array('widefat', 'plugins'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | * @return bool |
| 62 | 62 | */ |
| 63 | 63 | public function ajax_user_can() { |
| 64 | - if ( $this->is_site_themes ) |
|
| 65 | - return current_user_can( 'manage_sites' ); |
|
| 64 | + if ($this->is_site_themes) |
|
| 65 | + return current_user_can('manage_sites'); |
|
| 66 | 66 | else |
| 67 | - return current_user_can( 'manage_network_themes' ); |
|
| 67 | + return current_user_can('manage_network_themes'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function prepare_items() { |
| 80 | 80 | global $status, $totals, $page, $orderby, $order, $s; |
| 81 | 81 | |
| 82 | - wp_reset_vars( array( 'orderby', 'order', 's' ) ); |
|
| 82 | + wp_reset_vars(array('orderby', 'order', 's')); |
|
| 83 | 83 | |
| 84 | 84 | $themes = array( |
| 85 | 85 | /** |
@@ -90,78 +90,78 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param array $all An array of WP_Theme objects to display in the list table. |
| 92 | 92 | */ |
| 93 | - 'all' => apply_filters( 'all_themes', wp_get_themes() ), |
|
| 93 | + 'all' => apply_filters('all_themes', wp_get_themes()), |
|
| 94 | 94 | 'search' => array(), |
| 95 | 95 | 'enabled' => array(), |
| 96 | 96 | 'disabled' => array(), |
| 97 | 97 | 'upgrade' => array(), |
| 98 | - 'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), |
|
| 98 | + 'broken' => $this->is_site_themes ? array() : wp_get_themes(array('errors' => true)), |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - if ( $this->is_site_themes ) { |
|
| 102 | - $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); |
|
| 101 | + if ($this->is_site_themes) { |
|
| 102 | + $themes_per_page = $this->get_items_per_page('site_themes_network_per_page'); |
|
| 103 | 103 | $allowed_where = 'site'; |
| 104 | 104 | } else { |
| 105 | - $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); |
|
| 105 | + $themes_per_page = $this->get_items_per_page('themes_network_per_page'); |
|
| 106 | 106 | $allowed_where = 'network'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' ); |
|
| 109 | + $maybe_update = current_user_can('update_themes') && ! $this->is_site_themes && $current = get_site_transient('update_themes'); |
|
| 110 | 110 | |
| 111 | - foreach ( (array) $themes['all'] as $key => $theme ) { |
|
| 112 | - if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { |
|
| 113 | - unset( $themes['all'][ $key ] ); |
|
| 111 | + foreach ((array) $themes['all'] as $key => $theme) { |
|
| 112 | + if ($this->is_site_themes && $theme->is_allowed('network')) { |
|
| 113 | + unset($themes['all'][$key]); |
|
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $maybe_update && isset( $current->response[ $key ] ) ) { |
|
| 118 | - $themes['all'][ $key ]->update = true; |
|
| 119 | - $themes['upgrade'][ $key ] = $themes['all'][ $key ]; |
|
| 117 | + if ($maybe_update && isset($current->response[$key])) { |
|
| 118 | + $themes['all'][$key]->update = true; |
|
| 119 | + $themes['upgrade'][$key] = $themes['all'][$key]; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; |
|
| 123 | - $themes[ $filter ][ $key ] = $themes['all'][ $key ]; |
|
| 122 | + $filter = $theme->is_allowed($allowed_where, $this->site_id) ? 'enabled' : 'disabled'; |
|
| 123 | + $themes[$filter][$key] = $themes['all'][$key]; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if ( $s ) { |
|
| 126 | + if ($s) { |
|
| 127 | 127 | $status = 'search'; |
| 128 | - $themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) ); |
|
| 128 | + $themes['search'] = array_filter(array_merge($themes['all'], $themes['broken']), array($this, '_search_callback')); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $totals = array(); |
| 132 | - foreach ( $themes as $type => $list ) |
|
| 133 | - $totals[ $type ] = count( $list ); |
|
| 132 | + foreach ($themes as $type => $list) |
|
| 133 | + $totals[$type] = count($list); |
|
| 134 | 134 | |
| 135 | - if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) |
|
| 135 | + if (empty($themes[$status]) && ! in_array($status, array('all', 'search'))) |
|
| 136 | 136 | $status = 'all'; |
| 137 | 137 | |
| 138 | - $this->items = $themes[ $status ]; |
|
| 139 | - WP_Theme::sort_by_name( $this->items ); |
|
| 138 | + $this->items = $themes[$status]; |
|
| 139 | + WP_Theme::sort_by_name($this->items); |
|
| 140 | 140 | |
| 141 | - $this->has_items = ! empty( $themes['all'] ); |
|
| 142 | - $total_this_page = $totals[ $status ]; |
|
| 141 | + $this->has_items = ! empty($themes['all']); |
|
| 142 | + $total_this_page = $totals[$status]; |
|
| 143 | 143 | |
| 144 | - if ( $orderby ) { |
|
| 145 | - $orderby = ucfirst( $orderby ); |
|
| 146 | - $order = strtoupper( $order ); |
|
| 144 | + if ($orderby) { |
|
| 145 | + $orderby = ucfirst($orderby); |
|
| 146 | + $order = strtoupper($order); |
|
| 147 | 147 | |
| 148 | - if ( $orderby == 'Name' ) { |
|
| 149 | - if ( 'ASC' == $order ) |
|
| 150 | - $this->items = array_reverse( $this->items ); |
|
| 148 | + if ($orderby == 'Name') { |
|
| 149 | + if ('ASC' == $order) |
|
| 150 | + $this->items = array_reverse($this->items); |
|
| 151 | 151 | } else { |
| 152 | - uasort( $this->items, array( $this, '_order_callback' ) ); |
|
| 152 | + uasort($this->items, array($this, '_order_callback')); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $start = ( $page - 1 ) * $themes_per_page; |
|
| 156 | + $start = ($page - 1) * $themes_per_page; |
|
| 157 | 157 | |
| 158 | - if ( $total_this_page > $themes_per_page ) |
|
| 159 | - $this->items = array_slice( $this->items, $start, $themes_per_page, true ); |
|
| 158 | + if ($total_this_page > $themes_per_page) |
|
| 159 | + $this->items = array_slice($this->items, $start, $themes_per_page, true); |
|
| 160 | 160 | |
| 161 | - $this->set_pagination_args( array( |
|
| 161 | + $this->set_pagination_args(array( |
|
| 162 | 162 | 'total_items' => $total_this_page, |
| 163 | 163 | 'per_page' => $themes_per_page, |
| 164 | - ) ); |
|
| 164 | + )); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -169,21 +169,21 @@ discard block |
||
| 169 | 169 | * @param WP_Theme $theme |
| 170 | 170 | * @return bool |
| 171 | 171 | */ |
| 172 | - public function _search_callback( $theme ) { |
|
| 172 | + public function _search_callback($theme) { |
|
| 173 | 173 | static $term = null; |
| 174 | - if ( is_null( $term ) ) |
|
| 175 | - $term = wp_unslash( $_REQUEST['s'] ); |
|
| 174 | + if (is_null($term)) |
|
| 175 | + $term = wp_unslash($_REQUEST['s']); |
|
| 176 | 176 | |
| 177 | - foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) { |
|
| 177 | + foreach (array('Name', 'Description', 'Author', 'Author', 'AuthorURI') as $field) { |
|
| 178 | 178 | // Don't mark up; Do translate. |
| 179 | - if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) |
|
| 179 | + if (false !== stripos($theme->display($field, false, true), $term)) |
|
| 180 | 180 | return true; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( false !== stripos( $theme->get_stylesheet(), $term ) ) |
|
| 183 | + if (false !== stripos($theme->get_stylesheet(), $term)) |
|
| 184 | 184 | return true; |
| 185 | 185 | |
| 186 | - if ( false !== stripos( $theme->get_template(), $term ) ) |
|
| 186 | + if (false !== stripos($theme->get_template(), $term)) |
|
| 187 | 187 | return true; |
| 188 | 188 | |
| 189 | 189 | return false; |
@@ -197,29 +197,29 @@ discard block |
||
| 197 | 197 | * @param array $theme_b |
| 198 | 198 | * @return int |
| 199 | 199 | */ |
| 200 | - public function _order_callback( $theme_a, $theme_b ) { |
|
| 200 | + public function _order_callback($theme_a, $theme_b) { |
|
| 201 | 201 | global $orderby, $order; |
| 202 | 202 | |
| 203 | - $a = $theme_a[ $orderby ]; |
|
| 204 | - $b = $theme_b[ $orderby ]; |
|
| 203 | + $a = $theme_a[$orderby]; |
|
| 204 | + $b = $theme_b[$orderby]; |
|
| 205 | 205 | |
| 206 | - if ( $a == $b ) |
|
| 206 | + if ($a == $b) |
|
| 207 | 207 | return 0; |
| 208 | 208 | |
| 209 | - if ( 'DESC' == $order ) |
|
| 210 | - return ( $a < $b ) ? 1 : -1; |
|
| 209 | + if ('DESC' == $order) |
|
| 210 | + return ($a < $b) ? 1 : -1; |
|
| 211 | 211 | else |
| 212 | - return ( $a < $b ) ? -1 : 1; |
|
| 212 | + return ($a < $b) ? -1 : 1; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * @access public |
| 217 | 217 | */ |
| 218 | 218 | public function no_items() { |
| 219 | - if ( ! $this->has_items ) |
|
| 220 | - _e( 'No themes found.' ); |
|
| 219 | + if ( ! $this->has_items) |
|
| 220 | + _e('No themes found.'); |
|
| 221 | 221 | else |
| 222 | - _e( 'You do not appear to have any themes available at this time.' ); |
|
| 222 | + _e('You do not appear to have any themes available at this time.'); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | public function get_columns() { |
| 230 | 230 | return array( |
| 231 | 231 | 'cb' => '<input type="checkbox" />', |
| 232 | - 'name' => __( 'Theme' ), |
|
| 233 | - 'description' => __( 'Description' ), |
|
| 232 | + 'name' => __('Theme'), |
|
| 233 | + 'description' => __('Description'), |
|
| 234 | 234 | ); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -266,38 +266,38 @@ discard block |
||
| 266 | 266 | global $totals, $status; |
| 267 | 267 | |
| 268 | 268 | $status_links = array(); |
| 269 | - foreach ( $totals as $type => $count ) { |
|
| 270 | - if ( !$count ) |
|
| 269 | + foreach ($totals as $type => $count) { |
|
| 270 | + if ( ! $count) |
|
| 271 | 271 | continue; |
| 272 | 272 | |
| 273 | - switch ( $type ) { |
|
| 273 | + switch ($type) { |
|
| 274 | 274 | case 'all': |
| 275 | - $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes' ); |
|
| 275 | + $text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes'); |
|
| 276 | 276 | break; |
| 277 | 277 | case 'enabled': |
| 278 | - $text = _n( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count ); |
|
| 278 | + $text = _n('Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count); |
|
| 279 | 279 | break; |
| 280 | 280 | case 'disabled': |
| 281 | - $text = _n( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count ); |
|
| 281 | + $text = _n('Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count); |
|
| 282 | 282 | break; |
| 283 | 283 | case 'upgrade': |
| 284 | - $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count ); |
|
| 284 | + $text = _n('Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count); |
|
| 285 | 285 | break; |
| 286 | 286 | case 'broken' : |
| 287 | - $text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count ); |
|
| 287 | + $text = _n('Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count); |
|
| 288 | 288 | break; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if ( $this->is_site_themes ) |
|
| 292 | - $url = 'site-themes.php?id=' . $this->site_id; |
|
| 291 | + if ($this->is_site_themes) |
|
| 292 | + $url = 'site-themes.php?id='.$this->site_id; |
|
| 293 | 293 | else |
| 294 | 294 | $url = 'themes.php'; |
| 295 | 295 | |
| 296 | - if ( 'search' != $type ) { |
|
| 297 | - $status_links[$type] = sprintf( "<a href='%s' %s>%s</a>", |
|
| 298 | - esc_url( add_query_arg('theme_status', $type, $url) ), |
|
| 299 | - ( $type == $status ) ? ' class="current"' : '', |
|
| 300 | - sprintf( $text, number_format_i18n( $count ) ) |
|
| 296 | + if ('search' != $type) { |
|
| 297 | + $status_links[$type] = sprintf("<a href='%s' %s>%s</a>", |
|
| 298 | + esc_url(add_query_arg('theme_status', $type, $url)), |
|
| 299 | + ($type == $status) ? ' class="current"' : '', |
|
| 300 | + sprintf($text, number_format_i18n($count)) |
|
| 301 | 301 | ); |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -314,15 +314,15 @@ discard block |
||
| 314 | 314 | global $status; |
| 315 | 315 | |
| 316 | 316 | $actions = array(); |
| 317 | - if ( 'enabled' != $status ) |
|
| 318 | - $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); |
|
| 319 | - if ( 'disabled' != $status ) |
|
| 320 | - $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); |
|
| 321 | - if ( ! $this->is_site_themes ) { |
|
| 322 | - if ( current_user_can( 'update_themes' ) ) |
|
| 323 | - $actions['update-selected'] = __( 'Update' ); |
|
| 324 | - if ( current_user_can( 'delete_themes' ) ) |
|
| 325 | - $actions['delete-selected'] = __( 'Delete' ); |
|
| 317 | + if ('enabled' != $status) |
|
| 318 | + $actions['enable-selected'] = $this->is_site_themes ? __('Enable') : __('Network Enable'); |
|
| 319 | + if ('disabled' != $status) |
|
| 320 | + $actions['disable-selected'] = $this->is_site_themes ? __('Disable') : __('Network Disable'); |
|
| 321 | + if ( ! $this->is_site_themes) { |
|
| 322 | + if (current_user_can('update_themes')) |
|
| 323 | + $actions['update-selected'] = __('Update'); |
|
| 324 | + if (current_user_can('delete_themes')) |
|
| 325 | + $actions['delete-selected'] = __('Delete'); |
|
| 326 | 326 | } |
| 327 | 327 | return $actions; |
| 328 | 328 | } |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | * @access public |
| 332 | 332 | */ |
| 333 | 333 | public function display_rows() { |
| 334 | - foreach ( $this->items as $theme ) |
|
| 335 | - $this->single_row( $theme ); |
|
| 334 | + foreach ($this->items as $theme) |
|
| 335 | + $this->single_row($theme); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -343,11 +343,11 @@ discard block |
||
| 343 | 343 | * |
| 344 | 344 | * @param WP_Theme $theme The current WP_Theme object. |
| 345 | 345 | */ |
| 346 | - public function column_cb( $theme ) { |
|
| 347 | - $checkbox_id = 'checkbox_' . md5( $theme->get('Name') ); |
|
| 346 | + public function column_cb($theme) { |
|
| 347 | + $checkbox_id = 'checkbox_'.md5($theme->get('Name')); |
|
| 348 | 348 | ?> |
| 349 | - <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ) ?>" id="<?php echo $checkbox_id ?>" /> |
|
| 350 | - <label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e( 'Select' ) ?> <?php echo $theme->display( 'Name' ) ?></label> |
|
| 349 | + <input type="checkbox" name="checked[]" value="<?php echo esc_attr($theme->get_stylesheet()) ?>" id="<?php echo $checkbox_id ?>" /> |
|
| 350 | + <label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e('Select') ?> <?php echo $theme->display('Name') ?></label> |
|
| 351 | 351 | <?php |
| 352 | 352 | } |
| 353 | 353 | |
@@ -363,17 +363,17 @@ discard block |
||
| 363 | 363 | * |
| 364 | 364 | * @param WP_Theme $theme The current WP_Theme object. |
| 365 | 365 | */ |
| 366 | - public function column_name( $theme ) { |
|
| 366 | + public function column_name($theme) { |
|
| 367 | 367 | global $status, $page, $s; |
| 368 | 368 | |
| 369 | 369 | $context = $status; |
| 370 | 370 | |
| 371 | - if ( $this->is_site_themes ) { |
|
| 371 | + if ($this->is_site_themes) { |
|
| 372 | 372 | $url = "site-themes.php?id={$this->site_id}&"; |
| 373 | - $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
| 373 | + $allowed = $theme->is_allowed('site', $this->site_id); |
|
| 374 | 374 | } else { |
| 375 | 375 | $url = 'themes.php?'; |
| 376 | - $allowed = $theme->is_allowed( 'network' ); |
|
| 376 | + $allowed = $theme->is_allowed('network'); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Pre-order. |
@@ -385,22 +385,22 @@ discard block |
||
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | 387 | $stylesheet = $theme->get_stylesheet(); |
| 388 | - $theme_key = urlencode( $stylesheet ); |
|
| 388 | + $theme_key = urlencode($stylesheet); |
|
| 389 | 389 | |
| 390 | - if ( ! $allowed ) { |
|
| 391 | - if ( ! $theme->errors() ) { |
|
| 392 | - $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>'; |
|
| 390 | + if ( ! $allowed) { |
|
| 391 | + if ( ! $theme->errors()) { |
|
| 392 | + $actions['enable'] = '<a href="'.esc_url(wp_nonce_url($url.'action=enable&theme='.$theme_key.'&paged='.$page.'&s='.$s, 'enable-theme_'.$stylesheet)).'" title="'.esc_attr__('Enable this theme').'" class="edit">'.($this->is_site_themes ? __('Enable') : __('Network Enable')).'</a>'; |
|
| 393 | 393 | } |
| 394 | 394 | } else { |
| 395 | - $actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>'; |
|
| 395 | + $actions['disable'] = '<a href="'.esc_url(wp_nonce_url($url.'action=disable&theme='.$theme_key.'&paged='.$page.'&s='.$s, 'disable-theme_'.$stylesheet)).'" title="'.esc_attr__('Disable this theme').'">'.($this->is_site_themes ? __('Disable') : __('Network Disable')).'</a>'; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if ( current_user_can('edit_themes') ) { |
|
| 399 | - $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>'; |
|
| 398 | + if (current_user_can('edit_themes')) { |
|
| 399 | + $actions['edit'] = '<a href="'.esc_url('theme-editor.php?theme='.$theme_key).'" title="'.esc_attr__('Open this theme in the Theme Editor').'" class="edit">'.__('Edit').'</a>'; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) { |
|
| 403 | - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&checked[]=' . $theme_key . '&theme_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>'; |
|
| 402 | + if ( ! $allowed && current_user_can('delete_themes') && ! $this->is_site_themes && $stylesheet != get_option('stylesheet') && $stylesheet != get_option('template')) { |
|
| 403 | + $actions['delete'] = '<a href="'.esc_url(wp_nonce_url('themes.php?action=delete-selected&checked[]='.$theme_key.'&theme_status='.$context.'&paged='.$page.'&s='.$s, 'bulk-themes')).'" title="'.esc_attr__('Delete this theme').'" class="delete">'.__('Delete').'</a>'; |
|
| 404 | 404 | } |
| 405 | 405 | /** |
| 406 | 406 | * Filter the action links displayed for each theme in the Multisite |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @param WP_Theme $theme The current WP_Theme object. |
| 425 | 425 | * @param string $context Status of the theme. |
| 426 | 426 | */ |
| 427 | - $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context ); |
|
| 427 | + $actions = apply_filters('theme_action_links', array_filter($actions), $theme, $context); |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * Filter the action links of a specific theme in the Multisite themes |
@@ -440,9 +440,9 @@ discard block |
||
| 440 | 440 | * @param WP_Theme $theme The current WP_Theme object. |
| 441 | 441 | * @param string $context Status of the theme. |
| 442 | 442 | */ |
| 443 | - $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context ); |
|
| 443 | + $actions = apply_filters("theme_action_links_$stylesheet", $actions, $theme, $context); |
|
| 444 | 444 | |
| 445 | - echo $this->row_actions( $actions, true ); |
|
| 445 | + echo $this->row_actions($actions, true); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -456,36 +456,36 @@ discard block |
||
| 456 | 456 | * |
| 457 | 457 | * @param WP_Theme $theme The current WP_Theme object. |
| 458 | 458 | */ |
| 459 | - public function column_description( $theme ) { |
|
| 459 | + public function column_description($theme) { |
|
| 460 | 460 | global $status, $totals; |
| 461 | - if ( $theme->errors() ) { |
|
| 462 | - $pre = $status == 'broken' ? __( 'Broken Theme:' ) . ' ' : ''; |
|
| 463 | - echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>'; |
|
| 461 | + if ($theme->errors()) { |
|
| 462 | + $pre = $status == 'broken' ? __('Broken Theme:').' ' : ''; |
|
| 463 | + echo '<p><strong class="error-message">'.$pre.$theme->errors()->get_error_message().'</strong></p>'; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - if ( $this->is_site_themes ) { |
|
| 467 | - $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
| 466 | + if ($this->is_site_themes) { |
|
| 467 | + $allowed = $theme->is_allowed('site', $this->site_id); |
|
| 468 | 468 | } else { |
| 469 | - $allowed = $theme->is_allowed( 'network' ); |
|
| 469 | + $allowed = $theme->is_allowed('network'); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | $class = ! $allowed ? 'inactive' : 'active'; |
| 473 | - if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) |
|
| 473 | + if ( ! empty($totals['upgrade']) && ! empty($theme->update)) |
|
| 474 | 474 | $class .= ' update'; |
| 475 | 475 | |
| 476 | - echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div> |
|
| 476 | + echo "<div class='theme-description'><p>".$theme->display('Description')."</p></div> |
|
| 477 | 477 | <div class='$class second theme-version-author-uri'>"; |
| 478 | 478 | |
| 479 | 479 | $stylesheet = $theme->get_stylesheet(); |
| 480 | 480 | $theme_meta = array(); |
| 481 | 481 | |
| 482 | - if ( $theme->get('Version') ) { |
|
| 483 | - $theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') ); |
|
| 482 | + if ($theme->get('Version')) { |
|
| 483 | + $theme_meta[] = sprintf(__('Version %s'), $theme->display('Version')); |
|
| 484 | 484 | } |
| 485 | - $theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') ); |
|
| 485 | + $theme_meta[] = sprintf(__('By %s'), $theme->display('Author')); |
|
| 486 | 486 | |
| 487 | - if ( $theme->get('ThemeURI') ) { |
|
| 488 | - $theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>'; |
|
| 487 | + if ($theme->get('ThemeURI')) { |
|
| 488 | + $theme_meta[] = '<a href="'.$theme->display('ThemeURI').'" title="'.esc_attr__('Visit theme homepage').'">'.__('Visit Theme Site').'</a>'; |
|
| 489 | 489 | } |
| 490 | 490 | /** |
| 491 | 491 | * Filter the array of row meta for each theme in the Multisite themes |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | * @param WP_Theme $theme WP_Theme object. |
| 501 | 501 | * @param string $status Status of the theme. |
| 502 | 502 | */ |
| 503 | - $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); |
|
| 504 | - echo implode( ' | ', $theme_meta ); |
|
| 503 | + $theme_meta = apply_filters('theme_row_meta', $theme_meta, $stylesheet, $theme, $status); |
|
| 504 | + echo implode(' | ', $theme_meta); |
|
| 505 | 505 | |
| 506 | 506 | echo '</div>'; |
| 507 | 507 | } |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | * @param WP_Theme $theme The current WP_Theme object. |
| 516 | 516 | * @param string $column_name The current column name. |
| 517 | 517 | */ |
| 518 | - public function column_default( $theme, $column_name ) { |
|
| 518 | + public function column_default($theme, $column_name) { |
|
| 519 | 519 | $stylesheet = $theme->get_stylesheet(); |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | * @param string $stylesheet Directory name of the theme. |
| 528 | 528 | * @param WP_Theme $theme Current WP_Theme object. |
| 529 | 529 | */ |
| 530 | - do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme ); |
|
| 530 | + do_action('manage_themes_custom_column', $column_name, $stylesheet, $theme); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -538,28 +538,28 @@ discard block |
||
| 538 | 538 | * |
| 539 | 539 | * @param WP_Theme $item The current WP_Theme object. |
| 540 | 540 | */ |
| 541 | - public function single_row_columns( $item ) { |
|
| 542 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
| 541 | + public function single_row_columns($item) { |
|
| 542 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
| 543 | 543 | |
| 544 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
| 544 | + foreach ($columns as $column_name => $column_display_name) { |
|
| 545 | 545 | $extra_classes = ''; |
| 546 | - if ( in_array( $column_name, $hidden ) ) { |
|
| 546 | + if (in_array($column_name, $hidden)) { |
|
| 547 | 547 | $extra_classes .= ' hidden'; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - switch ( $column_name ) { |
|
| 550 | + switch ($column_name) { |
|
| 551 | 551 | case 'cb': |
| 552 | 552 | echo '<th scope="row" class="check-column">'; |
| 553 | 553 | |
| 554 | - $this->column_cb( $item ); |
|
| 554 | + $this->column_cb($item); |
|
| 555 | 555 | |
| 556 | 556 | echo '</th>'; |
| 557 | 557 | break; |
| 558 | 558 | |
| 559 | 559 | case 'name': |
| 560 | - echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display('Name') . "</strong>"; |
|
| 560 | + echo "<td class='theme-title column-primary{$extra_classes}'><strong>".$item->display('Name')."</strong>"; |
|
| 561 | 561 | |
| 562 | - $this->column_name( $item ); |
|
| 562 | + $this->column_name($item); |
|
| 563 | 563 | |
| 564 | 564 | echo "</td>"; |
| 565 | 565 | break; |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | case 'description': |
| 568 | 568 | echo "<td class='column-description desc{$extra_classes}'>"; |
| 569 | 569 | |
| 570 | - $this->column_description( $item ); |
|
| 570 | + $this->column_description($item); |
|
| 571 | 571 | |
| 572 | 572 | echo '</td>'; |
| 573 | 573 | break; |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | default: |
| 576 | 576 | echo "<td class='$column_name column-$column_name{$extra_classes}'>"; |
| 577 | 577 | |
| 578 | - $this->column_default( $item, $column_name ); |
|
| 578 | + $this->column_default($item, $column_name); |
|
| 579 | 579 | |
| 580 | 580 | echo "</td>"; |
| 581 | 581 | break; |
@@ -589,33 +589,33 @@ discard block |
||
| 589 | 589 | * |
| 590 | 590 | * @param WP_Theme $theme |
| 591 | 591 | */ |
| 592 | - public function single_row( $theme ) { |
|
| 592 | + public function single_row($theme) { |
|
| 593 | 593 | global $status, $totals; |
| 594 | 594 | |
| 595 | - if ( $this->is_site_themes ) { |
|
| 596 | - $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
| 595 | + if ($this->is_site_themes) { |
|
| 596 | + $allowed = $theme->is_allowed('site', $this->site_id); |
|
| 597 | 597 | } else { |
| 598 | - $allowed = $theme->is_allowed( 'network' ); |
|
| 598 | + $allowed = $theme->is_allowed('network'); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | $stylesheet = $theme->get_stylesheet(); |
| 602 | 602 | |
| 603 | 603 | $class = ! $allowed ? 'inactive' : 'active'; |
| 604 | 604 | |
| 605 | - $id = sanitize_html_class( $theme->get_stylesheet() ); |
|
| 605 | + $id = sanitize_html_class($theme->get_stylesheet()); |
|
| 606 | 606 | |
| 607 | - if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
|
| 607 | + if ( ! empty($totals['upgrade']) && ! empty($theme->update)) { |
|
| 608 | 608 | $class .= ' update'; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | echo "<tr id='$id' class='$class'>"; |
| 612 | 612 | |
| 613 | - $this->single_row_columns( $theme ); |
|
| 613 | + $this->single_row_columns($theme); |
|
| 614 | 614 | |
| 615 | 615 | echo "</tr>"; |
| 616 | 616 | |
| 617 | - if ( $this->is_site_themes ) |
|
| 618 | - remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |
|
| 617 | + if ($this->is_site_themes) |
|
| 618 | + remove_action("after_theme_row_$stylesheet", 'wp_theme_update_row'); |
|
| 619 | 619 | |
| 620 | 620 | /** |
| 621 | 621 | * Fires after each row in the Multisite themes list table. |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | * @param WP_Theme $theme Current WP_Theme object. |
| 627 | 627 | * @param string $status Status of the theme. |
| 628 | 628 | */ |
| 629 | - do_action( 'after_theme_row', $stylesheet, $theme, $status ); |
|
| 629 | + do_action('after_theme_row', $stylesheet, $theme, $status); |
|
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | 632 | * Fires after each specific row in the Multisite themes list table. |
@@ -641,6 +641,6 @@ discard block |
||
| 641 | 641 | * @param WP_Theme $theme Current WP_Theme object. |
| 642 | 642 | * @param string $status Status of the theme. |
| 643 | 643 | */ |
| 644 | - do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status ); |
|
| 644 | + do_action("after_theme_row_$stylesheet", $stylesheet, $theme, $status); |
|
| 645 | 645 | } |
| 646 | 646 | } |
@@ -36,15 +36,17 @@ discard block |
||
| 36 | 36 | ) ); |
| 37 | 37 | |
| 38 | 38 | $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; |
| 39 | - if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) |
|
| 40 | - $status = 'all'; |
|
| 39 | + if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) { |
|
| 40 | + $status = 'all'; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | $page = $this->get_pagenum(); |
| 43 | 44 | |
| 44 | 45 | $this->is_site_themes = ( 'site-themes-network' == $this->screen->id ) ? true : false; |
| 45 | 46 | |
| 46 | - if ( $this->is_site_themes ) |
|
| 47 | - $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
|
| 47 | + if ( $this->is_site_themes ) { |
|
| 48 | + $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
|
| 49 | + } |
|
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | /** |
@@ -61,10 +63,11 @@ discard block |
||
| 61 | 63 | * @return bool |
| 62 | 64 | */ |
| 63 | 65 | public function ajax_user_can() { |
| 64 | - if ( $this->is_site_themes ) |
|
| 65 | - return current_user_can( 'manage_sites' ); |
|
| 66 | - else |
|
| 67 | - return current_user_can( 'manage_network_themes' ); |
|
| 66 | + if ( $this->is_site_themes ) { |
|
| 67 | + return current_user_can( 'manage_sites' ); |
|
| 68 | + } else { |
|
| 69 | + return current_user_can( 'manage_network_themes' ); |
|
| 70 | + } |
|
| 68 | 71 | } |
| 69 | 72 | |
| 70 | 73 | /** |
@@ -129,11 +132,13 @@ discard block |
||
| 129 | 132 | } |
| 130 | 133 | |
| 131 | 134 | $totals = array(); |
| 132 | - foreach ( $themes as $type => $list ) |
|
| 133 | - $totals[ $type ] = count( $list ); |
|
| 135 | + foreach ( $themes as $type => $list ) { |
|
| 136 | + $totals[ $type ] = count( $list ); |
|
| 137 | + } |
|
| 134 | 138 | |
| 135 | - if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) |
|
| 136 | - $status = 'all'; |
|
| 139 | + if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) { |
|
| 140 | + $status = 'all'; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $this->items = $themes[ $status ]; |
| 139 | 144 | WP_Theme::sort_by_name( $this->items ); |
@@ -146,8 +151,9 @@ discard block |
||
| 146 | 151 | $order = strtoupper( $order ); |
| 147 | 152 | |
| 148 | 153 | if ( $orderby == 'Name' ) { |
| 149 | - if ( 'ASC' == $order ) |
|
| 150 | - $this->items = array_reverse( $this->items ); |
|
| 154 | + if ( 'ASC' == $order ) { |
|
| 155 | + $this->items = array_reverse( $this->items ); |
|
| 156 | + } |
|
| 151 | 157 | } else { |
| 152 | 158 | uasort( $this->items, array( $this, '_order_callback' ) ); |
| 153 | 159 | } |
@@ -155,8 +161,9 @@ discard block |
||
| 155 | 161 | |
| 156 | 162 | $start = ( $page - 1 ) * $themes_per_page; |
| 157 | 163 | |
| 158 | - if ( $total_this_page > $themes_per_page ) |
|
| 159 | - $this->items = array_slice( $this->items, $start, $themes_per_page, true ); |
|
| 164 | + if ( $total_this_page > $themes_per_page ) { |
|
| 165 | + $this->items = array_slice( $this->items, $start, $themes_per_page, true ); |
|
| 166 | + } |
|
| 160 | 167 | |
| 161 | 168 | $this->set_pagination_args( array( |
| 162 | 169 | 'total_items' => $total_this_page, |
@@ -171,20 +178,24 @@ discard block |
||
| 171 | 178 | */ |
| 172 | 179 | public function _search_callback( $theme ) { |
| 173 | 180 | static $term = null; |
| 174 | - if ( is_null( $term ) ) |
|
| 175 | - $term = wp_unslash( $_REQUEST['s'] ); |
|
| 181 | + if ( is_null( $term ) ) { |
|
| 182 | + $term = wp_unslash( $_REQUEST['s'] ); |
|
| 183 | + } |
|
| 176 | 184 | |
| 177 | 185 | foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) { |
| 178 | 186 | // Don't mark up; Do translate. |
| 179 | - if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) |
|
| 180 | - return true; |
|
| 187 | + if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) { |
|
| 188 | + return true; |
|
| 189 | + } |
|
| 181 | 190 | } |
| 182 | 191 | |
| 183 | - if ( false !== stripos( $theme->get_stylesheet(), $term ) ) |
|
| 184 | - return true; |
|
| 192 | + if ( false !== stripos( $theme->get_stylesheet(), $term ) ) { |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 185 | 195 | |
| 186 | - if ( false !== stripos( $theme->get_template(), $term ) ) |
|
| 187 | - return true; |
|
| 196 | + if ( false !== stripos( $theme->get_template(), $term ) ) { |
|
| 197 | + return true; |
|
| 198 | + } |
|
| 188 | 199 | |
| 189 | 200 | return false; |
| 190 | 201 | } |
@@ -203,23 +214,26 @@ discard block |
||
| 203 | 214 | $a = $theme_a[ $orderby ]; |
| 204 | 215 | $b = $theme_b[ $orderby ]; |
| 205 | 216 | |
| 206 | - if ( $a == $b ) |
|
| 207 | - return 0; |
|
| 217 | + if ( $a == $b ) { |
|
| 218 | + return 0; |
|
| 219 | + } |
|
| 208 | 220 | |
| 209 | - if ( 'DESC' == $order ) |
|
| 210 | - return ( $a < $b ) ? 1 : -1; |
|
| 211 | - else |
|
| 212 | - return ( $a < $b ) ? -1 : 1; |
|
| 221 | + if ( 'DESC' == $order ) { |
|
| 222 | + return ( $a < $b ) ? 1 : -1; |
|
| 223 | + } else { |
|
| 224 | + return ( $a < $b ) ? -1 : 1; |
|
| 225 | + } |
|
| 213 | 226 | } |
| 214 | 227 | |
| 215 | 228 | /** |
| 216 | 229 | * @access public |
| 217 | 230 | */ |
| 218 | 231 | public function no_items() { |
| 219 | - if ( ! $this->has_items ) |
|
| 220 | - _e( 'No themes found.' ); |
|
| 221 | - else |
|
| 222 | - _e( 'You do not appear to have any themes available at this time.' ); |
|
| 232 | + if ( ! $this->has_items ) { |
|
| 233 | + _e( 'No themes found.' ); |
|
| 234 | + } else { |
|
| 235 | + _e( 'You do not appear to have any themes available at this time.' ); |
|
| 236 | + } |
|
| 223 | 237 | } |
| 224 | 238 | |
| 225 | 239 | /** |
@@ -267,8 +281,9 @@ discard block |
||
| 267 | 281 | |
| 268 | 282 | $status_links = array(); |
| 269 | 283 | foreach ( $totals as $type => $count ) { |
| 270 | - if ( !$count ) |
|
| 271 | - continue; |
|
| 284 | + if ( !$count ) { |
|
| 285 | + continue; |
|
| 286 | + } |
|
| 272 | 287 | |
| 273 | 288 | switch ( $type ) { |
| 274 | 289 | case 'all': |
@@ -288,10 +303,11 @@ discard block |
||
| 288 | 303 | break; |
| 289 | 304 | } |
| 290 | 305 | |
| 291 | - if ( $this->is_site_themes ) |
|
| 292 | - $url = 'site-themes.php?id=' . $this->site_id; |
|
| 293 | - else |
|
| 294 | - $url = 'themes.php'; |
|
| 306 | + if ( $this->is_site_themes ) { |
|
| 307 | + $url = 'site-themes.php?id=' . $this->site_id; |
|
| 308 | + } else { |
|
| 309 | + $url = 'themes.php'; |
|
| 310 | + } |
|
| 295 | 311 | |
| 296 | 312 | if ( 'search' != $type ) { |
| 297 | 313 | $status_links[$type] = sprintf( "<a href='%s' %s>%s</a>", |
@@ -314,15 +330,19 @@ discard block |
||
| 314 | 330 | global $status; |
| 315 | 331 | |
| 316 | 332 | $actions = array(); |
| 317 | - if ( 'enabled' != $status ) |
|
| 318 | - $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); |
|
| 319 | - if ( 'disabled' != $status ) |
|
| 320 | - $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); |
|
| 333 | + if ( 'enabled' != $status ) { |
|
| 334 | + $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); |
|
| 335 | + } |
|
| 336 | + if ( 'disabled' != $status ) { |
|
| 337 | + $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); |
|
| 338 | + } |
|
| 321 | 339 | if ( ! $this->is_site_themes ) { |
| 322 | - if ( current_user_can( 'update_themes' ) ) |
|
| 323 | - $actions['update-selected'] = __( 'Update' ); |
|
| 324 | - if ( current_user_can( 'delete_themes' ) ) |
|
| 325 | - $actions['delete-selected'] = __( 'Delete' ); |
|
| 340 | + if ( current_user_can( 'update_themes' ) ) { |
|
| 341 | + $actions['update-selected'] = __( 'Update' ); |
|
| 342 | + } |
|
| 343 | + if ( current_user_can( 'delete_themes' ) ) { |
|
| 344 | + $actions['delete-selected'] = __( 'Delete' ); |
|
| 345 | + } |
|
| 326 | 346 | } |
| 327 | 347 | return $actions; |
| 328 | 348 | } |
@@ -331,8 +351,9 @@ discard block |
||
| 331 | 351 | * @access public |
| 332 | 352 | */ |
| 333 | 353 | public function display_rows() { |
| 334 | - foreach ( $this->items as $theme ) |
|
| 335 | - $this->single_row( $theme ); |
|
| 354 | + foreach ( $this->items as $theme ) { |
|
| 355 | + $this->single_row( $theme ); |
|
| 356 | + } |
|
| 336 | 357 | } |
| 337 | 358 | |
| 338 | 359 | /** |
@@ -470,8 +491,9 @@ discard block |
||
| 470 | 491 | } |
| 471 | 492 | |
| 472 | 493 | $class = ! $allowed ? 'inactive' : 'active'; |
| 473 | - if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) |
|
| 474 | - $class .= ' update'; |
|
| 494 | + if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
|
| 495 | + $class .= ' update'; |
|
| 496 | + } |
|
| 475 | 497 | |
| 476 | 498 | echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div> |
| 477 | 499 | <div class='$class second theme-version-author-uri'>"; |
@@ -614,8 +636,9 @@ discard block |
||
| 614 | 636 | |
| 615 | 637 | echo "</tr>"; |
| 616 | 638 | |
| 617 | - if ( $this->is_site_themes ) |
|
| 618 | - remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |
|
| 639 | + if ( $this->is_site_themes ) { |
|
| 640 | + remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |
|
| 641 | + } |
|
| 619 | 642 | |
| 620 | 643 | /** |
| 621 | 644 | * Fires after each row in the Multisite themes list table. |
@@ -389,7 +389,7 @@ |
||
| 389 | 389 | * @since 4.3.0 |
| 390 | 390 | * @access protected |
| 391 | 391 | * |
| 392 | - * @param object $user User being acted upon. |
|
| 392 | + * @param WP_User $user User being acted upon. |
|
| 393 | 393 | * @param string $column_name Current column name. |
| 394 | 394 | * @param string $primary Primary column name. |
| 395 | 395 | * @return string Row actions output for users in Multisite. |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Multisite Users List Table class. |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage List_Table |
|
| 7 | - * @since 3.1.0 |
|
| 8 | - * @access private |
|
| 9 | - */ |
|
| 3 | + * Multisite Users List Table class. |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage List_Table |
|
| 7 | + * @since 3.1.0 |
|
| 8 | + * @access private |
|
| 9 | + */ |
|
| 10 | 10 | class WP_MS_Users_List_Table extends WP_List_Table { |
| 11 | 11 | /** |
| 12 | 12 | * |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @return bool |
| 14 | 14 | */ |
| 15 | 15 | public function ajax_user_can() { |
| 16 | - return current_user_can( 'manage_network_users' ); |
|
| 16 | + return current_user_can('manage_network_users'); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -26,28 +26,28 @@ discard block |
||
| 26 | 26 | public function prepare_items() { |
| 27 | 27 | global $usersearch, $role, $wpdb, $mode; |
| 28 | 28 | |
| 29 | - $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; |
|
| 29 | + $usersearch = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : ''; |
|
| 30 | 30 | |
| 31 | - $users_per_page = $this->get_items_per_page( 'users_network_per_page' ); |
|
| 31 | + $users_per_page = $this->get_items_per_page('users_network_per_page'); |
|
| 32 | 32 | |
| 33 | - $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; |
|
| 33 | + $role = isset($_REQUEST['role']) ? $_REQUEST['role'] : ''; |
|
| 34 | 34 | |
| 35 | 35 | $paged = $this->get_pagenum(); |
| 36 | 36 | |
| 37 | 37 | $args = array( |
| 38 | 38 | 'number' => $users_per_page, |
| 39 | - 'offset' => ( $paged-1 ) * $users_per_page, |
|
| 39 | + 'offset' => ($paged - 1) * $users_per_page, |
|
| 40 | 40 | 'search' => $usersearch, |
| 41 | 41 | 'blog_id' => 0, |
| 42 | 42 | 'fields' => 'all_with_meta' |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - if ( wp_is_large_network( 'users' ) ) |
|
| 46 | - $args['search'] = ltrim( $args['search'], '*' ); |
|
| 45 | + if (wp_is_large_network('users')) |
|
| 46 | + $args['search'] = ltrim($args['search'], '*'); |
|
| 47 | 47 | |
| 48 | - if ( $role == 'super' ) { |
|
| 49 | - $logins = implode( "', '", get_super_admins() ); |
|
| 50 | - $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" ); |
|
| 48 | + if ($role == 'super') { |
|
| 49 | + $logins = implode("', '", get_super_admins()); |
|
| 50 | + $args['include'] = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')"); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /* |
@@ -55,31 +55,31 @@ discard block |
||
| 55 | 55 | * show only the latest users with no paging in order to avoid |
| 56 | 56 | * expensive count queries. |
| 57 | 57 | */ |
| 58 | - if ( !$usersearch && wp_is_large_network( 'users' ) ) { |
|
| 59 | - if ( !isset($_REQUEST['orderby']) ) |
|
| 58 | + if ( ! $usersearch && wp_is_large_network('users')) { |
|
| 59 | + if ( ! isset($_REQUEST['orderby'])) |
|
| 60 | 60 | $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; |
| 61 | - if ( !isset($_REQUEST['order']) ) |
|
| 61 | + if ( ! isset($_REQUEST['order'])) |
|
| 62 | 62 | $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
| 63 | 63 | $args['count_total'] = false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if ( isset( $_REQUEST['orderby'] ) ) |
|
| 66 | + if (isset($_REQUEST['orderby'])) |
|
| 67 | 67 | $args['orderby'] = $_REQUEST['orderby']; |
| 68 | 68 | |
| 69 | - if ( isset( $_REQUEST['order'] ) ) |
|
| 69 | + if (isset($_REQUEST['order'])) |
|
| 70 | 70 | $args['order'] = $_REQUEST['order']; |
| 71 | 71 | |
| 72 | - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
| 72 | + $mode = empty($_REQUEST['mode']) ? 'list' : $_REQUEST['mode']; |
|
| 73 | 73 | |
| 74 | 74 | // Query the user IDs for this page |
| 75 | - $wp_user_search = new WP_User_Query( $args ); |
|
| 75 | + $wp_user_search = new WP_User_Query($args); |
|
| 76 | 76 | |
| 77 | 77 | $this->items = $wp_user_search->get_results(); |
| 78 | 78 | |
| 79 | - $this->set_pagination_args( array( |
|
| 79 | + $this->set_pagination_args(array( |
|
| 80 | 80 | 'total_items' => $wp_user_search->get_total(), |
| 81 | 81 | 'per_page' => $users_per_page, |
| 82 | - ) ); |
|
| 82 | + )); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | protected function get_bulk_actions() { |
| 90 | 90 | $actions = array(); |
| 91 | - if ( current_user_can( 'delete_users' ) ) |
|
| 92 | - $actions['delete'] = __( 'Delete' ); |
|
| 93 | - $actions['spam'] = _x( 'Mark as Spam', 'user' ); |
|
| 94 | - $actions['notspam'] = _x( 'Not Spam', 'user' ); |
|
| 91 | + if (current_user_can('delete_users')) |
|
| 92 | + $actions['delete'] = __('Delete'); |
|
| 93 | + $actions['spam'] = _x('Mark as Spam', 'user'); |
|
| 94 | + $actions['notspam'] = _x('Not Spam', 'user'); |
|
| 95 | 95 | |
| 96 | 96 | return $actions; |
| 97 | 97 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @access public |
| 101 | 101 | */ |
| 102 | 102 | public function no_items() { |
| 103 | - _e( 'No users found.' ); |
|
| 103 | + _e('No users found.'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $total_users = get_user_count(); |
| 115 | 115 | $super_admins = get_super_admins(); |
| 116 | - $total_admins = count( $super_admins ); |
|
| 116 | + $total_admins = count($super_admins); |
|
| 117 | 117 | |
| 118 | 118 | $class = $role != 'super' ? ' class="current"' : ''; |
| 119 | 119 | $role_links = array(); |
| 120 | - $role_links['all'] = "<a href='" . network_admin_url('users.php') . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; |
|
| 120 | + $role_links['all'] = "<a href='".network_admin_url('users.php')."'$class>".sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)).'</a>'; |
|
| 121 | 121 | $class = $role == 'super' ? ' class="current"' : ''; |
| 122 | - $role_links['super'] = "<a href='" . network_admin_url('users.php?role=super') . "'$class>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>'; |
|
| 122 | + $role_links['super'] = "<a href='".network_admin_url('users.php?role=super')."'$class>".sprintf(_n('Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins), number_format_i18n($total_admins)).'</a>'; |
|
| 123 | 123 | |
| 124 | 124 | return $role_links; |
| 125 | 125 | } |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | * @global string $mode |
| 129 | 129 | * @param string $which |
| 130 | 130 | */ |
| 131 | - protected function pagination( $which ) { |
|
| 131 | + protected function pagination($which) { |
|
| 132 | 132 | global $mode; |
| 133 | 133 | |
| 134 | - parent::pagination ( $which ); |
|
| 134 | + parent::pagination($which); |
|
| 135 | 135 | |
| 136 | - if ( 'top' == $which ) |
|
| 137 | - $this->view_switcher( $mode ); |
|
| 136 | + if ('top' == $which) |
|
| 137 | + $this->view_switcher($mode); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | public function get_columns() { |
| 145 | 145 | $users_columns = array( |
| 146 | 146 | 'cb' => '<input type="checkbox" />', |
| 147 | - 'username' => __( 'Username' ), |
|
| 148 | - 'name' => __( 'Name' ), |
|
| 149 | - 'email' => __( 'E-mail' ), |
|
| 150 | - 'registered' => _x( 'Registered', 'user' ), |
|
| 151 | - 'blogs' => __( 'Sites' ) |
|
| 147 | + 'username' => __('Username'), |
|
| 148 | + 'name' => __('Name'), |
|
| 149 | + 'email' => __('E-mail'), |
|
| 150 | + 'registered' => _x('Registered', 'user'), |
|
| 151 | + 'blogs' => __('Sites') |
|
| 152 | 152 | ); |
| 153 | 153 | /** |
| 154 | 154 | * Filter the columns displayed in the Network Admin Users list table. |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param array $users_columns An array of user columns. Default 'cb', 'username', |
| 159 | 159 | * 'name', 'email', 'registered', 'blogs'. |
| 160 | 160 | */ |
| 161 | - return apply_filters( 'wpmu_users_columns', $users_columns ); |
|
| 161 | + return apply_filters('wpmu_users_columns', $users_columns); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | * |
| 183 | 183 | * @param WP_User $user The current WP_User object. |
| 184 | 184 | */ |
| 185 | - public function column_cb( $user ) { |
|
| 185 | + public function column_cb($user) { |
|
| 186 | 186 | ?> |
| 187 | - <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label> |
|
| 188 | - <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" /> |
|
| 187 | + <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf(__('Select %s'), $user->user_login); ?></label> |
|
| 188 | + <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr($user->ID) ?>" /> |
|
| 189 | 189 | <?php |
| 190 | 190 | } |
| 191 | 191 | |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @param WP_User $user The current WP_User object. |
| 199 | 199 | */ |
| 200 | - public function column_username( $user ) { |
|
| 200 | + public function column_username($user) { |
|
| 201 | 201 | $super_admins = get_super_admins(); |
| 202 | - $avatar = get_avatar( $user->user_email, 32 ); |
|
| 203 | - $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); |
|
| 202 | + $avatar = get_avatar($user->user_email, 32); |
|
| 203 | + $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID))); |
|
| 204 | 204 | |
| 205 | 205 | echo $avatar; |
| 206 | 206 | |
| 207 | 207 | ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php |
| 208 | - if ( in_array( $user->user_login, $super_admins ) ) { |
|
| 209 | - echo ' - ' . __( 'Super Admin' ); |
|
| 208 | + if (in_array($user->user_login, $super_admins)) { |
|
| 209 | + echo ' - '.__('Super Admin'); |
|
| 210 | 210 | } |
| 211 | 211 | ?></strong> |
| 212 | 212 | <?php |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @param WP_User $user The current WP_User object. |
| 222 | 222 | */ |
| 223 | - public function column_name( $user ) { |
|
| 223 | + public function column_name($user) { |
|
| 224 | 224 | echo "$user->first_name $user->last_name"; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * |
| 233 | 233 | * @param WP_User $user The current WP_User object. |
| 234 | 234 | */ |
| 235 | - public function column_email( $user ) { |
|
| 235 | + public function column_email($user) { |
|
| 236 | 236 | echo "<a href='mailto:$user->user_email'>$user->user_email</a>"; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @param WP_User $user The current WP_User object. |
| 248 | 248 | */ |
| 249 | - public function column_registered( $user ) { |
|
| 249 | + public function column_registered($user) { |
|
| 250 | 250 | global $mode; |
| 251 | - if ( 'list' == $mode ) { |
|
| 252 | - $date = __( 'Y/m/d' ); |
|
| 251 | + if ('list' == $mode) { |
|
| 252 | + $date = __('Y/m/d'); |
|
| 253 | 253 | } else { |
| 254 | - $date = __( 'Y/m/d g:i:s a' ); |
|
| 254 | + $date = __('Y/m/d g:i:s a'); |
|
| 255 | 255 | } |
| 256 | - echo mysql2date( $date, $user->user_registered ); |
|
| 256 | + echo mysql2date($date, $user->user_registered); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | * @param string $data |
| 266 | 266 | * @param string $primary |
| 267 | 267 | */ |
| 268 | - protected function _column_blogs( $user, $classes, $data, $primary ) { |
|
| 268 | + protected function _column_blogs($user, $classes, $data, $primary) { |
|
| 269 | 269 | echo '<td class="', $classes, ' has-row-actions" ', $data, '>'; |
| 270 | - echo $this->column_blogs( $user ); |
|
| 271 | - echo $this->handle_row_actions( $user, 'blogs', $primary ); |
|
| 270 | + echo $this->column_blogs($user); |
|
| 271 | + echo $this->handle_row_actions($user, 'blogs', $primary); |
|
| 272 | 272 | echo '</td>'; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -280,39 +280,39 @@ discard block |
||
| 280 | 280 | * |
| 281 | 281 | * @param WP_User $user The current WP_User object. |
| 282 | 282 | */ |
| 283 | - public function column_blogs( $user ) { |
|
| 284 | - $blogs = get_blogs_of_user( $user->ID, true ); |
|
| 285 | - if ( ! is_array( $blogs ) ) { |
|
| 283 | + public function column_blogs($user) { |
|
| 284 | + $blogs = get_blogs_of_user($user->ID, true); |
|
| 285 | + if ( ! is_array($blogs)) { |
|
| 286 | 286 | return; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - foreach ( $blogs as $val ) { |
|
| 290 | - if ( ! can_edit_network( $val->site_id ) ) { |
|
| 289 | + foreach ($blogs as $val) { |
|
| 290 | + if ( ! can_edit_network($val->site_id)) { |
|
| 291 | 291 | continue; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $path = ( $val->path == '/' ) ? '' : $val->path; |
|
| 295 | - echo '<span class="site-' . $val->site_id . '" >'; |
|
| 296 | - echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_current_site()->domain, '', $val->domain . $path ) . '</a>'; |
|
| 294 | + $path = ($val->path == '/') ? '' : $val->path; |
|
| 295 | + echo '<span class="site-'.$val->site_id.'" >'; |
|
| 296 | + echo '<a href="'.esc_url(network_admin_url('site-info.php?id='.$val->userblog_id)).'">'.str_replace('.'.get_current_site()->domain, '', $val->domain.$path).'</a>'; |
|
| 297 | 297 | echo ' <small class="row-actions">'; |
| 298 | 298 | $actions = array(); |
| 299 | - $actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>'; |
|
| 299 | + $actions['edit'] = '<a href="'.esc_url(network_admin_url('site-info.php?id='.$val->userblog_id)).'">'.__('Edit').'</a>'; |
|
| 300 | 300 | |
| 301 | 301 | $class = ''; |
| 302 | - if ( $val->spam == 1 ) { |
|
| 302 | + if ($val->spam == 1) { |
|
| 303 | 303 | $class .= 'site-spammed '; |
| 304 | 304 | } |
| 305 | - if ( $val->mature == 1 ) { |
|
| 305 | + if ($val->mature == 1) { |
|
| 306 | 306 | $class .= 'site-mature '; |
| 307 | 307 | } |
| 308 | - if ( $val->deleted == 1 ) { |
|
| 308 | + if ($val->deleted == 1) { |
|
| 309 | 309 | $class .= 'site-deleted '; |
| 310 | 310 | } |
| 311 | - if ( $val->archived == 1 ) { |
|
| 311 | + if ($val->archived == 1) { |
|
| 312 | 312 | $class .= 'site-archived '; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>'; |
|
| 315 | + $actions['view'] = '<a class="'.$class.'" href="'.esc_url(get_home_url($val->userblog_id)).'">'.__('View').'</a>'; |
|
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | 318 | * Filter the action links displayed next the sites a user belongs to |
@@ -324,13 +324,13 @@ discard block |
||
| 324 | 324 | * Default 'Edit', 'View'. |
| 325 | 325 | * @param int $userblog_id The site ID. |
| 326 | 326 | */ |
| 327 | - $actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id ); |
|
| 327 | + $actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id); |
|
| 328 | 328 | |
| 329 | - $i=0; |
|
| 330 | - $action_count = count( $actions ); |
|
| 331 | - foreach ( $actions as $action => $link ) { |
|
| 329 | + $i = 0; |
|
| 330 | + $action_count = count($actions); |
|
| 331 | + foreach ($actions as $action => $link) { |
|
| 332 | 332 | ++$i; |
| 333 | - $sep = ( $i == $action_count ) ? '' : ' | '; |
|
| 333 | + $sep = ($i == $action_count) ? '' : ' | '; |
|
| 334 | 334 | echo "<span class='$action'>$link$sep</span>"; |
| 335 | 335 | } |
| 336 | 336 | echo '</small></span><br/>'; |
@@ -346,26 +346,26 @@ discard block |
||
| 346 | 346 | * @param WP_User $user The current WP_User object. |
| 347 | 347 | * @param string $column_name The current column name. |
| 348 | 348 | */ |
| 349 | - public function column_default( $user, $column_name ) { |
|
| 349 | + public function column_default($user, $column_name) { |
|
| 350 | 350 | /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ |
| 351 | - echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); |
|
| 351 | + echo apply_filters('manage_users_custom_column', '', $column_name, $user->ID); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | public function display_rows() { |
| 355 | - foreach ( $this->items as $user ) { |
|
| 355 | + foreach ($this->items as $user) { |
|
| 356 | 356 | $class = ''; |
| 357 | 357 | |
| 358 | - $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' ); |
|
| 358 | + $status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted'); |
|
| 359 | 359 | |
| 360 | - foreach ( $status_list as $status => $col ) { |
|
| 361 | - if ( $user->$status ) { |
|
| 360 | + foreach ($status_list as $status => $col) { |
|
| 361 | + if ($user->$status) { |
|
| 362 | 362 | $class .= " $col"; |
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | ?> |
| 367 | - <tr class="<?php echo trim( $class ); ?>"> |
|
| 368 | - <?php $this->single_row_columns( $user ); ?> |
|
| 367 | + <tr class="<?php echo trim($class); ?>"> |
|
| 368 | + <?php $this->single_row_columns($user); ?> |
|
| 369 | 369 | </tr> |
| 370 | 370 | <?php |
| 371 | 371 | } |
@@ -394,19 +394,19 @@ discard block |
||
| 394 | 394 | * @param string $primary Primary column name. |
| 395 | 395 | * @return string Row actions output for users in Multisite. |
| 396 | 396 | */ |
| 397 | - protected function handle_row_actions( $user, $column_name, $primary ) { |
|
| 398 | - if ( $primary !== $column_name ) { |
|
| 397 | + protected function handle_row_actions($user, $column_name, $primary) { |
|
| 398 | + if ($primary !== $column_name) { |
|
| 399 | 399 | return ''; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | $super_admins = get_super_admins(); |
| 403 | - $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); |
|
| 403 | + $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID))); |
|
| 404 | 404 | |
| 405 | 405 | $actions = array(); |
| 406 | - $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; |
|
| 406 | + $actions['edit'] = '<a href="'.$edit_link.'">'.__('Edit').'</a>'; |
|
| 407 | 407 | |
| 408 | - if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { |
|
| 409 | - $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>'; |
|
| 408 | + if (current_user_can('delete_user', $user->ID) && ! in_array($user->user_login, $super_admins)) { |
|
| 409 | + $actions['delete'] = '<a href="'.$delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), wp_nonce_url('users.php', 'deleteuser').'&action=deleteuser&id='.$user->ID))).'" class="delete">'.__('Delete').'</a>'; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * Default 'Edit', 'Delete'. |
| 419 | 419 | * @param WP_User $user WP_User object. |
| 420 | 420 | */ |
| 421 | - $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); |
|
| 422 | - return $this->row_actions( $actions ); |
|
| 421 | + $actions = apply_filters('ms_user_row_actions', $actions, $user); |
|
| 422 | + return $this->row_actions($actions); |
|
| 423 | 423 | } |
| 424 | 424 | } |
@@ -42,8 +42,9 @@ discard block |
||
| 42 | 42 | 'fields' => 'all_with_meta' |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - if ( wp_is_large_network( 'users' ) ) |
|
| 46 | - $args['search'] = ltrim( $args['search'], '*' ); |
|
| 45 | + if ( wp_is_large_network( 'users' ) ) { |
|
| 46 | + $args['search'] = ltrim( $args['search'], '*' ); |
|
| 47 | + } |
|
| 47 | 48 | |
| 48 | 49 | if ( $role == 'super' ) { |
| 49 | 50 | $logins = implode( "', '", get_super_admins() ); |
@@ -56,18 +57,22 @@ discard block |
||
| 56 | 57 | * expensive count queries. |
| 57 | 58 | */ |
| 58 | 59 | if ( !$usersearch && wp_is_large_network( 'users' ) ) { |
| 59 | - if ( !isset($_REQUEST['orderby']) ) |
|
| 60 | - $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; |
|
| 61 | - if ( !isset($_REQUEST['order']) ) |
|
| 62 | - $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
| 60 | + if ( !isset($_REQUEST['orderby']) ) { |
|
| 61 | + $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; |
|
| 62 | + } |
|
| 63 | + if ( !isset($_REQUEST['order']) ) { |
|
| 64 | + $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
| 65 | + } |
|
| 63 | 66 | $args['count_total'] = false; |
| 64 | 67 | } |
| 65 | 68 | |
| 66 | - if ( isset( $_REQUEST['orderby'] ) ) |
|
| 67 | - $args['orderby'] = $_REQUEST['orderby']; |
|
| 69 | + if ( isset( $_REQUEST['orderby'] ) ) { |
|
| 70 | + $args['orderby'] = $_REQUEST['orderby']; |
|
| 71 | + } |
|
| 68 | 72 | |
| 69 | - if ( isset( $_REQUEST['order'] ) ) |
|
| 70 | - $args['order'] = $_REQUEST['order']; |
|
| 73 | + if ( isset( $_REQUEST['order'] ) ) { |
|
| 74 | + $args['order'] = $_REQUEST['order']; |
|
| 75 | + } |
|
| 71 | 76 | |
| 72 | 77 | $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
| 73 | 78 | |
@@ -88,8 +93,9 @@ discard block |
||
| 88 | 93 | */ |
| 89 | 94 | protected function get_bulk_actions() { |
| 90 | 95 | $actions = array(); |
| 91 | - if ( current_user_can( 'delete_users' ) ) |
|
| 92 | - $actions['delete'] = __( 'Delete' ); |
|
| 96 | + if ( current_user_can( 'delete_users' ) ) { |
|
| 97 | + $actions['delete'] = __( 'Delete' ); |
|
| 98 | + } |
|
| 93 | 99 | $actions['spam'] = _x( 'Mark as Spam', 'user' ); |
| 94 | 100 | $actions['notspam'] = _x( 'Not Spam', 'user' ); |
| 95 | 101 | |
@@ -133,8 +139,9 @@ discard block |
||
| 133 | 139 | |
| 134 | 140 | parent::pagination ( $which ); |
| 135 | 141 | |
| 136 | - if ( 'top' == $which ) |
|
| 137 | - $this->view_switcher( $mode ); |
|
| 142 | + if ( 'top' == $which ) { |
|
| 143 | + $this->view_switcher( $mode ); |
|
| 144 | + } |
|
| 138 | 145 | } |
| 139 | 146 | |
| 140 | 147 | /** |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @since 4.2.0 |
| 185 | 185 | * |
| 186 | - * @return bool Whether the current view is the "All" view. |
|
| 186 | + * @return boolean|null Whether the current view is the "All" view. |
|
| 187 | 187 | */ |
| 188 | 188 | protected function is_base_request() { |
| 189 | 189 | if ( empty( $_GET ) ) { |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | /** |
| 377 | 377 | * |
| 378 | - * @return array |
|
| 378 | + * @return string[] |
|
| 379 | 379 | */ |
| 380 | 380 | protected function get_table_classes() { |
| 381 | 381 | return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | * @since 4.3.0 |
| 1045 | 1045 | * @access protected |
| 1046 | 1046 | * |
| 1047 | - * @param object $post Post being acted upon. |
|
| 1047 | + * @param WP_Post $post Post being acted upon. |
|
| 1048 | 1048 | * @param string $column_name Current column name. |
| 1049 | 1049 | * @param string $primary Primary column name. |
| 1050 | 1050 | * @return string Row actions output for posts. |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Posts List Table class. |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage List_Table |
|
| 7 | - * @since 3.1.0 |
|
| 8 | - * @access private |
|
| 9 | - */ |
|
| 3 | + * Posts List Table class. |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage List_Table |
|
| 7 | + * @since 3.1.0 |
|
| 8 | + * @access private |
|
| 9 | + */ |
|
| 10 | 10 | class WP_Posts_List_Table extends WP_List_Table { |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -1013,10 +1013,10 @@ discard block |
||
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | if ( $post->post_parent ) { |
| 1016 | - $count = count( get_post_ancestors( $post->ID ) ); |
|
| 1017 | - $classes .= ' level-'. $count; |
|
| 1016 | + $count = count( get_post_ancestors( $post->ID ) ); |
|
| 1017 | + $classes .= ' level-'. $count; |
|
| 1018 | 1018 | } else { |
| 1019 | - $classes .= ' level-0'; |
|
| 1019 | + $classes .= ' level-0'; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | ?> |
| 1022 | 1022 | <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | <?php |
| 1348 | 1348 | /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
| 1349 | 1349 | $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' ); |
| 1350 | - ?> |
|
| 1350 | + ?> |
|
| 1351 | 1351 | <option value="default"><?php echo esc_html( $default_title ); ?></option> |
| 1352 | 1352 | <?php page_template_dropdown() ?> |
| 1353 | 1353 | </select> |
@@ -69,32 +69,32 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @param array $args An associative array of arguments. |
| 71 | 71 | */ |
| 72 | - public function __construct( $args = array() ) { |
|
| 72 | + public function __construct($args = array()) { |
|
| 73 | 73 | global $post_type_object, $wpdb; |
| 74 | 74 | |
| 75 | - parent::__construct( array( |
|
| 75 | + parent::__construct(array( |
|
| 76 | 76 | 'plural' => 'posts', |
| 77 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
| 78 | - ) ); |
|
| 77 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
| 78 | + )); |
|
| 79 | 79 | |
| 80 | 80 | $post_type = $this->screen->post_type; |
| 81 | - $post_type_object = get_post_type_object( $post_type ); |
|
| 81 | + $post_type_object = get_post_type_object($post_type); |
|
| 82 | 82 | |
| 83 | - if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
|
| 84 | - $exclude_states = get_post_stati( array( 'show_in_admin_all_list' => false ) ); |
|
| 85 | - $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " |
|
| 83 | + if ( ! current_user_can($post_type_object->cap->edit_others_posts)) { |
|
| 84 | + $exclude_states = get_post_stati(array('show_in_admin_all_list' => false)); |
|
| 85 | + $this->user_posts_count = $wpdb->get_var($wpdb->prepare(" |
|
| 86 | 86 | SELECT COUNT( 1 ) FROM $wpdb->posts |
| 87 | - WHERE post_type = %s AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) |
|
| 87 | + WHERE post_type = %s AND post_status NOT IN ( '".implode("','", $exclude_states)."' ) |
|
| 88 | 88 | AND post_author = %d |
| 89 | - ", $post_type, get_current_user_id() ) ); |
|
| 89 | + ", $post_type, get_current_user_id())); |
|
| 90 | 90 | |
| 91 | - if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) |
|
| 91 | + if ($this->user_posts_count && empty($_REQUEST['post_status']) && empty($_REQUEST['all_posts']) && empty($_REQUEST['author']) && empty($_REQUEST['show_sticky'])) |
|
| 92 | 92 | $_GET['author'] = get_current_user_id(); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { |
|
| 96 | - $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
|
| 97 | - $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) ); |
|
| 95 | + if ('post' == $post_type && $sticky_posts = get_option('sticky_posts')) { |
|
| 96 | + $sticky_posts = implode(', ', array_map('absint', (array) $sticky_posts)); |
|
| 97 | + $this->sticky_posts_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type)); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param bool $display Whether the table layout should be hierarchical. |
| 107 | 107 | */ |
| 108 | - public function set_hierarchical_display( $display ) { |
|
| 108 | + public function set_hierarchical_display($display) { |
|
| 109 | 109 | $this->hierarchical_display = $display; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @return bool |
| 115 | 115 | */ |
| 116 | 116 | public function ajax_user_can() { |
| 117 | - return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
|
| 117 | + return current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_posts); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -129,35 +129,35 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $avail_post_stati = wp_edit_posts_query(); |
| 131 | 131 | |
| 132 | - $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] ); |
|
| 132 | + $this->set_hierarchical_display(is_post_type_hierarchical($this->screen->post_type) && 'menu_order title' == $wp_query->query['orderby']); |
|
| 133 | 133 | |
| 134 | 134 | $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; |
| 135 | 135 | |
| 136 | 136 | $post_type = $this->screen->post_type; |
| 137 | - $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
|
| 137 | + $per_page = $this->get_items_per_page('edit_'.$post_type.'_per_page'); |
|
| 138 | 138 | |
| 139 | 139 | /** This filter is documented in wp-admin/includes/post.php */ |
| 140 | - $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
|
| 140 | + $per_page = apply_filters('edit_posts_per_page', $per_page, $post_type); |
|
| 141 | 141 | |
| 142 | - if ( $this->hierarchical_display ) |
|
| 143 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 142 | + if ($this->hierarchical_display) |
|
| 143 | + $total_pages = ceil($total_items / $per_page); |
|
| 144 | 144 | else |
| 145 | 145 | $total_pages = $wp_query->max_num_pages; |
| 146 | 146 | |
| 147 | - if ( ! empty( $_REQUEST['mode'] ) ) { |
|
| 147 | + if ( ! empty($_REQUEST['mode'])) { |
|
| 148 | 148 | $mode = $_REQUEST['mode'] == 'excerpt' ? 'excerpt' : 'list'; |
| 149 | - set_user_setting ( 'posts_list_mode', $mode ); |
|
| 149 | + set_user_setting('posts_list_mode', $mode); |
|
| 150 | 150 | } else { |
| 151 | - $mode = get_user_setting ( 'posts_list_mode', 'list' ); |
|
| 151 | + $mode = get_user_setting('posts_list_mode', 'list'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash'; |
|
| 154 | + $this->is_trash = isset($_REQUEST['post_status']) && $_REQUEST['post_status'] == 'trash'; |
|
| 155 | 155 | |
| 156 | - $this->set_pagination_args( array( |
|
| 156 | + $this->set_pagination_args(array( |
|
| 157 | 157 | 'total_items' => $total_items, |
| 158 | 158 | 'total_pages' => $total_pages, |
| 159 | 159 | 'per_page' => $per_page |
| 160 | - ) ); |
|
| 160 | + )); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | * @access public |
| 173 | 173 | */ |
| 174 | 174 | public function no_items() { |
| 175 | - if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) |
|
| 176 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
|
| 175 | + if (isset($_REQUEST['post_status']) && 'trash' == $_REQUEST['post_status']) |
|
| 176 | + echo get_post_type_object($this->screen->post_type)->labels->not_found_in_trash; |
|
| 177 | 177 | else |
| 178 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
|
| 178 | + echo get_post_type_object($this->screen->post_type)->labels->not_found; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | * @return bool Whether the current view is the "All" view. |
| 187 | 187 | */ |
| 188 | 188 | protected function is_base_request() { |
| 189 | - if ( empty( $_GET ) ) { |
|
| 189 | + if (empty($_GET)) { |
|
| 190 | 190 | return true; |
| 191 | - } elseif ( 1 === count( $_GET ) && ! empty( $_GET['post_type'] ) ) { |
|
| 191 | + } elseif (1 === count($_GET) && ! empty($_GET['post_type'])) { |
|
| 192 | 192 | return $this->screen->post_type === $_GET['post_type']; |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -204,32 +204,32 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $post_type = $this->screen->post_type; |
| 206 | 206 | |
| 207 | - if ( !empty($locked_post_status) ) |
|
| 207 | + if ( ! empty($locked_post_status)) |
|
| 208 | 208 | return array(); |
| 209 | 209 | |
| 210 | 210 | $status_links = array(); |
| 211 | - $num_posts = wp_count_posts( $post_type, 'readable' ); |
|
| 211 | + $num_posts = wp_count_posts($post_type, 'readable'); |
|
| 212 | 212 | $class = ''; |
| 213 | 213 | $allposts = ''; |
| 214 | 214 | |
| 215 | 215 | $current_user_id = get_current_user_id(); |
| 216 | 216 | |
| 217 | - if ( $this->user_posts_count ) { |
|
| 218 | - if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) |
|
| 217 | + if ($this->user_posts_count) { |
|
| 218 | + if (isset($_GET['author']) && ($_GET['author'] == $current_user_id)) |
|
| 219 | 219 | $class = ' class="current"'; |
| 220 | - $status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>'; |
|
| 220 | + $status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>".sprintf(_nx('Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts'), number_format_i18n($this->user_posts_count)).'</a>'; |
|
| 221 | 221 | $allposts = '&all_posts=1'; |
| 222 | 222 | $class = ''; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - $total_posts = array_sum( (array) $num_posts ); |
|
| 225 | + $total_posts = array_sum((array) $num_posts); |
|
| 226 | 226 | |
| 227 | 227 | // Subtract post types that are not included in the admin all list. |
| 228 | - foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) |
|
| 228 | + foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) |
|
| 229 | 229 | $total_posts -= $num_posts->$state; |
| 230 | 230 | |
| 231 | - if ( empty( $class ) && ( ( $this->is_base_request() && ! $this->user_posts_count ) || isset( $_REQUEST['all_posts'] ) ) ) { |
|
| 232 | - $class = ' class="current"'; |
|
| 231 | + if (empty($class) && (($this->is_base_request() && ! $this->user_posts_count) || isset($_REQUEST['all_posts']))) { |
|
| 232 | + $class = ' class="current"'; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | $all_inner_html = sprintf( |
@@ -239,36 +239,36 @@ discard block |
||
| 239 | 239 | $total_posts, |
| 240 | 240 | 'posts' |
| 241 | 241 | ), |
| 242 | - number_format_i18n( $total_posts ) |
|
| 242 | + number_format_i18n($total_posts) |
|
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | - $status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . $all_inner_html . '</a>'; |
|
| 245 | + $status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>".$all_inner_html.'</a>'; |
|
| 246 | 246 | |
| 247 | - foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { |
|
| 247 | + foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) { |
|
| 248 | 248 | $class = ''; |
| 249 | 249 | |
| 250 | 250 | $status_name = $status->name; |
| 251 | 251 | |
| 252 | - if ( !in_array( $status_name, $avail_post_stati ) ) |
|
| 252 | + if ( ! in_array($status_name, $avail_post_stati)) |
|
| 253 | 253 | continue; |
| 254 | 254 | |
| 255 | - if ( empty( $num_posts->$status_name ) ) |
|
| 255 | + if (empty($num_posts->$status_name)) |
|
| 256 | 256 | continue; |
| 257 | 257 | |
| 258 | - if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] ) |
|
| 258 | + if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) |
|
| 259 | 259 | $class = ' class="current"'; |
| 260 | 260 | |
| 261 | - $status_links[$status_name] = "<a href='edit.php?post_status=$status_name&post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>'; |
|
| 261 | + $status_links[$status_name] = "<a href='edit.php?post_status=$status_name&post_type=$post_type'$class>".sprintf(translate_nooped_plural($status->label_count, $num_posts->$status_name), number_format_i18n($num_posts->$status_name)).'</a>'; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if ( ! empty( $this->sticky_posts_count ) ) { |
|
| 265 | - $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; |
|
| 264 | + if ( ! empty($this->sticky_posts_count)) { |
|
| 265 | + $class = ! empty($_REQUEST['show_sticky']) ? ' class="current"' : ''; |
|
| 266 | 266 | |
| 267 | - $sticky_link = array( 'sticky' => "<a href='edit.php?post_type=$post_type&show_sticky=1'$class>" . sprintf( _nx( 'Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '</a>' ); |
|
| 267 | + $sticky_link = array('sticky' => "<a href='edit.php?post_type=$post_type&show_sticky=1'$class>".sprintf(_nx('Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts'), number_format_i18n($this->sticky_posts_count)).'</a>'); |
|
| 268 | 268 | |
| 269 | 269 | // Sticky comes after Publish, or if not listed, after All. |
| 270 | - $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); |
|
| 271 | - $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); |
|
| 270 | + $split = 1 + array_search((isset($status_links['publish']) ? 'publish' : 'all'), array_keys($status_links)); |
|
| 271 | + $status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split)); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | return $status_links; |
@@ -280,19 +280,19 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | protected function get_bulk_actions() { |
| 282 | 282 | $actions = array(); |
| 283 | - $post_type_obj = get_post_type_object( $this->screen->post_type ); |
|
| 283 | + $post_type_obj = get_post_type_object($this->screen->post_type); |
|
| 284 | 284 | |
| 285 | - if ( $this->is_trash ) { |
|
| 286 | - $actions['untrash'] = __( 'Restore' ); |
|
| 285 | + if ($this->is_trash) { |
|
| 286 | + $actions['untrash'] = __('Restore'); |
|
| 287 | 287 | } else { |
| 288 | - $actions['edit'] = __( 'Edit' ); |
|
| 288 | + $actions['edit'] = __('Edit'); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { |
|
| 292 | - if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { |
|
| 293 | - $actions['delete'] = __( 'Delete Permanently' ); |
|
| 291 | + if (current_user_can($post_type_obj->cap->delete_posts)) { |
|
| 292 | + if ($this->is_trash || ! EMPTY_TRASH_DAYS) { |
|
| 293 | + $actions['delete'] = __('Delete Permanently'); |
|
| 294 | 294 | } else { |
| 295 | - $actions['trash'] = __( 'Move to Trash' ); |
|
| 295 | + $actions['trash'] = __('Move to Trash'); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
@@ -303,18 +303,18 @@ discard block |
||
| 303 | 303 | * @global int $cat |
| 304 | 304 | * @param string $which |
| 305 | 305 | */ |
| 306 | - protected function extra_tablenav( $which ) { |
|
| 306 | + protected function extra_tablenav($which) { |
|
| 307 | 307 | global $cat; |
| 308 | 308 | ?> |
| 309 | 309 | <div class="alignleft actions"> |
| 310 | 310 | <?php |
| 311 | - if ( 'top' == $which && !is_singular() ) { |
|
| 311 | + if ('top' == $which && ! is_singular()) { |
|
| 312 | 312 | |
| 313 | - $this->months_dropdown( $this->screen->post_type ); |
|
| 313 | + $this->months_dropdown($this->screen->post_type); |
|
| 314 | 314 | |
| 315 | - if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) { |
|
| 315 | + if (is_object_in_taxonomy($this->screen->post_type, 'category')) { |
|
| 316 | 316 | $dropdown_options = array( |
| 317 | - 'show_option_all' => __( 'All categories' ), |
|
| 317 | + 'show_option_all' => __('All categories'), |
|
| 318 | 318 | 'hide_empty' => 0, |
| 319 | 319 | 'hierarchical' => 1, |
| 320 | 320 | 'show_count' => 0, |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | 'selected' => $cat |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | - echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>'; |
|
| 326 | - wp_dropdown_categories( $dropdown_options ); |
|
| 325 | + echo '<label class="screen-reader-text" for="cat">'.__('Filter by category').'</label>'; |
|
| 326 | + wp_dropdown_categories($dropdown_options); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @param string $post_type The post type slug. |
| 338 | 338 | */ |
| 339 | - do_action( 'restrict_manage_posts', $this->screen->post_type ); |
|
| 339 | + do_action('restrict_manage_posts', $this->screen->post_type); |
|
| 340 | 340 | |
| 341 | - submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
| 341 | + submit_button(__('Filter'), 'button', 'filter_action', false, array('id' => 'post-query-submit')); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) { |
|
| 345 | - submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
|
| 344 | + if ($this->is_trash && current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_others_posts)) { |
|
| 345 | + submit_button(__('Empty Trash'), 'apply', 'delete_all', false); |
|
| 346 | 346 | } |
| 347 | 347 | ?> |
| 348 | 348 | </div> |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @return string |
| 355 | 355 | */ |
| 356 | 356 | public function current_action() { |
| 357 | - if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
|
| 357 | + if (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) |
|
| 358 | 358 | return 'delete_all'; |
| 359 | 359 | |
| 360 | 360 | return parent::current_action(); |
@@ -364,13 +364,13 @@ discard block |
||
| 364 | 364 | * @global string $mode |
| 365 | 365 | * @param string $which |
| 366 | 366 | */ |
| 367 | - protected function pagination( $which ) { |
|
| 367 | + protected function pagination($which) { |
|
| 368 | 368 | global $mode; |
| 369 | 369 | |
| 370 | - parent::pagination( $which ); |
|
| 370 | + parent::pagination($which); |
|
| 371 | 371 | |
| 372 | - if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) ) |
|
| 373 | - $this->view_switcher( $mode ); |
|
| 372 | + if ('top' == $which && ! is_post_type_hierarchical($this->screen->post_type)) |
|
| 373 | + $this->view_switcher($mode); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @return array |
| 379 | 379 | */ |
| 380 | 380 | protected function get_table_classes() { |
| 381 | - return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
|
| 381 | + return array('widefat', 'fixed', 'striped', is_post_type_hierarchical($this->screen->post_type) ? 'pages' : 'posts'); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -393,14 +393,14 @@ discard block |
||
| 393 | 393 | $posts_columns['cb'] = '<input type="checkbox" />'; |
| 394 | 394 | |
| 395 | 395 | /* translators: manage posts column name */ |
| 396 | - $posts_columns['title'] = _x( 'Title', 'column name' ); |
|
| 396 | + $posts_columns['title'] = _x('Title', 'column name'); |
|
| 397 | 397 | |
| 398 | - if ( post_type_supports( $post_type, 'author' ) ) { |
|
| 399 | - $posts_columns['author'] = __( 'Author' ); |
|
| 398 | + if (post_type_supports($post_type, 'author')) { |
|
| 399 | + $posts_columns['author'] = __('Author'); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - $taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
|
| 403 | - $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
|
| 402 | + $taxonomies = get_object_taxonomies($post_type, 'objects'); |
|
| 403 | + $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name'); |
|
| 404 | 404 | |
| 405 | 405 | /** |
| 406 | 406 | * Filter the taxonomy columns in the Posts list table. |
@@ -413,27 +413,27 @@ discard block |
||
| 413 | 413 | * @param array $taxonomies Array of taxonomies to show columns for. |
| 414 | 414 | * @param string $post_type The post type. |
| 415 | 415 | */ |
| 416 | - $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
|
| 417 | - $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
| 416 | + $taxonomies = apply_filters("manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type); |
|
| 417 | + $taxonomies = array_filter($taxonomies, 'taxonomy_exists'); |
|
| 418 | 418 | |
| 419 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 420 | - if ( 'category' == $taxonomy ) |
|
| 419 | + foreach ($taxonomies as $taxonomy) { |
|
| 420 | + if ('category' == $taxonomy) |
|
| 421 | 421 | $column_key = 'categories'; |
| 422 | - elseif ( 'post_tag' == $taxonomy ) |
|
| 422 | + elseif ('post_tag' == $taxonomy) |
|
| 423 | 423 | $column_key = 'tags'; |
| 424 | 424 | else |
| 425 | - $column_key = 'taxonomy-' . $taxonomy; |
|
| 425 | + $column_key = 'taxonomy-'.$taxonomy; |
|
| 426 | 426 | |
| 427 | - $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
| 427 | + $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name; |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
|
| 431 | - if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
|
| 432 | - $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
| 430 | + $post_status = ! empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all'; |
|
| 431 | + if (post_type_supports($post_type, 'comments') && ! in_array($post_status, array('pending', 'draft', 'future'))) |
|
| 432 | + $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="'.esc_attr__('Comments').'"><span class="screen-reader-text">'.__('Comments').'</span></span>'; |
|
| 433 | 433 | |
| 434 | - $posts_columns['date'] = __( 'Date' ); |
|
| 434 | + $posts_columns['date'] = __('Date'); |
|
| 435 | 435 | |
| 436 | - if ( 'page' == $post_type ) { |
|
| 436 | + if ('page' == $post_type) { |
|
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | 439 | * Filter the columns displayed in the Pages list table. |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | * |
| 443 | 443 | * @param array $post_columns An array of column names. |
| 444 | 444 | */ |
| 445 | - $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
|
| 445 | + $posts_columns = apply_filters('manage_pages_columns', $posts_columns); |
|
| 446 | 446 | } else { |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | * @param array $posts_columns An array of column names. |
| 454 | 454 | * @param string $post_type The post type slug. |
| 455 | 455 | */ |
| 456 | - $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); |
|
| 456 | + $posts_columns = apply_filters('manage_posts_columns', $posts_columns, $post_type); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | * |
| 466 | 466 | * @param array $post_columns An array of column names. |
| 467 | 467 | */ |
| 468 | - return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); |
|
| 468 | + return apply_filters("manage_{$post_type}_posts_columns", $posts_columns); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | 'title' => 'title', |
| 478 | 478 | 'parent' => 'parent', |
| 479 | 479 | 'comments' => 'comment_count', |
| 480 | - 'date' => array( 'date', true ) |
|
| 480 | + 'date' => array('date', true) |
|
| 481 | 481 | ); |
| 482 | 482 | } |
| 483 | 483 | |
@@ -487,18 +487,18 @@ discard block |
||
| 487 | 487 | * @param array $posts |
| 488 | 488 | * @param int $level |
| 489 | 489 | */ |
| 490 | - public function display_rows( $posts = array(), $level = 0 ) { |
|
| 490 | + public function display_rows($posts = array(), $level = 0) { |
|
| 491 | 491 | global $wp_query, $per_page; |
| 492 | 492 | |
| 493 | - if ( empty( $posts ) ) |
|
| 493 | + if (empty($posts)) |
|
| 494 | 494 | $posts = $wp_query->posts; |
| 495 | 495 | |
| 496 | - add_filter( 'the_title', 'esc_html' ); |
|
| 496 | + add_filter('the_title', 'esc_html'); |
|
| 497 | 497 | |
| 498 | - if ( $this->hierarchical_display ) { |
|
| 499 | - $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); |
|
| 498 | + if ($this->hierarchical_display) { |
|
| 499 | + $this->_display_rows_hierarchical($posts, $this->get_pagenum(), $per_page); |
|
| 500 | 500 | } else { |
| 501 | - $this->_display_rows( $posts, $level ); |
|
| 501 | + $this->_display_rows($posts, $level); |
|
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | |
@@ -507,19 +507,19 @@ discard block |
||
| 507 | 507 | * @param array $posts |
| 508 | 508 | * @param int $level |
| 509 | 509 | */ |
| 510 | - private function _display_rows( $posts, $level = 0 ) { |
|
| 510 | + private function _display_rows($posts, $level = 0) { |
|
| 511 | 511 | global $mode; |
| 512 | 512 | |
| 513 | 513 | // Create array of post IDs. |
| 514 | 514 | $post_ids = array(); |
| 515 | 515 | |
| 516 | - foreach ( $posts as $a_post ) |
|
| 516 | + foreach ($posts as $a_post) |
|
| 517 | 517 | $post_ids[] = $a_post->ID; |
| 518 | 518 | |
| 519 | - $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
|
| 519 | + $this->comment_pending_count = get_pending_comments_num($post_ids); |
|
| 520 | 520 | |
| 521 | - foreach ( $posts as $post ) |
|
| 522 | - $this->single_row( $post, $level ); |
|
| 521 | + foreach ($posts as $post) |
|
| 522 | + $this->single_row($post, $level); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -529,15 +529,15 @@ discard block |
||
| 529 | 529 | * @param int $pagenum |
| 530 | 530 | * @param int $per_page |
| 531 | 531 | */ |
| 532 | - private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
|
| 532 | + private function _display_rows_hierarchical($pages, $pagenum = 1, $per_page = 20) { |
|
| 533 | 533 | global $wpdb; |
| 534 | 534 | |
| 535 | 535 | $level = 0; |
| 536 | 536 | |
| 537 | - if ( ! $pages ) { |
|
| 538 | - $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
|
| 537 | + if ( ! $pages) { |
|
| 538 | + $pages = get_pages(array('sort_column' => 'menu_order')); |
|
| 539 | 539 | |
| 540 | - if ( ! $pages ) |
|
| 540 | + if ( ! $pages) |
|
| 541 | 541 | return; |
| 542 | 542 | } |
| 543 | 543 | |
@@ -548,56 +548,56 @@ discard block |
||
| 548 | 548 | * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations |
| 549 | 549 | * If searching, ignore hierarchy and treat everything as top level |
| 550 | 550 | */ |
| 551 | - if ( empty( $_REQUEST['s'] ) ) { |
|
| 551 | + if (empty($_REQUEST['s'])) { |
|
| 552 | 552 | |
| 553 | 553 | $top_level_pages = array(); |
| 554 | 554 | $children_pages = array(); |
| 555 | 555 | |
| 556 | - foreach ( $pages as $page ) { |
|
| 556 | + foreach ($pages as $page) { |
|
| 557 | 557 | |
| 558 | 558 | // Catch and repair bad pages. |
| 559 | - if ( $page->post_parent == $page->ID ) { |
|
| 559 | + if ($page->post_parent == $page->ID) { |
|
| 560 | 560 | $page->post_parent = 0; |
| 561 | - $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); |
|
| 562 | - clean_post_cache( $page ); |
|
| 561 | + $wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID)); |
|
| 562 | + clean_post_cache($page); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - if ( 0 == $page->post_parent ) |
|
| 565 | + if (0 == $page->post_parent) |
|
| 566 | 566 | $top_level_pages[] = $page; |
| 567 | 567 | else |
| 568 | - $children_pages[ $page->post_parent ][] = $page; |
|
| 568 | + $children_pages[$page->post_parent][] = $page; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | $pages = &$top_level_pages; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | $count = 0; |
| 575 | - $start = ( $pagenum - 1 ) * $per_page; |
|
| 575 | + $start = ($pagenum - 1) * $per_page; |
|
| 576 | 576 | $end = $start + $per_page; |
| 577 | 577 | $to_display = array(); |
| 578 | 578 | |
| 579 | - foreach ( $pages as $page ) { |
|
| 580 | - if ( $count >= $end ) |
|
| 579 | + foreach ($pages as $page) { |
|
| 580 | + if ($count >= $end) |
|
| 581 | 581 | break; |
| 582 | 582 | |
| 583 | - if ( $count >= $start ) { |
|
| 583 | + if ($count >= $start) { |
|
| 584 | 584 | $to_display[$page->ID] = $level; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | $count++; |
| 588 | 588 | |
| 589 | - if ( isset( $children_pages ) ) |
|
| 590 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 589 | + if (isset($children_pages)) |
|
| 590 | + $this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | // If it is the last pagenum and there are orphaned pages, display them with paging as well. |
| 594 | - if ( isset( $children_pages ) && $count < $end ){ |
|
| 595 | - foreach ( $children_pages as $orphans ){ |
|
| 596 | - foreach ( $orphans as $op ) { |
|
| 597 | - if ( $count >= $end ) |
|
| 594 | + if (isset($children_pages) && $count < $end) { |
|
| 595 | + foreach ($children_pages as $orphans) { |
|
| 596 | + foreach ($orphans as $op) { |
|
| 597 | + if ($count >= $end) |
|
| 598 | 598 | break; |
| 599 | 599 | |
| 600 | - if ( $count >= $start ) { |
|
| 600 | + if ($count >= $start) { |
|
| 601 | 601 | $to_display[$op->ID] = 0; |
| 602 | 602 | } |
| 603 | 603 | |
@@ -606,16 +606,16 @@ discard block |
||
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - $ids = array_keys( $to_display ); |
|
| 610 | - _prime_post_caches( $ids ); |
|
| 609 | + $ids = array_keys($to_display); |
|
| 610 | + _prime_post_caches($ids); |
|
| 611 | 611 | |
| 612 | - if ( ! isset( $GLOBALS['post'] ) ) { |
|
| 613 | - $GLOBALS['post'] = reset( $ids ); |
|
| 612 | + if ( ! isset($GLOBALS['post'])) { |
|
| 613 | + $GLOBALS['post'] = reset($ids); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - foreach ( $to_display as $page_id => $level ) { |
|
| 616 | + foreach ($to_display as $page_id => $level) { |
|
| 617 | 617 | echo "\t"; |
| 618 | - $this->single_row( $page_id, $level ); |
|
| 618 | + $this->single_row($page_id, $level); |
|
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | |
@@ -634,51 +634,51 @@ discard block |
||
| 634 | 634 | * @param int $per_page |
| 635 | 635 | * @param array $to_display List of pages to be displayed. Passed by reference. |
| 636 | 636 | */ |
| 637 | - private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { |
|
| 638 | - if ( ! isset( $children_pages[$parent] ) ) |
|
| 637 | + private function _page_rows(&$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display) { |
|
| 638 | + if ( ! isset($children_pages[$parent])) |
|
| 639 | 639 | return; |
| 640 | 640 | |
| 641 | - $start = ( $pagenum - 1 ) * $per_page; |
|
| 641 | + $start = ($pagenum - 1) * $per_page; |
|
| 642 | 642 | $end = $start + $per_page; |
| 643 | 643 | |
| 644 | - foreach ( $children_pages[$parent] as $page ) { |
|
| 645 | - if ( $count >= $end ) |
|
| 644 | + foreach ($children_pages[$parent] as $page) { |
|
| 645 | + if ($count >= $end) |
|
| 646 | 646 | break; |
| 647 | 647 | |
| 648 | 648 | // If the page starts in a subtree, print the parents. |
| 649 | - if ( $count == $start && $page->post_parent > 0 ) { |
|
| 649 | + if ($count == $start && $page->post_parent > 0) { |
|
| 650 | 650 | $my_parents = array(); |
| 651 | 651 | $my_parent = $page->post_parent; |
| 652 | - while ( $my_parent ) { |
|
| 652 | + while ($my_parent) { |
|
| 653 | 653 | // Get the ID from the list or the attribute if my_parent is an object |
| 654 | 654 | $parent_id = $my_parent; |
| 655 | - if ( is_object( $my_parent ) ) { |
|
| 655 | + if (is_object($my_parent)) { |
|
| 656 | 656 | $parent_id = $my_parent->ID; |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - $my_parent = get_post( $parent_id ); |
|
| 659 | + $my_parent = get_post($parent_id); |
|
| 660 | 660 | $my_parents[] = $my_parent; |
| 661 | - if ( !$my_parent->post_parent ) |
|
| 661 | + if ( ! $my_parent->post_parent) |
|
| 662 | 662 | break; |
| 663 | 663 | $my_parent = $my_parent->post_parent; |
| 664 | 664 | } |
| 665 | - $num_parents = count( $my_parents ); |
|
| 666 | - while ( $my_parent = array_pop( $my_parents ) ) { |
|
| 665 | + $num_parents = count($my_parents); |
|
| 666 | + while ($my_parent = array_pop($my_parents)) { |
|
| 667 | 667 | $to_display[$my_parent->ID] = $level - $num_parents; |
| 668 | 668 | $num_parents--; |
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - if ( $count >= $start ) { |
|
| 672 | + if ($count >= $start) { |
|
| 673 | 673 | $to_display[$page->ID] = $level; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | $count++; |
| 677 | 677 | |
| 678 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 678 | + $this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - unset( $children_pages[$parent] ); //required in order to keep track of orphans |
|
| 681 | + unset($children_pages[$parent]); //required in order to keep track of orphans |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | /** |
@@ -689,10 +689,10 @@ discard block |
||
| 689 | 689 | * |
| 690 | 690 | * @param WP_Post $post The current WP_Post object. |
| 691 | 691 | */ |
| 692 | - public function column_cb( $post ) { |
|
| 693 | - if ( current_user_can( 'edit_post', $post->ID ) ): ?> |
|
| 692 | + public function column_cb($post) { |
|
| 693 | + if (current_user_can('edit_post', $post->ID)): ?> |
|
| 694 | 694 | <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php |
| 695 | - printf( __( 'Select %s' ), _draft_or_post_title() ); |
|
| 695 | + printf(__('Select %s'), _draft_or_post_title()); |
|
| 696 | 696 | ?></label> |
| 697 | 697 | <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
| 698 | 698 | <div class="locked-indicator"></div> |
@@ -708,10 +708,10 @@ discard block |
||
| 708 | 708 | * @param string $data |
| 709 | 709 | * @param string $primary |
| 710 | 710 | */ |
| 711 | - protected function _column_title( $post, $classes, $data, $primary ) { |
|
| 712 | - echo '<td class="' . $classes . ' page-title" ', $data, '>'; |
|
| 713 | - echo $this->column_title( $post ); |
|
| 714 | - echo $this->handle_row_actions( $post, 'title', $primary ); |
|
| 711 | + protected function _column_title($post, $classes, $data, $primary) { |
|
| 712 | + echo '<td class="'.$classes.' page-title" ', $data, '>'; |
|
| 713 | + echo $this->column_title($post); |
|
| 714 | + echo $this->handle_row_actions($post, 'title', $primary); |
|
| 715 | 715 | echo '</td>'; |
| 716 | 716 | } |
| 717 | 717 | |
@@ -725,77 +725,77 @@ discard block |
||
| 725 | 725 | * |
| 726 | 726 | * @param WP_Post $post The current WP_Post object. |
| 727 | 727 | */ |
| 728 | - public function column_title( $post ) { |
|
| 728 | + public function column_title($post) { |
|
| 729 | 729 | global $mode; |
| 730 | 730 | |
| 731 | - if ( $this->hierarchical_display ) { |
|
| 732 | - if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { |
|
| 731 | + if ($this->hierarchical_display) { |
|
| 732 | + if (0 === $this->current_level && (int) $post->post_parent > 0) { |
|
| 733 | 733 | // Sent level 0 by accident, by default, or because we don't know the actual level. |
| 734 | 734 | $find_main_page = (int) $post->post_parent; |
| 735 | - while ( $find_main_page > 0 ) { |
|
| 736 | - $parent = get_post( $find_main_page ); |
|
| 735 | + while ($find_main_page > 0) { |
|
| 736 | + $parent = get_post($find_main_page); |
|
| 737 | 737 | |
| 738 | - if ( is_null( $parent ) ) { |
|
| 738 | + if (is_null($parent)) { |
|
| 739 | 739 | break; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | $this->current_level++; |
| 743 | 743 | $find_main_page = (int) $parent->post_parent; |
| 744 | 744 | |
| 745 | - if ( ! isset( $parent_name ) ) { |
|
| 745 | + if ( ! isset($parent_name)) { |
|
| 746 | 746 | /** This filter is documented in wp-includes/post-template.php */ |
| 747 | - $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
|
| 747 | + $parent_name = apply_filters('the_title', $parent->post_title, $parent->ID); |
|
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - $pad = str_repeat( '— ', $this->current_level ); |
|
| 753 | + $pad = str_repeat('— ', $this->current_level); |
|
| 754 | 754 | echo "<strong>"; |
| 755 | 755 | |
| 756 | - $format = get_post_format( $post->ID ); |
|
| 757 | - if ( $format ) { |
|
| 758 | - $label = get_post_format_string( $format ); |
|
| 756 | + $format = get_post_format($post->ID); |
|
| 757 | + if ($format) { |
|
| 758 | + $label = get_post_format_string($format); |
|
| 759 | 759 | |
| 760 | - echo '<a href="' . esc_url( add_query_arg( array( 'post_format' => $format, 'post_type' => $post->post_type ), 'edit.php' ) ) . '" class="post-state-format post-format-icon post-format-' . $format . '" title="' . $label . '">' . $label . ":</a> "; |
|
| 760 | + echo '<a href="'.esc_url(add_query_arg(array('post_format' => $format, 'post_type' => $post->post_type), 'edit.php')).'" class="post-state-format post-format-icon post-format-'.$format.'" title="'.$label.'">'.$label.":</a> "; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
| 763 | + $can_edit_post = current_user_can('edit_post', $post->ID); |
|
| 764 | 764 | $title = _draft_or_post_title(); |
| 765 | 765 | |
| 766 | - if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
| 767 | - $edit_link = get_edit_post_link( $post->ID ); |
|
| 768 | - echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>'; |
|
| 766 | + if ($can_edit_post && $post->post_status != 'trash') { |
|
| 767 | + $edit_link = get_edit_post_link($post->ID); |
|
| 768 | + echo '<a class="row-title" href="'.$edit_link.'" title="'.esc_attr(sprintf(__('Edit “%s”'), $title)).'">'.$pad.$title.'</a>'; |
|
| 769 | 769 | } else { |
| 770 | - echo $pad . $title; |
|
| 770 | + echo $pad.$title; |
|
| 771 | 771 | } |
| 772 | - _post_states( $post ); |
|
| 772 | + _post_states($post); |
|
| 773 | 773 | |
| 774 | - if ( isset( $parent_name ) ) { |
|
| 775 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 776 | - echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
|
| 774 | + if (isset($parent_name)) { |
|
| 775 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 776 | + echo ' | '.$post_type_object->labels->parent_item_colon.' '.esc_html($parent_name); |
|
| 777 | 777 | } |
| 778 | 778 | echo "</strong>\n"; |
| 779 | 779 | |
| 780 | - if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
| 781 | - $lock_holder = wp_check_post_lock( $post->ID ); |
|
| 780 | + if ($can_edit_post && $post->post_status != 'trash') { |
|
| 781 | + $lock_holder = wp_check_post_lock($post->ID); |
|
| 782 | 782 | |
| 783 | - if ( $lock_holder ) { |
|
| 784 | - $lock_holder = get_userdata( $lock_holder ); |
|
| 785 | - $locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
|
| 786 | - $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
|
| 783 | + if ($lock_holder) { |
|
| 784 | + $lock_holder = get_userdata($lock_holder); |
|
| 785 | + $locked_avatar = get_avatar($lock_holder->ID, 18); |
|
| 786 | + $locked_text = esc_html(sprintf(__('%s is currently editing'), $lock_holder->display_name)); |
|
| 787 | 787 | } else { |
| 788 | 788 | $locked_avatar = $locked_text = ''; |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | - echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; |
|
| 791 | + echo '<div class="locked-info"><span class="locked-avatar">'.$locked_avatar.'</span> <span class="locked-text">'.$locked_text."</span></div>\n"; |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | - if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) { |
|
| 794 | + if ( ! is_post_type_hierarchical($this->screen->post_type) && 'excerpt' == $mode && current_user_can('read_post', $post->ID)) { |
|
| 795 | 795 | the_excerpt(); |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - get_inline_data( $post ); |
|
| 798 | + get_inline_data($post); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
@@ -808,27 +808,27 @@ discard block |
||
| 808 | 808 | * |
| 809 | 809 | * @param WP_Post $post The current WP_Post object. |
| 810 | 810 | */ |
| 811 | - public function column_date( $post ) { |
|
| 811 | + public function column_date($post) { |
|
| 812 | 812 | global $mode; |
| 813 | 813 | |
| 814 | - if ( '0000-00-00 00:00:00' == $post->post_date ) { |
|
| 815 | - $t_time = $h_time = __( 'Unpublished' ); |
|
| 814 | + if ('0000-00-00 00:00:00' == $post->post_date) { |
|
| 815 | + $t_time = $h_time = __('Unpublished'); |
|
| 816 | 816 | $time_diff = 0; |
| 817 | 817 | } else { |
| 818 | - $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
|
| 818 | + $t_time = get_the_time(__('Y/m/d g:i:s a')); |
|
| 819 | 819 | $m_time = $post->post_date; |
| 820 | - $time = get_post_time( 'G', true, $post ); |
|
| 820 | + $time = get_post_time('G', true, $post); |
|
| 821 | 821 | |
| 822 | 822 | $time_diff = time() - $time; |
| 823 | 823 | |
| 824 | - if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
|
| 825 | - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
| 824 | + if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { |
|
| 825 | + $h_time = sprintf(__('%s ago'), human_time_diff($time)); |
|
| 826 | 826 | } else { |
| 827 | - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
|
| 827 | + $h_time = mysql2date(__('Y/m/d'), $m_time); |
|
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | |
| 831 | - if ( 'excerpt' == $mode ) { |
|
| 831 | + if ('excerpt' == $mode) { |
|
| 832 | 832 | /** |
| 833 | 833 | * Filter the published time of the post. |
| 834 | 834 | * |
@@ -843,23 +843,23 @@ discard block |
||
| 843 | 843 | * @param string $column_name The column name. |
| 844 | 844 | * @param string $mode The list display mode ('excerpt' or 'list'). |
| 845 | 845 | */ |
| 846 | - echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
|
| 846 | + echo apply_filters('post_date_column_time', $t_time, $post, 'date', $mode); |
|
| 847 | 847 | } else { |
| 848 | 848 | |
| 849 | 849 | /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
| 850 | - echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>'; |
|
| 850 | + echo '<abbr title="'.$t_time.'">'.apply_filters('post_date_column_time', $h_time, $post, 'date', $mode).'</abbr>'; |
|
| 851 | 851 | } |
| 852 | 852 | echo '<br />'; |
| 853 | - if ( 'publish' == $post->post_status ) { |
|
| 854 | - _e( 'Published' ); |
|
| 855 | - } elseif ( 'future' == $post->post_status ) { |
|
| 856 | - if ( $time_diff > 0 ) { |
|
| 857 | - echo '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
|
| 853 | + if ('publish' == $post->post_status) { |
|
| 854 | + _e('Published'); |
|
| 855 | + } elseif ('future' == $post->post_status) { |
|
| 856 | + if ($time_diff > 0) { |
|
| 857 | + echo '<strong class="error-message">'.__('Missed schedule').'</strong>'; |
|
| 858 | 858 | } else { |
| 859 | - _e( 'Scheduled' ); |
|
| 859 | + _e('Scheduled'); |
|
| 860 | 860 | } |
| 861 | 861 | } else { |
| 862 | - _e( 'Last Modified' ); |
|
| 862 | + _e('Last Modified'); |
|
| 863 | 863 | } |
| 864 | 864 | } |
| 865 | 865 | |
@@ -871,13 +871,13 @@ discard block |
||
| 871 | 871 | * |
| 872 | 872 | * @param WP_Post $post The current WP_Post object. |
| 873 | 873 | */ |
| 874 | - public function column_comments( $post ) { |
|
| 874 | + public function column_comments($post) { |
|
| 875 | 875 | ?> |
| 876 | 876 | <div class="post-com-count-wrapper"> |
| 877 | 877 | <?php |
| 878 | - $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; |
|
| 878 | + $pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0; |
|
| 879 | 879 | |
| 880 | - $this->comments_bubble( $post->ID, $pending_comments ); |
|
| 880 | + $this->comments_bubble($post->ID, $pending_comments); |
|
| 881 | 881 | ?> |
| 882 | 882 | </div> |
| 883 | 883 | <?php |
@@ -891,9 +891,9 @@ discard block |
||
| 891 | 891 | * |
| 892 | 892 | * @param WP_Post $post The current WP_Post object. |
| 893 | 893 | */ |
| 894 | - public function column_author( $post ) { |
|
| 895 | - printf( '<a href="%s">%s</a>', |
|
| 896 | - esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )), |
|
| 894 | + public function column_author($post) { |
|
| 895 | + printf('<a href="%s">%s</a>', |
|
| 896 | + esc_url(add_query_arg(array('post_type' => $post->post_type, 'author' => get_the_author_meta('ID')), 'edit.php')), |
|
| 897 | 897 | get_the_author() |
| 898 | 898 | ); |
| 899 | 899 | } |
@@ -907,47 +907,47 @@ discard block |
||
| 907 | 907 | * @param WP_Post $post The current WP_Post object. |
| 908 | 908 | * @param string $column_name The current column name. |
| 909 | 909 | */ |
| 910 | - public function column_default( $post, $column_name ) { |
|
| 911 | - if ( 'categories' == $column_name ) { |
|
| 910 | + public function column_default($post, $column_name) { |
|
| 911 | + if ('categories' == $column_name) { |
|
| 912 | 912 | $taxonomy = 'category'; |
| 913 | - } elseif ( 'tags' == $column_name ) { |
|
| 913 | + } elseif ('tags' == $column_name) { |
|
| 914 | 914 | $taxonomy = 'post_tag'; |
| 915 | - } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
|
| 916 | - $taxonomy = substr( $column_name, 9 ); |
|
| 915 | + } elseif (0 === strpos($column_name, 'taxonomy-')) { |
|
| 916 | + $taxonomy = substr($column_name, 9); |
|
| 917 | 917 | } else { |
| 918 | 918 | $taxonomy = false; |
| 919 | 919 | } |
| 920 | - if ( $taxonomy ) { |
|
| 921 | - $taxonomy_object = get_taxonomy( $taxonomy ); |
|
| 922 | - $terms = get_the_terms( $post->ID, $taxonomy ); |
|
| 923 | - if ( is_array( $terms ) ) { |
|
| 920 | + if ($taxonomy) { |
|
| 921 | + $taxonomy_object = get_taxonomy($taxonomy); |
|
| 922 | + $terms = get_the_terms($post->ID, $taxonomy); |
|
| 923 | + if (is_array($terms)) { |
|
| 924 | 924 | $out = array(); |
| 925 | - foreach ( $terms as $t ) { |
|
| 925 | + foreach ($terms as $t) { |
|
| 926 | 926 | $posts_in_term_qv = array(); |
| 927 | - if ( 'post' != $post->post_type ) { |
|
| 927 | + if ('post' != $post->post_type) { |
|
| 928 | 928 | $posts_in_term_qv['post_type'] = $post->post_type; |
| 929 | 929 | } |
| 930 | - if ( $taxonomy_object->query_var ) { |
|
| 931 | - $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
|
| 930 | + if ($taxonomy_object->query_var) { |
|
| 931 | + $posts_in_term_qv[$taxonomy_object->query_var] = $t->slug; |
|
| 932 | 932 | } else { |
| 933 | 933 | $posts_in_term_qv['taxonomy'] = $taxonomy; |
| 934 | 934 | $posts_in_term_qv['term'] = $t->slug; |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - $out[] = sprintf( '<a href="%s">%s</a>', |
|
| 938 | - esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ), |
|
| 939 | - esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
|
| 937 | + $out[] = sprintf('<a href="%s">%s</a>', |
|
| 938 | + esc_url(add_query_arg($posts_in_term_qv, 'edit.php')), |
|
| 939 | + esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')) |
|
| 940 | 940 | ); |
| 941 | 941 | } |
| 942 | 942 | /* translators: used between list items, there is a space after the comma */ |
| 943 | - echo join( __( ', ' ), $out ); |
|
| 943 | + echo join(__(', '), $out); |
|
| 944 | 944 | } else { |
| 945 | - echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
|
| 945 | + echo '<span aria-hidden="true">—</span><span class="screen-reader-text">'.$taxonomy_object->labels->no_terms.'</span>'; |
|
| 946 | 946 | } |
| 947 | 947 | return; |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
| 950 | + if (is_post_type_hierarchical($post->post_type)) { |
|
| 951 | 951 | |
| 952 | 952 | /** |
| 953 | 953 | * Fires in each custom column on the Posts list table. |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | * @param string $column_name The name of the column to display. |
| 961 | 961 | * @param int $post_id The current post ID. |
| 962 | 962 | */ |
| 963 | - do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
|
| 963 | + do_action('manage_pages_custom_column', $column_name, $post->ID); |
|
| 964 | 964 | } else { |
| 965 | 965 | |
| 966 | 966 | /** |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | * @param string $column_name The name of the column to display. |
| 975 | 975 | * @param int $post_id The current post ID. |
| 976 | 976 | */ |
| 977 | - do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
|
| 977 | + do_action('manage_posts_custom_column', $column_name, $post->ID); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | * @param string $column_name The name of the column to display. |
| 988 | 988 | * @param int $post_id The current post ID. |
| 989 | 989 | */ |
| 990 | - do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
|
| 990 | + do_action("manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID); |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | /** |
@@ -996,31 +996,31 @@ discard block |
||
| 996 | 996 | * @param int|WP_Post $post |
| 997 | 997 | * @param int $level |
| 998 | 998 | */ |
| 999 | - public function single_row( $post, $level = 0 ) { |
|
| 999 | + public function single_row($post, $level = 0) { |
|
| 1000 | 1000 | $global_post = get_post(); |
| 1001 | 1001 | |
| 1002 | - $post = get_post( $post ); |
|
| 1002 | + $post = get_post($post); |
|
| 1003 | 1003 | $this->current_level = $level; |
| 1004 | 1004 | |
| 1005 | 1005 | $GLOBALS['post'] = $post; |
| 1006 | - setup_postdata( $post ); |
|
| 1006 | + setup_postdata($post); |
|
| 1007 | 1007 | |
| 1008 | - $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); |
|
| 1008 | + $classes = 'iedit author-'.(get_current_user_id() == $post->post_author ? 'self' : 'other'); |
|
| 1009 | 1009 | |
| 1010 | - $lock_holder = wp_check_post_lock( $post->ID ); |
|
| 1011 | - if ( $lock_holder ) { |
|
| 1010 | + $lock_holder = wp_check_post_lock($post->ID); |
|
| 1011 | + if ($lock_holder) { |
|
| 1012 | 1012 | $classes .= ' wp-locked'; |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - if ( $post->post_parent ) { |
|
| 1016 | - $count = count( get_post_ancestors( $post->ID ) ); |
|
| 1017 | - $classes .= ' level-'. $count; |
|
| 1015 | + if ($post->post_parent) { |
|
| 1016 | + $count = count(get_post_ancestors($post->ID)); |
|
| 1017 | + $classes .= ' level-'.$count; |
|
| 1018 | 1018 | } else { |
| 1019 | 1019 | $classes .= ' level-0'; |
| 1020 | 1020 | } |
| 1021 | 1021 | ?> |
| 1022 | - <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
|
| 1023 | - <?php $this->single_row_columns( $post ); ?> |
|
| 1022 | + <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode(' ', get_post_class($classes, $post->ID)); ?>"> |
|
| 1023 | + <?php $this->single_row_columns($post); ?> |
|
| 1024 | 1024 | </tr> |
| 1025 | 1025 | <?php |
| 1026 | 1026 | $GLOBALS['post'] = $global_post; |
@@ -1049,44 +1049,44 @@ discard block |
||
| 1049 | 1049 | * @param string $primary Primary column name. |
| 1050 | 1050 | * @return string Row actions output for posts. |
| 1051 | 1051 | */ |
| 1052 | - protected function handle_row_actions( $post, $column_name, $primary ) { |
|
| 1053 | - if ( $primary !== $column_name ) { |
|
| 1052 | + protected function handle_row_actions($post, $column_name, $primary) { |
|
| 1053 | + if ($primary !== $column_name) { |
|
| 1054 | 1054 | return ''; |
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1058 | - $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
| 1057 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1058 | + $can_edit_post = current_user_can('edit_post', $post->ID); |
|
| 1059 | 1059 | $actions = array(); |
| 1060 | 1060 | |
| 1061 | - if ( $can_edit_post && 'trash' != $post->post_status ) { |
|
| 1062 | - $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>'; |
|
| 1063 | - $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick Edit' ) . '</a>'; |
|
| 1061 | + if ($can_edit_post && 'trash' != $post->post_status) { |
|
| 1062 | + $actions['edit'] = '<a href="'.get_edit_post_link($post->ID).'" title="'.esc_attr__('Edit this item').'">'.__('Edit').'</a>'; |
|
| 1063 | + $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="'.esc_attr__('Edit this item inline').'">'.__('Quick Edit').'</a>'; |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | - if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
| 1067 | - if ( 'trash' == $post->post_status ) |
|
| 1068 | - $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; |
|
| 1069 | - elseif ( EMPTY_TRASH_DAYS ) |
|
| 1070 | - $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
|
| 1071 | - if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) |
|
| 1072 | - $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
|
| 1066 | + if (current_user_can('delete_post', $post->ID)) { |
|
| 1067 | + if ('trash' == $post->post_status) |
|
| 1068 | + $actions['untrash'] = "<a title='".esc_attr__('Restore this item from the Trash')."' href='".wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link.'&action=untrash', $post->ID)), 'untrash-post_'.$post->ID)."'>".__('Restore')."</a>"; |
|
| 1069 | + elseif (EMPTY_TRASH_DAYS) |
|
| 1070 | + $actions['trash'] = "<a class='submitdelete' title='".esc_attr__('Move this item to the Trash')."' href='".get_delete_post_link($post->ID)."'>".__('Trash')."</a>"; |
|
| 1071 | + if ('trash' == $post->post_status || ! EMPTY_TRASH_DAYS) |
|
| 1072 | + $actions['delete'] = "<a class='submitdelete' title='".esc_attr__('Delete this item permanently')."' href='".get_delete_post_link($post->ID, '', true)."'>".__('Delete Permanently')."</a>"; |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - if ( is_post_type_viewable( $post_type_object ) ) { |
|
| 1075 | + if (is_post_type_viewable($post_type_object)) { |
|
| 1076 | 1076 | $title = _draft_or_post_title(); |
| 1077 | - if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { |
|
| 1078 | - if ( $can_edit_post ) { |
|
| 1079 | - $preview_link = set_url_scheme( get_permalink( $post->ID ) ); |
|
| 1077 | + if (in_array($post->post_status, array('pending', 'draft', 'future'))) { |
|
| 1078 | + if ($can_edit_post) { |
|
| 1079 | + $preview_link = set_url_scheme(get_permalink($post->ID)); |
|
| 1080 | 1080 | /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
| 1081 | - $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ); |
|
| 1082 | - $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>'; |
|
| 1081 | + $preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post); |
|
| 1082 | + $actions['view'] = '<a href="'.esc_url($preview_link).'" title="'.esc_attr(sprintf(__('Preview “%s”'), $title)).'" rel="permalink">'.__('Preview').'</a>'; |
|
| 1083 | 1083 | } |
| 1084 | - } elseif ( 'trash' != $post->post_status ) { |
|
| 1085 | - $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; |
|
| 1084 | + } elseif ('trash' != $post->post_status) { |
|
| 1085 | + $actions['view'] = '<a href="'.get_permalink($post->ID).'" title="'.esc_attr(sprintf(__('View “%s”'), $title)).'" rel="permalink">'.__('View').'</a>'; |
|
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | - if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
| 1089 | + if (is_post_type_hierarchical($post->post_type)) { |
|
| 1090 | 1090 | |
| 1091 | 1091 | /** |
| 1092 | 1092 | * Filter the array of row action links on the Pages list table. |
@@ -1100,7 +1100,7 @@ discard block |
||
| 1100 | 1100 | * 'Delete Permanently', 'Preview', and 'View'. |
| 1101 | 1101 | * @param WP_Post $post The post object. |
| 1102 | 1102 | */ |
| 1103 | - $actions = apply_filters( 'page_row_actions', $actions, $post ); |
|
| 1103 | + $actions = apply_filters('page_row_actions', $actions, $post); |
|
| 1104 | 1104 | } else { |
| 1105 | 1105 | |
| 1106 | 1106 | /** |
@@ -1115,10 +1115,10 @@ discard block |
||
| 1115 | 1115 | * 'Delete Permanently', 'Preview', and 'View'. |
| 1116 | 1116 | * @param WP_Post $post The post object. |
| 1117 | 1117 | */ |
| 1118 | - $actions = apply_filters( 'post_row_actions', $actions, $post ); |
|
| 1118 | + $actions = apply_filters('post_row_actions', $actions, $post); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | - return $this->row_actions( $actions ); |
|
| 1121 | + return $this->row_actions($actions); |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | /** |
@@ -1133,15 +1133,15 @@ discard block |
||
| 1133 | 1133 | |
| 1134 | 1134 | $screen = $this->screen; |
| 1135 | 1135 | |
| 1136 | - $post = get_default_post_to_edit( $screen->post_type ); |
|
| 1137 | - $post_type_object = get_post_type_object( $screen->post_type ); |
|
| 1136 | + $post = get_default_post_to_edit($screen->post_type); |
|
| 1137 | + $post_type_object = get_post_type_object($screen->post_type); |
|
| 1138 | 1138 | |
| 1139 | - $taxonomy_names = get_object_taxonomies( $screen->post_type ); |
|
| 1139 | + $taxonomy_names = get_object_taxonomies($screen->post_type); |
|
| 1140 | 1140 | $hierarchical_taxonomies = array(); |
| 1141 | 1141 | $flat_taxonomies = array(); |
| 1142 | - foreach ( $taxonomy_names as $taxonomy_name ) { |
|
| 1142 | + foreach ($taxonomy_names as $taxonomy_name) { |
|
| 1143 | 1143 | |
| 1144 | - $taxonomy = get_taxonomy( $taxonomy_name ); |
|
| 1144 | + $taxonomy = get_taxonomy($taxonomy_name); |
|
| 1145 | 1145 | |
| 1146 | 1146 | $show_in_quick_edit = $taxonomy->show_in_quick_edit; |
| 1147 | 1147 | |
@@ -1154,38 +1154,38 @@ discard block |
||
| 1154 | 1154 | * @param string $taxonomy_name Taxonomy name. |
| 1155 | 1155 | * @param string $post_type Post type of current Quick Edit post. |
| 1156 | 1156 | */ |
| 1157 | - if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { |
|
| 1157 | + if ( ! apply_filters('quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type)) { |
|
| 1158 | 1158 | continue; |
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | - if ( $taxonomy->hierarchical ) |
|
| 1161 | + if ($taxonomy->hierarchical) |
|
| 1162 | 1162 | $hierarchical_taxonomies[] = $taxonomy; |
| 1163 | 1163 | else |
| 1164 | 1164 | $flat_taxonomies[] = $taxonomy; |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | - $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; |
|
| 1168 | - $can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
|
| 1169 | - $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); |
|
| 1167 | + $m = (isset($mode) && 'excerpt' == $mode) ? 'excerpt' : 'list'; |
|
| 1168 | + $can_publish = current_user_can($post_type_object->cap->publish_posts); |
|
| 1169 | + $core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true); |
|
| 1170 | 1170 | |
| 1171 | 1171 | ?> |
| 1172 | 1172 | |
| 1173 | 1173 | <form method="get"><table style="display: none"><tbody id="inlineedit"> |
| 1174 | 1174 | <?php |
| 1175 | - $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
|
| 1175 | + $hclass = count($hierarchical_taxonomies) ? 'post' : 'page'; |
|
| 1176 | 1176 | $bulk = 0; |
| 1177 | - while ( $bulk < 2 ) { ?> |
|
| 1177 | + while ($bulk < 2) { ?> |
|
| 1178 | 1178 | |
| 1179 | - <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type; |
|
| 1179 | + <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-".$screen->post_type; |
|
| 1180 | 1180 | echo $bulk ? " bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; |
| 1181 | 1181 | ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
| 1182 | 1182 | |
| 1183 | 1183 | <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> |
| 1184 | - <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4> |
|
| 1184 | + <h4><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?></h4> |
|
| 1185 | 1185 | <?php |
| 1186 | 1186 | |
| 1187 | - if ( post_type_supports( $screen->post_type, 'title' ) ) : |
|
| 1188 | - if ( $bulk ) : ?> |
|
| 1187 | + if (post_type_supports($screen->post_type, 'title')) : |
|
| 1188 | + if ($bulk) : ?> |
|
| 1189 | 1189 | <div id="bulk-title-div"> |
| 1190 | 1190 | <div id="bulk-titles"></div> |
| 1191 | 1191 | </div> |
@@ -1193,30 +1193,30 @@ discard block |
||
| 1193 | 1193 | <?php else : // $bulk ?> |
| 1194 | 1194 | |
| 1195 | 1195 | <label> |
| 1196 | - <span class="title"><?php _e( 'Title' ); ?></span> |
|
| 1196 | + <span class="title"><?php _e('Title'); ?></span> |
|
| 1197 | 1197 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
| 1198 | 1198 | </label> |
| 1199 | 1199 | |
| 1200 | 1200 | <label> |
| 1201 | - <span class="title"><?php _e( 'Slug' ); ?></span> |
|
| 1201 | + <span class="title"><?php _e('Slug'); ?></span> |
|
| 1202 | 1202 | <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> |
| 1203 | 1203 | </label> |
| 1204 | 1204 | |
| 1205 | 1205 | <?php endif; // $bulk |
| 1206 | 1206 | endif; // post_type_supports title ?> |
| 1207 | 1207 | |
| 1208 | - <?php if ( !$bulk ) : ?> |
|
| 1208 | + <?php if ( ! $bulk) : ?> |
|
| 1209 | 1209 | <fieldset class="inline-edit-date"> |
| 1210 | - <legend><span class="title"><?php _e( 'Date' ); ?></span></legend> |
|
| 1211 | - <?php touch_time( 1, 1, 0, 1 ); ?> |
|
| 1210 | + <legend><span class="title"><?php _e('Date'); ?></span></legend> |
|
| 1211 | + <?php touch_time(1, 1, 0, 1); ?> |
|
| 1212 | 1212 | </fieldset> |
| 1213 | 1213 | <br class="clear" /> |
| 1214 | 1214 | <?php endif; // $bulk |
| 1215 | 1215 | |
| 1216 | - if ( post_type_supports( $screen->post_type, 'author' ) ) : |
|
| 1216 | + if (post_type_supports($screen->post_type, 'author')) : |
|
| 1217 | 1217 | $authors_dropdown = ''; |
| 1218 | 1218 | |
| 1219 | - if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) : |
|
| 1219 | + if (is_super_admin() || current_user_can($post_type_object->cap->edit_others_posts)) : |
|
| 1220 | 1220 | $users_opt = array( |
| 1221 | 1221 | 'hide_if_only_one_author' => false, |
| 1222 | 1222 | 'who' => 'authors', |
@@ -1225,39 +1225,39 @@ discard block |
||
| 1225 | 1225 | 'multi' => 1, |
| 1226 | 1226 | 'echo' => 0 |
| 1227 | 1227 | ); |
| 1228 | - if ( $bulk ) |
|
| 1229 | - $users_opt['show_option_none'] = __( '— No Change —' ); |
|
| 1228 | + if ($bulk) |
|
| 1229 | + $users_opt['show_option_none'] = __('— No Change —'); |
|
| 1230 | 1230 | |
| 1231 | - if ( $authors = wp_dropdown_users( $users_opt ) ) : |
|
| 1231 | + if ($authors = wp_dropdown_users($users_opt)) : |
|
| 1232 | 1232 | $authors_dropdown = '<label class="inline-edit-author">'; |
| 1233 | - $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
|
| 1233 | + $authors_dropdown .= '<span class="title">'.__('Author').'</span>'; |
|
| 1234 | 1234 | $authors_dropdown .= $authors; |
| 1235 | 1235 | $authors_dropdown .= '</label>'; |
| 1236 | 1236 | endif; |
| 1237 | 1237 | endif; // authors |
| 1238 | 1238 | ?> |
| 1239 | 1239 | |
| 1240 | - <?php if ( !$bulk ) echo $authors_dropdown; |
|
| 1240 | + <?php if ( ! $bulk) echo $authors_dropdown; |
|
| 1241 | 1241 | endif; // post_type_supports author |
| 1242 | 1242 | |
| 1243 | - if ( !$bulk && $can_publish ) : |
|
| 1243 | + if ( ! $bulk && $can_publish) : |
|
| 1244 | 1244 | ?> |
| 1245 | 1245 | |
| 1246 | 1246 | <div class="inline-edit-group"> |
| 1247 | 1247 | <label class="alignleft"> |
| 1248 | - <span class="title"><?php _e( 'Password' ); ?></span> |
|
| 1248 | + <span class="title"><?php _e('Password'); ?></span> |
|
| 1249 | 1249 | <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
| 1250 | 1250 | </label> |
| 1251 | 1251 | |
| 1252 | 1252 | <em class="alignleft inline-edit-or"> |
| 1253 | 1253 | <?php |
| 1254 | 1254 | /* translators: Between password field and private checkbox on post quick edit interface */ |
| 1255 | - _e( '–OR–' ); |
|
| 1255 | + _e('–OR–'); |
|
| 1256 | 1256 | ?> |
| 1257 | 1257 | </em> |
| 1258 | 1258 | <label class="alignleft inline-edit-private"> |
| 1259 | 1259 | <input type="checkbox" name="keep_private" value="private" /> |
| 1260 | - <span class="checkbox-title"><?php _e( 'Private' ); ?></span> |
|
| 1260 | + <span class="checkbox-title"><?php _e('Private'); ?></span> |
|
| 1261 | 1261 | </label> |
| 1262 | 1262 | </div> |
| 1263 | 1263 | |
@@ -1265,16 +1265,16 @@ discard block |
||
| 1265 | 1265 | |
| 1266 | 1266 | </div></fieldset> |
| 1267 | 1267 | |
| 1268 | - <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?> |
|
| 1268 | + <?php if (count($hierarchical_taxonomies) && ! $bulk) : ?> |
|
| 1269 | 1269 | |
| 1270 | 1270 | <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> |
| 1271 | 1271 | |
| 1272 | - <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
|
| 1272 | + <?php foreach ($hierarchical_taxonomies as $taxonomy) : ?> |
|
| 1273 | 1273 | |
| 1274 | - <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
|
| 1275 | - <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
|
| 1276 | - <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist"> |
|
| 1277 | - <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?> |
|
| 1274 | + <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name) ?></span> |
|
| 1275 | + <input type="hidden" name="<?php echo ($taxonomy->name == 'category') ? 'post_category[]' : 'tax_input['.esc_attr($taxonomy->name).'][]'; ?>" value="0" /> |
|
| 1276 | + <ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist"> |
|
| 1277 | + <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?> |
|
| 1278 | 1278 | </ul> |
| 1279 | 1279 | |
| 1280 | 1280 | <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?> |
@@ -1286,27 +1286,27 @@ discard block |
||
| 1286 | 1286 | <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> |
| 1287 | 1287 | |
| 1288 | 1288 | <?php |
| 1289 | - if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) |
|
| 1289 | + if (post_type_supports($screen->post_type, 'author') && $bulk) |
|
| 1290 | 1290 | echo $authors_dropdown; |
| 1291 | 1291 | |
| 1292 | - if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : |
|
| 1292 | + if (post_type_supports($screen->post_type, 'page-attributes')) : |
|
| 1293 | 1293 | |
| 1294 | - if ( $post_type_object->hierarchical ) : |
|
| 1294 | + if ($post_type_object->hierarchical) : |
|
| 1295 | 1295 | ?> |
| 1296 | 1296 | <label> |
| 1297 | - <span class="title"><?php _e( 'Parent' ); ?></span> |
|
| 1297 | + <span class="title"><?php _e('Parent'); ?></span> |
|
| 1298 | 1298 | <?php |
| 1299 | 1299 | $dropdown_args = array( |
| 1300 | 1300 | 'post_type' => $post_type_object->name, |
| 1301 | 1301 | 'selected' => $post->post_parent, |
| 1302 | 1302 | 'name' => 'post_parent', |
| 1303 | - 'show_option_none' => __( 'Main Page (no parent)' ), |
|
| 1303 | + 'show_option_none' => __('Main Page (no parent)'), |
|
| 1304 | 1304 | 'option_none_value' => 0, |
| 1305 | 1305 | 'sort_column' => 'menu_order, post_title', |
| 1306 | 1306 | ); |
| 1307 | 1307 | |
| 1308 | - if ( $bulk ) |
|
| 1309 | - $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
| 1308 | + if ($bulk) |
|
| 1309 | + $dropdown_args['show_option_no_change'] = __('— No Change —'); |
|
| 1310 | 1310 | |
| 1311 | 1311 | /** |
| 1312 | 1312 | * Filter the arguments used to generate the Quick Edit page-parent drop-down. |
@@ -1317,38 +1317,38 @@ discard block |
||
| 1317 | 1317 | * |
| 1318 | 1318 | * @param array $dropdown_args An array of arguments. |
| 1319 | 1319 | */ |
| 1320 | - $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args ); |
|
| 1320 | + $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); |
|
| 1321 | 1321 | |
| 1322 | - wp_dropdown_pages( $dropdown_args ); |
|
| 1322 | + wp_dropdown_pages($dropdown_args); |
|
| 1323 | 1323 | ?> |
| 1324 | 1324 | </label> |
| 1325 | 1325 | |
| 1326 | 1326 | <?php |
| 1327 | 1327 | endif; // hierarchical |
| 1328 | 1328 | |
| 1329 | - if ( !$bulk ) : ?> |
|
| 1329 | + if ( ! $bulk) : ?> |
|
| 1330 | 1330 | |
| 1331 | 1331 | <label> |
| 1332 | - <span class="title"><?php _e( 'Order' ); ?></span> |
|
| 1332 | + <span class="title"><?php _e('Order'); ?></span> |
|
| 1333 | 1333 | <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span> |
| 1334 | 1334 | </label> |
| 1335 | 1335 | |
| 1336 | 1336 | <?php endif; // !$bulk |
| 1337 | 1337 | |
| 1338 | - if ( 'page' == $screen->post_type ) : |
|
| 1338 | + if ('page' == $screen->post_type) : |
|
| 1339 | 1339 | ?> |
| 1340 | 1340 | |
| 1341 | 1341 | <label> |
| 1342 | - <span class="title"><?php _e( 'Template' ); ?></span> |
|
| 1342 | + <span class="title"><?php _e('Template'); ?></span> |
|
| 1343 | 1343 | <select name="page_template"> |
| 1344 | - <?php if ( $bulk ) : ?> |
|
| 1345 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1344 | + <?php if ($bulk) : ?> |
|
| 1345 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1346 | 1346 | <?php endif; // $bulk ?> |
| 1347 | 1347 | <?php |
| 1348 | 1348 | /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
| 1349 | - $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' ); |
|
| 1349 | + $default_title = apply_filters('default_page_template_title', __('Default Template'), 'quick-edit'); |
|
| 1350 | 1350 | ?> |
| 1351 | - <option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
| 1351 | + <option value="default"><?php echo esc_html($default_title); ?></option> |
|
| 1352 | 1352 | <?php page_template_dropdown() ?> |
| 1353 | 1353 | </select> |
| 1354 | 1354 | </label> |
@@ -1358,13 +1358,13 @@ discard block |
||
| 1358 | 1358 | endif; // page-attributes |
| 1359 | 1359 | ?> |
| 1360 | 1360 | |
| 1361 | - <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?> |
|
| 1361 | + <?php if (count($flat_taxonomies) && ! $bulk) : ?> |
|
| 1362 | 1362 | |
| 1363 | - <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
|
| 1364 | - <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
|
| 1363 | + <?php foreach ($flat_taxonomies as $taxonomy) : ?> |
|
| 1364 | + <?php if (current_user_can($taxonomy->cap->assign_terms)) : ?> |
|
| 1365 | 1365 | <label class="inline-edit-tags"> |
| 1366 | - <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
|
| 1367 | - <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea> |
|
| 1366 | + <span class="title"><?php echo esc_html($taxonomy->labels->name) ?></span> |
|
| 1367 | + <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name)?>]" class="tax_input_<?php echo esc_attr($taxonomy->name)?>"></textarea> |
|
| 1368 | 1368 | </label> |
| 1369 | 1369 | <?php endif; ?> |
| 1370 | 1370 | |
@@ -1372,26 +1372,26 @@ discard block |
||
| 1372 | 1372 | |
| 1373 | 1373 | <?php endif; // count( $flat_taxonomies ) && !$bulk ?> |
| 1374 | 1374 | |
| 1375 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : |
|
| 1376 | - if ( $bulk ) : ?> |
|
| 1375 | + <?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) : |
|
| 1376 | + if ($bulk) : ?> |
|
| 1377 | 1377 | |
| 1378 | 1378 | <div class="inline-edit-group"> |
| 1379 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
| 1379 | + <?php if (post_type_supports($screen->post_type, 'comments')) : ?> |
|
| 1380 | 1380 | <label class="alignleft"> |
| 1381 | - <span class="title"><?php _e( 'Comments' ); ?></span> |
|
| 1381 | + <span class="title"><?php _e('Comments'); ?></span> |
|
| 1382 | 1382 | <select name="comment_status"> |
| 1383 | - <option value=""><?php _e( '— No Change —' ); ?></option> |
|
| 1384 | - <option value="open"><?php _e( 'Allow' ); ?></option> |
|
| 1385 | - <option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
| 1383 | + <option value=""><?php _e('— No Change —'); ?></option> |
|
| 1384 | + <option value="open"><?php _e('Allow'); ?></option> |
|
| 1385 | + <option value="closed"><?php _e('Do not allow'); ?></option> |
|
| 1386 | 1386 | </select> |
| 1387 | 1387 | </label> |
| 1388 | - <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
| 1388 | + <?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?> |
|
| 1389 | 1389 | <label class="alignright"> |
| 1390 | - <span class="title"><?php _e( 'Pings' ); ?></span> |
|
| 1390 | + <span class="title"><?php _e('Pings'); ?></span> |
|
| 1391 | 1391 | <select name="ping_status"> |
| 1392 | - <option value=""><?php _e( '— No Change —' ); ?></option> |
|
| 1393 | - <option value="open"><?php _e( 'Allow' ); ?></option> |
|
| 1394 | - <option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
| 1392 | + <option value=""><?php _e('— No Change —'); ?></option> |
|
| 1393 | + <option value="open"><?php _e('Allow'); ?></option> |
|
| 1394 | + <option value="closed"><?php _e('Do not allow'); ?></option> |
|
| 1395 | 1395 | </select> |
| 1396 | 1396 | </label> |
| 1397 | 1397 | <?php endif; ?> |
@@ -1400,15 +1400,15 @@ discard block |
||
| 1400 | 1400 | <?php else : // $bulk ?> |
| 1401 | 1401 | |
| 1402 | 1402 | <div class="inline-edit-group"> |
| 1403 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
| 1403 | + <?php if (post_type_supports($screen->post_type, 'comments')) : ?> |
|
| 1404 | 1404 | <label class="alignleft"> |
| 1405 | 1405 | <input type="checkbox" name="comment_status" value="open" /> |
| 1406 | - <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
| 1406 | + <span class="checkbox-title"><?php _e('Allow Comments'); ?></span> |
|
| 1407 | 1407 | </label> |
| 1408 | - <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
| 1408 | + <?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?> |
|
| 1409 | 1409 | <label class="alignleft"> |
| 1410 | 1410 | <input type="checkbox" name="ping_status" value="open" /> |
| 1411 | - <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> |
|
| 1411 | + <span class="checkbox-title"><?php _e('Allow Pings'); ?></span> |
|
| 1412 | 1412 | </label> |
| 1413 | 1413 | <?php endif; ?> |
| 1414 | 1414 | </div> |
@@ -1418,33 +1418,33 @@ discard block |
||
| 1418 | 1418 | |
| 1419 | 1419 | <div class="inline-edit-group"> |
| 1420 | 1420 | <label class="inline-edit-status alignleft"> |
| 1421 | - <span class="title"><?php _e( 'Status' ); ?></span> |
|
| 1421 | + <span class="title"><?php _e('Status'); ?></span> |
|
| 1422 | 1422 | <select name="_status"> |
| 1423 | - <?php if ( $bulk ) : ?> |
|
| 1424 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1423 | + <?php if ($bulk) : ?> |
|
| 1424 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1425 | 1425 | <?php endif; // $bulk ?> |
| 1426 | - <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?> |
|
| 1427 | - <option value="publish"><?php _e( 'Published' ); ?></option> |
|
| 1428 | - <option value="future"><?php _e( 'Scheduled' ); ?></option> |
|
| 1429 | - <?php if ( $bulk ) : ?> |
|
| 1430 | - <option value="private"><?php _e( 'Private' ) ?></option> |
|
| 1426 | + <?php if ($can_publish) : // Contributors only get "Unpublished" and "Pending Review" ?> |
|
| 1427 | + <option value="publish"><?php _e('Published'); ?></option> |
|
| 1428 | + <option value="future"><?php _e('Scheduled'); ?></option> |
|
| 1429 | + <?php if ($bulk) : ?> |
|
| 1430 | + <option value="private"><?php _e('Private') ?></option> |
|
| 1431 | 1431 | <?php endif; // $bulk ?> |
| 1432 | 1432 | <?php endif; ?> |
| 1433 | - <option value="pending"><?php _e( 'Pending Review' ); ?></option> |
|
| 1434 | - <option value="draft"><?php _e( 'Draft' ); ?></option> |
|
| 1433 | + <option value="pending"><?php _e('Pending Review'); ?></option> |
|
| 1434 | + <option value="draft"><?php _e('Draft'); ?></option> |
|
| 1435 | 1435 | </select> |
| 1436 | 1436 | </label> |
| 1437 | 1437 | |
| 1438 | - <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> |
|
| 1438 | + <?php if ('post' == $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) : ?> |
|
| 1439 | 1439 | |
| 1440 | - <?php if ( $bulk ) : ?> |
|
| 1440 | + <?php if ($bulk) : ?> |
|
| 1441 | 1441 | |
| 1442 | 1442 | <label class="alignright"> |
| 1443 | - <span class="title"><?php _e( 'Sticky' ); ?></span> |
|
| 1443 | + <span class="title"><?php _e('Sticky'); ?></span> |
|
| 1444 | 1444 | <select name="sticky"> |
| 1445 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1446 | - <option value="sticky"><?php _e( 'Sticky' ); ?></option> |
|
| 1447 | - <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> |
|
| 1445 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1446 | + <option value="sticky"><?php _e('Sticky'); ?></option> |
|
| 1447 | + <option value="unsticky"><?php _e('Not Sticky'); ?></option> |
|
| 1448 | 1448 | </select> |
| 1449 | 1449 | </label> |
| 1450 | 1450 | |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | |
| 1453 | 1453 | <label class="alignleft"> |
| 1454 | 1454 | <input type="checkbox" name="sticky" value="sticky" /> |
| 1455 | - <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
| 1455 | + <span class="checkbox-title"><?php _e('Make this post sticky'); ?></span> |
|
| 1456 | 1456 | </label> |
| 1457 | 1457 | |
| 1458 | 1458 | <?php endif; // $bulk ?> |
@@ -1463,20 +1463,20 @@ discard block |
||
| 1463 | 1463 | |
| 1464 | 1464 | <?php |
| 1465 | 1465 | |
| 1466 | - if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) { |
|
| 1467 | - $post_formats = get_theme_support( 'post-formats' ); |
|
| 1466 | + if ($bulk && current_theme_supports('post-formats') && post_type_supports($screen->post_type, 'post-formats')) { |
|
| 1467 | + $post_formats = get_theme_support('post-formats'); |
|
| 1468 | 1468 | |
| 1469 | 1469 | ?> |
| 1470 | 1470 | <label class="alignleft"> |
| 1471 | - <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> |
|
| 1471 | + <span class="title"><?php _ex('Format', 'post format'); ?></span> |
|
| 1472 | 1472 | <select name="post_format"> |
| 1473 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1474 | - <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
|
| 1473 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1474 | + <option value="0"><?php echo get_post_format_string('standard'); ?></option> |
|
| 1475 | 1475 | <?php |
| 1476 | - if ( is_array( $post_formats[0] ) ) { |
|
| 1477 | - foreach ( $post_formats[0] as $format ) { |
|
| 1476 | + if (is_array($post_formats[0])) { |
|
| 1477 | + foreach ($post_formats[0] as $format) { |
|
| 1478 | 1478 | ?> |
| 1479 | - <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> |
|
| 1479 | + <option value="<?php echo esc_attr($format); ?>"><?php echo esc_html(get_post_format_string($format)); ?></option> |
|
| 1480 | 1480 | <?php |
| 1481 | 1481 | } |
| 1482 | 1482 | } |
@@ -1491,13 +1491,13 @@ discard block |
||
| 1491 | 1491 | </div></fieldset> |
| 1492 | 1492 | |
| 1493 | 1493 | <?php |
| 1494 | - list( $columns ) = $this->get_column_info(); |
|
| 1494 | + list($columns) = $this->get_column_info(); |
|
| 1495 | 1495 | |
| 1496 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
| 1497 | - if ( isset( $core_columns[$column_name] ) ) |
|
| 1496 | + foreach ($columns as $column_name => $column_display_name) { |
|
| 1497 | + if (isset($core_columns[$column_name])) |
|
| 1498 | 1498 | continue; |
| 1499 | 1499 | |
| 1500 | - if ( $bulk ) { |
|
| 1500 | + if ($bulk) { |
|
| 1501 | 1501 | |
| 1502 | 1502 | /** |
| 1503 | 1503 | * Fires once for each column in Bulk Edit mode. |
@@ -1507,7 +1507,7 @@ discard block |
||
| 1507 | 1507 | * @param string $column_name Name of the column to edit. |
| 1508 | 1508 | * @param WP_Post $post_type The post type slug. |
| 1509 | 1509 | */ |
| 1510 | - do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); |
|
| 1510 | + do_action('bulk_edit_custom_box', $column_name, $screen->post_type); |
|
| 1511 | 1511 | } else { |
| 1512 | 1512 | |
| 1513 | 1513 | /** |
@@ -1518,25 +1518,25 @@ discard block |
||
| 1518 | 1518 | * @param string $column_name Name of the column to edit. |
| 1519 | 1519 | * @param string $post_type The post type slug. |
| 1520 | 1520 | */ |
| 1521 | - do_action( 'quick_edit_custom_box', $column_name, $screen->post_type ); |
|
| 1521 | + do_action('quick_edit_custom_box', $column_name, $screen->post_type); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | } |
| 1525 | 1525 | ?> |
| 1526 | 1526 | <p class="submit inline-edit-save"> |
| 1527 | - <button type="button" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></button> |
|
| 1528 | - <?php if ( ! $bulk ) { |
|
| 1529 | - wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); |
|
| 1527 | + <button type="button" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></button> |
|
| 1528 | + <?php if ( ! $bulk) { |
|
| 1529 | + wp_nonce_field('inlineeditnonce', '_inline_edit', false); |
|
| 1530 | 1530 | ?> |
| 1531 | - <button type="button" class="button-primary save alignright"><?php _e( 'Update' ); ?></button> |
|
| 1531 | + <button type="button" class="button-primary save alignright"><?php _e('Update'); ?></button> |
|
| 1532 | 1532 | <span class="spinner"></span> |
| 1533 | 1533 | <?php } else { |
| 1534 | - submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false ); |
|
| 1534 | + submit_button(__('Update'), 'button-primary alignright', 'bulk_edit', false); |
|
| 1535 | 1535 | } ?> |
| 1536 | - <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
|
| 1537 | - <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
|
| 1538 | - <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?> |
|
| 1539 | - <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
|
| 1536 | + <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" /> |
|
| 1537 | + <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" /> |
|
| 1538 | + <?php if ( ! $bulk && ! post_type_supports($screen->post_type, 'author')) { ?> |
|
| 1539 | + <input type="hidden" name="post_author" value="<?php echo esc_attr($post->post_author); ?>" /> |
|
| 1540 | 1540 | <?php } ?> |
| 1541 | 1541 | <span class="error" style="display:none"></span> |
| 1542 | 1542 | <br class="clear" /> |
@@ -88,8 +88,9 @@ discard block |
||
| 88 | 88 | AND post_author = %d |
| 89 | 89 | ", $post_type, get_current_user_id() ) ); |
| 90 | 90 | |
| 91 | - if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) |
|
| 92 | - $_GET['author'] = get_current_user_id(); |
|
| 91 | + if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) { |
|
| 92 | + $_GET['author'] = get_current_user_id(); |
|
| 93 | + } |
|
| 93 | 94 | } |
| 94 | 95 | |
| 95 | 96 | if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { |
@@ -139,10 +140,11 @@ discard block |
||
| 139 | 140 | /** This filter is documented in wp-admin/includes/post.php */ |
| 140 | 141 | $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
| 141 | 142 | |
| 142 | - if ( $this->hierarchical_display ) |
|
| 143 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 144 | - else |
|
| 145 | - $total_pages = $wp_query->max_num_pages; |
|
| 143 | + if ( $this->hierarchical_display ) { |
|
| 144 | + $total_pages = ceil( $total_items / $per_page ); |
|
| 145 | + } else { |
|
| 146 | + $total_pages = $wp_query->max_num_pages; |
|
| 147 | + } |
|
| 146 | 148 | |
| 147 | 149 | if ( ! empty( $_REQUEST['mode'] ) ) { |
| 148 | 150 | $mode = $_REQUEST['mode'] == 'excerpt' ? 'excerpt' : 'list'; |
@@ -172,10 +174,11 @@ discard block |
||
| 172 | 174 | * @access public |
| 173 | 175 | */ |
| 174 | 176 | public function no_items() { |
| 175 | - if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) |
|
| 176 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
|
| 177 | - else |
|
| 178 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
|
| 177 | + if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) { |
|
| 178 | + echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
|
| 179 | + } else { |
|
| 180 | + echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
|
| 181 | + } |
|
| 179 | 182 | } |
| 180 | 183 | |
| 181 | 184 | /** |
@@ -204,8 +207,9 @@ discard block |
||
| 204 | 207 | |
| 205 | 208 | $post_type = $this->screen->post_type; |
| 206 | 209 | |
| 207 | - if ( !empty($locked_post_status) ) |
|
| 208 | - return array(); |
|
| 210 | + if ( !empty($locked_post_status) ) { |
|
| 211 | + return array(); |
|
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | $status_links = array(); |
| 211 | 215 | $num_posts = wp_count_posts( $post_type, 'readable' ); |
@@ -215,8 +219,9 @@ discard block |
||
| 215 | 219 | $current_user_id = get_current_user_id(); |
| 216 | 220 | |
| 217 | 221 | if ( $this->user_posts_count ) { |
| 218 | - if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) |
|
| 219 | - $class = ' class="current"'; |
|
| 222 | + if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) { |
|
| 223 | + $class = ' class="current"'; |
|
| 224 | + } |
|
| 220 | 225 | $status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>'; |
| 221 | 226 | $allposts = '&all_posts=1'; |
| 222 | 227 | $class = ''; |
@@ -225,8 +230,9 @@ discard block |
||
| 225 | 230 | $total_posts = array_sum( (array) $num_posts ); |
| 226 | 231 | |
| 227 | 232 | // Subtract post types that are not included in the admin all list. |
| 228 | - foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) |
|
| 229 | - $total_posts -= $num_posts->$state; |
|
| 233 | + foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) { |
|
| 234 | + $total_posts -= $num_posts->$state; |
|
| 235 | + } |
|
| 230 | 236 | |
| 231 | 237 | if ( empty( $class ) && ( ( $this->is_base_request() && ! $this->user_posts_count ) || isset( $_REQUEST['all_posts'] ) ) ) { |
| 232 | 238 | $class = ' class="current"'; |
@@ -249,14 +255,17 @@ discard block |
||
| 249 | 255 | |
| 250 | 256 | $status_name = $status->name; |
| 251 | 257 | |
| 252 | - if ( !in_array( $status_name, $avail_post_stati ) ) |
|
| 253 | - continue; |
|
| 258 | + if ( !in_array( $status_name, $avail_post_stati ) ) { |
|
| 259 | + continue; |
|
| 260 | + } |
|
| 254 | 261 | |
| 255 | - if ( empty( $num_posts->$status_name ) ) |
|
| 256 | - continue; |
|
| 262 | + if ( empty( $num_posts->$status_name ) ) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 257 | 265 | |
| 258 | - if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] ) |
|
| 259 | - $class = ' class="current"'; |
|
| 266 | + if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] ) { |
|
| 267 | + $class = ' class="current"'; |
|
| 268 | + } |
|
| 260 | 269 | |
| 261 | 270 | $status_links[$status_name] = "<a href='edit.php?post_status=$status_name&post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>'; |
| 262 | 271 | } |
@@ -354,8 +363,9 @@ discard block |
||
| 354 | 363 | * @return string |
| 355 | 364 | */ |
| 356 | 365 | public function current_action() { |
| 357 | - if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
|
| 358 | - return 'delete_all'; |
|
| 366 | + if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { |
|
| 367 | + return 'delete_all'; |
|
| 368 | + } |
|
| 359 | 369 | |
| 360 | 370 | return parent::current_action(); |
| 361 | 371 | } |
@@ -369,8 +379,9 @@ discard block |
||
| 369 | 379 | |
| 370 | 380 | parent::pagination( $which ); |
| 371 | 381 | |
| 372 | - if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) ) |
|
| 373 | - $this->view_switcher( $mode ); |
|
| 382 | + if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) ) { |
|
| 383 | + $this->view_switcher( $mode ); |
|
| 384 | + } |
|
| 374 | 385 | } |
| 375 | 386 | |
| 376 | 387 | /** |
@@ -417,19 +428,21 @@ discard block |
||
| 417 | 428 | $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
| 418 | 429 | |
| 419 | 430 | foreach ( $taxonomies as $taxonomy ) { |
| 420 | - if ( 'category' == $taxonomy ) |
|
| 421 | - $column_key = 'categories'; |
|
| 422 | - elseif ( 'post_tag' == $taxonomy ) |
|
| 423 | - $column_key = 'tags'; |
|
| 424 | - else |
|
| 425 | - $column_key = 'taxonomy-' . $taxonomy; |
|
| 431 | + if ( 'category' == $taxonomy ) { |
|
| 432 | + $column_key = 'categories'; |
|
| 433 | + } elseif ( 'post_tag' == $taxonomy ) { |
|
| 434 | + $column_key = 'tags'; |
|
| 435 | + } else { |
|
| 436 | + $column_key = 'taxonomy-' . $taxonomy; |
|
| 437 | + } |
|
| 426 | 438 | |
| 427 | 439 | $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
| 428 | 440 | } |
| 429 | 441 | |
| 430 | 442 | $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
| 431 | - if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
|
| 432 | - $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
| 443 | + if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) { |
|
| 444 | + $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
| 445 | + } |
|
| 433 | 446 | |
| 434 | 447 | $posts_columns['date'] = __( 'Date' ); |
| 435 | 448 | |
@@ -490,8 +503,9 @@ discard block |
||
| 490 | 503 | public function display_rows( $posts = array(), $level = 0 ) { |
| 491 | 504 | global $wp_query, $per_page; |
| 492 | 505 | |
| 493 | - if ( empty( $posts ) ) |
|
| 494 | - $posts = $wp_query->posts; |
|
| 506 | + if ( empty( $posts ) ) { |
|
| 507 | + $posts = $wp_query->posts; |
|
| 508 | + } |
|
| 495 | 509 | |
| 496 | 510 | add_filter( 'the_title', 'esc_html' ); |
| 497 | 511 | |
@@ -513,13 +527,15 @@ discard block |
||
| 513 | 527 | // Create array of post IDs. |
| 514 | 528 | $post_ids = array(); |
| 515 | 529 | |
| 516 | - foreach ( $posts as $a_post ) |
|
| 517 | - $post_ids[] = $a_post->ID; |
|
| 530 | + foreach ( $posts as $a_post ) { |
|
| 531 | + $post_ids[] = $a_post->ID; |
|
| 532 | + } |
|
| 518 | 533 | |
| 519 | 534 | $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
| 520 | 535 | |
| 521 | - foreach ( $posts as $post ) |
|
| 522 | - $this->single_row( $post, $level ); |
|
| 536 | + foreach ( $posts as $post ) { |
|
| 537 | + $this->single_row( $post, $level ); |
|
| 538 | + } |
|
| 523 | 539 | } |
| 524 | 540 | |
| 525 | 541 | /** |
@@ -537,8 +553,9 @@ discard block |
||
| 537 | 553 | if ( ! $pages ) { |
| 538 | 554 | $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
| 539 | 555 | |
| 540 | - if ( ! $pages ) |
|
| 541 | - return; |
|
| 556 | + if ( ! $pages ) { |
|
| 557 | + return; |
|
| 558 | + } |
|
| 542 | 559 | } |
| 543 | 560 | |
| 544 | 561 | /* |
@@ -562,10 +579,11 @@ discard block |
||
| 562 | 579 | clean_post_cache( $page ); |
| 563 | 580 | } |
| 564 | 581 | |
| 565 | - if ( 0 == $page->post_parent ) |
|
| 566 | - $top_level_pages[] = $page; |
|
| 567 | - else |
|
| 568 | - $children_pages[ $page->post_parent ][] = $page; |
|
| 582 | + if ( 0 == $page->post_parent ) { |
|
| 583 | + $top_level_pages[] = $page; |
|
| 584 | + } else { |
|
| 585 | + $children_pages[ $page->post_parent ][] = $page; |
|
| 586 | + } |
|
| 569 | 587 | } |
| 570 | 588 | |
| 571 | 589 | $pages = &$top_level_pages; |
@@ -577,8 +595,9 @@ discard block |
||
| 577 | 595 | $to_display = array(); |
| 578 | 596 | |
| 579 | 597 | foreach ( $pages as $page ) { |
| 580 | - if ( $count >= $end ) |
|
| 581 | - break; |
|
| 598 | + if ( $count >= $end ) { |
|
| 599 | + break; |
|
| 600 | + } |
|
| 582 | 601 | |
| 583 | 602 | if ( $count >= $start ) { |
| 584 | 603 | $to_display[$page->ID] = $level; |
@@ -586,16 +605,18 @@ discard block |
||
| 586 | 605 | |
| 587 | 606 | $count++; |
| 588 | 607 | |
| 589 | - if ( isset( $children_pages ) ) |
|
| 590 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 608 | + if ( isset( $children_pages ) ) { |
|
| 609 | + $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 610 | + } |
|
| 591 | 611 | } |
| 592 | 612 | |
| 593 | 613 | // If it is the last pagenum and there are orphaned pages, display them with paging as well. |
| 594 | 614 | if ( isset( $children_pages ) && $count < $end ){ |
| 595 | 615 | foreach ( $children_pages as $orphans ){ |
| 596 | 616 | foreach ( $orphans as $op ) { |
| 597 | - if ( $count >= $end ) |
|
| 598 | - break; |
|
| 617 | + if ( $count >= $end ) { |
|
| 618 | + break; |
|
| 619 | + } |
|
| 599 | 620 | |
| 600 | 621 | if ( $count >= $start ) { |
| 601 | 622 | $to_display[$op->ID] = 0; |
@@ -635,15 +656,17 @@ discard block |
||
| 635 | 656 | * @param array $to_display List of pages to be displayed. Passed by reference. |
| 636 | 657 | */ |
| 637 | 658 | private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { |
| 638 | - if ( ! isset( $children_pages[$parent] ) ) |
|
| 639 | - return; |
|
| 659 | + if ( ! isset( $children_pages[$parent] ) ) { |
|
| 660 | + return; |
|
| 661 | + } |
|
| 640 | 662 | |
| 641 | 663 | $start = ( $pagenum - 1 ) * $per_page; |
| 642 | 664 | $end = $start + $per_page; |
| 643 | 665 | |
| 644 | 666 | foreach ( $children_pages[$parent] as $page ) { |
| 645 | - if ( $count >= $end ) |
|
| 646 | - break; |
|
| 667 | + if ( $count >= $end ) { |
|
| 668 | + break; |
|
| 669 | + } |
|
| 647 | 670 | |
| 648 | 671 | // If the page starts in a subtree, print the parents. |
| 649 | 672 | if ( $count == $start && $page->post_parent > 0 ) { |
@@ -658,8 +681,9 @@ discard block |
||
| 658 | 681 | |
| 659 | 682 | $my_parent = get_post( $parent_id ); |
| 660 | 683 | $my_parents[] = $my_parent; |
| 661 | - if ( !$my_parent->post_parent ) |
|
| 662 | - break; |
|
| 684 | + if ( !$my_parent->post_parent ) { |
|
| 685 | + break; |
|
| 686 | + } |
|
| 663 | 687 | $my_parent = $my_parent->post_parent; |
| 664 | 688 | } |
| 665 | 689 | $num_parents = count( $my_parents ); |
@@ -1064,12 +1088,14 @@ discard block |
||
| 1064 | 1088 | } |
| 1065 | 1089 | |
| 1066 | 1090 | if ( current_user_can( 'delete_post', $post->ID ) ) { |
| 1067 | - if ( 'trash' == $post->post_status ) |
|
| 1068 | - $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; |
|
| 1069 | - elseif ( EMPTY_TRASH_DAYS ) |
|
| 1070 | - $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
|
| 1071 | - if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) |
|
| 1072 | - $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
|
| 1091 | + if ( 'trash' == $post->post_status ) { |
|
| 1092 | + $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; |
|
| 1093 | + } elseif ( EMPTY_TRASH_DAYS ) { |
|
| 1094 | + $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
|
| 1095 | + } |
|
| 1096 | + if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) { |
|
| 1097 | + $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
|
| 1098 | + } |
|
| 1073 | 1099 | } |
| 1074 | 1100 | |
| 1075 | 1101 | if ( is_post_type_viewable( $post_type_object ) ) { |
@@ -1158,10 +1184,11 @@ discard block |
||
| 1158 | 1184 | continue; |
| 1159 | 1185 | } |
| 1160 | 1186 | |
| 1161 | - if ( $taxonomy->hierarchical ) |
|
| 1162 | - $hierarchical_taxonomies[] = $taxonomy; |
|
| 1163 | - else |
|
| 1164 | - $flat_taxonomies[] = $taxonomy; |
|
| 1187 | + if ( $taxonomy->hierarchical ) { |
|
| 1188 | + $hierarchical_taxonomies[] = $taxonomy; |
|
| 1189 | + } else { |
|
| 1190 | + $flat_taxonomies[] = $taxonomy; |
|
| 1191 | + } |
|
| 1165 | 1192 | } |
| 1166 | 1193 | |
| 1167 | 1194 | $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; |
@@ -1190,10 +1217,13 @@ discard block |
||
| 1190 | 1217 | <div id="bulk-titles"></div> |
| 1191 | 1218 | </div> |
| 1192 | 1219 | |
| 1193 | - <?php else : // $bulk ?> |
|
| 1220 | + <?php else { |
|
| 1221 | + : // $bulk ?> |
|
| 1194 | 1222 | |
| 1195 | 1223 | <label> |
| 1196 | - <span class="title"><?php _e( 'Title' ); ?></span> |
|
| 1224 | + <span class="title"><?php _e( 'Title' ); |
|
| 1225 | +} |
|
| 1226 | +?></span> |
|
| 1197 | 1227 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
| 1198 | 1228 | </label> |
| 1199 | 1229 | |
@@ -1225,8 +1255,9 @@ discard block |
||
| 1225 | 1255 | 'multi' => 1, |
| 1226 | 1256 | 'echo' => 0 |
| 1227 | 1257 | ); |
| 1228 | - if ( $bulk ) |
|
| 1229 | - $users_opt['show_option_none'] = __( '— No Change —' ); |
|
| 1258 | + if ( $bulk ) { |
|
| 1259 | + $users_opt['show_option_none'] = __( '— No Change —' ); |
|
| 1260 | + } |
|
| 1230 | 1261 | |
| 1231 | 1262 | if ( $authors = wp_dropdown_users( $users_opt ) ) : |
| 1232 | 1263 | $authors_dropdown = '<label class="inline-edit-author">'; |
@@ -1237,7 +1268,9 @@ discard block |
||
| 1237 | 1268 | endif; // authors |
| 1238 | 1269 | ?> |
| 1239 | 1270 | |
| 1240 | - <?php if ( !$bulk ) echo $authors_dropdown; |
|
| 1271 | + <?php if ( !$bulk ) { |
|
| 1272 | + echo $authors_dropdown; |
|
| 1273 | +} |
|
| 1241 | 1274 | endif; // post_type_supports author |
| 1242 | 1275 | |
| 1243 | 1276 | if ( !$bulk && $can_publish ) : |
@@ -1286,8 +1319,9 @@ discard block |
||
| 1286 | 1319 | <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> |
| 1287 | 1320 | |
| 1288 | 1321 | <?php |
| 1289 | - if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) |
|
| 1290 | - echo $authors_dropdown; |
|
| 1322 | + if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { |
|
| 1323 | + echo $authors_dropdown; |
|
| 1324 | + } |
|
| 1291 | 1325 | |
| 1292 | 1326 | if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : |
| 1293 | 1327 | |
@@ -1305,8 +1339,9 @@ discard block |
||
| 1305 | 1339 | 'sort_column' => 'menu_order, post_title', |
| 1306 | 1340 | ); |
| 1307 | 1341 | |
| 1308 | - if ( $bulk ) |
|
| 1309 | - $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
| 1342 | + if ( $bulk ) { |
|
| 1343 | + $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
| 1344 | + } |
|
| 1310 | 1345 | |
| 1311 | 1346 | /** |
| 1312 | 1347 | * Filter the arguments used to generate the Quick Edit page-parent drop-down. |
@@ -1397,13 +1432,16 @@ discard block |
||
| 1397 | 1432 | <?php endif; ?> |
| 1398 | 1433 | </div> |
| 1399 | 1434 | |
| 1400 | - <?php else : // $bulk ?> |
|
| 1435 | + <?php else { |
|
| 1436 | + : // $bulk ?> |
|
| 1401 | 1437 | |
| 1402 | 1438 | <div class="inline-edit-group"> |
| 1403 | 1439 | <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
| 1404 | 1440 | <label class="alignleft"> |
| 1405 | 1441 | <input type="checkbox" name="comment_status" value="open" /> |
| 1406 | - <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
| 1442 | + <span class="checkbox-title"><?php _e( 'Allow Comments' ); |
|
| 1443 | +} |
|
| 1444 | +?></span> |
|
| 1407 | 1445 | </label> |
| 1408 | 1446 | <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
| 1409 | 1447 | <label class="alignleft"> |
@@ -1448,11 +1486,14 @@ discard block |
||
| 1448 | 1486 | </select> |
| 1449 | 1487 | </label> |
| 1450 | 1488 | |
| 1451 | - <?php else : // $bulk ?> |
|
| 1489 | + <?php else { |
|
| 1490 | + : // $bulk ?> |
|
| 1452 | 1491 | |
| 1453 | 1492 | <label class="alignleft"> |
| 1454 | 1493 | <input type="checkbox" name="sticky" value="sticky" /> |
| 1455 | - <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
| 1494 | + <span class="checkbox-title"><?php _e( 'Make this post sticky' ); |
|
| 1495 | +} |
|
| 1496 | +?></span> |
|
| 1456 | 1497 | </label> |
| 1457 | 1498 | |
| 1458 | 1499 | <?php endif; // $bulk ?> |
@@ -1494,8 +1535,9 @@ discard block |
||
| 1494 | 1535 | list( $columns ) = $this->get_column_info(); |
| 1495 | 1536 | |
| 1496 | 1537 | foreach ( $columns as $column_name => $column_display_name ) { |
| 1497 | - if ( isset( $core_columns[$column_name] ) ) |
|
| 1498 | - continue; |
|
| 1538 | + if ( isset( $core_columns[$column_name] ) ) { |
|
| 1539 | + continue; |
|
| 1540 | + } |
|
| 1499 | 1541 | |
| 1500 | 1542 | if ( $bulk ) { |
| 1501 | 1543 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param bool $error |
| 60 | 60 | * @param string $context |
| 61 | 61 | * @param bool $allow_relaxed_file_ownership |
| 62 | - * @return type |
|
| 62 | + * @return boolean |
|
| 63 | 63 | */ |
| 64 | 64 | public function request_filesystem_credentials( $error = false, $context = false, $allow_relaxed_file_ownership = false ) { |
| 65 | 65 | $url = $this->options['url']; |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | /** |
| 888 | - * @param string|array|WP_Error $data |
|
| 888 | + * @param string $data |
|
| 889 | 889 | */ |
| 890 | 890 | public function feedback( $data ) { |
| 891 | 891 | if ( is_wp_error( $data ) ) { |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * The User Interface "Skins" for the WordPress File Upgrader |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Upgrader |
|
| 7 | - * @since 2.8.0 |
|
| 8 | - */ |
|
| 3 | + * The User Interface "Skins" for the WordPress File Upgrader |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Upgrader |
|
| 7 | + * @since 2.8.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes. |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @param array $args |
| 28 | 28 | */ |
| 29 | 29 | public function __construct($args = array()) { |
| 30 | - $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); |
|
| 30 | + $defaults = array('url' => '', 'nonce' => '', 'title' => '', 'context' => false); |
|
| 31 | 31 | $this->options = wp_parse_args($args, $defaults); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | * @param WP_Upgrader $upgrader |
| 36 | 36 | */ |
| 37 | 37 | public function set_upgrader(&$upgrader) { |
| 38 | - if ( is_object($upgrader) ) |
|
| 39 | - $this->upgrader =& $upgrader; |
|
| 38 | + if (is_object($upgrader)) |
|
| 39 | + $this->upgrader = & $upgrader; |
|
| 40 | 40 | $this->add_strings(); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -61,37 +61,37 @@ discard block |
||
| 61 | 61 | * @param bool $allow_relaxed_file_ownership |
| 62 | 62 | * @return type |
| 63 | 63 | */ |
| 64 | - public function request_filesystem_credentials( $error = false, $context = false, $allow_relaxed_file_ownership = false ) { |
|
| 64 | + public function request_filesystem_credentials($error = false, $context = false, $allow_relaxed_file_ownership = false) { |
|
| 65 | 65 | $url = $this->options['url']; |
| 66 | - if ( ! $context ) { |
|
| 66 | + if ( ! $context) { |
|
| 67 | 67 | $context = $this->options['context']; |
| 68 | 68 | } |
| 69 | - if ( !empty($this->options['nonce']) ) { |
|
| 69 | + if ( ! empty($this->options['nonce'])) { |
|
| 70 | 70 | $url = wp_nonce_url($url, $this->options['nonce']); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $extra_fields = array(); |
| 74 | 74 | |
| 75 | - return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership ); |
|
| 75 | + return request_filesystem_credentials($url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @access public |
| 80 | 80 | */ |
| 81 | 81 | public function header() { |
| 82 | - if ( $this->done_header ) { |
|
| 82 | + if ($this->done_header) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | $this->done_header = true; |
| 86 | 86 | echo '<div class="wrap">'; |
| 87 | - echo '<h1>' . $this->options['title'] . '</h1>'; |
|
| 87 | + echo '<h1>'.$this->options['title'].'</h1>'; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @access public |
| 92 | 92 | */ |
| 93 | 93 | public function footer() { |
| 94 | - if ( $this->done_footer ) { |
|
| 94 | + if ($this->done_footer) { |
|
| 95 | 95 | return; |
| 96 | 96 | } |
| 97 | 97 | $this->done_footer = true; |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | * @param string|WP_Error $errors |
| 104 | 104 | */ |
| 105 | 105 | public function error($errors) { |
| 106 | - if ( ! $this->done_header ) |
|
| 106 | + if ( ! $this->done_header) |
|
| 107 | 107 | $this->header(); |
| 108 | - if ( is_string($errors) ) { |
|
| 108 | + if (is_string($errors)) { |
|
| 109 | 109 | $this->feedback($errors); |
| 110 | - } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { |
|
| 111 | - foreach ( $errors->get_error_messages() as $message ) { |
|
| 112 | - if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) |
|
| 113 | - $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); |
|
| 110 | + } elseif (is_wp_error($errors) && $errors->get_error_code()) { |
|
| 111 | + foreach ($errors->get_error_messages() as $message) { |
|
| 112 | + if ($errors->get_error_data() && is_string($errors->get_error_data())) |
|
| 113 | + $this->feedback($message.' '.esc_html(strip_tags($errors->get_error_data()))); |
|
| 114 | 114 | else |
| 115 | 115 | $this->feedback($message); |
| 116 | 116 | } |
@@ -122,19 +122,19 @@ discard block |
||
| 122 | 122 | * @param string $string |
| 123 | 123 | */ |
| 124 | 124 | public function feedback($string) { |
| 125 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
| 125 | + if (isset($this->upgrader->strings[$string])) |
|
| 126 | 126 | $string = $this->upgrader->strings[$string]; |
| 127 | 127 | |
| 128 | - if ( strpos($string, '%') !== false ) { |
|
| 128 | + if (strpos($string, '%') !== false) { |
|
| 129 | 129 | $args = func_get_args(); |
| 130 | 130 | $args = array_splice($args, 1); |
| 131 | - if ( $args ) { |
|
| 132 | - $args = array_map( 'strip_tags', $args ); |
|
| 133 | - $args = array_map( 'esc_html', $args ); |
|
| 131 | + if ($args) { |
|
| 132 | + $args = array_map('strip_tags', $args); |
|
| 133 | + $args = array_map('esc_html', $args); |
|
| 134 | 134 | $string = vsprintf($string, $args); |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | - if ( empty($string) ) |
|
| 137 | + if (empty($string)) |
|
| 138 | 138 | return; |
| 139 | 139 | show_message($string); |
| 140 | 140 | } |
@@ -157,22 +157,22 @@ discard block |
||
| 157 | 157 | * @param string $type Type of update count to decrement. Likely values include 'plugin', |
| 158 | 158 | * 'theme', 'translation', etc. |
| 159 | 159 | */ |
| 160 | - protected function decrement_update_count( $type ) { |
|
| 161 | - if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) { |
|
| 160 | + protected function decrement_update_count($type) { |
|
| 161 | + if ( ! $this->result || is_wp_error($this->result) || 'up_to_date' === $this->result) { |
|
| 162 | 162 | return; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( defined( 'IFRAME_REQUEST' ) ) { |
|
| 165 | + if (defined('IFRAME_REQUEST')) { |
|
| 166 | 166 | echo '<script type="text/javascript"> |
| 167 | 167 | if ( window.postMessage && JSON ) { |
| 168 | - window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname ); |
|
| 168 | + window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type.'" } ), window.location.protocol + "//" + window.location.hostname ); |
|
| 169 | 169 | } |
| 170 | 170 | </script>'; |
| 171 | 171 | } else { |
| 172 | 172 | echo '<script type="text/javascript"> |
| 173 | 173 | (function( wp ) { |
| 174 | 174 | if ( wp && wp.updates.decrementCount ) { |
| 175 | - wp.updates.decrementCount( "' . $type . '" ); |
|
| 175 | + wp.updates.decrementCount( "' . $type.'" ); |
|
| 176 | 176 | } |
| 177 | 177 | })( window.wp ); |
| 178 | 178 | </script>'; |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @param array $args |
| 208 | 208 | */ |
| 209 | - public function __construct( $args = array() ) { |
|
| 210 | - $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') ); |
|
| 209 | + public function __construct($args = array()) { |
|
| 210 | + $defaults = array('url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin')); |
|
| 211 | 211 | $args = wp_parse_args($args, $defaults); |
| 212 | 212 | |
| 213 | 213 | $this->plugin = $args['plugin']; |
| 214 | 214 | |
| 215 | - $this->plugin_active = is_plugin_active( $this->plugin ); |
|
| 216 | - $this->plugin_network_active = is_plugin_active_for_network( $this->plugin ); |
|
| 215 | + $this->plugin_active = is_plugin_active($this->plugin); |
|
| 216 | + $this->plugin_network_active = is_plugin_active_for_network($this->plugin); |
|
| 217 | 217 | |
| 218 | 218 | parent::__construct($args); |
| 219 | 219 | } |
@@ -223,18 +223,18 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function after() { |
| 225 | 225 | $this->plugin = $this->upgrader->plugin_info(); |
| 226 | - if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ |
|
| 227 | - echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) .'"></iframe>'; |
|
| 226 | + if ( ! empty($this->plugin) && ! is_wp_error($this->result) && $this->plugin_active) { |
|
| 227 | + echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="'.wp_nonce_url('update.php?action=activate-plugin&networkwide='.$this->plugin_network_active.'&plugin='.urlencode($this->plugin), 'activate-plugin_'.$this->plugin).'"></iframe>'; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $this->decrement_update_count( 'plugin' ); |
|
| 230 | + $this->decrement_update_count('plugin'); |
|
| 231 | 231 | |
| 232 | - $update_actions = array( |
|
| 233 | - 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>', |
|
| 234 | - 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>' |
|
| 232 | + $update_actions = array( |
|
| 233 | + 'activate_plugin' => '<a href="'.wp_nonce_url('plugins.php?action=activate&plugin='.urlencode($this->plugin), 'activate-plugin_'.$this->plugin).'" target="_parent">'.__('Activate Plugin').'</a>', |
|
| 234 | + 'plugins_page' => '<a href="'.self_admin_url('plugins.php').'" target="_parent">'.__('Return to Plugins page').'</a>' |
|
| 235 | 235 | ); |
| 236 | - if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) |
|
| 237 | - unset( $update_actions['activate_plugin'] ); |
|
| 236 | + if ($this->plugin_active || ! $this->result || is_wp_error($this->result) || ! current_user_can('activate_plugins')) |
|
| 237 | + unset($update_actions['activate_plugin']); |
|
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | 240 | * Filter the list of action links available following a single plugin update. |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | * @param array $update_actions Array of plugin action links. |
| 245 | 245 | * @param string $plugin Path to the plugin file. |
| 246 | 246 | */ |
| 247 | - $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin ); |
|
| 247 | + $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin); |
|
| 248 | 248 | |
| 249 | - if ( ! empty($update_actions) ) |
|
| 250 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 249 | + if ( ! empty($update_actions)) |
|
| 250 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param array $args |
| 271 | 271 | */ |
| 272 | 272 | public function __construct($args = array()) { |
| 273 | - $defaults = array( 'url' => '', 'nonce' => '' ); |
|
| 273 | + $defaults = array('url' => '', 'nonce' => ''); |
|
| 274 | 274 | $args = wp_parse_args($args, $defaults); |
| 275 | 275 | |
| 276 | 276 | parent::__construct($args); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.'); |
| 284 | 284 | $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>'); |
| 285 | 285 | $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.'); |
| 286 | - $this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details' ) . '</span><span class="hidden">' . __( 'Hide Details' ) . '</span></a>'; |
|
| 286 | + $this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>'.__('Show Details').'</span><span class="hidden">'.__('Hide Details').'</span></a>'; |
|
| 287 | 287 | $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.'); |
| 288 | 288 | } |
| 289 | 289 | |
@@ -291,21 +291,21 @@ discard block |
||
| 291 | 291 | * @param string $string |
| 292 | 292 | */ |
| 293 | 293 | public function feedback($string) { |
| 294 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
| 294 | + if (isset($this->upgrader->strings[$string])) |
|
| 295 | 295 | $string = $this->upgrader->strings[$string]; |
| 296 | 296 | |
| 297 | - if ( strpos($string, '%') !== false ) { |
|
| 297 | + if (strpos($string, '%') !== false) { |
|
| 298 | 298 | $args = func_get_args(); |
| 299 | 299 | $args = array_splice($args, 1); |
| 300 | - if ( $args ) { |
|
| 301 | - $args = array_map( 'strip_tags', $args ); |
|
| 302 | - $args = array_map( 'esc_html', $args ); |
|
| 300 | + if ($args) { |
|
| 301 | + $args = array_map('strip_tags', $args); |
|
| 302 | + $args = array_map('esc_html', $args); |
|
| 303 | 303 | $string = vsprintf($string, $args); |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | - if ( empty($string) ) |
|
| 306 | + if (empty($string)) |
|
| 307 | 307 | return; |
| 308 | - if ( $this->in_loop ) |
|
| 308 | + if ($this->in_loop) |
|
| 309 | 309 | echo "$string<br />\n"; |
| 310 | 310 | else |
| 311 | 311 | echo "<p>$string</p>\n"; |
@@ -330,20 +330,20 @@ discard block |
||
| 330 | 330 | * @param string|WP_Error $error |
| 331 | 331 | */ |
| 332 | 332 | public function error($error) { |
| 333 | - if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) |
|
| 333 | + if (is_string($error) && isset($this->upgrader->strings[$error])) |
|
| 334 | 334 | $this->error = $this->upgrader->strings[$error]; |
| 335 | 335 | |
| 336 | - if ( is_wp_error($error) ) { |
|
| 336 | + if (is_wp_error($error)) { |
|
| 337 | 337 | $messages = array(); |
| 338 | - foreach ( $error->get_error_messages() as $emessage ) { |
|
| 339 | - if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) |
|
| 340 | - $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); |
|
| 338 | + foreach ($error->get_error_messages() as $emessage) { |
|
| 339 | + if ($error->get_error_data() && is_string($error->get_error_data())) |
|
| 340 | + $messages[] = $emessage.' '.esc_html(strip_tags($error->get_error_data())); |
|
| 341 | 341 | else |
| 342 | 342 | $messages[] = $emessage; |
| 343 | 343 | } |
| 344 | 344 | $this->error = implode(', ', $messages); |
| 345 | 345 | } |
| 346 | - echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; |
|
| 346 | + echo '<script type="text/javascript">jQuery(\'.waiting-'.esc_js($this->upgrader->update_current).'\').hide();</script>'; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | public function before($title = '') { |
| 368 | 368 | $this->in_loop = true; |
| 369 | - printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count); |
|
| 370 | - echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>'; |
|
| 371 | - echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>'; |
|
| 369 | + printf('<h4>'.$this->upgrader->strings['skin_before_update_header'].' <span class="spinner waiting-'.$this->upgrader->update_current.'"></span></h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count); |
|
| 370 | + echo '<script type="text/javascript">jQuery(\'.waiting-'.esc_js($this->upgrader->update_current).'\').css("display", "inline-block");</script>'; |
|
| 371 | + echo '<div class="update-messages hide-if-js" id="progress-'.esc_attr($this->upgrader->update_current).'"><p>'; |
|
| 372 | 372 | $this->flush_output(); |
| 373 | 373 | } |
| 374 | 374 | |
@@ -378,18 +378,18 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | public function after($title = '') { |
| 380 | 380 | echo '</p></div>'; |
| 381 | - if ( $this->error || ! $this->result ) { |
|
| 382 | - if ( $this->error ) |
|
| 383 | - echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>'; |
|
| 381 | + if ($this->error || ! $this->result) { |
|
| 382 | + if ($this->error) |
|
| 383 | + echo '<div class="error"><p>'.sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error).'</p></div>'; |
|
| 384 | 384 | else |
| 385 | - echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>'; |
|
| 385 | + echo '<div class="error"><p>'.sprintf($this->upgrader->strings['skin_update_failed'], $title).'</p></div>'; |
|
| 386 | 386 | |
| 387 | - echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>'; |
|
| 387 | + echo '<script type="text/javascript">jQuery(\'#progress-'.esc_js($this->upgrader->update_current).'\').show();</script>'; |
|
| 388 | 388 | } |
| 389 | - if ( $this->result && ! is_wp_error( $this->result ) ) { |
|
| 390 | - if ( ! $this->error ) |
|
| 391 | - echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>'; |
|
| 392 | - echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; |
|
| 389 | + if ($this->result && ! is_wp_error($this->result)) { |
|
| 390 | + if ( ! $this->error) |
|
| 391 | + echo '<div class="updated"><p>'.sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-'.esc_js($this->upgrader->update_current).'\').toggle();jQuery(\'span\', this).toggle(); return false;').'</p></div>'; |
|
| 392 | + echo '<script type="text/javascript">jQuery(\'.waiting-'.esc_js($this->upgrader->update_current).'\').hide();</script>'; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $this->reset(); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | */ |
| 436 | 436 | public function after($title = '') { |
| 437 | 437 | parent::after($this->plugin_info['Title']); |
| 438 | - $this->decrement_update_count( 'plugin' ); |
|
| 438 | + $this->decrement_update_count('plugin'); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -443,12 +443,12 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public function bulk_footer() { |
| 445 | 445 | parent::bulk_footer(); |
| 446 | - $update_actions = array( |
|
| 447 | - 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>', |
|
| 448 | - 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>' |
|
| 446 | + $update_actions = array( |
|
| 447 | + 'plugins_page' => '<a href="'.self_admin_url('plugins.php').'" target="_parent">'.__('Return to Plugins page').'</a>', |
|
| 448 | + 'updates_page' => '<a href="'.self_admin_url('update-core.php').'" target="_parent">'.__('Return to WordPress Updates page').'</a>' |
|
| 449 | 449 | ); |
| 450 | - if ( ! current_user_can( 'activate_plugins' ) ) |
|
| 451 | - unset( $update_actions['plugins_page'] ); |
|
| 450 | + if ( ! current_user_can('activate_plugins')) |
|
| 451 | + unset($update_actions['plugins_page']); |
|
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | 454 | * Filter the list of action links available following bulk plugin updates. |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | * @param array $update_actions Array of plugin action links. |
| 459 | 459 | * @param array $plugin_info Array of information for the last-updated plugin. |
| 460 | 460 | */ |
| 461 | - $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
|
| 461 | + $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info); |
|
| 462 | 462 | |
| 463 | - if ( ! empty($update_actions) ) |
|
| 464 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 463 | + if ( ! empty($update_actions)) |
|
| 464 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param string $title |
| 479 | 479 | */ |
| 480 | 480 | public function before($title = '') { |
| 481 | - parent::before( $this->theme_info->display('Name') ); |
|
| 481 | + parent::before($this->theme_info->display('Name')); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -486,8 +486,8 @@ discard block |
||
| 486 | 486 | * @param string $title |
| 487 | 487 | */ |
| 488 | 488 | public function after($title = '') { |
| 489 | - parent::after( $this->theme_info->display('Name') ); |
|
| 490 | - $this->decrement_update_count( 'theme' ); |
|
| 489 | + parent::after($this->theme_info->display('Name')); |
|
| 490 | + $this->decrement_update_count('theme'); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | public function bulk_footer() { |
| 497 | 497 | parent::bulk_footer(); |
| 498 | - $update_actions = array( |
|
| 499 | - 'themes_page' => '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>', |
|
| 500 | - 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>' |
|
| 498 | + $update_actions = array( |
|
| 499 | + 'themes_page' => '<a href="'.self_admin_url('themes.php').'" target="_parent">'.__('Return to Themes page').'</a>', |
|
| 500 | + 'updates_page' => '<a href="'.self_admin_url('update-core.php').'" target="_parent">'.__('Return to WordPress Updates page').'</a>' |
|
| 501 | 501 | ); |
| 502 | - if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) |
|
| 503 | - unset( $update_actions['themes_page'] ); |
|
| 502 | + if ( ! current_user_can('switch_themes') && ! current_user_can('edit_theme_options')) |
|
| 503 | + unset($update_actions['themes_page']); |
|
| 504 | 504 | |
| 505 | 505 | /** |
| 506 | 506 | * Filter the list of action links available following bulk theme updates. |
@@ -510,10 +510,10 @@ discard block |
||
| 510 | 510 | * @param array $update_actions Array of theme action links. |
| 511 | 511 | * @param array $theme_info Array of information for the last-updated theme. |
| 512 | 512 | */ |
| 513 | - $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info ); |
|
| 513 | + $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info); |
|
| 514 | 514 | |
| 515 | - if ( ! empty($update_actions) ) |
|
| 516 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 515 | + if ( ! empty($update_actions)) |
|
| 516 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @param array $args |
| 534 | 534 | */ |
| 535 | 535 | public function __construct($args = array()) { |
| 536 | - $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' ); |
|
| 536 | + $defaults = array('type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => ''); |
|
| 537 | 537 | $args = wp_parse_args($args, $defaults); |
| 538 | 538 | |
| 539 | 539 | $this->type = $args['type']; |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | * @access public |
| 547 | 547 | */ |
| 548 | 548 | public function before() { |
| 549 | - if ( !empty($this->api) ) |
|
| 550 | - $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version); |
|
| 549 | + if ( ! empty($this->api)) |
|
| 550 | + $this->upgrader->strings['process_success'] = sprintf(__('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -558,30 +558,30 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | $install_actions = array(); |
| 560 | 560 | |
| 561 | - $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins'; |
|
| 561 | + $from = isset($_GET['from']) ? wp_unslash($_GET['from']) : 'plugins'; |
|
| 562 | 562 | |
| 563 | - if ( 'import' == $from ) |
|
| 564 | - $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin & Run Importer' ) . '</a>'; |
|
| 563 | + if ('import' == $from) |
|
| 564 | + $install_actions['activate_plugin'] = '<a href="'.wp_nonce_url('plugins.php?action=activate&from=import&plugin='.urlencode($plugin_file), 'activate-plugin_'.$plugin_file).'" target="_parent">'.__('Activate Plugin & Run Importer').'</a>'; |
|
| 565 | 565 | else |
| 566 | - $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>'; |
|
| 566 | + $install_actions['activate_plugin'] = '<a href="'.wp_nonce_url('plugins.php?action=activate&plugin='.urlencode($plugin_file), 'activate-plugin_'.$plugin_file).'" target="_parent">'.__('Activate Plugin').'</a>'; |
|
| 567 | 567 | |
| 568 | - if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { |
|
| 569 | - $install_actions['network_activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&networkwide=1&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Network Activate' ) . '</a>'; |
|
| 570 | - unset( $install_actions['activate_plugin'] ); |
|
| 568 | + if (is_multisite() && current_user_can('manage_network_plugins')) { |
|
| 569 | + $install_actions['network_activate'] = '<a href="'.wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin='.urlencode($plugin_file), 'activate-plugin_'.$plugin_file).'" target="_parent">'.__('Network Activate').'</a>'; |
|
| 570 | + unset($install_actions['activate_plugin']); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - if ( 'import' == $from ) { |
|
| 574 | - $install_actions['importers_page'] = '<a href="' . admin_url( 'import.php' ) . '" target="_parent">' . __( 'Return to Importers' ) . '</a>'; |
|
| 575 | - } elseif ( $this->type == 'web' ) { |
|
| 576 | - $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugin-install.php' ) . '" target="_parent">' . __( 'Return to Plugin Installer' ) . '</a>'; |
|
| 573 | + if ('import' == $from) { |
|
| 574 | + $install_actions['importers_page'] = '<a href="'.admin_url('import.php').'" target="_parent">'.__('Return to Importers').'</a>'; |
|
| 575 | + } elseif ($this->type == 'web') { |
|
| 576 | + $install_actions['plugins_page'] = '<a href="'.self_admin_url('plugin-install.php').'" target="_parent">'.__('Return to Plugin Installer').'</a>'; |
|
| 577 | 577 | } else { |
| 578 | - $install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>'; |
|
| 578 | + $install_actions['plugins_page'] = '<a href="'.self_admin_url('plugins.php').'" target="_parent">'.__('Return to Plugins page').'</a>'; |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if ( ! $this->result || is_wp_error($this->result) ) { |
|
| 582 | - unset( $install_actions['activate_plugin'], $install_actions['network_activate'] ); |
|
| 583 | - } elseif ( ! current_user_can( 'activate_plugins' ) ) { |
|
| 584 | - unset( $install_actions['activate_plugin'] ); |
|
| 581 | + if ( ! $this->result || is_wp_error($this->result)) { |
|
| 582 | + unset($install_actions['activate_plugin'], $install_actions['network_activate']); |
|
| 583 | + } elseif ( ! current_user_can('activate_plugins')) { |
|
| 584 | + unset($install_actions['activate_plugin']); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | /** |
@@ -595,10 +595,10 @@ discard block |
||
| 595 | 595 | * via upload. |
| 596 | 596 | * @param string $plugin_file Path to the plugin file. |
| 597 | 597 | */ |
| 598 | - $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file ); |
|
| 598 | + $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file); |
|
| 599 | 599 | |
| 600 | - if ( ! empty($install_actions) ) |
|
| 601 | - $this->feedback(implode(' | ', (array)$install_actions)); |
|
| 600 | + if ( ! empty($install_actions)) |
|
| 601 | + $this->feedback(implode(' | ', (array) $install_actions)); |
|
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | * @param array $args |
| 619 | 619 | */ |
| 620 | 620 | public function __construct($args = array()) { |
| 621 | - $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' ); |
|
| 621 | + $defaults = array('type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => ''); |
|
| 622 | 622 | $args = wp_parse_args($args, $defaults); |
| 623 | 623 | |
| 624 | 624 | $this->type = $args['type']; |
@@ -631,49 +631,49 @@ discard block |
||
| 631 | 631 | * @access public |
| 632 | 632 | */ |
| 633 | 633 | public function before() { |
| 634 | - if ( !empty($this->api) ) |
|
| 635 | - $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
| 634 | + if ( ! empty($this->api)) |
|
| 635 | + $this->upgrader->strings['process_success'] = sprintf($this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * @access public |
| 640 | 640 | */ |
| 641 | 641 | public function after() { |
| 642 | - if ( empty($this->upgrader->result['destination_name']) ) |
|
| 642 | + if (empty($this->upgrader->result['destination_name'])) |
|
| 643 | 643 | return; |
| 644 | 644 | |
| 645 | 645 | $theme_info = $this->upgrader->theme_info(); |
| 646 | - if ( empty( $theme_info ) ) |
|
| 646 | + if (empty($theme_info)) |
|
| 647 | 647 | return; |
| 648 | 648 | |
| 649 | 649 | $name = $theme_info->display('Name'); |
| 650 | 650 | $stylesheet = $this->upgrader->result['destination_name']; |
| 651 | 651 | $template = $theme_info->get_template(); |
| 652 | 652 | |
| 653 | - $activate_link = add_query_arg( array( |
|
| 653 | + $activate_link = add_query_arg(array( |
|
| 654 | 654 | 'action' => 'activate', |
| 655 | - 'template' => urlencode( $template ), |
|
| 656 | - 'stylesheet' => urlencode( $stylesheet ), |
|
| 657 | - ), admin_url('themes.php') ); |
|
| 658 | - $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
|
| 655 | + 'template' => urlencode($template), |
|
| 656 | + 'stylesheet' => urlencode($stylesheet), |
|
| 657 | + ), admin_url('themes.php')); |
|
| 658 | + $activate_link = wp_nonce_url($activate_link, 'switch-theme_'.$stylesheet); |
|
| 659 | 659 | |
| 660 | 660 | $install_actions = array(); |
| 661 | 661 | |
| 662 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
| 663 | - $install_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; |
|
| 662 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
| 663 | + $install_actions['preview'] = '<a href="'.wp_customize_url($stylesheet).'" class="hide-if-no-customize load-customize"><span aria-hidden="true">'.__('Live Preview').'</span><span class="screen-reader-text">'.sprintf(__('Live Preview “%s”'), $name).'</span></a>'; |
|
| 664 | 664 | } |
| 665 | - $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
|
| 665 | + $install_actions['activate'] = '<a href="'.esc_url($activate_link).'" class="activatelink"><span aria-hidden="true">'.__('Activate').'</span><span class="screen-reader-text">'.sprintf(__('Activate “%s”'), $name).'</span></a>'; |
|
| 666 | 666 | |
| 667 | - if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) |
|
| 668 | - $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
|
| 667 | + if (is_network_admin() && current_user_can('manage_network_themes')) |
|
| 668 | + $install_actions['network_enable'] = '<a href="'.esc_url(wp_nonce_url('themes.php?action=enable&theme='.urlencode($stylesheet), 'enable-theme_'.$stylesheet)).'" target="_parent">'.__('Network Enable').'</a>'; |
|
| 669 | 669 | |
| 670 | - if ( $this->type == 'web' ) |
|
| 671 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; |
|
| 672 | - elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) |
|
| 673 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
| 670 | + if ($this->type == 'web') |
|
| 671 | + $install_actions['themes_page'] = '<a href="'.self_admin_url('theme-install.php').'" target="_parent">'.__('Return to Theme Installer').'</a>'; |
|
| 672 | + elseif (current_user_can('switch_themes') || current_user_can('edit_theme_options')) |
|
| 673 | + $install_actions['themes_page'] = '<a href="'.self_admin_url('themes.php').'" target="_parent">'.__('Return to Themes page').'</a>'; |
|
| 674 | 674 | |
| 675 | - if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) |
|
| 676 | - unset( $install_actions['activate'], $install_actions['preview'] ); |
|
| 675 | + if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can('switch_themes')) |
|
| 676 | + unset($install_actions['activate'], $install_actions['preview']); |
|
| 677 | 677 | |
| 678 | 678 | /** |
| 679 | 679 | * Filter the list of action links available following a single theme installation. |
@@ -685,9 +685,9 @@ discard block |
||
| 685 | 685 | * @param string $stylesheet Theme directory name. |
| 686 | 686 | * @param WP_Theme $theme_info Theme object. |
| 687 | 687 | */ |
| 688 | - $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); |
|
| 689 | - if ( ! empty($install_actions) ) |
|
| 690 | - $this->feedback(implode(' | ', (array)$install_actions)); |
|
| 688 | + $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info); |
|
| 689 | + if ( ! empty($install_actions)) |
|
| 690 | + $this->feedback(implode(' | ', (array) $install_actions)); |
|
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | * @param array $args |
| 707 | 707 | */ |
| 708 | 708 | public function __construct($args = array()) { |
| 709 | - $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') ); |
|
| 709 | + $defaults = array('url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme')); |
|
| 710 | 710 | $args = wp_parse_args($args, $defaults); |
| 711 | 711 | |
| 712 | 712 | $this->theme = $args['theme']; |
@@ -718,37 +718,37 @@ discard block |
||
| 718 | 718 | * @access public |
| 719 | 719 | */ |
| 720 | 720 | public function after() { |
| 721 | - $this->decrement_update_count( 'theme' ); |
|
| 721 | + $this->decrement_update_count('theme'); |
|
| 722 | 722 | |
| 723 | 723 | $update_actions = array(); |
| 724 | - if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) { |
|
| 724 | + if ( ! empty($this->upgrader->result['destination_name']) && $theme_info = $this->upgrader->theme_info()) { |
|
| 725 | 725 | $name = $theme_info->display('Name'); |
| 726 | 726 | $stylesheet = $this->upgrader->result['destination_name']; |
| 727 | 727 | $template = $theme_info->get_template(); |
| 728 | 728 | |
| 729 | - $activate_link = add_query_arg( array( |
|
| 729 | + $activate_link = add_query_arg(array( |
|
| 730 | 730 | 'action' => 'activate', |
| 731 | - 'template' => urlencode( $template ), |
|
| 732 | - 'stylesheet' => urlencode( $stylesheet ), |
|
| 733 | - ), admin_url('themes.php') ); |
|
| 734 | - $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
|
| 735 | - |
|
| 736 | - if ( get_stylesheet() == $stylesheet ) { |
|
| 737 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
| 738 | - $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>'; |
|
| 731 | + 'template' => urlencode($template), |
|
| 732 | + 'stylesheet' => urlencode($stylesheet), |
|
| 733 | + ), admin_url('themes.php')); |
|
| 734 | + $activate_link = wp_nonce_url($activate_link, 'switch-theme_'.$stylesheet); |
|
| 735 | + |
|
| 736 | + if (get_stylesheet() == $stylesheet) { |
|
| 737 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
| 738 | + $update_actions['preview'] = '<a href="'.wp_customize_url($stylesheet).'" class="hide-if-no-customize load-customize"><span aria-hidden="true">'.__('Customize').'</span><span class="screen-reader-text">'.sprintf(__('Customize “%s”'), $name).'</span></a>'; |
|
| 739 | 739 | } |
| 740 | - } elseif ( current_user_can( 'switch_themes' ) ) { |
|
| 741 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
| 742 | - $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; |
|
| 740 | + } elseif (current_user_can('switch_themes')) { |
|
| 741 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
| 742 | + $update_actions['preview'] = '<a href="'.wp_customize_url($stylesheet).'" class="hide-if-no-customize load-customize"><span aria-hidden="true">'.__('Live Preview').'</span><span class="screen-reader-text">'.sprintf(__('Live Preview “%s”'), $name).'</span></a>'; |
|
| 743 | 743 | } |
| 744 | - $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
|
| 744 | + $update_actions['activate'] = '<a href="'.esc_url($activate_link).'" class="activatelink"><span aria-hidden="true">'.__('Activate').'</span><span class="screen-reader-text">'.sprintf(__('Activate “%s”'), $name).'</span></a>'; |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) |
|
| 748 | - unset( $update_actions['preview'], $update_actions['activate'] ); |
|
| 747 | + if ( ! $this->result || is_wp_error($this->result) || is_network_admin()) |
|
| 748 | + unset($update_actions['preview'], $update_actions['activate']); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
| 751 | + $update_actions['themes_page'] = '<a href="'.self_admin_url('themes.php').'" target="_parent">'.__('Return to Themes page').'</a>'; |
|
| 752 | 752 | |
| 753 | 753 | /** |
| 754 | 754 | * Filter the list of action links available following a single theme update. |
@@ -758,10 +758,10 @@ discard block |
||
| 758 | 758 | * @param array $update_actions Array of theme action links. |
| 759 | 759 | * @param string $theme Theme directory name. |
| 760 | 760 | */ |
| 761 | - $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); |
|
| 761 | + $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme); |
|
| 762 | 762 | |
| 763 | - if ( ! empty($update_actions) ) |
|
| 764 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 763 | + if ( ! empty($update_actions)) |
|
| 764 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | |
@@ -782,35 +782,35 @@ discard block |
||
| 782 | 782 | * |
| 783 | 783 | * @param array $args |
| 784 | 784 | */ |
| 785 | - public function __construct( $args = array() ) { |
|
| 786 | - $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false ); |
|
| 787 | - $args = wp_parse_args( $args, $defaults ); |
|
| 788 | - if ( $args['skip_header_footer'] ) { |
|
| 785 | + public function __construct($args = array()) { |
|
| 786 | + $defaults = array('url' => '', 'nonce' => '', 'title' => __('Update Translations'), 'skip_header_footer' => false); |
|
| 787 | + $args = wp_parse_args($args, $defaults); |
|
| 788 | + if ($args['skip_header_footer']) { |
|
| 789 | 789 | $this->done_header = true; |
| 790 | 790 | $this->done_footer = true; |
| 791 | 791 | $this->display_footer_actions = false; |
| 792 | 792 | } |
| 793 | - parent::__construct( $args ); |
|
| 793 | + parent::__construct($args); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /** |
| 797 | 797 | * @access public |
| 798 | 798 | */ |
| 799 | 799 | public function before() { |
| 800 | - $name = $this->upgrader->get_name_for_update( $this->language_update ); |
|
| 800 | + $name = $this->upgrader->get_name_for_update($this->language_update); |
|
| 801 | 801 | |
| 802 | 802 | echo '<div class="update-messages lp-show-latest">'; |
| 803 | 803 | |
| 804 | - printf( '<h4>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h4>', $name, $this->language_update->language ); |
|
| 804 | + printf('<h4>'.__('Updating translations for %1$s (%2$s)…').'</h4>', $name, $this->language_update->language); |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
| 808 | 808 | * |
| 809 | 809 | * @param string|WP_Error $error |
| 810 | 810 | */ |
| 811 | - public function error( $error ) { |
|
| 811 | + public function error($error) { |
|
| 812 | 812 | echo '<div class="lp-error">'; |
| 813 | - parent::error( $error ); |
|
| 813 | + parent::error($error); |
|
| 814 | 814 | echo '</div>'; |
| 815 | 815 | } |
| 816 | 816 | |
@@ -825,9 +825,9 @@ discard block |
||
| 825 | 825 | * @access public |
| 826 | 826 | */ |
| 827 | 827 | public function bulk_footer() { |
| 828 | - $this->decrement_update_count( 'translation' ); |
|
| 828 | + $this->decrement_update_count('translation'); |
|
| 829 | 829 | $update_actions = array(); |
| 830 | - $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'; |
|
| 830 | + $update_actions['updates_page'] = '<a href="'.self_admin_url('update-core.php').'" target="_parent">'.__('Return to WordPress Updates page').'</a>'; |
|
| 831 | 831 | |
| 832 | 832 | /** |
| 833 | 833 | * Filter the list of action links available following a translations update. |
@@ -836,10 +836,10 @@ discard block |
||
| 836 | 836 | * |
| 837 | 837 | * @param array $update_actions Array of translations update links. |
| 838 | 838 | */ |
| 839 | - $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions ); |
|
| 839 | + $update_actions = apply_filters('update_translations_complete_actions', $update_actions); |
|
| 840 | 840 | |
| 841 | - if ( $update_actions && $this->display_footer_actions ) |
|
| 842 | - $this->feedback( implode( ' | ', $update_actions ) ); |
|
| 841 | + if ($update_actions && $this->display_footer_actions) |
|
| 842 | + $this->feedback(implode(' | ', $update_actions)); |
|
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | |
@@ -863,14 +863,14 @@ discard block |
||
| 863 | 863 | * @param bool $allow_relaxed_file_ownership |
| 864 | 864 | * @return bool |
| 865 | 865 | */ |
| 866 | - public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { |
|
| 867 | - if ( $context ) { |
|
| 866 | + public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false) { |
|
| 867 | + if ($context) { |
|
| 868 | 868 | $this->options['context'] = $context; |
| 869 | 869 | } |
| 870 | 870 | // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version |
| 871 | 871 | // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer |
| 872 | 872 | ob_start(); |
| 873 | - $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership ); |
|
| 873 | + $result = parent::request_filesystem_credentials($error, $context, $allow_relaxed_file_ownership); |
|
| 874 | 874 | ob_end_clean(); |
| 875 | 875 | return $result; |
| 876 | 876 | } |
@@ -887,37 +887,37 @@ discard block |
||
| 887 | 887 | /** |
| 888 | 888 | * @param string|array|WP_Error $data |
| 889 | 889 | */ |
| 890 | - public function feedback( $data ) { |
|
| 891 | - if ( is_wp_error( $data ) ) { |
|
| 890 | + public function feedback($data) { |
|
| 891 | + if (is_wp_error($data)) { |
|
| 892 | 892 | $string = $data->get_error_message(); |
| 893 | - } elseif ( is_array( $data ) ) { |
|
| 893 | + } elseif (is_array($data)) { |
|
| 894 | 894 | return; |
| 895 | 895 | } else { |
| 896 | 896 | $string = $data; |
| 897 | 897 | } |
| 898 | - if ( ! empty( $this->upgrader->strings[ $string ] ) ) |
|
| 899 | - $string = $this->upgrader->strings[ $string ]; |
|
| 898 | + if ( ! empty($this->upgrader->strings[$string])) |
|
| 899 | + $string = $this->upgrader->strings[$string]; |
|
| 900 | 900 | |
| 901 | - if ( strpos( $string, '%' ) !== false ) { |
|
| 901 | + if (strpos($string, '%') !== false) { |
|
| 902 | 902 | $args = func_get_args(); |
| 903 | - $args = array_splice( $args, 1 ); |
|
| 904 | - if ( ! empty( $args ) ) |
|
| 905 | - $string = vsprintf( $string, $args ); |
|
| 903 | + $args = array_splice($args, 1); |
|
| 904 | + if ( ! empty($args)) |
|
| 905 | + $string = vsprintf($string, $args); |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - $string = trim( $string ); |
|
| 908 | + $string = trim($string); |
|
| 909 | 909 | |
| 910 | 910 | // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output. |
| 911 | - $string = wp_kses( $string, array( |
|
| 911 | + $string = wp_kses($string, array( |
|
| 912 | 912 | 'a' => array( |
| 913 | 913 | 'href' => true |
| 914 | 914 | ), |
| 915 | 915 | 'br' => true, |
| 916 | 916 | 'em' => true, |
| 917 | 917 | 'strong' => true, |
| 918 | - ) ); |
|
| 918 | + )); |
|
| 919 | 919 | |
| 920 | - if ( empty( $string ) ) |
|
| 920 | + if (empty($string)) |
|
| 921 | 921 | return; |
| 922 | 922 | |
| 923 | 923 | $this->messages[] = $string; |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | */ |
| 936 | 936 | public function footer() { |
| 937 | 937 | $output = ob_get_clean(); |
| 938 | - if ( ! empty( $output ) ) |
|
| 939 | - $this->feedback( $output ); |
|
| 938 | + if ( ! empty($output)) |
|
| 939 | + $this->feedback($output); |
|
| 940 | 940 | } |
| 941 | 941 | } |
@@ -35,8 +35,9 @@ discard block |
||
| 35 | 35 | * @param WP_Upgrader $upgrader |
| 36 | 36 | */ |
| 37 | 37 | public function set_upgrader(&$upgrader) { |
| 38 | - if ( is_object($upgrader) ) |
|
| 39 | - $this->upgrader =& $upgrader; |
|
| 38 | + if ( is_object($upgrader) ) { |
|
| 39 | + $this->upgrader =& $upgrader; |
|
| 40 | + } |
|
| 40 | 41 | $this->add_strings(); |
| 41 | 42 | } |
| 42 | 43 | |
@@ -103,16 +104,18 @@ discard block |
||
| 103 | 104 | * @param string|WP_Error $errors |
| 104 | 105 | */ |
| 105 | 106 | public function error($errors) { |
| 106 | - if ( ! $this->done_header ) |
|
| 107 | - $this->header(); |
|
| 107 | + if ( ! $this->done_header ) { |
|
| 108 | + $this->header(); |
|
| 109 | + } |
|
| 108 | 110 | if ( is_string($errors) ) { |
| 109 | 111 | $this->feedback($errors); |
| 110 | 112 | } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { |
| 111 | 113 | foreach ( $errors->get_error_messages() as $message ) { |
| 112 | - if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) |
|
| 113 | - $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); |
|
| 114 | - else |
|
| 115 | - $this->feedback($message); |
|
| 114 | + if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) { |
|
| 115 | + $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); |
|
| 116 | + } else { |
|
| 117 | + $this->feedback($message); |
|
| 118 | + } |
|
| 116 | 119 | } |
| 117 | 120 | } |
| 118 | 121 | } |
@@ -122,8 +125,9 @@ discard block |
||
| 122 | 125 | * @param string $string |
| 123 | 126 | */ |
| 124 | 127 | public function feedback($string) { |
| 125 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
| 126 | - $string = $this->upgrader->strings[$string]; |
|
| 128 | + if ( isset( $this->upgrader->strings[$string] ) ) { |
|
| 129 | + $string = $this->upgrader->strings[$string]; |
|
| 130 | + } |
|
| 127 | 131 | |
| 128 | 132 | if ( strpos($string, '%') !== false ) { |
| 129 | 133 | $args = func_get_args(); |
@@ -134,8 +138,9 @@ discard block |
||
| 134 | 138 | $string = vsprintf($string, $args); |
| 135 | 139 | } |
| 136 | 140 | } |
| 137 | - if ( empty($string) ) |
|
| 138 | - return; |
|
| 141 | + if ( empty($string) ) { |
|
| 142 | + return; |
|
| 143 | + } |
|
| 139 | 144 | show_message($string); |
| 140 | 145 | } |
| 141 | 146 | |
@@ -233,8 +238,9 @@ discard block |
||
| 233 | 238 | 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>', |
| 234 | 239 | 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>' |
| 235 | 240 | ); |
| 236 | - if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) |
|
| 237 | - unset( $update_actions['activate_plugin'] ); |
|
| 241 | + if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) { |
|
| 242 | + unset( $update_actions['activate_plugin'] ); |
|
| 243 | + } |
|
| 238 | 244 | |
| 239 | 245 | /** |
| 240 | 246 | * Filter the list of action links available following a single plugin update. |
@@ -246,8 +252,9 @@ discard block |
||
| 246 | 252 | */ |
| 247 | 253 | $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin ); |
| 248 | 254 | |
| 249 | - if ( ! empty($update_actions) ) |
|
| 250 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 255 | + if ( ! empty($update_actions) ) { |
|
| 256 | + $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | } |
| 253 | 260 | |
@@ -291,8 +298,9 @@ discard block |
||
| 291 | 298 | * @param string $string |
| 292 | 299 | */ |
| 293 | 300 | public function feedback($string) { |
| 294 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
| 295 | - $string = $this->upgrader->strings[$string]; |
|
| 301 | + if ( isset( $this->upgrader->strings[$string] ) ) { |
|
| 302 | + $string = $this->upgrader->strings[$string]; |
|
| 303 | + } |
|
| 296 | 304 | |
| 297 | 305 | if ( strpos($string, '%') !== false ) { |
| 298 | 306 | $args = func_get_args(); |
@@ -303,12 +311,14 @@ discard block |
||
| 303 | 311 | $string = vsprintf($string, $args); |
| 304 | 312 | } |
| 305 | 313 | } |
| 306 | - if ( empty($string) ) |
|
| 307 | - return; |
|
| 308 | - if ( $this->in_loop ) |
|
| 309 | - echo "$string<br />\n"; |
|
| 310 | - else |
|
| 311 | - echo "<p>$string</p>\n"; |
|
| 314 | + if ( empty($string) ) { |
|
| 315 | + return; |
|
| 316 | + } |
|
| 317 | + if ( $this->in_loop ) { |
|
| 318 | + echo "$string<br />\n"; |
|
| 319 | + } else { |
|
| 320 | + echo "<p>$string</p>\n"; |
|
| 321 | + } |
|
| 312 | 322 | } |
| 313 | 323 | |
| 314 | 324 | /** |
@@ -330,16 +340,18 @@ discard block |
||
| 330 | 340 | * @param string|WP_Error $error |
| 331 | 341 | */ |
| 332 | 342 | public function error($error) { |
| 333 | - if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) |
|
| 334 | - $this->error = $this->upgrader->strings[$error]; |
|
| 343 | + if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) { |
|
| 344 | + $this->error = $this->upgrader->strings[$error]; |
|
| 345 | + } |
|
| 335 | 346 | |
| 336 | 347 | if ( is_wp_error($error) ) { |
| 337 | 348 | $messages = array(); |
| 338 | 349 | foreach ( $error->get_error_messages() as $emessage ) { |
| 339 | - if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) |
|
| 340 | - $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); |
|
| 341 | - else |
|
| 342 | - $messages[] = $emessage; |
|
| 350 | + if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) { |
|
| 351 | + $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); |
|
| 352 | + } else { |
|
| 353 | + $messages[] = $emessage; |
|
| 354 | + } |
|
| 343 | 355 | } |
| 344 | 356 | $this->error = implode(', ', $messages); |
| 345 | 357 | } |
@@ -379,16 +391,18 @@ discard block |
||
| 379 | 391 | public function after($title = '') { |
| 380 | 392 | echo '</p></div>'; |
| 381 | 393 | if ( $this->error || ! $this->result ) { |
| 382 | - if ( $this->error ) |
|
| 383 | - echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>'; |
|
| 384 | - else |
|
| 385 | - echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>'; |
|
| 394 | + if ( $this->error ) { |
|
| 395 | + echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>'; |
|
| 396 | + } else { |
|
| 397 | + echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>'; |
|
| 398 | + } |
|
| 386 | 399 | |
| 387 | 400 | echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>'; |
| 388 | 401 | } |
| 389 | 402 | if ( $this->result && ! is_wp_error( $this->result ) ) { |
| 390 | - if ( ! $this->error ) |
|
| 391 | - echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>'; |
|
| 403 | + if ( ! $this->error ) { |
|
| 404 | + echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>'; |
|
| 405 | + } |
|
| 392 | 406 | echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; |
| 393 | 407 | } |
| 394 | 408 | |
@@ -447,8 +461,9 @@ discard block |
||
| 447 | 461 | 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>', |
| 448 | 462 | 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>' |
| 449 | 463 | ); |
| 450 | - if ( ! current_user_can( 'activate_plugins' ) ) |
|
| 451 | - unset( $update_actions['plugins_page'] ); |
|
| 464 | + if ( ! current_user_can( 'activate_plugins' ) ) { |
|
| 465 | + unset( $update_actions['plugins_page'] ); |
|
| 466 | + } |
|
| 452 | 467 | |
| 453 | 468 | /** |
| 454 | 469 | * Filter the list of action links available following bulk plugin updates. |
@@ -460,8 +475,9 @@ discard block |
||
| 460 | 475 | */ |
| 461 | 476 | $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
| 462 | 477 | |
| 463 | - if ( ! empty($update_actions) ) |
|
| 464 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 478 | + if ( ! empty($update_actions) ) { |
|
| 479 | + $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 480 | + } |
|
| 465 | 481 | } |
| 466 | 482 | } |
| 467 | 483 | |
@@ -499,8 +515,9 @@ discard block |
||
| 499 | 515 | 'themes_page' => '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>', |
| 500 | 516 | 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>' |
| 501 | 517 | ); |
| 502 | - if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) |
|
| 503 | - unset( $update_actions['themes_page'] ); |
|
| 518 | + if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) { |
|
| 519 | + unset( $update_actions['themes_page'] ); |
|
| 520 | + } |
|
| 504 | 521 | |
| 505 | 522 | /** |
| 506 | 523 | * Filter the list of action links available following bulk theme updates. |
@@ -512,8 +529,9 @@ discard block |
||
| 512 | 529 | */ |
| 513 | 530 | $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info ); |
| 514 | 531 | |
| 515 | - if ( ! empty($update_actions) ) |
|
| 516 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 532 | + if ( ! empty($update_actions) ) { |
|
| 533 | + $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | } |
| 519 | 537 | |
@@ -546,8 +564,9 @@ discard block |
||
| 546 | 564 | * @access public |
| 547 | 565 | */ |
| 548 | 566 | public function before() { |
| 549 | - if ( !empty($this->api) ) |
|
| 550 | - $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version); |
|
| 567 | + if ( !empty($this->api) ) { |
|
| 568 | + $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version); |
|
| 569 | + } |
|
| 551 | 570 | } |
| 552 | 571 | |
| 553 | 572 | /** |
@@ -560,10 +579,11 @@ discard block |
||
| 560 | 579 | |
| 561 | 580 | $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins'; |
| 562 | 581 | |
| 563 | - if ( 'import' == $from ) |
|
| 564 | - $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin & Run Importer' ) . '</a>'; |
|
| 565 | - else |
|
| 566 | - $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>'; |
|
| 582 | + if ( 'import' == $from ) { |
|
| 583 | + $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin & Run Importer' ) . '</a>'; |
|
| 584 | + } else { |
|
| 585 | + $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>'; |
|
| 586 | + } |
|
| 567 | 587 | |
| 568 | 588 | if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { |
| 569 | 589 | $install_actions['network_activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&networkwide=1&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Network Activate' ) . '</a>'; |
@@ -597,8 +617,9 @@ discard block |
||
| 597 | 617 | */ |
| 598 | 618 | $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file ); |
| 599 | 619 | |
| 600 | - if ( ! empty($install_actions) ) |
|
| 601 | - $this->feedback(implode(' | ', (array)$install_actions)); |
|
| 620 | + if ( ! empty($install_actions) ) { |
|
| 621 | + $this->feedback(implode(' | ', (array)$install_actions)); |
|
| 622 | + } |
|
| 602 | 623 | } |
| 603 | 624 | } |
| 604 | 625 | |
@@ -631,20 +652,23 @@ discard block |
||
| 631 | 652 | * @access public |
| 632 | 653 | */ |
| 633 | 654 | public function before() { |
| 634 | - if ( !empty($this->api) ) |
|
| 635 | - $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
| 655 | + if ( !empty($this->api) ) { |
|
| 656 | + $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
| 657 | + } |
|
| 636 | 658 | } |
| 637 | 659 | |
| 638 | 660 | /** |
| 639 | 661 | * @access public |
| 640 | 662 | */ |
| 641 | 663 | public function after() { |
| 642 | - if ( empty($this->upgrader->result['destination_name']) ) |
|
| 643 | - return; |
|
| 664 | + if ( empty($this->upgrader->result['destination_name']) ) { |
|
| 665 | + return; |
|
| 666 | + } |
|
| 644 | 667 | |
| 645 | 668 | $theme_info = $this->upgrader->theme_info(); |
| 646 | - if ( empty( $theme_info ) ) |
|
| 647 | - return; |
|
| 669 | + if ( empty( $theme_info ) ) { |
|
| 670 | + return; |
|
| 671 | + } |
|
| 648 | 672 | |
| 649 | 673 | $name = $theme_info->display('Name'); |
| 650 | 674 | $stylesheet = $this->upgrader->result['destination_name']; |
@@ -664,16 +688,19 @@ discard block |
||
| 664 | 688 | } |
| 665 | 689 | $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
| 666 | 690 | |
| 667 | - if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) |
|
| 668 | - $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
|
| 691 | + if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) { |
|
| 692 | + $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
|
| 693 | + } |
|
| 669 | 694 | |
| 670 | - if ( $this->type == 'web' ) |
|
| 671 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; |
|
| 672 | - elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) |
|
| 673 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
| 695 | + if ( $this->type == 'web' ) { |
|
| 696 | + $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; |
|
| 697 | + } elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) { |
|
| 698 | + $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
| 699 | + } |
|
| 674 | 700 | |
| 675 | - if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) |
|
| 676 | - unset( $install_actions['activate'], $install_actions['preview'] ); |
|
| 701 | + if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) { |
|
| 702 | + unset( $install_actions['activate'], $install_actions['preview'] ); |
|
| 703 | + } |
|
| 677 | 704 | |
| 678 | 705 | /** |
| 679 | 706 | * Filter the list of action links available following a single theme installation. |
@@ -686,8 +713,9 @@ discard block |
||
| 686 | 713 | * @param WP_Theme $theme_info Theme object. |
| 687 | 714 | */ |
| 688 | 715 | $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); |
| 689 | - if ( ! empty($install_actions) ) |
|
| 690 | - $this->feedback(implode(' | ', (array)$install_actions)); |
|
| 716 | + if ( ! empty($install_actions) ) { |
|
| 717 | + $this->feedback(implode(' | ', (array)$install_actions)); |
|
| 718 | + } |
|
| 691 | 719 | } |
| 692 | 720 | } |
| 693 | 721 | |
@@ -744,8 +772,9 @@ discard block |
||
| 744 | 772 | $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
| 745 | 773 | } |
| 746 | 774 | |
| 747 | - if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) |
|
| 748 | - unset( $update_actions['preview'], $update_actions['activate'] ); |
|
| 775 | + if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) { |
|
| 776 | + unset( $update_actions['preview'], $update_actions['activate'] ); |
|
| 777 | + } |
|
| 749 | 778 | } |
| 750 | 779 | |
| 751 | 780 | $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
@@ -760,8 +789,9 @@ discard block |
||
| 760 | 789 | */ |
| 761 | 790 | $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); |
| 762 | 791 | |
| 763 | - if ( ! empty($update_actions) ) |
|
| 764 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 792 | + if ( ! empty($update_actions) ) { |
|
| 793 | + $this->feedback(implode(' | ', (array)$update_actions)); |
|
| 794 | + } |
|
| 765 | 795 | } |
| 766 | 796 | } |
| 767 | 797 | |
@@ -838,8 +868,9 @@ discard block |
||
| 838 | 868 | */ |
| 839 | 869 | $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions ); |
| 840 | 870 | |
| 841 | - if ( $update_actions && $this->display_footer_actions ) |
|
| 842 | - $this->feedback( implode( ' | ', $update_actions ) ); |
|
| 871 | + if ( $update_actions && $this->display_footer_actions ) { |
|
| 872 | + $this->feedback( implode( ' | ', $update_actions ) ); |
|
| 873 | + } |
|
| 843 | 874 | } |
| 844 | 875 | } |
| 845 | 876 | |
@@ -895,14 +926,16 @@ discard block |
||
| 895 | 926 | } else { |
| 896 | 927 | $string = $data; |
| 897 | 928 | } |
| 898 | - if ( ! empty( $this->upgrader->strings[ $string ] ) ) |
|
| 899 | - $string = $this->upgrader->strings[ $string ]; |
|
| 929 | + if ( ! empty( $this->upgrader->strings[ $string ] ) ) { |
|
| 930 | + $string = $this->upgrader->strings[ $string ]; |
|
| 931 | + } |
|
| 900 | 932 | |
| 901 | 933 | if ( strpos( $string, '%' ) !== false ) { |
| 902 | 934 | $args = func_get_args(); |
| 903 | 935 | $args = array_splice( $args, 1 ); |
| 904 | - if ( ! empty( $args ) ) |
|
| 905 | - $string = vsprintf( $string, $args ); |
|
| 936 | + if ( ! empty( $args ) ) { |
|
| 937 | + $string = vsprintf( $string, $args ); |
|
| 938 | + } |
|
| 906 | 939 | } |
| 907 | 940 | |
| 908 | 941 | $string = trim( $string ); |
@@ -917,8 +950,9 @@ discard block |
||
| 917 | 950 | 'strong' => true, |
| 918 | 951 | ) ); |
| 919 | 952 | |
| 920 | - if ( empty( $string ) ) |
|
| 921 | - return; |
|
| 953 | + if ( empty( $string ) ) { |
|
| 954 | + return; |
|
| 955 | + } |
|
| 922 | 956 | |
| 923 | 957 | $this->messages[] = $string; |
| 924 | 958 | } |
@@ -935,7 +969,8 @@ discard block |
||
| 935 | 969 | */ |
| 936 | 970 | public function footer() { |
| 937 | 971 | $output = ob_get_clean(); |
| 938 | - if ( ! empty( $output ) ) |
|
| 939 | - $this->feedback( $output ); |
|
| 972 | + if ( ! empty( $output ) ) { |
|
| 973 | + $this->feedback( $output ); |
|
| 974 | + } |
|
| 940 | 975 | } |
| 941 | 976 | } |
@@ -1277,7 +1277,7 @@ |
||
| 1277 | 1277 | * |
| 1278 | 1278 | * @global string $wp_version |
| 1279 | 1279 | * |
| 1280 | - * @return array|bool False on failure, array of browser data on success. |
|
| 1280 | + * @return string False on failure, array of browser data on success. |
|
| 1281 | 1281 | */ |
| 1282 | 1282 | function wp_check_browser_version() { |
| 1283 | 1283 | if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) |
@@ -1245,13 +1245,13 @@ |
||
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | /** |
| 1248 | - * Filter the notice output for the 'Browse Happy' nag meta box. |
|
| 1249 | - * |
|
| 1250 | - * @since 3.2.0 |
|
| 1251 | - * |
|
| 1252 | - * @param string $notice The notice content. |
|
| 1253 | - * @param array $response An array containing web browser information. |
|
| 1254 | - */ |
|
| 1248 | + * Filter the notice output for the 'Browse Happy' nag meta box. |
|
| 1249 | + * |
|
| 1250 | + * @since 3.2.0 |
|
| 1251 | + * |
|
| 1252 | + * @param string $notice The notice content. |
|
| 1253 | + * @param array $response An array containing web browser information. |
|
| 1254 | + */ |
|
| 1255 | 1255 | echo apply_filters( 'browse-happy-notice', $notice, $response ); |
| 1256 | 1256 | } |
| 1257 | 1257 | |
@@ -26,43 +26,43 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | $response = wp_check_browser_version(); |
| 28 | 28 | |
| 29 | - if ( $response && $response['upgrade'] ) { |
|
| 30 | - add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); |
|
| 31 | - if ( $response['insecure'] ) |
|
| 32 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
|
| 29 | + if ($response && $response['upgrade']) { |
|
| 30 | + add_filter('postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class'); |
|
| 31 | + if ($response['insecure']) |
|
| 32 | + wp_add_dashboard_widget('dashboard_browser_nag', __('You are using an insecure browser!'), 'wp_dashboard_browser_nag'); |
|
| 33 | 33 | else |
| 34 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
|
| 34 | + wp_add_dashboard_widget('dashboard_browser_nag', __('Your browser is out of date!'), 'wp_dashboard_browser_nag'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // Right Now |
| 38 | - if ( is_blog_admin() && current_user_can('edit_posts') ) |
|
| 39 | - wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
|
| 38 | + if (is_blog_admin() && current_user_can('edit_posts')) |
|
| 39 | + wp_add_dashboard_widget('dashboard_right_now', __('At a Glance'), 'wp_dashboard_right_now'); |
|
| 40 | 40 | |
| 41 | - if ( is_network_admin() ) |
|
| 42 | - wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
|
| 41 | + if (is_network_admin()) |
|
| 42 | + wp_add_dashboard_widget('network_dashboard_right_now', __('Right Now'), 'wp_network_dashboard_right_now'); |
|
| 43 | 43 | |
| 44 | 44 | // Activity Widget |
| 45 | - if ( is_blog_admin() ) { |
|
| 46 | - wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); |
|
| 45 | + if (is_blog_admin()) { |
|
| 46 | + wp_add_dashboard_widget('dashboard_activity', __('Activity'), 'wp_dashboard_site_activity'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // QuickPress Widget |
| 50 | - if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { |
|
| 51 | - $quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Drafts' ) ); |
|
| 52 | - wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); |
|
| 50 | + if (is_blog_admin() && current_user_can('edit_posts')) { |
|
| 51 | + $quick_draft_title = sprintf('<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __('Quick Draft'), __('Drafts')); |
|
| 52 | + wp_add_dashboard_widget('dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // WordPress News |
| 56 | - wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress News' ), 'wp_dashboard_primary' ); |
|
| 56 | + wp_add_dashboard_widget('dashboard_primary', __('WordPress News'), 'wp_dashboard_primary'); |
|
| 57 | 57 | |
| 58 | - if ( is_network_admin() ) { |
|
| 58 | + if (is_network_admin()) { |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Fires after core widgets for the Network Admin dashboard have been registered. |
| 62 | 62 | * |
| 63 | 63 | * @since 3.1.0 |
| 64 | 64 | */ |
| 65 | - do_action( 'wp_network_dashboard_setup' ); |
|
| 65 | + do_action('wp_network_dashboard_setup'); |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * Filter the list of widgets to load for the Network Admin dashboard. |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @param array $dashboard_widgets An array of dashboard widgets. |
| 73 | 73 | */ |
| 74 | - $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); |
|
| 75 | - } elseif ( is_user_admin() ) { |
|
| 74 | + $dashboard_widgets = apply_filters('wp_network_dashboard_widgets', array()); |
|
| 75 | + } elseif (is_user_admin()) { |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * Fires after core widgets for the User Admin dashboard have been registered. |
| 79 | 79 | * |
| 80 | 80 | * @since 3.1.0 |
| 81 | 81 | */ |
| 82 | - do_action( 'wp_user_dashboard_setup' ); |
|
| 82 | + do_action('wp_user_dashboard_setup'); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Filter the list of widgets to load for the User Admin dashboard. |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @param array $dashboard_widgets An array of dashboard widgets. |
| 90 | 90 | */ |
| 91 | - $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); |
|
| 91 | + $dashboard_widgets = apply_filters('wp_user_dashboard_widgets', array()); |
|
| 92 | 92 | } else { |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @since 2.5.0 |
| 98 | 98 | */ |
| 99 | - do_action( 'wp_dashboard_setup' ); |
|
| 99 | + do_action('wp_dashboard_setup'); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Filter the list of widgets to load for the admin dashboard. |
@@ -105,28 +105,28 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param array $dashboard_widgets An array of dashboard widgets. |
| 107 | 107 | */ |
| 108 | - $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); |
|
| 108 | + $dashboard_widgets = apply_filters('wp_dashboard_widgets', array()); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - foreach ( $dashboard_widgets as $widget_id ) { |
|
| 112 | - $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>'; |
|
| 113 | - wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] ); |
|
| 111 | + foreach ($dashboard_widgets as $widget_id) { |
|
| 112 | + $name = empty($wp_registered_widgets[$widget_id]['all_link']) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name']." <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>".__('View all').'</a>'; |
|
| 113 | + wp_add_dashboard_widget($widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback']); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { |
|
| 117 | - check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); |
|
| 116 | + if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id'])) { |
|
| 117 | + check_admin_referer('edit-dashboard-widget_'.$_POST['widget_id'], 'dashboard-widget-nonce'); |
|
| 118 | 118 | ob_start(); // hack - but the same hack wp-admin/widgets.php uses |
| 119 | - wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); |
|
| 119 | + wp_dashboard_trigger_widget_control($_POST['widget_id']); |
|
| 120 | 120 | ob_end_clean(); |
| 121 | - wp_redirect( remove_query_arg( 'edit' ) ); |
|
| 121 | + wp_redirect(remove_query_arg('edit')); |
|
| 122 | 122 | exit; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
| 126 | - do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); |
|
| 126 | + do_action('do_meta_boxes', $screen->id, 'normal', ''); |
|
| 127 | 127 | |
| 128 | 128 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
| 129 | - do_action( 'do_meta_boxes', $screen->id, 'side', '' ); |
|
| 129 | + do_action('do_meta_boxes', $screen->id, 'side', ''); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,33 +139,33 @@ discard block |
||
| 139 | 139 | * @param callback $control_callback |
| 140 | 140 | * @param array $callback_args |
| 141 | 141 | */ |
| 142 | -function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) { |
|
| 142 | +function wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null) { |
|
| 143 | 143 | $screen = get_current_screen(); |
| 144 | 144 | global $wp_dashboard_control_callbacks; |
| 145 | 145 | |
| 146 | - if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { |
|
| 146 | + if ($control_callback && current_user_can('edit_dashboard') && is_callable($control_callback)) { |
|
| 147 | 147 | $wp_dashboard_control_callbacks[$widget_id] = $control_callback; |
| 148 | - if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { |
|
| 149 | - list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); |
|
| 150 | - $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>'; |
|
| 148 | + if (isset($_GET['edit']) && $widget_id == $_GET['edit']) { |
|
| 149 | + list($url) = explode('#', add_query_arg('edit', false), 2); |
|
| 150 | + $widget_name .= ' <span class="postbox-title-action"><a href="'.esc_url($url).'">'.__('Cancel').'</a></span>'; |
|
| 151 | 151 | $callback = '_wp_dashboard_control_callback'; |
| 152 | 152 | } else { |
| 153 | - list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); |
|
| 154 | - $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>'; |
|
| 153 | + list($url) = explode('#', add_query_arg('edit', $widget_id), 2); |
|
| 154 | + $widget_name .= ' <span class="postbox-title-action"><a href="'.esc_url("$url#$widget_id").'" class="edit-box open-box">'.__('Configure').'</a></span>'; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); |
|
| 158 | + $side_widgets = array('dashboard_quick_press', 'dashboard_primary'); |
|
| 159 | 159 | |
| 160 | 160 | $location = 'normal'; |
| 161 | - if ( in_array($widget_id, $side_widgets) ) |
|
| 161 | + if (in_array($widget_id, $side_widgets)) |
|
| 162 | 162 | $location = 'side'; |
| 163 | 163 | |
| 164 | 164 | $priority = 'core'; |
| 165 | - if ( 'dashboard_browser_nag' === $widget_id ) |
|
| 165 | + if ('dashboard_browser_nag' === $widget_id) |
|
| 166 | 166 | $priority = 'high'; |
| 167 | 167 | |
| 168 | - add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); |
|
| 168 | + add_meta_box($widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -173,12 +173,12 @@ discard block |
||
| 173 | 173 | * @param type $dashboard |
| 174 | 174 | * @param type $meta_box |
| 175 | 175 | */ |
| 176 | -function _wp_dashboard_control_callback( $dashboard, $meta_box ) { |
|
| 176 | +function _wp_dashboard_control_callback($dashboard, $meta_box) { |
|
| 177 | 177 | echo '<form method="post" class="dashboard-widget-control-form">'; |
| 178 | - wp_dashboard_trigger_widget_control( $meta_box['id'] ); |
|
| 179 | - wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' ); |
|
| 180 | - echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />'; |
|
| 181 | - submit_button( __('Submit') ); |
|
| 178 | + wp_dashboard_trigger_widget_control($meta_box['id']); |
|
| 179 | + wp_nonce_field('edit-dashboard-widget_'.$meta_box['id'], 'dashboard-widget-nonce'); |
|
| 180 | + echo '<input type="hidden" name="widget_id" value="'.esc_attr($meta_box['id']).'" />'; |
|
| 181 | + submit_button(__('Submit')); |
|
| 182 | 182 | echo '</form>'; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -189,31 +189,31 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | function wp_dashboard() { |
| 191 | 191 | $screen = get_current_screen(); |
| 192 | - $columns = absint( $screen->get_columns() ); |
|
| 192 | + $columns = absint($screen->get_columns()); |
|
| 193 | 193 | $columns_css = ''; |
| 194 | - if ( $columns ) { |
|
| 194 | + if ($columns) { |
|
| 195 | 195 | $columns_css = " columns-$columns"; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | ?> |
| 199 | 199 | <div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>"> |
| 200 | 200 | <div id="postbox-container-1" class="postbox-container"> |
| 201 | - <?php do_meta_boxes( $screen->id, 'normal', '' ); ?> |
|
| 201 | + <?php do_meta_boxes($screen->id, 'normal', ''); ?> |
|
| 202 | 202 | </div> |
| 203 | 203 | <div id="postbox-container-2" class="postbox-container"> |
| 204 | - <?php do_meta_boxes( $screen->id, 'side', '' ); ?> |
|
| 204 | + <?php do_meta_boxes($screen->id, 'side', ''); ?> |
|
| 205 | 205 | </div> |
| 206 | 206 | <div id="postbox-container-3" class="postbox-container"> |
| 207 | - <?php do_meta_boxes( $screen->id, 'column3', '' ); ?> |
|
| 207 | + <?php do_meta_boxes($screen->id, 'column3', ''); ?> |
|
| 208 | 208 | </div> |
| 209 | 209 | <div id="postbox-container-4" class="postbox-container"> |
| 210 | - <?php do_meta_boxes( $screen->id, 'column4', '' ); ?> |
|
| 210 | + <?php do_meta_boxes($screen->id, 'column4', ''); ?> |
|
| 211 | 211 | </div> |
| 212 | 212 | </div> |
| 213 | 213 | |
| 214 | 214 | <?php |
| 215 | - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
| 216 | - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
| 215 | + wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
| 216 | + wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
| 217 | 217 | |
| 218 | 218 | } |
| 219 | 219 | |
@@ -234,34 +234,34 @@ discard block |
||
| 234 | 234 | <ul> |
| 235 | 235 | <?php |
| 236 | 236 | // Posts and Pages |
| 237 | - foreach ( array( 'post', 'page' ) as $post_type ) { |
|
| 238 | - $num_posts = wp_count_posts( $post_type ); |
|
| 239 | - if ( $num_posts && $num_posts->publish ) { |
|
| 240 | - if ( 'post' == $post_type ) { |
|
| 241 | - $text = _n( '%s Post', '%s Posts', $num_posts->publish ); |
|
| 237 | + foreach (array('post', 'page') as $post_type) { |
|
| 238 | + $num_posts = wp_count_posts($post_type); |
|
| 239 | + if ($num_posts && $num_posts->publish) { |
|
| 240 | + if ('post' == $post_type) { |
|
| 241 | + $text = _n('%s Post', '%s Posts', $num_posts->publish); |
|
| 242 | 242 | } else { |
| 243 | - $text = _n( '%s Page', '%s Pages', $num_posts->publish ); |
|
| 243 | + $text = _n('%s Page', '%s Pages', $num_posts->publish); |
|
| 244 | 244 | } |
| 245 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
| 246 | - $post_type_object = get_post_type_object( $post_type ); |
|
| 247 | - if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { |
|
| 248 | - printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text ); |
|
| 245 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
| 246 | + $post_type_object = get_post_type_object($post_type); |
|
| 247 | + if ($post_type_object && current_user_can($post_type_object->cap->edit_posts)) { |
|
| 248 | + printf('<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text); |
|
| 249 | 249 | } else { |
| 250 | - printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text ); |
|
| 250 | + printf('<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | // Comments |
| 256 | 256 | $num_comm = wp_count_comments(); |
| 257 | - if ( $num_comm && $num_comm->approved ) { |
|
| 258 | - $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); |
|
| 257 | + if ($num_comm && $num_comm->approved) { |
|
| 258 | + $text = sprintf(_n('%s Comment', '%s Comments', $num_comm->approved), number_format_i18n($num_comm->approved)); |
|
| 259 | 259 | ?> |
| 260 | 260 | <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li> |
| 261 | 261 | <?php |
| 262 | - if ( $num_comm->moderated ) { |
|
| 262 | + if ($num_comm->moderated) { |
|
| 263 | 263 | /* translators: Number of comments in moderation */ |
| 264 | - $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) ); |
|
| 264 | + $text = sprintf(_nx('%s in moderation', '%s in moderation', $num_comm->moderated, 'comments'), number_format_i18n($num_comm->moderated)); |
|
| 265 | 265 | ?> |
| 266 | 266 | <li class="comment-mod-count"><a href="edit-comments.php?comment_status=moderated"><?php echo $text; ?></a></li> |
| 267 | 267 | <?php |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @param array $items Array of extra 'At a Glance' widget items. |
| 281 | 281 | */ |
| 282 | - $elements = apply_filters( 'dashboard_glance_items', array() ); |
|
| 282 | + $elements = apply_filters('dashboard_glance_items', array()); |
|
| 283 | 283 | |
| 284 | - if ( $elements ) { |
|
| 285 | - echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n"; |
|
| 284 | + if ($elements) { |
|
| 285 | + echo '<li>'.implode("</li>\n<li>", $elements)."</li>\n"; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | ?> |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | update_right_now_message(); |
| 292 | 292 | |
| 293 | 293 | // Check if search engines are asked not to index this site. |
| 294 | - if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '1' != get_option( 'blog_public' ) ) { |
|
| 294 | + if ( ! is_network_admin() && ! is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public')) { |
|
| 295 | 295 | |
| 296 | 296 | /** |
| 297 | 297 | * Filter the link title attribute for the 'Search Engines Discouraged' |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @param string $title Default attribute text. |
| 305 | 305 | */ |
| 306 | - $title = apply_filters( 'privacy_on_link_title', __( 'Your site is asking search engines not to index its content' ) ); |
|
| 306 | + $title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content')); |
|
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | 309 | * Filter the link label for the 'Search Engines Discouraged' message |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @param string $content Default text. |
| 317 | 317 | */ |
| 318 | - $content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) ); |
|
| 318 | + $content = apply_filters('privacy_on_link_text', __('Search Engines Discouraged')); |
|
| 319 | 319 | |
| 320 | 320 | echo "<p><a href='options-reading.php' title='$title'>$content</a></p>"; |
| 321 | 321 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @since 2.5.0 |
| 337 | 337 | */ |
| 338 | - do_action( 'rightnow_end' ); |
|
| 338 | + do_action('rightnow_end'); |
|
| 339 | 339 | |
| 340 | 340 | /** |
| 341 | 341 | * Fires at the end of the 'At a Glance' dashboard widget. |
@@ -344,11 +344,11 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @since 2.0.0 |
| 346 | 346 | */ |
| 347 | - do_action( 'activity_box_end' ); |
|
| 347 | + do_action('activity_box_end'); |
|
| 348 | 348 | |
| 349 | 349 | $actions = ob_get_clean(); |
| 350 | 350 | |
| 351 | - if ( !empty( $actions ) ) : ?> |
|
| 351 | + if ( ! empty($actions)) : ?> |
|
| 352 | 352 | <div class="sub"> |
| 353 | 353 | <?php echo $actions; ?> |
| 354 | 354 | </div> |
@@ -360,25 +360,25 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | function wp_network_dashboard_right_now() { |
| 362 | 362 | $actions = array(); |
| 363 | - if ( current_user_can('create_sites') ) |
|
| 364 | - $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>'; |
|
| 365 | - if ( current_user_can('create_users') ) |
|
| 366 | - $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>'; |
|
| 363 | + if (current_user_can('create_sites')) |
|
| 364 | + $actions['create-site'] = '<a href="'.network_admin_url('site-new.php').'">'.__('Create a New Site').'</a>'; |
|
| 365 | + if (current_user_can('create_users')) |
|
| 366 | + $actions['create-user'] = '<a href="'.network_admin_url('user-new.php').'">'.__('Create a New User').'</a>'; |
|
| 367 | 367 | |
| 368 | 368 | $c_users = get_user_count(); |
| 369 | 369 | $c_blogs = get_blog_count(); |
| 370 | 370 | |
| 371 | - $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); |
|
| 372 | - $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); |
|
| 371 | + $user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users)); |
|
| 372 | + $blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs)); |
|
| 373 | 373 | |
| 374 | - $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); |
|
| 374 | + $sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text); |
|
| 375 | 375 | |
| 376 | - if ( $actions ) { |
|
| 376 | + if ($actions) { |
|
| 377 | 377 | echo '<ul class="subsubsub">'; |
| 378 | - foreach ( $actions as $class => $action ) { |
|
| 379 | - $actions[ $class ] = "\t<li class='$class'>$action"; |
|
| 378 | + foreach ($actions as $class => $action) { |
|
| 379 | + $actions[$class] = "\t<li class='$class'>$action"; |
|
| 380 | 380 | } |
| 381 | - echo implode( " |</li>\n", $actions ) . "</li>\n"; |
|
| 381 | + echo implode(" |</li>\n", $actions)."</li>\n"; |
|
| 382 | 382 | echo '</ul>'; |
| 383 | 383 | } |
| 384 | 384 | ?> |
@@ -396,22 +396,22 @@ discard block |
||
| 396 | 396 | * |
| 397 | 397 | * @param null $unused |
| 398 | 398 | */ |
| 399 | - do_action( 'wpmuadminresult', '' ); |
|
| 399 | + do_action('wpmuadminresult', ''); |
|
| 400 | 400 | ?> |
| 401 | 401 | |
| 402 | 402 | <form action="<?php echo network_admin_url('users.php'); ?>" method="get"> |
| 403 | 403 | <p> |
| 404 | - <label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label> |
|
| 404 | + <label class="screen-reader-text" for="search-users"><?php _e('Search Users'); ?></label> |
|
| 405 | 405 | <input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/> |
| 406 | - <?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?> |
|
| 406 | + <?php submit_button(__('Search Users'), 'button', 'submit', false, array('id' => 'submit_users')); ?> |
|
| 407 | 407 | </p> |
| 408 | 408 | </form> |
| 409 | 409 | |
| 410 | 410 | <form action="<?php echo network_admin_url('sites.php'); ?>" method="get"> |
| 411 | 411 | <p> |
| 412 | - <label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label> |
|
| 412 | + <label class="screen-reader-text" for="search-sites"><?php _e('Search Sites'); ?></label> |
|
| 413 | 413 | <input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/> |
| 414 | - <?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?> |
|
| 414 | + <?php submit_button(__('Search Sites'), 'button', 'submit', false, array('id' => 'submit_sites')); ?> |
|
| 415 | 415 | </p> |
| 416 | 416 | </form> |
| 417 | 417 | <?php |
@@ -420,14 +420,14 @@ discard block |
||
| 420 | 420 | * |
| 421 | 421 | * @since MU |
| 422 | 422 | */ |
| 423 | - do_action( 'mu_rightnow_end' ); |
|
| 423 | + do_action('mu_rightnow_end'); |
|
| 424 | 424 | |
| 425 | 425 | /** |
| 426 | 426 | * Fires at the end of the 'Right Now' widget in the Network Admin dashboard. |
| 427 | 427 | * |
| 428 | 428 | * @since MU |
| 429 | 429 | */ |
| 430 | - do_action( 'mu_activity_box_end' ); |
|
| 430 | + do_action('mu_activity_box_end'); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -439,37 +439,37 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * @param string $error_msg Optional. Error message. Default false. |
| 441 | 441 | */ |
| 442 | -function wp_dashboard_quick_press( $error_msg = false ) { |
|
| 442 | +function wp_dashboard_quick_press($error_msg = false) { |
|
| 443 | 443 | global $post_ID; |
| 444 | 444 | |
| 445 | - if ( ! current_user_can( 'edit_posts' ) ) { |
|
| 445 | + if ( ! current_user_can('edit_posts')) { |
|
| 446 | 446 | return; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ |
| 450 | - $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID |
|
| 451 | - if ( $last_post_id ) { |
|
| 452 | - $post = get_post( $last_post_id ); |
|
| 453 | - if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore |
|
| 454 | - $post = get_default_post_to_edit( 'post', true ); |
|
| 455 | - update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
|
| 450 | + $last_post_id = (int) get_user_option('dashboard_quick_press_last_post_id'); // Get the last post_ID |
|
| 451 | + if ($last_post_id) { |
|
| 452 | + $post = get_post($last_post_id); |
|
| 453 | + if (empty($post) || $post->post_status != 'auto-draft') { // auto-draft doesn't exists anymore |
|
| 454 | + $post = get_default_post_to_edit('post', true); |
|
| 455 | + update_user_option(get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID |
|
| 456 | 456 | } else { |
| 457 | 457 | $post->post_title = ''; // Remove the auto draft title |
| 458 | 458 | } |
| 459 | 459 | } else { |
| 460 | - $post = get_default_post_to_edit( 'post' , true); |
|
| 460 | + $post = get_default_post_to_edit('post', true); |
|
| 461 | 461 | $user_id = get_current_user_id(); |
| 462 | 462 | // Don't create an option if this is a super admin who does not belong to this site. |
| 463 | - if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) |
|
| 464 | - update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
|
| 463 | + if ( ! (is_super_admin($user_id) && ! in_array(get_current_blog_id(), array_keys(get_blogs_of_user($user_id))))) |
|
| 464 | + update_user_option($user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $post_ID = (int) $post->ID; |
| 468 | 468 | ?> |
| 469 | 469 | |
| 470 | - <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js"> |
|
| 470 | + <form name="post" action="<?php echo esc_url(admin_url('post.php')); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js"> |
|
| 471 | 471 | |
| 472 | - <?php if ( $error_msg ) : ?> |
|
| 472 | + <?php if ($error_msg) : ?> |
|
| 473 | 473 | <div class="error"><?php echo $error_msg; ?></div> |
| 474 | 474 | <?php endif; ?> |
| 475 | 475 | |
@@ -478,14 +478,14 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | <?php |
| 480 | 480 | /** This filter is documented in wp-admin/edit-form-advanced.php */ |
| 481 | - echo apply_filters( 'enter_title_here', __( 'Title' ), $post ); |
|
| 481 | + echo apply_filters('enter_title_here', __('Title'), $post); |
|
| 482 | 482 | ?> |
| 483 | 483 | </label> |
| 484 | 484 | <input type="text" name="post_title" id="title" autocomplete="off" /> |
| 485 | 485 | </div> |
| 486 | 486 | |
| 487 | 487 | <div class="textarea-wrap" id="description-wrap"> |
| 488 | - <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label> |
|
| 488 | + <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e('What’s on your mind?'); ?></label> |
|
| 489 | 489 | <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea> |
| 490 | 490 | </div> |
| 491 | 491 | |
@@ -493,8 +493,8 @@ discard block |
||
| 493 | 493 | <input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" /> |
| 494 | 494 | <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" /> |
| 495 | 495 | <input type="hidden" name="post_type" value="post" /> |
| 496 | - <?php wp_nonce_field( 'add-post' ); ?> |
|
| 497 | - <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?> |
|
| 496 | + <?php wp_nonce_field('add-post'); ?> |
|
| 497 | + <?php submit_button(__('Save Draft'), 'primary', 'save', false, array('id' => 'save-post')); ?> |
|
| 498 | 498 | <br class="clear" /> |
| 499 | 499 | </p> |
| 500 | 500 | |
@@ -510,8 +510,8 @@ discard block |
||
| 510 | 510 | * |
| 511 | 511 | * @param array $drafts |
| 512 | 512 | */ |
| 513 | -function wp_dashboard_recent_drafts( $drafts = false ) { |
|
| 514 | - if ( ! $drafts ) { |
|
| 513 | +function wp_dashboard_recent_drafts($drafts = false) { |
|
| 514 | + if ( ! $drafts) { |
|
| 515 | 515 | $query_args = array( |
| 516 | 516 | 'post_type' => 'post', |
| 517 | 517 | 'post_status' => 'draft', |
@@ -520,27 +520,27 @@ discard block |
||
| 520 | 520 | 'orderby' => 'modified', |
| 521 | 521 | 'order' => 'DESC' |
| 522 | 522 | ); |
| 523 | - $drafts = get_posts( $query_args ); |
|
| 524 | - if ( ! $drafts ) { |
|
| 523 | + $drafts = get_posts($query_args); |
|
| 524 | + if ( ! $drafts) { |
|
| 525 | 525 | return; |
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | echo '<div class="drafts">'; |
| 530 | - if ( count( $drafts ) > 3 ) { |
|
| 531 | - echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n"; |
|
| 530 | + if (count($drafts) > 3) { |
|
| 531 | + echo '<p class="view-all"><a href="'.esc_url(admin_url('edit.php?post_status=draft')).'">'._x('View all', 'drafts')."</a></p>\n"; |
|
| 532 | 532 | } |
| 533 | - echo '<h4 class="hide-if-no-js">' . __( 'Drafts' ) . "</h4>\n<ul>"; |
|
| 533 | + echo '<h4 class="hide-if-no-js">'.__('Drafts')."</h4>\n<ul>"; |
|
| 534 | 534 | |
| 535 | - $drafts = array_slice( $drafts, 0, 3 ); |
|
| 536 | - foreach ( $drafts as $draft ) { |
|
| 537 | - $url = get_edit_post_link( $draft->ID ); |
|
| 538 | - $title = _draft_or_post_title( $draft->ID ); |
|
| 535 | + $drafts = array_slice($drafts, 0, 3); |
|
| 536 | + foreach ($drafts as $draft) { |
|
| 537 | + $url = get_edit_post_link($draft->ID); |
|
| 538 | + $title = _draft_or_post_title($draft->ID); |
|
| 539 | 539 | echo "<li>\n"; |
| 540 | - echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>'; |
|
| 541 | - echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( get_option( 'date_format' ), $draft ) . '</time></div>'; |
|
| 542 | - if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) { |
|
| 543 | - echo '<p>' . $the_content . '</p>'; |
|
| 540 | + echo '<div class="draft-title"><a href="'.esc_url($url).'" title="'.esc_attr(sprintf(__('Edit “%s”'), $title)).'">'.esc_html($title).'</a>'; |
|
| 541 | + echo '<time datetime="'.get_the_time('c', $draft).'">'.get_the_time(get_option('date_format'), $draft).'</time></div>'; |
|
| 542 | + if ($the_content = wp_trim_words($draft->post_content, 10)) { |
|
| 543 | + echo '<p>'.$the_content.'</p>'; |
|
| 544 | 544 | } |
| 545 | 545 | echo "</li>\n"; |
| 546 | 546 | } |
@@ -553,22 +553,22 @@ discard block |
||
| 553 | 553 | * @param object $comment |
| 554 | 554 | * @param bool $show_date |
| 555 | 555 | */ |
| 556 | -function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { |
|
| 557 | - $GLOBALS['comment'] =& $comment; |
|
| 556 | +function _wp_dashboard_recent_comments_row(&$comment, $show_date = true) { |
|
| 557 | + $GLOBALS['comment'] = & $comment; |
|
| 558 | 558 | |
| 559 | - $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); |
|
| 559 | + $comment_post_title = _draft_or_post_title($comment->comment_post_ID); |
|
| 560 | 560 | |
| 561 | - if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) { |
|
| 562 | - $comment_post_url = get_edit_post_link( $comment->comment_post_ID ); |
|
| 561 | + if (current_user_can('edit_post', $comment->comment_post_ID)) { |
|
| 562 | + $comment_post_url = get_edit_post_link($comment->comment_post_ID); |
|
| 563 | 563 | $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>"; |
| 564 | 564 | } else { |
| 565 | 565 | $comment_post_link = $comment_post_title; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - $comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>'; |
|
| 568 | + $comment_link = '<a class="comment-link" href="'.esc_url(get_comment_link()).'">#</a>'; |
|
| 569 | 569 | |
| 570 | 570 | $actions_string = ''; |
| 571 | - if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
| 571 | + if (current_user_can('edit_comment', $comment->comment_ID)) { |
|
| 572 | 572 | // Pre-order it: Approve | Reply | Edit | Spam | Trash. |
| 573 | 573 | $actions = array( |
| 574 | 574 | 'approve' => '', 'unapprove' => '', |
@@ -578,24 +578,24 @@ discard block |
||
| 578 | 578 | 'trash' => '', 'delete' => '' |
| 579 | 579 | ); |
| 580 | 580 | |
| 581 | - $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); |
|
| 582 | - $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); |
|
| 583 | - |
|
| 584 | - $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
|
| 585 | - $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
|
| 586 | - $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
| 587 | - $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
| 588 | - $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
| 589 | - |
|
| 590 | - $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
|
| 591 | - $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
|
| 592 | - $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>'; |
|
| 593 | - $actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; |
|
| 594 | - $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
|
| 595 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 596 | - $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; |
|
| 581 | + $del_nonce = esc_html('_wpnonce='.wp_create_nonce("delete-comment_$comment->comment_ID")); |
|
| 582 | + $approve_nonce = esc_html('_wpnonce='.wp_create_nonce("approve-comment_$comment->comment_ID")); |
|
| 583 | + |
|
| 584 | + $approve_url = esc_url("comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce"); |
|
| 585 | + $unapprove_url = esc_url("comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce"); |
|
| 586 | + $spam_url = esc_url("comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce"); |
|
| 587 | + $trash_url = esc_url("comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce"); |
|
| 588 | + $delete_url = esc_url("comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce"); |
|
| 589 | + |
|
| 590 | + $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='".esc_attr__('Approve this comment')."'>".__('Approve').'</a>'; |
|
| 591 | + $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='".esc_attr__('Unapprove this comment')."'>".__('Unapprove').'</a>'; |
|
| 592 | + $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='".esc_attr__('Edit comment')."'>".__('Edit').'</a>'; |
|
| 593 | + $actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">'.__('Reply').'</a>'; |
|
| 594 | + $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='".esc_attr__('Mark this comment as spam')."'>"./* translators: mark as spam link */ _x('Spam', 'verb').'</a>'; |
|
| 595 | + if ( ! EMPTY_TRASH_DAYS) |
|
| 596 | + $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive'>".__('Delete Permanently').'</a>'; |
|
| 597 | 597 | else |
| 598 | - $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; |
|
| 598 | + $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='".esc_attr__('Move this comment to the trash')."'>"._x('Trash', 'verb').'</a>'; |
|
| 599 | 599 | |
| 600 | 600 | /** |
| 601 | 601 | * Filter the action links displayed for each comment in the 'Recent Comments' |
@@ -608,15 +608,15 @@ discard block |
||
| 608 | 608 | * 'Delete', and 'Trash'. |
| 609 | 609 | * @param object $comment The comment object. |
| 610 | 610 | */ |
| 611 | - $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); |
|
| 611 | + $actions = apply_filters('comment_row_actions', array_filter($actions), $comment); |
|
| 612 | 612 | |
| 613 | 613 | $i = 0; |
| 614 | - foreach ( $actions as $action => $link ) { |
|
| 614 | + foreach ($actions as $action => $link) { |
|
| 615 | 615 | ++$i; |
| 616 | - ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
|
| 616 | + ((('approve' == $action || 'unapprove' == $action) && 2 === $i) || 1 === $i) ? $sep = '' : $sep = ' | '; |
|
| 617 | 617 | |
| 618 | 618 | // Reply and quickedit need a hide-if-no-js span |
| 619 | - if ( 'reply' == $action || 'quickedit' == $action ) |
|
| 619 | + if ('reply' == $action || 'quickedit' == $action) |
|
| 620 | 620 | $action .= ' hide-if-no-js'; |
| 621 | 621 | |
| 622 | 622 | $actions_string .= "<span class='$action'>$sep$link</span>"; |
@@ -625,35 +625,35 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | ?> |
| 627 | 627 | |
| 628 | - <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>> |
|
| 628 | + <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class(array('comment-item', wp_get_comment_status($comment->comment_ID))); ?>> |
|
| 629 | 629 | |
| 630 | - <?php echo get_avatar( $comment, 50, 'mystery' ); ?> |
|
| 630 | + <?php echo get_avatar($comment, 50, 'mystery'); ?> |
|
| 631 | 631 | |
| 632 | - <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?> |
|
| 632 | + <?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type) : ?> |
|
| 633 | 633 | |
| 634 | 634 | <div class="dashboard-comment-wrap has-row-actions"> |
| 635 | 635 | <h4 class="comment-meta"> |
| 636 | - <?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__( 'From %1$s on %2$s%3$s' ), |
|
| 637 | - '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?> |
|
| 636 | + <?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__('From %1$s on %2$s%3$s'), |
|
| 637 | + '<cite class="comment-author">'.get_comment_author_link().'</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">'.__('[Pending]').'</span>' ); ?> |
|
| 638 | 638 | </h4> |
| 639 | 639 | |
| 640 | 640 | <?php |
| 641 | 641 | else : |
| 642 | - switch ( $comment->comment_type ) { |
|
| 642 | + switch ($comment->comment_type) { |
|
| 643 | 643 | case 'pingback' : |
| 644 | - $type = __( 'Pingback' ); |
|
| 644 | + $type = __('Pingback'); |
|
| 645 | 645 | break; |
| 646 | 646 | case 'trackback' : |
| 647 | - $type = __( 'Trackback' ); |
|
| 647 | + $type = __('Trackback'); |
|
| 648 | 648 | break; |
| 649 | 649 | default : |
| 650 | - $type = ucwords( $comment->comment_type ); |
|
| 650 | + $type = ucwords($comment->comment_type); |
|
| 651 | 651 | } |
| 652 | - $type = esc_html( $type ); |
|
| 652 | + $type = esc_html($type); |
|
| 653 | 653 | ?> |
| 654 | 654 | <div class="dashboard-comment-wrap has-row-actions"> |
| 655 | 655 | <?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?> |
| 656 | - <h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link." ".$comment_link ); ?></h4> |
|
| 656 | + <h4 class="comment-meta"><?php printf(_x('%1$s on %2$s', 'dashboard'), "<strong>$type</strong>", $comment_post_link." ".$comment_link); ?></h4> |
|
| 657 | 657 | <p class="comment-author"><?php comment_author_link(); ?></p> |
| 658 | 658 | |
| 659 | 659 | <?php endif; // comment_type ?> |
@@ -673,27 +673,27 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | echo '<div id="activity-widget">'; |
| 675 | 675 | |
| 676 | - $future_posts = wp_dashboard_recent_posts( array( |
|
| 676 | + $future_posts = wp_dashboard_recent_posts(array( |
|
| 677 | 677 | 'max' => 5, |
| 678 | 678 | 'status' => 'future', |
| 679 | 679 | 'order' => 'ASC', |
| 680 | - 'title' => __( 'Publishing Soon' ), |
|
| 680 | + 'title' => __('Publishing Soon'), |
|
| 681 | 681 | 'id' => 'future-posts', |
| 682 | - ) ); |
|
| 683 | - $recent_posts = wp_dashboard_recent_posts( array( |
|
| 682 | + )); |
|
| 683 | + $recent_posts = wp_dashboard_recent_posts(array( |
|
| 684 | 684 | 'max' => 5, |
| 685 | 685 | 'status' => 'publish', |
| 686 | 686 | 'order' => 'DESC', |
| 687 | - 'title' => __( 'Recently Published' ), |
|
| 687 | + 'title' => __('Recently Published'), |
|
| 688 | 688 | 'id' => 'published-posts', |
| 689 | - ) ); |
|
| 689 | + )); |
|
| 690 | 690 | |
| 691 | 691 | $recent_comments = wp_dashboard_recent_comments(); |
| 692 | 692 | |
| 693 | - if ( !$future_posts && !$recent_posts && !$recent_comments ) { |
|
| 693 | + if ( ! $future_posts && ! $recent_posts && ! $recent_comments) { |
|
| 694 | 694 | echo '<div class="no-activity">'; |
| 695 | 695 | echo '<p class="smiley"></p>'; |
| 696 | - echo '<p>' . __( 'No activity yet!' ) . '</p>'; |
|
| 696 | + echo '<p>'.__('No activity yet!').'</p>'; |
|
| 697 | 697 | echo '</div>'; |
| 698 | 698 | } |
| 699 | 699 | |
@@ -716,16 +716,16 @@ discard block |
||
| 716 | 716 | * } |
| 717 | 717 | * @return bool False if no posts were found. True otherwise. |
| 718 | 718 | */ |
| 719 | -function wp_dashboard_recent_posts( $args ) { |
|
| 719 | +function wp_dashboard_recent_posts($args) { |
|
| 720 | 720 | $query_args = array( |
| 721 | 721 | 'post_type' => 'post', |
| 722 | 722 | 'post_status' => $args['status'], |
| 723 | 723 | 'orderby' => 'date', |
| 724 | 724 | 'order' => $args['order'], |
| 725 | - 'posts_per_page' => intval( $args['max'] ), |
|
| 725 | + 'posts_per_page' => intval($args['max']), |
|
| 726 | 726 | 'no_found_rows' => true, |
| 727 | 727 | 'cache_results' => false, |
| 728 | - 'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', |
|
| 728 | + 'perm' => ('future' === $args['status']) ? 'editable' : 'readable', |
|
| 729 | 729 | ); |
| 730 | 730 | |
| 731 | 731 | /** |
@@ -735,39 +735,39 @@ discard block |
||
| 735 | 735 | * |
| 736 | 736 | * @param array $query_args The arguments passed to WP_Query to produce the list of posts. |
| 737 | 737 | */ |
| 738 | - $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args ); |
|
| 739 | - $posts = new WP_Query( $query_args ); |
|
| 738 | + $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args); |
|
| 739 | + $posts = new WP_Query($query_args); |
|
| 740 | 740 | |
| 741 | - if ( $posts->have_posts() ) { |
|
| 741 | + if ($posts->have_posts()) { |
|
| 742 | 742 | |
| 743 | - echo '<div id="' . $args['id'] . '" class="activity-block">'; |
|
| 743 | + echo '<div id="'.$args['id'].'" class="activity-block">'; |
|
| 744 | 744 | |
| 745 | - echo '<h4>' . $args['title'] . '</h4>'; |
|
| 745 | + echo '<h4>'.$args['title'].'</h4>'; |
|
| 746 | 746 | |
| 747 | 747 | echo '<ul>'; |
| 748 | 748 | |
| 749 | - $today = date( 'Y-m-d', current_time( 'timestamp' ) ); |
|
| 750 | - $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); |
|
| 749 | + $today = date('Y-m-d', current_time('timestamp')); |
|
| 750 | + $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp'))); |
|
| 751 | 751 | |
| 752 | - while ( $posts->have_posts() ) { |
|
| 752 | + while ($posts->have_posts()) { |
|
| 753 | 753 | $posts->the_post(); |
| 754 | 754 | |
| 755 | - $time = get_the_time( 'U' ); |
|
| 756 | - if ( date( 'Y-m-d', $time ) == $today ) { |
|
| 757 | - $relative = __( 'Today' ); |
|
| 758 | - } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { |
|
| 759 | - $relative = __( 'Tomorrow' ); |
|
| 755 | + $time = get_the_time('U'); |
|
| 756 | + if (date('Y-m-d', $time) == $today) { |
|
| 757 | + $relative = __('Today'); |
|
| 758 | + } elseif (date('Y-m-d', $time) == $tomorrow) { |
|
| 759 | + $relative = __('Tomorrow'); |
|
| 760 | 760 | } else { |
| 761 | 761 | /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */ |
| 762 | - $relative = date_i18n( __( 'M jS' ), $time ); |
|
| 762 | + $relative = date_i18n(__('M jS'), $time); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | // Use the post edit link for those who can edit, the permalink otherwise. |
| 766 | - $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink(); |
|
| 766 | + $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink(); |
|
| 767 | 767 | |
| 768 | 768 | /* translators: 1: relative date, 2: time, 3: post edit link or permalink, 4: post title */ |
| 769 | - $format = __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' ); |
|
| 770 | - printf( "<li>$format</li>", $relative, get_the_time(), $recent_post_link, _draft_or_post_title() ); |
|
| 769 | + $format = __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>'); |
|
| 770 | + printf("<li>$format</li>", $relative, get_the_time(), $recent_post_link, _draft_or_post_title()); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | echo '</ul>'; |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @param int $total_items Optional. Number of comments to query. Default 5. |
| 791 | 791 | * @return bool False if no comments were found. True otherwise. |
| 792 | 792 | */ |
| 793 | -function wp_dashboard_recent_comments( $total_items = 5 ) { |
|
| 793 | +function wp_dashboard_recent_comments($total_items = 5) { |
|
| 794 | 794 | // Select all comment types and filter out spam later for better query performance. |
| 795 | 795 | $comments = array(); |
| 796 | 796 | |
@@ -798,34 +798,34 @@ discard block |
||
| 798 | 798 | 'number' => $total_items * 5, |
| 799 | 799 | 'offset' => 0 |
| 800 | 800 | ); |
| 801 | - if ( ! current_user_can( 'edit_posts' ) ) |
|
| 801 | + if ( ! current_user_can('edit_posts')) |
|
| 802 | 802 | $comments_query['status'] = 'approve'; |
| 803 | 803 | |
| 804 | - while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { |
|
| 805 | - if ( ! is_array( $possible ) ) { |
|
| 804 | + while (count($comments) < $total_items && $possible = get_comments($comments_query)) { |
|
| 805 | + if ( ! is_array($possible)) { |
|
| 806 | 806 | break; |
| 807 | 807 | } |
| 808 | - foreach ( $possible as $comment ) { |
|
| 809 | - if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) |
|
| 808 | + foreach ($possible as $comment) { |
|
| 809 | + if ( ! current_user_can('read_post', $comment->comment_post_ID)) |
|
| 810 | 810 | continue; |
| 811 | 811 | $comments[] = $comment; |
| 812 | - if ( count( $comments ) == $total_items ) |
|
| 812 | + if (count($comments) == $total_items) |
|
| 813 | 813 | break 2; |
| 814 | 814 | } |
| 815 | 815 | $comments_query['offset'] += $comments_query['number']; |
| 816 | 816 | $comments_query['number'] = $total_items * 10; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - if ( $comments ) { |
|
| 819 | + if ($comments) { |
|
| 820 | 820 | echo '<div id="latest-comments" class="activity-block">'; |
| 821 | - echo '<h4>' . __( 'Comments' ) . '</h4>'; |
|
| 821 | + echo '<h4>'.__('Comments').'</h4>'; |
|
| 822 | 822 | |
| 823 | 823 | echo '<div id="the-comment-list" data-wp-lists="list:comment">'; |
| 824 | - foreach ( $comments as $comment ) |
|
| 825 | - _wp_dashboard_recent_comments_row( $comment ); |
|
| 824 | + foreach ($comments as $comment) |
|
| 825 | + _wp_dashboard_recent_comments_row($comment); |
|
| 826 | 826 | echo '</div>'; |
| 827 | 827 | |
| 828 | - if ( current_user_can('edit_posts') ) |
|
| 828 | + if (current_user_can('edit_posts')) |
|
| 829 | 829 | _get_list_table('WP_Comments_List_Table')->views(); |
| 830 | 830 | |
| 831 | 831 | wp_comment_reply( -1, false, 'dashboard', false ); |
@@ -845,10 +845,10 @@ discard block |
||
| 845 | 845 | * |
| 846 | 846 | * @param string $widget_id |
| 847 | 847 | */ |
| 848 | -function wp_dashboard_rss_output( $widget_id ) { |
|
| 849 | - $widgets = get_option( 'dashboard_widget_options' ); |
|
| 848 | +function wp_dashboard_rss_output($widget_id) { |
|
| 849 | + $widgets = get_option('dashboard_widget_options'); |
|
| 850 | 850 | echo '<div class="rss-widget">'; |
| 851 | - wp_widget_rss_output( $widgets[ $widget_id ] ); |
|
| 851 | + wp_widget_rss_output($widgets[$widget_id]); |
|
| 852 | 852 | echo "</div>"; |
| 853 | 853 | } |
| 854 | 854 | |
@@ -867,37 +867,37 @@ discard block |
||
| 867 | 867 | * @param array $check_urls RSS feeds |
| 868 | 868 | * @return bool False on failure. True on success. |
| 869 | 869 | */ |
| 870 | -function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { |
|
| 871 | - $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>'; |
|
| 872 | - $doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
| 870 | +function wp_dashboard_cached_rss_widget($widget_id, $callback, $check_urls = array()) { |
|
| 871 | + $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading…').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>'; |
|
| 872 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
| 873 | 873 | |
| 874 | - if ( empty($check_urls) ) { |
|
| 875 | - $widgets = get_option( 'dashboard_widget_options' ); |
|
| 876 | - if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) { |
|
| 874 | + if (empty($check_urls)) { |
|
| 875 | + $widgets = get_option('dashboard_widget_options'); |
|
| 876 | + if (empty($widgets[$widget_id]['url']) && ! $doing_ajax) { |
|
| 877 | 877 | echo $loading; |
| 878 | 878 | return false; |
| 879 | 879 | } |
| 880 | - $check_urls = array( $widgets[$widget_id]['url'] ); |
|
| 880 | + $check_urls = array($widgets[$widget_id]['url']); |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | $locale = get_locale(); |
| 884 | - $cache_key = 'dash_' . md5( $widget_id . '_' . $locale ); |
|
| 885 | - if ( false !== ( $output = get_transient( $cache_key ) ) ) { |
|
| 884 | + $cache_key = 'dash_'.md5($widget_id.'_'.$locale); |
|
| 885 | + if (false !== ($output = get_transient($cache_key))) { |
|
| 886 | 886 | echo $output; |
| 887 | 887 | return true; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - if ( ! $doing_ajax ) { |
|
| 890 | + if ( ! $doing_ajax) { |
|
| 891 | 891 | echo $loading; |
| 892 | 892 | return false; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if ( $callback && is_callable( $callback ) ) { |
|
| 896 | - $args = array_slice( func_get_args(), 3 ); |
|
| 897 | - array_unshift( $args, $widget_id, $check_urls ); |
|
| 895 | + if ($callback && is_callable($callback)) { |
|
| 896 | + $args = array_slice(func_get_args(), 3); |
|
| 897 | + array_unshift($args, $widget_id, $check_urls); |
|
| 898 | 898 | ob_start(); |
| 899 | - call_user_func_array( $callback, $args ); |
|
| 900 | - set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) |
|
| 899 | + call_user_func_array($callback, $args); |
|
| 900 | + set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); // Default lifetime in cache of 12 hours (same as the feeds) |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | return true; |
@@ -915,11 +915,11 @@ discard block |
||
| 915 | 915 | * |
| 916 | 916 | * @param int $widget_control_id Registered Widget ID. |
| 917 | 917 | */ |
| 918 | -function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { |
|
| 918 | +function wp_dashboard_trigger_widget_control($widget_control_id = false) { |
|
| 919 | 919 | global $wp_dashboard_control_callbacks; |
| 920 | 920 | |
| 921 | - if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) { |
|
| 922 | - call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) ); |
|
| 921 | + if (is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id])) { |
|
| 922 | + call_user_func($wp_dashboard_control_callbacks[$widget_control_id], '', array('id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id])); |
|
| 923 | 923 | } |
| 924 | 924 | } |
| 925 | 925 | |
@@ -934,25 +934,25 @@ discard block |
||
| 934 | 934 | * @param string $widget_id |
| 935 | 935 | * @param array $form_inputs |
| 936 | 936 | */ |
| 937 | -function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
|
| 938 | - if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) |
|
| 937 | +function wp_dashboard_rss_control($widget_id, $form_inputs = array()) { |
|
| 938 | + if ( ! $widget_options = get_option('dashboard_widget_options')) |
|
| 939 | 939 | $widget_options = array(); |
| 940 | 940 | |
| 941 | - if ( !isset($widget_options[$widget_id]) ) |
|
| 941 | + if ( ! isset($widget_options[$widget_id])) |
|
| 942 | 942 | $widget_options[$widget_id] = array(); |
| 943 | 943 | |
| 944 | 944 | $number = 1; // Hack to use wp_widget_rss_form() |
| 945 | 945 | $widget_options[$widget_id]['number'] = $number; |
| 946 | 946 | |
| 947 | - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { |
|
| 948 | - $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); |
|
| 949 | - $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); |
|
| 947 | + if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number])) { |
|
| 948 | + $_POST['widget-rss'][$number] = wp_unslash($_POST['widget-rss'][$number]); |
|
| 949 | + $widget_options[$widget_id] = wp_widget_rss_process($_POST['widget-rss'][$number]); |
|
| 950 | 950 | $widget_options[$widget_id]['number'] = $number; |
| 951 | 951 | |
| 952 | 952 | // Title is optional. If black, fill it if possible. |
| 953 | - if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { |
|
| 953 | + if ( ! $widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title'])) { |
|
| 954 | 954 | $rss = fetch_feed($widget_options[$widget_id]['url']); |
| 955 | - if ( is_wp_error($rss) ) { |
|
| 955 | + if (is_wp_error($rss)) { |
|
| 956 | 956 | $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); |
| 957 | 957 | } else { |
| 958 | 958 | $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); |
@@ -960,12 +960,12 @@ discard block |
||
| 960 | 960 | unset($rss); |
| 961 | 961 | } |
| 962 | 962 | } |
| 963 | - update_option( 'dashboard_widget_options', $widget_options ); |
|
| 964 | - $cache_key = 'dash_' . md5( $widget_id ); |
|
| 965 | - delete_transient( $cache_key ); |
|
| 963 | + update_option('dashboard_widget_options', $widget_options); |
|
| 964 | + $cache_key = 'dash_'.md5($widget_id); |
|
| 965 | + delete_transient($cache_key); |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); |
|
| 968 | + wp_widget_rss_form($widget_options[$widget_id], $form_inputs); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | /** |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | * |
| 985 | 985 | * @param string $link The widget's primary link URL. |
| 986 | 986 | */ |
| 987 | - 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ), |
|
| 987 | + 'link' => apply_filters('dashboard_primary_link', __('http://wordpress.org/news/')), |
|
| 988 | 988 | |
| 989 | 989 | /** |
| 990 | 990 | * Filter the primary feed URL for the 'WordPress News' dashboard widget. |
@@ -993,7 +993,7 @@ discard block |
||
| 993 | 993 | * |
| 994 | 994 | * @param string $url The widget's primary feed URL. |
| 995 | 995 | */ |
| 996 | - 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), |
|
| 996 | + 'url' => apply_filters('dashboard_primary_feed', __('http://wordpress.org/news/feed/')), |
|
| 997 | 997 | |
| 998 | 998 | /** |
| 999 | 999 | * Filter the primary link title for the 'WordPress News' dashboard widget. |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | * |
| 1003 | 1003 | * @param string $title Title attribute for the widget's primary link. |
| 1004 | 1004 | */ |
| 1005 | - 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), |
|
| 1005 | + 'title' => apply_filters('dashboard_primary_title', __('WordPress Blog')), |
|
| 1006 | 1006 | 'items' => 1, |
| 1007 | 1007 | 'show_summary' => 1, |
| 1008 | 1008 | 'show_author' => 0, |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | * |
| 1018 | 1018 | * @param string $link The widget's secondary link URL. |
| 1019 | 1019 | */ |
| 1020 | - 'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ), |
|
| 1020 | + 'link' => apply_filters('dashboard_secondary_link', __('https://planet.wordpress.org/')), |
|
| 1021 | 1021 | |
| 1022 | 1022 | /** |
| 1023 | 1023 | * Filter the secondary feed URL for the 'WordPress News' dashboard widget. |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | * |
| 1027 | 1027 | * @param string $url The widget's secondary feed URL. |
| 1028 | 1028 | */ |
| 1029 | - 'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ), |
|
| 1029 | + 'url' => apply_filters('dashboard_secondary_feed', __('https://planet.wordpress.org/feed/')), |
|
| 1030 | 1030 | |
| 1031 | 1031 | /** |
| 1032 | 1032 | * Filter the secondary link title for the 'WordPress News' dashboard widget. |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | * |
| 1036 | 1036 | * @param string $title Title attribute for the widget's secondary link. |
| 1037 | 1037 | */ |
| 1038 | - 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), |
|
| 1038 | + 'title' => apply_filters('dashboard_secondary_title', __('Other WordPress News')), |
|
| 1039 | 1039 | 'items' => 3, |
| 1040 | 1040 | 'show_summary' => 0, |
| 1041 | 1041 | 'show_author' => 0, |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | ) |
| 1044 | 1044 | ); |
| 1045 | 1045 | |
| 1046 | - if ( ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) ) { |
|
| 1046 | + if (( ! is_multisite() && is_blog_admin() && current_user_can('install_plugins')) || (is_network_admin() && current_user_can('manage_network_plugins') && current_user_can('install_plugins'))) { |
|
| 1047 | 1047 | $feeds['plugins'] = array( |
| 1048 | 1048 | 'link' => '', |
| 1049 | 1049 | 'url' => array( |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | ); |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds ); |
|
| 1060 | + wp_dashboard_cached_rss_widget('dashboard_primary', 'wp_dashboard_primary_output', $feeds); |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | /** |
@@ -1068,14 +1068,14 @@ discard block |
||
| 1068 | 1068 | * @param string $widget_id Widget ID. |
| 1069 | 1069 | * @param array $feeds Array of RSS feeds. |
| 1070 | 1070 | */ |
| 1071 | -function wp_dashboard_primary_output( $widget_id, $feeds ) { |
|
| 1072 | - foreach( $feeds as $type => $args ) { |
|
| 1071 | +function wp_dashboard_primary_output($widget_id, $feeds) { |
|
| 1072 | + foreach ($feeds as $type => $args) { |
|
| 1073 | 1073 | $args['type'] = $type; |
| 1074 | 1074 | echo '<div class="rss-widget">'; |
| 1075 | - if ( $type === 'plugins' ) { |
|
| 1076 | - wp_dashboard_plugins_output( $args['url'], $args ); |
|
| 1075 | + if ($type === 'plugins') { |
|
| 1076 | + wp_dashboard_plugins_output($args['url'], $args); |
|
| 1077 | 1077 | } else { |
| 1078 | - wp_widget_rss_output( $args['url'], $args ); |
|
| 1078 | + wp_widget_rss_output($args['url'], $args); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | echo "</div>"; |
| 1081 | 1081 | } |
@@ -1086,47 +1086,47 @@ discard block |
||
| 1086 | 1086 | * |
| 1087 | 1087 | * @since 2.5.0 |
| 1088 | 1088 | */ |
| 1089 | -function wp_dashboard_plugins_output( $rss, $args = array() ) { |
|
| 1089 | +function wp_dashboard_plugins_output($rss, $args = array()) { |
|
| 1090 | 1090 | // Plugin feeds plus link to install them |
| 1091 | - $popular = fetch_feed( $args['url']['popular'] ); |
|
| 1091 | + $popular = fetch_feed($args['url']['popular']); |
|
| 1092 | 1092 | |
| 1093 | - if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) { |
|
| 1094 | - $plugin_slugs = array_keys( get_plugins() ); |
|
| 1095 | - set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS ); |
|
| 1093 | + if (false === $plugin_slugs = get_transient('plugin_slugs')) { |
|
| 1094 | + $plugin_slugs = array_keys(get_plugins()); |
|
| 1095 | + set_transient('plugin_slugs', $plugin_slugs, DAY_IN_SECONDS); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | 1098 | echo '<ul>'; |
| 1099 | 1099 | |
| 1100 | - foreach ( array( $popular ) as $feed ) { |
|
| 1101 | - if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) |
|
| 1100 | + foreach (array($popular) as $feed) { |
|
| 1101 | + if (is_wp_error($feed) || ! $feed->get_item_quantity()) |
|
| 1102 | 1102 | continue; |
| 1103 | 1103 | |
| 1104 | 1104 | $items = $feed->get_items(0, 5); |
| 1105 | 1105 | |
| 1106 | 1106 | // Pick a random, non-installed plugin |
| 1107 | - while ( true ) { |
|
| 1107 | + while (true) { |
|
| 1108 | 1108 | // Abort this foreach loop iteration if there's no plugins left of this type |
| 1109 | - if ( 0 == count($items) ) |
|
| 1109 | + if (0 == count($items)) |
|
| 1110 | 1110 | continue 2; |
| 1111 | 1111 | |
| 1112 | 1112 | $item_key = array_rand($items); |
| 1113 | 1113 | $item = $items[$item_key]; |
| 1114 | 1114 | |
| 1115 | - list($link, $frag) = explode( '#', $item->get_link() ); |
|
| 1115 | + list($link, $frag) = explode('#', $item->get_link()); |
|
| 1116 | 1116 | |
| 1117 | 1117 | $link = esc_url($link); |
| 1118 | - if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) |
|
| 1118 | + if (preg_match('|/([^/]+?)/?$|', $link, $matches)) |
|
| 1119 | 1119 | $slug = $matches[1]; |
| 1120 | 1120 | else { |
| 1121 | - unset( $items[$item_key] ); |
|
| 1121 | + unset($items[$item_key]); |
|
| 1122 | 1122 | continue; |
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | // Is this random plugin's slug already installed? If so, try again. |
| 1126 | - reset( $plugin_slugs ); |
|
| 1127 | - foreach ( $plugin_slugs as $plugin_slug ) { |
|
| 1128 | - if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) { |
|
| 1129 | - unset( $items[$item_key] ); |
|
| 1126 | + reset($plugin_slugs); |
|
| 1127 | + foreach ($plugin_slugs as $plugin_slug) { |
|
| 1128 | + if ($slug == substr($plugin_slug, 0, strlen($slug))) { |
|
| 1129 | + unset($items[$item_key]); |
|
| 1130 | 1130 | continue 2; |
| 1131 | 1131 | } |
| 1132 | 1132 | } |
@@ -1136,19 +1136,19 @@ discard block |
||
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | // Eliminate some common badly formed plugin descriptions |
| 1139 | - while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) |
|
| 1139 | + while ((null !== $item_key = array_rand($items)) && false !== strpos($items[$item_key]->get_description(), 'Plugin Name:')) |
|
| 1140 | 1140 | unset($items[$item_key]); |
| 1141 | 1141 | |
| 1142 | - if ( !isset($items[$item_key]) ) |
|
| 1142 | + if ( ! isset($items[$item_key])) |
|
| 1143 | 1143 | continue; |
| 1144 | 1144 | |
| 1145 | - $title = esc_html( $item->get_title() ); |
|
| 1145 | + $title = esc_html($item->get_title()); |
|
| 1146 | 1146 | |
| 1147 | - $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800'; |
|
| 1148 | - echo "<li class='dashboard-news-plugin'><span>" . __( 'Popular Plugin' ) . ":</span> <a href='$link' class='dashboard-news-plugin-link'>$title</a> <span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span></li>"; |
|
| 1147 | + $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin='.$slug, 'install-plugin_'.$slug).'&TB_iframe=true&width=600&height=800'; |
|
| 1148 | + echo "<li class='dashboard-news-plugin'><span>".__('Popular Plugin').":</span> <a href='$link' class='dashboard-news-plugin-link'>$title</a> <span>(<a href='$ilink' class='thickbox' title='$title'>".__('Install')."</a>)</span></li>"; |
|
| 1149 | 1149 | |
| 1150 | 1150 | $feed->__destruct(); |
| 1151 | - unset( $feed ); |
|
| 1151 | + unset($feed); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | echo '</ul>'; |
@@ -1164,47 +1164,47 @@ discard block |
||
| 1164 | 1164 | * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled. |
| 1165 | 1165 | */ |
| 1166 | 1166 | function wp_dashboard_quota() { |
| 1167 | - if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) |
|
| 1167 | + if ( ! is_multisite() || ! current_user_can('upload_files') || get_site_option('upload_space_check_disabled')) |
|
| 1168 | 1168 | return true; |
| 1169 | 1169 | |
| 1170 | 1170 | $quota = get_space_allowed(); |
| 1171 | 1171 | $used = get_space_used(); |
| 1172 | 1172 | |
| 1173 | - if ( $used > $quota ) |
|
| 1173 | + if ($used > $quota) |
|
| 1174 | 1174 | $percentused = '100'; |
| 1175 | 1175 | else |
| 1176 | - $percentused = ( $used / $quota ) * 100; |
|
| 1177 | - $used_class = ( $percentused >= 70 ) ? ' warning' : ''; |
|
| 1178 | - $used = round( $used, 2 ); |
|
| 1179 | - $percentused = number_format( $percentused ); |
|
| 1176 | + $percentused = ($used / $quota) * 100; |
|
| 1177 | + $used_class = ($percentused >= 70) ? ' warning' : ''; |
|
| 1178 | + $used = round($used, 2); |
|
| 1179 | + $percentused = number_format($percentused); |
|
| 1180 | 1180 | |
| 1181 | 1181 | ?> |
| 1182 | - <h4 class="mu-storage"><?php _e( 'Storage Space' ); ?></h4> |
|
| 1182 | + <h4 class="mu-storage"><?php _e('Storage Space'); ?></h4> |
|
| 1183 | 1183 | <div class="mu-storage"> |
| 1184 | 1184 | <ul> |
| 1185 | 1185 | <li class="storage-count"> |
| 1186 | 1186 | <?php $text = sprintf( |
| 1187 | 1187 | /* translators: number of megabytes */ |
| 1188 | - __( '%s MB Space Allowed' ), |
|
| 1189 | - number_format_i18n( $quota ) |
|
| 1188 | + __('%s MB Space Allowed'), |
|
| 1189 | + number_format_i18n($quota) |
|
| 1190 | 1190 | ); |
| 1191 | 1191 | printf( |
| 1192 | 1192 | '<a href="%1$s" title="%2$s">%3$s</a>', |
| 1193 | - esc_url( admin_url( 'upload.php' ) ), |
|
| 1194 | - __( 'Manage Uploads' ), |
|
| 1193 | + esc_url(admin_url('upload.php')), |
|
| 1194 | + __('Manage Uploads'), |
|
| 1195 | 1195 | $text |
| 1196 | 1196 | ); ?> |
| 1197 | 1197 | </li><li class="storage-count <?php echo $used_class; ?>"> |
| 1198 | 1198 | <?php $text = sprintf( |
| 1199 | 1199 | /* translators: 1: number of megabytes, 2: percentage */ |
| 1200 | - __( '%1$s MB (%2$s%%) Space Used' ), |
|
| 1201 | - number_format_i18n( $used, 2 ), |
|
| 1200 | + __('%1$s MB (%2$s%%) Space Used'), |
|
| 1201 | + number_format_i18n($used, 2), |
|
| 1202 | 1202 | $percentused |
| 1203 | 1203 | ); |
| 1204 | 1204 | printf( |
| 1205 | 1205 | '<a href="%1$s" title="%2$s" class="musublink">%3$s</a>', |
| 1206 | - esc_url( admin_url( 'upload.php' ) ), |
|
| 1207 | - __( 'Manage Uploads' ), |
|
| 1206 | + esc_url(admin_url('upload.php')), |
|
| 1207 | + __('Manage Uploads'), |
|
| 1208 | 1208 | $text |
| 1209 | 1209 | ); ?> |
| 1210 | 1210 | </li> |
@@ -1218,29 +1218,29 @@ discard block |
||
| 1218 | 1218 | $notice = ''; |
| 1219 | 1219 | $response = wp_check_browser_version(); |
| 1220 | 1220 | |
| 1221 | - if ( $response ) { |
|
| 1222 | - if ( $response['insecure'] ) { |
|
| 1223 | - $msg = sprintf( __( "It looks like you're using an insecure version of <a href='%s'>%s</a>. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) ); |
|
| 1221 | + if ($response) { |
|
| 1222 | + if ($response['insecure']) { |
|
| 1223 | + $msg = sprintf(__("It looks like you're using an insecure version of <a href='%s'>%s</a>. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser."), esc_attr($response['update_url']), esc_html($response['name'])); |
|
| 1224 | 1224 | } else { |
| 1225 | - $msg = sprintf( __( "It looks like you're using an old version of <a href='%s'>%s</a>. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) ); |
|
| 1225 | + $msg = sprintf(__("It looks like you're using an old version of <a href='%s'>%s</a>. For the best WordPress experience, please update your browser."), esc_attr($response['update_url']), esc_html($response['name'])); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | $browser_nag_class = ''; |
| 1229 | - if ( !empty( $response['img_src'] ) ) { |
|
| 1230 | - $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src']; |
|
| 1229 | + if ( ! empty($response['img_src'])) { |
|
| 1230 | + $img_src = (is_ssl() && ! empty($response['img_src_ssl'])) ? $response['img_src_ssl'] : $response['img_src']; |
|
| 1231 | 1231 | |
| 1232 | - $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>'; |
|
| 1232 | + $notice .= '<div class="alignright browser-icon"><a href="'.esc_attr($response['update_url']).'"><img src="'.esc_attr($img_src).'" alt="" /></a></div>'; |
|
| 1233 | 1233 | $browser_nag_class = ' has-browser-icon'; |
| 1234 | 1234 | } |
| 1235 | 1235 | $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; |
| 1236 | 1236 | |
| 1237 | 1237 | $browsehappy = 'http://browsehappy.com/'; |
| 1238 | 1238 | $locale = get_locale(); |
| 1239 | - if ( 'en_US' !== $locale ) |
|
| 1240 | - $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
|
| 1239 | + if ('en_US' !== $locale) |
|
| 1240 | + $browsehappy = add_query_arg('locale', $locale, $browsehappy); |
|
| 1241 | 1241 | |
| 1242 | - $notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>'; |
|
| 1243 | - $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>'; |
|
| 1242 | + $notice .= '<p>'.sprintf(__('<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>'), esc_attr($response['update_url']), esc_html($response['name']), esc_url($browsehappy)).'</p>'; |
|
| 1243 | + $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">'.__('Dismiss').'</a></p>'; |
|
| 1244 | 1244 | $notice .= '<div class="clear"></div>'; |
| 1245 | 1245 | } |
| 1246 | 1246 | |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | * @param string $notice The notice content. |
| 1253 | 1253 | * @param array $response An array containing web browser information. |
| 1254 | 1254 | */ |
| 1255 | - echo apply_filters( 'browse-happy-notice', $notice, $response ); |
|
| 1255 | + echo apply_filters('browse-happy-notice', $notice, $response); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | /** |
@@ -1261,10 +1261,10 @@ discard block |
||
| 1261 | 1261 | * @param array $classes |
| 1262 | 1262 | * @return array |
| 1263 | 1263 | */ |
| 1264 | -function dashboard_browser_nag_class( $classes ) { |
|
| 1264 | +function dashboard_browser_nag_class($classes) { |
|
| 1265 | 1265 | $response = wp_check_browser_version(); |
| 1266 | 1266 | |
| 1267 | - if ( $response && $response['insecure'] ) |
|
| 1267 | + if ($response && $response['insecure']) |
|
| 1268 | 1268 | $classes[] = 'browser-insecure'; |
| 1269 | 1269 | |
| 1270 | 1270 | return $classes; |
@@ -1280,22 +1280,22 @@ discard block |
||
| 1280 | 1280 | * @return array|bool False on failure, array of browser data on success. |
| 1281 | 1281 | */ |
| 1282 | 1282 | function wp_check_browser_version() { |
| 1283 | - if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) |
|
| 1283 | + if (empty($_SERVER['HTTP_USER_AGENT'])) |
|
| 1284 | 1284 | return false; |
| 1285 | 1285 | |
| 1286 | - $key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
|
| 1286 | + $key = md5($_SERVER['HTTP_USER_AGENT']); |
|
| 1287 | 1287 | |
| 1288 | - if ( false === ($response = get_site_transient('browser_' . $key) ) ) { |
|
| 1288 | + if (false === ($response = get_site_transient('browser_'.$key))) { |
|
| 1289 | 1289 | global $wp_version; |
| 1290 | 1290 | |
| 1291 | 1291 | $options = array( |
| 1292 | - 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), |
|
| 1293 | - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() |
|
| 1292 | + 'body' => array('useragent' => $_SERVER['HTTP_USER_AGENT']), |
|
| 1293 | + 'user-agent' => 'WordPress/'.$wp_version.'; '.home_url() |
|
| 1294 | 1294 | ); |
| 1295 | 1295 | |
| 1296 | - $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options ); |
|
| 1296 | + $response = wp_remote_post('http://api.wordpress.org/core/browse-happy/1.1/', $options); |
|
| 1297 | 1297 | |
| 1298 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
| 1298 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) |
|
| 1299 | 1299 | return false; |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1309,12 +1309,12 @@ discard block |
||
| 1309 | 1309 | * 'img_src' - string - An image representing the browser |
| 1310 | 1310 | * 'img_src_ssl' - string - An image (over SSL) representing the browser |
| 1311 | 1311 | */ |
| 1312 | - $response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 1312 | + $response = json_decode(wp_remote_retrieve_body($response), true); |
|
| 1313 | 1313 | |
| 1314 | - if ( ! is_array( $response ) ) |
|
| 1314 | + if ( ! is_array($response)) |
|
| 1315 | 1315 | return false; |
| 1316 | 1316 | |
| 1317 | - set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); |
|
| 1317 | + set_site_transient('browser_'.$key, $response, WEEK_IN_SECONDS); |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | return $response; |
@@ -1333,55 +1333,55 @@ discard block |
||
| 1333 | 1333 | function wp_welcome_panel() { |
| 1334 | 1334 | ?> |
| 1335 | 1335 | <div class="welcome-panel-content"> |
| 1336 | - <h3><?php _e( 'Welcome to WordPress!' ); ?></h3> |
|
| 1337 | - <p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p> |
|
| 1336 | + <h3><?php _e('Welcome to WordPress!'); ?></h3> |
|
| 1337 | + <p class="about-description"><?php _e('We’ve assembled some links to get you started:'); ?></p> |
|
| 1338 | 1338 | <div class="welcome-panel-column-container"> |
| 1339 | 1339 | <div class="welcome-panel-column"> |
| 1340 | - <?php if ( current_user_can( 'customize' ) ): ?> |
|
| 1341 | - <h4><?php _e( 'Get Started' ); ?></h4> |
|
| 1342 | - <a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
|
| 1340 | + <?php if (current_user_can('customize')): ?> |
|
| 1341 | + <h4><?php _e('Get Started'); ?></h4> |
|
| 1342 | + <a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e('Customize Your Site'); ?></a> |
|
| 1343 | 1343 | <?php endif; ?> |
| 1344 | - <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
|
| 1345 | - <?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?> |
|
| 1346 | - <p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), admin_url( 'themes.php' ) ); ?></p> |
|
| 1344 | + <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url('themes.php'); ?>"><?php _e('Customize Your Site'); ?></a> |
|
| 1345 | + <?php if (current_user_can('install_themes') || (current_user_can('switch_themes') && count(wp_get_themes(array('allowed' => true))) > 1)) : ?> |
|
| 1346 | + <p class="hide-if-no-customize"><?php printf(__('or, <a href="%s">change your theme completely</a>'), admin_url('themes.php')); ?></p> |
|
| 1347 | 1347 | <?php endif; ?> |
| 1348 | 1348 | </div> |
| 1349 | 1349 | <div class="welcome-panel-column"> |
| 1350 | - <h4><?php _e( 'Next Steps' ); ?></h4> |
|
| 1350 | + <h4><?php _e('Next Steps'); ?></h4> |
|
| 1351 | 1351 | <ul> |
| 1352 | - <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?> |
|
| 1353 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
|
| 1354 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
| 1355 | - <?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?> |
|
| 1356 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
|
| 1357 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
| 1358 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
| 1352 | + <?php if ('page' == get_option('show_on_front') && ! get_option('page_for_posts')) : ?> |
|
| 1353 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-edit-page">'.__('Edit your front page').'</a>', get_edit_post_link(get_option('page_on_front'))); ?></li> |
|
| 1354 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-add-page">'.__('Add additional pages').'</a>', admin_url('post-new.php?post_type=page')); ?></li> |
|
| 1355 | + <?php elseif ('page' == get_option('show_on_front')) : ?> |
|
| 1356 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-edit-page">'.__('Edit your front page').'</a>', get_edit_post_link(get_option('page_on_front'))); ?></li> |
|
| 1357 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-add-page">'.__('Add additional pages').'</a>', admin_url('post-new.php?post_type=page')); ?></li> |
|
| 1358 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-write-blog">'.__('Add a blog post').'</a>', admin_url('post-new.php')); ?></li> |
|
| 1359 | 1359 | <?php else : ?> |
| 1360 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
| 1361 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
| 1360 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-write-blog">'.__('Write your first blog post').'</a>', admin_url('post-new.php')); ?></li> |
|
| 1361 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-add-page">'.__('Add an About page').'</a>', admin_url('post-new.php?post_type=page')); ?></li> |
|
| 1362 | 1362 | <?php endif; ?> |
| 1363 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li> |
|
| 1363 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-view-site">'.__('View your site').'</a>', home_url('/')); ?></li> |
|
| 1364 | 1364 | </ul> |
| 1365 | 1365 | </div> |
| 1366 | 1366 | <div class="welcome-panel-column welcome-panel-last"> |
| 1367 | - <h4><?php _e( 'More Actions' ); ?></h4> |
|
| 1367 | + <h4><?php _e('More Actions'); ?></h4> |
|
| 1368 | 1368 | <ul> |
| 1369 | - <?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?> |
|
| 1369 | + <?php if (current_theme_supports('widgets') || current_theme_supports('menus')) : ?> |
|
| 1370 | 1370 | <li><div class="welcome-icon welcome-widgets-menus"><?php |
| 1371 | - if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) { |
|
| 1372 | - printf( __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ), |
|
| 1373 | - admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); |
|
| 1374 | - } elseif ( current_theme_supports( 'widgets' ) ) { |
|
| 1375 | - echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>'; |
|
| 1371 | + if (current_theme_supports('widgets') && current_theme_supports('menus')) { |
|
| 1372 | + printf(__('Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>'), |
|
| 1373 | + admin_url('widgets.php'), admin_url('nav-menus.php')); |
|
| 1374 | + } elseif (current_theme_supports('widgets')) { |
|
| 1375 | + echo '<a href="'.admin_url('widgets.php').'">'.__('Manage widgets').'</a>'; |
|
| 1376 | 1376 | } else { |
| 1377 | - echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>'; |
|
| 1377 | + echo '<a href="'.admin_url('nav-menus.php').'">'.__('Manage menus').'</a>'; |
|
| 1378 | 1378 | } |
| 1379 | 1379 | ?></div></li> |
| 1380 | 1380 | <?php endif; ?> |
| 1381 | - <?php if ( current_user_can( 'manage_options' ) ) : ?> |
|
| 1382 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li> |
|
| 1381 | + <?php if (current_user_can('manage_options')) : ?> |
|
| 1382 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-comments">'.__('Turn comments on or off').'</a>', admin_url('options-discussion.php')); ?></li> |
|
| 1383 | 1383 | <?php endif; ?> |
| 1384 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li> |
|
| 1384 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-learn-more">'.__('Learn more about getting started').'</a>', __('https://codex.wordpress.org/First_Steps_With_WordPress')); ?></li> |
|
| 1385 | 1385 | </ul> |
| 1386 | 1386 | </div> |
| 1387 | 1387 | </div> |
@@ -28,18 +28,21 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | if ( $response && $response['upgrade'] ) { |
| 30 | 30 | add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); |
| 31 | - if ( $response['insecure'] ) |
|
| 32 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
|
| 33 | - else |
|
| 34 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
|
| 31 | + if ( $response['insecure'] ) { |
|
| 32 | + wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
|
| 33 | + } else { |
|
| 34 | + wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | // Right Now |
| 38 | - if ( is_blog_admin() && current_user_can('edit_posts') ) |
|
| 39 | - wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
|
| 39 | + if ( is_blog_admin() && current_user_can('edit_posts') ) { |
|
| 40 | + wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | - if ( is_network_admin() ) |
|
| 42 | - wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
|
| 43 | + if ( is_network_admin() ) { |
|
| 44 | + wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | // Activity Widget |
| 45 | 48 | if ( is_blog_admin() ) { |
@@ -158,12 +161,14 @@ discard block |
||
| 158 | 161 | $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); |
| 159 | 162 | |
| 160 | 163 | $location = 'normal'; |
| 161 | - if ( in_array($widget_id, $side_widgets) ) |
|
| 162 | - $location = 'side'; |
|
| 164 | + if ( in_array($widget_id, $side_widgets) ) { |
|
| 165 | + $location = 'side'; |
|
| 166 | + } |
|
| 163 | 167 | |
| 164 | 168 | $priority = 'core'; |
| 165 | - if ( 'dashboard_browser_nag' === $widget_id ) |
|
| 166 | - $priority = 'high'; |
|
| 169 | + if ( 'dashboard_browser_nag' === $widget_id ) { |
|
| 170 | + $priority = 'high'; |
|
| 171 | + } |
|
| 167 | 172 | |
| 168 | 173 | add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); |
| 169 | 174 | } |
@@ -360,10 +365,12 @@ discard block |
||
| 360 | 365 | */ |
| 361 | 366 | function wp_network_dashboard_right_now() { |
| 362 | 367 | $actions = array(); |
| 363 | - if ( current_user_can('create_sites') ) |
|
| 364 | - $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>'; |
|
| 365 | - if ( current_user_can('create_users') ) |
|
| 366 | - $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>'; |
|
| 368 | + if ( current_user_can('create_sites') ) { |
|
| 369 | + $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>'; |
|
| 370 | + } |
|
| 371 | + if ( current_user_can('create_users') ) { |
|
| 372 | + $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>'; |
|
| 373 | + } |
|
| 367 | 374 | |
| 368 | 375 | $c_users = get_user_count(); |
| 369 | 376 | $c_blogs = get_blog_count(); |
@@ -460,8 +467,10 @@ discard block |
||
| 460 | 467 | $post = get_default_post_to_edit( 'post' , true); |
| 461 | 468 | $user_id = get_current_user_id(); |
| 462 | 469 | // Don't create an option if this is a super admin who does not belong to this site. |
| 463 | - if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) |
|
| 464 | - update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
|
| 470 | + if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) { |
|
| 471 | + update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); |
|
| 472 | + } |
|
| 473 | + // Save post_ID |
|
| 465 | 474 | } |
| 466 | 475 | |
| 467 | 476 | $post_ID = (int) $post->ID; |
@@ -592,10 +601,11 @@ discard block |
||
| 592 | 601 | $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>'; |
| 593 | 602 | $actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; |
| 594 | 603 | $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
| 595 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 596 | - $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; |
|
| 597 | - else |
|
| 598 | - $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; |
|
| 604 | + if ( !EMPTY_TRASH_DAYS ) { |
|
| 605 | + $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; |
|
| 606 | + } else { |
|
| 607 | + $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; |
|
| 608 | + } |
|
| 599 | 609 | |
| 600 | 610 | /** |
| 601 | 611 | * Filter the action links displayed for each comment in the 'Recent Comments' |
@@ -616,8 +626,9 @@ discard block |
||
| 616 | 626 | ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
| 617 | 627 | |
| 618 | 628 | // Reply and quickedit need a hide-if-no-js span |
| 619 | - if ( 'reply' == $action || 'quickedit' == $action ) |
|
| 620 | - $action .= ' hide-if-no-js'; |
|
| 629 | + if ( 'reply' == $action || 'quickedit' == $action ) { |
|
| 630 | + $action .= ' hide-if-no-js'; |
|
| 631 | + } |
|
| 621 | 632 | |
| 622 | 633 | $actions_string .= "<span class='$action'>$sep$link</span>"; |
| 623 | 634 | } |
@@ -638,10 +649,12 @@ discard block |
||
| 638 | 649 | </h4> |
| 639 | 650 | |
| 640 | 651 | <?php |
| 641 | - else : |
|
| 652 | + else { |
|
| 653 | + : |
|
| 642 | 654 | switch ( $comment->comment_type ) { |
| 643 | 655 | case 'pingback' : |
| 644 | 656 | $type = __( 'Pingback' ); |
| 657 | + } |
|
| 645 | 658 | break; |
| 646 | 659 | case 'trackback' : |
| 647 | 660 | $type = __( 'Trackback' ); |
@@ -798,19 +811,22 @@ discard block |
||
| 798 | 811 | 'number' => $total_items * 5, |
| 799 | 812 | 'offset' => 0 |
| 800 | 813 | ); |
| 801 | - if ( ! current_user_can( 'edit_posts' ) ) |
|
| 802 | - $comments_query['status'] = 'approve'; |
|
| 814 | + if ( ! current_user_can( 'edit_posts' ) ) { |
|
| 815 | + $comments_query['status'] = 'approve'; |
|
| 816 | + } |
|
| 803 | 817 | |
| 804 | 818 | while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { |
| 805 | 819 | if ( ! is_array( $possible ) ) { |
| 806 | 820 | break; |
| 807 | 821 | } |
| 808 | 822 | foreach ( $possible as $comment ) { |
| 809 | - if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) |
|
| 810 | - continue; |
|
| 823 | + if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) { |
|
| 824 | + continue; |
|
| 825 | + } |
|
| 811 | 826 | $comments[] = $comment; |
| 812 | - if ( count( $comments ) == $total_items ) |
|
| 813 | - break 2; |
|
| 827 | + if ( count( $comments ) == $total_items ) { |
|
| 828 | + break 2; |
|
| 829 | + } |
|
| 814 | 830 | } |
| 815 | 831 | $comments_query['offset'] += $comments_query['number']; |
| 816 | 832 | $comments_query['number'] = $total_items * 10; |
@@ -821,12 +837,14 @@ discard block |
||
| 821 | 837 | echo '<h4>' . __( 'Comments' ) . '</h4>'; |
| 822 | 838 | |
| 823 | 839 | echo '<div id="the-comment-list" data-wp-lists="list:comment">'; |
| 824 | - foreach ( $comments as $comment ) |
|
| 825 | - _wp_dashboard_recent_comments_row( $comment ); |
|
| 840 | + foreach ( $comments as $comment ) { |
|
| 841 | + _wp_dashboard_recent_comments_row( $comment ); |
|
| 842 | + } |
|
| 826 | 843 | echo '</div>'; |
| 827 | 844 | |
| 828 | - if ( current_user_can('edit_posts') ) |
|
| 829 | - _get_list_table('WP_Comments_List_Table')->views(); |
|
| 845 | + if ( current_user_can('edit_posts') ) { |
|
| 846 | + _get_list_table('WP_Comments_List_Table')->views(); |
|
| 847 | + } |
|
| 830 | 848 | |
| 831 | 849 | wp_comment_reply( -1, false, 'dashboard', false ); |
| 832 | 850 | wp_comment_trashnotice(); |
@@ -935,11 +953,13 @@ discard block |
||
| 935 | 953 | * @param array $form_inputs |
| 936 | 954 | */ |
| 937 | 955 | function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
| 938 | - if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) |
|
| 939 | - $widget_options = array(); |
|
| 956 | + if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) { |
|
| 957 | + $widget_options = array(); |
|
| 958 | + } |
|
| 940 | 959 | |
| 941 | - if ( !isset($widget_options[$widget_id]) ) |
|
| 942 | - $widget_options[$widget_id] = array(); |
|
| 960 | + if ( !isset($widget_options[$widget_id]) ) { |
|
| 961 | + $widget_options[$widget_id] = array(); |
|
| 962 | + } |
|
| 943 | 963 | |
| 944 | 964 | $number = 1; // Hack to use wp_widget_rss_form() |
| 945 | 965 | $widget_options[$widget_id]['number'] = $number; |
@@ -1098,16 +1118,18 @@ discard block |
||
| 1098 | 1118 | echo '<ul>'; |
| 1099 | 1119 | |
| 1100 | 1120 | foreach ( array( $popular ) as $feed ) { |
| 1101 | - if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) |
|
| 1102 | - continue; |
|
| 1121 | + if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) { |
|
| 1122 | + continue; |
|
| 1123 | + } |
|
| 1103 | 1124 | |
| 1104 | 1125 | $items = $feed->get_items(0, 5); |
| 1105 | 1126 | |
| 1106 | 1127 | // Pick a random, non-installed plugin |
| 1107 | 1128 | while ( true ) { |
| 1108 | 1129 | // Abort this foreach loop iteration if there's no plugins left of this type |
| 1109 | - if ( 0 == count($items) ) |
|
| 1110 | - continue 2; |
|
| 1130 | + if ( 0 == count($items) ) { |
|
| 1131 | + continue 2; |
|
| 1132 | + } |
|
| 1111 | 1133 | |
| 1112 | 1134 | $item_key = array_rand($items); |
| 1113 | 1135 | $item = $items[$item_key]; |
@@ -1115,9 +1137,9 @@ discard block |
||
| 1115 | 1137 | list($link, $frag) = explode( '#', $item->get_link() ); |
| 1116 | 1138 | |
| 1117 | 1139 | $link = esc_url($link); |
| 1118 | - if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) |
|
| 1119 | - $slug = $matches[1]; |
|
| 1120 | - else { |
|
| 1140 | + if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) { |
|
| 1141 | + $slug = $matches[1]; |
|
| 1142 | + } else { |
|
| 1121 | 1143 | unset( $items[$item_key] ); |
| 1122 | 1144 | continue; |
| 1123 | 1145 | } |
@@ -1136,11 +1158,13 @@ discard block |
||
| 1136 | 1158 | } |
| 1137 | 1159 | |
| 1138 | 1160 | // Eliminate some common badly formed plugin descriptions |
| 1139 | - while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) |
|
| 1140 | - unset($items[$item_key]); |
|
| 1161 | + while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) { |
|
| 1162 | + unset($items[$item_key]); |
|
| 1163 | + } |
|
| 1141 | 1164 | |
| 1142 | - if ( !isset($items[$item_key]) ) |
|
| 1143 | - continue; |
|
| 1165 | + if ( !isset($items[$item_key]) ) { |
|
| 1166 | + continue; |
|
| 1167 | + } |
|
| 1144 | 1168 | |
| 1145 | 1169 | $title = esc_html( $item->get_title() ); |
| 1146 | 1170 | |
@@ -1164,16 +1188,18 @@ discard block |
||
| 1164 | 1188 | * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled. |
| 1165 | 1189 | */ |
| 1166 | 1190 | function wp_dashboard_quota() { |
| 1167 | - if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) |
|
| 1168 | - return true; |
|
| 1191 | + if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) { |
|
| 1192 | + return true; |
|
| 1193 | + } |
|
| 1169 | 1194 | |
| 1170 | 1195 | $quota = get_space_allowed(); |
| 1171 | 1196 | $used = get_space_used(); |
| 1172 | 1197 | |
| 1173 | - if ( $used > $quota ) |
|
| 1174 | - $percentused = '100'; |
|
| 1175 | - else |
|
| 1176 | - $percentused = ( $used / $quota ) * 100; |
|
| 1198 | + if ( $used > $quota ) { |
|
| 1199 | + $percentused = '100'; |
|
| 1200 | + } else { |
|
| 1201 | + $percentused = ( $used / $quota ) * 100; |
|
| 1202 | + } |
|
| 1177 | 1203 | $used_class = ( $percentused >= 70 ) ? ' warning' : ''; |
| 1178 | 1204 | $used = round( $used, 2 ); |
| 1179 | 1205 | $percentused = number_format( $percentused ); |
@@ -1236,8 +1262,9 @@ discard block |
||
| 1236 | 1262 | |
| 1237 | 1263 | $browsehappy = 'http://browsehappy.com/'; |
| 1238 | 1264 | $locale = get_locale(); |
| 1239 | - if ( 'en_US' !== $locale ) |
|
| 1240 | - $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
|
| 1265 | + if ( 'en_US' !== $locale ) { |
|
| 1266 | + $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
|
| 1267 | + } |
|
| 1241 | 1268 | |
| 1242 | 1269 | $notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>'; |
| 1243 | 1270 | $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>'; |
@@ -1264,8 +1291,9 @@ discard block |
||
| 1264 | 1291 | function dashboard_browser_nag_class( $classes ) { |
| 1265 | 1292 | $response = wp_check_browser_version(); |
| 1266 | 1293 | |
| 1267 | - if ( $response && $response['insecure'] ) |
|
| 1268 | - $classes[] = 'browser-insecure'; |
|
| 1294 | + if ( $response && $response['insecure'] ) { |
|
| 1295 | + $classes[] = 'browser-insecure'; |
|
| 1296 | + } |
|
| 1269 | 1297 | |
| 1270 | 1298 | return $classes; |
| 1271 | 1299 | } |
@@ -1280,8 +1308,9 @@ discard block |
||
| 1280 | 1308 | * @return array|bool False on failure, array of browser data on success. |
| 1281 | 1309 | */ |
| 1282 | 1310 | function wp_check_browser_version() { |
| 1283 | - if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) |
|
| 1284 | - return false; |
|
| 1311 | + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1312 | + return false; |
|
| 1313 | + } |
|
| 1285 | 1314 | |
| 1286 | 1315 | $key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
| 1287 | 1316 | |
@@ -1295,8 +1324,9 @@ discard block |
||
| 1295 | 1324 | |
| 1296 | 1325 | $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options ); |
| 1297 | 1326 | |
| 1298 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
| 1299 | - return false; |
|
| 1327 | + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
| 1328 | + return false; |
|
| 1329 | + } |
|
| 1300 | 1330 | |
| 1301 | 1331 | /** |
| 1302 | 1332 | * Response should be an array with: |
@@ -1311,8 +1341,9 @@ discard block |
||
| 1311 | 1341 | */ |
| 1312 | 1342 | $response = json_decode( wp_remote_retrieve_body( $response ), true ); |
| 1313 | 1343 | |
| 1314 | - if ( ! is_array( $response ) ) |
|
| 1315 | - return false; |
|
| 1344 | + if ( ! is_array( $response ) ) { |
|
| 1345 | + return false; |
|
| 1346 | + } |
|
| 1316 | 1347 | |
| 1317 | 1348 | set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); |
| 1318 | 1349 | } |
@@ -1356,8 +1387,11 @@ discard block |
||
| 1356 | 1387 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
| 1357 | 1388 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
| 1358 | 1389 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
| 1359 | - <?php else : ?> |
|
| 1360 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
| 1390 | + <?php else { |
|
| 1391 | + : ?> |
|
| 1392 | + <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); |
|
| 1393 | +} |
|
| 1394 | +?></li> |
|
| 1361 | 1395 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
| 1362 | 1396 | <?php endif; ?> |
| 1363 | 1397 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li> |
@@ -127,8 +127,8 @@ |
||
| 127 | 127 | * @param int $currentparent |
| 128 | 128 | * @param int $parent |
| 129 | 129 | * @param int $level |
| 130 | - * @param array $categories |
|
| 131 | - * @return bool|null |
|
| 130 | + * @param integer $categories |
|
| 131 | + * @return null|false |
|
| 132 | 132 | */ |
| 133 | 133 | function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { |
| 134 | 134 | _deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' ); |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Deprecated admin functions from past WordPress versions. You shouldn't use these |
|
| 4 | - * functions and look for the alternatives instead. The functions will be removed |
|
| 5 | - * in a later version. |
|
| 6 | - * |
|
| 7 | - * @package WordPress |
|
| 8 | - * @subpackage Deprecated |
|
| 9 | - */ |
|
| 3 | + * Deprecated admin functions from past WordPress versions. You shouldn't use these |
|
| 4 | + * functions and look for the alternatives instead. The functions will be removed |
|
| 5 | + * in a later version. |
|
| 6 | + * |
|
| 7 | + * @package WordPress |
|
| 8 | + * @subpackage Deprecated |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | /* |
| 12 | 12 | * Deprecated functions come here to die. |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @see wp_editor() |
| 19 | 19 | */ |
| 20 | 20 | function tinymce_include() { |
| 21 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_editor()' ); |
|
| 21 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_editor()'); |
|
| 22 | 22 | |
| 23 | 23 | wp_tiny_mce(); |
| 24 | 24 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | */ |
| 33 | 33 | function documentation_link() { |
| 34 | - _deprecated_function( __FUNCTION__, '2.5' ); |
|
| 34 | + _deprecated_function(__FUNCTION__, '2.5'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | * @param int $hmax Maximum wanted height |
| 48 | 48 | * @return array Shrunk dimensions (width, height). |
| 49 | 49 | */ |
| 50 | -function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) { |
|
| 51 | - _deprecated_function( __FUNCTION__, '3.0', 'wp_constrain_dimensions()' ); |
|
| 52 | - return wp_constrain_dimensions( $width, $height, $wmax, $hmax ); |
|
| 50 | +function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) { |
|
| 51 | + _deprecated_function(__FUNCTION__, '3.0', 'wp_constrain_dimensions()'); |
|
| 52 | + return wp_constrain_dimensions($width, $height, $wmax, $hmax); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | * @param int $height Current height of the image |
| 64 | 64 | * @return array Shrunk dimensions (width, height). |
| 65 | 65 | */ |
| 66 | -function get_udims( $width, $height ) { |
|
| 67 | - _deprecated_function( __FUNCTION__, '3.5', 'wp_constrain_dimensions()' ); |
|
| 68 | - return wp_constrain_dimensions( $width, $height, 128, 96 ); |
|
| 66 | +function get_udims($width, $height) { |
|
| 67 | + _deprecated_function(__FUNCTION__, '3.5', 'wp_constrain_dimensions()'); |
|
| 68 | + return wp_constrain_dimensions($width, $height, 128, 96); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | * @param int $parent |
| 80 | 80 | * @param array $popular_ids |
| 81 | 81 | */ |
| 82 | -function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) { |
|
| 83 | - _deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' ); |
|
| 82 | +function dropdown_categories($default = 0, $parent = 0, $popular_ids = array()) { |
|
| 83 | + _deprecated_function(__FUNCTION__, '2.6', 'wp_category_checklist()'); |
|
| 84 | 84 | global $post_ID; |
| 85 | - wp_category_checklist( $post_ID ); |
|
| 85 | + wp_category_checklist($post_ID); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @param int $default |
| 96 | 96 | */ |
| 97 | -function dropdown_link_categories( $default = 0 ) { |
|
| 98 | - _deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' ); |
|
| 97 | +function dropdown_link_categories($default = 0) { |
|
| 98 | + _deprecated_function(__FUNCTION__, '2.6', 'wp_link_category_checklist()'); |
|
| 99 | 99 | global $link_id; |
| 100 | - wp_link_category_checklist( $link_id ); |
|
| 100 | + wp_link_category_checklist($link_id); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | * @param string $file Filesystem path relative to the wp-content directory. |
| 111 | 111 | * @return string Full filesystem path to edit. |
| 112 | 112 | */ |
| 113 | -function get_real_file_to_edit( $file ) { |
|
| 114 | - _deprecated_function( __FUNCTION__, '2.9' ); |
|
| 113 | +function get_real_file_to_edit($file) { |
|
| 114 | + _deprecated_function(__FUNCTION__, '2.9'); |
|
| 115 | 115 | |
| 116 | - return WP_CONTENT_DIR . $file; |
|
| 116 | + return WP_CONTENT_DIR.$file; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -130,21 +130,21 @@ discard block |
||
| 130 | 130 | * @param array $categories |
| 131 | 131 | * @return bool|null |
| 132 | 132 | */ |
| 133 | -function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { |
|
| 134 | - _deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' ); |
|
| 135 | - if (!$categories ) |
|
| 136 | - $categories = get_categories( array('hide_empty' => 0) ); |
|
| 137 | - |
|
| 138 | - if ( $categories ) { |
|
| 139 | - foreach ( $categories as $category ) { |
|
| 140 | - if ( $currentcat != $category->term_id && $parent == $category->parent) { |
|
| 141 | - $pad = str_repeat( '– ', $level ); |
|
| 142 | - $category->name = esc_html( $category->name ); |
|
| 133 | +function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) { |
|
| 134 | + _deprecated_function(__FUNCTION__, '3.0', 'wp_dropdown_categories()'); |
|
| 135 | + if ( ! $categories) |
|
| 136 | + $categories = get_categories(array('hide_empty' => 0)); |
|
| 137 | + |
|
| 138 | + if ($categories) { |
|
| 139 | + foreach ($categories as $category) { |
|
| 140 | + if ($currentcat != $category->term_id && $parent == $category->parent) { |
|
| 141 | + $pad = str_repeat('– ', $level); |
|
| 142 | + $category->name = esc_html($category->name); |
|
| 143 | 143 | echo "\n\t<option value='$category->term_id'"; |
| 144 | - if ( $currentparent == $category->term_id ) |
|
| 144 | + if ($currentparent == $category->term_id) |
|
| 145 | 145 | echo " selected='selected'"; |
| 146 | 146 | echo ">$pad$category->name</option>"; |
| 147 | - wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); |
|
| 147 | + wp_dropdown_cats($currentcat, $currentparent, $category->term_id, $level + 1, $categories); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | } else { |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | * @param string $option_name The name of an option to sanitize and save. |
| 165 | 165 | * @param callable $sanitize_callback A callback function that sanitizes the option's value. |
| 166 | 166 | */ |
| 167 | -function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) { |
|
| 168 | - _deprecated_function( __FUNCTION__, '3.0', 'register_setting()' ); |
|
| 169 | - register_setting( $option_group, $option_name, $sanitize_callback ); |
|
| 167 | +function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') { |
|
| 168 | + _deprecated_function(__FUNCTION__, '3.0', 'register_setting()'); |
|
| 169 | + register_setting($option_group, $option_name, $sanitize_callback); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | * @param string $option_name |
| 181 | 181 | * @param callable $sanitize_callback |
| 182 | 182 | */ |
| 183 | -function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) { |
|
| 184 | - _deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' ); |
|
| 185 | - unregister_setting( $option_group, $option_name, $sanitize_callback ); |
|
| 183 | +function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') { |
|
| 184 | + _deprecated_function(__FUNCTION__, '3.0', 'unregister_setting()'); |
|
| 185 | + unregister_setting($option_group, $option_name, $sanitize_callback); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param string $filename |
| 195 | 195 | **/ |
| 196 | -function codepress_get_lang( $filename ) { |
|
| 197 | - _deprecated_function( __FUNCTION__, '3.0' ); |
|
| 196 | +function codepress_get_lang($filename) { |
|
| 197 | + _deprecated_function(__FUNCTION__, '3.0'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @deprecated 3.0.0 |
| 205 | 205 | **/ |
| 206 | 206 | function codepress_footer_js() { |
| 207 | - _deprecated_function( __FUNCTION__, '3.0' ); |
|
| 207 | + _deprecated_function(__FUNCTION__, '3.0'); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @deprecated 3.0.0 |
| 215 | 215 | **/ |
| 216 | 216 | function use_codepress() { |
| 217 | - _deprecated_function( __FUNCTION__, '3.0' ); |
|
| 217 | + _deprecated_function(__FUNCTION__, '3.0'); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -225,15 +225,15 @@ discard block |
||
| 225 | 225 | * @return array List of user IDs. |
| 226 | 226 | */ |
| 227 | 227 | function get_author_user_ids() { |
| 228 | - _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); |
|
| 228 | + _deprecated_function(__FUNCTION__, '3.1', 'get_users()'); |
|
| 229 | 229 | |
| 230 | 230 | global $wpdb; |
| 231 | - if ( !is_multisite() ) |
|
| 232 | - $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 231 | + if ( ! is_multisite()) |
|
| 232 | + $level_key = $wpdb->get_blog_prefix().'user_level'; |
|
| 233 | 233 | else |
| 234 | - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels |
|
| 234 | + $level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels |
|
| 235 | 235 | |
| 236 | - return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) ); |
|
| 236 | + return $wpdb->get_col($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key)); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -244,18 +244,18 @@ discard block |
||
| 244 | 244 | * @param int $user_id User ID. |
| 245 | 245 | * @return array|bool List of editable authors. False if no editable users. |
| 246 | 246 | */ |
| 247 | -function get_editable_authors( $user_id ) { |
|
| 248 | - _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); |
|
| 247 | +function get_editable_authors($user_id) { |
|
| 248 | + _deprecated_function(__FUNCTION__, '3.1', 'get_users()'); |
|
| 249 | 249 | |
| 250 | 250 | global $wpdb; |
| 251 | 251 | |
| 252 | - $editable = get_editable_user_ids( $user_id ); |
|
| 252 | + $editable = get_editable_user_ids($user_id); |
|
| 253 | 253 | |
| 254 | - if ( !$editable ) { |
|
| 254 | + if ( ! $editable) { |
|
| 255 | 255 | return false; |
| 256 | 256 | } else { |
| 257 | 257 | $editable = join(',', $editable); |
| 258 | - $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" ); |
|
| 258 | + $authors = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name"); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | return apply_filters('get_editable_authors', $authors); |
@@ -270,32 +270,32 @@ discard block |
||
| 270 | 270 | * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros. |
| 271 | 271 | * @return mixed |
| 272 | 272 | */ |
| 273 | -function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) { |
|
| 274 | - _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); |
|
| 273 | +function get_editable_user_ids($user_id, $exclude_zeros = true, $post_type = 'post') { |
|
| 274 | + _deprecated_function(__FUNCTION__, '3.1', 'get_users()'); |
|
| 275 | 275 | |
| 276 | 276 | global $wpdb; |
| 277 | 277 | |
| 278 | - if ( ! $user = get_userdata( $user_id ) ) |
|
| 278 | + if ( ! $user = get_userdata($user_id)) |
|
| 279 | 279 | return array(); |
| 280 | 280 | $post_type_obj = get_post_type_object($post_type); |
| 281 | 281 | |
| 282 | - if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) { |
|
| 283 | - if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) |
|
| 282 | + if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts)) { |
|
| 283 | + if ($user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros) |
|
| 284 | 284 | return array($user->ID); |
| 285 | 285 | else |
| 286 | 286 | return array(); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( !is_multisite() ) |
|
| 290 | - $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 289 | + if ( ! is_multisite()) |
|
| 290 | + $level_key = $wpdb->get_blog_prefix().'user_level'; |
|
| 291 | 291 | else |
| 292 | - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels |
|
| 292 | + $level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels |
|
| 293 | 293 | |
| 294 | 294 | $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key); |
| 295 | - if ( $exclude_zeros ) |
|
| 295 | + if ($exclude_zeros) |
|
| 296 | 296 | $query .= " AND meta_value != '0'"; |
| 297 | 297 | |
| 298 | - return $wpdb->get_col( $query ); |
|
| 298 | + return $wpdb->get_col($query); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -304,19 +304,19 @@ discard block |
||
| 304 | 304 | * @deprecated 3.1.0 Use get_users() |
| 305 | 305 | */ |
| 306 | 306 | function get_nonauthor_user_ids() { |
| 307 | - _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); |
|
| 307 | + _deprecated_function(__FUNCTION__, '3.1', 'get_users()'); |
|
| 308 | 308 | |
| 309 | 309 | global $wpdb; |
| 310 | 310 | |
| 311 | - if ( !is_multisite() ) |
|
| 312 | - $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 311 | + if ( ! is_multisite()) |
|
| 312 | + $level_key = $wpdb->get_blog_prefix().'user_level'; |
|
| 313 | 313 | else |
| 314 | - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels |
|
| 314 | + $level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels |
|
| 315 | 315 | |
| 316 | - return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); |
|
| 316 | + return $wpdb->get_col($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key)); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | -if ( !class_exists('WP_User_Search') ) : |
|
| 319 | +if ( ! class_exists('WP_User_Search')) : |
|
| 320 | 320 | /** |
| 321 | 321 | * WordPress User Search class. |
| 322 | 322 | * |
@@ -479,12 +479,12 @@ discard block |
||
| 479 | 479 | * @param string $role Role name. |
| 480 | 480 | * @return WP_User_Search |
| 481 | 481 | */ |
| 482 | - function __construct( $search_term = '', $page = '', $role = '' ) { |
|
| 483 | - _deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' ); |
|
| 482 | + function __construct($search_term = '', $page = '', $role = '') { |
|
| 483 | + _deprecated_function(__FUNCTION__, '3.1', 'WP_User_Query'); |
|
| 484 | 484 | |
| 485 | - $this->search_term = wp_unslash( $search_term ); |
|
| 486 | - $this->raw_page = ( '' == $page ) ? false : (int) $page; |
|
| 487 | - $this->page = (int) ( '' == $page ) ? 1 : $page; |
|
| 485 | + $this->search_term = wp_unslash($search_term); |
|
| 486 | + $this->raw_page = ('' == $page) ? false : (int) $page; |
|
| 487 | + $this->page = (int) ('' == $page) ? 1 : $page; |
|
| 488 | 488 | $this->role = $role; |
| 489 | 489 | |
| 490 | 490 | $this->prepare_query(); |
@@ -502,8 +502,8 @@ discard block |
||
| 502 | 502 | * @param string $role Role name. |
| 503 | 503 | * @return WP_User_Search |
| 504 | 504 | */ |
| 505 | - public function WP_User_Search( $search_term = '', $page = '', $role = '' ) { |
|
| 506 | - self::__construct( $search_term, $page, $role ); |
|
| 505 | + public function WP_User_Search($search_term = '', $page = '', $role = '') { |
|
| 506 | + self::__construct($search_term, $page, $role); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -522,11 +522,11 @@ discard block |
||
| 522 | 522 | $this->query_orderby = ' ORDER BY user_login'; |
| 523 | 523 | |
| 524 | 524 | $search_sql = ''; |
| 525 | - if ( $this->search_term ) { |
|
| 525 | + if ($this->search_term) { |
|
| 526 | 526 | $searches = array(); |
| 527 | 527 | $search_sql = 'AND ('; |
| 528 | - foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) |
|
| 529 | - $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' ); |
|
| 528 | + foreach (array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col) |
|
| 529 | + $searches[] = $wpdb->prepare($col.' LIKE %s', '%'.like_escape($this->search_term).'%'); |
|
| 530 | 530 | $search_sql .= implode(' OR ', $searches); |
| 531 | 531 | $search_sql .= ')'; |
| 532 | 532 | } |
@@ -534,16 +534,16 @@ discard block |
||
| 534 | 534 | $this->query_from = " FROM $wpdb->users"; |
| 535 | 535 | $this->query_where = " WHERE 1=1 $search_sql"; |
| 536 | 536 | |
| 537 | - if ( $this->role ) { |
|
| 537 | + if ($this->role) { |
|
| 538 | 538 | $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id"; |
| 539 | - $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%'); |
|
| 540 | - } elseif ( is_multisite() ) { |
|
| 541 | - $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels |
|
| 539 | + $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%'.$this->role.'%'); |
|
| 540 | + } elseif (is_multisite()) { |
|
| 541 | + $level_key = $wpdb->prefix.'capabilities'; // wpmu site admins don't have user_levels |
|
| 542 | 542 | $this->query_from .= ", $wpdb->usermeta"; |
| 543 | 543 | $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'"; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - do_action_ref_array( 'pre_user_search', array( &$this ) ); |
|
| 546 | + do_action_ref_array('pre_user_search', array(&$this)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -557,10 +557,10 @@ discard block |
||
| 557 | 557 | function query() { |
| 558 | 558 | global $wpdb; |
| 559 | 559 | |
| 560 | - $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit); |
|
| 560 | + $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)".$this->query_from.$this->query_where.$this->query_orderby.$this->query_limit); |
|
| 561 | 561 | |
| 562 | - if ( $this->results ) |
|
| 563 | - $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit |
|
| 562 | + if ($this->results) |
|
| 563 | + $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))".$this->query_from.$this->query_where); // no limit |
|
| 564 | 564 | else |
| 565 | 565 | $this->search_errors = new WP_Error('no_matching_users_found', __('No users found.')); |
| 566 | 566 | } |
@@ -584,25 +584,25 @@ discard block |
||
| 584 | 584 | * @access public |
| 585 | 585 | */ |
| 586 | 586 | function do_paging() { |
| 587 | - if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results |
|
| 587 | + if ($this->total_users_for_query > $this->users_per_page) { // have to page the results |
|
| 588 | 588 | $args = array(); |
| 589 | - if ( ! empty($this->search_term) ) |
|
| 589 | + if ( ! empty($this->search_term)) |
|
| 590 | 590 | $args['usersearch'] = urlencode($this->search_term); |
| 591 | - if ( ! empty($this->role) ) |
|
| 591 | + if ( ! empty($this->role)) |
|
| 592 | 592 | $args['role'] = urlencode($this->role); |
| 593 | 593 | |
| 594 | - $this->paging_text = paginate_links( array( |
|
| 594 | + $this->paging_text = paginate_links(array( |
|
| 595 | 595 | 'total' => ceil($this->total_users_for_query / $this->users_per_page), |
| 596 | 596 | 'current' => $this->page, |
| 597 | 597 | 'base' => 'users.php?%_%', |
| 598 | 598 | 'format' => 'userspage=%#%', |
| 599 | 599 | 'add_args' => $args |
| 600 | - ) ); |
|
| 601 | - if ( $this->paging_text ) { |
|
| 602 | - $this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', |
|
| 603 | - number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ), |
|
| 604 | - number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ), |
|
| 605 | - number_format_i18n( $this->total_users_for_query ), |
|
| 600 | + )); |
|
| 601 | + if ($this->paging_text) { |
|
| 602 | + $this->paging_text = sprintf('<span class="displaying-num">'.__('Displaying %s–%s of %s').'</span>%s', |
|
| 603 | + number_format_i18n(($this->page - 1) * $this->users_per_page + 1), |
|
| 604 | + number_format_i18n(min($this->page * $this->users_per_page, $this->total_users_for_query)), |
|
| 605 | + number_format_i18n($this->total_users_for_query), |
|
| 606 | 606 | $this->paging_text |
| 607 | 607 | ); |
| 608 | 608 | } |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | * @return bool |
| 647 | 647 | */ |
| 648 | 648 | function results_are_paged() { |
| 649 | - if ( $this->paging_text ) |
|
| 649 | + if ($this->paging_text) |
|
| 650 | 650 | return true; |
| 651 | 651 | return false; |
| 652 | 652 | } |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | * @return bool |
| 661 | 661 | */ |
| 662 | 662 | function is_search() { |
| 663 | - if ( $this->search_term ) |
|
| 663 | + if ($this->search_term) |
|
| 664 | 664 | return true; |
| 665 | 665 | return false; |
| 666 | 666 | } |
@@ -677,25 +677,25 @@ discard block |
||
| 677 | 677 | * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'. |
| 678 | 678 | * @return array List of posts from others. |
| 679 | 679 | */ |
| 680 | -function get_others_unpublished_posts($user_id, $type='any') { |
|
| 681 | - _deprecated_function( __FUNCTION__, '3.1' ); |
|
| 680 | +function get_others_unpublished_posts($user_id, $type = 'any') { |
|
| 681 | + _deprecated_function(__FUNCTION__, '3.1'); |
|
| 682 | 682 | |
| 683 | 683 | global $wpdb; |
| 684 | 684 | |
| 685 | - $editable = get_editable_user_ids( $user_id ); |
|
| 685 | + $editable = get_editable_user_ids($user_id); |
|
| 686 | 686 | |
| 687 | - if ( in_array($type, array('draft', 'pending')) ) |
|
| 687 | + if (in_array($type, array('draft', 'pending'))) |
|
| 688 | 688 | $type_sql = " post_status = '$type' "; |
| 689 | 689 | else |
| 690 | 690 | $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; |
| 691 | 691 | |
| 692 | - $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC'; |
|
| 692 | + $dir = ('pending' == $type) ? 'ASC' : 'DESC'; |
|
| 693 | 693 | |
| 694 | - if ( !$editable ) { |
|
| 694 | + if ( ! $editable) { |
|
| 695 | 695 | $other_unpubs = ''; |
| 696 | 696 | } else { |
| 697 | 697 | $editable = join(',', $editable); |
| 698 | - $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) ); |
|
| 698 | + $other_unpubs = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id)); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | return apply_filters('get_others_drafts', $other_unpubs); |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | * @return array List of drafts from other users. |
| 712 | 712 | */ |
| 713 | 713 | function get_others_drafts($user_id) { |
| 714 | - _deprecated_function( __FUNCTION__, '3.1' ); |
|
| 714 | + _deprecated_function(__FUNCTION__, '3.1'); |
|
| 715 | 715 | |
| 716 | 716 | return get_others_unpublished_posts($user_id, 'draft'); |
| 717 | 717 | } |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | * @return array List of posts with pending review post type from other users. |
| 727 | 727 | */ |
| 728 | 728 | function get_others_pending($user_id) { |
| 729 | - _deprecated_function( __FUNCTION__, '3.1' ); |
|
| 729 | + _deprecated_function(__FUNCTION__, '3.1'); |
|
| 730 | 730 | |
| 731 | 731 | return get_others_unpublished_posts($user_id, 'pending'); |
| 732 | 732 | } |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | * @see wp_dashboard_quick_press() |
| 740 | 740 | */ |
| 741 | 741 | function wp_dashboard_quick_press_output() { |
| 742 | - _deprecated_function( __FUNCTION__, '3.2', 'wp_dashboard_quick_press()' ); |
|
| 742 | + _deprecated_function(__FUNCTION__, '3.2', 'wp_dashboard_quick_press()'); |
|
| 743 | 743 | wp_dashboard_quick_press(); |
| 744 | 744 | } |
| 745 | 745 | |
@@ -752,15 +752,15 @@ discard block |
||
| 752 | 752 | * |
| 753 | 753 | * @staticvar int $num |
| 754 | 754 | */ |
| 755 | -function wp_tiny_mce( $teeny = false, $settings = false ) { |
|
| 756 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); |
|
| 755 | +function wp_tiny_mce($teeny = false, $settings = false) { |
|
| 756 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_editor()'); |
|
| 757 | 757 | |
| 758 | 758 | static $num = 1; |
| 759 | 759 | |
| 760 | - if ( ! class_exists('_WP_Editors' ) ) |
|
| 761 | - require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|
| 760 | + if ( ! class_exists('_WP_Editors')) |
|
| 761 | + require_once(ABSPATH.WPINC.'/class-wp-editor.php'); |
|
| 762 | 762 | |
| 763 | - $editor_id = 'content' . $num++; |
|
| 763 | + $editor_id = 'content'.$num++; |
|
| 764 | 764 | |
| 765 | 765 | $set = array( |
| 766 | 766 | 'teeny' => $teeny, |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | * @see wp_editor() |
| 780 | 780 | */ |
| 781 | 781 | function wp_preload_dialogs() { |
| 782 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); |
|
| 782 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_editor()'); |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /** |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | * @see wp_editor() |
| 790 | 790 | */ |
| 791 | 791 | function wp_print_editor_js() { |
| 792 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); |
|
| 792 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_editor()'); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | * @see wp_editor() |
| 800 | 800 | */ |
| 801 | 801 | function wp_quicktags() { |
| 802 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); |
|
| 802 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_editor()'); |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | /** |
@@ -809,12 +809,12 @@ discard block |
||
| 809 | 809 | * @deprecated 3.3.0 WP_Screen::render_screen_layout() |
| 810 | 810 | * @see WP_Screen::render_screen_layout() |
| 811 | 811 | */ |
| 812 | -function screen_layout( $screen ) { |
|
| 813 | - _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_screen_layout()' ); |
|
| 812 | +function screen_layout($screen) { |
|
| 813 | + _deprecated_function(__FUNCTION__, '3.3', '$current_screen->render_screen_layout()'); |
|
| 814 | 814 | |
| 815 | 815 | $current_screen = get_current_screen(); |
| 816 | 816 | |
| 817 | - if ( ! $current_screen ) |
|
| 817 | + if ( ! $current_screen) |
|
| 818 | 818 | return ''; |
| 819 | 819 | |
| 820 | 820 | ob_start(); |
@@ -829,12 +829,12 @@ discard block |
||
| 829 | 829 | * @deprecated 3.3.0 Use WP_Screen::render_per_page_options() |
| 830 | 830 | * @see WP_Screen::render_per_page_options() |
| 831 | 831 | */ |
| 832 | -function screen_options( $screen ) { |
|
| 833 | - _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_per_page_options()' ); |
|
| 832 | +function screen_options($screen) { |
|
| 833 | + _deprecated_function(__FUNCTION__, '3.3', '$current_screen->render_per_page_options()'); |
|
| 834 | 834 | |
| 835 | 835 | $current_screen = get_current_screen(); |
| 836 | 836 | |
| 837 | - if ( ! $current_screen ) |
|
| 837 | + if ( ! $current_screen) |
|
| 838 | 838 | return ''; |
| 839 | 839 | |
| 840 | 840 | ob_start(); |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | * @deprecated 3.3.0 Use WP_Screen::render_screen_meta() |
| 850 | 850 | * @see WP_Screen::render_screen_meta() |
| 851 | 851 | */ |
| 852 | -function screen_meta( $screen ) { |
|
| 852 | +function screen_meta($screen) { |
|
| 853 | 853 | $current_screen = get_current_screen(); |
| 854 | 854 | $current_screen->render_screen_meta(); |
| 855 | 855 | } |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | * @see WP_Admin_Bar |
| 863 | 863 | */ |
| 864 | 864 | function favorite_actions() { |
| 865 | - _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' ); |
|
| 865 | + _deprecated_function(__FUNCTION__, '3.2', 'WP_Admin_Bar'); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | /** |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | * @return null|string |
| 875 | 875 | */ |
| 876 | 876 | function media_upload_image() { |
| 877 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' ); |
|
| 877 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_media_upload_handler()'); |
|
| 878 | 878 | return wp_media_upload_handler(); |
| 879 | 879 | } |
| 880 | 880 | |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * @return null|string |
| 888 | 888 | */ |
| 889 | 889 | function media_upload_audio() { |
| 890 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' ); |
|
| 890 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_media_upload_handler()'); |
|
| 891 | 891 | return wp_media_upload_handler(); |
| 892 | 892 | } |
| 893 | 893 | |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | * @return null|string |
| 901 | 901 | */ |
| 902 | 902 | function media_upload_video() { |
| 903 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' ); |
|
| 903 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_media_upload_handler()'); |
|
| 904 | 904 | return wp_media_upload_handler(); |
| 905 | 905 | } |
| 906 | 906 | |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | * @return null|string |
| 914 | 914 | */ |
| 915 | 915 | function media_upload_file() { |
| 916 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' ); |
|
| 916 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_media_upload_handler()'); |
|
| 917 | 917 | return wp_media_upload_handler(); |
| 918 | 918 | } |
| 919 | 919 | |
@@ -926,8 +926,8 @@ discard block |
||
| 926 | 926 | * @return string |
| 927 | 927 | */ |
| 928 | 928 | function type_url_form_image() { |
| 929 | - _deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('image')" ); |
|
| 930 | - return wp_media_insert_url_form( 'image' ); |
|
| 929 | + _deprecated_function(__FUNCTION__, '3.3', "wp_media_insert_url_form('image')"); |
|
| 930 | + return wp_media_insert_url_form('image'); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
@@ -939,8 +939,8 @@ discard block |
||
| 939 | 939 | * @return string |
| 940 | 940 | */ |
| 941 | 941 | function type_url_form_audio() { |
| 942 | - _deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('audio')" ); |
|
| 943 | - return wp_media_insert_url_form( 'audio' ); |
|
| 942 | + _deprecated_function(__FUNCTION__, '3.3', "wp_media_insert_url_form('audio')"); |
|
| 943 | + return wp_media_insert_url_form('audio'); |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | /** |
@@ -952,8 +952,8 @@ discard block |
||
| 952 | 952 | * @return string |
| 953 | 953 | */ |
| 954 | 954 | function type_url_form_video() { |
| 955 | - _deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('video')" ); |
|
| 956 | - return wp_media_insert_url_form( 'video' ); |
|
| 955 | + _deprecated_function(__FUNCTION__, '3.3', "wp_media_insert_url_form('video')"); |
|
| 956 | + return wp_media_insert_url_form('video'); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | /** |
@@ -965,8 +965,8 @@ discard block |
||
| 965 | 965 | * @return string |
| 966 | 966 | */ |
| 967 | 967 | function type_url_form_file() { |
| 968 | - _deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" ); |
|
| 969 | - return wp_media_insert_url_form( 'file' ); |
|
| 968 | + _deprecated_function(__FUNCTION__, '3.3', "wp_media_insert_url_form('file')"); |
|
| 969 | + return wp_media_insert_url_form('file'); |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | /** |
@@ -981,13 +981,13 @@ discard block |
||
| 981 | 981 | * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. |
| 982 | 982 | * @param string $help The content of an 'Overview' help tab. |
| 983 | 983 | */ |
| 984 | -function add_contextual_help( $screen, $help ) { |
|
| 985 | - _deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' ); |
|
| 984 | +function add_contextual_help($screen, $help) { |
|
| 985 | + _deprecated_function(__FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()'); |
|
| 986 | 986 | |
| 987 | - if ( is_string( $screen ) ) |
|
| 988 | - $screen = convert_to_screen( $screen ); |
|
| 987 | + if (is_string($screen)) |
|
| 988 | + $screen = convert_to_screen($screen); |
|
| 989 | 989 | |
| 990 | - WP_Screen::add_old_compat_help( $screen, $help ); |
|
| 990 | + WP_Screen::add_old_compat_help($screen, $help); |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | /** |
@@ -1000,13 +1000,13 @@ discard block |
||
| 1000 | 1000 | * @return array $themes Array of allowed themes. |
| 1001 | 1001 | */ |
| 1002 | 1002 | function get_allowed_themes() { |
| 1003 | - _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'allowed' => true ) )" ); |
|
| 1003 | + _deprecated_function(__FUNCTION__, '3.4', "wp_get_themes( array( 'allowed' => true ) )"); |
|
| 1004 | 1004 | |
| 1005 | - $themes = wp_get_themes( array( 'allowed' => true ) ); |
|
| 1005 | + $themes = wp_get_themes(array('allowed' => true)); |
|
| 1006 | 1006 | |
| 1007 | 1007 | $wp_themes = array(); |
| 1008 | - foreach ( $themes as $theme ) { |
|
| 1009 | - $wp_themes[ $theme->get('Name') ] = $theme; |
|
| 1008 | + foreach ($themes as $theme) { |
|
| 1009 | + $wp_themes[$theme->get('Name')] = $theme; |
|
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | return $wp_themes; |
@@ -1022,13 +1022,13 @@ discard block |
||
| 1022 | 1022 | * @return array |
| 1023 | 1023 | */ |
| 1024 | 1024 | function get_broken_themes() { |
| 1025 | - _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'errors' => true )" ); |
|
| 1025 | + _deprecated_function(__FUNCTION__, '3.4', "wp_get_themes( array( 'errors' => true )"); |
|
| 1026 | 1026 | |
| 1027 | - $themes = wp_get_themes( array( 'errors' => true ) ); |
|
| 1027 | + $themes = wp_get_themes(array('errors' => true)); |
|
| 1028 | 1028 | $broken = array(); |
| 1029 | - foreach ( $themes as $theme ) { |
|
| 1029 | + foreach ($themes as $theme) { |
|
| 1030 | 1030 | $name = $theme->get('Name'); |
| 1031 | - $broken[ $name ] = array( |
|
| 1031 | + $broken[$name] = array( |
|
| 1032 | 1032 | 'Name' => $name, |
| 1033 | 1033 | 'Title' => $name, |
| 1034 | 1034 | 'Description' => $theme->errors()->get_error_message(), |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | * @return WP_Theme |
| 1048 | 1048 | */ |
| 1049 | 1049 | function current_theme_info() { |
| 1050 | - _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' ); |
|
| 1050 | + _deprecated_function(__FUNCTION__, '3.4', 'wp_get_theme()'); |
|
| 1051 | 1051 | |
| 1052 | 1052 | return wp_get_theme(); |
| 1053 | 1053 | } |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | * |
| 1060 | 1060 | * @deprecated 3.5.0 |
| 1061 | 1061 | */ |
| 1062 | -function _insert_into_post_button( $type ) { |
|
| 1063 | - _deprecated_function( __FUNCTION__, '3.5' ); |
|
| 1062 | +function _insert_into_post_button($type) { |
|
| 1063 | + _deprecated_function(__FUNCTION__, '3.5'); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | /** |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | * @deprecated 3.5.0 |
| 1072 | 1072 | */ |
| 1073 | 1073 | function _media_button($title, $icon, $type, $id) { |
| 1074 | - _deprecated_function( __FUNCTION__, '3.5' ); |
|
| 1074 | + _deprecated_function(__FUNCTION__, '3.5'); |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1084,10 +1084,10 @@ discard block |
||
| 1084 | 1084 | * @param int $id |
| 1085 | 1085 | * @return object |
| 1086 | 1086 | */ |
| 1087 | -function get_post_to_edit( $id ) { |
|
| 1088 | - _deprecated_function( __FUNCTION__, '3.5', 'get_post()' ); |
|
| 1087 | +function get_post_to_edit($id) { |
|
| 1088 | + _deprecated_function(__FUNCTION__, '3.5', 'get_post()'); |
|
| 1089 | 1089 | |
| 1090 | - return get_post( $id, OBJECT, 'edit' ); |
|
| 1090 | + return get_post($id, OBJECT, 'edit'); |
|
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | /** |
@@ -1100,7 +1100,7 @@ discard block |
||
| 1100 | 1100 | * @return WP_Post Post object containing all the default post data as attributes |
| 1101 | 1101 | */ |
| 1102 | 1102 | function get_default_page_to_edit() { |
| 1103 | - _deprecated_function( __FUNCTION__, '3.5', "get_default_post_to_edit( 'page' )" ); |
|
| 1103 | + _deprecated_function(__FUNCTION__, '3.5', "get_default_post_to_edit( 'page' )"); |
|
| 1104 | 1104 | |
| 1105 | 1105 | $page = get_default_post_to_edit(); |
| 1106 | 1106 | $page->post_type = 'page'; |
@@ -1119,9 +1119,9 @@ discard block |
||
| 1119 | 1119 | * @param mixed $deprecated Never used. |
| 1120 | 1120 | * @return string Thumbnail path on success, Error string on failure. |
| 1121 | 1121 | */ |
| 1122 | -function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) { |
|
| 1123 | - _deprecated_function( __FUNCTION__, '3.5', 'image_resize()' ); |
|
| 1124 | - return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) ); |
|
| 1122 | +function wp_create_thumbnail($file, $max_side, $deprecated = '') { |
|
| 1123 | + _deprecated_function(__FUNCTION__, '3.5', 'image_resize()'); |
|
| 1124 | + return apply_filters('wp_create_thumbnail', image_resize($file, $max_side, $max_side)); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | /** |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | * @deprecated 3.6.0 |
| 1134 | 1134 | */ |
| 1135 | 1135 | function wp_nav_menu_locations_meta_box() { |
| 1136 | - _deprecated_function( __FUNCTION__, '3.6' ); |
|
| 1136 | + _deprecated_function(__FUNCTION__, '3.6'); |
|
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | 1139 | /** |
@@ -1147,12 +1147,12 @@ discard block |
||
| 1147 | 1147 | * @see Core_Upgrader |
| 1148 | 1148 | */ |
| 1149 | 1149 | function wp_update_core($current, $feedback = '') { |
| 1150 | - _deprecated_function( __FUNCTION__, '3.7', 'new Core_Upgrader();' ); |
|
| 1150 | + _deprecated_function(__FUNCTION__, '3.7', 'new Core_Upgrader();'); |
|
| 1151 | 1151 | |
| 1152 | - if ( !empty($feedback) ) |
|
| 1152 | + if ( ! empty($feedback)) |
|
| 1153 | 1153 | add_filter('update_feedback', $feedback); |
| 1154 | 1154 | |
| 1155 | - include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
| 1155 | + include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); |
|
| 1156 | 1156 | $upgrader = new Core_Upgrader(); |
| 1157 | 1157 | return $upgrader->upgrade($current); |
| 1158 | 1158 | |
@@ -1170,12 +1170,12 @@ discard block |
||
| 1170 | 1170 | * @see Plugin_Upgrader |
| 1171 | 1171 | */ |
| 1172 | 1172 | function wp_update_plugin($plugin, $feedback = '') { |
| 1173 | - _deprecated_function( __FUNCTION__, '3.7', 'new Plugin_Upgrader();' ); |
|
| 1173 | + _deprecated_function(__FUNCTION__, '3.7', 'new Plugin_Upgrader();'); |
|
| 1174 | 1174 | |
| 1175 | - if ( !empty($feedback) ) |
|
| 1175 | + if ( ! empty($feedback)) |
|
| 1176 | 1176 | add_filter('update_feedback', $feedback); |
| 1177 | 1177 | |
| 1178 | - include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
| 1178 | + include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); |
|
| 1179 | 1179 | $upgrader = new Plugin_Upgrader(); |
| 1180 | 1180 | return $upgrader->upgrade($plugin); |
| 1181 | 1181 | } |
@@ -1192,12 +1192,12 @@ discard block |
||
| 1192 | 1192 | * @see Theme_Upgrader |
| 1193 | 1193 | */ |
| 1194 | 1194 | function wp_update_theme($theme, $feedback = '') { |
| 1195 | - _deprecated_function( __FUNCTION__, '3.7', 'new Theme_Upgrader();' ); |
|
| 1195 | + _deprecated_function(__FUNCTION__, '3.7', 'new Theme_Upgrader();'); |
|
| 1196 | 1196 | |
| 1197 | - if ( !empty($feedback) ) |
|
| 1197 | + if ( ! empty($feedback)) |
|
| 1198 | 1198 | add_filter('update_feedback', $feedback); |
| 1199 | 1199 | |
| 1200 | - include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
| 1200 | + include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); |
|
| 1201 | 1201 | $upgrader = new Theme_Upgrader(); |
| 1202 | 1202 | return $upgrader->upgrade($theme); |
| 1203 | 1203 | } |
@@ -1210,8 +1210,8 @@ discard block |
||
| 1210 | 1210 | * |
| 1211 | 1211 | * @param int|bool $id |
| 1212 | 1212 | */ |
| 1213 | -function the_attachment_links( $id = false ) { |
|
| 1214 | - _deprecated_function( __FUNCTION__, '3.7' ); |
|
| 1213 | +function the_attachment_links($id = false) { |
|
| 1214 | + _deprecated_function(__FUNCTION__, '3.7'); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | /** |
@@ -1312,6 +1312,6 @@ discard block |
||
| 1312 | 1312 | * @param int $old_ID |
| 1313 | 1313 | * @param int $new_ID |
| 1314 | 1314 | */ |
| 1315 | -function _relocate_children( $old_ID, $new_ID ) { |
|
| 1316 | - _deprecated_function( __FUNCTION__, '3.9' ); |
|
| 1315 | +function _relocate_children($old_ID, $new_ID) { |
|
| 1316 | + _deprecated_function(__FUNCTION__, '3.9'); |
|
| 1317 | 1317 | } |
@@ -132,8 +132,9 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { |
| 134 | 134 | _deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' ); |
| 135 | - if (!$categories ) |
|
| 136 | - $categories = get_categories( array('hide_empty' => 0) ); |
|
| 135 | + if (!$categories ) { |
|
| 136 | + $categories = get_categories( array('hide_empty' => 0) ); |
|
| 137 | + } |
|
| 137 | 138 | |
| 138 | 139 | if ( $categories ) { |
| 139 | 140 | foreach ( $categories as $category ) { |
@@ -141,8 +142,9 @@ discard block |
||
| 141 | 142 | $pad = str_repeat( '– ', $level ); |
| 142 | 143 | $category->name = esc_html( $category->name ); |
| 143 | 144 | echo "\n\t<option value='$category->term_id'"; |
| 144 | - if ( $currentparent == $category->term_id ) |
|
| 145 | - echo " selected='selected'"; |
|
| 145 | + if ( $currentparent == $category->term_id ) { |
|
| 146 | + echo " selected='selected'"; |
|
| 147 | + } |
|
| 146 | 148 | echo ">$pad$category->name</option>"; |
| 147 | 149 | wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); |
| 148 | 150 | } |
@@ -228,10 +230,12 @@ discard block |
||
| 228 | 230 | _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); |
| 229 | 231 | |
| 230 | 232 | global $wpdb; |
| 231 | - if ( !is_multisite() ) |
|
| 232 | - $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 233 | - else |
|
| 234 | - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels |
|
| 233 | + if ( !is_multisite() ) { |
|
| 234 | + $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 235 | + } else { |
|
| 236 | + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; |
|
| 237 | + } |
|
| 238 | + // wpmu site admins don't have user_levels |
|
| 235 | 239 | |
| 236 | 240 | return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) ); |
| 237 | 241 | } |
@@ -275,25 +279,30 @@ discard block |
||
| 275 | 279 | |
| 276 | 280 | global $wpdb; |
| 277 | 281 | |
| 278 | - if ( ! $user = get_userdata( $user_id ) ) |
|
| 279 | - return array(); |
|
| 282 | + if ( ! $user = get_userdata( $user_id ) ) { |
|
| 283 | + return array(); |
|
| 284 | + } |
|
| 280 | 285 | $post_type_obj = get_post_type_object($post_type); |
| 281 | 286 | |
| 282 | 287 | if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) { |
| 283 | - if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) |
|
| 284 | - return array($user->ID); |
|
| 285 | - else |
|
| 286 | - return array(); |
|
| 288 | + if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) { |
|
| 289 | + return array($user->ID); |
|
| 290 | + } else { |
|
| 291 | + return array(); |
|
| 292 | + } |
|
| 287 | 293 | } |
| 288 | 294 | |
| 289 | - if ( !is_multisite() ) |
|
| 290 | - $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 291 | - else |
|
| 292 | - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels |
|
| 295 | + if ( !is_multisite() ) { |
|
| 296 | + $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 297 | + } else { |
|
| 298 | + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; |
|
| 299 | + } |
|
| 300 | + // wpmu site admins don't have user_levels |
|
| 293 | 301 | |
| 294 | 302 | $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key); |
| 295 | - if ( $exclude_zeros ) |
|
| 296 | - $query .= " AND meta_value != '0'"; |
|
| 303 | + if ( $exclude_zeros ) { |
|
| 304 | + $query .= " AND meta_value != '0'"; |
|
| 305 | + } |
|
| 297 | 306 | |
| 298 | 307 | return $wpdb->get_col( $query ); |
| 299 | 308 | } |
@@ -308,10 +317,12 @@ discard block |
||
| 308 | 317 | |
| 309 | 318 | global $wpdb; |
| 310 | 319 | |
| 311 | - if ( !is_multisite() ) |
|
| 312 | - $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 313 | - else |
|
| 314 | - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels |
|
| 320 | + if ( !is_multisite() ) { |
|
| 321 | + $level_key = $wpdb->get_blog_prefix() . 'user_level'; |
|
| 322 | + } else { |
|
| 323 | + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; |
|
| 324 | + } |
|
| 325 | + // wpmu site admins don't have user_levels |
|
| 315 | 326 | |
| 316 | 327 | return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); |
| 317 | 328 | } |
@@ -525,8 +536,9 @@ discard block |
||
| 525 | 536 | if ( $this->search_term ) { |
| 526 | 537 | $searches = array(); |
| 527 | 538 | $search_sql = 'AND ('; |
| 528 | - foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) |
|
| 529 | - $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' ); |
|
| 539 | + foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) { |
|
| 540 | + $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' ); |
|
| 541 | + } |
|
| 530 | 542 | $search_sql .= implode(' OR ', $searches); |
| 531 | 543 | $search_sql .= ')'; |
| 532 | 544 | } |
@@ -559,10 +571,13 @@ discard block |
||
| 559 | 571 | |
| 560 | 572 | $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit); |
| 561 | 573 | |
| 562 | - if ( $this->results ) |
|
| 563 | - $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit |
|
| 564 | - else |
|
| 565 | - $this->search_errors = new WP_Error('no_matching_users_found', __('No users found.')); |
|
| 574 | + if ( $this->results ) { |
|
| 575 | + $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); |
|
| 576 | + } |
|
| 577 | + // no limit |
|
| 578 | + else { |
|
| 579 | + $this->search_errors = new WP_Error('no_matching_users_found', __('No users found.')); |
|
| 580 | + } |
|
| 566 | 581 | } |
| 567 | 582 | |
| 568 | 583 | /** |
@@ -586,10 +601,12 @@ discard block |
||
| 586 | 601 | function do_paging() { |
| 587 | 602 | if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results |
| 588 | 603 | $args = array(); |
| 589 | - if ( ! empty($this->search_term) ) |
|
| 590 | - $args['usersearch'] = urlencode($this->search_term); |
|
| 591 | - if ( ! empty($this->role) ) |
|
| 592 | - $args['role'] = urlencode($this->role); |
|
| 604 | + if ( ! empty($this->search_term) ) { |
|
| 605 | + $args['usersearch'] = urlencode($this->search_term); |
|
| 606 | + } |
|
| 607 | + if ( ! empty($this->role) ) { |
|
| 608 | + $args['role'] = urlencode($this->role); |
|
| 609 | + } |
|
| 593 | 610 | |
| 594 | 611 | $this->paging_text = paginate_links( array( |
| 595 | 612 | 'total' => ceil($this->total_users_for_query / $this->users_per_page), |
@@ -646,8 +663,9 @@ discard block |
||
| 646 | 663 | * @return bool |
| 647 | 664 | */ |
| 648 | 665 | function results_are_paged() { |
| 649 | - if ( $this->paging_text ) |
|
| 650 | - return true; |
|
| 666 | + if ( $this->paging_text ) { |
|
| 667 | + return true; |
|
| 668 | + } |
|
| 651 | 669 | return false; |
| 652 | 670 | } |
| 653 | 671 | |
@@ -660,8 +678,9 @@ discard block |
||
| 660 | 678 | * @return bool |
| 661 | 679 | */ |
| 662 | 680 | function is_search() { |
| 663 | - if ( $this->search_term ) |
|
| 664 | - return true; |
|
| 681 | + if ( $this->search_term ) { |
|
| 682 | + return true; |
|
| 683 | + } |
|
| 665 | 684 | return false; |
| 666 | 685 | } |
| 667 | 686 | } |
@@ -684,10 +703,11 @@ discard block |
||
| 684 | 703 | |
| 685 | 704 | $editable = get_editable_user_ids( $user_id ); |
| 686 | 705 | |
| 687 | - if ( in_array($type, array('draft', 'pending')) ) |
|
| 688 | - $type_sql = " post_status = '$type' "; |
|
| 689 | - else |
|
| 690 | - $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; |
|
| 706 | + if ( in_array($type, array('draft', 'pending')) ) { |
|
| 707 | + $type_sql = " post_status = '$type' "; |
|
| 708 | + } else { |
|
| 709 | + $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; |
|
| 710 | + } |
|
| 691 | 711 | |
| 692 | 712 | $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC'; |
| 693 | 713 | |
@@ -757,8 +777,9 @@ discard block |
||
| 757 | 777 | |
| 758 | 778 | static $num = 1; |
| 759 | 779 | |
| 760 | - if ( ! class_exists('_WP_Editors' ) ) |
|
| 761 | - require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|
| 780 | + if ( ! class_exists('_WP_Editors' ) ) { |
|
| 781 | + require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|
| 782 | + } |
|
| 762 | 783 | |
| 763 | 784 | $editor_id = 'content' . $num++; |
| 764 | 785 | |
@@ -814,8 +835,9 @@ discard block |
||
| 814 | 835 | |
| 815 | 836 | $current_screen = get_current_screen(); |
| 816 | 837 | |
| 817 | - if ( ! $current_screen ) |
|
| 818 | - return ''; |
|
| 838 | + if ( ! $current_screen ) { |
|
| 839 | + return ''; |
|
| 840 | + } |
|
| 819 | 841 | |
| 820 | 842 | ob_start(); |
| 821 | 843 | $current_screen->render_screen_layout(); |
@@ -834,8 +856,9 @@ discard block |
||
| 834 | 856 | |
| 835 | 857 | $current_screen = get_current_screen(); |
| 836 | 858 | |
| 837 | - if ( ! $current_screen ) |
|
| 838 | - return ''; |
|
| 859 | + if ( ! $current_screen ) { |
|
| 860 | + return ''; |
|
| 861 | + } |
|
| 839 | 862 | |
| 840 | 863 | ob_start(); |
| 841 | 864 | $current_screen->render_per_page_options(); |
@@ -984,8 +1007,9 @@ discard block |
||
| 984 | 1007 | function add_contextual_help( $screen, $help ) { |
| 985 | 1008 | _deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' ); |
| 986 | 1009 | |
| 987 | - if ( is_string( $screen ) ) |
|
| 988 | - $screen = convert_to_screen( $screen ); |
|
| 1010 | + if ( is_string( $screen ) ) { |
|
| 1011 | + $screen = convert_to_screen( $screen ); |
|
| 1012 | + } |
|
| 989 | 1013 | |
| 990 | 1014 | WP_Screen::add_old_compat_help( $screen, $help ); |
| 991 | 1015 | } |
@@ -1149,8 +1173,9 @@ discard block |
||
| 1149 | 1173 | function wp_update_core($current, $feedback = '') { |
| 1150 | 1174 | _deprecated_function( __FUNCTION__, '3.7', 'new Core_Upgrader();' ); |
| 1151 | 1175 | |
| 1152 | - if ( !empty($feedback) ) |
|
| 1153 | - add_filter('update_feedback', $feedback); |
|
| 1176 | + if ( !empty($feedback) ) { |
|
| 1177 | + add_filter('update_feedback', $feedback); |
|
| 1178 | + } |
|
| 1154 | 1179 | |
| 1155 | 1180 | include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
| 1156 | 1181 | $upgrader = new Core_Upgrader(); |
@@ -1172,8 +1197,9 @@ discard block |
||
| 1172 | 1197 | function wp_update_plugin($plugin, $feedback = '') { |
| 1173 | 1198 | _deprecated_function( __FUNCTION__, '3.7', 'new Plugin_Upgrader();' ); |
| 1174 | 1199 | |
| 1175 | - if ( !empty($feedback) ) |
|
| 1176 | - add_filter('update_feedback', $feedback); |
|
| 1200 | + if ( !empty($feedback) ) { |
|
| 1201 | + add_filter('update_feedback', $feedback); |
|
| 1202 | + } |
|
| 1177 | 1203 | |
| 1178 | 1204 | include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
| 1179 | 1205 | $upgrader = new Plugin_Upgrader(); |
@@ -1194,8 +1220,9 @@ discard block |
||
| 1194 | 1220 | function wp_update_theme($theme, $feedback = '') { |
| 1195 | 1221 | _deprecated_function( __FUNCTION__, '3.7', 'new Theme_Upgrader();' ); |
| 1196 | 1222 | |
| 1197 | - if ( !empty($feedback) ) |
|
| 1198 | - add_filter('update_feedback', $feedback); |
|
| 1223 | + if ( !empty($feedback) ) { |
|
| 1224 | + add_filter('update_feedback', $feedback); |
|
| 1225 | + } |
|
| 1199 | 1226 | |
| 1200 | 1227 | include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
| 1201 | 1228 | $upgrader = new Theme_Upgrader(); |
@@ -833,7 +833,7 @@ |
||
| 833 | 833 | * |
| 834 | 834 | * @global WP_Filesystem_Base $wp_filesystem Subclass |
| 835 | 835 | * |
| 836 | - * @param array|false $args Optional. Connection args, These are passed directly to |
|
| 836 | + * @param boolean $args Optional. Connection args, These are passed directly to |
|
| 837 | 837 | * the `WP_Filesystem_*()` classes. Default false. |
| 838 | 838 | * @param string|false $context Optional. Context for get_filesystem_method(). Default false. |
| 839 | 839 | * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Functions for reading, writing, modifying, and deleting files on the file system. |
|
| 4 | - * Includes functionality for theme-specific files as well as operations for uploading, |
|
| 5 | - * archiving, and rendering output when necessary. |
|
| 6 | - * |
|
| 7 | - * @package WordPress |
|
| 8 | - * @subpackage Administration |
|
| 9 | - */ |
|
| 3 | + * Functions for reading, writing, modifying, and deleting files on the file system. |
|
| 4 | + * Includes functionality for theme-specific files as well as operations for uploading, |
|
| 5 | + * archiving, and rendering output when necessary. |
|
| 6 | + * |
|
| 7 | + * @package WordPress |
|
| 8 | + * @subpackage Administration |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | /** The descriptions for theme files. */ |
| 12 | 12 | $wp_file_descriptions = array( |
@@ -10,38 +10,38 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | /** The descriptions for theme files. */ |
| 12 | 12 | $wp_file_descriptions = array( |
| 13 | - 'index.php' => __( 'Main Index Template' ), |
|
| 14 | - 'style.css' => __( 'Stylesheet' ), |
|
| 15 | - 'editor-style.css' => __( 'Visual Editor Stylesheet' ), |
|
| 16 | - 'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ), |
|
| 17 | - 'rtl.css' => __( 'RTL Stylesheet' ), |
|
| 18 | - 'comments.php' => __( 'Comments' ), |
|
| 19 | - 'comments-popup.php' => __( 'Popup Comments' ), |
|
| 20 | - 'footer.php' => __( 'Footer' ), |
|
| 21 | - 'header.php' => __( 'Header' ), |
|
| 22 | - 'sidebar.php' => __( 'Sidebar' ), |
|
| 23 | - 'archive.php' => __( 'Archives' ), |
|
| 24 | - 'author.php' => __( 'Author Template' ), |
|
| 25 | - 'tag.php' => __( 'Tag Template' ), |
|
| 26 | - 'category.php' => __( 'Category Template' ), |
|
| 27 | - 'page.php' => __( 'Page Template' ), |
|
| 28 | - 'search.php' => __( 'Search Results' ), |
|
| 29 | - 'searchform.php' => __( 'Search Form' ), |
|
| 30 | - 'single.php' => __( 'Single Post' ), |
|
| 31 | - '404.php' => __( '404 Template' ), |
|
| 32 | - 'link.php' => __( 'Links Template' ), |
|
| 33 | - 'functions.php' => __( 'Theme Functions' ), |
|
| 34 | - 'attachment.php' => __( 'Attachment Template' ), |
|
| 13 | + 'index.php' => __('Main Index Template'), |
|
| 14 | + 'style.css' => __('Stylesheet'), |
|
| 15 | + 'editor-style.css' => __('Visual Editor Stylesheet'), |
|
| 16 | + 'editor-style-rtl.css' => __('Visual Editor RTL Stylesheet'), |
|
| 17 | + 'rtl.css' => __('RTL Stylesheet'), |
|
| 18 | + 'comments.php' => __('Comments'), |
|
| 19 | + 'comments-popup.php' => __('Popup Comments'), |
|
| 20 | + 'footer.php' => __('Footer'), |
|
| 21 | + 'header.php' => __('Header'), |
|
| 22 | + 'sidebar.php' => __('Sidebar'), |
|
| 23 | + 'archive.php' => __('Archives'), |
|
| 24 | + 'author.php' => __('Author Template'), |
|
| 25 | + 'tag.php' => __('Tag Template'), |
|
| 26 | + 'category.php' => __('Category Template'), |
|
| 27 | + 'page.php' => __('Page Template'), |
|
| 28 | + 'search.php' => __('Search Results'), |
|
| 29 | + 'searchform.php' => __('Search Form'), |
|
| 30 | + 'single.php' => __('Single Post'), |
|
| 31 | + '404.php' => __('404 Template'), |
|
| 32 | + 'link.php' => __('Links Template'), |
|
| 33 | + 'functions.php' => __('Theme Functions'), |
|
| 34 | + 'attachment.php' => __('Attachment Template'), |
|
| 35 | 35 | 'image.php' => __('Image Attachment Template'), |
| 36 | 36 | 'video.php' => __('Video Attachment Template'), |
| 37 | 37 | 'audio.php' => __('Audio Attachment Template'), |
| 38 | 38 | 'application.php' => __('Application Attachment Template'), |
| 39 | - 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), |
|
| 40 | - '.htaccess' => __( '.htaccess (for rewrite rules )' ), |
|
| 39 | + 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), |
|
| 40 | + '.htaccess' => __('.htaccess (for rewrite rules )'), |
|
| 41 | 41 | // Deprecated files |
| 42 | - 'wp-layout.css' => __( 'Stylesheet' ), |
|
| 43 | - 'wp-comments.php' => __( 'Comments Template' ), |
|
| 44 | - 'wp-comments-popup.php' => __( 'Popup Comments Template' ), |
|
| 42 | + 'wp-layout.css' => __('Stylesheet'), |
|
| 43 | + 'wp-comments.php' => __('Comments Template'), |
|
| 44 | + 'wp-comments-popup.php' => __('Popup Comments Template'), |
|
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | * @param string $file Filesystem path or filename |
| 55 | 55 | * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist |
| 56 | 56 | */ |
| 57 | -function get_file_description( $file ) { |
|
| 57 | +function get_file_description($file) { |
|
| 58 | 58 | global $wp_file_descriptions; |
| 59 | 59 | |
| 60 | - if ( isset( $wp_file_descriptions[basename( $file )] ) ) { |
|
| 61 | - return $wp_file_descriptions[basename( $file )]; |
|
| 60 | + if (isset($wp_file_descriptions[basename($file)])) { |
|
| 61 | + return $wp_file_descriptions[basename($file)]; |
|
| 62 | 62 | } |
| 63 | - elseif ( file_exists( $file ) && is_file( $file ) ) { |
|
| 64 | - $template_data = implode( '', file( $file ) ); |
|
| 65 | - if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) |
|
| 66 | - return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) ); |
|
| 63 | + elseif (file_exists($file) && is_file($file)) { |
|
| 64 | + $template_data = implode('', file($file)); |
|
| 65 | + if (preg_match('|Template Name:(.*)$|mi', $template_data, $name)) |
|
| 66 | + return sprintf(__('%s Page Template'), _cleanup_header_comment($name[1])); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - return trim( basename( $file ) ); |
|
| 69 | + return trim(basename($file)); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | * @return string Full filesystem path to the root of the WordPress installation |
| 78 | 78 | */ |
| 79 | 79 | function get_home_path() { |
| 80 | - $home = set_url_scheme( get_option( 'home' ), 'http' ); |
|
| 81 | - $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' ); |
|
| 82 | - if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) { |
|
| 83 | - $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */ |
|
| 84 | - $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) ); |
|
| 85 | - $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); |
|
| 86 | - $home_path = trailingslashit( $home_path ); |
|
| 80 | + $home = set_url_scheme(get_option('home'), 'http'); |
|
| 81 | + $siteurl = set_url_scheme(get_option('siteurl'), 'http'); |
|
| 82 | + if ( ! empty($home) && 0 !== strcasecmp($home, $siteurl)) { |
|
| 83 | + $wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */ |
|
| 84 | + $pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home)); |
|
| 85 | + $home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos); |
|
| 86 | + $home_path = trailingslashit($home_path); |
|
| 87 | 87 | } else { |
| 88 | 88 | $home_path = ABSPATH; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - return str_replace( '\\', '/', $home_path ); |
|
| 91 | + return str_replace('\\', '/', $home_path); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -101,30 +101,30 @@ discard block |
||
| 101 | 101 | * @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit). |
| 102 | 102 | * @return bool|array False on failure, Else array of files |
| 103 | 103 | */ |
| 104 | -function list_files( $folder = '', $levels = 100 ) { |
|
| 105 | - if ( empty($folder) ) |
|
| 104 | +function list_files($folder = '', $levels = 100) { |
|
| 105 | + if (empty($folder)) |
|
| 106 | 106 | return false; |
| 107 | 107 | |
| 108 | - if ( ! $levels ) |
|
| 108 | + if ( ! $levels) |
|
| 109 | 109 | return false; |
| 110 | 110 | |
| 111 | 111 | $files = array(); |
| 112 | - if ( $dir = @opendir( $folder ) ) { |
|
| 113 | - while (($file = readdir( $dir ) ) !== false ) { |
|
| 114 | - if ( in_array($file, array('.', '..') ) ) |
|
| 112 | + if ($dir = @opendir($folder)) { |
|
| 113 | + while (($file = readdir($dir)) !== false) { |
|
| 114 | + if (in_array($file, array('.', '..'))) |
|
| 115 | 115 | continue; |
| 116 | - if ( is_dir( $folder . '/' . $file ) ) { |
|
| 117 | - $files2 = list_files( $folder . '/' . $file, $levels - 1); |
|
| 118 | - if ( $files2 ) |
|
| 119 | - $files = array_merge($files, $files2 ); |
|
| 116 | + if (is_dir($folder.'/'.$file)) { |
|
| 117 | + $files2 = list_files($folder.'/'.$file, $levels - 1); |
|
| 118 | + if ($files2) |
|
| 119 | + $files = array_merge($files, $files2); |
|
| 120 | 120 | else |
| 121 | - $files[] = $folder . '/' . $file . '/'; |
|
| 121 | + $files[] = $folder.'/'.$file.'/'; |
|
| 122 | 122 | } else { |
| 123 | - $files[] = $folder . '/' . $file; |
|
| 123 | + $files[] = $folder.'/'.$file; |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | - @closedir( $dir ); |
|
| 127 | + @closedir($dir); |
|
| 128 | 128 | return $files; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -141,27 +141,27 @@ discard block |
||
| 141 | 141 | * @param string $dir Optional. Directory to store the file in. Default empty. |
| 142 | 142 | * @return string a writable filename |
| 143 | 143 | */ |
| 144 | -function wp_tempnam( $filename = '', $dir = '' ) { |
|
| 145 | - if ( empty( $dir ) ) { |
|
| 144 | +function wp_tempnam($filename = '', $dir = '') { |
|
| 145 | + if (empty($dir)) { |
|
| 146 | 146 | $dir = get_temp_dir(); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( empty( $filename ) || '.' == $filename || '/' == $filename ) { |
|
| 149 | + if (empty($filename) || '.' == $filename || '/' == $filename) { |
|
| 150 | 150 | $filename = time(); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Use the basename of the given file without the extension as the name for the temporary directory |
| 154 | - $temp_filename = basename( $filename ); |
|
| 155 | - $temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename ); |
|
| 154 | + $temp_filename = basename($filename); |
|
| 155 | + $temp_filename = preg_replace('|\.[^.]*$|', '', $temp_filename); |
|
| 156 | 156 | |
| 157 | 157 | // If the folder is falsey, use it's parent directory name instead |
| 158 | - if ( ! $temp_filename ) { |
|
| 159 | - return wp_tempnam( dirname( $filename ), $dir ); |
|
| 158 | + if ( ! $temp_filename) { |
|
| 159 | + return wp_tempnam(dirname($filename), $dir); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $temp_filename .= '.tmp'; |
| 163 | - $temp_filename = $dir . wp_unique_filename( $dir, $temp_filename ); |
|
| 164 | - touch( $temp_filename ); |
|
| 163 | + $temp_filename = $dir.wp_unique_filename($dir, $temp_filename); |
|
| 164 | + touch($temp_filename); |
|
| 165 | 165 | |
| 166 | 166 | return $temp_filename; |
| 167 | 167 | } |
@@ -177,21 +177,21 @@ discard block |
||
| 177 | 177 | * @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly |
| 178 | 178 | * @return string|null |
| 179 | 179 | */ |
| 180 | -function validate_file_to_edit( $file, $allowed_files = '' ) { |
|
| 181 | - $code = validate_file( $file, $allowed_files ); |
|
| 180 | +function validate_file_to_edit($file, $allowed_files = '') { |
|
| 181 | + $code = validate_file($file, $allowed_files); |
|
| 182 | 182 | |
| 183 | - if (!$code ) |
|
| 183 | + if ( ! $code) |
|
| 184 | 184 | return $file; |
| 185 | 185 | |
| 186 | - switch ( $code ) { |
|
| 186 | + switch ($code) { |
|
| 187 | 187 | case 1 : |
| 188 | - wp_die( __( 'Sorry, that file cannot be edited.' ) ); |
|
| 188 | + wp_die(__('Sorry, that file cannot be edited.')); |
|
| 189 | 189 | |
| 190 | 190 | // case 2 : |
| 191 | 191 | // wp_die( __('Sorry, can’t call files with their real path.' )); |
| 192 | 192 | |
| 193 | 193 | case 3 : |
| 194 | - wp_die( __( 'Sorry, that file cannot be edited.' ) ); |
|
| 194 | + wp_die(__('Sorry, that file cannot be edited.')); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | * @return array On success, returns an associative array of file attributes. On failure, returns |
| 211 | 211 | * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). |
| 212 | 212 | */ |
| 213 | -function _wp_handle_upload( &$file, $overrides, $time, $action ) { |
|
| 213 | +function _wp_handle_upload(&$file, $overrides, $time, $action) { |
|
| 214 | 214 | // The default error handler. |
| 215 | - if ( ! function_exists( 'wp_handle_upload_error' ) ) { |
|
| 216 | - function wp_handle_upload_error( &$file, $message ) { |
|
| 217 | - return array( 'error' => $message ); |
|
| 215 | + if ( ! function_exists('wp_handle_upload_error')) { |
|
| 216 | + function wp_handle_upload_error(&$file, $message) { |
|
| 217 | + return array('error' => $message); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -228,24 +228,24 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @param array $file An array of data for a single file. |
| 230 | 230 | */ |
| 231 | - $file = apply_filters( "{$action}_prefilter", $file ); |
|
| 231 | + $file = apply_filters("{$action}_prefilter", $file); |
|
| 232 | 232 | |
| 233 | 233 | // You may define your own function and pass the name in $overrides['upload_error_handler'] |
| 234 | 234 | $upload_error_handler = 'wp_handle_upload_error'; |
| 235 | - if ( isset( $overrides['upload_error_handler'] ) ) { |
|
| 235 | + if (isset($overrides['upload_error_handler'])) { |
|
| 236 | 236 | $upload_error_handler = $overrides['upload_error_handler']; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully. |
| 240 | - if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) { |
|
| 241 | - return $upload_error_handler( $file, $file['error'] ); |
|
| 240 | + if (isset($file['error']) && ! is_numeric($file['error']) && $file['error']) { |
|
| 241 | + return $upload_error_handler($file, $file['error']); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Install user overrides. Did we mention that this voids your warranty? |
| 245 | 245 | |
| 246 | 246 | // You may define your own function and pass the name in $overrides['unique_filename_callback'] |
| 247 | 247 | $unique_filename_callback = null; |
| 248 | - if ( isset( $overrides['unique_filename_callback'] ) ) { |
|
| 248 | + if (isset($overrides['unique_filename_callback'])) { |
|
| 249 | 249 | $unique_filename_callback = $overrides['unique_filename_callback']; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -253,72 +253,72 @@ discard block |
||
| 253 | 253 | * This may not have orignially been intended to be overrideable, |
| 254 | 254 | * but historically has been. |
| 255 | 255 | */ |
| 256 | - if ( isset( $overrides['upload_error_strings'] ) ) { |
|
| 256 | + if (isset($overrides['upload_error_strings'])) { |
|
| 257 | 257 | $upload_error_strings = $overrides['upload_error_strings']; |
| 258 | 258 | } else { |
| 259 | 259 | // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. |
| 260 | 260 | $upload_error_strings = array( |
| 261 | 261 | false, |
| 262 | - __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.' ), |
|
| 263 | - __( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.' ), |
|
| 264 | - __( 'The uploaded file was only partially uploaded.' ), |
|
| 265 | - __( 'No file was uploaded.' ), |
|
| 262 | + __('The uploaded file exceeds the upload_max_filesize directive in php.ini.'), |
|
| 263 | + __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'), |
|
| 264 | + __('The uploaded file was only partially uploaded.'), |
|
| 265 | + __('No file was uploaded.'), |
|
| 266 | 266 | '', |
| 267 | - __( 'Missing a temporary folder.' ), |
|
| 268 | - __( 'Failed to write file to disk.' ), |
|
| 269 | - __( 'File upload stopped by extension.' ) |
|
| 267 | + __('Missing a temporary folder.'), |
|
| 268 | + __('Failed to write file to disk.'), |
|
| 269 | + __('File upload stopped by extension.') |
|
| 270 | 270 | ); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false; |
| 274 | - $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true; |
|
| 275 | - $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true; |
|
| 274 | + $test_form = isset($overrides['test_form']) ? $overrides['test_form'] : true; |
|
| 275 | + $test_size = isset($overrides['test_size']) ? $overrides['test_size'] : true; |
|
| 276 | 276 | |
| 277 | 277 | // If you override this, you must provide $ext and $type!! |
| 278 | - $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true; |
|
| 279 | - $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false; |
|
| 278 | + $test_type = isset($overrides['test_type']) ? $overrides['test_type'] : true; |
|
| 279 | + $mimes = isset($overrides['mimes']) ? $overrides['mimes'] : false; |
|
| 280 | 280 | |
| 281 | 281 | // A correct form post will pass this test. |
| 282 | - if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) { |
|
| 283 | - return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) ); |
|
| 282 | + if ($test_form && ( ! isset($_POST['action']) || ($_POST['action'] != $action))) { |
|
| 283 | + return call_user_func($upload_error_handler, $file, __('Invalid form submission.')); |
|
| 284 | 284 | } |
| 285 | 285 | // A successful upload will pass this test. It makes no sense to override this one. |
| 286 | - if ( isset( $file['error'] ) && $file['error'] > 0 ) { |
|
| 287 | - return call_user_func( $upload_error_handler, $file, $upload_error_strings[ $file['error'] ] ); |
|
| 286 | + if (isset($file['error']) && $file['error'] > 0) { |
|
| 287 | + return call_user_func($upload_error_handler, $file, $upload_error_strings[$file['error']]); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] ); |
|
| 290 | + $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize($file['tmp_name']); |
|
| 291 | 291 | // A non-empty file will pass this test. |
| 292 | - if ( $test_size && ! ( $test_file_size > 0 ) ) { |
|
| 293 | - if ( is_multisite() ) { |
|
| 294 | - $error_msg = __( 'File is empty. Please upload something more substantial.' ); |
|
| 292 | + if ($test_size && ! ($test_file_size > 0)) { |
|
| 293 | + if (is_multisite()) { |
|
| 294 | + $error_msg = __('File is empty. Please upload something more substantial.'); |
|
| 295 | 295 | } else { |
| 296 | - $error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ); |
|
| 296 | + $error_msg = __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.'); |
|
| 297 | 297 | } |
| 298 | - return call_user_func( $upload_error_handler, $file, $error_msg ); |
|
| 298 | + return call_user_func($upload_error_handler, $file, $error_msg); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | // A properly uploaded file will pass this test. There should be no reason to override this one. |
| 302 | - $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] ); |
|
| 303 | - if ( ! $test_uploaded_file ) { |
|
| 304 | - return call_user_func( $upload_error_handler, $file, __( 'Specified file failed upload test.' ) ); |
|
| 302 | + $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file($file['tmp_name']) : @ is_file($file['tmp_name']); |
|
| 303 | + if ( ! $test_uploaded_file) { |
|
| 304 | + return call_user_func($upload_error_handler, $file, __('Specified file failed upload test.')); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. |
| 308 | - if ( $test_type ) { |
|
| 309 | - $wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes ); |
|
| 310 | - $ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext']; |
|
| 311 | - $type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type']; |
|
| 312 | - $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; |
|
| 308 | + if ($test_type) { |
|
| 309 | + $wp_filetype = wp_check_filetype_and_ext($file['tmp_name'], $file['name'], $mimes); |
|
| 310 | + $ext = empty($wp_filetype['ext']) ? '' : $wp_filetype['ext']; |
|
| 311 | + $type = empty($wp_filetype['type']) ? '' : $wp_filetype['type']; |
|
| 312 | + $proper_filename = empty($wp_filetype['proper_filename']) ? '' : $wp_filetype['proper_filename']; |
|
| 313 | 313 | |
| 314 | 314 | // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect |
| 315 | - if ( $proper_filename ) { |
|
| 315 | + if ($proper_filename) { |
|
| 316 | 316 | $file['name'] = $proper_filename; |
| 317 | 317 | } |
| 318 | - if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) { |
|
| 319 | - return call_user_func( $upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ) ); |
|
| 318 | + if (( ! $type || ! $ext) && ! current_user_can('unfiltered_upload')) { |
|
| 319 | + return call_user_func($upload_error_handler, $file, __('Sorry, this file type is not permitted for security reasons.')); |
|
| 320 | 320 | } |
| 321 | - if ( ! $type ) { |
|
| 321 | + if ( ! $type) { |
|
| 322 | 322 | $type = $file['type']; |
| 323 | 323 | } |
| 324 | 324 | } else { |
@@ -329,39 +329,39 @@ discard block |
||
| 329 | 329 | * A writable uploads dir will pass this test. Again, there's no point |
| 330 | 330 | * overriding this one. |
| 331 | 331 | */ |
| 332 | - if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) { |
|
| 333 | - return call_user_func( $upload_error_handler, $file, $uploads['error'] ); |
|
| 332 | + if ( ! (($uploads = wp_upload_dir($time)) && false === $uploads['error'])) { |
|
| 333 | + return call_user_func($upload_error_handler, $file, $uploads['error']); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); |
|
| 336 | + $filename = wp_unique_filename($uploads['path'], $file['name'], $unique_filename_callback); |
|
| 337 | 337 | |
| 338 | 338 | // Move the file to the uploads dir. |
| 339 | - $new_file = $uploads['path'] . "/$filename"; |
|
| 340 | - if ( 'wp_handle_upload' === $action ) { |
|
| 341 | - $move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file ); |
|
| 339 | + $new_file = $uploads['path']."/$filename"; |
|
| 340 | + if ('wp_handle_upload' === $action) { |
|
| 341 | + $move_new_file = @ move_uploaded_file($file['tmp_name'], $new_file); |
|
| 342 | 342 | } else { |
| 343 | - $move_new_file = @ rename( $file['tmp_name'], $new_file ); |
|
| 343 | + $move_new_file = @ rename($file['tmp_name'], $new_file); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - if ( false === $move_new_file ) { |
|
| 347 | - if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) { |
|
| 348 | - $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; |
|
| 346 | + if (false === $move_new_file) { |
|
| 347 | + if (0 === strpos($uploads['basedir'], ABSPATH)) { |
|
| 348 | + $error_path = str_replace(ABSPATH, '', $uploads['basedir']).$uploads['subdir']; |
|
| 349 | 349 | } else { |
| 350 | - $error_path = basename( $uploads['basedir'] ) . $uploads['subdir']; |
|
| 350 | + $error_path = basename($uploads['basedir']).$uploads['subdir']; |
|
| 351 | 351 | } |
| 352 | - return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) ); |
|
| 352 | + return $upload_error_handler($file, sprintf(__('The uploaded file could not be moved to %s.'), $error_path)); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // Set correct file permissions. |
| 356 | - $stat = stat( dirname( $new_file )); |
|
| 356 | + $stat = stat(dirname($new_file)); |
|
| 357 | 357 | $perms = $stat['mode'] & 0000666; |
| 358 | - @ chmod( $new_file, $perms ); |
|
| 358 | + @ chmod($new_file, $perms); |
|
| 359 | 359 | |
| 360 | 360 | // Compute the URL. |
| 361 | - $url = $uploads['url'] . "/$filename"; |
|
| 361 | + $url = $uploads['url']."/$filename"; |
|
| 362 | 362 | |
| 363 | - if ( is_multisite() ) { |
|
| 364 | - delete_transient( 'dirsize_cache' ); |
|
| 363 | + if (is_multisite()) { |
|
| 364 | + delete_transient('dirsize_cache'); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
@@ -378,11 +378,11 @@ discard block |
||
| 378 | 378 | * } |
| 379 | 379 | * @param string $context The type of upload action. Values include 'upload' or 'sideload'. |
| 380 | 380 | */ |
| 381 | - return apply_filters( 'wp_handle_upload', array( |
|
| 381 | + return apply_filters('wp_handle_upload', array( |
|
| 382 | 382 | 'file' => $new_file, |
| 383 | 383 | 'url' => $url, |
| 384 | 384 | 'type' => $type |
| 385 | - ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' ); } |
|
| 385 | + ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload'); } |
|
| 386 | 386 | |
| 387 | 387 | /** |
| 388 | 388 | * Wrapper for _wp_handle_upload(), passes 'wp_handle_upload' action. |
@@ -399,17 +399,17 @@ discard block |
||
| 399 | 399 | * @return array On success, returns an associative array of file attributes. On failure, returns |
| 400 | 400 | * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). |
| 401 | 401 | */ |
| 402 | -function wp_handle_upload( &$file, $overrides = false, $time = null ) { |
|
| 402 | +function wp_handle_upload(&$file, $overrides = false, $time = null) { |
|
| 403 | 403 | /* |
| 404 | 404 | * $_POST['action'] must be set and its value must equal $overrides['action'] |
| 405 | 405 | * or this: |
| 406 | 406 | */ |
| 407 | 407 | $action = 'wp_handle_upload'; |
| 408 | - if ( isset( $overrides['action'] ) ) { |
|
| 408 | + if (isset($overrides['action'])) { |
|
| 409 | 409 | $action = $overrides['action']; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - return _wp_handle_upload( $file, $overrides, $time, $action ); |
|
| 412 | + return _wp_handle_upload($file, $overrides, $time, $action); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -426,16 +426,16 @@ discard block |
||
| 426 | 426 | * @return array On success, returns an associative array of file attributes. On failure, returns |
| 427 | 427 | * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). |
| 428 | 428 | */ |
| 429 | -function wp_handle_sideload( &$file, $overrides = false, $time = null ) { |
|
| 429 | +function wp_handle_sideload(&$file, $overrides = false, $time = null) { |
|
| 430 | 430 | /* |
| 431 | 431 | * $_POST['action'] must be set and its value must equal $overrides['action'] |
| 432 | 432 | * or this: |
| 433 | 433 | */ |
| 434 | 434 | $action = 'wp_handle_sideload'; |
| 435 | - if ( isset( $overrides['action'] ) ) { |
|
| 435 | + if (isset($overrides['action'])) { |
|
| 436 | 436 | $action = $overrides['action']; |
| 437 | 437 | } |
| 438 | - return _wp_handle_upload( $file, $overrides, $time, $action ); |
|
| 438 | + return _wp_handle_upload($file, $overrides, $time, $action); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
@@ -449,32 +449,32 @@ discard block |
||
| 449 | 449 | * @param int $timeout The timeout for the request to download the file default 300 seconds |
| 450 | 450 | * @return mixed WP_Error on failure, string Filename on success. |
| 451 | 451 | */ |
| 452 | -function download_url( $url, $timeout = 300 ) { |
|
| 452 | +function download_url($url, $timeout = 300) { |
|
| 453 | 453 | //WARNING: The file is not automatically deleted, The script must unlink() the file. |
| 454 | - if ( ! $url ) |
|
| 454 | + if ( ! $url) |
|
| 455 | 455 | return new WP_Error('http_no_url', __('Invalid URL Provided.')); |
| 456 | 456 | |
| 457 | 457 | $tmpfname = wp_tempnam($url); |
| 458 | - if ( ! $tmpfname ) |
|
| 458 | + if ( ! $tmpfname) |
|
| 459 | 459 | return new WP_Error('http_no_file', __('Could not create Temporary file.')); |
| 460 | 460 | |
| 461 | - $response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) ); |
|
| 461 | + $response = wp_safe_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname)); |
|
| 462 | 462 | |
| 463 | - if ( is_wp_error( $response ) ) { |
|
| 464 | - unlink( $tmpfname ); |
|
| 463 | + if (is_wp_error($response)) { |
|
| 464 | + unlink($tmpfname); |
|
| 465 | 465 | return $response; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( 200 != wp_remote_retrieve_response_code( $response ) ){ |
|
| 469 | - unlink( $tmpfname ); |
|
| 470 | - return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) ); |
|
| 468 | + if (200 != wp_remote_retrieve_response_code($response)) { |
|
| 469 | + unlink($tmpfname); |
|
| 470 | + return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response))); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); |
|
| 474 | - if ( $content_md5 ) { |
|
| 475 | - $md5_check = verify_file_md5( $tmpfname, $content_md5 ); |
|
| 476 | - if ( is_wp_error( $md5_check ) ) { |
|
| 477 | - unlink( $tmpfname ); |
|
| 473 | + $content_md5 = wp_remote_retrieve_header($response, 'content-md5'); |
|
| 474 | + if ($content_md5) { |
|
| 475 | + $md5_check = verify_file_md5($tmpfname, $content_md5); |
|
| 476 | + if (is_wp_error($md5_check)) { |
|
| 477 | + unlink($tmpfname); |
|
| 478 | 478 | return $md5_check; |
| 479 | 479 | } |
| 480 | 480 | } |
@@ -491,20 +491,20 @@ discard block |
||
| 491 | 491 | * @param string $expected_md5 The expected MD5 of the file, either a base64 encoded raw md5, or a hex-encoded md5 |
| 492 | 492 | * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected |
| 493 | 493 | */ |
| 494 | -function verify_file_md5( $filename, $expected_md5 ) { |
|
| 495 | - if ( 32 == strlen( $expected_md5 ) ) |
|
| 496 | - $expected_raw_md5 = pack( 'H*', $expected_md5 ); |
|
| 497 | - elseif ( 24 == strlen( $expected_md5 ) ) |
|
| 498 | - $expected_raw_md5 = base64_decode( $expected_md5 ); |
|
| 494 | +function verify_file_md5($filename, $expected_md5) { |
|
| 495 | + if (32 == strlen($expected_md5)) |
|
| 496 | + $expected_raw_md5 = pack('H*', $expected_md5); |
|
| 497 | + elseif (24 == strlen($expected_md5)) |
|
| 498 | + $expected_raw_md5 = base64_decode($expected_md5); |
|
| 499 | 499 | else |
| 500 | 500 | return false; // unknown format |
| 501 | 501 | |
| 502 | - $file_md5 = md5_file( $filename, true ); |
|
| 502 | + $file_md5 = md5_file($filename, true); |
|
| 503 | 503 | |
| 504 | - if ( $file_md5 === $expected_raw_md5 ) |
|
| 504 | + if ($file_md5 === $expected_raw_md5) |
|
| 505 | 505 | return true; |
| 506 | 506 | |
| 507 | - return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) ); |
|
| 507 | + return new WP_Error('md5_mismatch', sprintf(__('The checksum of the file (%1$s) does not match the expected checksum value (%2$s).'), bin2hex($file_md5), bin2hex($expected_raw_md5))); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | /** |
@@ -525,28 +525,28 @@ discard block |
||
| 525 | 525 | function unzip_file($file, $to) { |
| 526 | 526 | global $wp_filesystem; |
| 527 | 527 | |
| 528 | - if ( ! $wp_filesystem || !is_object($wp_filesystem) ) |
|
| 528 | + if ( ! $wp_filesystem || ! is_object($wp_filesystem)) |
|
| 529 | 529 | return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
| 530 | 530 | |
| 531 | 531 | // Unzip can use a lot of memory, but not this much hopefully |
| 532 | 532 | /** This filter is documented in wp-admin/admin.php */ |
| 533 | - @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
| 533 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
| 534 | 534 | |
| 535 | 535 | $needed_dirs = array(); |
| 536 | 536 | $to = trailingslashit($to); |
| 537 | 537 | |
| 538 | 538 | // Determine any parent dir's needed (of the upgrade directory) |
| 539 | - if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist |
|
| 539 | + if ( ! $wp_filesystem->is_dir($to)) { //Only do parents if no children exist |
|
| 540 | 540 | $path = preg_split('![/\\\]!', untrailingslashit($to)); |
| 541 | - for ( $i = count($path); $i >= 0; $i-- ) { |
|
| 542 | - if ( empty($path[$i]) ) |
|
| 541 | + for ($i = count($path); $i >= 0; $i--) { |
|
| 542 | + if (empty($path[$i])) |
|
| 543 | 543 | continue; |
| 544 | 544 | |
| 545 | - $dir = implode('/', array_slice($path, 0, $i+1) ); |
|
| 546 | - if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter. |
|
| 545 | + $dir = implode('/', array_slice($path, 0, $i + 1)); |
|
| 546 | + if (preg_match('!^[a-z]:$!i', $dir)) // Skip it if it looks like a Windows Drive letter. |
|
| 547 | 547 | continue; |
| 548 | 548 | |
| 549 | - if ( ! $wp_filesystem->is_dir($dir) ) |
|
| 549 | + if ( ! $wp_filesystem->is_dir($dir)) |
|
| 550 | 550 | $needed_dirs[] = $dir; |
| 551 | 551 | else |
| 552 | 552 | break; // A folder exists, therefor, we dont need the check the levels below this |
@@ -560,12 +560,12 @@ discard block |
||
| 560 | 560 | * |
| 561 | 561 | * @param bool $ziparchive Whether to use ZipArchive. Default true. |
| 562 | 562 | */ |
| 563 | - if ( class_exists( 'ZipArchive' ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) { |
|
| 563 | + if (class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true)) { |
|
| 564 | 564 | $result = _unzip_file_ziparchive($file, $to, $needed_dirs); |
| 565 | - if ( true === $result ) { |
|
| 565 | + if (true === $result) { |
|
| 566 | 566 | return $result; |
| 567 | - } elseif ( is_wp_error($result) ) { |
|
| 568 | - if ( 'incompatible_archive' != $result->get_error_code() ) |
|
| 567 | + } elseif (is_wp_error($result)) { |
|
| 568 | + if ('incompatible_archive' != $result->get_error_code()) |
|
| 569 | 569 | return $result; |
| 570 | 570 | } |
| 571 | 571 | } |
@@ -588,30 +588,30 @@ discard block |
||
| 588 | 588 | * @param array $needed_dirs A partial list of required folders needed to be created. |
| 589 | 589 | * @return mixed WP_Error on failure, True on success |
| 590 | 590 | */ |
| 591 | -function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) { |
|
| 591 | +function _unzip_file_ziparchive($file, $to, $needed_dirs = array()) { |
|
| 592 | 592 | global $wp_filesystem; |
| 593 | 593 | |
| 594 | 594 | $z = new ZipArchive(); |
| 595 | 595 | |
| 596 | - $zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS ); |
|
| 597 | - if ( true !== $zopen ) |
|
| 598 | - return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) ); |
|
| 596 | + $zopen = $z->open($file, ZIPARCHIVE::CHECKCONS); |
|
| 597 | + if (true !== $zopen) |
|
| 598 | + return new WP_Error('incompatible_archive', __('Incompatible Archive.'), array('ziparchive_error' => $zopen)); |
|
| 599 | 599 | |
| 600 | 600 | $uncompressed_size = 0; |
| 601 | 601 | |
| 602 | - for ( $i = 0; $i < $z->numFiles; $i++ ) { |
|
| 603 | - if ( ! $info = $z->statIndex($i) ) |
|
| 604 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 602 | + for ($i = 0; $i < $z->numFiles; $i++) { |
|
| 603 | + if ( ! $info = $z->statIndex($i)) |
|
| 604 | + return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.')); |
|
| 605 | 605 | |
| 606 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
| 606 | + if ('__MACOSX/' === substr($info['name'], 0, 9)) // Skip the OS X-created __MACOSX directory |
|
| 607 | 607 | continue; |
| 608 | 608 | |
| 609 | 609 | $uncompressed_size += $info['size']; |
| 610 | 610 | |
| 611 | - if ( '/' == substr($info['name'], -1) ) // directory |
|
| 612 | - $needed_dirs[] = $to . untrailingslashit($info['name']); |
|
| 611 | + if ('/' == substr($info['name'], -1)) // directory |
|
| 612 | + $needed_dirs[] = $to.untrailingslashit($info['name']); |
|
| 613 | 613 | else |
| 614 | - $needed_dirs[] = $to . untrailingslashit(dirname($info['name'])); |
|
| 614 | + $needed_dirs[] = $to.untrailingslashit(dirname($info['name'])); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | /* |
@@ -619,22 +619,22 @@ discard block |
||
| 619 | 619 | * A disk that has zero free bytes has bigger problems. |
| 620 | 620 | * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
| 621 | 621 | */ |
| 622 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
| 623 | - $available_space = @disk_free_space( WP_CONTENT_DIR ); |
|
| 624 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
| 625 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 622 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
| 623 | + $available_space = @disk_free_space(WP_CONTENT_DIR); |
|
| 624 | + if ($available_space && ($uncompressed_size * 2.1) > $available_space) |
|
| 625 | + return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space')); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | $needed_dirs = array_unique($needed_dirs); |
| 629 | - foreach ( $needed_dirs as $dir ) { |
|
| 629 | + foreach ($needed_dirs as $dir) { |
|
| 630 | 630 | // Check the parent folders of the folders all exist within the creation array. |
| 631 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
| 631 | + if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist) |
|
| 632 | 632 | continue; |
| 633 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
| 633 | + if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it |
|
| 634 | 634 | continue; |
| 635 | 635 | |
| 636 | 636 | $parent_folder = dirname($dir); |
| 637 | - while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
|
| 637 | + while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) { |
|
| 638 | 638 | $needed_dirs[] = $parent_folder; |
| 639 | 639 | $parent_folder = dirname($parent_folder); |
| 640 | 640 | } |
@@ -642,30 +642,30 @@ discard block |
||
| 642 | 642 | asort($needed_dirs); |
| 643 | 643 | |
| 644 | 644 | // Create those directories if need be: |
| 645 | - foreach ( $needed_dirs as $_dir ) { |
|
| 645 | + foreach ($needed_dirs as $_dir) { |
|
| 646 | 646 | // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
| 647 | - if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
| 648 | - return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
| 647 | + if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir)) { |
|
| 648 | + return new WP_Error('mkdir_failed_ziparchive', __('Could not create directory.'), substr($_dir, strlen($to))); |
|
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | unset($needed_dirs); |
| 652 | 652 | |
| 653 | - for ( $i = 0; $i < $z->numFiles; $i++ ) { |
|
| 654 | - if ( ! $info = $z->statIndex($i) ) |
|
| 655 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 653 | + for ($i = 0; $i < $z->numFiles; $i++) { |
|
| 654 | + if ( ! $info = $z->statIndex($i)) |
|
| 655 | + return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.')); |
|
| 656 | 656 | |
| 657 | - if ( '/' == substr($info['name'], -1) ) // directory |
|
| 657 | + if ('/' == substr($info['name'], -1)) // directory |
|
| 658 | 658 | continue; |
| 659 | 659 | |
| 660 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
| 660 | + if ('__MACOSX/' === substr($info['name'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files |
|
| 661 | 661 | continue; |
| 662 | 662 | |
| 663 | 663 | $contents = $z->getFromIndex($i); |
| 664 | - if ( false === $contents ) |
|
| 665 | - return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); |
|
| 664 | + if (false === $contents) |
|
| 665 | + return new WP_Error('extract_failed_ziparchive', __('Could not extract file from archive.'), $info['name']); |
|
| 666 | 666 | |
| 667 | - if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) |
|
| 668 | - return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] ); |
|
| 667 | + if ( ! $wp_filesystem->put_contents($to.$info['name'], $contents, FS_CHMOD_FILE)) |
|
| 668 | + return new WP_Error('copy_failed_ziparchive', __('Could not copy file.'), $info['name']); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | $z->close(); |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | |
| 694 | 694 | mbstring_binary_safe_encoding(); |
| 695 | 695 | |
| 696 | - require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); |
|
| 696 | + require_once(ABSPATH.'wp-admin/includes/class-pclzip.php'); |
|
| 697 | 697 | |
| 698 | 698 | $archive = new PclZip($file); |
| 699 | 699 | |
@@ -702,22 +702,22 @@ discard block |
||
| 702 | 702 | reset_mbstring_encoding(); |
| 703 | 703 | |
| 704 | 704 | // Is the archive valid? |
| 705 | - if ( !is_array($archive_files) ) |
|
| 705 | + if ( ! is_array($archive_files)) |
|
| 706 | 706 | return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); |
| 707 | 707 | |
| 708 | - if ( 0 == count($archive_files) ) |
|
| 709 | - return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) ); |
|
| 708 | + if (0 == count($archive_files)) |
|
| 709 | + return new WP_Error('empty_archive_pclzip', __('Empty archive.')); |
|
| 710 | 710 | |
| 711 | 711 | $uncompressed_size = 0; |
| 712 | 712 | |
| 713 | 713 | // Determine any children directories needed (From within the archive) |
| 714 | - foreach ( $archive_files as $file ) { |
|
| 715 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
| 714 | + foreach ($archive_files as $file) { |
|
| 715 | + if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Skip the OS X-created __MACOSX directory |
|
| 716 | 716 | continue; |
| 717 | 717 | |
| 718 | 718 | $uncompressed_size += $file['size']; |
| 719 | 719 | |
| 720 | - $needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) ); |
|
| 720 | + $needed_dirs[] = $to.untrailingslashit($file['folder'] ? $file['filename'] : dirname($file['filename'])); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /* |
@@ -725,22 +725,22 @@ discard block |
||
| 725 | 725 | * A disk that has zero free bytes has bigger problems. |
| 726 | 726 | * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
| 727 | 727 | */ |
| 728 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
| 729 | - $available_space = @disk_free_space( WP_CONTENT_DIR ); |
|
| 730 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
| 731 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 728 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
| 729 | + $available_space = @disk_free_space(WP_CONTENT_DIR); |
|
| 730 | + if ($available_space && ($uncompressed_size * 2.1) > $available_space) |
|
| 731 | + return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space')); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | $needed_dirs = array_unique($needed_dirs); |
| 735 | - foreach ( $needed_dirs as $dir ) { |
|
| 735 | + foreach ($needed_dirs as $dir) { |
|
| 736 | 736 | // Check the parent folders of the folders all exist within the creation array. |
| 737 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
| 737 | + if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist) |
|
| 738 | 738 | continue; |
| 739 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
| 739 | + if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it |
|
| 740 | 740 | continue; |
| 741 | 741 | |
| 742 | 742 | $parent_folder = dirname($dir); |
| 743 | - while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
|
| 743 | + while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) { |
|
| 744 | 744 | $needed_dirs[] = $parent_folder; |
| 745 | 745 | $parent_folder = dirname($parent_folder); |
| 746 | 746 | } |
@@ -748,23 +748,23 @@ discard block |
||
| 748 | 748 | asort($needed_dirs); |
| 749 | 749 | |
| 750 | 750 | // Create those directories if need be: |
| 751 | - foreach ( $needed_dirs as $_dir ) { |
|
| 751 | + foreach ($needed_dirs as $_dir) { |
|
| 752 | 752 | // Only check to see if the dir exists upon creation failure. Less I/O this way. |
| 753 | - if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) |
|
| 754 | - return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
| 753 | + if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir)) |
|
| 754 | + return new WP_Error('mkdir_failed_pclzip', __('Could not create directory.'), substr($_dir, strlen($to))); |
|
| 755 | 755 | } |
| 756 | 756 | unset($needed_dirs); |
| 757 | 757 | |
| 758 | 758 | // Extract the files from the zip |
| 759 | - foreach ( $archive_files as $file ) { |
|
| 760 | - if ( $file['folder'] ) |
|
| 759 | + foreach ($archive_files as $file) { |
|
| 760 | + if ($file['folder']) |
|
| 761 | 761 | continue; |
| 762 | 762 | |
| 763 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
| 763 | + if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files |
|
| 764 | 764 | continue; |
| 765 | 765 | |
| 766 | - if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) |
|
| 767 | - return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); |
|
| 766 | + if ( ! $wp_filesystem->put_contents($to.$file['filename'], $file['content'], FS_CHMOD_FILE)) |
|
| 767 | + return new WP_Error('copy_failed_pclzip', __('Could not copy file.'), $file['filename']); |
|
| 768 | 768 | } |
| 769 | 769 | return true; |
| 770 | 770 | } |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | * @param array $skip_list a list of files/folders to skip copying |
| 783 | 783 | * @return mixed WP_Error on failure, True on success. |
| 784 | 784 | */ |
| 785 | -function copy_dir($from, $to, $skip_list = array() ) { |
|
| 785 | +function copy_dir($from, $to, $skip_list = array()) { |
|
| 786 | 786 | global $wp_filesystem; |
| 787 | 787 | |
| 788 | 788 | $dirlist = $wp_filesystem->dirlist($from); |
@@ -790,32 +790,32 @@ discard block |
||
| 790 | 790 | $from = trailingslashit($from); |
| 791 | 791 | $to = trailingslashit($to); |
| 792 | 792 | |
| 793 | - foreach ( (array) $dirlist as $filename => $fileinfo ) { |
|
| 794 | - if ( in_array( $filename, $skip_list ) ) |
|
| 793 | + foreach ((array) $dirlist as $filename => $fileinfo) { |
|
| 794 | + if (in_array($filename, $skip_list)) |
|
| 795 | 795 | continue; |
| 796 | 796 | |
| 797 | - if ( 'f' == $fileinfo['type'] ) { |
|
| 798 | - if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { |
|
| 797 | + if ('f' == $fileinfo['type']) { |
|
| 798 | + if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE)) { |
|
| 799 | 799 | // If copy failed, chmod file to 0644 and try again. |
| 800 | - $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); |
|
| 801 | - if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) |
|
| 802 | - return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
|
| 800 | + $wp_filesystem->chmod($to.$filename, FS_CHMOD_FILE); |
|
| 801 | + if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE)) |
|
| 802 | + return new WP_Error('copy_failed_copy_dir', __('Could not copy file.'), $to.$filename); |
|
| 803 | 803 | } |
| 804 | - } elseif ( 'd' == $fileinfo['type'] ) { |
|
| 805 | - if ( !$wp_filesystem->is_dir($to . $filename) ) { |
|
| 806 | - if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) |
|
| 807 | - return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); |
|
| 804 | + } elseif ('d' == $fileinfo['type']) { |
|
| 805 | + if ( ! $wp_filesystem->is_dir($to.$filename)) { |
|
| 806 | + if ( ! $wp_filesystem->mkdir($to.$filename, FS_CHMOD_DIR)) |
|
| 807 | + return new WP_Error('mkdir_failed_copy_dir', __('Could not create directory.'), $to.$filename); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list |
| 811 | 811 | $sub_skip_list = array(); |
| 812 | - foreach ( $skip_list as $skip_item ) { |
|
| 813 | - if ( 0 === strpos( $skip_item, $filename . '/' ) ) |
|
| 814 | - $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); |
|
| 812 | + foreach ($skip_list as $skip_item) { |
|
| 813 | + if (0 === strpos($skip_item, $filename.'/')) |
|
| 814 | + $sub_skip_list[] = preg_replace('!^'.preg_quote($filename, '!').'/!i', '', $skip_item); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $result = copy_dir($from . $filename, $to . $filename, $sub_skip_list); |
|
| 818 | - if ( is_wp_error($result) ) |
|
| 817 | + $result = copy_dir($from.$filename, $to.$filename, $sub_skip_list); |
|
| 818 | + if (is_wp_error($result)) |
|
| 819 | 819 | return $result; |
| 820 | 820 | } |
| 821 | 821 | } |
@@ -839,17 +839,17 @@ discard block |
||
| 839 | 839 | * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. |
| 840 | 840 | * @return null|bool false on failure, true on success. |
| 841 | 841 | */ |
| 842 | -function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) { |
|
| 842 | +function WP_Filesystem($args = false, $context = false, $allow_relaxed_file_ownership = false) { |
|
| 843 | 843 | global $wp_filesystem; |
| 844 | 844 | |
| 845 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
| 845 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
| 846 | 846 | |
| 847 | - $method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership ); |
|
| 847 | + $method = get_filesystem_method($args, $context, $allow_relaxed_file_ownership); |
|
| 848 | 848 | |
| 849 | - if ( ! $method ) |
|
| 849 | + if ( ! $method) |
|
| 850 | 850 | return false; |
| 851 | 851 | |
| 852 | - if ( ! class_exists("WP_Filesystem_$method") ) { |
|
| 852 | + if ( ! class_exists("WP_Filesystem_$method")) { |
|
| 853 | 853 | |
| 854 | 854 | /** |
| 855 | 855 | * Filter the path for a specific filesystem method class file. |
@@ -861,9 +861,9 @@ discard block |
||
| 861 | 861 | * @param string $path Path to the specific filesystem method class file. |
| 862 | 862 | * @param string $method The filesystem method to use. |
| 863 | 863 | */ |
| 864 | - $abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
| 864 | + $abstraction_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
| 865 | 865 | |
| 866 | - if ( ! file_exists($abstraction_file) ) |
|
| 866 | + if ( ! file_exists($abstraction_file)) |
|
| 867 | 867 | return; |
| 868 | 868 | |
| 869 | 869 | require_once($abstraction_file); |
@@ -873,22 +873,22 @@ discard block |
||
| 873 | 873 | $wp_filesystem = new $method($args); |
| 874 | 874 | |
| 875 | 875 | //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default. |
| 876 | - if ( ! defined('FS_CONNECT_TIMEOUT') ) |
|
| 876 | + if ( ! defined('FS_CONNECT_TIMEOUT')) |
|
| 877 | 877 | define('FS_CONNECT_TIMEOUT', 30); |
| 878 | - if ( ! defined('FS_TIMEOUT') ) |
|
| 878 | + if ( ! defined('FS_TIMEOUT')) |
|
| 879 | 879 | define('FS_TIMEOUT', 30); |
| 880 | 880 | |
| 881 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 881 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) |
|
| 882 | 882 | return false; |
| 883 | 883 | |
| 884 | - if ( !$wp_filesystem->connect() ) |
|
| 884 | + if ( ! $wp_filesystem->connect()) |
|
| 885 | 885 | return false; //There was an error connecting to the server. |
| 886 | 886 | |
| 887 | 887 | // Set the permission constants if not already set. |
| 888 | - if ( ! defined('FS_CHMOD_DIR') ) |
|
| 889 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
| 890 | - if ( ! defined('FS_CHMOD_FILE') ) |
|
| 891 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
| 888 | + if ( ! defined('FS_CHMOD_DIR')) |
|
| 889 | + define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755)); |
|
| 890 | + if ( ! defined('FS_CHMOD_FILE')) |
|
| 891 | + define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644)); |
|
| 892 | 892 | |
| 893 | 893 | return true; |
| 894 | 894 | } |
@@ -919,39 +919,39 @@ discard block |
||
| 919 | 919 | * Default false. |
| 920 | 920 | * @return string The transport to use, see description for valid return values. |
| 921 | 921 | */ |
| 922 | -function get_filesystem_method( $args = array(), $context = false, $allow_relaxed_file_ownership = false ) { |
|
| 922 | +function get_filesystem_method($args = array(), $context = false, $allow_relaxed_file_ownership = false) { |
|
| 923 | 923 | $method = defined('FS_METHOD') ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets' |
| 924 | 924 | |
| 925 | - if ( ! $context ) { |
|
| 925 | + if ( ! $context) { |
|
| 926 | 926 | $context = WP_CONTENT_DIR; |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | // If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it. |
| 930 | - if ( WP_LANG_DIR == $context && ! is_dir( $context ) ) { |
|
| 931 | - $context = dirname( $context ); |
|
| 930 | + if (WP_LANG_DIR == $context && ! is_dir($context)) { |
|
| 931 | + $context = dirname($context); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - $context = trailingslashit( $context ); |
|
| 934 | + $context = trailingslashit($context); |
|
| 935 | 935 | |
| 936 | - if ( ! $method ) { |
|
| 936 | + if ( ! $method) { |
|
| 937 | 937 | |
| 938 | - $temp_file_name = $context . 'temp-write-test-' . time(); |
|
| 938 | + $temp_file_name = $context.'temp-write-test-'.time(); |
|
| 939 | 939 | $temp_handle = @fopen($temp_file_name, 'w'); |
| 940 | - if ( $temp_handle ) { |
|
| 940 | + if ($temp_handle) { |
|
| 941 | 941 | |
| 942 | 942 | // Attempt to determine the file owner of the WordPress files, and that of newly created files |
| 943 | 943 | $wp_file_owner = $temp_file_owner = false; |
| 944 | - if ( function_exists('fileowner') ) { |
|
| 945 | - $wp_file_owner = @fileowner( __FILE__ ); |
|
| 946 | - $temp_file_owner = @fileowner( $temp_file_name ); |
|
| 944 | + if (function_exists('fileowner')) { |
|
| 945 | + $wp_file_owner = @fileowner(__FILE__); |
|
| 946 | + $temp_file_owner = @fileowner($temp_file_name); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | - if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) { |
|
| 949 | + if ($wp_file_owner !== false && $wp_file_owner === $temp_file_owner) { |
|
| 950 | 950 | // WordPress is creating files as the same owner as the WordPress files, |
| 951 | 951 | // this means it's safe to modify & create new files via PHP. |
| 952 | 952 | $method = 'direct'; |
| 953 | 953 | $GLOBALS['_wp_filesystem_direct_method'] = 'file_owner'; |
| 954 | - } elseif ( $allow_relaxed_file_ownership ) { |
|
| 954 | + } elseif ($allow_relaxed_file_ownership) { |
|
| 955 | 955 | // The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files |
| 956 | 956 | // safely in this directory. This mode doesn't create new files, only alter existing ones. |
| 957 | 957 | $method = 'direct'; |
@@ -963,9 +963,9 @@ discard block |
||
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2'; |
|
| 967 | - if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; |
|
| 968 | - if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
| 966 | + if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents')) $method = 'ssh2'; |
|
| 967 | + if ( ! $method && extension_loaded('ftp')) $method = 'ftpext'; |
|
| 968 | + if ( ! $method && (extension_loaded('sockets') || function_exists('fsockopen'))) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
| 969 | 969 | |
| 970 | 970 | /** |
| 971 | 971 | * Filter the filesystem method to use. |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | * @param string $context Full path to the directory that is tested for being writable. |
| 978 | 978 | * @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable. |
| 979 | 979 | */ |
| 980 | - return apply_filters( 'filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership ); |
|
| 980 | + return apply_filters('filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership); |
|
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | /** |
@@ -1004,7 +1004,7 @@ discard block |
||
| 1004 | 1004 | * @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable. |
| 1005 | 1005 | * @return bool False on failure. True on success. |
| 1006 | 1006 | */ |
| 1007 | -function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null, $allow_relaxed_file_ownership = false ) { |
|
| 1007 | +function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null, $allow_relaxed_file_ownership = false) { |
|
| 1008 | 1008 | |
| 1009 | 1009 | /** |
| 1010 | 1010 | * Filter the filesystem credentials form output. |
@@ -1024,87 +1024,87 @@ discard block |
||
| 1024 | 1024 | * @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable. |
| 1025 | 1025 | * @param array $extra_fields Extra POST fields. |
| 1026 | 1026 | */ |
| 1027 | - $req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership ); |
|
| 1028 | - if ( '' !== $req_cred ) |
|
| 1027 | + $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership); |
|
| 1028 | + if ('' !== $req_cred) |
|
| 1029 | 1029 | return $req_cred; |
| 1030 | 1030 | |
| 1031 | - if ( empty($type) ) { |
|
| 1032 | - $type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership ); |
|
| 1031 | + if (empty($type)) { |
|
| 1032 | + $type = get_filesystem_method(array(), $context, $allow_relaxed_file_ownership); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | - if ( 'direct' == $type ) |
|
| 1035 | + if ('direct' == $type) |
|
| 1036 | 1036 | return true; |
| 1037 | 1037 | |
| 1038 | - if ( is_null( $extra_fields ) ) |
|
| 1039 | - $extra_fields = array( 'version', 'locale' ); |
|
| 1038 | + if (is_null($extra_fields)) |
|
| 1039 | + $extra_fields = array('version', 'locale'); |
|
| 1040 | 1040 | |
| 1041 | - $credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => '')); |
|
| 1041 | + $credentials = get_option('ftp_credentials', array('hostname' => '', 'username' => '')); |
|
| 1042 | 1042 | |
| 1043 | 1043 | // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option) |
| 1044 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? wp_unslash( $_POST['hostname'] ) : $credentials['hostname']); |
|
| 1045 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? wp_unslash( $_POST['username'] ) : $credentials['username']); |
|
| 1046 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? wp_unslash( $_POST['password'] ) : ''); |
|
| 1044 | + $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : ( ! empty($_POST['hostname']) ? wp_unslash($_POST['hostname']) : $credentials['hostname']); |
|
| 1045 | + $credentials['username'] = defined('FTP_USER') ? FTP_USER : ( ! empty($_POST['username']) ? wp_unslash($_POST['username']) : $credentials['username']); |
|
| 1046 | + $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ( ! empty($_POST['password']) ? wp_unslash($_POST['password']) : ''); |
|
| 1047 | 1047 | |
| 1048 | 1048 | // Check to see if we are setting the public/private keys for ssh |
| 1049 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? wp_unslash( $_POST['public_key'] ) : ''); |
|
| 1050 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? wp_unslash( $_POST['private_key'] ) : ''); |
|
| 1049 | + $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ( ! empty($_POST['public_key']) ? wp_unslash($_POST['public_key']) : ''); |
|
| 1050 | + $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ( ! empty($_POST['private_key']) ? wp_unslash($_POST['private_key']) : ''); |
|
| 1051 | 1051 | |
| 1052 | 1052 | // Sanitize the hostname, Some people might pass in odd-data: |
| 1053 | 1053 | $credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off |
| 1054 | 1054 | |
| 1055 | - if ( strpos($credentials['hostname'], ':') ) { |
|
| 1056 | - list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2); |
|
| 1057 | - if ( ! is_numeric($credentials['port']) ) |
|
| 1055 | + if (strpos($credentials['hostname'], ':')) { |
|
| 1056 | + list($credentials['hostname'], $credentials['port']) = explode(':', $credentials['hostname'], 2); |
|
| 1057 | + if ( ! is_numeric($credentials['port'])) |
|
| 1058 | 1058 | unset($credentials['port']); |
| 1059 | 1059 | } else { |
| 1060 | 1060 | unset($credentials['port']); |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | - if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) { |
|
| 1063 | + if ((defined('FTP_SSH') && FTP_SSH) || (defined('FS_METHOD') && 'ssh2' == FS_METHOD)) { |
|
| 1064 | 1064 | $credentials['connection_type'] = 'ssh'; |
| 1065 | - } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL |
|
| 1065 | + } elseif ((defined('FTP_SSL') && FTP_SSL) && 'ftpext' == $type) { //Only the FTP Extension understands SSL |
|
| 1066 | 1066 | $credentials['connection_type'] = 'ftps'; |
| 1067 | - } elseif ( ! empty( $_POST['connection_type'] ) ) { |
|
| 1068 | - $credentials['connection_type'] = wp_unslash( $_POST['connection_type'] ); |
|
| 1069 | - } elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP |
|
| 1067 | + } elseif ( ! empty($_POST['connection_type'])) { |
|
| 1068 | + $credentials['connection_type'] = wp_unslash($_POST['connection_type']); |
|
| 1069 | + } elseif ( ! isset($credentials['connection_type'])) { //All else fails (And it's not defaulted to something else saved), Default to FTP |
|
| 1070 | 1070 | $credentials['connection_type'] = 'ftp'; |
| 1071 | 1071 | } |
| 1072 | 1072 | if ( ! $error && |
| 1073 | 1073 | ( |
| 1074 | - ( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) || |
|
| 1075 | - ( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) ) |
|
| 1076 | - ) ) { |
|
| 1074 | + ( ! empty($credentials['password']) && ! empty($credentials['username']) && ! empty($credentials['hostname'])) || |
|
| 1075 | + ('ssh' == $credentials['connection_type'] && ! empty($credentials['public_key']) && ! empty($credentials['private_key'])) |
|
| 1076 | + )) { |
|
| 1077 | 1077 | $stored_credentials = $credentials; |
| 1078 | - if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code. |
|
| 1079 | - $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; |
|
| 1078 | + if ( ! empty($stored_credentials['port'])) //save port as part of hostname to simplify above code. |
|
| 1079 | + $stored_credentials['hostname'] .= ':'.$stored_credentials['port']; |
|
| 1080 | 1080 | |
| 1081 | 1081 | unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']); |
| 1082 | - if ( ! defined( 'WP_INSTALLING' ) ) { |
|
| 1083 | - update_option( 'ftp_credentials', $stored_credentials ); |
|
| 1082 | + if ( ! defined('WP_INSTALLING')) { |
|
| 1083 | + update_option('ftp_credentials', $stored_credentials); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | return $credentials; |
| 1086 | 1086 | } |
| 1087 | - $hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : ''; |
|
| 1088 | - $username = isset( $credentials['username'] ) ? $credentials['username'] : ''; |
|
| 1089 | - $public_key = isset( $credentials['public_key'] ) ? $credentials['public_key'] : ''; |
|
| 1090 | - $private_key = isset( $credentials['private_key'] ) ? $credentials['private_key'] : ''; |
|
| 1091 | - $port = isset( $credentials['port'] ) ? $credentials['port'] : ''; |
|
| 1092 | - $connection_type = isset( $credentials['connection_type'] ) ? $credentials['connection_type'] : ''; |
|
| 1093 | - |
|
| 1094 | - if ( $error ) { |
|
| 1087 | + $hostname = isset($credentials['hostname']) ? $credentials['hostname'] : ''; |
|
| 1088 | + $username = isset($credentials['username']) ? $credentials['username'] : ''; |
|
| 1089 | + $public_key = isset($credentials['public_key']) ? $credentials['public_key'] : ''; |
|
| 1090 | + $private_key = isset($credentials['private_key']) ? $credentials['private_key'] : ''; |
|
| 1091 | + $port = isset($credentials['port']) ? $credentials['port'] : ''; |
|
| 1092 | + $connection_type = isset($credentials['connection_type']) ? $credentials['connection_type'] : ''; |
|
| 1093 | + |
|
| 1094 | + if ($error) { |
|
| 1095 | 1095 | $error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.'); |
| 1096 | - if ( is_wp_error($error) ) |
|
| 1097 | - $error_string = esc_html( $error->get_error_message() ); |
|
| 1098 | - echo '<div id="message" class="error"><p>' . $error_string . '</p></div>'; |
|
| 1096 | + if (is_wp_error($error)) |
|
| 1097 | + $error_string = esc_html($error->get_error_message()); |
|
| 1098 | + echo '<div id="message" class="error"><p>'.$error_string.'</p></div>'; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | $types = array(); |
| 1102 | - if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) |
|
| 1103 | - $types[ 'ftp' ] = __('FTP'); |
|
| 1104 | - if ( extension_loaded('ftp') ) //Only this supports FTPS |
|
| 1105 | - $types[ 'ftps' ] = __('FTPS (SSL)'); |
|
| 1106 | - if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) |
|
| 1107 | - $types[ 'ssh' ] = __('SSH2'); |
|
| 1102 | + if (extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen')) |
|
| 1103 | + $types['ftp'] = __('FTP'); |
|
| 1104 | + if (extension_loaded('ftp')) //Only this supports FTPS |
|
| 1105 | + $types['ftps'] = __('FTPS (SSL)'); |
|
| 1106 | + if (extension_loaded('ssh2') && function_exists('stream_get_contents')) |
|
| 1107 | + $types['ssh'] = __('SSH2'); |
|
| 1108 | 1108 | |
| 1109 | 1109 | /** |
| 1110 | 1110 | * Filter the connection types to output to the filesystem credentials form. |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | * @param string $context Full path to the directory that is tested |
| 1119 | 1119 | * for being writable. |
| 1120 | 1120 | */ |
| 1121 | - $types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context ); |
|
| 1121 | + $types = apply_filters('fs_ftp_connection_types', $types, $credentials, $type, $error, $context); |
|
| 1122 | 1122 | |
| 1123 | 1123 | ?> |
| 1124 | 1124 | <script type="text/javascript"> |
@@ -1134,16 +1134,16 @@ discard block |
||
| 1134 | 1134 | }); |
| 1135 | 1135 | --> |
| 1136 | 1136 | </script> |
| 1137 | -<form action="<?php echo esc_url( $form_post ) ?>" method="post"> |
|
| 1137 | +<form action="<?php echo esc_url($form_post) ?>" method="post"> |
|
| 1138 | 1138 | <div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form"> |
| 1139 | -<h3 id="request-filesystem-credentials-title"><?php _e( 'Connection Information' ) ?></h3> |
|
| 1139 | +<h3 id="request-filesystem-credentials-title"><?php _e('Connection Information') ?></h3> |
|
| 1140 | 1140 | <p id="request-filesystem-credentials-desc"><?php |
| 1141 | 1141 | $label_user = __('Username'); |
| 1142 | 1142 | $label_pass = __('Password'); |
| 1143 | 1143 | _e('To perform the requested action, WordPress needs to access your web server.'); |
| 1144 | 1144 | echo ' '; |
| 1145 | - if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) { |
|
| 1146 | - if ( isset( $types['ssh'] ) ) { |
|
| 1145 | + if ((isset($types['ftp']) || isset($types['ftps']))) { |
|
| 1146 | + if (isset($types['ssh'])) { |
|
| 1147 | 1147 | _e('Please enter your FTP or SSH credentials to proceed.'); |
| 1148 | 1148 | $label_user = __('FTP/SSH Username'); |
| 1149 | 1149 | $label_pass = __('FTP/SSH Password'); |
@@ -1157,39 +1157,39 @@ discard block |
||
| 1157 | 1157 | _e('If you do not remember your credentials, you should contact your web host.'); |
| 1158 | 1158 | ?></p> |
| 1159 | 1159 | <label for="hostname"> |
| 1160 | - <span class="field-title"><?php _e( 'Hostname' ) ?></span> |
|
| 1161 | - <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> /> |
|
| 1160 | + <span class="field-title"><?php _e('Hostname') ?></span> |
|
| 1161 | + <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e('example: www.wordpress.org') ?>" value="<?php echo esc_attr($hostname); if ( ! empty($port)) echo ":$port"; ?>"<?php disabled(defined('FTP_HOST')); ?> /> |
|
| 1162 | 1162 | </label> |
| 1163 | 1163 | <div class="ftp-username"> |
| 1164 | 1164 | <label for="username"> |
| 1165 | 1165 | <span class="field-title"><?php echo $label_user; ?></span> |
| 1166 | - <input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> /> |
|
| 1166 | + <input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled(defined('FTP_USER')); ?> /> |
|
| 1167 | 1167 | </label> |
| 1168 | 1168 | </div> |
| 1169 | 1169 | <div class="ftp-password"> |
| 1170 | 1170 | <label for="password"> |
| 1171 | 1171 | <span class="field-title"><?php echo $label_pass; ?></span> |
| 1172 | - <input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> /> |
|
| 1173 | - <em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em> |
|
| 1172 | + <input name="password" type="password" id="password" value="<?php if (defined('FTP_PASS')) echo '*****'; ?>"<?php disabled(defined('FTP_PASS')); ?> /> |
|
| 1173 | + <em><?php if ( ! defined('FTP_PASS')) _e('This password will not be stored on the server.'); ?></em> |
|
| 1174 | 1174 | </label> |
| 1175 | 1175 | </div> |
| 1176 | -<?php if ( isset($types['ssh']) ) : ?> |
|
| 1176 | +<?php if (isset($types['ssh'])) : ?> |
|
| 1177 | 1177 | <h4><?php _e('Authentication Keys') ?></h4> |
| 1178 | 1178 | <label for="public_key"> |
| 1179 | 1179 | <span class="field-title"><?php _e('Public Key:') ?></span> |
| 1180 | - <input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> /> |
|
| 1180 | + <input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled(defined('FTP_PUBKEY')); ?> /> |
|
| 1181 | 1181 | </label> |
| 1182 | 1182 | <label for="private_key"> |
| 1183 | 1183 | <span class="field-title"><?php _e('Private Key:') ?></span> |
| 1184 | - <input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> /> |
|
| 1184 | + <input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled(defined('FTP_PRIKEY')); ?> /> |
|
| 1185 | 1185 | </label> |
| 1186 | 1186 | <span id="auth-keys-desc"><?php _e('Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.') ?></span> |
| 1187 | 1187 | <?php endif; ?> |
| 1188 | 1188 | <h4><?php _e('Connection Type') ?></h4> |
| 1189 | 1189 | <fieldset><legend class="screen-reader-text"><span><?php _e('Connection Type') ?></span></legend> |
| 1190 | 1190 | <?php |
| 1191 | - $disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false ); |
|
| 1192 | - foreach ( $types as $name => $text ) : ?> |
|
| 1191 | + $disabled = disabled((defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false); |
|
| 1192 | + foreach ($types as $name => $text) : ?> |
|
| 1193 | 1193 | <label for="<?php echo esc_attr($name) ?>"> |
| 1194 | 1194 | <input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); echo $disabled; ?> /> |
| 1195 | 1195 | <?php echo $text ?> |
@@ -1197,14 +1197,14 @@ discard block |
||
| 1197 | 1197 | <?php endforeach; ?> |
| 1198 | 1198 | </fieldset> |
| 1199 | 1199 | <?php |
| 1200 | -foreach ( (array) $extra_fields as $field ) { |
|
| 1201 | - if ( isset( $_POST[ $field ] ) ) |
|
| 1202 | - echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; |
|
| 1200 | +foreach ((array) $extra_fields as $field) { |
|
| 1201 | + if (isset($_POST[$field])) |
|
| 1202 | + echo '<input type="hidden" name="'.esc_attr($field).'" value="'.esc_attr(wp_unslash($_POST[$field])).'" />'; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | ?> |
| 1205 | 1205 | <p class="request-filesystem-credentials-action-buttons"> |
| 1206 | - <button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button> |
|
| 1207 | - <?php submit_button( __( 'Proceed' ), 'button', 'upgrade', false ); ?> |
|
| 1206 | + <button class="button cancel-button" data-js-action="close" type="button"><?php _e('Cancel'); ?></button> |
|
| 1207 | + <?php submit_button(__('Proceed'), 'button', 'upgrade', false); ?> |
|
| 1208 | 1208 | </p> |
| 1209 | 1209 | </div> |
| 1210 | 1210 | </form> |
@@ -1220,10 +1220,10 @@ discard block |
||
| 1220 | 1220 | function wp_print_request_filesystem_credentials_modal() { |
| 1221 | 1221 | $filesystem_method = get_filesystem_method(); |
| 1222 | 1222 | ob_start(); |
| 1223 | - $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); |
|
| 1223 | + $filesystem_credentials_are_stored = request_filesystem_credentials(self_admin_url()); |
|
| 1224 | 1224 | ob_end_clean(); |
| 1225 | - $request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored ); |
|
| 1226 | - if ( ! $request_filesystem_credentials ) { |
|
| 1225 | + $request_filesystem_credentials = ($filesystem_method != 'direct' && ! $filesystem_credentials_are_stored); |
|
| 1226 | + if ( ! $request_filesystem_credentials) { |
|
| 1227 | 1227 | return; |
| 1228 | 1228 | } |
| 1229 | 1229 | ?> |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | <div class="notification-dialog-background"></div> |
| 1232 | 1232 | <div class="notification-dialog" role="dialog" aria-labelledby="request-filesystem-credentials-title" tabindex="0"> |
| 1233 | 1233 | <div class="request-filesystem-credentials-dialog-content"> |
| 1234 | - <?php request_filesystem_credentials( site_url() ); ?> |
|
| 1234 | + <?php request_filesystem_credentials(site_url()); ?> |
|
| 1235 | 1235 | <div> |
| 1236 | 1236 | </div> |
| 1237 | 1237 | </div> |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | if ( isset( $wp_file_descriptions[basename( $file )] ) ) { |
| 61 | 61 | return $wp_file_descriptions[basename( $file )]; |
| 62 | - } |
|
| 63 | - elseif ( file_exists( $file ) && is_file( $file ) ) { |
|
| 62 | + } elseif ( file_exists( $file ) && is_file( $file ) ) { |
|
| 64 | 63 | $template_data = implode( '', file( $file ) ); |
| 65 | - if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) |
|
| 66 | - return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) ); |
|
| 64 | + if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) { |
|
| 65 | + return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) ); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | return trim( basename( $file ) ); |
@@ -102,23 +102,27 @@ discard block |
||
| 102 | 102 | * @return bool|array False on failure, Else array of files |
| 103 | 103 | */ |
| 104 | 104 | function list_files( $folder = '', $levels = 100 ) { |
| 105 | - if ( empty($folder) ) |
|
| 106 | - return false; |
|
| 105 | + if ( empty($folder) ) { |
|
| 106 | + return false; |
|
| 107 | + } |
|
| 107 | 108 | |
| 108 | - if ( ! $levels ) |
|
| 109 | - return false; |
|
| 109 | + if ( ! $levels ) { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 110 | 112 | |
| 111 | 113 | $files = array(); |
| 112 | 114 | if ( $dir = @opendir( $folder ) ) { |
| 113 | 115 | while (($file = readdir( $dir ) ) !== false ) { |
| 114 | - if ( in_array($file, array('.', '..') ) ) |
|
| 115 | - continue; |
|
| 116 | + if ( in_array($file, array('.', '..') ) ) { |
|
| 117 | + continue; |
|
| 118 | + } |
|
| 116 | 119 | if ( is_dir( $folder . '/' . $file ) ) { |
| 117 | 120 | $files2 = list_files( $folder . '/' . $file, $levels - 1); |
| 118 | - if ( $files2 ) |
|
| 119 | - $files = array_merge($files, $files2 ); |
|
| 120 | - else |
|
| 121 | - $files[] = $folder . '/' . $file . '/'; |
|
| 121 | + if ( $files2 ) { |
|
| 122 | + $files = array_merge($files, $files2 ); |
|
| 123 | + } else { |
|
| 124 | + $files[] = $folder . '/' . $file . '/'; |
|
| 125 | + } |
|
| 122 | 126 | } else { |
| 123 | 127 | $files[] = $folder . '/' . $file; |
| 124 | 128 | } |
@@ -180,8 +184,9 @@ discard block |
||
| 180 | 184 | function validate_file_to_edit( $file, $allowed_files = '' ) { |
| 181 | 185 | $code = validate_file( $file, $allowed_files ); |
| 182 | 186 | |
| 183 | - if (!$code ) |
|
| 184 | - return $file; |
|
| 187 | + if (!$code ) { |
|
| 188 | + return $file; |
|
| 189 | + } |
|
| 185 | 190 | |
| 186 | 191 | switch ( $code ) { |
| 187 | 192 | case 1 : |
@@ -451,12 +456,14 @@ discard block |
||
| 451 | 456 | */ |
| 452 | 457 | function download_url( $url, $timeout = 300 ) { |
| 453 | 458 | //WARNING: The file is not automatically deleted, The script must unlink() the file. |
| 454 | - if ( ! $url ) |
|
| 455 | - return new WP_Error('http_no_url', __('Invalid URL Provided.')); |
|
| 459 | + if ( ! $url ) { |
|
| 460 | + return new WP_Error('http_no_url', __('Invalid URL Provided.')); |
|
| 461 | + } |
|
| 456 | 462 | |
| 457 | 463 | $tmpfname = wp_tempnam($url); |
| 458 | - if ( ! $tmpfname ) |
|
| 459 | - return new WP_Error('http_no_file', __('Could not create Temporary file.')); |
|
| 464 | + if ( ! $tmpfname ) { |
|
| 465 | + return new WP_Error('http_no_file', __('Could not create Temporary file.')); |
|
| 466 | + } |
|
| 460 | 467 | |
| 461 | 468 | $response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) ); |
| 462 | 469 | |
@@ -492,17 +499,20 @@ discard block |
||
| 492 | 499 | * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected |
| 493 | 500 | */ |
| 494 | 501 | function verify_file_md5( $filename, $expected_md5 ) { |
| 495 | - if ( 32 == strlen( $expected_md5 ) ) |
|
| 496 | - $expected_raw_md5 = pack( 'H*', $expected_md5 ); |
|
| 497 | - elseif ( 24 == strlen( $expected_md5 ) ) |
|
| 498 | - $expected_raw_md5 = base64_decode( $expected_md5 ); |
|
| 499 | - else |
|
| 500 | - return false; // unknown format |
|
| 502 | + if ( 32 == strlen( $expected_md5 ) ) { |
|
| 503 | + $expected_raw_md5 = pack( 'H*', $expected_md5 ); |
|
| 504 | + } elseif ( 24 == strlen( $expected_md5 ) ) { |
|
| 505 | + $expected_raw_md5 = base64_decode( $expected_md5 ); |
|
| 506 | + } else { |
|
| 507 | + return false; |
|
| 508 | + } |
|
| 509 | + // unknown format |
|
| 501 | 510 | |
| 502 | 511 | $file_md5 = md5_file( $filename, true ); |
| 503 | 512 | |
| 504 | - if ( $file_md5 === $expected_raw_md5 ) |
|
| 505 | - return true; |
|
| 513 | + if ( $file_md5 === $expected_raw_md5 ) { |
|
| 514 | + return true; |
|
| 515 | + } |
|
| 506 | 516 | |
| 507 | 517 | return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) ); |
| 508 | 518 | } |
@@ -525,8 +535,9 @@ discard block |
||
| 525 | 535 | function unzip_file($file, $to) { |
| 526 | 536 | global $wp_filesystem; |
| 527 | 537 | |
| 528 | - if ( ! $wp_filesystem || !is_object($wp_filesystem) ) |
|
| 529 | - return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
| 538 | + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) { |
|
| 539 | + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
| 540 | + } |
|
| 530 | 541 | |
| 531 | 542 | // Unzip can use a lot of memory, but not this much hopefully |
| 532 | 543 | /** This filter is documented in wp-admin/admin.php */ |
@@ -539,17 +550,22 @@ discard block |
||
| 539 | 550 | if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist |
| 540 | 551 | $path = preg_split('![/\\\]!', untrailingslashit($to)); |
| 541 | 552 | for ( $i = count($path); $i >= 0; $i-- ) { |
| 542 | - if ( empty($path[$i]) ) |
|
| 543 | - continue; |
|
| 553 | + if ( empty($path[$i]) ) { |
|
| 554 | + continue; |
|
| 555 | + } |
|
| 544 | 556 | |
| 545 | 557 | $dir = implode('/', array_slice($path, 0, $i+1) ); |
| 546 | - if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter. |
|
| 558 | + if ( preg_match('!^[a-z]:$!i', $dir) ) { |
|
| 559 | + // Skip it if it looks like a Windows Drive letter. |
|
| 547 | 560 | continue; |
| 561 | + } |
|
| 548 | 562 | |
| 549 | - if ( ! $wp_filesystem->is_dir($dir) ) |
|
| 550 | - $needed_dirs[] = $dir; |
|
| 551 | - else |
|
| 552 | - break; // A folder exists, therefor, we dont need the check the levels below this |
|
| 563 | + if ( ! $wp_filesystem->is_dir($dir) ) { |
|
| 564 | + $needed_dirs[] = $dir; |
|
| 565 | + } else { |
|
| 566 | + break; |
|
| 567 | + } |
|
| 568 | + // A folder exists, therefor, we dont need the check the levels below this |
|
| 553 | 569 | } |
| 554 | 570 | } |
| 555 | 571 | |
@@ -565,8 +581,9 @@ discard block |
||
| 565 | 581 | if ( true === $result ) { |
| 566 | 582 | return $result; |
| 567 | 583 | } elseif ( is_wp_error($result) ) { |
| 568 | - if ( 'incompatible_archive' != $result->get_error_code() ) |
|
| 569 | - return $result; |
|
| 584 | + if ( 'incompatible_archive' != $result->get_error_code() ) { |
|
| 585 | + return $result; |
|
| 586 | + } |
|
| 570 | 587 | } |
| 571 | 588 | } |
| 572 | 589 | // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file. |
@@ -594,24 +611,30 @@ discard block |
||
| 594 | 611 | $z = new ZipArchive(); |
| 595 | 612 | |
| 596 | 613 | $zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS ); |
| 597 | - if ( true !== $zopen ) |
|
| 598 | - return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) ); |
|
| 614 | + if ( true !== $zopen ) { |
|
| 615 | + return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) ); |
|
| 616 | + } |
|
| 599 | 617 | |
| 600 | 618 | $uncompressed_size = 0; |
| 601 | 619 | |
| 602 | 620 | for ( $i = 0; $i < $z->numFiles; $i++ ) { |
| 603 | - if ( ! $info = $z->statIndex($i) ) |
|
| 604 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 621 | + if ( ! $info = $z->statIndex($i) ) { |
|
| 622 | + return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 623 | + } |
|
| 605 | 624 | |
| 606 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
| 625 | + if ( '__MACOSX/' === substr($info['name'], 0, 9) ) { |
|
| 626 | + // Skip the OS X-created __MACOSX directory |
|
| 607 | 627 | continue; |
| 628 | + } |
|
| 608 | 629 | |
| 609 | 630 | $uncompressed_size += $info['size']; |
| 610 | 631 | |
| 611 | - if ( '/' == substr($info['name'], -1) ) // directory |
|
| 632 | + if ( '/' == substr($info['name'], -1) ) { |
|
| 633 | + // directory |
|
| 612 | 634 | $needed_dirs[] = $to . untrailingslashit($info['name']); |
| 613 | - else |
|
| 614 | - $needed_dirs[] = $to . untrailingslashit(dirname($info['name'])); |
|
| 635 | + } else { |
|
| 636 | + $needed_dirs[] = $to . untrailingslashit(dirname($info['name'])); |
|
| 637 | + } |
|
| 615 | 638 | } |
| 616 | 639 | |
| 617 | 640 | /* |
@@ -621,17 +644,22 @@ discard block |
||
| 621 | 644 | */ |
| 622 | 645 | if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
| 623 | 646 | $available_space = @disk_free_space( WP_CONTENT_DIR ); |
| 624 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
| 625 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 647 | + if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
|
| 648 | + return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 649 | + } |
|
| 626 | 650 | } |
| 627 | 651 | |
| 628 | 652 | $needed_dirs = array_unique($needed_dirs); |
| 629 | 653 | foreach ( $needed_dirs as $dir ) { |
| 630 | 654 | // Check the parent folders of the folders all exist within the creation array. |
| 631 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
| 655 | + if ( untrailingslashit($to) == $dir ) { |
|
| 656 | + // Skip over the working directory, We know this exists (or will exist) |
|
| 632 | 657 | continue; |
| 633 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
| 658 | + } |
|
| 659 | + if ( strpos($dir, $to) === false ) { |
|
| 660 | + // If the directory is not within the working directory, Skip it |
|
| 634 | 661 | continue; |
| 662 | + } |
|
| 635 | 663 | |
| 636 | 664 | $parent_folder = dirname($dir); |
| 637 | 665 | while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
@@ -651,21 +679,28 @@ discard block |
||
| 651 | 679 | unset($needed_dirs); |
| 652 | 680 | |
| 653 | 681 | for ( $i = 0; $i < $z->numFiles; $i++ ) { |
| 654 | - if ( ! $info = $z->statIndex($i) ) |
|
| 655 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 682 | + if ( ! $info = $z->statIndex($i) ) { |
|
| 683 | + return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 684 | + } |
|
| 656 | 685 | |
| 657 | - if ( '/' == substr($info['name'], -1) ) // directory |
|
| 686 | + if ( '/' == substr($info['name'], -1) ) { |
|
| 687 | + // directory |
|
| 658 | 688 | continue; |
| 689 | + } |
|
| 659 | 690 | |
| 660 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
| 691 | + if ( '__MACOSX/' === substr($info['name'], 0, 9) ) { |
|
| 692 | + // Don't extract the OS X-created __MACOSX directory files |
|
| 661 | 693 | continue; |
| 694 | + } |
|
| 662 | 695 | |
| 663 | 696 | $contents = $z->getFromIndex($i); |
| 664 | - if ( false === $contents ) |
|
| 665 | - return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); |
|
| 697 | + if ( false === $contents ) { |
|
| 698 | + return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); |
|
| 699 | + } |
|
| 666 | 700 | |
| 667 | - if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) |
|
| 668 | - return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] ); |
|
| 701 | + if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) { |
|
| 702 | + return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] ); |
|
| 703 | + } |
|
| 669 | 704 | } |
| 670 | 705 | |
| 671 | 706 | $z->close(); |
@@ -702,18 +737,22 @@ discard block |
||
| 702 | 737 | reset_mbstring_encoding(); |
| 703 | 738 | |
| 704 | 739 | // Is the archive valid? |
| 705 | - if ( !is_array($archive_files) ) |
|
| 706 | - return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); |
|
| 740 | + if ( !is_array($archive_files) ) { |
|
| 741 | + return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); |
|
| 742 | + } |
|
| 707 | 743 | |
| 708 | - if ( 0 == count($archive_files) ) |
|
| 709 | - return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) ); |
|
| 744 | + if ( 0 == count($archive_files) ) { |
|
| 745 | + return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) ); |
|
| 746 | + } |
|
| 710 | 747 | |
| 711 | 748 | $uncompressed_size = 0; |
| 712 | 749 | |
| 713 | 750 | // Determine any children directories needed (From within the archive) |
| 714 | 751 | foreach ( $archive_files as $file ) { |
| 715 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
| 752 | + if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) { |
|
| 753 | + // Skip the OS X-created __MACOSX directory |
|
| 716 | 754 | continue; |
| 755 | + } |
|
| 717 | 756 | |
| 718 | 757 | $uncompressed_size += $file['size']; |
| 719 | 758 | |
@@ -727,17 +766,22 @@ discard block |
||
| 727 | 766 | */ |
| 728 | 767 | if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
| 729 | 768 | $available_space = @disk_free_space( WP_CONTENT_DIR ); |
| 730 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
| 731 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 769 | + if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
|
| 770 | + return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 771 | + } |
|
| 732 | 772 | } |
| 733 | 773 | |
| 734 | 774 | $needed_dirs = array_unique($needed_dirs); |
| 735 | 775 | foreach ( $needed_dirs as $dir ) { |
| 736 | 776 | // Check the parent folders of the folders all exist within the creation array. |
| 737 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
| 777 | + if ( untrailingslashit($to) == $dir ) { |
|
| 778 | + // Skip over the working directory, We know this exists (or will exist) |
|
| 738 | 779 | continue; |
| 739 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
| 780 | + } |
|
| 781 | + if ( strpos($dir, $to) === false ) { |
|
| 782 | + // If the directory is not within the working directory, Skip it |
|
| 740 | 783 | continue; |
| 784 | + } |
|
| 741 | 785 | |
| 742 | 786 | $parent_folder = dirname($dir); |
| 743 | 787 | while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
@@ -750,21 +794,26 @@ discard block |
||
| 750 | 794 | // Create those directories if need be: |
| 751 | 795 | foreach ( $needed_dirs as $_dir ) { |
| 752 | 796 | // Only check to see if the dir exists upon creation failure. Less I/O this way. |
| 753 | - if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) |
|
| 754 | - return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
| 797 | + if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
| 798 | + return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
| 799 | + } |
|
| 755 | 800 | } |
| 756 | 801 | unset($needed_dirs); |
| 757 | 802 | |
| 758 | 803 | // Extract the files from the zip |
| 759 | 804 | foreach ( $archive_files as $file ) { |
| 760 | - if ( $file['folder'] ) |
|
| 761 | - continue; |
|
| 805 | + if ( $file['folder'] ) { |
|
| 806 | + continue; |
|
| 807 | + } |
|
| 762 | 808 | |
| 763 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
| 809 | + if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) { |
|
| 810 | + // Don't extract the OS X-created __MACOSX directory files |
|
| 764 | 811 | continue; |
| 812 | + } |
|
| 765 | 813 | |
| 766 | - if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) |
|
| 767 | - return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); |
|
| 814 | + if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) { |
|
| 815 | + return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); |
|
| 816 | + } |
|
| 768 | 817 | } |
| 769 | 818 | return true; |
| 770 | 819 | } |
@@ -791,32 +840,37 @@ discard block |
||
| 791 | 840 | $to = trailingslashit($to); |
| 792 | 841 | |
| 793 | 842 | foreach ( (array) $dirlist as $filename => $fileinfo ) { |
| 794 | - if ( in_array( $filename, $skip_list ) ) |
|
| 795 | - continue; |
|
| 843 | + if ( in_array( $filename, $skip_list ) ) { |
|
| 844 | + continue; |
|
| 845 | + } |
|
| 796 | 846 | |
| 797 | 847 | if ( 'f' == $fileinfo['type'] ) { |
| 798 | 848 | if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { |
| 799 | 849 | // If copy failed, chmod file to 0644 and try again. |
| 800 | 850 | $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); |
| 801 | - if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) |
|
| 802 | - return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
|
| 851 | + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { |
|
| 852 | + return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
|
| 853 | + } |
|
| 803 | 854 | } |
| 804 | 855 | } elseif ( 'd' == $fileinfo['type'] ) { |
| 805 | 856 | if ( !$wp_filesystem->is_dir($to . $filename) ) { |
| 806 | - if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) |
|
| 807 | - return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); |
|
| 857 | + if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) { |
|
| 858 | + return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); |
|
| 859 | + } |
|
| 808 | 860 | } |
| 809 | 861 | |
| 810 | 862 | // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list |
| 811 | 863 | $sub_skip_list = array(); |
| 812 | 864 | foreach ( $skip_list as $skip_item ) { |
| 813 | - if ( 0 === strpos( $skip_item, $filename . '/' ) ) |
|
| 814 | - $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); |
|
| 865 | + if ( 0 === strpos( $skip_item, $filename . '/' ) ) { |
|
| 866 | + $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); |
|
| 867 | + } |
|
| 815 | 868 | } |
| 816 | 869 | |
| 817 | 870 | $result = copy_dir($from . $filename, $to . $filename, $sub_skip_list); |
| 818 | - if ( is_wp_error($result) ) |
|
| 819 | - return $result; |
|
| 871 | + if ( is_wp_error($result) ) { |
|
| 872 | + return $result; |
|
| 873 | + } |
|
| 820 | 874 | } |
| 821 | 875 | } |
| 822 | 876 | return true; |
@@ -846,8 +900,9 @@ discard block |
||
| 846 | 900 | |
| 847 | 901 | $method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership ); |
| 848 | 902 | |
| 849 | - if ( ! $method ) |
|
| 850 | - return false; |
|
| 903 | + if ( ! $method ) { |
|
| 904 | + return false; |
|
| 905 | + } |
|
| 851 | 906 | |
| 852 | 907 | if ( ! class_exists("WP_Filesystem_$method") ) { |
| 853 | 908 | |
@@ -863,8 +918,9 @@ discard block |
||
| 863 | 918 | */ |
| 864 | 919 | $abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
| 865 | 920 | |
| 866 | - if ( ! file_exists($abstraction_file) ) |
|
| 867 | - return; |
|
| 921 | + if ( ! file_exists($abstraction_file) ) { |
|
| 922 | + return; |
|
| 923 | + } |
|
| 868 | 924 | |
| 869 | 925 | require_once($abstraction_file); |
| 870 | 926 | } |
@@ -873,22 +929,29 @@ discard block |
||
| 873 | 929 | $wp_filesystem = new $method($args); |
| 874 | 930 | |
| 875 | 931 | //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default. |
| 876 | - if ( ! defined('FS_CONNECT_TIMEOUT') ) |
|
| 877 | - define('FS_CONNECT_TIMEOUT', 30); |
|
| 878 | - if ( ! defined('FS_TIMEOUT') ) |
|
| 879 | - define('FS_TIMEOUT', 30); |
|
| 932 | + if ( ! defined('FS_CONNECT_TIMEOUT') ) { |
|
| 933 | + define('FS_CONNECT_TIMEOUT', 30); |
|
| 934 | + } |
|
| 935 | + if ( ! defined('FS_TIMEOUT') ) { |
|
| 936 | + define('FS_TIMEOUT', 30); |
|
| 937 | + } |
|
| 880 | 938 | |
| 881 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 882 | - return false; |
|
| 939 | + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) { |
|
| 940 | + return false; |
|
| 941 | + } |
|
| 883 | 942 | |
| 884 | - if ( !$wp_filesystem->connect() ) |
|
| 885 | - return false; //There was an error connecting to the server. |
|
| 943 | + if ( !$wp_filesystem->connect() ) { |
|
| 944 | + return false; |
|
| 945 | + } |
|
| 946 | + //There was an error connecting to the server. |
|
| 886 | 947 | |
| 887 | 948 | // Set the permission constants if not already set. |
| 888 | - if ( ! defined('FS_CHMOD_DIR') ) |
|
| 889 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
| 890 | - if ( ! defined('FS_CHMOD_FILE') ) |
|
| 891 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
| 949 | + if ( ! defined('FS_CHMOD_DIR') ) { |
|
| 950 | + define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
| 951 | + } |
|
| 952 | + if ( ! defined('FS_CHMOD_FILE') ) { |
|
| 953 | + define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
| 954 | + } |
|
| 892 | 955 | |
| 893 | 956 | return true; |
| 894 | 957 | } |
@@ -963,9 +1026,16 @@ discard block |
||
| 963 | 1026 | } |
| 964 | 1027 | } |
| 965 | 1028 | |
| 966 | - if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2'; |
|
| 967 | - if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; |
|
| 968 | - if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
| 1029 | + if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) { |
|
| 1030 | + $method = 'ssh2'; |
|
| 1031 | + } |
|
| 1032 | + if ( ! $method && extension_loaded('ftp') ) { |
|
| 1033 | + $method = 'ftpext'; |
|
| 1034 | + } |
|
| 1035 | + if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) { |
|
| 1036 | + $method = 'ftpsockets'; |
|
| 1037 | + } |
|
| 1038 | + //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
| 969 | 1039 | |
| 970 | 1040 | /** |
| 971 | 1041 | * Filter the filesystem method to use. |
@@ -1025,18 +1095,21 @@ discard block |
||
| 1025 | 1095 | * @param array $extra_fields Extra POST fields. |
| 1026 | 1096 | */ |
| 1027 | 1097 | $req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership ); |
| 1028 | - if ( '' !== $req_cred ) |
|
| 1029 | - return $req_cred; |
|
| 1098 | + if ( '' !== $req_cred ) { |
|
| 1099 | + return $req_cred; |
|
| 1100 | + } |
|
| 1030 | 1101 | |
| 1031 | 1102 | if ( empty($type) ) { |
| 1032 | 1103 | $type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership ); |
| 1033 | 1104 | } |
| 1034 | 1105 | |
| 1035 | - if ( 'direct' == $type ) |
|
| 1036 | - return true; |
|
| 1106 | + if ( 'direct' == $type ) { |
|
| 1107 | + return true; |
|
| 1108 | + } |
|
| 1037 | 1109 | |
| 1038 | - if ( is_null( $extra_fields ) ) |
|
| 1039 | - $extra_fields = array( 'version', 'locale' ); |
|
| 1110 | + if ( is_null( $extra_fields ) ) { |
|
| 1111 | + $extra_fields = array( 'version', 'locale' ); |
|
| 1112 | + } |
|
| 1040 | 1113 | |
| 1041 | 1114 | $credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => '')); |
| 1042 | 1115 | |
@@ -1054,8 +1127,9 @@ discard block |
||
| 1054 | 1127 | |
| 1055 | 1128 | if ( strpos($credentials['hostname'], ':') ) { |
| 1056 | 1129 | list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2); |
| 1057 | - if ( ! is_numeric($credentials['port']) ) |
|
| 1058 | - unset($credentials['port']); |
|
| 1130 | + if ( ! is_numeric($credentials['port']) ) { |
|
| 1131 | + unset($credentials['port']); |
|
| 1132 | + } |
|
| 1059 | 1133 | } else { |
| 1060 | 1134 | unset($credentials['port']); |
| 1061 | 1135 | } |
@@ -1075,8 +1149,10 @@ discard block |
||
| 1075 | 1149 | ( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) ) |
| 1076 | 1150 | ) ) { |
| 1077 | 1151 | $stored_credentials = $credentials; |
| 1078 | - if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code. |
|
| 1152 | + if ( !empty($stored_credentials['port']) ) { |
|
| 1153 | + //save port as part of hostname to simplify above code. |
|
| 1079 | 1154 | $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; |
| 1155 | + } |
|
| 1080 | 1156 | |
| 1081 | 1157 | unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']); |
| 1082 | 1158 | if ( ! defined( 'WP_INSTALLING' ) ) { |
@@ -1093,18 +1169,23 @@ discard block |
||
| 1093 | 1169 | |
| 1094 | 1170 | if ( $error ) { |
| 1095 | 1171 | $error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.'); |
| 1096 | - if ( is_wp_error($error) ) |
|
| 1097 | - $error_string = esc_html( $error->get_error_message() ); |
|
| 1172 | + if ( is_wp_error($error) ) { |
|
| 1173 | + $error_string = esc_html( $error->get_error_message() ); |
|
| 1174 | + } |
|
| 1098 | 1175 | echo '<div id="message" class="error"><p>' . $error_string . '</p></div>'; |
| 1099 | 1176 | } |
| 1100 | 1177 | |
| 1101 | 1178 | $types = array(); |
| 1102 | - if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) |
|
| 1103 | - $types[ 'ftp' ] = __('FTP'); |
|
| 1104 | - if ( extension_loaded('ftp') ) //Only this supports FTPS |
|
| 1179 | + if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) { |
|
| 1180 | + $types[ 'ftp' ] = __('FTP'); |
|
| 1181 | + } |
|
| 1182 | + if ( extension_loaded('ftp') ) { |
|
| 1183 | + //Only this supports FTPS |
|
| 1105 | 1184 | $types[ 'ftps' ] = __('FTPS (SSL)'); |
| 1106 | - if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) |
|
| 1107 | - $types[ 'ssh' ] = __('SSH2'); |
|
| 1185 | + } |
|
| 1186 | + if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) { |
|
| 1187 | + $types[ 'ssh' ] = __('SSH2'); |
|
| 1188 | + } |
|
| 1108 | 1189 | |
| 1109 | 1190 | /** |
| 1110 | 1191 | * Filter the connection types to output to the filesystem credentials form. |
@@ -1158,7 +1239,10 @@ discard block |
||
| 1158 | 1239 | ?></p> |
| 1159 | 1240 | <label for="hostname"> |
| 1160 | 1241 | <span class="field-title"><?php _e( 'Hostname' ) ?></span> |
| 1161 | - <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> /> |
|
| 1242 | + <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) { |
|
| 1243 | + echo ":$port"; |
|
| 1244 | +} |
|
| 1245 | +?>"<?php disabled( defined('FTP_HOST') ); ?> /> |
|
| 1162 | 1246 | </label> |
| 1163 | 1247 | <div class="ftp-username"> |
| 1164 | 1248 | <label for="username"> |
@@ -1169,8 +1253,14 @@ discard block |
||
| 1169 | 1253 | <div class="ftp-password"> |
| 1170 | 1254 | <label for="password"> |
| 1171 | 1255 | <span class="field-title"><?php echo $label_pass; ?></span> |
| 1172 | - <input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> /> |
|
| 1173 | - <em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em> |
|
| 1256 | + <input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) { |
|
| 1257 | + echo '*****'; |
|
| 1258 | +} |
|
| 1259 | +?>"<?php disabled( defined('FTP_PASS') ); ?> /> |
|
| 1260 | + <em><?php if ( ! defined('FTP_PASS') ) { |
|
| 1261 | + _e( 'This password will not be stored on the server.' ); |
|
| 1262 | +} |
|
| 1263 | +?></em> |
|
| 1174 | 1264 | </label> |
| 1175 | 1265 | </div> |
| 1176 | 1266 | <?php if ( isset($types['ssh']) ) : ?> |
@@ -1198,9 +1288,10 @@ discard block |
||
| 1198 | 1288 | </fieldset> |
| 1199 | 1289 | <?php |
| 1200 | 1290 | foreach ( (array) $extra_fields as $field ) { |
| 1201 | - if ( isset( $_POST[ $field ] ) ) |
|
| 1202 | - echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; |
|
| 1203 | -} |
|
| 1291 | + if ( isset( $_POST[ $field ] ) ) { |
|
| 1292 | + echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; |
|
| 1293 | + } |
|
| 1294 | + } |
|
| 1204 | 1295 | ?> |
| 1205 | 1296 | <p class="request-filesystem-credentials-action-buttons"> |
| 1206 | 1297 | <button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button> |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @ignore |
| 342 | 342 | * @param int $w Image width in pixels. |
| 343 | 343 | * @param int $h Image height in pixels. |
| 344 | - * @return float|int Image preview ratio. |
|
| 344 | + * @return integer Image preview ratio. |
|
| 345 | 345 | */ |
| 346 | 346 | function _image_get_preview_ratio($w, $h) { |
| 347 | 347 | $max = max($w, $h); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * @ignore |
| 357 | 357 | * @param resource $img Image resource. |
| 358 | 358 | * @param float|int $angle Image rotation angle, in degrees. |
| 359 | - * @return resource|false GD image resource, false otherwise. |
|
| 359 | + * @return resource GD image resource, false otherwise. |
|
| 360 | 360 | */ |
| 361 | 361 | function _rotate_image_resource($img, $angle) { |
| 362 | 362 | _deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::rotate' ) ); |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress Image Editor |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Administration |
|
| 7 | - */ |
|
| 3 | + * WordPress Image Editor |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Administration |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Loads the WP image-editing interface. |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @since 3.5.0 |
| 492 | 492 | * |
| 493 | 493 | * @param WP_Image_Editor $image WP_Image_Editor instance. |
| 494 | - * @param array $changes Array of change operations. |
|
| 494 | + * @param array $changes Array of change operations. |
|
| 495 | 495 | */ |
| 496 | 496 | $image = apply_filters( 'wp_image_editor_before_change', $image, $changes ); |
| 497 | 497 | } elseif ( is_resource( $image ) ) { |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | * @deprecated 3.5.0 Use wp_image_editor_before_change instead. |
| 504 | 504 | * |
| 505 | 505 | * @param resource $image GD image resource. |
| 506 | - * @param array $changes Array of change operations. |
|
| 506 | + * @param array $changes Array of change operations. |
|
| 507 | 507 | */ |
| 508 | 508 | $image = apply_filters( 'image_edit_before_change', $image, $changes ); |
| 509 | 509 | } |
@@ -562,8 +562,8 @@ discard block |
||
| 562 | 562 | |
| 563 | 563 | $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) ); |
| 564 | 564 | |
| 565 | - if ( is_wp_error( $img ) ) |
|
| 566 | - return false; |
|
| 565 | + if ( is_wp_error( $img ) ) |
|
| 566 | + return false; |
|
| 567 | 567 | |
| 568 | 568 | $changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null; |
| 569 | 569 | if ( $changes ) |
@@ -20,22 +20,22 @@ discard block |
||
| 20 | 20 | $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']); |
| 21 | 21 | $note = ''; |
| 22 | 22 | |
| 23 | - if ( isset( $meta['width'], $meta['height'] ) ) |
|
| 24 | - $big = max( $meta['width'], $meta['height'] ); |
|
| 23 | + if (isset($meta['width'], $meta['height'])) |
|
| 24 | + $big = max($meta['width'], $meta['height']); |
|
| 25 | 25 | else |
| 26 | - die( __('Image data does not exist. Please re-upload the image.') ); |
|
| 26 | + die(__('Image data does not exist. Please re-upload the image.')); |
|
| 27 | 27 | |
| 28 | 28 | $sizer = $big > 400 ? 400 / $big : 1; |
| 29 | 29 | |
| 30 | - $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
|
| 30 | + $backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true); |
|
| 31 | 31 | $can_restore = false; |
| 32 | - if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) |
|
| 33 | - $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); |
|
| 32 | + if ( ! empty($backup_sizes) && isset($backup_sizes['full-orig'], $meta['file'])) |
|
| 33 | + $can_restore = $backup_sizes['full-orig']['file'] != basename($meta['file']); |
|
| 34 | 34 | |
| 35 | - if ( $msg ) { |
|
| 36 | - if ( isset($msg->error) ) |
|
| 35 | + if ($msg) { |
|
| 36 | + if (isset($msg->error)) |
|
| 37 | 37 | $note = "<div class='error'><p>$msg->error</p></div>"; |
| 38 | - elseif ( isset($msg->msg) ) |
|
| 38 | + elseif (isset($msg->msg)) |
|
| 39 | 39 | $note = "<div class='updated'><p>$msg->msg</p></div>"; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,22 +46,22 @@ discard block |
||
| 46 | 46 | <div class="imgedit-settings"> |
| 47 | 47 | <div class="imgedit-group"> |
| 48 | 48 | <div class="imgedit-group-top"> |
| 49 | - <h3><?php _e( 'Scale Image' ); ?> <a href="#" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;"></a></h3> |
|
| 49 | + <h3><?php _e('Scale Image'); ?> <a href="#" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;"></a></h3> |
|
| 50 | 50 | <div class="imgedit-help"> |
| 51 | 51 | <p><?php _e('You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.'); ?></p> |
| 52 | 52 | </div> |
| 53 | - <?php if ( isset( $meta['width'], $meta['height'] ) ): ?> |
|
| 54 | - <p><?php printf( __('Original dimensions %s'), $meta['width'] . ' × ' . $meta['height'] ); ?></p> |
|
| 53 | + <?php if (isset($meta['width'], $meta['height'])): ?> |
|
| 54 | + <p><?php printf(__('Original dimensions %s'), $meta['width'].' × '.$meta['height']); ?></p> |
|
| 55 | 55 | <?php endif ?> |
| 56 | 56 | <div class="imgedit-submit"> |
| 57 | - <span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> × <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> |
|
| 57 | + <span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" /> × <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" /> |
|
| 58 | 58 | <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span></span> |
| 59 | - <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" /> |
|
| 59 | + <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e('Scale'); ?>" /> |
|
| 60 | 60 | </div> |
| 61 | 61 | </div> |
| 62 | 62 | </div> |
| 63 | 63 | |
| 64 | -<?php if ( $can_restore ) { ?> |
|
| 64 | +<?php if ($can_restore) { ?> |
|
| 65 | 65 | |
| 66 | 66 | <div class="imgedit-group"> |
| 67 | 67 | <div class="imgedit-group-top"> |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | <div class="imgedit-help"> |
| 70 | 70 | <p><?php _e('Discard any changes and restore the original image.'); |
| 71 | 71 | |
| 72 | - if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) |
|
| 72 | + if ( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) |
|
| 73 | 73 | echo ' '.__('Previously edited copies of the image will not be deleted.'); |
| 74 | 74 | |
| 75 | 75 | ?></p> |
| 76 | 76 | <div class="imgedit-submit"> |
| 77 | - <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> /> |
|
| 77 | + <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e('Restore image'); ?>" <?php echo $can_restore; ?> /> |
|
| 78 | 78 | </div> |
| 79 | 79 | </div> |
| 80 | 80 | </div> |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | </p> |
| 117 | 117 | </div> |
| 118 | 118 | |
| 119 | - <?php if ( $thumb && $sub_sizes ) { |
|
| 120 | - $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 ); |
|
| 119 | + <?php if ($thumb && $sub_sizes) { |
|
| 120 | + $thumb_img = wp_constrain_dimensions($thumb['width'], $thumb['height'], 160, 120); |
|
| 121 | 121 | ?> |
| 122 | 122 | |
| 123 | 123 | <div class="imgedit-group imgedit-applyto"> |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | <div class="imgedit-panel-content"> |
| 156 | 156 | <?php echo $note; ?> |
| 157 | 157 | <div class="imgedit-menu"> |
| 158 | - <div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php |
|
| 158 | + <div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e('Crop'); ?>"></div><?php |
|
| 159 | 159 | |
| 160 | 160 | // On some setups GD library does not provide imagerotate() - Ticket #11536 |
| 161 | - if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { ?> |
|
| 162 | - <div class="imgedit-rleft" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div> |
|
| 163 | - <div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div> |
|
| 161 | + if (wp_image_editor_supports(array('mime_type' => get_post_mime_type($post_id), 'methods' => array('rotate')))) { ?> |
|
| 162 | + <div class="imgedit-rleft" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e('Rotate counter-clockwise'); ?>"></div> |
|
| 163 | + <div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e('Rotate clockwise'); ?>"></div> |
|
| 164 | 164 | <?php } else { |
| 165 | 165 | $note_no_rotate = esc_attr__('Image rotation is not supported by your web host.'); |
| 166 | 166 | ?> |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | <div class="imgedit-rright disabled" title="<?php echo $note_no_rotate; ?>"></div> |
| 169 | 169 | <?php } ?> |
| 170 | 170 | |
| 171 | - <div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div> |
|
| 172 | - <div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php esc_attr_e( 'Flip horizontally' ); ?>"></div> |
|
| 171 | + <div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e('Flip vertically'); ?>"></div> |
|
| 172 | + <div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php esc_attr_e('Flip horizontally'); ?>"></div> |
|
| 173 | 173 | |
| 174 | - <div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php esc_attr_e( 'Undo' ); ?>"></div> |
|
| 175 | - <div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php esc_attr_e( 'Redo' ); ?>"></div> |
|
| 174 | + <div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php esc_attr_e('Undo'); ?>"></div> |
|
| 175 | + <div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php esc_attr_e('Redo'); ?>"></div> |
|
| 176 | 176 | <br class="clear" /> |
| 177 | 177 | </div> |
| 178 | 178 | |
@@ -180,16 +180,16 @@ discard block |
||
| 180 | 180 | <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> |
| 181 | 181 | <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" /> |
| 182 | 182 | <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" /> |
| 183 | - <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> |
|
| 184 | - <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> |
|
| 183 | + <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" /> |
|
| 184 | + <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" /> |
|
| 185 | 185 | |
| 186 | 186 | <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap"> |
| 187 | - <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&_ajax_nonce=<?php echo $nonce; ?>&postid=<?php echo $post_id; ?>&rand=<?php echo rand(1, 99999); ?>" /> |
|
| 187 | + <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url('admin-ajax.php', 'relative'); ?>?action=imgedit-preview&_ajax_nonce=<?php echo $nonce; ?>&postid=<?php echo $post_id; ?>&rand=<?php echo rand(1, 99999); ?>" /> |
|
| 188 | 188 | </div> |
| 189 | 189 | |
| 190 | 190 | <div class="imgedit-submit"> |
| 191 | - <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button" value="<?php esc_attr_e( 'Cancel' ); ?>" /> |
|
| 192 | - <input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" /> |
|
| 191 | + <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button" value="<?php esc_attr_e('Cancel'); ?>" /> |
|
| 192 | + <input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e('Save'); ?>" /> |
|
| 193 | 193 | </div> |
| 194 | 194 | </div> |
| 195 | 195 | |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | * @param int $post_id |
| 211 | 211 | * @return bool |
| 212 | 212 | */ |
| 213 | -function wp_stream_image( $image, $mime_type, $post_id ) { |
|
| 214 | - if ( $image instanceof WP_Image_Editor ) { |
|
| 213 | +function wp_stream_image($image, $mime_type, $post_id) { |
|
| 214 | + if ($image instanceof WP_Image_Editor) { |
|
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | 217 | * Filter the WP_Image_Editor instance for the image to be streamed to the browser. |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | * @param WP_Image_Editor $image WP_Image_Editor instance. |
| 222 | 222 | * @param int $post_id Post ID. |
| 223 | 223 | */ |
| 224 | - $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); |
|
| 224 | + $image = apply_filters('image_editor_save_pre', $image, $post_id); |
|
| 225 | 225 | |
| 226 | - if ( is_wp_error( $image->stream( $mime_type ) ) ) |
|
| 226 | + if (is_wp_error($image->stream($mime_type))) |
|
| 227 | 227 | return false; |
| 228 | 228 | |
| 229 | 229 | return true; |
| 230 | 230 | } else { |
| 231 | - _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
| 231 | + _deprecated_argument(__FUNCTION__, '3.5', __('$image needs to be an WP_Image_Editor object')); |
|
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * Filter the GD image resource to be streamed to the browser. |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | * @param resource $image Image resource to be streamed. |
| 240 | 240 | * @param int $post_id Post ID. |
| 241 | 241 | */ |
| 242 | - $image = apply_filters( 'image_save_pre', $image, $post_id ); |
|
| 242 | + $image = apply_filters('image_save_pre', $image, $post_id); |
|
| 243 | 243 | |
| 244 | - switch ( $mime_type ) { |
|
| 244 | + switch ($mime_type) { |
|
| 245 | 245 | case 'image/jpeg': |
| 246 | - header( 'Content-Type: image/jpeg' ); |
|
| 247 | - return imagejpeg( $image, null, 90 ); |
|
| 246 | + header('Content-Type: image/jpeg'); |
|
| 247 | + return imagejpeg($image, null, 90); |
|
| 248 | 248 | case 'image/png': |
| 249 | - header( 'Content-Type: image/png' ); |
|
| 250 | - return imagepng( $image ); |
|
| 249 | + header('Content-Type: image/png'); |
|
| 250 | + return imagepng($image); |
|
| 251 | 251 | case 'image/gif': |
| 252 | - header( 'Content-Type: image/gif' ); |
|
| 253 | - return imagegif( $image ); |
|
| 252 | + header('Content-Type: image/gif'); |
|
| 253 | + return imagegif($image); |
|
| 254 | 254 | default: |
| 255 | 255 | return false; |
| 256 | 256 | } |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | * @param int $post_id |
| 267 | 267 | * @return bool |
| 268 | 268 | */ |
| 269 | -function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { |
|
| 270 | - if ( $image instanceof WP_Image_Editor ) { |
|
| 269 | +function wp_save_image_file($filename, $image, $mime_type, $post_id) { |
|
| 270 | + if ($image instanceof WP_Image_Editor) { |
|
| 271 | 271 | |
| 272 | 272 | /** This filter is documented in wp-admin/includes/image-edit.php */ |
| 273 | - $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); |
|
| 273 | + $image = apply_filters('image_editor_save_pre', $image, $post_id); |
|
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * Filter whether to skip saving the image file. |
@@ -286,17 +286,17 @@ discard block |
||
| 286 | 286 | * @param string $mime_type Image mime type. |
| 287 | 287 | * @param int $post_id Post ID. |
| 288 | 288 | */ |
| 289 | - $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); |
|
| 289 | + $saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id); |
|
| 290 | 290 | |
| 291 | - if ( null !== $saved ) |
|
| 291 | + if (null !== $saved) |
|
| 292 | 292 | return $saved; |
| 293 | 293 | |
| 294 | - return $image->save( $filename, $mime_type ); |
|
| 294 | + return $image->save($filename, $mime_type); |
|
| 295 | 295 | } else { |
| 296 | - _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
| 296 | + _deprecated_argument(__FUNCTION__, '3.5', __('$image needs to be an WP_Image_Editor object')); |
|
| 297 | 297 | |
| 298 | 298 | /** This filter is documented in wp-admin/includes/image-edit.php */ |
| 299 | - $image = apply_filters( 'image_save_pre', $image, $post_id ); |
|
| 299 | + $image = apply_filters('image_save_pre', $image, $post_id); |
|
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * Filter whether to skip saving the image file. |
@@ -313,20 +313,20 @@ discard block |
||
| 313 | 313 | * @param string $mime_type Image mime type. |
| 314 | 314 | * @param int $post_id Post ID. |
| 315 | 315 | */ |
| 316 | - $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id ); |
|
| 316 | + $saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id); |
|
| 317 | 317 | |
| 318 | - if ( null !== $saved ) |
|
| 318 | + if (null !== $saved) |
|
| 319 | 319 | return $saved; |
| 320 | 320 | |
| 321 | - switch ( $mime_type ) { |
|
| 321 | + switch ($mime_type) { |
|
| 322 | 322 | case 'image/jpeg': |
| 323 | 323 | |
| 324 | 324 | /** This filter is documented in wp-includes/class-wp-image-editor.php */ |
| 325 | - return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) ); |
|
| 325 | + return imagejpeg($image, $filename, apply_filters('jpeg_quality', 90, 'edit_image')); |
|
| 326 | 326 | case 'image/png': |
| 327 | - return imagepng( $image, $filename ); |
|
| 327 | + return imagepng($image, $filename); |
|
| 328 | 328 | case 'image/gif': |
| 329 | - return imagegif( $image, $filename ); |
|
| 329 | + return imagegif($image, $filename); |
|
| 330 | 330 | default: |
| 331 | 331 | return false; |
| 332 | 332 | } |
@@ -359,10 +359,10 @@ discard block |
||
| 359 | 359 | * @return resource|false GD image resource, false otherwise. |
| 360 | 360 | */ |
| 361 | 361 | function _rotate_image_resource($img, $angle) { |
| 362 | - _deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::rotate' ) ); |
|
| 363 | - if ( function_exists('imagerotate') ) { |
|
| 362 | + _deprecated_function(__FUNCTION__, '3.5', __('Use WP_Image_Editor::rotate')); |
|
| 363 | + if (function_exists('imagerotate')) { |
|
| 364 | 364 | $rotated = imagerotate($img, $angle, 0); |
| 365 | - if ( is_resource($rotated) ) { |
|
| 365 | + if (is_resource($rotated)) { |
|
| 366 | 366 | imagedestroy($img); |
| 367 | 367 | $img = $rotated; |
| 368 | 368 | } |
@@ -382,17 +382,17 @@ discard block |
||
| 382 | 382 | * @return resource (maybe) flipped image resource. |
| 383 | 383 | */ |
| 384 | 384 | function _flip_image_resource($img, $horz, $vert) { |
| 385 | - _deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::flip' ) ); |
|
| 385 | + _deprecated_function(__FUNCTION__, '3.5', __('Use WP_Image_Editor::flip')); |
|
| 386 | 386 | $w = imagesx($img); |
| 387 | 387 | $h = imagesy($img); |
| 388 | 388 | $dst = wp_imagecreatetruecolor($w, $h); |
| 389 | - if ( is_resource($dst) ) { |
|
| 389 | + if (is_resource($dst)) { |
|
| 390 | 390 | $sx = $vert ? ($w - 1) : 0; |
| 391 | 391 | $sy = $horz ? ($h - 1) : 0; |
| 392 | 392 | $sw = $vert ? -$w : $w; |
| 393 | 393 | $sh = $horz ? -$h : $h; |
| 394 | 394 | |
| 395 | - if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) { |
|
| 395 | + if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) { |
|
| 396 | 396 | imagedestroy($img); |
| 397 | 397 | $img = $dst; |
| 398 | 398 | } |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | */ |
| 416 | 416 | function _crop_image_resource($img, $x, $y, $w, $h) { |
| 417 | 417 | $dst = wp_imagecreatetruecolor($w, $h); |
| 418 | - if ( is_resource($dst) ) { |
|
| 419 | - if ( imagecopy($dst, $img, 0, 0, $x, $y, $w, $h) ) { |
|
| 418 | + if (is_resource($dst)) { |
|
| 419 | + if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) { |
|
| 420 | 420 | imagedestroy($img); |
| 421 | 421 | $img = $dst; |
| 422 | 422 | } |
@@ -433,24 +433,24 @@ discard block |
||
| 433 | 433 | * @param array $changes Array of change operations. |
| 434 | 434 | * @return WP_Image_Editor {@see WP_Image_Editor} instance with changes applied. |
| 435 | 435 | */ |
| 436 | -function image_edit_apply_changes( $image, $changes ) { |
|
| 437 | - if ( is_resource( $image ) ) |
|
| 438 | - _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
| 436 | +function image_edit_apply_changes($image, $changes) { |
|
| 437 | + if (is_resource($image)) |
|
| 438 | + _deprecated_argument(__FUNCTION__, '3.5', __('$image needs to be an WP_Image_Editor object')); |
|
| 439 | 439 | |
| 440 | - if ( !is_array($changes) ) |
|
| 440 | + if ( ! is_array($changes)) |
|
| 441 | 441 | return $image; |
| 442 | 442 | |
| 443 | 443 | // Expand change operations. |
| 444 | - foreach ( $changes as $key => $obj ) { |
|
| 445 | - if ( isset($obj->r) ) { |
|
| 444 | + foreach ($changes as $key => $obj) { |
|
| 445 | + if (isset($obj->r)) { |
|
| 446 | 446 | $obj->type = 'rotate'; |
| 447 | 447 | $obj->angle = $obj->r; |
| 448 | 448 | unset($obj->r); |
| 449 | - } elseif ( isset($obj->f) ) { |
|
| 449 | + } elseif (isset($obj->f)) { |
|
| 450 | 450 | $obj->type = 'flip'; |
| 451 | 451 | $obj->axis = $obj->f; |
| 452 | 452 | unset($obj->f); |
| 453 | - } elseif ( isset($obj->c) ) { |
|
| 453 | + } elseif (isset($obj->c)) { |
|
| 454 | 454 | $obj->type = 'crop'; |
| 455 | 455 | $obj->sel = $obj->c; |
| 456 | 456 | unset($obj->c); |
@@ -459,12 +459,12 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // Combine operations. |
| 462 | - if ( count($changes) > 1 ) { |
|
| 462 | + if (count($changes) > 1) { |
|
| 463 | 463 | $filtered = array($changes[0]); |
| 464 | - for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) { |
|
| 464 | + for ($i = 0, $j = 1, $c = count($changes); $j < $c; $j++) { |
|
| 465 | 465 | $combined = false; |
| 466 | - if ( $filtered[$i]->type == $changes[$j]->type ) { |
|
| 467 | - switch ( $filtered[$i]->type ) { |
|
| 466 | + if ($filtered[$i]->type == $changes[$j]->type) { |
|
| 467 | + switch ($filtered[$i]->type) { |
|
| 468 | 468 | case 'rotate': |
| 469 | 469 | $filtered[$i]->angle += $changes[$j]->angle; |
| 470 | 470 | $combined = true; |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | break; |
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | - if ( !$combined ) |
|
| 478 | + if ( ! $combined) |
|
| 479 | 479 | $filtered[++$i] = $changes[$j]; |
| 480 | 480 | } |
| 481 | 481 | $changes = $filtered; |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | // Image resource before applying the changes. |
| 486 | - if ( $image instanceof WP_Image_Editor ) { |
|
| 486 | + if ($image instanceof WP_Image_Editor) { |
|
| 487 | 487 | |
| 488 | 488 | /** |
| 489 | 489 | * Filter the WP_Image_Editor instance before applying changes to the image. |
@@ -493,8 +493,8 @@ discard block |
||
| 493 | 493 | * @param WP_Image_Editor $image WP_Image_Editor instance. |
| 494 | 494 | * @param array $changes Array of change operations. |
| 495 | 495 | */ |
| 496 | - $image = apply_filters( 'wp_image_editor_before_change', $image, $changes ); |
|
| 497 | - } elseif ( is_resource( $image ) ) { |
|
| 496 | + $image = apply_filters('wp_image_editor_before_change', $image, $changes); |
|
| 497 | + } elseif (is_resource($image)) { |
|
| 498 | 498 | |
| 499 | 499 | /** |
| 500 | 500 | * Filter the GD image resource before applying changes to the image. |
@@ -505,39 +505,39 @@ discard block |
||
| 505 | 505 | * @param resource $image GD image resource. |
| 506 | 506 | * @param array $changes Array of change operations. |
| 507 | 507 | */ |
| 508 | - $image = apply_filters( 'image_edit_before_change', $image, $changes ); |
|
| 508 | + $image = apply_filters('image_edit_before_change', $image, $changes); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - foreach ( $changes as $operation ) { |
|
| 512 | - switch ( $operation->type ) { |
|
| 511 | + foreach ($changes as $operation) { |
|
| 512 | + switch ($operation->type) { |
|
| 513 | 513 | case 'rotate': |
| 514 | - if ( $operation->angle != 0 ) { |
|
| 515 | - if ( $image instanceof WP_Image_Editor ) |
|
| 516 | - $image->rotate( $operation->angle ); |
|
| 514 | + if ($operation->angle != 0) { |
|
| 515 | + if ($image instanceof WP_Image_Editor) |
|
| 516 | + $image->rotate($operation->angle); |
|
| 517 | 517 | else |
| 518 | - $image = _rotate_image_resource( $image, $operation->angle ); |
|
| 518 | + $image = _rotate_image_resource($image, $operation->angle); |
|
| 519 | 519 | } |
| 520 | 520 | break; |
| 521 | 521 | case 'flip': |
| 522 | - if ( $operation->axis != 0 ) |
|
| 523 | - if ( $image instanceof WP_Image_Editor ) |
|
| 524 | - $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 ); |
|
| 522 | + if ($operation->axis != 0) |
|
| 523 | + if ($image instanceof WP_Image_Editor) |
|
| 524 | + $image->flip(($operation->axis & 1) != 0, ($operation->axis & 2) != 0); |
|
| 525 | 525 | else |
| 526 | - $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); |
|
| 526 | + $image = _flip_image_resource($image, ($operation->axis & 1) != 0, ($operation->axis & 2) != 0); |
|
| 527 | 527 | break; |
| 528 | 528 | case 'crop': |
| 529 | 529 | $sel = $operation->sel; |
| 530 | 530 | |
| 531 | - if ( $image instanceof WP_Image_Editor ) { |
|
| 531 | + if ($image instanceof WP_Image_Editor) { |
|
| 532 | 532 | $size = $image->get_size(); |
| 533 | 533 | $w = $size['width']; |
| 534 | 534 | $h = $size['height']; |
| 535 | 535 | |
| 536 | - $scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling |
|
| 537 | - $image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); |
|
| 536 | + $scale = 1 / _image_get_preview_ratio($w, $h); // discard preview scaling |
|
| 537 | + $image->crop($sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale); |
|
| 538 | 538 | } else { |
| 539 | - $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // discard preview scaling |
|
| 540 | - $image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); |
|
| 539 | + $scale = 1 / _image_get_preview_ratio(imagesx($image), imagesy($image)); // discard preview scaling |
|
| 540 | + $image = _crop_image_resource($image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale); |
|
| 541 | 541 | } |
| 542 | 542 | break; |
| 543 | 543 | } |
@@ -554,34 +554,34 @@ discard block |
||
| 554 | 554 | * @param int $post_id |
| 555 | 555 | * @return bool |
| 556 | 556 | */ |
| 557 | -function stream_preview_image( $post_id ) { |
|
| 558 | - $post = get_post( $post_id ); |
|
| 557 | +function stream_preview_image($post_id) { |
|
| 558 | + $post = get_post($post_id); |
|
| 559 | 559 | |
| 560 | 560 | /** This filter is documented in wp-admin/admin.php */ |
| 561 | - @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
| 561 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
| 562 | 562 | |
| 563 | - $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) ); |
|
| 563 | + $img = wp_get_image_editor(_load_image_to_edit_path($post_id)); |
|
| 564 | 564 | |
| 565 | - if ( is_wp_error( $img ) ) |
|
| 565 | + if (is_wp_error($img)) |
|
| 566 | 566 | return false; |
| 567 | 567 | |
| 568 | - $changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null; |
|
| 569 | - if ( $changes ) |
|
| 570 | - $img = image_edit_apply_changes( $img, $changes ); |
|
| 568 | + $changes = ! empty($_REQUEST['history']) ? json_decode(wp_unslash($_REQUEST['history'])) : null; |
|
| 569 | + if ($changes) |
|
| 570 | + $img = image_edit_apply_changes($img, $changes); |
|
| 571 | 571 | |
| 572 | 572 | // Scale the image. |
| 573 | 573 | $size = $img->get_size(); |
| 574 | 574 | $w = $size['width']; |
| 575 | 575 | $h = $size['height']; |
| 576 | 576 | |
| 577 | - $ratio = _image_get_preview_ratio( $w, $h ); |
|
| 578 | - $w2 = max ( 1, $w * $ratio ); |
|
| 579 | - $h2 = max ( 1, $h * $ratio ); |
|
| 577 | + $ratio = _image_get_preview_ratio($w, $h); |
|
| 578 | + $w2 = max(1, $w * $ratio); |
|
| 579 | + $h2 = max(1, $h * $ratio); |
|
| 580 | 580 | |
| 581 | - if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) |
|
| 581 | + if (is_wp_error($img->resize($w2, $h2))) |
|
| 582 | 582 | return false; |
| 583 | 583 | |
| 584 | - return wp_stream_image( $img, $post->post_mime_type, $post_id ); |
|
| 584 | + return wp_stream_image($img, $post->post_mime_type, $post_id); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | /** |
@@ -595,30 +595,30 @@ discard block |
||
| 595 | 595 | function wp_restore_image($post_id) { |
| 596 | 596 | $meta = wp_get_attachment_metadata($post_id); |
| 597 | 597 | $file = get_attached_file($post_id); |
| 598 | - $backup_sizes = $old_backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
|
| 598 | + $backup_sizes = $old_backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true); |
|
| 599 | 599 | $restored = false; |
| 600 | 600 | $msg = new stdClass; |
| 601 | 601 | |
| 602 | - if ( !is_array($backup_sizes) ) { |
|
| 602 | + if ( ! is_array($backup_sizes)) { |
|
| 603 | 603 | $msg->error = __('Cannot load image metadata.'); |
| 604 | 604 | return $msg; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | $parts = pathinfo($file); |
| 608 | - $suffix = time() . rand(100, 999); |
|
| 608 | + $suffix = time().rand(100, 999); |
|
| 609 | 609 | $default_sizes = get_intermediate_image_sizes(); |
| 610 | 610 | |
| 611 | - if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) { |
|
| 611 | + if (isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig'])) { |
|
| 612 | 612 | $data = $backup_sizes['full-orig']; |
| 613 | 613 | |
| 614 | - if ( $parts['basename'] != $data['file'] ) { |
|
| 615 | - if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { |
|
| 614 | + if ($parts['basename'] != $data['file']) { |
|
| 615 | + if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) { |
|
| 616 | 616 | |
| 617 | 617 | // Delete only if it's edited image. |
| 618 | - if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) { |
|
| 619 | - wp_delete_file( $file ); |
|
| 618 | + if (preg_match('/-e[0-9]{13}\./', $parts['basename'])) { |
|
| 619 | + wp_delete_file($file); |
|
| 620 | 620 | } |
| 621 | - } elseif ( isset( $meta['width'], $meta['height'] ) ) { |
|
| 621 | + } elseif (isset($meta['width'], $meta['height'])) { |
|
| 622 | 622 | $backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']); |
| 623 | 623 | } |
| 624 | 624 | } |
@@ -626,21 +626,21 @@ discard block |
||
| 626 | 626 | $restored_file = path_join($parts['dirname'], $data['file']); |
| 627 | 627 | $restored = update_attached_file($post_id, $restored_file); |
| 628 | 628 | |
| 629 | - $meta['file'] = _wp_relative_upload_path( $restored_file ); |
|
| 629 | + $meta['file'] = _wp_relative_upload_path($restored_file); |
|
| 630 | 630 | $meta['width'] = $data['width']; |
| 631 | 631 | $meta['height'] = $data['height']; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - foreach ( $default_sizes as $default_size ) { |
|
| 635 | - if ( isset($backup_sizes["$default_size-orig"]) ) { |
|
| 634 | + foreach ($default_sizes as $default_size) { |
|
| 635 | + if (isset($backup_sizes["$default_size-orig"])) { |
|
| 636 | 636 | $data = $backup_sizes["$default_size-orig"]; |
| 637 | - if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) { |
|
| 638 | - if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { |
|
| 637 | + if (isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file']) { |
|
| 638 | + if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) { |
|
| 639 | 639 | |
| 640 | 640 | // Delete only if it's edited image |
| 641 | - if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) { |
|
| 642 | - $delete_file = path_join( $parts['dirname'], $meta['sizes'][$default_size]['file'] ); |
|
| 643 | - wp_delete_file( $delete_file ); |
|
| 641 | + if (preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file'])) { |
|
| 642 | + $delete_file = path_join($parts['dirname'], $meta['sizes'][$default_size]['file']); |
|
| 643 | + wp_delete_file($delete_file); |
|
| 644 | 644 | } |
| 645 | 645 | } else { |
| 646 | 646 | $backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size]; |
@@ -653,14 +653,14 @@ discard block |
||
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - if ( ! wp_update_attachment_metadata( $post_id, $meta ) || |
|
| 657 | - ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) { |
|
| 656 | + if ( ! wp_update_attachment_metadata($post_id, $meta) || |
|
| 657 | + ($old_backup_sizes !== $backup_sizes && ! update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes))) { |
|
| 658 | 658 | |
| 659 | 659 | $msg->error = __('Cannot save image metadata.'); |
| 660 | 660 | return $msg; |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - if ( !$restored ) |
|
| 663 | + if ( ! $restored) |
|
| 664 | 664 | $msg->error = __('Image metadata is inconsistent.'); |
| 665 | 665 | else |
| 666 | 666 | $msg->msg = __('Image restored successfully.'); |
@@ -677,25 +677,25 @@ discard block |
||
| 677 | 677 | * @param int $post_id |
| 678 | 678 | * @return \stdClass |
| 679 | 679 | */ |
| 680 | -function wp_save_image( $post_id ) { |
|
| 680 | +function wp_save_image($post_id) { |
|
| 681 | 681 | global $_wp_additional_image_sizes; |
| 682 | 682 | |
| 683 | 683 | $return = new stdClass; |
| 684 | 684 | $success = $delete = $scaled = $nocrop = false; |
| 685 | - $post = get_post( $post_id ); |
|
| 685 | + $post = get_post($post_id); |
|
| 686 | 686 | |
| 687 | - $img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) ); |
|
| 688 | - if ( is_wp_error( $img ) ) { |
|
| 689 | - $return->error = esc_js( __('Unable to create new image.') ); |
|
| 687 | + $img = wp_get_image_editor(_load_image_to_edit_path($post_id, 'full')); |
|
| 688 | + if (is_wp_error($img)) { |
|
| 689 | + $return->error = esc_js(__('Unable to create new image.')); |
|
| 690 | 690 | return $return; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - $fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0; |
|
| 694 | - $fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0; |
|
| 695 | - $target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : ''; |
|
| 696 | - $scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do']; |
|
| 693 | + $fwidth = ! empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0; |
|
| 694 | + $fheight = ! empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0; |
|
| 695 | + $target = ! empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : ''; |
|
| 696 | + $scale = ! empty($_REQUEST['do']) && 'scale' == $_REQUEST['do']; |
|
| 697 | 697 | |
| 698 | - if ( $scale && $fwidth > 0 && $fheight > 0 ) { |
|
| 698 | + if ($scale && $fwidth > 0 && $fheight > 0) { |
|
| 699 | 699 | $size = $img->get_size(); |
| 700 | 700 | $sX = $size['width']; |
| 701 | 701 | $sY = $size['height']; |
@@ -704,54 +704,54 @@ discard block |
||
| 704 | 704 | $diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2); |
| 705 | 705 | if ( -0.1 < $diff && $diff < 0.1 ) { |
| 706 | 706 | // Scale the full size image. |
| 707 | - if ( $img->resize( $fwidth, $fheight ) ) |
|
| 707 | + if ($img->resize($fwidth, $fheight)) |
|
| 708 | 708 | $scaled = true; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - if ( !$scaled ) { |
|
| 712 | - $return->error = esc_js( __('Error while saving the scaled image. Please reload the page and try again.') ); |
|
| 711 | + if ( ! $scaled) { |
|
| 712 | + $return->error = esc_js(__('Error while saving the scaled image. Please reload the page and try again.')); |
|
| 713 | 713 | return $return; |
| 714 | 714 | } |
| 715 | - } elseif ( !empty($_REQUEST['history']) ) { |
|
| 716 | - $changes = json_decode( wp_unslash($_REQUEST['history']) ); |
|
| 717 | - if ( $changes ) |
|
| 715 | + } elseif ( ! empty($_REQUEST['history'])) { |
|
| 716 | + $changes = json_decode(wp_unslash($_REQUEST['history'])); |
|
| 717 | + if ($changes) |
|
| 718 | 718 | $img = image_edit_apply_changes($img, $changes); |
| 719 | 719 | } else { |
| 720 | - $return->error = esc_js( __('Nothing to save, the image has not changed.') ); |
|
| 720 | + $return->error = esc_js(__('Nothing to save, the image has not changed.')); |
|
| 721 | 721 | return $return; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | $meta = wp_get_attachment_metadata($post_id); |
| 725 | - $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true ); |
|
| 725 | + $backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true); |
|
| 726 | 726 | |
| 727 | - if ( !is_array($meta) ) { |
|
| 728 | - $return->error = esc_js( __('Image data does not exist. Please re-upload the image.') ); |
|
| 727 | + if ( ! is_array($meta)) { |
|
| 728 | + $return->error = esc_js(__('Image data does not exist. Please re-upload the image.')); |
|
| 729 | 729 | return $return; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - if ( !is_array($backup_sizes) ) |
|
| 732 | + if ( ! is_array($backup_sizes)) |
|
| 733 | 733 | $backup_sizes = array(); |
| 734 | 734 | |
| 735 | 735 | // Generate new filename. |
| 736 | 736 | $path = get_attached_file($post_id); |
| 737 | - $path_parts = pathinfo( $path ); |
|
| 737 | + $path_parts = pathinfo($path); |
|
| 738 | 738 | $filename = $path_parts['filename']; |
| 739 | - $suffix = time() . rand(100, 999); |
|
| 739 | + $suffix = time().rand(100, 999); |
|
| 740 | 740 | |
| 741 | - if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && |
|
| 742 | - isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) { |
|
| 741 | + if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && |
|
| 742 | + isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename']) { |
|
| 743 | 743 | |
| 744 | - if ( 'thumbnail' == $target ) |
|
| 744 | + if ('thumbnail' == $target) |
|
| 745 | 745 | $new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}"; |
| 746 | 746 | else |
| 747 | 747 | $new_path = $path; |
| 748 | 748 | } else { |
| 749 | - while( true ) { |
|
| 750 | - $filename = preg_replace( '/-e([0-9]+)$/', '', $filename ); |
|
| 749 | + while (true) { |
|
| 750 | + $filename = preg_replace('/-e([0-9]+)$/', '', $filename); |
|
| 751 | 751 | $filename .= "-e{$suffix}"; |
| 752 | 752 | $new_filename = "{$filename}.{$path_parts['extension']}"; |
| 753 | 753 | $new_path = "{$path_parts['dirname']}/$new_filename"; |
| 754 | - if ( file_exists($new_path) ) |
|
| 754 | + if (file_exists($new_path)) |
|
| 755 | 755 | $suffix++; |
| 756 | 756 | else |
| 757 | 757 | break; |
@@ -759,92 +759,92 @@ discard block |
||
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | // Save the full-size file, also needed to create sub-sizes. |
| 762 | - if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) { |
|
| 763 | - $return->error = esc_js( __('Unable to save the image.') ); |
|
| 762 | + if ( ! wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id)) { |
|
| 763 | + $return->error = esc_js(__('Unable to save the image.')); |
|
| 764 | 764 | return $return; |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | - if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) { |
|
| 767 | + if ('nothumb' == $target || 'all' == $target || 'full' == $target || $scaled) { |
|
| 768 | 768 | $tag = false; |
| 769 | - if ( isset($backup_sizes['full-orig']) ) { |
|
| 770 | - if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) |
|
| 769 | + if (isset($backup_sizes['full-orig'])) { |
|
| 770 | + if (( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) && $backup_sizes['full-orig']['file'] != $path_parts['basename']) |
|
| 771 | 771 | $tag = "full-$suffix"; |
| 772 | 772 | } else { |
| 773 | 773 | $tag = 'full-orig'; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - if ( $tag ) |
|
| 776 | + if ($tag) |
|
| 777 | 777 | $backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']); |
| 778 | 778 | |
| 779 | - $success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path ); |
|
| 779 | + $success = ($path === $new_path) || update_attached_file($post_id, $new_path); |
|
| 780 | 780 | |
| 781 | - $meta['file'] = _wp_relative_upload_path( $new_path ); |
|
| 781 | + $meta['file'] = _wp_relative_upload_path($new_path); |
|
| 782 | 782 | |
| 783 | 783 | $size = $img->get_size(); |
| 784 | 784 | $meta['width'] = $size['width']; |
| 785 | 785 | $meta['height'] = $size['height']; |
| 786 | 786 | |
| 787 | - if ( $success && ('nothumb' == $target || 'all' == $target) ) { |
|
| 787 | + if ($success && ('nothumb' == $target || 'all' == $target)) { |
|
| 788 | 788 | $sizes = get_intermediate_image_sizes(); |
| 789 | - if ( 'nothumb' == $target ) |
|
| 790 | - $sizes = array_diff( $sizes, array('thumbnail') ); |
|
| 789 | + if ('nothumb' == $target) |
|
| 790 | + $sizes = array_diff($sizes, array('thumbnail')); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | $return->fw = $meta['width']; |
| 794 | 794 | $return->fh = $meta['height']; |
| 795 | - } elseif ( 'thumbnail' == $target ) { |
|
| 796 | - $sizes = array( 'thumbnail' ); |
|
| 795 | + } elseif ('thumbnail' == $target) { |
|
| 796 | + $sizes = array('thumbnail'); |
|
| 797 | 797 | $success = $delete = $nocrop = true; |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - if ( isset( $sizes ) ) { |
|
| 800 | + if (isset($sizes)) { |
|
| 801 | 801 | $_sizes = array(); |
| 802 | 802 | |
| 803 | - foreach ( $sizes as $size ) { |
|
| 803 | + foreach ($sizes as $size) { |
|
| 804 | 804 | $tag = false; |
| 805 | - if ( isset( $meta['sizes'][$size] ) ) { |
|
| 806 | - if ( isset($backup_sizes["$size-orig"]) ) { |
|
| 807 | - if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) |
|
| 805 | + if (isset($meta['sizes'][$size])) { |
|
| 806 | + if (isset($backup_sizes["$size-orig"])) { |
|
| 807 | + if (( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file']) |
|
| 808 | 808 | $tag = "$size-$suffix"; |
| 809 | 809 | } else { |
| 810 | 810 | $tag = "$size-orig"; |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | - if ( $tag ) |
|
| 813 | + if ($tag) |
|
| 814 | 814 | $backup_sizes[$tag] = $meta['sizes'][$size]; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - if ( isset( $_wp_additional_image_sizes[ $size ] ) ) { |
|
| 818 | - $width = intval( $_wp_additional_image_sizes[ $size ]['width'] ); |
|
| 819 | - $height = intval( $_wp_additional_image_sizes[ $size ]['height'] ); |
|
| 820 | - $crop = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop']; |
|
| 817 | + if (isset($_wp_additional_image_sizes[$size])) { |
|
| 818 | + $width = intval($_wp_additional_image_sizes[$size]['width']); |
|
| 819 | + $height = intval($_wp_additional_image_sizes[$size]['height']); |
|
| 820 | + $crop = ($nocrop) ? false : $_wp_additional_image_sizes[$size]['crop']; |
|
| 821 | 821 | } else { |
| 822 | - $height = get_option( "{$size}_size_h" ); |
|
| 823 | - $width = get_option( "{$size}_size_w" ); |
|
| 824 | - $crop = ( $nocrop ) ? false : get_option( "{$size}_crop" ); |
|
| 822 | + $height = get_option("{$size}_size_h"); |
|
| 823 | + $width = get_option("{$size}_size_w"); |
|
| 824 | + $crop = ($nocrop) ? false : get_option("{$size}_crop"); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - $_sizes[ $size ] = array( 'width' => $width, 'height' => $height, 'crop' => $crop ); |
|
| 827 | + $_sizes[$size] = array('width' => $width, 'height' => $height, 'crop' => $crop); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - $meta['sizes'] = array_merge( $meta['sizes'], $img->multi_resize( $_sizes ) ); |
|
| 830 | + $meta['sizes'] = array_merge($meta['sizes'], $img->multi_resize($_sizes)); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - unset( $img ); |
|
| 833 | + unset($img); |
|
| 834 | 834 | |
| 835 | - if ( $success ) { |
|
| 836 | - wp_update_attachment_metadata( $post_id, $meta ); |
|
| 837 | - update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes); |
|
| 835 | + if ($success) { |
|
| 836 | + wp_update_attachment_metadata($post_id, $meta); |
|
| 837 | + update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes); |
|
| 838 | 838 | |
| 839 | - if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) { |
|
| 839 | + if ($target == 'thumbnail' || $target == 'all' || $target == 'full') { |
|
| 840 | 840 | // Check if it's an image edit from attachment edit screen |
| 841 | - if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) { |
|
| 842 | - $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); |
|
| 841 | + if ( ! empty($_REQUEST['context']) && 'edit-attachment' == $_REQUEST['context']) { |
|
| 842 | + $thumb_url = wp_get_attachment_image_src($post_id, array(900, 600), true); |
|
| 843 | 843 | $return->thumbnail = $thumb_url[0]; |
| 844 | 844 | } else { |
| 845 | 845 | $file_url = wp_get_attachment_url($post_id); |
| 846 | - if ( ! empty( $meta['sizes']['thumbnail'] ) && $thumb = $meta['sizes']['thumbnail'] ) { |
|
| 847 | - $return->thumbnail = path_join( dirname($file_url), $thumb['file'] ); |
|
| 846 | + if ( ! empty($meta['sizes']['thumbnail']) && $thumb = $meta['sizes']['thumbnail']) { |
|
| 847 | + $return->thumbnail = path_join(dirname($file_url), $thumb['file']); |
|
| 848 | 848 | } else { |
| 849 | 849 | $return->thumbnail = "$file_url?w=128&h=128"; |
| 850 | 850 | } |
@@ -854,10 +854,10 @@ discard block |
||
| 854 | 854 | $delete = true; |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | - if ( $delete ) { |
|
| 858 | - wp_delete_file( $new_path ); |
|
| 857 | + if ($delete) { |
|
| 858 | + wp_delete_file($new_path); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | - $return->msg = esc_js( __('Image saved') ); |
|
| 861 | + $return->msg = esc_js(__('Image saved')); |
|
| 862 | 862 | return $return; |
| 863 | 863 | } |
@@ -20,23 +20,26 @@ discard block |
||
| 20 | 20 | $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']); |
| 21 | 21 | $note = ''; |
| 22 | 22 | |
| 23 | - if ( isset( $meta['width'], $meta['height'] ) ) |
|
| 24 | - $big = max( $meta['width'], $meta['height'] ); |
|
| 25 | - else |
|
| 26 | - die( __('Image data does not exist. Please re-upload the image.') ); |
|
| 23 | + if ( isset( $meta['width'], $meta['height'] ) ) { |
|
| 24 | + $big = max( $meta['width'], $meta['height'] ); |
|
| 25 | + } else { |
|
| 26 | + die( __('Image data does not exist. Please re-upload the image.') ); |
|
| 27 | + } |
|
| 27 | 28 | |
| 28 | 29 | $sizer = $big > 400 ? 400 / $big : 1; |
| 29 | 30 | |
| 30 | 31 | $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
| 31 | 32 | $can_restore = false; |
| 32 | - if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) |
|
| 33 | - $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); |
|
| 33 | + if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) { |
|
| 34 | + $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | if ( $msg ) { |
| 36 | - if ( isset($msg->error) ) |
|
| 37 | - $note = "<div class='error'><p>$msg->error</p></div>"; |
|
| 38 | - elseif ( isset($msg->msg) ) |
|
| 39 | - $note = "<div class='updated'><p>$msg->msg</p></div>"; |
|
| 38 | + if ( isset($msg->error) ) { |
|
| 39 | + $note = "<div class='error'><p>$msg->error</p></div>"; |
|
| 40 | + } elseif ( isset($msg->msg) ) { |
|
| 41 | + $note = "<div class='updated'><p>$msg->msg</p></div>"; |
|
| 42 | + } |
|
| 40 | 43 | } |
| 41 | 44 | |
| 42 | 45 | ?> |
@@ -69,8 +72,9 @@ discard block |
||
| 69 | 72 | <div class="imgedit-help"> |
| 70 | 73 | <p><?php _e('Discard any changes and restore the original image.'); |
| 71 | 74 | |
| 72 | - if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) |
|
| 73 | - echo ' '.__('Previously edited copies of the image will not be deleted.'); |
|
| 75 | + if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) { |
|
| 76 | + echo ' '.__('Previously edited copies of the image will not be deleted.'); |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | ?></p> |
| 76 | 80 | <div class="imgedit-submit"> |
@@ -223,8 +227,9 @@ discard block |
||
| 223 | 227 | */ |
| 224 | 228 | $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); |
| 225 | 229 | |
| 226 | - if ( is_wp_error( $image->stream( $mime_type ) ) ) |
|
| 227 | - return false; |
|
| 230 | + if ( is_wp_error( $image->stream( $mime_type ) ) ) { |
|
| 231 | + return false; |
|
| 232 | + } |
|
| 228 | 233 | |
| 229 | 234 | return true; |
| 230 | 235 | } else { |
@@ -288,8 +293,9 @@ discard block |
||
| 288 | 293 | */ |
| 289 | 294 | $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); |
| 290 | 295 | |
| 291 | - if ( null !== $saved ) |
|
| 292 | - return $saved; |
|
| 296 | + if ( null !== $saved ) { |
|
| 297 | + return $saved; |
|
| 298 | + } |
|
| 293 | 299 | |
| 294 | 300 | return $image->save( $filename, $mime_type ); |
| 295 | 301 | } else { |
@@ -315,8 +321,9 @@ discard block |
||
| 315 | 321 | */ |
| 316 | 322 | $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id ); |
| 317 | 323 | |
| 318 | - if ( null !== $saved ) |
|
| 319 | - return $saved; |
|
| 324 | + if ( null !== $saved ) { |
|
| 325 | + return $saved; |
|
| 326 | + } |
|
| 320 | 327 | |
| 321 | 328 | switch ( $mime_type ) { |
| 322 | 329 | case 'image/jpeg': |
@@ -434,11 +441,13 @@ discard block |
||
| 434 | 441 | * @return WP_Image_Editor {@see WP_Image_Editor} instance with changes applied. |
| 435 | 442 | */ |
| 436 | 443 | function image_edit_apply_changes( $image, $changes ) { |
| 437 | - if ( is_resource( $image ) ) |
|
| 438 | - _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
| 444 | + if ( is_resource( $image ) ) { |
|
| 445 | + _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
| 446 | + } |
|
| 439 | 447 | |
| 440 | - if ( !is_array($changes) ) |
|
| 441 | - return $image; |
|
| 448 | + if ( !is_array($changes) ) { |
|
| 449 | + return $image; |
|
| 450 | + } |
|
| 442 | 451 | |
| 443 | 452 | // Expand change operations. |
| 444 | 453 | foreach ( $changes as $key => $obj ) { |
@@ -475,8 +484,9 @@ discard block |
||
| 475 | 484 | break; |
| 476 | 485 | } |
| 477 | 486 | } |
| 478 | - if ( !$combined ) |
|
| 479 | - $filtered[++$i] = $changes[$j]; |
|
| 487 | + if ( !$combined ) { |
|
| 488 | + $filtered[++$i] = $changes[$j]; |
|
| 489 | + } |
|
| 480 | 490 | } |
| 481 | 491 | $changes = $filtered; |
| 482 | 492 | unset($filtered); |
@@ -512,18 +522,20 @@ discard block |
||
| 512 | 522 | switch ( $operation->type ) { |
| 513 | 523 | case 'rotate': |
| 514 | 524 | if ( $operation->angle != 0 ) { |
| 515 | - if ( $image instanceof WP_Image_Editor ) |
|
| 516 | - $image->rotate( $operation->angle ); |
|
| 517 | - else |
|
| 518 | - $image = _rotate_image_resource( $image, $operation->angle ); |
|
| 525 | + if ( $image instanceof WP_Image_Editor ) { |
|
| 526 | + $image->rotate( $operation->angle ); |
|
| 527 | + } else { |
|
| 528 | + $image = _rotate_image_resource( $image, $operation->angle ); |
|
| 529 | + } |
|
| 519 | 530 | } |
| 520 | 531 | break; |
| 521 | 532 | case 'flip': |
| 522 | - if ( $operation->axis != 0 ) |
|
| 523 | - if ( $image instanceof WP_Image_Editor ) |
|
| 533 | + if ( $operation->axis != 0 ) { |
|
| 534 | + if ( $image instanceof WP_Image_Editor ) |
|
| 524 | 535 | $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 ); |
| 525 | - else |
|
| 526 | - $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); |
|
| 536 | + } else { |
|
| 537 | + $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); |
|
| 538 | + } |
|
| 527 | 539 | break; |
| 528 | 540 | case 'crop': |
| 529 | 541 | $sel = $operation->sel; |
@@ -562,12 +574,14 @@ discard block |
||
| 562 | 574 | |
| 563 | 575 | $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) ); |
| 564 | 576 | |
| 565 | - if ( is_wp_error( $img ) ) |
|
| 566 | - return false; |
|
| 577 | + if ( is_wp_error( $img ) ) { |
|
| 578 | + return false; |
|
| 579 | + } |
|
| 567 | 580 | |
| 568 | 581 | $changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null; |
| 569 | - if ( $changes ) |
|
| 570 | - $img = image_edit_apply_changes( $img, $changes ); |
|
| 582 | + if ( $changes ) { |
|
| 583 | + $img = image_edit_apply_changes( $img, $changes ); |
|
| 584 | + } |
|
| 571 | 585 | |
| 572 | 586 | // Scale the image. |
| 573 | 587 | $size = $img->get_size(); |
@@ -578,8 +592,9 @@ discard block |
||
| 578 | 592 | $w2 = max ( 1, $w * $ratio ); |
| 579 | 593 | $h2 = max ( 1, $h * $ratio ); |
| 580 | 594 | |
| 581 | - if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) |
|
| 582 | - return false; |
|
| 595 | + if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) { |
|
| 596 | + return false; |
|
| 597 | + } |
|
| 583 | 598 | |
| 584 | 599 | return wp_stream_image( $img, $post->post_mime_type, $post_id ); |
| 585 | 600 | } |
@@ -660,10 +675,11 @@ discard block |
||
| 660 | 675 | return $msg; |
| 661 | 676 | } |
| 662 | 677 | |
| 663 | - if ( !$restored ) |
|
| 664 | - $msg->error = __('Image metadata is inconsistent.'); |
|
| 665 | - else |
|
| 666 | - $msg->msg = __('Image restored successfully.'); |
|
| 678 | + if ( !$restored ) { |
|
| 679 | + $msg->error = __('Image metadata is inconsistent.'); |
|
| 680 | + } else { |
|
| 681 | + $msg->msg = __('Image restored successfully.'); |
|
| 682 | + } |
|
| 667 | 683 | |
| 668 | 684 | return $msg; |
| 669 | 685 | } |
@@ -704,8 +720,9 @@ discard block |
||
| 704 | 720 | $diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2); |
| 705 | 721 | if ( -0.1 < $diff && $diff < 0.1 ) { |
| 706 | 722 | // Scale the full size image. |
| 707 | - if ( $img->resize( $fwidth, $fheight ) ) |
|
| 708 | - $scaled = true; |
|
| 723 | + if ( $img->resize( $fwidth, $fheight ) ) { |
|
| 724 | + $scaled = true; |
|
| 725 | + } |
|
| 709 | 726 | } |
| 710 | 727 | |
| 711 | 728 | if ( !$scaled ) { |
@@ -714,8 +731,9 @@ discard block |
||
| 714 | 731 | } |
| 715 | 732 | } elseif ( !empty($_REQUEST['history']) ) { |
| 716 | 733 | $changes = json_decode( wp_unslash($_REQUEST['history']) ); |
| 717 | - if ( $changes ) |
|
| 718 | - $img = image_edit_apply_changes($img, $changes); |
|
| 734 | + if ( $changes ) { |
|
| 735 | + $img = image_edit_apply_changes($img, $changes); |
|
| 736 | + } |
|
| 719 | 737 | } else { |
| 720 | 738 | $return->error = esc_js( __('Nothing to save, the image has not changed.') ); |
| 721 | 739 | return $return; |
@@ -729,8 +747,9 @@ discard block |
||
| 729 | 747 | return $return; |
| 730 | 748 | } |
| 731 | 749 | |
| 732 | - if ( !is_array($backup_sizes) ) |
|
| 733 | - $backup_sizes = array(); |
|
| 750 | + if ( !is_array($backup_sizes) ) { |
|
| 751 | + $backup_sizes = array(); |
|
| 752 | + } |
|
| 734 | 753 | |
| 735 | 754 | // Generate new filename. |
| 736 | 755 | $path = get_attached_file($post_id); |
@@ -741,20 +760,22 @@ discard block |
||
| 741 | 760 | if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && |
| 742 | 761 | isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) { |
| 743 | 762 | |
| 744 | - if ( 'thumbnail' == $target ) |
|
| 745 | - $new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}"; |
|
| 746 | - else |
|
| 747 | - $new_path = $path; |
|
| 763 | + if ( 'thumbnail' == $target ) { |
|
| 764 | + $new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}"; |
|
| 765 | + } else { |
|
| 766 | + $new_path = $path; |
|
| 767 | + } |
|
| 748 | 768 | } else { |
| 749 | 769 | while( true ) { |
| 750 | 770 | $filename = preg_replace( '/-e([0-9]+)$/', '', $filename ); |
| 751 | 771 | $filename .= "-e{$suffix}"; |
| 752 | 772 | $new_filename = "{$filename}.{$path_parts['extension']}"; |
| 753 | 773 | $new_path = "{$path_parts['dirname']}/$new_filename"; |
| 754 | - if ( file_exists($new_path) ) |
|
| 755 | - $suffix++; |
|
| 756 | - else |
|
| 757 | - break; |
|
| 774 | + if ( file_exists($new_path) ) { |
|
| 775 | + $suffix++; |
|
| 776 | + } else { |
|
| 777 | + break; |
|
| 778 | + } |
|
| 758 | 779 | } |
| 759 | 780 | } |
| 760 | 781 | |
@@ -767,14 +788,16 @@ discard block |
||
| 767 | 788 | if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) { |
| 768 | 789 | $tag = false; |
| 769 | 790 | if ( isset($backup_sizes['full-orig']) ) { |
| 770 | - if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) |
|
| 771 | - $tag = "full-$suffix"; |
|
| 791 | + if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) { |
|
| 792 | + $tag = "full-$suffix"; |
|
| 793 | + } |
|
| 772 | 794 | } else { |
| 773 | 795 | $tag = 'full-orig'; |
| 774 | 796 | } |
| 775 | 797 | |
| 776 | - if ( $tag ) |
|
| 777 | - $backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']); |
|
| 798 | + if ( $tag ) { |
|
| 799 | + $backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']); |
|
| 800 | + } |
|
| 778 | 801 | |
| 779 | 802 | $success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path ); |
| 780 | 803 | |
@@ -786,8 +809,9 @@ discard block |
||
| 786 | 809 | |
| 787 | 810 | if ( $success && ('nothumb' == $target || 'all' == $target) ) { |
| 788 | 811 | $sizes = get_intermediate_image_sizes(); |
| 789 | - if ( 'nothumb' == $target ) |
|
| 790 | - $sizes = array_diff( $sizes, array('thumbnail') ); |
|
| 812 | + if ( 'nothumb' == $target ) { |
|
| 813 | + $sizes = array_diff( $sizes, array('thumbnail') ); |
|
| 814 | + } |
|
| 791 | 815 | } |
| 792 | 816 | |
| 793 | 817 | $return->fw = $meta['width']; |
@@ -804,14 +828,16 @@ discard block |
||
| 804 | 828 | $tag = false; |
| 805 | 829 | if ( isset( $meta['sizes'][$size] ) ) { |
| 806 | 830 | if ( isset($backup_sizes["$size-orig"]) ) { |
| 807 | - if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) |
|
| 808 | - $tag = "$size-$suffix"; |
|
| 831 | + if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) { |
|
| 832 | + $tag = "$size-$suffix"; |
|
| 833 | + } |
|
| 809 | 834 | } else { |
| 810 | 835 | $tag = "$size-orig"; |
| 811 | 836 | } |
| 812 | 837 | |
| 813 | - if ( $tag ) |
|
| 814 | - $backup_sizes[$tag] = $meta['sizes'][$size]; |
|
| 838 | + if ( $tag ) { |
|
| 839 | + $backup_sizes[$tag] = $meta['sizes'][$size]; |
|
| 840 | + } |
|
| 815 | 841 | } |
| 816 | 842 | |
| 817 | 843 | if ( isset( $_wp_additional_image_sizes[ $size ] ) ) { |