@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | /** |
| 486 | 486 | * |
| 487 | - * @return array |
|
| 487 | + * @return string[] |
|
| 488 | 488 | */ |
| 489 | 489 | protected function get_table_classes() { |
| 490 | 490 | return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | * @since 4.3.0 |
| 1163 | 1163 | * @access protected |
| 1164 | 1164 | * |
| 1165 | - * @param object $post Post being acted upon. |
|
| 1165 | + * @param WP_Post $post Post being acted upon. |
|
| 1166 | 1166 | * @param string $column_name Current column name. |
| 1167 | 1167 | * @param string $primary Primary column name. |
| 1168 | 1168 | * @return string Row actions output for posts. |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * List Table API: WP_Posts_List_Table class |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Administration |
|
| 7 | - * @since 3.1.0 |
|
| 8 | - */ |
|
| 3 | + * List Table API: WP_Posts_List_Table class |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Administration |
|
| 7 | + * @since 3.1.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Core class used to implement displaying posts in a list table. |
@@ -1131,10 +1131,10 @@ discard block |
||
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | if ( $post->post_parent ) { |
| 1134 | - $count = count( get_post_ancestors( $post->ID ) ); |
|
| 1135 | - $classes .= ' level-'. $count; |
|
| 1134 | + $count = count( get_post_ancestors( $post->ID ) ); |
|
| 1135 | + $classes .= ' level-'. $count; |
|
| 1136 | 1136 | } else { |
| 1137 | - $classes .= ' level-0'; |
|
| 1137 | + $classes .= ' level-0'; |
|
| 1138 | 1138 | } |
| 1139 | 1139 | ?> |
| 1140 | 1140 | <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
@@ -1508,7 +1508,7 @@ discard block |
||
| 1508 | 1508 | <?php |
| 1509 | 1509 | /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
| 1510 | 1510 | $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' ); |
| 1511 | - ?> |
|
| 1511 | + ?> |
|
| 1512 | 1512 | <option value="default"><?php echo esc_html( $default_title ); ?></option> |
| 1513 | 1513 | <?php page_template_dropdown() ?> |
| 1514 | 1514 | </select> |
@@ -77,35 +77,35 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @param array $args An associative array of arguments. |
| 79 | 79 | */ |
| 80 | - public function __construct( $args = array() ) { |
|
| 80 | + public function __construct($args = array()) { |
|
| 81 | 81 | global $post_type_object, $wpdb; |
| 82 | 82 | |
| 83 | - parent::__construct( array( |
|
| 83 | + parent::__construct(array( |
|
| 84 | 84 | 'plural' => 'posts', |
| 85 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
| 86 | - ) ); |
|
| 85 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
| 86 | + )); |
|
| 87 | 87 | |
| 88 | 88 | $post_type = $this->screen->post_type; |
| 89 | - $post_type_object = get_post_type_object( $post_type ); |
|
| 89 | + $post_type_object = get_post_type_object($post_type); |
|
| 90 | 90 | |
| 91 | - $exclude_states = get_post_stati( array( |
|
| 91 | + $exclude_states = get_post_stati(array( |
|
| 92 | 92 | 'show_in_admin_all_list' => false, |
| 93 | - ) ); |
|
| 94 | - $this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( " |
|
| 93 | + )); |
|
| 94 | + $this->user_posts_count = intval($wpdb->get_var($wpdb->prepare(" |
|
| 95 | 95 | SELECT COUNT( 1 ) |
| 96 | 96 | FROM $wpdb->posts |
| 97 | 97 | WHERE post_type = %s |
| 98 | - AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) |
|
| 98 | + AND post_status NOT IN ( '".implode("','", $exclude_states)."' ) |
|
| 99 | 99 | AND post_author = %d |
| 100 | - ", $post_type, get_current_user_id() ) ) ); |
|
| 100 | + ", $post_type, get_current_user_id()))); |
|
| 101 | 101 | |
| 102 | - if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) { |
|
| 102 | + if ($this->user_posts_count && ! current_user_can($post_type_object->cap->edit_others_posts) && empty($_REQUEST['post_status']) && empty($_REQUEST['all_posts']) && empty($_REQUEST['author']) && empty($_REQUEST['show_sticky'])) { |
|
| 103 | 103 | $_GET['author'] = get_current_user_id(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( 'post' === $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { |
|
| 107 | - $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
|
| 108 | - $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 ) ); |
|
| 106 | + if ('post' === $post_type && $sticky_posts = get_option('sticky_posts')) { |
|
| 107 | + $sticky_posts = implode(', ', array_map('absint', (array) $sticky_posts)); |
|
| 108 | + $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)); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @param bool $display Whether the table layout should be hierarchical. |
| 118 | 118 | */ |
| 119 | - public function set_hierarchical_display( $display ) { |
|
| 119 | + public function set_hierarchical_display($display) { |
|
| 120 | 120 | $this->hierarchical_display = $display; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @return bool |
| 126 | 126 | */ |
| 127 | 127 | public function ajax_user_can() { |
| 128 | - return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
|
| 128 | + return current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_posts); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -141,50 +141,50 @@ discard block |
||
| 141 | 141 | // is going to call wp() |
| 142 | 142 | $avail_post_stati = wp_edit_posts_query(); |
| 143 | 143 | |
| 144 | - $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] ); |
|
| 144 | + $this->set_hierarchical_display(is_post_type_hierarchical($this->screen->post_type) && 'menu_order title' === $wp_query->query['orderby']); |
|
| 145 | 145 | |
| 146 | 146 | $post_type = $this->screen->post_type; |
| 147 | - $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
|
| 147 | + $per_page = $this->get_items_per_page('edit_'.$post_type.'_per_page'); |
|
| 148 | 148 | |
| 149 | 149 | /** This filter is documented in wp-admin/includes/post.php */ |
| 150 | - $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
|
| 150 | + $per_page = apply_filters('edit_posts_per_page', $per_page, $post_type); |
|
| 151 | 151 | |
| 152 | - if ( $this->hierarchical_display ) { |
|
| 152 | + if ($this->hierarchical_display) { |
|
| 153 | 153 | $total_items = $wp_query->post_count; |
| 154 | - } elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) { |
|
| 154 | + } elseif ($wp_query->found_posts || $this->get_pagenum() === 1) { |
|
| 155 | 155 | $total_items = $wp_query->found_posts; |
| 156 | 156 | } else { |
| 157 | - $post_counts = (array) wp_count_posts( $post_type, 'readable' ); |
|
| 157 | + $post_counts = (array) wp_count_posts($post_type, 'readable'); |
|
| 158 | 158 | |
| 159 | - if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) { |
|
| 160 | - $total_items = $post_counts[ $_REQUEST['post_status'] ]; |
|
| 161 | - } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { |
|
| 159 | + if (isset($_REQUEST['post_status']) && in_array($_REQUEST['post_status'], $avail_post_stati)) { |
|
| 160 | + $total_items = $post_counts[$_REQUEST['post_status']]; |
|
| 161 | + } elseif (isset($_REQUEST['show_sticky']) && $_REQUEST['show_sticky']) { |
|
| 162 | 162 | $total_items = $this->sticky_posts_count; |
| 163 | - } elseif ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) { |
|
| 163 | + } elseif (isset($_GET['author']) && $_GET['author'] == get_current_user_id()) { |
|
| 164 | 164 | $total_items = $this->user_posts_count; |
| 165 | 165 | } else { |
| 166 | - $total_items = array_sum( $post_counts ); |
|
| 166 | + $total_items = array_sum($post_counts); |
|
| 167 | 167 | |
| 168 | 168 | // Subtract post types that are not included in the admin all list. |
| 169 | - foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
|
| 170 | - $total_items -= $post_counts[ $state ]; |
|
| 169 | + foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) { |
|
| 170 | + $total_items -= $post_counts[$state]; |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( ! empty( $_REQUEST['mode'] ) ) { |
|
| 175 | + if ( ! empty($_REQUEST['mode'])) { |
|
| 176 | 176 | $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; |
| 177 | - set_user_setting( 'posts_list_mode', $mode ); |
|
| 177 | + set_user_setting('posts_list_mode', $mode); |
|
| 178 | 178 | } else { |
| 179 | - $mode = get_user_setting( 'posts_list_mode', 'list' ); |
|
| 179 | + $mode = get_user_setting('posts_list_mode', 'list'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash'; |
|
| 182 | + $this->is_trash = isset($_REQUEST['post_status']) && $_REQUEST['post_status'] === 'trash'; |
|
| 183 | 183 | |
| 184 | - $this->set_pagination_args( array( |
|
| 184 | + $this->set_pagination_args(array( |
|
| 185 | 185 | 'total_items' => $total_items, |
| 186 | 186 | 'per_page' => $per_page |
| 187 | - ) ); |
|
| 187 | + )); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @access public |
| 200 | 200 | */ |
| 201 | 201 | public function no_items() { |
| 202 | - if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) |
|
| 203 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
|
| 202 | + if (isset($_REQUEST['post_status']) && 'trash' === $_REQUEST['post_status']) |
|
| 203 | + echo get_post_type_object($this->screen->post_type)->labels->not_found_in_trash; |
|
| 204 | 204 | else |
| 205 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
|
| 205 | + echo get_post_type_object($this->screen->post_type)->labels->not_found; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -214,15 +214,15 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function is_base_request() { |
| 216 | 216 | $vars = $_GET; |
| 217 | - unset( $vars['paged'] ); |
|
| 217 | + unset($vars['paged']); |
|
| 218 | 218 | |
| 219 | - if ( empty( $vars ) ) { |
|
| 219 | + if (empty($vars)) { |
|
| 220 | 220 | return true; |
| 221 | - } elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) { |
|
| 221 | + } elseif (1 === count($vars) && ! empty($vars['post_type'])) { |
|
| 222 | 222 | return $this->screen->post_type === $vars['post_type']; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - return 1 === count( $vars ) && ! empty( $vars['mode'] ); |
|
| 225 | + return 1 === count($vars) && ! empty($vars['mode']); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -236,20 +236,20 @@ discard block |
||
| 236 | 236 | * @param string $class Optional. Class attribute. Default empty string. |
| 237 | 237 | * @return string The formatted link string. |
| 238 | 238 | */ |
| 239 | - protected function get_edit_link( $args, $label, $class = '' ) { |
|
| 240 | - $url = add_query_arg( $args, 'edit.php' ); |
|
| 239 | + protected function get_edit_link($args, $label, $class = '') { |
|
| 240 | + $url = add_query_arg($args, 'edit.php'); |
|
| 241 | 241 | |
| 242 | 242 | $class_html = ''; |
| 243 | - if ( ! empty( $class ) ) { |
|
| 243 | + if ( ! empty($class)) { |
|
| 244 | 244 | $class_html = sprintf( |
| 245 | 245 | ' class="%s"', |
| 246 | - esc_attr( $class ) |
|
| 246 | + esc_attr($class) |
|
| 247 | 247 | ); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | return sprintf( |
| 251 | 251 | '<a href="%s"%s>%s</a>', |
| 252 | - esc_url( $url ), |
|
| 252 | + esc_url($url), |
|
| 253 | 253 | $class_html, |
| 254 | 254 | $label |
| 255 | 255 | ); |
@@ -266,25 +266,25 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | $post_type = $this->screen->post_type; |
| 268 | 268 | |
| 269 | - if ( !empty($locked_post_status) ) |
|
| 269 | + if ( ! empty($locked_post_status)) |
|
| 270 | 270 | return array(); |
| 271 | 271 | |
| 272 | 272 | $status_links = array(); |
| 273 | - $num_posts = wp_count_posts( $post_type, 'readable' ); |
|
| 274 | - $total_posts = array_sum( (array) $num_posts ); |
|
| 273 | + $num_posts = wp_count_posts($post_type, 'readable'); |
|
| 274 | + $total_posts = array_sum((array) $num_posts); |
|
| 275 | 275 | $class = ''; |
| 276 | 276 | |
| 277 | 277 | $current_user_id = get_current_user_id(); |
| 278 | - $all_args = array( 'post_type' => $post_type ); |
|
| 278 | + $all_args = array('post_type' => $post_type); |
|
| 279 | 279 | $mine = ''; |
| 280 | 280 | |
| 281 | 281 | // Subtract post types that are not included in the admin all list. |
| 282 | - foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
|
| 282 | + foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) { |
|
| 283 | 283 | $total_posts -= $num_posts->$state; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { |
|
| 287 | - if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) { |
|
| 286 | + if ($this->user_posts_count && $this->user_posts_count !== $total_posts) { |
|
| 287 | + if (isset($_GET['author']) && ($_GET['author'] == $current_user_id)) { |
|
| 288 | 288 | $class = 'current'; |
| 289 | 289 | } |
| 290 | 290 | |
@@ -300,16 +300,16 @@ discard block |
||
| 300 | 300 | $this->user_posts_count, |
| 301 | 301 | 'posts' |
| 302 | 302 | ), |
| 303 | - number_format_i18n( $this->user_posts_count ) |
|
| 303 | + number_format_i18n($this->user_posts_count) |
|
| 304 | 304 | ); |
| 305 | 305 | |
| 306 | - $mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class ); |
|
| 306 | + $mine = $this->get_edit_link($mine_args, $mine_inner_html, $class); |
|
| 307 | 307 | |
| 308 | 308 | $all_args['all_posts'] = 1; |
| 309 | 309 | $class = ''; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ) ) { |
|
| 312 | + if (empty($class) && ($this->is_base_request() || isset($_REQUEST['all_posts']))) { |
|
| 313 | 313 | $class = 'current'; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -320,24 +320,24 @@ discard block |
||
| 320 | 320 | $total_posts, |
| 321 | 321 | 'posts' |
| 322 | 322 | ), |
| 323 | - number_format_i18n( $total_posts ) |
|
| 323 | + number_format_i18n($total_posts) |
|
| 324 | 324 | ); |
| 325 | 325 | |
| 326 | - $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class ); |
|
| 327 | - if ( $mine ) { |
|
| 326 | + $status_links['all'] = $this->get_edit_link($all_args, $all_inner_html, $class); |
|
| 327 | + if ($mine) { |
|
| 328 | 328 | $status_links['mine'] = $mine; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { |
|
| 331 | + foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) { |
|
| 332 | 332 | $class = ''; |
| 333 | 333 | |
| 334 | 334 | $status_name = $status->name; |
| 335 | 335 | |
| 336 | - if ( ! in_array( $status_name, $avail_post_stati ) || empty( $num_posts->$status_name ) ) { |
|
| 336 | + if ( ! in_array($status_name, $avail_post_stati) || empty($num_posts->$status_name)) { |
|
| 337 | 337 | continue; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) { |
|
| 340 | + if (isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status']) { |
|
| 341 | 341 | $class = 'current'; |
| 342 | 342 | } |
| 343 | 343 | |
@@ -347,15 +347,15 @@ discard block |
||
| 347 | 347 | ); |
| 348 | 348 | |
| 349 | 349 | $status_label = sprintf( |
| 350 | - translate_nooped_plural( $status->label_count, $num_posts->$status_name ), |
|
| 351 | - number_format_i18n( $num_posts->$status_name ) |
|
| 350 | + translate_nooped_plural($status->label_count, $num_posts->$status_name), |
|
| 351 | + number_format_i18n($num_posts->$status_name) |
|
| 352 | 352 | ); |
| 353 | 353 | |
| 354 | - $status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class ); |
|
| 354 | + $status_links[$status_name] = $this->get_edit_link($status_args, $status_label, $class); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if ( ! empty( $this->sticky_posts_count ) ) { |
|
| 358 | - $class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : ''; |
|
| 357 | + if ( ! empty($this->sticky_posts_count)) { |
|
| 358 | + $class = ! empty($_REQUEST['show_sticky']) ? 'current' : ''; |
|
| 359 | 359 | |
| 360 | 360 | $sticky_args = array( |
| 361 | 361 | 'post_type' => $post_type, |
@@ -369,16 +369,16 @@ discard block |
||
| 369 | 369 | $this->sticky_posts_count, |
| 370 | 370 | 'posts' |
| 371 | 371 | ), |
| 372 | - number_format_i18n( $this->sticky_posts_count ) |
|
| 372 | + number_format_i18n($this->sticky_posts_count) |
|
| 373 | 373 | ); |
| 374 | 374 | |
| 375 | 375 | $sticky_link = array( |
| 376 | - 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ) |
|
| 376 | + 'sticky' => $this->get_edit_link($sticky_args, $sticky_inner_html, $class) |
|
| 377 | 377 | ); |
| 378 | 378 | |
| 379 | 379 | // Sticky comes after Publish, or if not listed, after All. |
| 380 | - $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); |
|
| 381 | - $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); |
|
| 380 | + $split = 1 + array_search((isset($status_links['publish']) ? 'publish' : 'all'), array_keys($status_links)); |
|
| 381 | + $status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split)); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | return $status_links; |
@@ -390,21 +390,21 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | protected function get_bulk_actions() { |
| 392 | 392 | $actions = array(); |
| 393 | - $post_type_obj = get_post_type_object( $this->screen->post_type ); |
|
| 393 | + $post_type_obj = get_post_type_object($this->screen->post_type); |
|
| 394 | 394 | |
| 395 | - if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
|
| 396 | - if ( $this->is_trash ) { |
|
| 397 | - $actions['untrash'] = __( 'Restore' ); |
|
| 395 | + if (current_user_can($post_type_obj->cap->edit_posts)) { |
|
| 396 | + if ($this->is_trash) { |
|
| 397 | + $actions['untrash'] = __('Restore'); |
|
| 398 | 398 | } else { |
| 399 | - $actions['edit'] = __( 'Edit' ); |
|
| 399 | + $actions['edit'] = __('Edit'); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { |
|
| 404 | - if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { |
|
| 405 | - $actions['delete'] = __( 'Delete Permanently' ); |
|
| 403 | + if (current_user_can($post_type_obj->cap->delete_posts)) { |
|
| 404 | + if ($this->is_trash || ! EMPTY_TRASH_DAYS) { |
|
| 405 | + $actions['delete'] = __('Delete Permanently'); |
|
| 406 | 406 | } else { |
| 407 | - $actions['trash'] = __( 'Move to Trash' ); |
|
| 407 | + $actions['trash'] = __('Move to Trash'); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | |
@@ -415,18 +415,18 @@ discard block |
||
| 415 | 415 | * @global int $cat |
| 416 | 416 | * @param string $which |
| 417 | 417 | */ |
| 418 | - protected function extra_tablenav( $which ) { |
|
| 418 | + protected function extra_tablenav($which) { |
|
| 419 | 419 | global $cat; |
| 420 | 420 | ?> |
| 421 | 421 | <div class="alignleft actions"> |
| 422 | 422 | <?php |
| 423 | - if ( 'top' === $which && !is_singular() ) { |
|
| 423 | + if ('top' === $which && ! is_singular()) { |
|
| 424 | 424 | |
| 425 | - $this->months_dropdown( $this->screen->post_type ); |
|
| 425 | + $this->months_dropdown($this->screen->post_type); |
|
| 426 | 426 | |
| 427 | - if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) { |
|
| 427 | + if (is_object_in_taxonomy($this->screen->post_type, 'category')) { |
|
| 428 | 428 | $dropdown_options = array( |
| 429 | - 'show_option_all' => get_taxonomy( 'category' )->labels->all_items, |
|
| 429 | + 'show_option_all' => get_taxonomy('category')->labels->all_items, |
|
| 430 | 430 | 'hide_empty' => 0, |
| 431 | 431 | 'hierarchical' => 1, |
| 432 | 432 | 'show_count' => 0, |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | 'selected' => $cat |
| 435 | 435 | ); |
| 436 | 436 | |
| 437 | - echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>'; |
|
| 438 | - wp_dropdown_categories( $dropdown_options ); |
|
| 437 | + echo '<label class="screen-reader-text" for="cat">'.__('Filter by category').'</label>'; |
|
| 438 | + wp_dropdown_categories($dropdown_options); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -449,13 +449,13 @@ discard block |
||
| 449 | 449 | * |
| 450 | 450 | * @param string $post_type The post type slug. |
| 451 | 451 | */ |
| 452 | - do_action( 'restrict_manage_posts', $this->screen->post_type ); |
|
| 452 | + do_action('restrict_manage_posts', $this->screen->post_type); |
|
| 453 | 453 | |
| 454 | - submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
| 454 | + submit_button(__('Filter'), 'button', 'filter_action', false, array('id' => 'post-query-submit')); |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) { |
|
| 458 | - submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
|
| 457 | + if ($this->is_trash && current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_others_posts)) { |
|
| 458 | + submit_button(__('Empty Trash'), 'apply', 'delete_all', false); |
|
| 459 | 459 | } |
| 460 | 460 | ?> |
| 461 | 461 | </div> |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * |
| 469 | 469 | * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. |
| 470 | 470 | */ |
| 471 | - do_action( 'manage_posts_extra_tablenav', $which ); |
|
| 471 | + do_action('manage_posts_extra_tablenav', $which); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | * @return string |
| 477 | 477 | */ |
| 478 | 478 | public function current_action() { |
| 479 | - if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
|
| 479 | + if (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) |
|
| 480 | 480 | return 'delete_all'; |
| 481 | 481 | |
| 482 | 482 | return parent::current_action(); |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | * @return array |
| 488 | 488 | */ |
| 489 | 489 | protected function get_table_classes() { |
| 490 | - return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
|
| 490 | + return array('widefat', 'fixed', 'striped', is_post_type_hierarchical($this->screen->post_type) ? 'pages' : 'posts'); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
@@ -502,14 +502,14 @@ discard block |
||
| 502 | 502 | $posts_columns['cb'] = '<input type="checkbox" />'; |
| 503 | 503 | |
| 504 | 504 | /* translators: manage posts column name */ |
| 505 | - $posts_columns['title'] = _x( 'Title', 'column name' ); |
|
| 505 | + $posts_columns['title'] = _x('Title', 'column name'); |
|
| 506 | 506 | |
| 507 | - if ( post_type_supports( $post_type, 'author' ) ) { |
|
| 508 | - $posts_columns['author'] = __( 'Author' ); |
|
| 507 | + if (post_type_supports($post_type, 'author')) { |
|
| 508 | + $posts_columns['author'] = __('Author'); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - $taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
|
| 512 | - $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
|
| 511 | + $taxonomies = get_object_taxonomies($post_type, 'objects'); |
|
| 512 | + $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name'); |
|
| 513 | 513 | |
| 514 | 514 | /** |
| 515 | 515 | * Filter the taxonomy columns in the Posts list table. |
@@ -522,27 +522,27 @@ discard block |
||
| 522 | 522 | * @param array $taxonomies Array of taxonomies to show columns for. |
| 523 | 523 | * @param string $post_type The post type. |
| 524 | 524 | */ |
| 525 | - $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
|
| 526 | - $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
| 525 | + $taxonomies = apply_filters("manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type); |
|
| 526 | + $taxonomies = array_filter($taxonomies, 'taxonomy_exists'); |
|
| 527 | 527 | |
| 528 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 529 | - if ( 'category' === $taxonomy ) |
|
| 528 | + foreach ($taxonomies as $taxonomy) { |
|
| 529 | + if ('category' === $taxonomy) |
|
| 530 | 530 | $column_key = 'categories'; |
| 531 | - elseif ( 'post_tag' === $taxonomy ) |
|
| 531 | + elseif ('post_tag' === $taxonomy) |
|
| 532 | 532 | $column_key = 'tags'; |
| 533 | 533 | else |
| 534 | - $column_key = 'taxonomy-' . $taxonomy; |
|
| 534 | + $column_key = 'taxonomy-'.$taxonomy; |
|
| 535 | 535 | |
| 536 | - $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
| 536 | + $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name; |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
|
| 540 | - if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
|
| 541 | - $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
| 539 | + $post_status = ! empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all'; |
|
| 540 | + if (post_type_supports($post_type, 'comments') && ! in_array($post_status, array('pending', 'draft', 'future'))) |
|
| 541 | + $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="'.esc_attr__('Comments').'"><span class="screen-reader-text">'.__('Comments').'</span></span>'; |
|
| 542 | 542 | |
| 543 | - $posts_columns['date'] = __( 'Date' ); |
|
| 543 | + $posts_columns['date'] = __('Date'); |
|
| 544 | 544 | |
| 545 | - if ( 'page' === $post_type ) { |
|
| 545 | + if ('page' === $post_type) { |
|
| 546 | 546 | |
| 547 | 547 | /** |
| 548 | 548 | * Filter the columns displayed in the Pages list table. |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | * |
| 552 | 552 | * @param array $post_columns An array of column names. |
| 553 | 553 | */ |
| 554 | - $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
|
| 554 | + $posts_columns = apply_filters('manage_pages_columns', $posts_columns); |
|
| 555 | 555 | } else { |
| 556 | 556 | |
| 557 | 557 | /** |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | * @param array $posts_columns An array of column names. |
| 563 | 563 | * @param string $post_type The post type slug. |
| 564 | 564 | */ |
| 565 | - $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); |
|
| 565 | + $posts_columns = apply_filters('manage_posts_columns', $posts_columns, $post_type); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | * |
| 575 | 575 | * @param array $post_columns An array of column names. |
| 576 | 576 | */ |
| 577 | - return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); |
|
| 577 | + return apply_filters("manage_{$post_type}_posts_columns", $posts_columns); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | /** |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | 'title' => 'title', |
| 587 | 587 | 'parent' => 'parent', |
| 588 | 588 | 'comments' => 'comment_count', |
| 589 | - 'date' => array( 'date', true ) |
|
| 589 | + 'date' => array('date', true) |
|
| 590 | 590 | ); |
| 591 | 591 | } |
| 592 | 592 | |
@@ -596,18 +596,18 @@ discard block |
||
| 596 | 596 | * @param array $posts |
| 597 | 597 | * @param int $level |
| 598 | 598 | */ |
| 599 | - public function display_rows( $posts = array(), $level = 0 ) { |
|
| 599 | + public function display_rows($posts = array(), $level = 0) { |
|
| 600 | 600 | global $wp_query, $per_page; |
| 601 | 601 | |
| 602 | - if ( empty( $posts ) ) |
|
| 602 | + if (empty($posts)) |
|
| 603 | 603 | $posts = $wp_query->posts; |
| 604 | 604 | |
| 605 | - add_filter( 'the_title', 'esc_html' ); |
|
| 605 | + add_filter('the_title', 'esc_html'); |
|
| 606 | 606 | |
| 607 | - if ( $this->hierarchical_display ) { |
|
| 608 | - $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); |
|
| 607 | + if ($this->hierarchical_display) { |
|
| 608 | + $this->_display_rows_hierarchical($posts, $this->get_pagenum(), $per_page); |
|
| 609 | 609 | } else { |
| 610 | - $this->_display_rows( $posts, $level ); |
|
| 610 | + $this->_display_rows($posts, $level); |
|
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | |
@@ -615,17 +615,17 @@ discard block |
||
| 615 | 615 | * @param array $posts |
| 616 | 616 | * @param int $level |
| 617 | 617 | */ |
| 618 | - private function _display_rows( $posts, $level = 0 ) { |
|
| 618 | + private function _display_rows($posts, $level = 0) { |
|
| 619 | 619 | // Create array of post IDs. |
| 620 | 620 | $post_ids = array(); |
| 621 | 621 | |
| 622 | - foreach ( $posts as $a_post ) |
|
| 622 | + foreach ($posts as $a_post) |
|
| 623 | 623 | $post_ids[] = $a_post->ID; |
| 624 | 624 | |
| 625 | - $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
|
| 625 | + $this->comment_pending_count = get_pending_comments_num($post_ids); |
|
| 626 | 626 | |
| 627 | - foreach ( $posts as $post ) |
|
| 628 | - $this->single_row( $post, $level ); |
|
| 627 | + foreach ($posts as $post) |
|
| 628 | + $this->single_row($post, $level); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
@@ -635,15 +635,15 @@ discard block |
||
| 635 | 635 | * @param int $pagenum |
| 636 | 636 | * @param int $per_page |
| 637 | 637 | */ |
| 638 | - private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
|
| 638 | + private function _display_rows_hierarchical($pages, $pagenum = 1, $per_page = 20) { |
|
| 639 | 639 | global $wpdb; |
| 640 | 640 | |
| 641 | 641 | $level = 0; |
| 642 | 642 | |
| 643 | - if ( ! $pages ) { |
|
| 644 | - $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
|
| 643 | + if ( ! $pages) { |
|
| 644 | + $pages = get_pages(array('sort_column' => 'menu_order')); |
|
| 645 | 645 | |
| 646 | - if ( ! $pages ) |
|
| 646 | + if ( ! $pages) |
|
| 647 | 647 | return; |
| 648 | 648 | } |
| 649 | 649 | |
@@ -654,56 +654,56 @@ discard block |
||
| 654 | 654 | * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations |
| 655 | 655 | * If searching, ignore hierarchy and treat everything as top level |
| 656 | 656 | */ |
| 657 | - if ( empty( $_REQUEST['s'] ) ) { |
|
| 657 | + if (empty($_REQUEST['s'])) { |
|
| 658 | 658 | |
| 659 | 659 | $top_level_pages = array(); |
| 660 | 660 | $children_pages = array(); |
| 661 | 661 | |
| 662 | - foreach ( $pages as $page ) { |
|
| 662 | + foreach ($pages as $page) { |
|
| 663 | 663 | |
| 664 | 664 | // Catch and repair bad pages. |
| 665 | - if ( $page->post_parent == $page->ID ) { |
|
| 665 | + if ($page->post_parent == $page->ID) { |
|
| 666 | 666 | $page->post_parent = 0; |
| 667 | - $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); |
|
| 668 | - clean_post_cache( $page ); |
|
| 667 | + $wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID)); |
|
| 668 | + clean_post_cache($page); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - if ( 0 == $page->post_parent ) |
|
| 671 | + if (0 == $page->post_parent) |
|
| 672 | 672 | $top_level_pages[] = $page; |
| 673 | 673 | else |
| 674 | - $children_pages[ $page->post_parent ][] = $page; |
|
| 674 | + $children_pages[$page->post_parent][] = $page; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | $pages = &$top_level_pages; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | $count = 0; |
| 681 | - $start = ( $pagenum - 1 ) * $per_page; |
|
| 681 | + $start = ($pagenum - 1) * $per_page; |
|
| 682 | 682 | $end = $start + $per_page; |
| 683 | 683 | $to_display = array(); |
| 684 | 684 | |
| 685 | - foreach ( $pages as $page ) { |
|
| 686 | - if ( $count >= $end ) |
|
| 685 | + foreach ($pages as $page) { |
|
| 686 | + if ($count >= $end) |
|
| 687 | 687 | break; |
| 688 | 688 | |
| 689 | - if ( $count >= $start ) { |
|
| 689 | + if ($count >= $start) { |
|
| 690 | 690 | $to_display[$page->ID] = $level; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | $count++; |
| 694 | 694 | |
| 695 | - if ( isset( $children_pages ) ) |
|
| 696 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 695 | + if (isset($children_pages)) |
|
| 696 | + $this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | // If it is the last pagenum and there are orphaned pages, display them with paging as well. |
| 700 | - if ( isset( $children_pages ) && $count < $end ){ |
|
| 701 | - foreach ( $children_pages as $orphans ){ |
|
| 702 | - foreach ( $orphans as $op ) { |
|
| 703 | - if ( $count >= $end ) |
|
| 700 | + if (isset($children_pages) && $count < $end) { |
|
| 701 | + foreach ($children_pages as $orphans) { |
|
| 702 | + foreach ($orphans as $op) { |
|
| 703 | + if ($count >= $end) |
|
| 704 | 704 | break; |
| 705 | 705 | |
| 706 | - if ( $count >= $start ) { |
|
| 706 | + if ($count >= $start) { |
|
| 707 | 707 | $to_display[$op->ID] = 0; |
| 708 | 708 | } |
| 709 | 709 | |
@@ -712,16 +712,16 @@ discard block |
||
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | - $ids = array_keys( $to_display ); |
|
| 716 | - _prime_post_caches( $ids ); |
|
| 715 | + $ids = array_keys($to_display); |
|
| 716 | + _prime_post_caches($ids); |
|
| 717 | 717 | |
| 718 | - if ( ! isset( $GLOBALS['post'] ) ) { |
|
| 719 | - $GLOBALS['post'] = reset( $ids ); |
|
| 718 | + if ( ! isset($GLOBALS['post'])) { |
|
| 719 | + $GLOBALS['post'] = reset($ids); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - foreach ( $to_display as $page_id => $level ) { |
|
| 722 | + foreach ($to_display as $page_id => $level) { |
|
| 723 | 723 | echo "\t"; |
| 724 | - $this->single_row( $page_id, $level ); |
|
| 724 | + $this->single_row($page_id, $level); |
|
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | |
@@ -740,51 +740,51 @@ discard block |
||
| 740 | 740 | * @param int $per_page |
| 741 | 741 | * @param array $to_display List of pages to be displayed. Passed by reference. |
| 742 | 742 | */ |
| 743 | - private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { |
|
| 744 | - if ( ! isset( $children_pages[$parent] ) ) |
|
| 743 | + private function _page_rows(&$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display) { |
|
| 744 | + if ( ! isset($children_pages[$parent])) |
|
| 745 | 745 | return; |
| 746 | 746 | |
| 747 | - $start = ( $pagenum - 1 ) * $per_page; |
|
| 747 | + $start = ($pagenum - 1) * $per_page; |
|
| 748 | 748 | $end = $start + $per_page; |
| 749 | 749 | |
| 750 | - foreach ( $children_pages[$parent] as $page ) { |
|
| 751 | - if ( $count >= $end ) |
|
| 750 | + foreach ($children_pages[$parent] as $page) { |
|
| 751 | + if ($count >= $end) |
|
| 752 | 752 | break; |
| 753 | 753 | |
| 754 | 754 | // If the page starts in a subtree, print the parents. |
| 755 | - if ( $count == $start && $page->post_parent > 0 ) { |
|
| 755 | + if ($count == $start && $page->post_parent > 0) { |
|
| 756 | 756 | $my_parents = array(); |
| 757 | 757 | $my_parent = $page->post_parent; |
| 758 | - while ( $my_parent ) { |
|
| 758 | + while ($my_parent) { |
|
| 759 | 759 | // Get the ID from the list or the attribute if my_parent is an object |
| 760 | 760 | $parent_id = $my_parent; |
| 761 | - if ( is_object( $my_parent ) ) { |
|
| 761 | + if (is_object($my_parent)) { |
|
| 762 | 762 | $parent_id = $my_parent->ID; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - $my_parent = get_post( $parent_id ); |
|
| 765 | + $my_parent = get_post($parent_id); |
|
| 766 | 766 | $my_parents[] = $my_parent; |
| 767 | - if ( !$my_parent->post_parent ) |
|
| 767 | + if ( ! $my_parent->post_parent) |
|
| 768 | 768 | break; |
| 769 | 769 | $my_parent = $my_parent->post_parent; |
| 770 | 770 | } |
| 771 | - $num_parents = count( $my_parents ); |
|
| 772 | - while ( $my_parent = array_pop( $my_parents ) ) { |
|
| 771 | + $num_parents = count($my_parents); |
|
| 772 | + while ($my_parent = array_pop($my_parents)) { |
|
| 773 | 773 | $to_display[$my_parent->ID] = $level - $num_parents; |
| 774 | 774 | $num_parents--; |
| 775 | 775 | } |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | - if ( $count >= $start ) { |
|
| 778 | + if ($count >= $start) { |
|
| 779 | 779 | $to_display[$page->ID] = $level; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | $count++; |
| 783 | 783 | |
| 784 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 784 | + $this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display); |
|
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - unset( $children_pages[$parent] ); //required in order to keep track of orphans |
|
| 787 | + unset($children_pages[$parent]); //required in order to keep track of orphans |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -795,10 +795,10 @@ discard block |
||
| 795 | 795 | * |
| 796 | 796 | * @param WP_Post $post The current WP_Post object. |
| 797 | 797 | */ |
| 798 | - public function column_cb( $post ) { |
|
| 799 | - if ( current_user_can( 'edit_post', $post->ID ) ): ?> |
|
| 798 | + public function column_cb($post) { |
|
| 799 | + if (current_user_can('edit_post', $post->ID)): ?> |
|
| 800 | 800 | <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php |
| 801 | - printf( __( 'Select %s' ), _draft_or_post_title() ); |
|
| 801 | + printf(__('Select %s'), _draft_or_post_title()); |
|
| 802 | 802 | ?></label> |
| 803 | 803 | <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
| 804 | 804 | <div class="locked-indicator"></div> |
@@ -814,10 +814,10 @@ discard block |
||
| 814 | 814 | * @param string $data |
| 815 | 815 | * @param string $primary |
| 816 | 816 | */ |
| 817 | - protected function _column_title( $post, $classes, $data, $primary ) { |
|
| 818 | - echo '<td class="' . $classes . ' page-title" ', $data, '>'; |
|
| 819 | - echo $this->column_title( $post ); |
|
| 820 | - echo $this->handle_row_actions( $post, 'title', $primary ); |
|
| 817 | + protected function _column_title($post, $classes, $data, $primary) { |
|
| 818 | + echo '<td class="'.$classes.' page-title" ', $data, '>'; |
|
| 819 | + echo $this->column_title($post); |
|
| 820 | + echo $this->handle_row_actions($post, 'title', $primary); |
|
| 821 | 821 | echo '</td>'; |
| 822 | 822 | } |
| 823 | 823 | |
@@ -831,90 +831,90 @@ discard block |
||
| 831 | 831 | * |
| 832 | 832 | * @param WP_Post $post The current WP_Post object. |
| 833 | 833 | */ |
| 834 | - public function column_title( $post ) { |
|
| 834 | + public function column_title($post) { |
|
| 835 | 835 | global $mode; |
| 836 | 836 | |
| 837 | - if ( $this->hierarchical_display ) { |
|
| 838 | - if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { |
|
| 837 | + if ($this->hierarchical_display) { |
|
| 838 | + if (0 === $this->current_level && (int) $post->post_parent > 0) { |
|
| 839 | 839 | // Sent level 0 by accident, by default, or because we don't know the actual level. |
| 840 | 840 | $find_main_page = (int) $post->post_parent; |
| 841 | - while ( $find_main_page > 0 ) { |
|
| 842 | - $parent = get_post( $find_main_page ); |
|
| 841 | + while ($find_main_page > 0) { |
|
| 842 | + $parent = get_post($find_main_page); |
|
| 843 | 843 | |
| 844 | - if ( is_null( $parent ) ) { |
|
| 844 | + if (is_null($parent)) { |
|
| 845 | 845 | break; |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | $this->current_level++; |
| 849 | 849 | $find_main_page = (int) $parent->post_parent; |
| 850 | 850 | |
| 851 | - if ( ! isset( $parent_name ) ) { |
|
| 851 | + if ( ! isset($parent_name)) { |
|
| 852 | 852 | /** This filter is documented in wp-includes/post-template.php */ |
| 853 | - $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
|
| 853 | + $parent_name = apply_filters('the_title', $parent->post_title, $parent->ID); |
|
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - $pad = str_repeat( '— ', $this->current_level ); |
|
| 859 | + $pad = str_repeat('— ', $this->current_level); |
|
| 860 | 860 | echo "<strong>"; |
| 861 | 861 | |
| 862 | - $format = get_post_format( $post->ID ); |
|
| 863 | - if ( $format ) { |
|
| 864 | - $label = get_post_format_string( $format ); |
|
| 862 | + $format = get_post_format($post->ID); |
|
| 863 | + if ($format) { |
|
| 864 | + $label = get_post_format_string($format); |
|
| 865 | 865 | |
| 866 | - $format_class = 'post-state-format post-format-icon post-format-' . $format; |
|
| 866 | + $format_class = 'post-state-format post-format-icon post-format-'.$format; |
|
| 867 | 867 | |
| 868 | 868 | $format_args = array( |
| 869 | 869 | 'post_format' => $format, |
| 870 | 870 | 'post_type' => $post->post_type |
| 871 | 871 | ); |
| 872 | 872 | |
| 873 | - echo $this->get_edit_link( $format_args, $label . ':', $format_class ); |
|
| 873 | + echo $this->get_edit_link($format_args, $label.':', $format_class); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
| 876 | + $can_edit_post = current_user_can('edit_post', $post->ID); |
|
| 877 | 877 | $title = _draft_or_post_title(); |
| 878 | 878 | |
| 879 | - if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
| 879 | + if ($can_edit_post && $post->post_status != 'trash') { |
|
| 880 | 880 | printf( |
| 881 | 881 | '<a class="row-title" href="%s" aria-label="%s">%s%s</a>', |
| 882 | - get_edit_post_link( $post->ID ), |
|
| 882 | + get_edit_post_link($post->ID), |
|
| 883 | 883 | /* translators: %s: post title */ |
| 884 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ), |
|
| 884 | + esc_attr(sprintf(__('“%s” (Edit)'), $title)), |
|
| 885 | 885 | $pad, |
| 886 | 886 | $title |
| 887 | 887 | ); |
| 888 | 888 | } else { |
| 889 | - echo $pad . $title; |
|
| 889 | + echo $pad.$title; |
|
| 890 | 890 | } |
| 891 | - _post_states( $post ); |
|
| 891 | + _post_states($post); |
|
| 892 | 892 | |
| 893 | - if ( isset( $parent_name ) ) { |
|
| 894 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 895 | - echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
|
| 893 | + if (isset($parent_name)) { |
|
| 894 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 895 | + echo ' | '.$post_type_object->labels->parent_item_colon.' '.esc_html($parent_name); |
|
| 896 | 896 | } |
| 897 | 897 | echo "</strong>\n"; |
| 898 | 898 | |
| 899 | - if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
| 900 | - $lock_holder = wp_check_post_lock( $post->ID ); |
|
| 899 | + if ($can_edit_post && $post->post_status != 'trash') { |
|
| 900 | + $lock_holder = wp_check_post_lock($post->ID); |
|
| 901 | 901 | |
| 902 | - if ( $lock_holder ) { |
|
| 903 | - $lock_holder = get_userdata( $lock_holder ); |
|
| 904 | - $locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
|
| 905 | - $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
|
| 902 | + if ($lock_holder) { |
|
| 903 | + $lock_holder = get_userdata($lock_holder); |
|
| 904 | + $locked_avatar = get_avatar($lock_holder->ID, 18); |
|
| 905 | + $locked_text = esc_html(sprintf(__('%s is currently editing'), $lock_holder->display_name)); |
|
| 906 | 906 | } else { |
| 907 | 907 | $locked_avatar = $locked_text = ''; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; |
|
| 910 | + echo '<div class="locked-info"><span class="locked-avatar">'.$locked_avatar.'</span> <span class="locked-text">'.$locked_text."</span></div>\n"; |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | - if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) { |
|
| 913 | + if ( ! is_post_type_hierarchical($this->screen->post_type) && 'excerpt' === $mode && current_user_can('read_post', $post->ID)) { |
|
| 914 | 914 | the_excerpt(); |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | - get_inline_data( $post ); |
|
| 917 | + get_inline_data($post); |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | /** |
@@ -927,39 +927,39 @@ discard block |
||
| 927 | 927 | * |
| 928 | 928 | * @param WP_Post $post The current WP_Post object. |
| 929 | 929 | */ |
| 930 | - public function column_date( $post ) { |
|
| 930 | + public function column_date($post) { |
|
| 931 | 931 | global $mode; |
| 932 | 932 | |
| 933 | - if ( '0000-00-00 00:00:00' === $post->post_date ) { |
|
| 934 | - $t_time = $h_time = __( 'Unpublished' ); |
|
| 933 | + if ('0000-00-00 00:00:00' === $post->post_date) { |
|
| 934 | + $t_time = $h_time = __('Unpublished'); |
|
| 935 | 935 | $time_diff = 0; |
| 936 | 936 | } else { |
| 937 | - $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
|
| 937 | + $t_time = get_the_time(__('Y/m/d g:i:s a')); |
|
| 938 | 938 | $m_time = $post->post_date; |
| 939 | - $time = get_post_time( 'G', true, $post ); |
|
| 939 | + $time = get_post_time('G', true, $post); |
|
| 940 | 940 | |
| 941 | 941 | $time_diff = time() - $time; |
| 942 | 942 | |
| 943 | - if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
|
| 944 | - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
| 943 | + if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { |
|
| 944 | + $h_time = sprintf(__('%s ago'), human_time_diff($time)); |
|
| 945 | 945 | } else { |
| 946 | - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
|
| 946 | + $h_time = mysql2date(__('Y/m/d'), $m_time); |
|
| 947 | 947 | } |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - if ( 'publish' === $post->post_status ) { |
|
| 951 | - _e( 'Published' ); |
|
| 952 | - } elseif ( 'future' === $post->post_status ) { |
|
| 953 | - if ( $time_diff > 0 ) { |
|
| 954 | - echo '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
|
| 950 | + if ('publish' === $post->post_status) { |
|
| 951 | + _e('Published'); |
|
| 952 | + } elseif ('future' === $post->post_status) { |
|
| 953 | + if ($time_diff > 0) { |
|
| 954 | + echo '<strong class="error-message">'.__('Missed schedule').'</strong>'; |
|
| 955 | 955 | } else { |
| 956 | - _e( 'Scheduled' ); |
|
| 956 | + _e('Scheduled'); |
|
| 957 | 957 | } |
| 958 | 958 | } else { |
| 959 | - _e( 'Last Modified' ); |
|
| 959 | + _e('Last Modified'); |
|
| 960 | 960 | } |
| 961 | 961 | echo '<br />'; |
| 962 | - if ( 'excerpt' === $mode ) { |
|
| 962 | + if ('excerpt' === $mode) { |
|
| 963 | 963 | /** |
| 964 | 964 | * Filter the published time of the post. |
| 965 | 965 | * |
@@ -974,11 +974,11 @@ discard block |
||
| 974 | 974 | * @param string $column_name The column name. |
| 975 | 975 | * @param string $mode The list display mode ('excerpt' or 'list'). |
| 976 | 976 | */ |
| 977 | - echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
|
| 977 | + echo apply_filters('post_date_column_time', $t_time, $post, 'date', $mode); |
|
| 978 | 978 | } else { |
| 979 | 979 | |
| 980 | 980 | /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
| 981 | - echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>'; |
|
| 981 | + echo '<abbr title="'.$t_time.'">'.apply_filters('post_date_column_time', $h_time, $post, 'date', $mode).'</abbr>'; |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | |
@@ -990,13 +990,13 @@ discard block |
||
| 990 | 990 | * |
| 991 | 991 | * @param WP_Post $post The current WP_Post object. |
| 992 | 992 | */ |
| 993 | - public function column_comments( $post ) { |
|
| 993 | + public function column_comments($post) { |
|
| 994 | 994 | ?> |
| 995 | 995 | <div class="post-com-count-wrapper"> |
| 996 | 996 | <?php |
| 997 | - $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; |
|
| 997 | + $pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0; |
|
| 998 | 998 | |
| 999 | - $this->comments_bubble( $post->ID, $pending_comments ); |
|
| 999 | + $this->comments_bubble($post->ID, $pending_comments); |
|
| 1000 | 1000 | ?> |
| 1001 | 1001 | </div> |
| 1002 | 1002 | <?php |
@@ -1010,12 +1010,12 @@ discard block |
||
| 1010 | 1010 | * |
| 1011 | 1011 | * @param WP_Post $post The current WP_Post object. |
| 1012 | 1012 | */ |
| 1013 | - public function column_author( $post ) { |
|
| 1013 | + public function column_author($post) { |
|
| 1014 | 1014 | $args = array( |
| 1015 | 1015 | 'post_type' => $post->post_type, |
| 1016 | - 'author' => get_the_author_meta( 'ID' ) |
|
| 1016 | + 'author' => get_the_author_meta('ID') |
|
| 1017 | 1017 | ); |
| 1018 | - echo $this->get_edit_link( $args, get_the_author() ); |
|
| 1018 | + echo $this->get_edit_link($args, get_the_author()); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | /** |
@@ -1027,45 +1027,45 @@ discard block |
||
| 1027 | 1027 | * @param WP_Post $post The current WP_Post object. |
| 1028 | 1028 | * @param string $column_name The current column name. |
| 1029 | 1029 | */ |
| 1030 | - public function column_default( $post, $column_name ) { |
|
| 1031 | - if ( 'categories' === $column_name ) { |
|
| 1030 | + public function column_default($post, $column_name) { |
|
| 1031 | + if ('categories' === $column_name) { |
|
| 1032 | 1032 | $taxonomy = 'category'; |
| 1033 | - } elseif ( 'tags' === $column_name ) { |
|
| 1033 | + } elseif ('tags' === $column_name) { |
|
| 1034 | 1034 | $taxonomy = 'post_tag'; |
| 1035 | - } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
|
| 1036 | - $taxonomy = substr( $column_name, 9 ); |
|
| 1035 | + } elseif (0 === strpos($column_name, 'taxonomy-')) { |
|
| 1036 | + $taxonomy = substr($column_name, 9); |
|
| 1037 | 1037 | } else { |
| 1038 | 1038 | $taxonomy = false; |
| 1039 | 1039 | } |
| 1040 | - if ( $taxonomy ) { |
|
| 1041 | - $taxonomy_object = get_taxonomy( $taxonomy ); |
|
| 1042 | - $terms = get_the_terms( $post->ID, $taxonomy ); |
|
| 1043 | - if ( is_array( $terms ) ) { |
|
| 1040 | + if ($taxonomy) { |
|
| 1041 | + $taxonomy_object = get_taxonomy($taxonomy); |
|
| 1042 | + $terms = get_the_terms($post->ID, $taxonomy); |
|
| 1043 | + if (is_array($terms)) { |
|
| 1044 | 1044 | $out = array(); |
| 1045 | - foreach ( $terms as $t ) { |
|
| 1045 | + foreach ($terms as $t) { |
|
| 1046 | 1046 | $posts_in_term_qv = array(); |
| 1047 | - if ( 'post' != $post->post_type ) { |
|
| 1047 | + if ('post' != $post->post_type) { |
|
| 1048 | 1048 | $posts_in_term_qv['post_type'] = $post->post_type; |
| 1049 | 1049 | } |
| 1050 | - if ( $taxonomy_object->query_var ) { |
|
| 1051 | - $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
|
| 1050 | + if ($taxonomy_object->query_var) { |
|
| 1051 | + $posts_in_term_qv[$taxonomy_object->query_var] = $t->slug; |
|
| 1052 | 1052 | } else { |
| 1053 | 1053 | $posts_in_term_qv['taxonomy'] = $taxonomy; |
| 1054 | 1054 | $posts_in_term_qv['term'] = $t->slug; |
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - $label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); |
|
| 1058 | - $out[] = $this->get_edit_link( $posts_in_term_qv, $label ); |
|
| 1057 | + $label = esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')); |
|
| 1058 | + $out[] = $this->get_edit_link($posts_in_term_qv, $label); |
|
| 1059 | 1059 | } |
| 1060 | 1060 | /* translators: used between list items, there is a space after the comma */ |
| 1061 | - echo join( __( ', ' ), $out ); |
|
| 1061 | + echo join(__(', '), $out); |
|
| 1062 | 1062 | } else { |
| 1063 | - echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
|
| 1063 | + echo '<span aria-hidden="true">—</span><span class="screen-reader-text">'.$taxonomy_object->labels->no_terms.'</span>'; |
|
| 1064 | 1064 | } |
| 1065 | 1065 | return; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
| 1068 | + if (is_post_type_hierarchical($post->post_type)) { |
|
| 1069 | 1069 | |
| 1070 | 1070 | /** |
| 1071 | 1071 | * Fires in each custom column on the Posts list table. |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | * @param string $column_name The name of the column to display. |
| 1079 | 1079 | * @param int $post_id The current post ID. |
| 1080 | 1080 | */ |
| 1081 | - do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
|
| 1081 | + do_action('manage_pages_custom_column', $column_name, $post->ID); |
|
| 1082 | 1082 | } else { |
| 1083 | 1083 | |
| 1084 | 1084 | /** |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | * @param string $column_name The name of the column to display. |
| 1093 | 1093 | * @param int $post_id The current post ID. |
| 1094 | 1094 | */ |
| 1095 | - do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
|
| 1095 | + do_action('manage_posts_custom_column', $column_name, $post->ID); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | 1098 | /** |
@@ -1105,7 +1105,7 @@ discard block |
||
| 1105 | 1105 | * @param string $column_name The name of the column to display. |
| 1106 | 1106 | * @param int $post_id The current post ID. |
| 1107 | 1107 | */ |
| 1108 | - do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
|
| 1108 | + do_action("manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID); |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | /** |
@@ -1114,31 +1114,31 @@ discard block |
||
| 1114 | 1114 | * @param int|WP_Post $post |
| 1115 | 1115 | * @param int $level |
| 1116 | 1116 | */ |
| 1117 | - public function single_row( $post, $level = 0 ) { |
|
| 1117 | + public function single_row($post, $level = 0) { |
|
| 1118 | 1118 | $global_post = get_post(); |
| 1119 | 1119 | |
| 1120 | - $post = get_post( $post ); |
|
| 1120 | + $post = get_post($post); |
|
| 1121 | 1121 | $this->current_level = $level; |
| 1122 | 1122 | |
| 1123 | 1123 | $GLOBALS['post'] = $post; |
| 1124 | - setup_postdata( $post ); |
|
| 1124 | + setup_postdata($post); |
|
| 1125 | 1125 | |
| 1126 | - $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); |
|
| 1126 | + $classes = 'iedit author-'.(get_current_user_id() == $post->post_author ? 'self' : 'other'); |
|
| 1127 | 1127 | |
| 1128 | - $lock_holder = wp_check_post_lock( $post->ID ); |
|
| 1129 | - if ( $lock_holder ) { |
|
| 1128 | + $lock_holder = wp_check_post_lock($post->ID); |
|
| 1129 | + if ($lock_holder) { |
|
| 1130 | 1130 | $classes .= ' wp-locked'; |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - if ( $post->post_parent ) { |
|
| 1134 | - $count = count( get_post_ancestors( $post->ID ) ); |
|
| 1135 | - $classes .= ' level-'. $count; |
|
| 1133 | + if ($post->post_parent) { |
|
| 1134 | + $count = count(get_post_ancestors($post->ID)); |
|
| 1135 | + $classes .= ' level-'.$count; |
|
| 1136 | 1136 | } else { |
| 1137 | 1137 | $classes .= ' level-0'; |
| 1138 | 1138 | } |
| 1139 | 1139 | ?> |
| 1140 | - <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
|
| 1141 | - <?php $this->single_row_columns( $post ); ?> |
|
| 1140 | + <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode(' ', get_post_class($classes, $post->ID)); ?>"> |
|
| 1141 | + <?php $this->single_row_columns($post); ?> |
|
| 1142 | 1142 | </tr> |
| 1143 | 1143 | <?php |
| 1144 | 1144 | $GLOBALS['post'] = $global_post; |
@@ -1167,85 +1167,85 @@ discard block |
||
| 1167 | 1167 | * @param string $primary Primary column name. |
| 1168 | 1168 | * @return string Row actions output for posts. |
| 1169 | 1169 | */ |
| 1170 | - protected function handle_row_actions( $post, $column_name, $primary ) { |
|
| 1171 | - if ( $primary !== $column_name ) { |
|
| 1170 | + protected function handle_row_actions($post, $column_name, $primary) { |
|
| 1171 | + if ($primary !== $column_name) { |
|
| 1172 | 1172 | return ''; |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1176 | - $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
| 1175 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1176 | + $can_edit_post = current_user_can('edit_post', $post->ID); |
|
| 1177 | 1177 | $actions = array(); |
| 1178 | 1178 | $title = _draft_or_post_title(); |
| 1179 | 1179 | |
| 1180 | - if ( $can_edit_post && 'trash' != $post->post_status ) { |
|
| 1180 | + if ($can_edit_post && 'trash' != $post->post_status) { |
|
| 1181 | 1181 | $actions['edit'] = sprintf( |
| 1182 | 1182 | '<a href="%s" aria-label="%s">%s</a>', |
| 1183 | - get_edit_post_link( $post->ID ), |
|
| 1183 | + get_edit_post_link($post->ID), |
|
| 1184 | 1184 | /* translators: %s: post title */ |
| 1185 | - esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), |
|
| 1186 | - __( 'Edit' ) |
|
| 1185 | + esc_attr(sprintf(__('Edit “%s”'), $title)), |
|
| 1186 | + __('Edit') |
|
| 1187 | 1187 | ); |
| 1188 | 1188 | $actions['inline hide-if-no-js'] = sprintf( |
| 1189 | 1189 | '<a href="#" class="editinline" aria-label="%s">%s</a>', |
| 1190 | 1190 | /* translators: %s: post title */ |
| 1191 | - esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), |
|
| 1192 | - __( 'Quick Edit' ) |
|
| 1191 | + esc_attr(sprintf(__('Quick edit “%s” inline'), $title)), |
|
| 1192 | + __('Quick Edit') |
|
| 1193 | 1193 | ); |
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | - if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
| 1197 | - if ( 'trash' === $post->post_status ) { |
|
| 1196 | + if (current_user_can('delete_post', $post->ID)) { |
|
| 1197 | + if ('trash' === $post->post_status) { |
|
| 1198 | 1198 | $actions['untrash'] = sprintf( |
| 1199 | 1199 | '<a href="%s" aria-label="%s">%s</a>', |
| 1200 | - wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), |
|
| 1200 | + wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link.'&action=untrash', $post->ID)), 'untrash-post_'.$post->ID), |
|
| 1201 | 1201 | /* translators: %s: post title */ |
| 1202 | - esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), |
|
| 1203 | - __( 'Restore' ) |
|
| 1202 | + esc_attr(sprintf(__('Restore “%s” from the Trash'), $title)), |
|
| 1203 | + __('Restore') |
|
| 1204 | 1204 | ); |
| 1205 | - } elseif ( EMPTY_TRASH_DAYS ) { |
|
| 1205 | + } elseif (EMPTY_TRASH_DAYS) { |
|
| 1206 | 1206 | $actions['trash'] = sprintf( |
| 1207 | 1207 | '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
| 1208 | - get_delete_post_link( $post->ID ), |
|
| 1208 | + get_delete_post_link($post->ID), |
|
| 1209 | 1209 | /* translators: %s: post title */ |
| 1210 | - esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), |
|
| 1211 | - _x( 'Trash', 'verb' ) |
|
| 1210 | + esc_attr(sprintf(__('Move “%s” to the Trash'), $title)), |
|
| 1211 | + _x('Trash', 'verb') |
|
| 1212 | 1212 | ); |
| 1213 | 1213 | } |
| 1214 | - if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { |
|
| 1214 | + if ('trash' === $post->post_status || ! EMPTY_TRASH_DAYS) { |
|
| 1215 | 1215 | $actions['delete'] = sprintf( |
| 1216 | 1216 | '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
| 1217 | - get_delete_post_link( $post->ID, '', true ), |
|
| 1217 | + get_delete_post_link($post->ID, '', true), |
|
| 1218 | 1218 | /* translators: %s: post title */ |
| 1219 | - esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), |
|
| 1220 | - __( 'Delete Permanently' ) |
|
| 1219 | + esc_attr(sprintf(__('Delete “%s” permanently'), $title)), |
|
| 1220 | + __('Delete Permanently') |
|
| 1221 | 1221 | ); |
| 1222 | 1222 | } |
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | - if ( is_post_type_viewable( $post_type_object ) ) { |
|
| 1226 | - if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { |
|
| 1227 | - if ( $can_edit_post ) { |
|
| 1228 | - $preview_link = get_preview_post_link( $post ); |
|
| 1225 | + if (is_post_type_viewable($post_type_object)) { |
|
| 1226 | + if (in_array($post->post_status, array('pending', 'draft', 'future'))) { |
|
| 1227 | + if ($can_edit_post) { |
|
| 1228 | + $preview_link = get_preview_post_link($post); |
|
| 1229 | 1229 | $actions['view'] = sprintf( |
| 1230 | 1230 | '<a href="%s" rel="permalink" aria-label="%s">%s</a>', |
| 1231 | - esc_url( $preview_link ), |
|
| 1231 | + esc_url($preview_link), |
|
| 1232 | 1232 | /* translators: %s: post title */ |
| 1233 | - esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), |
|
| 1234 | - __( 'Preview' ) |
|
| 1233 | + esc_attr(sprintf(__('Preview “%s”'), $title)), |
|
| 1234 | + __('Preview') |
|
| 1235 | 1235 | ); |
| 1236 | 1236 | } |
| 1237 | - } elseif ( 'trash' != $post->post_status ) { |
|
| 1237 | + } elseif ('trash' != $post->post_status) { |
|
| 1238 | 1238 | $actions['view'] = sprintf( |
| 1239 | 1239 | '<a href="%s" rel="permalink" aria-label="%s">%s</a>', |
| 1240 | - get_permalink( $post->ID ), |
|
| 1240 | + get_permalink($post->ID), |
|
| 1241 | 1241 | /* translators: %s: post title */ |
| 1242 | - esc_attr( sprintf( __( 'View “%s”' ), $title ) ), |
|
| 1243 | - __( 'View' ) |
|
| 1242 | + esc_attr(sprintf(__('View “%s”'), $title)), |
|
| 1243 | + __('View') |
|
| 1244 | 1244 | ); |
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | - if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
| 1248 | + if (is_post_type_hierarchical($post->post_type)) { |
|
| 1249 | 1249 | |
| 1250 | 1250 | /** |
| 1251 | 1251 | * Filter the array of row action links on the Pages list table. |
@@ -1259,7 +1259,7 @@ discard block |
||
| 1259 | 1259 | * 'Delete Permanently', 'Preview', and 'View'. |
| 1260 | 1260 | * @param WP_Post $post The post object. |
| 1261 | 1261 | */ |
| 1262 | - $actions = apply_filters( 'page_row_actions', $actions, $post ); |
|
| 1262 | + $actions = apply_filters('page_row_actions', $actions, $post); |
|
| 1263 | 1263 | } else { |
| 1264 | 1264 | |
| 1265 | 1265 | /** |
@@ -1274,10 +1274,10 @@ discard block |
||
| 1274 | 1274 | * 'Delete Permanently', 'Preview', and 'View'. |
| 1275 | 1275 | * @param WP_Post $post The post object. |
| 1276 | 1276 | */ |
| 1277 | - $actions = apply_filters( 'post_row_actions', $actions, $post ); |
|
| 1277 | + $actions = apply_filters('post_row_actions', $actions, $post); |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | - return $this->row_actions( $actions ); |
|
| 1280 | + return $this->row_actions($actions); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | 1283 | /** |
@@ -1292,15 +1292,15 @@ discard block |
||
| 1292 | 1292 | |
| 1293 | 1293 | $screen = $this->screen; |
| 1294 | 1294 | |
| 1295 | - $post = get_default_post_to_edit( $screen->post_type ); |
|
| 1296 | - $post_type_object = get_post_type_object( $screen->post_type ); |
|
| 1295 | + $post = get_default_post_to_edit($screen->post_type); |
|
| 1296 | + $post_type_object = get_post_type_object($screen->post_type); |
|
| 1297 | 1297 | |
| 1298 | - $taxonomy_names = get_object_taxonomies( $screen->post_type ); |
|
| 1298 | + $taxonomy_names = get_object_taxonomies($screen->post_type); |
|
| 1299 | 1299 | $hierarchical_taxonomies = array(); |
| 1300 | 1300 | $flat_taxonomies = array(); |
| 1301 | - foreach ( $taxonomy_names as $taxonomy_name ) { |
|
| 1301 | + foreach ($taxonomy_names as $taxonomy_name) { |
|
| 1302 | 1302 | |
| 1303 | - $taxonomy = get_taxonomy( $taxonomy_name ); |
|
| 1303 | + $taxonomy = get_taxonomy($taxonomy_name); |
|
| 1304 | 1304 | |
| 1305 | 1305 | $show_in_quick_edit = $taxonomy->show_in_quick_edit; |
| 1306 | 1306 | |
@@ -1313,39 +1313,39 @@ discard block |
||
| 1313 | 1313 | * @param string $taxonomy_name Taxonomy name. |
| 1314 | 1314 | * @param string $post_type Post type of current Quick Edit post. |
| 1315 | 1315 | */ |
| 1316 | - if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { |
|
| 1316 | + if ( ! apply_filters('quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type)) { |
|
| 1317 | 1317 | continue; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - if ( $taxonomy->hierarchical ) |
|
| 1320 | + if ($taxonomy->hierarchical) |
|
| 1321 | 1321 | $hierarchical_taxonomies[] = $taxonomy; |
| 1322 | 1322 | else |
| 1323 | 1323 | $flat_taxonomies[] = $taxonomy; |
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | - $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; |
|
| 1327 | - $can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
|
| 1328 | - $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); |
|
| 1326 | + $m = (isset($mode) && 'excerpt' === $mode) ? 'excerpt' : 'list'; |
|
| 1327 | + $can_publish = current_user_can($post_type_object->cap->publish_posts); |
|
| 1328 | + $core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true); |
|
| 1329 | 1329 | |
| 1330 | 1330 | ?> |
| 1331 | 1331 | |
| 1332 | 1332 | <form method="get"><table style="display: none"><tbody id="inlineedit"> |
| 1333 | 1333 | <?php |
| 1334 | - $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
|
| 1334 | + $hclass = count($hierarchical_taxonomies) ? 'post' : 'page'; |
|
| 1335 | 1335 | $bulk = 0; |
| 1336 | - while ( $bulk < 2 ) { ?> |
|
| 1336 | + while ($bulk < 2) { ?> |
|
| 1337 | 1337 | |
| 1338 | - <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type; |
|
| 1338 | + <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-".$screen->post_type; |
|
| 1339 | 1339 | 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}"; |
| 1340 | 1340 | ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
| 1341 | 1341 | |
| 1342 | 1342 | <fieldset class="inline-edit-col-left"> |
| 1343 | - <legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> |
|
| 1343 | + <legend class="inline-edit-legend"><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?></legend> |
|
| 1344 | 1344 | <div class="inline-edit-col"> |
| 1345 | 1345 | <?php |
| 1346 | 1346 | |
| 1347 | - if ( post_type_supports( $screen->post_type, 'title' ) ) : |
|
| 1348 | - if ( $bulk ) : ?> |
|
| 1347 | + if (post_type_supports($screen->post_type, 'title')) : |
|
| 1348 | + if ($bulk) : ?> |
|
| 1349 | 1349 | <div id="bulk-title-div"> |
| 1350 | 1350 | <div id="bulk-titles"></div> |
| 1351 | 1351 | </div> |
@@ -1353,30 +1353,30 @@ discard block |
||
| 1353 | 1353 | <?php else : // $bulk ?> |
| 1354 | 1354 | |
| 1355 | 1355 | <label> |
| 1356 | - <span class="title"><?php _e( 'Title' ); ?></span> |
|
| 1356 | + <span class="title"><?php _e('Title'); ?></span> |
|
| 1357 | 1357 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
| 1358 | 1358 | </label> |
| 1359 | 1359 | |
| 1360 | 1360 | <label> |
| 1361 | - <span class="title"><?php _e( 'Slug' ); ?></span> |
|
| 1361 | + <span class="title"><?php _e('Slug'); ?></span> |
|
| 1362 | 1362 | <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> |
| 1363 | 1363 | </label> |
| 1364 | 1364 | |
| 1365 | 1365 | <?php endif; // $bulk |
| 1366 | 1366 | endif; // post_type_supports title ?> |
| 1367 | 1367 | |
| 1368 | - <?php if ( !$bulk ) : ?> |
|
| 1368 | + <?php if ( ! $bulk) : ?> |
|
| 1369 | 1369 | <fieldset class="inline-edit-date"> |
| 1370 | - <legend><span class="title"><?php _e( 'Date' ); ?></span></legend> |
|
| 1371 | - <?php touch_time( 1, 1, 0, 1 ); ?> |
|
| 1370 | + <legend><span class="title"><?php _e('Date'); ?></span></legend> |
|
| 1371 | + <?php touch_time(1, 1, 0, 1); ?> |
|
| 1372 | 1372 | </fieldset> |
| 1373 | 1373 | <br class="clear" /> |
| 1374 | 1374 | <?php endif; // $bulk |
| 1375 | 1375 | |
| 1376 | - if ( post_type_supports( $screen->post_type, 'author' ) ) : |
|
| 1376 | + if (post_type_supports($screen->post_type, 'author')) : |
|
| 1377 | 1377 | $authors_dropdown = ''; |
| 1378 | 1378 | |
| 1379 | - if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) : |
|
| 1379 | + if (is_super_admin() || current_user_can($post_type_object->cap->edit_others_posts)) : |
|
| 1380 | 1380 | $users_opt = array( |
| 1381 | 1381 | 'hide_if_only_one_author' => false, |
| 1382 | 1382 | 'who' => 'authors', |
@@ -1386,39 +1386,39 @@ discard block |
||
| 1386 | 1386 | 'echo' => 0, |
| 1387 | 1387 | 'show' => 'display_name_with_login', |
| 1388 | 1388 | ); |
| 1389 | - if ( $bulk ) |
|
| 1390 | - $users_opt['show_option_none'] = __( '— No Change —' ); |
|
| 1389 | + if ($bulk) |
|
| 1390 | + $users_opt['show_option_none'] = __('— No Change —'); |
|
| 1391 | 1391 | |
| 1392 | - if ( $authors = wp_dropdown_users( $users_opt ) ) : |
|
| 1392 | + if ($authors = wp_dropdown_users($users_opt)) : |
|
| 1393 | 1393 | $authors_dropdown = '<label class="inline-edit-author">'; |
| 1394 | - $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
|
| 1394 | + $authors_dropdown .= '<span class="title">'.__('Author').'</span>'; |
|
| 1395 | 1395 | $authors_dropdown .= $authors; |
| 1396 | 1396 | $authors_dropdown .= '</label>'; |
| 1397 | 1397 | endif; |
| 1398 | 1398 | endif; // authors |
| 1399 | 1399 | ?> |
| 1400 | 1400 | |
| 1401 | - <?php if ( !$bulk ) echo $authors_dropdown; |
|
| 1401 | + <?php if ( ! $bulk) echo $authors_dropdown; |
|
| 1402 | 1402 | endif; // post_type_supports author |
| 1403 | 1403 | |
| 1404 | - if ( !$bulk && $can_publish ) : |
|
| 1404 | + if ( ! $bulk && $can_publish) : |
|
| 1405 | 1405 | ?> |
| 1406 | 1406 | |
| 1407 | 1407 | <div class="inline-edit-group wp-clearfix"> |
| 1408 | 1408 | <label class="alignleft"> |
| 1409 | - <span class="title"><?php _e( 'Password' ); ?></span> |
|
| 1409 | + <span class="title"><?php _e('Password'); ?></span> |
|
| 1410 | 1410 | <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
| 1411 | 1411 | </label> |
| 1412 | 1412 | |
| 1413 | 1413 | <em class="alignleft inline-edit-or"> |
| 1414 | 1414 | <?php |
| 1415 | 1415 | /* translators: Between password field and private checkbox on post quick edit interface */ |
| 1416 | - _e( '–OR–' ); |
|
| 1416 | + _e('–OR–'); |
|
| 1417 | 1417 | ?> |
| 1418 | 1418 | </em> |
| 1419 | 1419 | <label class="alignleft inline-edit-private"> |
| 1420 | 1420 | <input type="checkbox" name="keep_private" value="private" /> |
| 1421 | - <span class="checkbox-title"><?php _e( 'Private' ); ?></span> |
|
| 1421 | + <span class="checkbox-title"><?php _e('Private'); ?></span> |
|
| 1422 | 1422 | </label> |
| 1423 | 1423 | </div> |
| 1424 | 1424 | |
@@ -1426,16 +1426,16 @@ discard block |
||
| 1426 | 1426 | |
| 1427 | 1427 | </div></fieldset> |
| 1428 | 1428 | |
| 1429 | - <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?> |
|
| 1429 | + <?php if (count($hierarchical_taxonomies) && ! $bulk) : ?> |
|
| 1430 | 1430 | |
| 1431 | 1431 | <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> |
| 1432 | 1432 | |
| 1433 | - <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
|
| 1433 | + <?php foreach ($hierarchical_taxonomies as $taxonomy) : ?> |
|
| 1434 | 1434 | |
| 1435 | - <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
|
| 1436 | - <input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
|
| 1437 | - <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist"> |
|
| 1438 | - <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?> |
|
| 1435 | + <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name) ?></span> |
|
| 1436 | + <input type="hidden" name="<?php echo ($taxonomy->name === 'category') ? 'post_category[]' : 'tax_input['.esc_attr($taxonomy->name).'][]'; ?>" value="0" /> |
|
| 1437 | + <ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist"> |
|
| 1438 | + <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?> |
|
| 1439 | 1439 | </ul> |
| 1440 | 1440 | |
| 1441 | 1441 | <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?> |
@@ -1447,27 +1447,27 @@ discard block |
||
| 1447 | 1447 | <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> |
| 1448 | 1448 | |
| 1449 | 1449 | <?php |
| 1450 | - if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) |
|
| 1450 | + if (post_type_supports($screen->post_type, 'author') && $bulk) |
|
| 1451 | 1451 | echo $authors_dropdown; |
| 1452 | 1452 | |
| 1453 | - if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : |
|
| 1453 | + if (post_type_supports($screen->post_type, 'page-attributes')) : |
|
| 1454 | 1454 | |
| 1455 | - if ( $post_type_object->hierarchical ) : |
|
| 1455 | + if ($post_type_object->hierarchical) : |
|
| 1456 | 1456 | ?> |
| 1457 | 1457 | <label> |
| 1458 | - <span class="title"><?php _e( 'Parent' ); ?></span> |
|
| 1458 | + <span class="title"><?php _e('Parent'); ?></span> |
|
| 1459 | 1459 | <?php |
| 1460 | 1460 | $dropdown_args = array( |
| 1461 | 1461 | 'post_type' => $post_type_object->name, |
| 1462 | 1462 | 'selected' => $post->post_parent, |
| 1463 | 1463 | 'name' => 'post_parent', |
| 1464 | - 'show_option_none' => __( 'Main Page (no parent)' ), |
|
| 1464 | + 'show_option_none' => __('Main Page (no parent)'), |
|
| 1465 | 1465 | 'option_none_value' => 0, |
| 1466 | 1466 | 'sort_column' => 'menu_order, post_title', |
| 1467 | 1467 | ); |
| 1468 | 1468 | |
| 1469 | - if ( $bulk ) |
|
| 1470 | - $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
| 1469 | + if ($bulk) |
|
| 1470 | + $dropdown_args['show_option_no_change'] = __('— No Change —'); |
|
| 1471 | 1471 | |
| 1472 | 1472 | /** |
| 1473 | 1473 | * Filter the arguments used to generate the Quick Edit page-parent drop-down. |
@@ -1478,38 +1478,38 @@ discard block |
||
| 1478 | 1478 | * |
| 1479 | 1479 | * @param array $dropdown_args An array of arguments. |
| 1480 | 1480 | */ |
| 1481 | - $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args ); |
|
| 1481 | + $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); |
|
| 1482 | 1482 | |
| 1483 | - wp_dropdown_pages( $dropdown_args ); |
|
| 1483 | + wp_dropdown_pages($dropdown_args); |
|
| 1484 | 1484 | ?> |
| 1485 | 1485 | </label> |
| 1486 | 1486 | |
| 1487 | 1487 | <?php |
| 1488 | 1488 | endif; // hierarchical |
| 1489 | 1489 | |
| 1490 | - if ( !$bulk ) : ?> |
|
| 1490 | + if ( ! $bulk) : ?> |
|
| 1491 | 1491 | |
| 1492 | 1492 | <label> |
| 1493 | - <span class="title"><?php _e( 'Order' ); ?></span> |
|
| 1493 | + <span class="title"><?php _e('Order'); ?></span> |
|
| 1494 | 1494 | <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span> |
| 1495 | 1495 | </label> |
| 1496 | 1496 | |
| 1497 | 1497 | <?php endif; // !$bulk |
| 1498 | 1498 | |
| 1499 | - if ( 'page' === $screen->post_type ) : |
|
| 1499 | + if ('page' === $screen->post_type) : |
|
| 1500 | 1500 | ?> |
| 1501 | 1501 | |
| 1502 | 1502 | <label> |
| 1503 | - <span class="title"><?php _e( 'Template' ); ?></span> |
|
| 1503 | + <span class="title"><?php _e('Template'); ?></span> |
|
| 1504 | 1504 | <select name="page_template"> |
| 1505 | - <?php if ( $bulk ) : ?> |
|
| 1506 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1505 | + <?php if ($bulk) : ?> |
|
| 1506 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1507 | 1507 | <?php endif; // $bulk ?> |
| 1508 | 1508 | <?php |
| 1509 | 1509 | /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
| 1510 | - $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' ); |
|
| 1510 | + $default_title = apply_filters('default_page_template_title', __('Default Template'), 'quick-edit'); |
|
| 1511 | 1511 | ?> |
| 1512 | - <option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
| 1512 | + <option value="default"><?php echo esc_html($default_title); ?></option> |
|
| 1513 | 1513 | <?php page_template_dropdown() ?> |
| 1514 | 1514 | </select> |
| 1515 | 1515 | </label> |
@@ -1519,13 +1519,13 @@ discard block |
||
| 1519 | 1519 | endif; // page-attributes |
| 1520 | 1520 | ?> |
| 1521 | 1521 | |
| 1522 | - <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?> |
|
| 1522 | + <?php if (count($flat_taxonomies) && ! $bulk) : ?> |
|
| 1523 | 1523 | |
| 1524 | - <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
|
| 1525 | - <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
|
| 1524 | + <?php foreach ($flat_taxonomies as $taxonomy) : ?> |
|
| 1525 | + <?php if (current_user_can($taxonomy->cap->assign_terms)) : ?> |
|
| 1526 | 1526 | <label class="inline-edit-tags"> |
| 1527 | - <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
|
| 1528 | - <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea> |
|
| 1527 | + <span class="title"><?php echo esc_html($taxonomy->labels->name) ?></span> |
|
| 1528 | + <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name)?>]" class="tax_input_<?php echo esc_attr($taxonomy->name)?>"></textarea> |
|
| 1529 | 1529 | </label> |
| 1530 | 1530 | <?php endif; ?> |
| 1531 | 1531 | |
@@ -1533,26 +1533,26 @@ discard block |
||
| 1533 | 1533 | |
| 1534 | 1534 | <?php endif; // count( $flat_taxonomies ) && !$bulk ?> |
| 1535 | 1535 | |
| 1536 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : |
|
| 1537 | - if ( $bulk ) : ?> |
|
| 1536 | + <?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) : |
|
| 1537 | + if ($bulk) : ?> |
|
| 1538 | 1538 | |
| 1539 | 1539 | <div class="inline-edit-group wp-clearfix"> |
| 1540 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
| 1540 | + <?php if (post_type_supports($screen->post_type, 'comments')) : ?> |
|
| 1541 | 1541 | <label class="alignleft"> |
| 1542 | - <span class="title"><?php _e( 'Comments' ); ?></span> |
|
| 1542 | + <span class="title"><?php _e('Comments'); ?></span> |
|
| 1543 | 1543 | <select name="comment_status"> |
| 1544 | - <option value=""><?php _e( '— No Change —' ); ?></option> |
|
| 1545 | - <option value="open"><?php _e( 'Allow' ); ?></option> |
|
| 1546 | - <option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
| 1544 | + <option value=""><?php _e('— No Change —'); ?></option> |
|
| 1545 | + <option value="open"><?php _e('Allow'); ?></option> |
|
| 1546 | + <option value="closed"><?php _e('Do not allow'); ?></option> |
|
| 1547 | 1547 | </select> |
| 1548 | 1548 | </label> |
| 1549 | - <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
| 1549 | + <?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?> |
|
| 1550 | 1550 | <label class="alignright"> |
| 1551 | - <span class="title"><?php _e( 'Pings' ); ?></span> |
|
| 1551 | + <span class="title"><?php _e('Pings'); ?></span> |
|
| 1552 | 1552 | <select name="ping_status"> |
| 1553 | - <option value=""><?php _e( '— No Change —' ); ?></option> |
|
| 1554 | - <option value="open"><?php _e( 'Allow' ); ?></option> |
|
| 1555 | - <option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
| 1553 | + <option value=""><?php _e('— No Change —'); ?></option> |
|
| 1554 | + <option value="open"><?php _e('Allow'); ?></option> |
|
| 1555 | + <option value="closed"><?php _e('Do not allow'); ?></option> |
|
| 1556 | 1556 | </select> |
| 1557 | 1557 | </label> |
| 1558 | 1558 | <?php endif; ?> |
@@ -1561,15 +1561,15 @@ discard block |
||
| 1561 | 1561 | <?php else : // $bulk ?> |
| 1562 | 1562 | |
| 1563 | 1563 | <div class="inline-edit-group wp-clearfix"> |
| 1564 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
| 1564 | + <?php if (post_type_supports($screen->post_type, 'comments')) : ?> |
|
| 1565 | 1565 | <label class="alignleft"> |
| 1566 | 1566 | <input type="checkbox" name="comment_status" value="open" /> |
| 1567 | - <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
| 1567 | + <span class="checkbox-title"><?php _e('Allow Comments'); ?></span> |
|
| 1568 | 1568 | </label> |
| 1569 | - <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
| 1569 | + <?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?> |
|
| 1570 | 1570 | <label class="alignleft"> |
| 1571 | 1571 | <input type="checkbox" name="ping_status" value="open" /> |
| 1572 | - <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> |
|
| 1572 | + <span class="checkbox-title"><?php _e('Allow Pings'); ?></span> |
|
| 1573 | 1573 | </label> |
| 1574 | 1574 | <?php endif; ?> |
| 1575 | 1575 | </div> |
@@ -1579,33 +1579,33 @@ discard block |
||
| 1579 | 1579 | |
| 1580 | 1580 | <div class="inline-edit-group wp-clearfix"> |
| 1581 | 1581 | <label class="inline-edit-status alignleft"> |
| 1582 | - <span class="title"><?php _e( 'Status' ); ?></span> |
|
| 1582 | + <span class="title"><?php _e('Status'); ?></span> |
|
| 1583 | 1583 | <select name="_status"> |
| 1584 | - <?php if ( $bulk ) : ?> |
|
| 1585 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1584 | + <?php if ($bulk) : ?> |
|
| 1585 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1586 | 1586 | <?php endif; // $bulk ?> |
| 1587 | - <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?> |
|
| 1588 | - <option value="publish"><?php _e( 'Published' ); ?></option> |
|
| 1589 | - <option value="future"><?php _e( 'Scheduled' ); ?></option> |
|
| 1590 | - <?php if ( $bulk ) : ?> |
|
| 1591 | - <option value="private"><?php _e( 'Private' ) ?></option> |
|
| 1587 | + <?php if ($can_publish) : // Contributors only get "Unpublished" and "Pending Review" ?> |
|
| 1588 | + <option value="publish"><?php _e('Published'); ?></option> |
|
| 1589 | + <option value="future"><?php _e('Scheduled'); ?></option> |
|
| 1590 | + <?php if ($bulk) : ?> |
|
| 1591 | + <option value="private"><?php _e('Private') ?></option> |
|
| 1592 | 1592 | <?php endif; // $bulk ?> |
| 1593 | 1593 | <?php endif; ?> |
| 1594 | - <option value="pending"><?php _e( 'Pending Review' ); ?></option> |
|
| 1595 | - <option value="draft"><?php _e( 'Draft' ); ?></option> |
|
| 1594 | + <option value="pending"><?php _e('Pending Review'); ?></option> |
|
| 1595 | + <option value="draft"><?php _e('Draft'); ?></option> |
|
| 1596 | 1596 | </select> |
| 1597 | 1597 | </label> |
| 1598 | 1598 | |
| 1599 | - <?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> |
|
| 1599 | + <?php if ('post' === $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) : ?> |
|
| 1600 | 1600 | |
| 1601 | - <?php if ( $bulk ) : ?> |
|
| 1601 | + <?php if ($bulk) : ?> |
|
| 1602 | 1602 | |
| 1603 | 1603 | <label class="alignright"> |
| 1604 | - <span class="title"><?php _e( 'Sticky' ); ?></span> |
|
| 1604 | + <span class="title"><?php _e('Sticky'); ?></span> |
|
| 1605 | 1605 | <select name="sticky"> |
| 1606 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1607 | - <option value="sticky"><?php _e( 'Sticky' ); ?></option> |
|
| 1608 | - <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> |
|
| 1606 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1607 | + <option value="sticky"><?php _e('Sticky'); ?></option> |
|
| 1608 | + <option value="unsticky"><?php _e('Not Sticky'); ?></option> |
|
| 1609 | 1609 | </select> |
| 1610 | 1610 | </label> |
| 1611 | 1611 | |
@@ -1613,7 +1613,7 @@ discard block |
||
| 1613 | 1613 | |
| 1614 | 1614 | <label class="alignleft"> |
| 1615 | 1615 | <input type="checkbox" name="sticky" value="sticky" /> |
| 1616 | - <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
| 1616 | + <span class="checkbox-title"><?php _e('Make this post sticky'); ?></span> |
|
| 1617 | 1617 | </label> |
| 1618 | 1618 | |
| 1619 | 1619 | <?php endif; // $bulk ?> |
@@ -1624,20 +1624,20 @@ discard block |
||
| 1624 | 1624 | |
| 1625 | 1625 | <?php |
| 1626 | 1626 | |
| 1627 | - if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) { |
|
| 1628 | - $post_formats = get_theme_support( 'post-formats' ); |
|
| 1627 | + if ($bulk && current_theme_supports('post-formats') && post_type_supports($screen->post_type, 'post-formats')) { |
|
| 1628 | + $post_formats = get_theme_support('post-formats'); |
|
| 1629 | 1629 | |
| 1630 | 1630 | ?> |
| 1631 | 1631 | <label class="alignleft"> |
| 1632 | - <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> |
|
| 1632 | + <span class="title"><?php _ex('Format', 'post format'); ?></span> |
|
| 1633 | 1633 | <select name="post_format"> |
| 1634 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
| 1635 | - <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
|
| 1634 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
| 1635 | + <option value="0"><?php echo get_post_format_string('standard'); ?></option> |
|
| 1636 | 1636 | <?php |
| 1637 | - if ( is_array( $post_formats[0] ) ) { |
|
| 1638 | - foreach ( $post_formats[0] as $format ) { |
|
| 1637 | + if (is_array($post_formats[0])) { |
|
| 1638 | + foreach ($post_formats[0] as $format) { |
|
| 1639 | 1639 | ?> |
| 1640 | - <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> |
|
| 1640 | + <option value="<?php echo esc_attr($format); ?>"><?php echo esc_html(get_post_format_string($format)); ?></option> |
|
| 1641 | 1641 | <?php |
| 1642 | 1642 | } |
| 1643 | 1643 | } |
@@ -1652,13 +1652,13 @@ discard block |
||
| 1652 | 1652 | </div></fieldset> |
| 1653 | 1653 | |
| 1654 | 1654 | <?php |
| 1655 | - list( $columns ) = $this->get_column_info(); |
|
| 1655 | + list($columns) = $this->get_column_info(); |
|
| 1656 | 1656 | |
| 1657 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
| 1658 | - if ( isset( $core_columns[$column_name] ) ) |
|
| 1657 | + foreach ($columns as $column_name => $column_display_name) { |
|
| 1658 | + if (isset($core_columns[$column_name])) |
|
| 1659 | 1659 | continue; |
| 1660 | 1660 | |
| 1661 | - if ( $bulk ) { |
|
| 1661 | + if ($bulk) { |
|
| 1662 | 1662 | |
| 1663 | 1663 | /** |
| 1664 | 1664 | * Fires once for each column in Bulk Edit mode. |
@@ -1668,7 +1668,7 @@ discard block |
||
| 1668 | 1668 | * @param string $column_name Name of the column to edit. |
| 1669 | 1669 | * @param WP_Post $post_type The post type slug. |
| 1670 | 1670 | */ |
| 1671 | - do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); |
|
| 1671 | + do_action('bulk_edit_custom_box', $column_name, $screen->post_type); |
|
| 1672 | 1672 | } else { |
| 1673 | 1673 | |
| 1674 | 1674 | /** |
@@ -1679,25 +1679,25 @@ discard block |
||
| 1679 | 1679 | * @param string $column_name Name of the column to edit. |
| 1680 | 1680 | * @param string $post_type The post type slug. |
| 1681 | 1681 | */ |
| 1682 | - do_action( 'quick_edit_custom_box', $column_name, $screen->post_type ); |
|
| 1682 | + do_action('quick_edit_custom_box', $column_name, $screen->post_type); |
|
| 1683 | 1683 | } |
| 1684 | 1684 | |
| 1685 | 1685 | } |
| 1686 | 1686 | ?> |
| 1687 | 1687 | <p class="submit inline-edit-save"> |
| 1688 | - <button type="button" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></button> |
|
| 1689 | - <?php if ( ! $bulk ) { |
|
| 1690 | - wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); |
|
| 1688 | + <button type="button" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></button> |
|
| 1689 | + <?php if ( ! $bulk) { |
|
| 1690 | + wp_nonce_field('inlineeditnonce', '_inline_edit', false); |
|
| 1691 | 1691 | ?> |
| 1692 | - <button type="button" class="button-primary save alignright"><?php _e( 'Update' ); ?></button> |
|
| 1692 | + <button type="button" class="button-primary save alignright"><?php _e('Update'); ?></button> |
|
| 1693 | 1693 | <span class="spinner"></span> |
| 1694 | 1694 | <?php } else { |
| 1695 | - submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false ); |
|
| 1695 | + submit_button(__('Update'), 'button-primary alignright', 'bulk_edit', false); |
|
| 1696 | 1696 | } ?> |
| 1697 | - <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
|
| 1698 | - <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
|
| 1699 | - <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?> |
|
| 1700 | - <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
|
| 1697 | + <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" /> |
|
| 1698 | + <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" /> |
|
| 1699 | + <?php if ( ! $bulk && ! post_type_supports($screen->post_type, 'author')) { ?> |
|
| 1700 | + <input type="hidden" name="post_author" value="<?php echo esc_attr($post->post_author); ?>" /> |
|
| 1701 | 1701 | <?php } ?> |
| 1702 | 1702 | <span class="error" style="display:none"></span> |
| 1703 | 1703 | <br class="clear" /> |
@@ -199,10 +199,11 @@ discard block |
||
| 199 | 199 | * @access public |
| 200 | 200 | */ |
| 201 | 201 | public function no_items() { |
| 202 | - if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) |
|
| 203 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
|
| 204 | - else |
|
| 205 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
|
| 202 | + if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { |
|
| 203 | + echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
|
| 204 | + } else { |
|
| 205 | + echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
|
| 206 | + } |
|
| 206 | 207 | } |
| 207 | 208 | |
| 208 | 209 | /** |
@@ -266,8 +267,9 @@ discard block |
||
| 266 | 267 | |
| 267 | 268 | $post_type = $this->screen->post_type; |
| 268 | 269 | |
| 269 | - if ( !empty($locked_post_status) ) |
|
| 270 | - return array(); |
|
| 270 | + if ( !empty($locked_post_status) ) { |
|
| 271 | + return array(); |
|
| 272 | + } |
|
| 271 | 273 | |
| 272 | 274 | $status_links = array(); |
| 273 | 275 | $num_posts = wp_count_posts( $post_type, 'readable' ); |
@@ -476,8 +478,9 @@ discard block |
||
| 476 | 478 | * @return string |
| 477 | 479 | */ |
| 478 | 480 | public function current_action() { |
| 479 | - if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
|
| 480 | - return 'delete_all'; |
|
| 481 | + if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { |
|
| 482 | + return 'delete_all'; |
|
| 483 | + } |
|
| 481 | 484 | |
| 482 | 485 | return parent::current_action(); |
| 483 | 486 | } |
@@ -526,19 +529,21 @@ discard block |
||
| 526 | 529 | $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
| 527 | 530 | |
| 528 | 531 | foreach ( $taxonomies as $taxonomy ) { |
| 529 | - if ( 'category' === $taxonomy ) |
|
| 530 | - $column_key = 'categories'; |
|
| 531 | - elseif ( 'post_tag' === $taxonomy ) |
|
| 532 | - $column_key = 'tags'; |
|
| 533 | - else |
|
| 534 | - $column_key = 'taxonomy-' . $taxonomy; |
|
| 532 | + if ( 'category' === $taxonomy ) { |
|
| 533 | + $column_key = 'categories'; |
|
| 534 | + } elseif ( 'post_tag' === $taxonomy ) { |
|
| 535 | + $column_key = 'tags'; |
|
| 536 | + } else { |
|
| 537 | + $column_key = 'taxonomy-' . $taxonomy; |
|
| 538 | + } |
|
| 535 | 539 | |
| 536 | 540 | $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
| 537 | 541 | } |
| 538 | 542 | |
| 539 | 543 | $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
| 540 | - if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
|
| 541 | - $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
| 544 | + if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) { |
|
| 545 | + $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
| 546 | + } |
|
| 542 | 547 | |
| 543 | 548 | $posts_columns['date'] = __( 'Date' ); |
| 544 | 549 | |
@@ -599,8 +604,9 @@ discard block |
||
| 599 | 604 | public function display_rows( $posts = array(), $level = 0 ) { |
| 600 | 605 | global $wp_query, $per_page; |
| 601 | 606 | |
| 602 | - if ( empty( $posts ) ) |
|
| 603 | - $posts = $wp_query->posts; |
|
| 607 | + if ( empty( $posts ) ) { |
|
| 608 | + $posts = $wp_query->posts; |
|
| 609 | + } |
|
| 604 | 610 | |
| 605 | 611 | add_filter( 'the_title', 'esc_html' ); |
| 606 | 612 | |
@@ -619,13 +625,15 @@ discard block |
||
| 619 | 625 | // Create array of post IDs. |
| 620 | 626 | $post_ids = array(); |
| 621 | 627 | |
| 622 | - foreach ( $posts as $a_post ) |
|
| 623 | - $post_ids[] = $a_post->ID; |
|
| 628 | + foreach ( $posts as $a_post ) { |
|
| 629 | + $post_ids[] = $a_post->ID; |
|
| 630 | + } |
|
| 624 | 631 | |
| 625 | 632 | $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
| 626 | 633 | |
| 627 | - foreach ( $posts as $post ) |
|
| 628 | - $this->single_row( $post, $level ); |
|
| 634 | + foreach ( $posts as $post ) { |
|
| 635 | + $this->single_row( $post, $level ); |
|
| 636 | + } |
|
| 629 | 637 | } |
| 630 | 638 | |
| 631 | 639 | /** |
@@ -643,8 +651,9 @@ discard block |
||
| 643 | 651 | if ( ! $pages ) { |
| 644 | 652 | $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
| 645 | 653 | |
| 646 | - if ( ! $pages ) |
|
| 647 | - return; |
|
| 654 | + if ( ! $pages ) { |
|
| 655 | + return; |
|
| 656 | + } |
|
| 648 | 657 | } |
| 649 | 658 | |
| 650 | 659 | /* |
@@ -668,10 +677,11 @@ discard block |
||
| 668 | 677 | clean_post_cache( $page ); |
| 669 | 678 | } |
| 670 | 679 | |
| 671 | - if ( 0 == $page->post_parent ) |
|
| 672 | - $top_level_pages[] = $page; |
|
| 673 | - else |
|
| 674 | - $children_pages[ $page->post_parent ][] = $page; |
|
| 680 | + if ( 0 == $page->post_parent ) { |
|
| 681 | + $top_level_pages[] = $page; |
|
| 682 | + } else { |
|
| 683 | + $children_pages[ $page->post_parent ][] = $page; |
|
| 684 | + } |
|
| 675 | 685 | } |
| 676 | 686 | |
| 677 | 687 | $pages = &$top_level_pages; |
@@ -683,8 +693,9 @@ discard block |
||
| 683 | 693 | $to_display = array(); |
| 684 | 694 | |
| 685 | 695 | foreach ( $pages as $page ) { |
| 686 | - if ( $count >= $end ) |
|
| 687 | - break; |
|
| 696 | + if ( $count >= $end ) { |
|
| 697 | + break; |
|
| 698 | + } |
|
| 688 | 699 | |
| 689 | 700 | if ( $count >= $start ) { |
| 690 | 701 | $to_display[$page->ID] = $level; |
@@ -692,16 +703,18 @@ discard block |
||
| 692 | 703 | |
| 693 | 704 | $count++; |
| 694 | 705 | |
| 695 | - if ( isset( $children_pages ) ) |
|
| 696 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 706 | + if ( isset( $children_pages ) ) { |
|
| 707 | + $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
| 708 | + } |
|
| 697 | 709 | } |
| 698 | 710 | |
| 699 | 711 | // If it is the last pagenum and there are orphaned pages, display them with paging as well. |
| 700 | 712 | if ( isset( $children_pages ) && $count < $end ){ |
| 701 | 713 | foreach ( $children_pages as $orphans ){ |
| 702 | 714 | foreach ( $orphans as $op ) { |
| 703 | - if ( $count >= $end ) |
|
| 704 | - break; |
|
| 715 | + if ( $count >= $end ) { |
|
| 716 | + break; |
|
| 717 | + } |
|
| 705 | 718 | |
| 706 | 719 | if ( $count >= $start ) { |
| 707 | 720 | $to_display[$op->ID] = 0; |
@@ -741,15 +754,17 @@ discard block |
||
| 741 | 754 | * @param array $to_display List of pages to be displayed. Passed by reference. |
| 742 | 755 | */ |
| 743 | 756 | private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { |
| 744 | - if ( ! isset( $children_pages[$parent] ) ) |
|
| 745 | - return; |
|
| 757 | + if ( ! isset( $children_pages[$parent] ) ) { |
|
| 758 | + return; |
|
| 759 | + } |
|
| 746 | 760 | |
| 747 | 761 | $start = ( $pagenum - 1 ) * $per_page; |
| 748 | 762 | $end = $start + $per_page; |
| 749 | 763 | |
| 750 | 764 | foreach ( $children_pages[$parent] as $page ) { |
| 751 | - if ( $count >= $end ) |
|
| 752 | - break; |
|
| 765 | + if ( $count >= $end ) { |
|
| 766 | + break; |
|
| 767 | + } |
|
| 753 | 768 | |
| 754 | 769 | // If the page starts in a subtree, print the parents. |
| 755 | 770 | if ( $count == $start && $page->post_parent > 0 ) { |
@@ -764,8 +779,9 @@ discard block |
||
| 764 | 779 | |
| 765 | 780 | $my_parent = get_post( $parent_id ); |
| 766 | 781 | $my_parents[] = $my_parent; |
| 767 | - if ( !$my_parent->post_parent ) |
|
| 768 | - break; |
|
| 782 | + if ( !$my_parent->post_parent ) { |
|
| 783 | + break; |
|
| 784 | + } |
|
| 769 | 785 | $my_parent = $my_parent->post_parent; |
| 770 | 786 | } |
| 771 | 787 | $num_parents = count( $my_parents ); |
@@ -1317,10 +1333,11 @@ discard block |
||
| 1317 | 1333 | continue; |
| 1318 | 1334 | } |
| 1319 | 1335 | |
| 1320 | - if ( $taxonomy->hierarchical ) |
|
| 1321 | - $hierarchical_taxonomies[] = $taxonomy; |
|
| 1322 | - else |
|
| 1323 | - $flat_taxonomies[] = $taxonomy; |
|
| 1336 | + if ( $taxonomy->hierarchical ) { |
|
| 1337 | + $hierarchical_taxonomies[] = $taxonomy; |
|
| 1338 | + } else { |
|
| 1339 | + $flat_taxonomies[] = $taxonomy; |
|
| 1340 | + } |
|
| 1324 | 1341 | } |
| 1325 | 1342 | |
| 1326 | 1343 | $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; |
@@ -1350,10 +1367,13 @@ discard block |
||
| 1350 | 1367 | <div id="bulk-titles"></div> |
| 1351 | 1368 | </div> |
| 1352 | 1369 | |
| 1353 | - <?php else : // $bulk ?> |
|
| 1370 | + <?php else { |
|
| 1371 | + : // $bulk ?> |
|
| 1354 | 1372 | |
| 1355 | 1373 | <label> |
| 1356 | - <span class="title"><?php _e( 'Title' ); ?></span> |
|
| 1374 | + <span class="title"><?php _e( 'Title' ); |
|
| 1375 | +} |
|
| 1376 | +?></span> |
|
| 1357 | 1377 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
| 1358 | 1378 | </label> |
| 1359 | 1379 | |
@@ -1386,8 +1406,9 @@ discard block |
||
| 1386 | 1406 | 'echo' => 0, |
| 1387 | 1407 | 'show' => 'display_name_with_login', |
| 1388 | 1408 | ); |
| 1389 | - if ( $bulk ) |
|
| 1390 | - $users_opt['show_option_none'] = __( '— No Change —' ); |
|
| 1409 | + if ( $bulk ) { |
|
| 1410 | + $users_opt['show_option_none'] = __( '— No Change —' ); |
|
| 1411 | + } |
|
| 1391 | 1412 | |
| 1392 | 1413 | if ( $authors = wp_dropdown_users( $users_opt ) ) : |
| 1393 | 1414 | $authors_dropdown = '<label class="inline-edit-author">'; |
@@ -1398,7 +1419,9 @@ discard block |
||
| 1398 | 1419 | endif; // authors |
| 1399 | 1420 | ?> |
| 1400 | 1421 | |
| 1401 | - <?php if ( !$bulk ) echo $authors_dropdown; |
|
| 1422 | + <?php if ( !$bulk ) { |
|
| 1423 | + echo $authors_dropdown; |
|
| 1424 | +} |
|
| 1402 | 1425 | endif; // post_type_supports author |
| 1403 | 1426 | |
| 1404 | 1427 | if ( !$bulk && $can_publish ) : |
@@ -1447,8 +1470,9 @@ discard block |
||
| 1447 | 1470 | <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> |
| 1448 | 1471 | |
| 1449 | 1472 | <?php |
| 1450 | - if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) |
|
| 1451 | - echo $authors_dropdown; |
|
| 1473 | + if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { |
|
| 1474 | + echo $authors_dropdown; |
|
| 1475 | + } |
|
| 1452 | 1476 | |
| 1453 | 1477 | if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : |
| 1454 | 1478 | |
@@ -1466,8 +1490,9 @@ discard block |
||
| 1466 | 1490 | 'sort_column' => 'menu_order, post_title', |
| 1467 | 1491 | ); |
| 1468 | 1492 | |
| 1469 | - if ( $bulk ) |
|
| 1470 | - $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
| 1493 | + if ( $bulk ) { |
|
| 1494 | + $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
| 1495 | + } |
|
| 1471 | 1496 | |
| 1472 | 1497 | /** |
| 1473 | 1498 | * Filter the arguments used to generate the Quick Edit page-parent drop-down. |
@@ -1558,13 +1583,16 @@ discard block |
||
| 1558 | 1583 | <?php endif; ?> |
| 1559 | 1584 | </div> |
| 1560 | 1585 | |
| 1561 | - <?php else : // $bulk ?> |
|
| 1586 | + <?php else { |
|
| 1587 | + : // $bulk ?> |
|
| 1562 | 1588 | |
| 1563 | 1589 | <div class="inline-edit-group wp-clearfix"> |
| 1564 | 1590 | <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
| 1565 | 1591 | <label class="alignleft"> |
| 1566 | 1592 | <input type="checkbox" name="comment_status" value="open" /> |
| 1567 | - <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
| 1593 | + <span class="checkbox-title"><?php _e( 'Allow Comments' ); |
|
| 1594 | +} |
|
| 1595 | +?></span> |
|
| 1568 | 1596 | </label> |
| 1569 | 1597 | <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
| 1570 | 1598 | <label class="alignleft"> |
@@ -1609,11 +1637,14 @@ discard block |
||
| 1609 | 1637 | </select> |
| 1610 | 1638 | </label> |
| 1611 | 1639 | |
| 1612 | - <?php else : // $bulk ?> |
|
| 1640 | + <?php else { |
|
| 1641 | + : // $bulk ?> |
|
| 1613 | 1642 | |
| 1614 | 1643 | <label class="alignleft"> |
| 1615 | 1644 | <input type="checkbox" name="sticky" value="sticky" /> |
| 1616 | - <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
| 1645 | + <span class="checkbox-title"><?php _e( 'Make this post sticky' ); |
|
| 1646 | +} |
|
| 1647 | +?></span> |
|
| 1617 | 1648 | </label> |
| 1618 | 1649 | |
| 1619 | 1650 | <?php endif; // $bulk ?> |
@@ -1655,8 +1686,9 @@ discard block |
||
| 1655 | 1686 | list( $columns ) = $this->get_column_info(); |
| 1656 | 1687 | |
| 1657 | 1688 | foreach ( $columns as $column_name => $column_display_name ) { |
| 1658 | - if ( isset( $core_columns[$column_name] ) ) |
|
| 1659 | - continue; |
|
| 1689 | + if ( isset( $core_columns[$column_name] ) ) { |
|
| 1690 | + continue; |
|
| 1691 | + } |
|
| 1660 | 1692 | |
| 1661 | 1693 | if ( $bulk ) { |
| 1662 | 1694 | |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @param int $dst_h The destination height. |
| 21 | 21 | * @param int $src_abs Optional. If the source crop points are absolute. |
| 22 | 22 | * @param string $dst_file Optional. The destination file to write to. |
| 23 | - * @return string|WP_Error New filepath on success, WP_Error on failure. |
|
| 23 | + * @return string New filepath on success, WP_Error on failure. |
|
| 24 | 24 | */ |
| 25 | 25 | function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { |
| 26 | 26 | $src_file = $src; |
@@ -22,41 +22,41 @@ discard block |
||
| 22 | 22 | * @param string $dst_file Optional. The destination file to write to. |
| 23 | 23 | * @return string|WP_Error New filepath on success, WP_Error on failure. |
| 24 | 24 | */ |
| 25 | -function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { |
|
| 25 | +function wp_crop_image($src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false) { |
|
| 26 | 26 | $src_file = $src; |
| 27 | - if ( is_numeric( $src ) ) { // Handle int as attachment ID |
|
| 28 | - $src_file = get_attached_file( $src ); |
|
| 27 | + if (is_numeric($src)) { // Handle int as attachment ID |
|
| 28 | + $src_file = get_attached_file($src); |
|
| 29 | 29 | |
| 30 | - if ( ! file_exists( $src_file ) ) { |
|
| 30 | + if ( ! file_exists($src_file)) { |
|
| 31 | 31 | // If the file doesn't exist, attempt a URL fopen on the src link. |
| 32 | 32 | // This can occur with certain file replication plugins. |
| 33 | - $src = _load_image_to_edit_path( $src, 'full' ); |
|
| 33 | + $src = _load_image_to_edit_path($src, 'full'); |
|
| 34 | 34 | } else { |
| 35 | 35 | $src = $src_file; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $editor = wp_get_image_editor( $src ); |
|
| 40 | - if ( is_wp_error( $editor ) ) |
|
| 39 | + $editor = wp_get_image_editor($src); |
|
| 40 | + if (is_wp_error($editor)) |
|
| 41 | 41 | return $editor; |
| 42 | 42 | |
| 43 | - $src = $editor->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs ); |
|
| 44 | - if ( is_wp_error( $src ) ) |
|
| 43 | + $src = $editor->crop($src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs); |
|
| 44 | + if (is_wp_error($src)) |
|
| 45 | 45 | return $src; |
| 46 | 46 | |
| 47 | - if ( ! $dst_file ) |
|
| 48 | - $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file ); |
|
| 47 | + if ( ! $dst_file) |
|
| 48 | + $dst_file = str_replace(basename($src_file), 'cropped-'.basename($src_file), $src_file); |
|
| 49 | 49 | |
| 50 | 50 | /* |
| 51 | 51 | * The directory containing the original file may no longer exist when |
| 52 | 52 | * using a replication plugin. |
| 53 | 53 | */ |
| 54 | - wp_mkdir_p( dirname( $dst_file ) ); |
|
| 54 | + wp_mkdir_p(dirname($dst_file)); |
|
| 55 | 55 | |
| 56 | - $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) ); |
|
| 56 | + $dst_file = dirname($dst_file).'/'.wp_unique_filename(dirname($dst_file), basename($dst_file)); |
|
| 57 | 57 | |
| 58 | - $result = $editor->save( $dst_file ); |
|
| 59 | - if ( is_wp_error( $result ) ) |
|
| 58 | + $result = $editor->save($dst_file); |
|
| 59 | + if (is_wp_error($result)) |
|
| 60 | 60 | return $result; |
| 61 | 61 | |
| 62 | 62 | return $dst_file; |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | * @param string $file Filepath of the Attached image. |
| 74 | 74 | * @return mixed Metadata for attachment. |
| 75 | 75 | */ |
| 76 | -function wp_generate_attachment_metadata( $attachment_id, $file ) { |
|
| 77 | - $attachment = get_post( $attachment_id ); |
|
| 76 | +function wp_generate_attachment_metadata($attachment_id, $file) { |
|
| 77 | + $attachment = get_post($attachment_id); |
|
| 78 | 78 | |
| 79 | 79 | $metadata = array(); |
| 80 | 80 | $support = false; |
| 81 | - if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) { |
|
| 82 | - $imagesize = getimagesize( $file ); |
|
| 81 | + if (preg_match('!^image/!', get_post_mime_type($attachment)) && file_is_displayable_image($file)) { |
|
| 82 | + $imagesize = getimagesize($file); |
|
| 83 | 83 | $metadata['width'] = $imagesize[0]; |
| 84 | 84 | $metadata['height'] = $imagesize[1]; |
| 85 | 85 | |
@@ -90,20 +90,20 @@ discard block |
||
| 90 | 90 | global $_wp_additional_image_sizes; |
| 91 | 91 | |
| 92 | 92 | $sizes = array(); |
| 93 | - foreach ( get_intermediate_image_sizes() as $s ) { |
|
| 94 | - $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false ); |
|
| 95 | - if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) |
|
| 96 | - $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes |
|
| 93 | + foreach (get_intermediate_image_sizes() as $s) { |
|
| 94 | + $sizes[$s] = array('width' => '', 'height' => '', 'crop' => false); |
|
| 95 | + if (isset($_wp_additional_image_sizes[$s]['width'])) |
|
| 96 | + $sizes[$s]['width'] = intval($_wp_additional_image_sizes[$s]['width']); // For theme-added sizes |
|
| 97 | 97 | else |
| 98 | - $sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options |
|
| 99 | - if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) |
|
| 100 | - $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes |
|
| 98 | + $sizes[$s]['width'] = get_option("{$s}_size_w"); // For default sizes set in options |
|
| 99 | + if (isset($_wp_additional_image_sizes[$s]['height'])) |
|
| 100 | + $sizes[$s]['height'] = intval($_wp_additional_image_sizes[$s]['height']); // For theme-added sizes |
|
| 101 | 101 | else |
| 102 | - $sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options |
|
| 103 | - if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) |
|
| 102 | + $sizes[$s]['height'] = get_option("{$s}_size_h"); // For default sizes set in options |
|
| 103 | + if (isset($_wp_additional_image_sizes[$s]['crop'])) |
|
| 104 | 104 | $sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop']; // For theme-added sizes |
| 105 | 105 | else |
| 106 | - $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options |
|
| 106 | + $sizes[$s]['crop'] = get_option("{$s}_crop"); // For default sizes set in options |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -115,34 +115,34 @@ discard block |
||
| 115 | 115 | * @param array $sizes An associative array of image sizes. |
| 116 | 116 | * @param array $metadata An associative array of image metadata: width, height, file. |
| 117 | 117 | */ |
| 118 | - $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes, $metadata ); |
|
| 118 | + $sizes = apply_filters('intermediate_image_sizes_advanced', $sizes, $metadata); |
|
| 119 | 119 | |
| 120 | - if ( $sizes ) { |
|
| 121 | - $editor = wp_get_image_editor( $file ); |
|
| 120 | + if ($sizes) { |
|
| 121 | + $editor = wp_get_image_editor($file); |
|
| 122 | 122 | |
| 123 | - if ( ! is_wp_error( $editor ) ) |
|
| 124 | - $metadata['sizes'] = $editor->multi_resize( $sizes ); |
|
| 123 | + if ( ! is_wp_error($editor)) |
|
| 124 | + $metadata['sizes'] = $editor->multi_resize($sizes); |
|
| 125 | 125 | } else { |
| 126 | 126 | $metadata['sizes'] = array(); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Fetch additional metadata from EXIF/IPTC. |
| 130 | - $image_meta = wp_read_image_metadata( $file ); |
|
| 131 | - if ( $image_meta ) |
|
| 130 | + $image_meta = wp_read_image_metadata($file); |
|
| 131 | + if ($image_meta) |
|
| 132 | 132 | $metadata['image_meta'] = $image_meta; |
| 133 | 133 | |
| 134 | - } elseif ( wp_attachment_is( 'video', $attachment ) ) { |
|
| 135 | - $metadata = wp_read_video_metadata( $file ); |
|
| 136 | - $support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' ); |
|
| 137 | - } elseif ( wp_attachment_is( 'audio', $attachment ) ) { |
|
| 138 | - $metadata = wp_read_audio_metadata( $file ); |
|
| 139 | - $support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' ); |
|
| 134 | + } elseif (wp_attachment_is('video', $attachment)) { |
|
| 135 | + $metadata = wp_read_video_metadata($file); |
|
| 136 | + $support = current_theme_supports('post-thumbnails', 'attachment:video') || post_type_supports('attachment:video', 'thumbnail'); |
|
| 137 | + } elseif (wp_attachment_is('audio', $attachment)) { |
|
| 138 | + $metadata = wp_read_audio_metadata($file); |
|
| 139 | + $support = current_theme_supports('post-thumbnails', 'attachment:audio') || post_type_supports('attachment:audio', 'thumbnail'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ( $support && ! empty( $metadata['image']['data'] ) ) { |
|
| 142 | + if ($support && ! empty($metadata['image']['data'])) { |
|
| 143 | 143 | // Check for existing cover. |
| 144 | - $hash = md5( $metadata['image']['data'] ); |
|
| 145 | - $posts = get_posts( array( |
|
| 144 | + $hash = md5($metadata['image']['data']); |
|
| 145 | + $posts = get_posts(array( |
|
| 146 | 146 | 'fields' => 'ids', |
| 147 | 147 | 'post_type' => 'attachment', |
| 148 | 148 | 'post_mime_type' => $metadata['image']['mime'], |
@@ -150,14 +150,14 @@ discard block |
||
| 150 | 150 | 'posts_per_page' => 1, |
| 151 | 151 | 'meta_key' => '_cover_hash', |
| 152 | 152 | 'meta_value' => $hash |
| 153 | - ) ); |
|
| 154 | - $exists = reset( $posts ); |
|
| 153 | + )); |
|
| 154 | + $exists = reset($posts); |
|
| 155 | 155 | |
| 156 | - if ( ! empty( $exists ) ) { |
|
| 157 | - update_post_meta( $attachment_id, '_thumbnail_id', $exists ); |
|
| 156 | + if ( ! empty($exists)) { |
|
| 157 | + update_post_meta($attachment_id, '_thumbnail_id', $exists); |
|
| 158 | 158 | } else { |
| 159 | 159 | $ext = '.jpg'; |
| 160 | - switch ( $metadata['image']['mime'] ) { |
|
| 160 | + switch ($metadata['image']['mime']) { |
|
| 161 | 161 | case 'image/gif': |
| 162 | 162 | $ext = '.gif'; |
| 163 | 163 | break; |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | $ext = '.png'; |
| 166 | 166 | break; |
| 167 | 167 | } |
| 168 | - $basename = str_replace( '.', '-', basename( $file ) ) . '-image' . $ext; |
|
| 169 | - $uploaded = wp_upload_bits( $basename, '', $metadata['image']['data'] ); |
|
| 170 | - if ( false === $uploaded['error'] ) { |
|
| 168 | + $basename = str_replace('.', '-', basename($file)).'-image'.$ext; |
|
| 169 | + $uploaded = wp_upload_bits($basename, '', $metadata['image']['data']); |
|
| 170 | + if (false === $uploaded['error']) { |
|
| 171 | 171 | $image_attachment = array( |
| 172 | 172 | 'post_mime_type' => $metadata['image']['mime'], |
| 173 | 173 | 'post_type' => 'attachment', |
@@ -182,20 +182,20 @@ discard block |
||
| 182 | 182 | * @param array $metadata Current attachment metadata. |
| 183 | 183 | * @param array $uploaded An array containing the thumbnail path and url. |
| 184 | 184 | */ |
| 185 | - $image_attachment = apply_filters( 'attachment_thumbnail_args', $image_attachment, $metadata, $uploaded ); |
|
| 185 | + $image_attachment = apply_filters('attachment_thumbnail_args', $image_attachment, $metadata, $uploaded); |
|
| 186 | 186 | |
| 187 | - $sub_attachment_id = wp_insert_attachment( $image_attachment, $uploaded['file'] ); |
|
| 188 | - add_post_meta( $sub_attachment_id, '_cover_hash', $hash ); |
|
| 189 | - $attach_data = wp_generate_attachment_metadata( $sub_attachment_id, $uploaded['file'] ); |
|
| 190 | - wp_update_attachment_metadata( $sub_attachment_id, $attach_data ); |
|
| 191 | - update_post_meta( $attachment_id, '_thumbnail_id', $sub_attachment_id ); |
|
| 187 | + $sub_attachment_id = wp_insert_attachment($image_attachment, $uploaded['file']); |
|
| 188 | + add_post_meta($sub_attachment_id, '_cover_hash', $hash); |
|
| 189 | + $attach_data = wp_generate_attachment_metadata($sub_attachment_id, $uploaded['file']); |
|
| 190 | + wp_update_attachment_metadata($sub_attachment_id, $attach_data); |
|
| 191 | + update_post_meta($attachment_id, '_thumbnail_id', $sub_attachment_id); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Remove the blob of binary data from the array. |
| 197 | - if ( $metadata ) { |
|
| 198 | - unset( $metadata['image']['data'] ); |
|
| 197 | + if ($metadata) { |
|
| 198 | + unset($metadata['image']['data']); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param array $metadata An array of attachment meta data. |
| 207 | 207 | * @param int $attachment_id Current attachment ID. |
| 208 | 208 | */ |
| 209 | - return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id ); |
|
| 209 | + return apply_filters('wp_generate_attachment_metadata', $metadata, $attachment_id); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | * @return int|float |
| 219 | 219 | */ |
| 220 | 220 | function wp_exif_frac2dec($str) { |
| 221 | - @list( $n, $d ) = explode( '/', $str ); |
|
| 222 | - if ( !empty($d) ) |
|
| 221 | + @list($n, $d) = explode('/', $str); |
|
| 222 | + if ( ! empty($d)) |
|
| 223 | 223 | return $n / $d; |
| 224 | 224 | return $str; |
| 225 | 225 | } |
@@ -233,10 +233,10 @@ discard block |
||
| 233 | 233 | * @return int |
| 234 | 234 | */ |
| 235 | 235 | function wp_exif_date2ts($str) { |
| 236 | - @list( $date, $time ) = explode( ' ', trim($str) ); |
|
| 237 | - @list( $y, $m, $d ) = explode( ':', $date ); |
|
| 236 | + @list($date, $time) = explode(' ', trim($str)); |
|
| 237 | + @list($y, $m, $d) = explode(':', $date); |
|
| 238 | 238 | |
| 239 | - return strtotime( "{$y}-{$m}-{$d} {$time}" ); |
|
| 239 | + return strtotime("{$y}-{$m}-{$d} {$time}"); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | * @param string $file |
| 256 | 256 | * @return bool|array False on failure. Image metadata array on success. |
| 257 | 257 | */ |
| 258 | -function wp_read_image_metadata( $file ) { |
|
| 259 | - if ( ! file_exists( $file ) ) |
|
| 258 | +function wp_read_image_metadata($file) { |
|
| 259 | + if ( ! file_exists($file)) |
|
| 260 | 260 | return false; |
| 261 | 261 | |
| 262 | - list( , , $sourceImageType ) = getimagesize( $file ); |
|
| 262 | + list(,, $sourceImageType) = getimagesize($file); |
|
| 263 | 263 | |
| 264 | 264 | /* |
| 265 | 265 | * EXIF contains a bunch of data we'll probably never need formatted in ways |
@@ -287,31 +287,31 @@ discard block |
||
| 287 | 287 | * Read IPTC first, since it might contain data not available in exif such |
| 288 | 288 | * as caption, description etc. |
| 289 | 289 | */ |
| 290 | - if ( is_callable( 'iptcparse' ) ) { |
|
| 291 | - getimagesize( $file, $info ); |
|
| 290 | + if (is_callable('iptcparse')) { |
|
| 291 | + getimagesize($file, $info); |
|
| 292 | 292 | |
| 293 | - if ( ! empty( $info['APP13'] ) ) { |
|
| 294 | - $iptc = iptcparse( $info['APP13'] ); |
|
| 293 | + if ( ! empty($info['APP13'])) { |
|
| 294 | + $iptc = iptcparse($info['APP13']); |
|
| 295 | 295 | |
| 296 | 296 | // Headline, "A brief synopsis of the caption." |
| 297 | - if ( ! empty( $iptc['2#105'][0] ) ) { |
|
| 298 | - $meta['title'] = trim( $iptc['2#105'][0] ); |
|
| 297 | + if ( ! empty($iptc['2#105'][0])) { |
|
| 298 | + $meta['title'] = trim($iptc['2#105'][0]); |
|
| 299 | 299 | /* |
| 300 | 300 | * Title, "Many use the Title field to store the filename of the image, |
| 301 | 301 | * though the field may be used in many ways." |
| 302 | 302 | */ |
| 303 | - } elseif ( ! empty( $iptc['2#005'][0] ) ) { |
|
| 304 | - $meta['title'] = trim( $iptc['2#005'][0] ); |
|
| 303 | + } elseif ( ! empty($iptc['2#005'][0])) { |
|
| 304 | + $meta['title'] = trim($iptc['2#005'][0]); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption |
|
| 308 | - $caption = trim( $iptc['2#120'][0] ); |
|
| 307 | + if ( ! empty($iptc['2#120'][0])) { // description / legacy caption |
|
| 308 | + $caption = trim($iptc['2#120'][0]); |
|
| 309 | 309 | |
| 310 | 310 | mbstring_binary_safe_encoding(); |
| 311 | - $caption_length = strlen( $caption ); |
|
| 311 | + $caption_length = strlen($caption); |
|
| 312 | 312 | reset_mbstring_encoding(); |
| 313 | 313 | |
| 314 | - if ( empty( $meta['title'] ) && $caption_length < 80 ) { |
|
| 314 | + if (empty($meta['title']) && $caption_length < 80) { |
|
| 315 | 315 | // Assume the title is stored in 2:120 if it's short. |
| 316 | 316 | $meta['title'] = $caption; |
| 317 | 317 | } |
@@ -319,19 +319,19 @@ discard block |
||
| 319 | 319 | $meta['caption'] = $caption; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - if ( ! empty( $iptc['2#110'][0] ) ) // credit |
|
| 323 | - $meta['credit'] = trim( $iptc['2#110'][0] ); |
|
| 324 | - elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline |
|
| 325 | - $meta['credit'] = trim( $iptc['2#080'][0] ); |
|
| 322 | + if ( ! empty($iptc['2#110'][0])) // credit |
|
| 323 | + $meta['credit'] = trim($iptc['2#110'][0]); |
|
| 324 | + elseif ( ! empty($iptc['2#080'][0])) // creator / legacy byline |
|
| 325 | + $meta['credit'] = trim($iptc['2#080'][0]); |
|
| 326 | 326 | |
| 327 | - if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) // created date and time |
|
| 328 | - $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] ); |
|
| 327 | + if ( ! empty($iptc['2#055'][0]) && ! empty($iptc['2#060'][0])) // created date and time |
|
| 328 | + $meta['created_timestamp'] = strtotime($iptc['2#055'][0].' '.$iptc['2#060'][0]); |
|
| 329 | 329 | |
| 330 | - if ( ! empty( $iptc['2#116'][0] ) ) // copyright |
|
| 331 | - $meta['copyright'] = trim( $iptc['2#116'][0] ); |
|
| 330 | + if ( ! empty($iptc['2#116'][0])) // copyright |
|
| 331 | + $meta['copyright'] = trim($iptc['2#116'][0]); |
|
| 332 | 332 | |
| 333 | - if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array |
|
| 334 | - $meta['keywords'] = array_values( $iptc['2#025'] ); |
|
| 333 | + if ( ! empty($iptc['2#025'][0])) { // keywords array |
|
| 334 | + $meta['keywords'] = array_values($iptc['2#025']); |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | } |
@@ -343,78 +343,78 @@ discard block |
||
| 343 | 343 | * |
| 344 | 344 | * @param array $image_types Image types to check for exif data. |
| 345 | 345 | */ |
| 346 | - if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) { |
|
| 347 | - $exif = @exif_read_data( $file ); |
|
| 346 | + if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) { |
|
| 347 | + $exif = @exif_read_data($file); |
|
| 348 | 348 | |
| 349 | - if ( ! empty( $exif['ImageDescription'] ) ) { |
|
| 349 | + if ( ! empty($exif['ImageDescription'])) { |
|
| 350 | 350 | mbstring_binary_safe_encoding(); |
| 351 | - $description_length = strlen( $exif['ImageDescription'] ); |
|
| 351 | + $description_length = strlen($exif['ImageDescription']); |
|
| 352 | 352 | reset_mbstring_encoding(); |
| 353 | 353 | |
| 354 | - if ( empty( $meta['title'] ) && $description_length < 80 ) { |
|
| 354 | + if (empty($meta['title']) && $description_length < 80) { |
|
| 355 | 355 | // Assume the title is stored in ImageDescription |
| 356 | - $meta['title'] = trim( $exif['ImageDescription'] ); |
|
| 356 | + $meta['title'] = trim($exif['ImageDescription']); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) { |
|
| 360 | - $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] ); |
|
| 359 | + if (empty($meta['caption']) && ! empty($exif['COMPUTED']['UserComment'])) { |
|
| 360 | + $meta['caption'] = trim($exif['COMPUTED']['UserComment']); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( empty( $meta['caption'] ) ) { |
|
| 364 | - $meta['caption'] = trim( $exif['ImageDescription'] ); |
|
| 363 | + if (empty($meta['caption'])) { |
|
| 364 | + $meta['caption'] = trim($exif['ImageDescription']); |
|
| 365 | 365 | } |
| 366 | - } elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) ) { |
|
| 367 | - $meta['caption'] = trim( $exif['Comments'] ); |
|
| 366 | + } elseif (empty($meta['caption']) && ! empty($exif['Comments'])) { |
|
| 367 | + $meta['caption'] = trim($exif['Comments']); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if ( empty( $meta['credit'] ) ) { |
|
| 371 | - if ( ! empty( $exif['Artist'] ) ) { |
|
| 372 | - $meta['credit'] = trim( $exif['Artist'] ); |
|
| 373 | - } elseif ( ! empty($exif['Author'] ) ) { |
|
| 374 | - $meta['credit'] = trim( $exif['Author'] ); |
|
| 370 | + if (empty($meta['credit'])) { |
|
| 371 | + if ( ! empty($exif['Artist'])) { |
|
| 372 | + $meta['credit'] = trim($exif['Artist']); |
|
| 373 | + } elseif ( ! empty($exif['Author'])) { |
|
| 374 | + $meta['credit'] = trim($exif['Author']); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ( empty( $meta['copyright'] ) && ! empty( $exif['Copyright'] ) ) { |
|
| 379 | - $meta['copyright'] = trim( $exif['Copyright'] ); |
|
| 378 | + if (empty($meta['copyright']) && ! empty($exif['Copyright'])) { |
|
| 379 | + $meta['copyright'] = trim($exif['Copyright']); |
|
| 380 | 380 | } |
| 381 | - if ( ! empty( $exif['FNumber'] ) ) { |
|
| 382 | - $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); |
|
| 381 | + if ( ! empty($exif['FNumber'])) { |
|
| 382 | + $meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2); |
|
| 383 | 383 | } |
| 384 | - if ( ! empty( $exif['Model'] ) ) { |
|
| 385 | - $meta['camera'] = trim( $exif['Model'] ); |
|
| 384 | + if ( ! empty($exif['Model'])) { |
|
| 385 | + $meta['camera'] = trim($exif['Model']); |
|
| 386 | 386 | } |
| 387 | - if ( empty( $meta['created_timestamp'] ) && ! empty( $exif['DateTimeDigitized'] ) ) { |
|
| 388 | - $meta['created_timestamp'] = wp_exif_date2ts( $exif['DateTimeDigitized'] ); |
|
| 387 | + if (empty($meta['created_timestamp']) && ! empty($exif['DateTimeDigitized'])) { |
|
| 388 | + $meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']); |
|
| 389 | 389 | } |
| 390 | - if ( ! empty( $exif['FocalLength'] ) ) { |
|
| 391 | - $meta['focal_length'] = (string) wp_exif_frac2dec( $exif['FocalLength'] ); |
|
| 390 | + if ( ! empty($exif['FocalLength'])) { |
|
| 391 | + $meta['focal_length'] = (string) wp_exif_frac2dec($exif['FocalLength']); |
|
| 392 | 392 | } |
| 393 | - if ( ! empty( $exif['ISOSpeedRatings'] ) ) { |
|
| 394 | - $meta['iso'] = is_array( $exif['ISOSpeedRatings'] ) ? reset( $exif['ISOSpeedRatings'] ) : $exif['ISOSpeedRatings']; |
|
| 395 | - $meta['iso'] = trim( $meta['iso'] ); |
|
| 393 | + if ( ! empty($exif['ISOSpeedRatings'])) { |
|
| 394 | + $meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings']; |
|
| 395 | + $meta['iso'] = trim($meta['iso']); |
|
| 396 | 396 | } |
| 397 | - if ( ! empty( $exif['ExposureTime'] ) ) { |
|
| 398 | - $meta['shutter_speed'] = (string) wp_exif_frac2dec( $exif['ExposureTime'] ); |
|
| 397 | + if ( ! empty($exif['ExposureTime'])) { |
|
| 398 | + $meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']); |
|
| 399 | 399 | } |
| 400 | - if ( ! empty( $exif['Orientation'] ) ) { |
|
| 400 | + if ( ! empty($exif['Orientation'])) { |
|
| 401 | 401 | $meta['orientation'] = $exif['Orientation']; |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - foreach ( array( 'title', 'caption', 'credit', 'copyright', 'camera', 'iso' ) as $key ) { |
|
| 406 | - if ( $meta[ $key ] && ! seems_utf8( $meta[ $key ] ) ) { |
|
| 407 | - $meta[ $key ] = utf8_encode( $meta[ $key ] ); |
|
| 405 | + foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) { |
|
| 406 | + if ($meta[$key] && ! seems_utf8($meta[$key])) { |
|
| 407 | + $meta[$key] = utf8_encode($meta[$key]); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - foreach ( $meta['keywords'] as $key => $keyword ) { |
|
| 412 | - if ( ! seems_utf8( $keyword ) ) { |
|
| 413 | - $meta['keywords'][ $key ] = utf8_encode( $keyword ); |
|
| 411 | + foreach ($meta['keywords'] as $key => $keyword) { |
|
| 412 | + if ( ! seems_utf8($keyword)) { |
|
| 413 | + $meta['keywords'][$key] = utf8_encode($keyword); |
|
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $meta = wp_kses_post_deep( $meta ); |
|
| 417 | + $meta = wp_kses_post_deep($meta); |
|
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | 420 | * Filter the array of meta data read from an image's exif data. |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @param int $sourceImageType Type of image. |
| 428 | 428 | * @param array $iptc IPTC data. |
| 429 | 429 | */ |
| 430 | - return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc ); |
|
| 430 | + return apply_filters('wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc); |
|
| 431 | 431 | |
| 432 | 432 | } |
| 433 | 433 | |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | function file_is_valid_image($path) { |
| 443 | 443 | $size = @getimagesize($path); |
| 444 | - return !empty($size); |
|
| 444 | + return ! empty($size); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
@@ -453,12 +453,12 @@ discard block |
||
| 453 | 453 | * @return bool True if suitable, false if not suitable. |
| 454 | 454 | */ |
| 455 | 455 | function file_is_displayable_image($path) { |
| 456 | - $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP ); |
|
| 456 | + $displayable_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP); |
|
| 457 | 457 | |
| 458 | - $info = @getimagesize( $path ); |
|
| 459 | - if ( empty( $info ) ) { |
|
| 458 | + $info = @getimagesize($path); |
|
| 459 | + if (empty($info)) { |
|
| 460 | 460 | $result = false; |
| 461 | - } elseif ( ! in_array( $info[2], $displayable_image_types ) ) { |
|
| 461 | + } elseif ( ! in_array($info[2], $displayable_image_types)) { |
|
| 462 | 462 | $result = false; |
| 463 | 463 | } else { |
| 464 | 464 | $result = true; |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | * @param bool $result Whether the image can be displayed. Default true. |
| 473 | 473 | * @param string $path Path to the image. |
| 474 | 474 | */ |
| 475 | - return apply_filters( 'file_is_displayable_image', $result, $path ); |
|
| 475 | + return apply_filters('file_is_displayable_image', $result, $path); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
@@ -485,12 +485,12 @@ discard block |
||
| 485 | 485 | * @param string $size Optional. Image size, defaults to 'full'. |
| 486 | 486 | * @return resource|false The resulting image resource on success, false on failure. |
| 487 | 487 | */ |
| 488 | -function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) { |
|
| 489 | - $filepath = _load_image_to_edit_path( $attachment_id, $size ); |
|
| 490 | - if ( empty( $filepath ) ) |
|
| 488 | +function load_image_to_edit($attachment_id, $mime_type, $size = 'full') { |
|
| 489 | + $filepath = _load_image_to_edit_path($attachment_id, $size); |
|
| 490 | + if (empty($filepath)) |
|
| 491 | 491 | return false; |
| 492 | 492 | |
| 493 | - switch ( $mime_type ) { |
|
| 493 | + switch ($mime_type) { |
|
| 494 | 494 | case 'image/jpeg': |
| 495 | 495 | $image = imagecreatefromjpeg($filepath); |
| 496 | 496 | break; |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | $image = false; |
| 505 | 505 | break; |
| 506 | 506 | } |
| 507 | - if ( is_resource($image) ) { |
|
| 507 | + if (is_resource($image)) { |
|
| 508 | 508 | /** |
| 509 | 509 | * Filter the current image being loaded for editing. |
| 510 | 510 | * |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | * @param string $attachment_id Attachment ID. |
| 515 | 515 | * @param string $size Image size. |
| 516 | 516 | */ |
| 517 | - $image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size ); |
|
| 518 | - if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) { |
|
| 517 | + $image = apply_filters('load_image_to_edit', $image, $attachment_id, $size); |
|
| 518 | + if (function_exists('imagealphablending') && function_exists('imagesavealpha')) { |
|
| 519 | 519 | imagealphablending($image, false); |
| 520 | 520 | imagesavealpha($image, true); |
| 521 | 521 | } |
@@ -536,11 +536,11 @@ discard block |
||
| 536 | 536 | * @param string $size Optional. Image size, defaults to 'full'. |
| 537 | 537 | * @return string|false File path or url on success, false on failure. |
| 538 | 538 | */ |
| 539 | -function _load_image_to_edit_path( $attachment_id, $size = 'full' ) { |
|
| 540 | - $filepath = get_attached_file( $attachment_id ); |
|
| 539 | +function _load_image_to_edit_path($attachment_id, $size = 'full') { |
|
| 540 | + $filepath = get_attached_file($attachment_id); |
|
| 541 | 541 | |
| 542 | - if ( $filepath && file_exists( $filepath ) ) { |
|
| 543 | - if ( 'full' != $size && ( $data = image_get_intermediate_size( $attachment_id, $size ) ) ) { |
|
| 542 | + if ($filepath && file_exists($filepath)) { |
|
| 543 | + if ('full' != $size && ($data = image_get_intermediate_size($attachment_id, $size))) { |
|
| 544 | 544 | /** |
| 545 | 545 | * Filter the path to the current image. |
| 546 | 546 | * |
@@ -552,9 +552,9 @@ discard block |
||
| 552 | 552 | * @param string $attachment_id Attachment ID. |
| 553 | 553 | * @param string $size Size of the image. |
| 554 | 554 | */ |
| 555 | - $filepath = apply_filters( 'load_image_to_edit_filesystempath', path_join( dirname( $filepath ), $data['file'] ), $attachment_id, $size ); |
|
| 555 | + $filepath = apply_filters('load_image_to_edit_filesystempath', path_join(dirname($filepath), $data['file']), $attachment_id, $size); |
|
| 556 | 556 | } |
| 557 | - } elseif ( function_exists( 'fopen' ) && function_exists( 'ini_get' ) && true == ini_get( 'allow_url_fopen' ) ) { |
|
| 557 | + } elseif (function_exists('fopen') && function_exists('ini_get') && true == ini_get('allow_url_fopen')) { |
|
| 558 | 558 | /** |
| 559 | 559 | * Filter the image URL if not in the local filesystem. |
| 560 | 560 | * |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * @param string $attachment_id Attachment ID. |
| 567 | 567 | * @param string $size Size of the image. |
| 568 | 568 | */ |
| 569 | - $filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size ); |
|
| 569 | + $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @param string $attachment_id Attachment ID. |
| 579 | 579 | * @param string $size Size of the image. |
| 580 | 580 | */ |
| 581 | - return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size ); |
|
| 581 | + return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -590,22 +590,22 @@ discard block |
||
| 590 | 590 | * @param string $attachment_id Attachment ID. |
| 591 | 591 | * @return string|false New file path on success, false on failure. |
| 592 | 592 | */ |
| 593 | -function _copy_image_file( $attachment_id ) { |
|
| 594 | - $dst_file = $src_file = get_attached_file( $attachment_id ); |
|
| 595 | - if ( ! file_exists( $src_file ) ) |
|
| 596 | - $src_file = _load_image_to_edit_path( $attachment_id ); |
|
| 593 | +function _copy_image_file($attachment_id) { |
|
| 594 | + $dst_file = $src_file = get_attached_file($attachment_id); |
|
| 595 | + if ( ! file_exists($src_file)) |
|
| 596 | + $src_file = _load_image_to_edit_path($attachment_id); |
|
| 597 | 597 | |
| 598 | - if ( $src_file ) { |
|
| 599 | - $dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file ); |
|
| 600 | - $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) ); |
|
| 598 | + if ($src_file) { |
|
| 599 | + $dst_file = str_replace(basename($dst_file), 'copy-'.basename($dst_file), $dst_file); |
|
| 600 | + $dst_file = dirname($dst_file).'/'.wp_unique_filename(dirname($dst_file), basename($dst_file)); |
|
| 601 | 601 | |
| 602 | 602 | /* |
| 603 | 603 | * The directory containing the original file may no longer |
| 604 | 604 | * exist when using a replication plugin. |
| 605 | 605 | */ |
| 606 | - wp_mkdir_p( dirname( $dst_file ) ); |
|
| 606 | + wp_mkdir_p(dirname($dst_file)); |
|
| 607 | 607 | |
| 608 | - if ( ! @copy( $src_file, $dst_file ) ) |
|
| 608 | + if ( ! @copy($src_file, $dst_file)) |
|
| 609 | 609 | $dst_file = false; |
| 610 | 610 | } else { |
| 611 | 611 | $dst_file = false; |
@@ -1372,7 +1372,7 @@ |
||
| 1372 | 1372 | * @global array $_wp_additional_image_sizes |
| 1373 | 1373 | * |
| 1374 | 1374 | * @param int $thumbnail_id ID of the attachment used for thumbnail |
| 1375 | - * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. |
|
| 1375 | + * @param integer $post The post ID or object associated with the thumbnail, defaults to global $post. |
|
| 1376 | 1376 | * @return string html |
| 1377 | 1377 | */ |
| 1378 | 1378 | function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { |
@@ -18,151 +18,151 @@ discard block |
||
| 18 | 18 | * @param array $post_data Array of post data. Defaults to the contents of $_POST. |
| 19 | 19 | * @return object|bool WP_Error on failure, true on success. |
| 20 | 20 | */ |
| 21 | -function _wp_translate_postdata( $update = false, $post_data = null ) { |
|
| 21 | +function _wp_translate_postdata($update = false, $post_data = null) { |
|
| 22 | 22 | |
| 23 | - if ( empty($post_data) ) |
|
| 23 | + if (empty($post_data)) |
|
| 24 | 24 | $post_data = &$_POST; |
| 25 | 25 | |
| 26 | - if ( $update ) |
|
| 26 | + if ($update) |
|
| 27 | 27 | $post_data['ID'] = (int) $post_data['post_ID']; |
| 28 | 28 | |
| 29 | - $ptype = get_post_type_object( $post_data['post_type'] ); |
|
| 29 | + $ptype = get_post_type_object($post_data['post_type']); |
|
| 30 | 30 | |
| 31 | - if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { |
|
| 32 | - if ( 'page' == $post_data['post_type'] ) |
|
| 33 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
| 31 | + if ($update && ! current_user_can('edit_post', $post_data['ID'])) { |
|
| 32 | + if ('page' == $post_data['post_type']) |
|
| 33 | + return new WP_Error('edit_others_pages', __('You are not allowed to edit pages as this user.')); |
|
| 34 | 34 | else |
| 35 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
| 36 | - } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
|
| 37 | - if ( 'page' == $post_data['post_type'] ) |
|
| 38 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
| 35 | + return new WP_Error('edit_others_posts', __('You are not allowed to edit posts as this user.')); |
|
| 36 | + } elseif ( ! $update && ! current_user_can($ptype->cap->create_posts)) { |
|
| 37 | + if ('page' == $post_data['post_type']) |
|
| 38 | + return new WP_Error('edit_others_pages', __('You are not allowed to create pages as this user.')); |
|
| 39 | 39 | else |
| 40 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
| 40 | + return new WP_Error('edit_others_posts', __('You are not allowed to create posts as this user.')); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ( isset( $post_data['content'] ) ) |
|
| 43 | + if (isset($post_data['content'])) |
|
| 44 | 44 | $post_data['post_content'] = $post_data['content']; |
| 45 | 45 | |
| 46 | - if ( isset( $post_data['excerpt'] ) ) |
|
| 46 | + if (isset($post_data['excerpt'])) |
|
| 47 | 47 | $post_data['post_excerpt'] = $post_data['excerpt']; |
| 48 | 48 | |
| 49 | - if ( isset( $post_data['parent_id'] ) ) |
|
| 49 | + if (isset($post_data['parent_id'])) |
|
| 50 | 50 | $post_data['post_parent'] = (int) $post_data['parent_id']; |
| 51 | 51 | |
| 52 | - if ( isset($post_data['trackback_url']) ) |
|
| 52 | + if (isset($post_data['trackback_url'])) |
|
| 53 | 53 | $post_data['to_ping'] = $post_data['trackback_url']; |
| 54 | 54 | |
| 55 | 55 | $post_data['user_ID'] = get_current_user_id(); |
| 56 | 56 | |
| 57 | - if (!empty ( $post_data['post_author_override'] ) ) { |
|
| 57 | + if ( ! empty ($post_data['post_author_override'])) { |
|
| 58 | 58 | $post_data['post_author'] = (int) $post_data['post_author_override']; |
| 59 | 59 | } else { |
| 60 | - if (!empty ( $post_data['post_author'] ) ) { |
|
| 60 | + if ( ! empty ($post_data['post_author'])) { |
|
| 61 | 61 | $post_data['post_author'] = (int) $post_data['post_author']; |
| 62 | 62 | } else { |
| 63 | 63 | $post_data['post_author'] = (int) $post_data['user_ID']; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
|
| 68 | - && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
| 69 | - if ( $update ) { |
|
| 70 | - if ( 'page' == $post_data['post_type'] ) |
|
| 71 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
| 67 | + if (isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) |
|
| 68 | + && ! current_user_can($ptype->cap->edit_others_posts)) { |
|
| 69 | + if ($update) { |
|
| 70 | + if ('page' == $post_data['post_type']) |
|
| 71 | + return new WP_Error('edit_others_pages', __('You are not allowed to edit pages as this user.')); |
|
| 72 | 72 | else |
| 73 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
| 73 | + return new WP_Error('edit_others_posts', __('You are not allowed to edit posts as this user.')); |
|
| 74 | 74 | } else { |
| 75 | - if ( 'page' == $post_data['post_type'] ) |
|
| 76 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
| 75 | + if ('page' == $post_data['post_type']) |
|
| 76 | + return new WP_Error('edit_others_pages', __('You are not allowed to create pages as this user.')); |
|
| 77 | 77 | else |
| 78 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
| 78 | + return new WP_Error('edit_others_posts', __('You are not allowed to create posts as this user.')); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
| 83 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
| 82 | + if ( ! empty($post_data['post_status'])) { |
|
| 83 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
| 84 | 84 | |
| 85 | 85 | // No longer an auto-draft |
| 86 | - if ( 'auto-draft' === $post_data['post_status'] ) { |
|
| 86 | + if ('auto-draft' === $post_data['post_status']) { |
|
| 87 | 87 | $post_data['post_status'] = 'draft'; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( ! get_post_status_object( $post_data['post_status'] ) ) { |
|
| 91 | - unset( $post_data['post_status'] ); |
|
| 90 | + if ( ! get_post_status_object($post_data['post_status'])) { |
|
| 91 | + unset($post_data['post_status']); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // What to do based on which button they pressed |
| 96 | - if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
|
| 96 | + if (isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft']) |
|
| 97 | 97 | $post_data['post_status'] = 'draft'; |
| 98 | - if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) |
|
| 98 | + if (isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate']) |
|
| 99 | 99 | $post_data['post_status'] = 'private'; |
| 100 | - if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) |
|
| 100 | + if (isset($post_data['publish']) && ('' != $post_data['publish']) && ( ! isset($post_data['post_status']) || $post_data['post_status'] != 'private')) |
|
| 101 | 101 | $post_data['post_status'] = 'publish'; |
| 102 | - if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) |
|
| 102 | + if (isset($post_data['advanced']) && '' != $post_data['advanced']) |
|
| 103 | 103 | $post_data['post_status'] = 'draft'; |
| 104 | - if ( isset($post_data['pending']) && '' != $post_data['pending'] ) |
|
| 104 | + if (isset($post_data['pending']) && '' != $post_data['pending']) |
|
| 105 | 105 | $post_data['post_status'] = 'pending'; |
| 106 | 106 | |
| 107 | - if ( isset( $post_data['ID'] ) ) |
|
| 107 | + if (isset($post_data['ID'])) |
|
| 108 | 108 | $post_id = $post_data['ID']; |
| 109 | 109 | else |
| 110 | 110 | $post_id = false; |
| 111 | - $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; |
|
| 111 | + $previous_status = $post_id ? get_post_field('post_status', $post_id) : false; |
|
| 112 | 112 | |
| 113 | - if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
| 113 | + if (isset($post_data['post_status']) && 'private' == $post_data['post_status'] && ! current_user_can($ptype->cap->publish_posts)) { |
|
| 114 | 114 | $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $published_statuses = array( 'publish', 'future' ); |
|
| 117 | + $published_statuses = array('publish', 'future'); |
|
| 118 | 118 | |
| 119 | 119 | // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. |
| 120 | 120 | // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. |
| 121 | - if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) |
|
| 122 | - if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
| 121 | + if (isset($post_data['post_status']) && (in_array($post_data['post_status'], $published_statuses) && ! current_user_can($ptype->cap->publish_posts))) |
|
| 122 | + if ( ! in_array($previous_status, $published_statuses) || ! current_user_can('edit_post', $post_id)) |
|
| 123 | 123 | $post_data['post_status'] = 'pending'; |
| 124 | 124 | |
| 125 | - if ( ! isset( $post_data['post_status'] ) ) { |
|
| 125 | + if ( ! isset($post_data['post_status'])) { |
|
| 126 | 126 | $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
| 130 | - unset( $post_data['post_password'] ); |
|
| 129 | + if (isset($post_data['post_password']) && ! current_user_can($ptype->cap->publish_posts)) { |
|
| 130 | + unset($post_data['post_password']); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if (!isset( $post_data['comment_status'] )) |
|
| 133 | + if ( ! isset($post_data['comment_status'])) |
|
| 134 | 134 | $post_data['comment_status'] = 'closed'; |
| 135 | 135 | |
| 136 | - if (!isset( $post_data['ping_status'] )) |
|
| 136 | + if ( ! isset($post_data['ping_status'])) |
|
| 137 | 137 | $post_data['ping_status'] = 'closed'; |
| 138 | 138 | |
| 139 | - foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
|
| 140 | - if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { |
|
| 139 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
| 140 | + if ( ! empty($post_data['hidden_'.$timeunit]) && $post_data['hidden_'.$timeunit] != $post_data[$timeunit]) { |
|
| 141 | 141 | $post_data['edit_date'] = '1'; |
| 142 | 142 | break; |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( !empty( $post_data['edit_date'] ) ) { |
|
| 146 | + if ( ! empty($post_data['edit_date'])) { |
|
| 147 | 147 | $aa = $post_data['aa']; |
| 148 | 148 | $mm = $post_data['mm']; |
| 149 | 149 | $jj = $post_data['jj']; |
| 150 | 150 | $hh = $post_data['hh']; |
| 151 | 151 | $mn = $post_data['mn']; |
| 152 | 152 | $ss = $post_data['ss']; |
| 153 | - $aa = ($aa <= 0 ) ? date('Y') : $aa; |
|
| 154 | - $mm = ($mm <= 0 ) ? date('n') : $mm; |
|
| 155 | - $jj = ($jj > 31 ) ? 31 : $jj; |
|
| 156 | - $jj = ($jj <= 0 ) ? date('j') : $jj; |
|
| 157 | - $hh = ($hh > 23 ) ? $hh -24 : $hh; |
|
| 158 | - $mn = ($mn > 59 ) ? $mn -60 : $mn; |
|
| 159 | - $ss = ($ss > 59 ) ? $ss -60 : $ss; |
|
| 160 | - $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); |
|
| 161 | - $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); |
|
| 162 | - if ( !$valid_date ) { |
|
| 163 | - return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) ); |
|
| 153 | + $aa = ($aa <= 0) ? date('Y') : $aa; |
|
| 154 | + $mm = ($mm <= 0) ? date('n') : $mm; |
|
| 155 | + $jj = ($jj > 31) ? 31 : $jj; |
|
| 156 | + $jj = ($jj <= 0) ? date('j') : $jj; |
|
| 157 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
| 158 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
| 159 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
| 160 | + $post_data['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss); |
|
| 161 | + $valid_date = wp_checkdate($mm, $jj, $aa, $post_data['post_date']); |
|
| 162 | + if ( ! $valid_date) { |
|
| 163 | + return new WP_Error('invalid_date', __('Whoops, the provided date is invalid.')); |
|
| 164 | 164 | } |
| 165 | - $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); |
|
| 165 | + $post_data['post_date_gmt'] = get_gmt_from_date($post_data['post_date']); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $post_data; |
@@ -178,149 +178,149 @@ discard block |
||
| 178 | 178 | * @param array $post_data Optional. |
| 179 | 179 | * @return int Post ID. |
| 180 | 180 | */ |
| 181 | -function edit_post( $post_data = null ) { |
|
| 181 | +function edit_post($post_data = null) { |
|
| 182 | 182 | global $wpdb; |
| 183 | 183 | |
| 184 | - if ( empty($post_data) ) |
|
| 184 | + if (empty($post_data)) |
|
| 185 | 185 | $post_data = &$_POST; |
| 186 | 186 | |
| 187 | 187 | // Clear out any data in internal vars. |
| 188 | - unset( $post_data['filter'] ); |
|
| 188 | + unset($post_data['filter']); |
|
| 189 | 189 | |
| 190 | 190 | $post_ID = (int) $post_data['post_ID']; |
| 191 | - $post = get_post( $post_ID ); |
|
| 191 | + $post = get_post($post_ID); |
|
| 192 | 192 | $post_data['post_type'] = $post->post_type; |
| 193 | 193 | $post_data['post_mime_type'] = $post->post_mime_type; |
| 194 | 194 | |
| 195 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
| 196 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
| 195 | + if ( ! empty($post_data['post_status'])) { |
|
| 196 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
| 197 | 197 | |
| 198 | - if ( 'inherit' == $post_data['post_status'] ) { |
|
| 199 | - unset( $post_data['post_status'] ); |
|
| 198 | + if ('inherit' == $post_data['post_status']) { |
|
| 199 | + unset($post_data['post_status']); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $ptype = get_post_type_object($post_data['post_type']); |
| 204 | - if ( !current_user_can( 'edit_post', $post_ID ) ) { |
|
| 205 | - if ( 'page' == $post_data['post_type'] ) |
|
| 206 | - wp_die( __('You are not allowed to edit this page.' )); |
|
| 204 | + if ( ! current_user_can('edit_post', $post_ID)) { |
|
| 205 | + if ('page' == $post_data['post_type']) |
|
| 206 | + wp_die(__('You are not allowed to edit this page.')); |
|
| 207 | 207 | else |
| 208 | - wp_die( __('You are not allowed to edit this post.' )); |
|
| 208 | + wp_die(__('You are not allowed to edit this post.')); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if ( post_type_supports( $ptype->name, 'revisions' ) ) { |
|
| 212 | - $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) ); |
|
| 213 | - $revision = current( $revisions ); |
|
| 211 | + if (post_type_supports($ptype->name, 'revisions')) { |
|
| 212 | + $revisions = wp_get_post_revisions($post_ID, array('order' => 'ASC', 'posts_per_page' => 1)); |
|
| 213 | + $revision = current($revisions); |
|
| 214 | 214 | |
| 215 | 215 | // Check if the revisions have been upgraded |
| 216 | - if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) |
|
| 217 | - _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
| 216 | + if ($revisions && _wp_get_post_revision_version($revision) < 1) |
|
| 217 | + _wp_upgrade_revisions_of_post($post, wp_get_post_revisions($post_ID)); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if ( isset($post_data['visibility']) ) { |
|
| 221 | - switch ( $post_data['visibility'] ) { |
|
| 220 | + if (isset($post_data['visibility'])) { |
|
| 221 | + switch ($post_data['visibility']) { |
|
| 222 | 222 | case 'public' : |
| 223 | 223 | $post_data['post_password'] = ''; |
| 224 | 224 | break; |
| 225 | 225 | case 'password' : |
| 226 | - unset( $post_data['sticky'] ); |
|
| 226 | + unset($post_data['sticky']); |
|
| 227 | 227 | break; |
| 228 | 228 | case 'private' : |
| 229 | 229 | $post_data['post_status'] = 'private'; |
| 230 | 230 | $post_data['post_password'] = ''; |
| 231 | - unset( $post_data['sticky'] ); |
|
| 231 | + unset($post_data['sticky']); |
|
| 232 | 232 | break; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
| 237 | - if ( is_wp_error($post_data) ) |
|
| 238 | - wp_die( $post_data->get_error_message() ); |
|
| 236 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
| 237 | + if (is_wp_error($post_data)) |
|
| 238 | + wp_die($post_data->get_error_message()); |
|
| 239 | 239 | |
| 240 | 240 | // Post Formats |
| 241 | - if ( isset( $post_data['post_format'] ) ) |
|
| 242 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 241 | + if (isset($post_data['post_format'])) |
|
| 242 | + set_post_format($post_ID, $post_data['post_format']); |
|
| 243 | 243 | |
| 244 | - $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); |
|
| 245 | - foreach ( $format_meta_urls as $format_meta_url ) { |
|
| 246 | - $keyed = '_format_' . $format_meta_url; |
|
| 247 | - if ( isset( $post_data[ $keyed ] ) ) |
|
| 248 | - update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
| 244 | + $format_meta_urls = array('url', 'link_url', 'quote_source_url'); |
|
| 245 | + foreach ($format_meta_urls as $format_meta_url) { |
|
| 246 | + $keyed = '_format_'.$format_meta_url; |
|
| 247 | + if (isset($post_data[$keyed])) |
|
| 248 | + update_post_meta($post_ID, $keyed, wp_slash(esc_url_raw(wp_unslash($post_data[$keyed])))); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); |
|
| 251 | + $format_keys = array('quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed'); |
|
| 252 | 252 | |
| 253 | - foreach ( $format_keys as $key ) { |
|
| 254 | - $keyed = '_format_' . $key; |
|
| 255 | - if ( isset( $post_data[ $keyed ] ) ) { |
|
| 256 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 257 | - update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
| 253 | + foreach ($format_keys as $key) { |
|
| 254 | + $keyed = '_format_'.$key; |
|
| 255 | + if (isset($post_data[$keyed])) { |
|
| 256 | + if (current_user_can('unfiltered_html')) |
|
| 257 | + update_post_meta($post_ID, $keyed, $post_data[$keyed]); |
|
| 258 | 258 | else |
| 259 | - update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
| 259 | + update_post_meta($post_ID, $keyed, wp_filter_post_kses($post_data[$keyed])); |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) { |
|
| 264 | - $id3data = wp_get_attachment_metadata( $post_ID ); |
|
| 265 | - if ( ! is_array( $id3data ) ) { |
|
| 263 | + if ('attachment' === $post_data['post_type'] && preg_match('#^(audio|video)/#', $post_data['post_mime_type'])) { |
|
| 264 | + $id3data = wp_get_attachment_metadata($post_ID); |
|
| 265 | + if ( ! is_array($id3data)) { |
|
| 266 | 266 | $id3data = array(); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) { |
|
| 270 | - if ( isset( $post_data[ 'id3_' . $key ] ) ) { |
|
| 271 | - $id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) ); |
|
| 269 | + foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) { |
|
| 270 | + if (isset($post_data['id3_'.$key])) { |
|
| 271 | + $id3data[$key] = sanitize_text_field(wp_unslash($post_data['id3_'.$key])); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | - wp_update_attachment_metadata( $post_ID, $id3data ); |
|
| 274 | + wp_update_attachment_metadata($post_ID, $id3data); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Meta Stuff |
| 278 | - if ( isset($post_data['meta']) && $post_data['meta'] ) { |
|
| 279 | - foreach ( $post_data['meta'] as $key => $value ) { |
|
| 280 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 278 | + if (isset($post_data['meta']) && $post_data['meta']) { |
|
| 279 | + foreach ($post_data['meta'] as $key => $value) { |
|
| 280 | + if ( ! $meta = get_post_meta_by_id($key)) |
|
| 281 | 281 | continue; |
| 282 | - if ( $meta->post_id != $post_ID ) |
|
| 282 | + if ($meta->post_id != $post_ID) |
|
| 283 | 283 | continue; |
| 284 | - if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) |
|
| 284 | + if (is_protected_meta($value['key'], 'post') || ! current_user_can('edit_post_meta', $post_ID, $value['key'])) |
|
| 285 | 285 | continue; |
| 286 | - update_meta( $key, $value['key'], $value['value'] ); |
|
| 286 | + update_meta($key, $value['key'], $value['value']); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { |
|
| 291 | - foreach ( $post_data['deletemeta'] as $key => $value ) { |
|
| 292 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 290 | + if (isset($post_data['deletemeta']) && $post_data['deletemeta']) { |
|
| 291 | + foreach ($post_data['deletemeta'] as $key => $value) { |
|
| 292 | + if ( ! $meta = get_post_meta_by_id($key)) |
|
| 293 | 293 | continue; |
| 294 | - if ( $meta->post_id != $post_ID ) |
|
| 294 | + if ($meta->post_id != $post_ID) |
|
| 295 | 295 | continue; |
| 296 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) |
|
| 296 | + if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $post_ID, $meta->meta_key)) |
|
| 297 | 297 | continue; |
| 298 | - delete_meta( $key ); |
|
| 298 | + delete_meta($key); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Attachment stuff |
| 303 | - if ( 'attachment' == $post_data['post_type'] ) { |
|
| 304 | - if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) { |
|
| 305 | - $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); |
|
| 306 | - if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) { |
|
| 307 | - $image_alt = wp_strip_all_tags( $image_alt, true ); |
|
| 303 | + if ('attachment' == $post_data['post_type']) { |
|
| 304 | + if (isset($post_data['_wp_attachment_image_alt'])) { |
|
| 305 | + $image_alt = wp_unslash($post_data['_wp_attachment_image_alt']); |
|
| 306 | + if ($image_alt != get_post_meta($post_ID, '_wp_attachment_image_alt', true)) { |
|
| 307 | + $image_alt = wp_strip_all_tags($image_alt, true); |
|
| 308 | 308 | // update_meta expects slashed. |
| 309 | - update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); |
|
| 309 | + update_post_meta($post_ID, '_wp_attachment_image_alt', wp_slash($image_alt)); |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); |
|
| 313 | + $attachment_data = isset($post_data['attachments'][$post_ID]) ? $post_data['attachments'][$post_ID] : array(); |
|
| 314 | 314 | |
| 315 | 315 | /** This filter is documented in wp-admin/includes/media.php */ |
| 316 | - $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data ); |
|
| 316 | + $post_data = apply_filters('attachment_fields_to_save', $post_data, $attachment_data); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | // Convert taxonomy input to term IDs, to avoid ambiguity. |
| 320 | - if ( isset( $post_data['tax_input'] ) ) { |
|
| 321 | - foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { |
|
| 320 | + if (isset($post_data['tax_input'])) { |
|
| 321 | + foreach ((array) $post_data['tax_input'] as $taxonomy => $terms) { |
|
| 322 | 322 | // Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary. |
| 323 | - if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
| 323 | + if (is_taxonomy_hierarchical($taxonomy)) { |
|
| 324 | 324 | continue; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -329,67 +329,67 @@ discard block |
||
| 329 | 329 | * Some languages may use a character other than a comma as a delimiter, so we standardize on |
| 330 | 330 | * commas before parsing the list. |
| 331 | 331 | */ |
| 332 | - if ( ! is_array( $terms ) ) { |
|
| 333 | - $comma = _x( ',', 'tag delimiter' ); |
|
| 334 | - if ( ',' !== $comma ) { |
|
| 335 | - $terms = str_replace( $comma, ',', $terms ); |
|
| 332 | + if ( ! is_array($terms)) { |
|
| 333 | + $comma = _x(',', 'tag delimiter'); |
|
| 334 | + if (',' !== $comma) { |
|
| 335 | + $terms = str_replace($comma, ',', $terms); |
|
| 336 | 336 | } |
| 337 | - $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
| 337 | + $terms = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | $clean_terms = array(); |
| 341 | - foreach ( $terms as $term ) { |
|
| 341 | + foreach ($terms as $term) { |
|
| 342 | 342 | // Empty terms are invalid input. |
| 343 | - if ( empty( $term ) ) { |
|
| 343 | + if (empty($term)) { |
|
| 344 | 344 | continue; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $_term = get_terms( $taxonomy, array( |
|
| 347 | + $_term = get_terms($taxonomy, array( |
|
| 348 | 348 | 'name' => $term, |
| 349 | 349 | 'fields' => 'ids', |
| 350 | 350 | 'hide_empty' => false, |
| 351 | - ) ); |
|
| 351 | + )); |
|
| 352 | 352 | |
| 353 | - if ( ! empty( $_term ) ) { |
|
| 354 | - $clean_terms[] = intval( $_term[0] ); |
|
| 353 | + if ( ! empty($_term)) { |
|
| 354 | + $clean_terms[] = intval($_term[0]); |
|
| 355 | 355 | } else { |
| 356 | 356 | // No existing term was found, so pass the string. A new term will be created. |
| 357 | 357 | $clean_terms[] = $term; |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $post_data['tax_input'][ $taxonomy ] = $clean_terms; |
|
| 361 | + $post_data['tax_input'][$taxonomy] = $clean_terms; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - add_meta( $post_ID ); |
|
| 365 | + add_meta($post_ID); |
|
| 366 | 366 | |
| 367 | - update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); |
|
| 367 | + update_post_meta($post_ID, '_edit_last', get_current_user_id()); |
|
| 368 | 368 | |
| 369 | - $success = wp_update_post( $post_data ); |
|
| 369 | + $success = wp_update_post($post_data); |
|
| 370 | 370 | // If the save failed, see if we can sanity check the main fields and try again |
| 371 | - if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { |
|
| 372 | - $fields = array( 'post_title', 'post_content', 'post_excerpt' ); |
|
| 371 | + if ( ! $success && is_callable(array($wpdb, 'strip_invalid_text_for_column'))) { |
|
| 372 | + $fields = array('post_title', 'post_content', 'post_excerpt'); |
|
| 373 | 373 | |
| 374 | - foreach ( $fields as $field ) { |
|
| 375 | - if ( isset( $post_data[ $field ] ) ) { |
|
| 376 | - $post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] ); |
|
| 374 | + foreach ($fields as $field) { |
|
| 375 | + if (isset($post_data[$field])) { |
|
| 376 | + $post_data[$field] = $wpdb->strip_invalid_text_for_column($wpdb->posts, $field, $post_data[$field]); |
|
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - wp_update_post( $post_data ); |
|
| 380 | + wp_update_post($post_data); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // Now that we have an ID we can fix any attachment anchor hrefs |
| 384 | - _fix_attachment_links( $post_ID ); |
|
| 384 | + _fix_attachment_links($post_ID); |
|
| 385 | 385 | |
| 386 | - wp_set_post_lock( $post_ID ); |
|
| 386 | + wp_set_post_lock($post_ID); |
|
| 387 | 387 | |
| 388 | - if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { |
|
| 389 | - if ( ! empty( $post_data['sticky'] ) ) |
|
| 390 | - stick_post( $post_ID ); |
|
| 388 | + if (current_user_can($ptype->cap->edit_others_posts) && current_user_can($ptype->cap->publish_posts)) { |
|
| 389 | + if ( ! empty($post_data['sticky'])) |
|
| 390 | + stick_post($post_ID); |
|
| 391 | 391 | else |
| 392 | - unstick_post( $post_ID ); |
|
| 392 | + unstick_post($post_ID); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | return $post_ID; |
@@ -408,22 +408,22 @@ discard block |
||
| 408 | 408 | * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal. |
| 409 | 409 | * @return array |
| 410 | 410 | */ |
| 411 | -function bulk_edit_posts( $post_data = null ) { |
|
| 411 | +function bulk_edit_posts($post_data = null) { |
|
| 412 | 412 | global $wpdb; |
| 413 | 413 | |
| 414 | - if ( empty($post_data) ) |
|
| 414 | + if (empty($post_data)) |
|
| 415 | 415 | $post_data = &$_POST; |
| 416 | 416 | |
| 417 | - if ( isset($post_data['post_type']) ) |
|
| 417 | + if (isset($post_data['post_type'])) |
|
| 418 | 418 | $ptype = get_post_type_object($post_data['post_type']); |
| 419 | 419 | else |
| 420 | 420 | $ptype = get_post_type_object('post'); |
| 421 | 421 | |
| 422 | - if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
|
| 423 | - if ( 'page' == $ptype->name ) |
|
| 424 | - wp_die( __('You are not allowed to edit pages.')); |
|
| 422 | + if ( ! current_user_can($ptype->cap->edit_posts)) { |
|
| 423 | + if ('page' == $ptype->name) |
|
| 424 | + wp_die(__('You are not allowed to edit pages.')); |
|
| 425 | 425 | else |
| 426 | - wp_die( __('You are not allowed to edit posts.')); |
|
| 426 | + wp_die(__('You are not allowed to edit posts.')); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | if ( -1 == $post_data['_status'] ) { |
@@ -434,15 +434,15 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | unset($post_data['_status']); |
| 436 | 436 | |
| 437 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
| 438 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
| 437 | + if ( ! empty($post_data['post_status'])) { |
|
| 438 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
| 439 | 439 | |
| 440 | - if ( 'inherit' == $post_data['post_status'] ) { |
|
| 441 | - unset( $post_data['post_status'] ); |
|
| 440 | + if ('inherit' == $post_data['post_status']) { |
|
| 441 | + unset($post_data['post_status']); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - $post_IDs = array_map( 'intval', (array) $post_data['post'] ); |
|
| 445 | + $post_IDs = array_map('intval', (array) $post_data['post']); |
|
| 446 | 446 | |
| 447 | 447 | $reset = array( |
| 448 | 448 | 'post_author', 'post_status', 'post_password', |
@@ -451,43 +451,43 @@ discard block |
||
| 451 | 451 | 'post_category', 'sticky', 'post_format', |
| 452 | 452 | ); |
| 453 | 453 | |
| 454 | - foreach ( $reset as $field ) { |
|
| 455 | - if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) |
|
| 454 | + foreach ($reset as $field) { |
|
| 455 | + if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field])) |
|
| 456 | 456 | unset($post_data[$field]); |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if ( isset($post_data['post_category']) ) { |
|
| 460 | - if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) |
|
| 461 | - $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
| 459 | + if (isset($post_data['post_category'])) { |
|
| 460 | + if (is_array($post_data['post_category']) && ! empty($post_data['post_category'])) |
|
| 461 | + $new_cats = array_map('absint', $post_data['post_category']); |
|
| 462 | 462 | else |
| 463 | 463 | unset($post_data['post_category']); |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | $tax_input = array(); |
| 467 | - if ( isset($post_data['tax_input'])) { |
|
| 468 | - foreach ( $post_data['tax_input'] as $tax_name => $terms ) { |
|
| 469 | - if ( empty($terms) ) |
|
| 467 | + if (isset($post_data['tax_input'])) { |
|
| 468 | + foreach ($post_data['tax_input'] as $tax_name => $terms) { |
|
| 469 | + if (empty($terms)) |
|
| 470 | 470 | continue; |
| 471 | - if ( is_taxonomy_hierarchical( $tax_name ) ) { |
|
| 472 | - $tax_input[ $tax_name ] = array_map( 'absint', $terms ); |
|
| 471 | + if (is_taxonomy_hierarchical($tax_name)) { |
|
| 472 | + $tax_input[$tax_name] = array_map('absint', $terms); |
|
| 473 | 473 | } else { |
| 474 | - $comma = _x( ',', 'tag delimiter' ); |
|
| 475 | - if ( ',' !== $comma ) |
|
| 476 | - $terms = str_replace( $comma, ',', $terms ); |
|
| 477 | - $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
| 474 | + $comma = _x(',', 'tag delimiter'); |
|
| 475 | + if (',' !== $comma) |
|
| 476 | + $terms = str_replace($comma, ',', $terms); |
|
| 477 | + $tax_input[$tax_name] = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) { |
|
| 482 | + if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) { |
|
| 483 | 483 | $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'"); |
| 484 | 484 | $children = array(); |
| 485 | 485 | |
| 486 | - for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { |
|
| 486 | + for ($i = 0; $i < 50 && $parent > 0; $i++) { |
|
| 487 | 487 | $children[] = $parent; |
| 488 | 488 | |
| 489 | - foreach ( $pages as $page ) { |
|
| 490 | - if ( $page->ID == $parent ) { |
|
| 489 | + foreach ($pages as $page) { |
|
| 490 | + if ($page->ID == $parent) { |
|
| 491 | 491 | $parent = $page->post_parent; |
| 492 | 492 | break; |
| 493 | 493 | } |
@@ -498,78 +498,78 @@ discard block |
||
| 498 | 498 | $updated = $skipped = $locked = array(); |
| 499 | 499 | $shared_post_data = $post_data; |
| 500 | 500 | |
| 501 | - foreach ( $post_IDs as $post_ID ) { |
|
| 501 | + foreach ($post_IDs as $post_ID) { |
|
| 502 | 502 | // Start with fresh post data with each iteration. |
| 503 | 503 | $post_data = $shared_post_data; |
| 504 | 504 | |
| 505 | - $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); |
|
| 505 | + $post_type_object = get_post_type_object(get_post_type($post_ID)); |
|
| 506 | 506 | |
| 507 | - if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) { |
|
| 507 | + if ( ! isset($post_type_object) || (isset($children) && in_array($post_ID, $children)) || ! current_user_can('edit_post', $post_ID)) { |
|
| 508 | 508 | $skipped[] = $post_ID; |
| 509 | 509 | continue; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - if ( wp_check_post_lock( $post_ID ) ) { |
|
| 512 | + if (wp_check_post_lock($post_ID)) { |
|
| 513 | 513 | $locked[] = $post_ID; |
| 514 | 514 | continue; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - $post = get_post( $post_ID ); |
|
| 518 | - $tax_names = get_object_taxonomies( $post ); |
|
| 519 | - foreach ( $tax_names as $tax_name ) { |
|
| 517 | + $post = get_post($post_ID); |
|
| 518 | + $tax_names = get_object_taxonomies($post); |
|
| 519 | + foreach ($tax_names as $tax_name) { |
|
| 520 | 520 | $taxonomy_obj = get_taxonomy($tax_name); |
| 521 | - if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) |
|
| 521 | + if (isset($tax_input[$tax_name]) && current_user_can($taxonomy_obj->cap->assign_terms)) |
|
| 522 | 522 | $new_terms = $tax_input[$tax_name]; |
| 523 | 523 | else |
| 524 | 524 | $new_terms = array(); |
| 525 | 525 | |
| 526 | - if ( $taxonomy_obj->hierarchical ) |
|
| 527 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
| 526 | + if ($taxonomy_obj->hierarchical) |
|
| 527 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'ids')); |
|
| 528 | 528 | else |
| 529 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
| 529 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'names')); |
|
| 530 | 530 | |
| 531 | - $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms ); |
|
| 531 | + $post_data['tax_input'][$tax_name] = array_merge($current_terms, $new_terms); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - if ( isset($new_cats) && in_array( 'category', $tax_names ) ) { |
|
| 534 | + if (isset($new_cats) && in_array('category', $tax_names)) { |
|
| 535 | 535 | $cats = (array) wp_get_post_categories($post_ID); |
| 536 | - $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) ); |
|
| 537 | - unset( $post_data['tax_input']['category'] ); |
|
| 536 | + $post_data['post_category'] = array_unique(array_merge($cats, $new_cats)); |
|
| 537 | + unset($post_data['tax_input']['category']); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | $post_data['post_type'] = $post->post_type; |
| 541 | 541 | $post_data['post_mime_type'] = $post->post_mime_type; |
| 542 | 542 | $post_data['guid'] = $post->guid; |
| 543 | 543 | |
| 544 | - foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) { |
|
| 545 | - if ( ! isset( $post_data[ $field ] ) ) { |
|
| 546 | - $post_data[ $field ] = $post->$field; |
|
| 544 | + foreach (array('comment_status', 'ping_status', 'post_author') as $field) { |
|
| 545 | + if ( ! isset($post_data[$field])) { |
|
| 546 | + $post_data[$field] = $post->$field; |
|
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | $post_data['ID'] = $post_ID; |
| 551 | 551 | $post_data['post_ID'] = $post_ID; |
| 552 | 552 | |
| 553 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
| 554 | - if ( is_wp_error( $post_data ) ) { |
|
| 553 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
| 554 | + if (is_wp_error($post_data)) { |
|
| 555 | 555 | $skipped[] = $post_ID; |
| 556 | 556 | continue; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $updated[] = wp_update_post( $post_data ); |
|
| 559 | + $updated[] = wp_update_post($post_data); |
|
| 560 | 560 | |
| 561 | - if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
| 562 | - if ( 'sticky' == $post_data['sticky'] ) |
|
| 563 | - stick_post( $post_ID ); |
|
| 561 | + if (isset($post_data['sticky']) && current_user_can($ptype->cap->edit_others_posts)) { |
|
| 562 | + if ('sticky' == $post_data['sticky']) |
|
| 563 | + stick_post($post_ID); |
|
| 564 | 564 | else |
| 565 | - unstick_post( $post_ID ); |
|
| 565 | + unstick_post($post_ID); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - if ( isset( $post_data['post_format'] ) ) |
|
| 569 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 568 | + if (isset($post_data['post_format'])) |
|
| 569 | + set_post_format($post_ID, $post_data['post_format']); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); |
|
| 572 | + return array('updated' => $updated, 'skipped' => $skipped, 'locked' => $locked); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | /** |
@@ -581,24 +581,24 @@ discard block |
||
| 581 | 581 | * @param bool $create_in_db Optional. Whether to insert the post into database. Default false. |
| 582 | 582 | * @return WP_Post Post object containing all the default post data as attributes |
| 583 | 583 | */ |
| 584 | -function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { |
|
| 584 | +function get_default_post_to_edit($post_type = 'post', $create_in_db = false) { |
|
| 585 | 585 | $post_title = ''; |
| 586 | - if ( !empty( $_REQUEST['post_title'] ) ) |
|
| 587 | - $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
| 586 | + if ( ! empty($_REQUEST['post_title'])) |
|
| 587 | + $post_title = esc_html(wp_unslash($_REQUEST['post_title'])); |
|
| 588 | 588 | |
| 589 | 589 | $post_content = ''; |
| 590 | - if ( !empty( $_REQUEST['content'] ) ) |
|
| 591 | - $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
| 590 | + if ( ! empty($_REQUEST['content'])) |
|
| 591 | + $post_content = esc_html(wp_unslash($_REQUEST['content'])); |
|
| 592 | 592 | |
| 593 | 593 | $post_excerpt = ''; |
| 594 | - if ( !empty( $_REQUEST['excerpt'] ) ) |
|
| 595 | - $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
| 596 | - |
|
| 597 | - if ( $create_in_db ) { |
|
| 598 | - $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
|
| 599 | - $post = get_post( $post_id ); |
|
| 600 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) |
|
| 601 | - set_post_format( $post, get_option( 'default_post_format' ) ); |
|
| 594 | + if ( ! empty($_REQUEST['excerpt'])) |
|
| 595 | + $post_excerpt = esc_html(wp_unslash($_REQUEST['excerpt'])); |
|
| 596 | + |
|
| 597 | + if ($create_in_db) { |
|
| 598 | + $post_id = wp_insert_post(array('post_title' => __('Auto Draft'), 'post_type' => $post_type, 'post_status' => 'auto-draft')); |
|
| 599 | + $post = get_post($post_id); |
|
| 600 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats') && get_option('default_post_format')) |
|
| 601 | + set_post_format($post, get_option('default_post_format')); |
|
| 602 | 602 | } else { |
| 603 | 603 | $post = new stdClass; |
| 604 | 604 | $post->ID = 0; |
@@ -611,14 +611,14 @@ discard block |
||
| 611 | 611 | $post->post_status = 'draft'; |
| 612 | 612 | $post->to_ping = ''; |
| 613 | 613 | $post->pinged = ''; |
| 614 | - $post->comment_status = get_default_comment_status( $post_type ); |
|
| 615 | - $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); |
|
| 616 | - $post->post_pingback = get_option( 'default_pingback_flag' ); |
|
| 617 | - $post->post_category = get_option( 'default_category' ); |
|
| 614 | + $post->comment_status = get_default_comment_status($post_type); |
|
| 615 | + $post->ping_status = get_default_comment_status($post_type, 'pingback'); |
|
| 616 | + $post->post_pingback = get_option('default_pingback_flag'); |
|
| 617 | + $post->post_category = get_option('default_category'); |
|
| 618 | 618 | $post->page_template = 'default'; |
| 619 | 619 | $post->post_parent = 0; |
| 620 | 620 | $post->menu_order = 0; |
| 621 | - $post = new WP_Post( $post ); |
|
| 621 | + $post = new WP_Post($post); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | * @param string $post_content Default post content. |
| 630 | 630 | * @param WP_Post $post Post object. |
| 631 | 631 | */ |
| 632 | - $post->post_content = apply_filters( 'default_content', $post_content, $post ); |
|
| 632 | + $post->post_content = apply_filters('default_content', $post_content, $post); |
|
| 633 | 633 | |
| 634 | 634 | /** |
| 635 | 635 | * Filter the default post title initially used in the "Write Post" form. |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | * @param string $post_title Default post title. |
| 640 | 640 | * @param WP_Post $post Post object. |
| 641 | 641 | */ |
| 642 | - $post->post_title = apply_filters( 'default_title', $post_title, $post ); |
|
| 642 | + $post->post_title = apply_filters('default_title', $post_title, $post); |
|
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | 645 | * Filter the default post excerpt initially used in the "Write Post" form. |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | * @param string $post_excerpt Default post excerpt. |
| 650 | 650 | * @param WP_Post $post Post object. |
| 651 | 651 | */ |
| 652 | - $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); |
|
| 652 | + $post->post_excerpt = apply_filters('default_excerpt', $post_excerpt, $post); |
|
| 653 | 653 | |
| 654 | 654 | return $post; |
| 655 | 655 | } |
@@ -669,30 +669,30 @@ discard block |
||
| 669 | 669 | function post_exists($title, $content = '', $date = '') { |
| 670 | 670 | global $wpdb; |
| 671 | 671 | |
| 672 | - $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); |
|
| 673 | - $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); |
|
| 674 | - $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); |
|
| 672 | + $post_title = wp_unslash(sanitize_post_field('post_title', $title, 0, 'db')); |
|
| 673 | + $post_content = wp_unslash(sanitize_post_field('post_content', $content, 0, 'db')); |
|
| 674 | + $post_date = wp_unslash(sanitize_post_field('post_date', $date, 0, 'db')); |
|
| 675 | 675 | |
| 676 | 676 | $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; |
| 677 | 677 | $args = array(); |
| 678 | 678 | |
| 679 | - if ( !empty ( $date ) ) { |
|
| 679 | + if ( ! empty ($date)) { |
|
| 680 | 680 | $query .= ' AND post_date = %s'; |
| 681 | 681 | $args[] = $post_date; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if ( !empty ( $title ) ) { |
|
| 684 | + if ( ! empty ($title)) { |
|
| 685 | 685 | $query .= ' AND post_title = %s'; |
| 686 | 686 | $args[] = $post_title; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - if ( !empty ( $content ) ) { |
|
| 689 | + if ( ! empty ($content)) { |
|
| 690 | 690 | $query .= ' AND post_content = %s'; |
| 691 | 691 | $args[] = $post_content; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - if ( !empty ( $args ) ) |
|
| 695 | - return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
| 694 | + if ( ! empty ($args)) |
|
| 695 | + return (int) $wpdb->get_var($wpdb->prepare($query, $args)); |
|
| 696 | 696 | |
| 697 | 697 | return 0; |
| 698 | 698 | } |
@@ -707,63 +707,63 @@ discard block |
||
| 707 | 707 | * @return int|WP_Error |
| 708 | 708 | */ |
| 709 | 709 | function wp_write_post() { |
| 710 | - if ( isset($_POST['post_type']) ) |
|
| 710 | + if (isset($_POST['post_type'])) |
|
| 711 | 711 | $ptype = get_post_type_object($_POST['post_type']); |
| 712 | 712 | else |
| 713 | 713 | $ptype = get_post_type_object('post'); |
| 714 | 714 | |
| 715 | - if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
|
| 716 | - if ( 'page' == $ptype->name ) |
|
| 717 | - return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) ); |
|
| 715 | + if ( ! current_user_can($ptype->cap->edit_posts)) { |
|
| 716 | + if ('page' == $ptype->name) |
|
| 717 | + return new WP_Error('edit_pages', __('You are not allowed to create pages on this site.')); |
|
| 718 | 718 | else |
| 719 | - return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) ); |
|
| 719 | + return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this site.')); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | $_POST['post_mime_type'] = ''; |
| 723 | 723 | |
| 724 | 724 | // Clear out any data in internal vars. |
| 725 | - unset( $_POST['filter'] ); |
|
| 725 | + unset($_POST['filter']); |
|
| 726 | 726 | |
| 727 | 727 | // Edit don't write if we have a post id. |
| 728 | - if ( isset( $_POST['post_ID'] ) ) |
|
| 728 | + if (isset($_POST['post_ID'])) |
|
| 729 | 729 | return edit_post(); |
| 730 | 730 | |
| 731 | - if ( isset($_POST['visibility']) ) { |
|
| 732 | - switch ( $_POST['visibility'] ) { |
|
| 731 | + if (isset($_POST['visibility'])) { |
|
| 732 | + switch ($_POST['visibility']) { |
|
| 733 | 733 | case 'public' : |
| 734 | 734 | $_POST['post_password'] = ''; |
| 735 | 735 | break; |
| 736 | 736 | case 'password' : |
| 737 | - unset( $_POST['sticky'] ); |
|
| 737 | + unset($_POST['sticky']); |
|
| 738 | 738 | break; |
| 739 | 739 | case 'private' : |
| 740 | 740 | $_POST['post_status'] = 'private'; |
| 741 | 741 | $_POST['post_password'] = ''; |
| 742 | - unset( $_POST['sticky'] ); |
|
| 742 | + unset($_POST['sticky']); |
|
| 743 | 743 | break; |
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - $translated = _wp_translate_postdata( false ); |
|
| 748 | - if ( is_wp_error($translated) ) |
|
| 747 | + $translated = _wp_translate_postdata(false); |
|
| 748 | + if (is_wp_error($translated)) |
|
| 749 | 749 | return $translated; |
| 750 | 750 | |
| 751 | 751 | // Create the post. |
| 752 | - $post_ID = wp_insert_post( $_POST ); |
|
| 753 | - if ( is_wp_error( $post_ID ) ) |
|
| 752 | + $post_ID = wp_insert_post($_POST); |
|
| 753 | + if (is_wp_error($post_ID)) |
|
| 754 | 754 | return $post_ID; |
| 755 | 755 | |
| 756 | - if ( empty($post_ID) ) |
|
| 756 | + if (empty($post_ID)) |
|
| 757 | 757 | return 0; |
| 758 | 758 | |
| 759 | - add_meta( $post_ID ); |
|
| 759 | + add_meta($post_ID); |
|
| 760 | 760 | |
| 761 | - add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); |
|
| 761 | + add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID); |
|
| 762 | 762 | |
| 763 | 763 | // Now that we have an ID we can fix any attachment anchor hrefs |
| 764 | - _fix_attachment_links( $post_ID ); |
|
| 764 | + _fix_attachment_links($post_ID); |
|
| 765 | 765 | |
| 766 | - wp_set_post_lock( $post_ID ); |
|
| 766 | + wp_set_post_lock($post_ID); |
|
| 767 | 767 | |
| 768 | 768 | return $post_ID; |
| 769 | 769 | } |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | */ |
| 778 | 778 | function write_post() { |
| 779 | 779 | $result = wp_write_post(); |
| 780 | - if ( is_wp_error( $result ) ) |
|
| 781 | - wp_die( $result->get_error_message() ); |
|
| 780 | + if (is_wp_error($result)) |
|
| 781 | + wp_die($result->get_error_message()); |
|
| 782 | 782 | else |
| 783 | 783 | return $result; |
| 784 | 784 | } |
@@ -795,32 +795,32 @@ discard block |
||
| 795 | 795 | * @param int $post_ID |
| 796 | 796 | * @return int|bool |
| 797 | 797 | */ |
| 798 | -function add_meta( $post_ID ) { |
|
| 798 | +function add_meta($post_ID) { |
|
| 799 | 799 | $post_ID = (int) $post_ID; |
| 800 | 800 | |
| 801 | - $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; |
|
| 802 | - $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; |
|
| 801 | + $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash(trim($_POST['metakeyselect'])) : ''; |
|
| 802 | + $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash(trim($_POST['metakeyinput'])) : ''; |
|
| 803 | 803 | $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; |
| 804 | - if ( is_string( $metavalue ) ) |
|
| 805 | - $metavalue = trim( $metavalue ); |
|
| 804 | + if (is_string($metavalue)) |
|
| 805 | + $metavalue = trim($metavalue); |
|
| 806 | 806 | |
| 807 | - if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) { |
|
| 807 | + if (('0' === $metavalue || ! empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && ! empty ($metakeyselect)) || ! empty ($metakeyinput))) { |
|
| 808 | 808 | /* |
| 809 | 809 | * We have a key/value pair. If both the select and the input |
| 810 | 810 | * for the key have data, the input takes precedence. |
| 811 | 811 | */ |
| 812 | - if ( '#NONE#' != $metakeyselect ) |
|
| 812 | + if ('#NONE#' != $metakeyselect) |
|
| 813 | 813 | $metakey = $metakeyselect; |
| 814 | 814 | |
| 815 | - if ( $metakeyinput ) |
|
| 815 | + if ($metakeyinput) |
|
| 816 | 816 | $metakey = $metakeyinput; // default |
| 817 | 817 | |
| 818 | - if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) |
|
| 818 | + if (is_protected_meta($metakey, 'post') || ! current_user_can('add_post_meta', $post_ID, $metakey)) |
|
| 819 | 819 | return false; |
| 820 | 820 | |
| 821 | - $metakey = wp_slash( $metakey ); |
|
| 821 | + $metakey = wp_slash($metakey); |
|
| 822 | 822 | |
| 823 | - return add_post_meta( $post_ID, $metakey, $metavalue ); |
|
| 823 | + return add_post_meta($post_ID, $metakey, $metavalue); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | return false; |
@@ -834,8 +834,8 @@ discard block |
||
| 834 | 834 | * @param int $mid |
| 835 | 835 | * @return bool |
| 836 | 836 | */ |
| 837 | -function delete_meta( $mid ) { |
|
| 838 | - return delete_metadata_by_mid( 'post' , $mid ); |
|
| 837 | +function delete_meta($mid) { |
|
| 838 | + return delete_metadata_by_mid('post', $mid); |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | /** |
@@ -850,11 +850,11 @@ discard block |
||
| 850 | 850 | function get_meta_keys() { |
| 851 | 851 | global $wpdb; |
| 852 | 852 | |
| 853 | - $keys = $wpdb->get_col( " |
|
| 853 | + $keys = $wpdb->get_col(" |
|
| 854 | 854 | SELECT meta_key |
| 855 | 855 | FROM $wpdb->postmeta |
| 856 | 856 | GROUP BY meta_key |
| 857 | - ORDER BY meta_key" ); |
|
| 857 | + ORDER BY meta_key"); |
|
| 858 | 858 | |
| 859 | 859 | return $keys; |
| 860 | 860 | } |
@@ -867,8 +867,8 @@ discard block |
||
| 867 | 867 | * @param int $mid |
| 868 | 868 | * @return object|bool |
| 869 | 869 | */ |
| 870 | -function get_post_meta_by_id( $mid ) { |
|
| 871 | - return get_metadata_by_mid( 'post', $mid ); |
|
| 870 | +function get_post_meta_by_id($mid) { |
|
| 871 | + return get_metadata_by_mid('post', $mid); |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | /** |
@@ -881,12 +881,12 @@ discard block |
||
| 881 | 881 | * @param int $postid |
| 882 | 882 | * @return mixed |
| 883 | 883 | */ |
| 884 | -function has_meta( $postid ) { |
|
| 884 | +function has_meta($postid) { |
|
| 885 | 885 | global $wpdb; |
| 886 | 886 | |
| 887 | - return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id |
|
| 887 | + return $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id |
|
| 888 | 888 | FROM $wpdb->postmeta WHERE post_id = %d |
| 889 | - ORDER BY meta_key,meta_id", $postid), ARRAY_A ); |
|
| 889 | + ORDER BY meta_key,meta_id", $postid), ARRAY_A); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | /** |
@@ -899,11 +899,11 @@ discard block |
||
| 899 | 899 | * @param string $meta_value Expect Slashed |
| 900 | 900 | * @return bool |
| 901 | 901 | */ |
| 902 | -function update_meta( $meta_id, $meta_key, $meta_value ) { |
|
| 903 | - $meta_key = wp_unslash( $meta_key ); |
|
| 904 | - $meta_value = wp_unslash( $meta_value ); |
|
| 902 | +function update_meta($meta_id, $meta_key, $meta_value) { |
|
| 903 | + $meta_key = wp_unslash($meta_key); |
|
| 904 | + $meta_value = wp_unslash($meta_value); |
|
| 905 | 905 | |
| 906 | - return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key ); |
|
| 906 | + return update_metadata_by_mid('post', $meta_id, $meta_value, $meta_key); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | // |
@@ -919,42 +919,42 @@ discard block |
||
| 919 | 919 | * @param int|object $post Post ID or post object. |
| 920 | 920 | * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success. |
| 921 | 921 | */ |
| 922 | -function _fix_attachment_links( $post ) { |
|
| 923 | - $post = get_post( $post, ARRAY_A ); |
|
| 922 | +function _fix_attachment_links($post) { |
|
| 923 | + $post = get_post($post, ARRAY_A); |
|
| 924 | 924 | $content = $post['post_content']; |
| 925 | 925 | |
| 926 | 926 | // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. |
| 927 | - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) |
|
| 927 | + if ( ! get_option('permalink_structure') || ! in_array($post['post_status'], array('publish', 'future', 'private'))) |
|
| 928 | 928 | return; |
| 929 | 929 | |
| 930 | 930 | // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) |
| 931 | - if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) |
|
| 931 | + if ( ! strpos($content, '?attachment_id=') || ! preg_match_all('/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches)) |
|
| 932 | 932 | return; |
| 933 | 933 | |
| 934 | 934 | $site_url = get_bloginfo('url'); |
| 935 | - $site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s) |
|
| 935 | + $site_url = substr($site_url, (int) strpos($site_url, '://')); // remove the http(s) |
|
| 936 | 936 | $replace = ''; |
| 937 | 937 | |
| 938 | - foreach ( $link_matches[1] as $key => $value ) { |
|
| 939 | - if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') |
|
| 940 | - || !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) |
|
| 941 | - || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) |
|
| 938 | + foreach ($link_matches[1] as $key => $value) { |
|
| 939 | + if ( ! strpos($value, '?attachment_id=') || ! strpos($value, 'wp-att-') |
|
| 940 | + || ! preg_match('/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match) |
|
| 941 | + || ! preg_match('/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match)) |
|
| 942 | 942 | continue; |
| 943 | 943 | |
| 944 | 944 | $quote = $url_match[1]; // the quote (single or double) |
| 945 | 945 | $url_id = (int) $url_match[2]; |
| 946 | 946 | $rel_id = (int) $rel_match[1]; |
| 947 | 947 | |
| 948 | - if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) |
|
| 948 | + if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false) |
|
| 949 | 949 | continue; |
| 950 | 950 | |
| 951 | 951 | $link = $link_matches[0][$key]; |
| 952 | - $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); |
|
| 952 | + $replace = str_replace($url_match[0], 'href='.$quote.get_attachment_link($url_id).$quote, $link); |
|
| 953 | 953 | |
| 954 | - $content = str_replace( $link, $replace, $content ); |
|
| 954 | + $content = str_replace($link, $replace, $content); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - if ( $replace ) { |
|
| 957 | + if ($replace) { |
|
| 958 | 958 | $post['post_content'] = $content; |
| 959 | 959 | // Escape data pulled from DB. |
| 960 | 960 | $post = add_magic_quotes($post); |
@@ -985,40 +985,40 @@ discard block |
||
| 985 | 985 | * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal. |
| 986 | 986 | * @return array |
| 987 | 987 | */ |
| 988 | -function wp_edit_posts_query( $q = false ) { |
|
| 989 | - if ( false === $q ) |
|
| 988 | +function wp_edit_posts_query($q = false) { |
|
| 989 | + if (false === $q) |
|
| 990 | 990 | $q = $_GET; |
| 991 | 991 | $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
| 992 | 992 | $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
| 993 | - $post_stati = get_post_stati(); |
|
| 993 | + $post_stati = get_post_stati(); |
|
| 994 | 994 | |
| 995 | - if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) |
|
| 995 | + if (isset($q['post_type']) && in_array($q['post_type'], get_post_types())) |
|
| 996 | 996 | $post_type = $q['post_type']; |
| 997 | 997 | else |
| 998 | 998 | $post_type = 'post'; |
| 999 | 999 | |
| 1000 | 1000 | $avail_post_stati = get_available_post_statuses($post_type); |
| 1001 | 1001 | |
| 1002 | - if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) { |
|
| 1002 | + if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) { |
|
| 1003 | 1003 | $post_status = $q['post_status']; |
| 1004 | 1004 | $perm = 'readable'; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | - if ( isset( $q['orderby'] ) ) { |
|
| 1007 | + if (isset($q['orderby'])) { |
|
| 1008 | 1008 | $orderby = $q['orderby']; |
| 1009 | - } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) { |
|
| 1009 | + } elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'))) { |
|
| 1010 | 1010 | $orderby = 'modified'; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - if ( isset( $q['order'] ) ) { |
|
| 1013 | + if (isset($q['order'])) { |
|
| 1014 | 1014 | $order = $q['order']; |
| 1015 | - } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) { |
|
| 1015 | + } elseif (isset($q['post_status']) && 'pending' == $q['post_status']) { |
|
| 1016 | 1016 | $order = 'ASC'; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | $per_page = "edit_{$post_type}_per_page"; |
| 1020 | - $posts_per_page = (int) get_user_option( $per_page ); |
|
| 1021 | - if ( empty( $posts_per_page ) || $posts_per_page < 1 ) |
|
| 1020 | + $posts_per_page = (int) get_user_option($per_page); |
|
| 1021 | + if (empty($posts_per_page) || $posts_per_page < 1) |
|
| 1022 | 1022 | $posts_per_page = 20; |
| 1023 | 1023 | |
| 1024 | 1024 | /** |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | * @param int $posts_per_page Number of posts to display per page for the given post |
| 1035 | 1035 | * type. Default 20. |
| 1036 | 1036 | */ |
| 1037 | - $posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page ); |
|
| 1037 | + $posts_per_page = apply_filters("edit_{$post_type}_per_page", $posts_per_page); |
|
| 1038 | 1038 | |
| 1039 | 1039 | /** |
| 1040 | 1040 | * Filter the number of posts displayed per page when specifically listing "posts". |
@@ -1044,12 +1044,12 @@ discard block |
||
| 1044 | 1044 | * @param int $posts_per_page Number of posts to be displayed. Default 20. |
| 1045 | 1045 | * @param string $post_type The post type. |
| 1046 | 1046 | */ |
| 1047 | - $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type ); |
|
| 1047 | + $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type); |
|
| 1048 | 1048 | |
| 1049 | 1049 | $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page'); |
| 1050 | 1050 | |
| 1051 | 1051 | // Hierarchical types require special args. |
| 1052 | - if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) { |
|
| 1052 | + if (is_post_type_hierarchical($post_type) && ! isset($orderby)) { |
|
| 1053 | 1053 | $query['orderby'] = 'menu_order title'; |
| 1054 | 1054 | $query['order'] = 'asc'; |
| 1055 | 1055 | $query['posts_per_page'] = -1; |
@@ -1057,10 +1057,10 @@ discard block |
||
| 1057 | 1057 | $query['fields'] = 'id=>parent'; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - if ( ! empty( $q['show_sticky'] ) ) |
|
| 1061 | - $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
| 1060 | + if ( ! empty($q['show_sticky'])) |
|
| 1061 | + $query['post__in'] = (array) get_option('sticky_posts'); |
|
| 1062 | 1062 | |
| 1063 | - wp( $query ); |
|
| 1063 | + wp($query); |
|
| 1064 | 1064 | |
| 1065 | 1065 | return $avail_post_stati; |
| 1066 | 1066 | } |
@@ -1091,24 +1091,24 @@ discard block |
||
| 1091 | 1091 | * to use $_GET superglobal. Default false. |
| 1092 | 1092 | * @return array The parsed query vars. |
| 1093 | 1093 | */ |
| 1094 | -function wp_edit_attachments_query_vars( $q = false ) { |
|
| 1095 | - if ( false === $q ) { |
|
| 1094 | +function wp_edit_attachments_query_vars($q = false) { |
|
| 1095 | + if (false === $q) { |
|
| 1096 | 1096 | $q = $_GET; |
| 1097 | 1097 | } |
| 1098 | - $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; |
|
| 1099 | - $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; |
|
| 1098 | + $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
|
| 1099 | + $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
|
| 1100 | 1100 | $q['post_type'] = 'attachment'; |
| 1101 | - $post_type = get_post_type_object( 'attachment' ); |
|
| 1101 | + $post_type = get_post_type_object('attachment'); |
|
| 1102 | 1102 | $states = 'inherit'; |
| 1103 | - if ( current_user_can( $post_type->cap->read_private_posts ) ) { |
|
| 1103 | + if (current_user_can($post_type->cap->read_private_posts)) { |
|
| 1104 | 1104 | $states .= ',private'; |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | - $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states; |
|
| 1108 | - $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; |
|
| 1107 | + $q['post_status'] = isset($q['status']) && 'trash' == $q['status'] ? 'trash' : $states; |
|
| 1108 | + $q['post_status'] = isset($q['attachment-filter']) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; |
|
| 1109 | 1109 | |
| 1110 | - $media_per_page = (int) get_user_option( 'upload_per_page' ); |
|
| 1111 | - if ( empty( $media_per_page ) || $media_per_page < 1 ) { |
|
| 1110 | + $media_per_page = (int) get_user_option('upload_per_page'); |
|
| 1111 | + if (empty($media_per_page) || $media_per_page < 1) { |
|
| 1112 | 1112 | $media_per_page = 20; |
| 1113 | 1113 | } |
| 1114 | 1114 | |
@@ -1119,21 +1119,21 @@ discard block |
||
| 1119 | 1119 | * |
| 1120 | 1120 | * @param int $media_per_page Number of media to list. Default 20. |
| 1121 | 1121 | */ |
| 1122 | - $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page ); |
|
| 1122 | + $q['posts_per_page'] = apply_filters('upload_per_page', $media_per_page); |
|
| 1123 | 1123 | |
| 1124 | 1124 | $post_mime_types = get_post_mime_types(); |
| 1125 | - if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) { |
|
| 1125 | + if (isset($q['post_mime_type']) && ! array_intersect((array) $q['post_mime_type'], array_keys($post_mime_types))) { |
|
| 1126 | 1126 | unset($q['post_mime_type']); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - foreach ( array_keys( $post_mime_types ) as $type ) { |
|
| 1130 | - if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) { |
|
| 1129 | + foreach (array_keys($post_mime_types) as $type) { |
|
| 1130 | + if (isset($q['attachment-filter']) && "post_mime_type:$type" == $q['attachment-filter']) { |
|
| 1131 | 1131 | $q['post_mime_type'] = $type; |
| 1132 | 1132 | break; |
| 1133 | 1133 | } |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | - if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) { |
|
| 1136 | + if (isset($q['detached']) || (isset($q['attachment-filter']) && 'detached' == $q['attachment-filter'])) { |
|
| 1137 | 1137 | $q['post_parent'] = 0; |
| 1138 | 1138 | } |
| 1139 | 1139 | |
@@ -1149,13 +1149,13 @@ discard block |
||
| 1149 | 1149 | * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal. |
| 1150 | 1150 | * @return array |
| 1151 | 1151 | */ |
| 1152 | -function wp_edit_attachments_query( $q = false ) { |
|
| 1153 | - wp( wp_edit_attachments_query_vars( $q ) ); |
|
| 1152 | +function wp_edit_attachments_query($q = false) { |
|
| 1153 | + wp(wp_edit_attachments_query_vars($q)); |
|
| 1154 | 1154 | |
| 1155 | 1155 | $post_mime_types = get_post_mime_types(); |
| 1156 | - $avail_post_mime_types = get_available_post_mime_types( 'attachment' ); |
|
| 1156 | + $avail_post_mime_types = get_available_post_mime_types('attachment'); |
|
| 1157 | 1157 | |
| 1158 | - return array( $post_mime_types, $avail_post_mime_types ); |
|
| 1158 | + return array($post_mime_types, $avail_post_mime_types); |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | /** |
@@ -1167,17 +1167,17 @@ discard block |
||
| 1167 | 1167 | * @param string $page |
| 1168 | 1168 | * @return string |
| 1169 | 1169 | */ |
| 1170 | -function postbox_classes( $id, $page ) { |
|
| 1171 | - if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) { |
|
| 1172 | - $classes = array( '' ); |
|
| 1173 | - } elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) { |
|
| 1174 | - if ( !is_array( $closed ) ) { |
|
| 1175 | - $classes = array( '' ); |
|
| 1170 | +function postbox_classes($id, $page) { |
|
| 1171 | + if (isset($_GET['edit']) && $_GET['edit'] == $id) { |
|
| 1172 | + $classes = array(''); |
|
| 1173 | + } elseif ($closed = get_user_option('closedpostboxes_'.$page)) { |
|
| 1174 | + if ( ! is_array($closed)) { |
|
| 1175 | + $classes = array(''); |
|
| 1176 | 1176 | } else { |
| 1177 | - $classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' ); |
|
| 1177 | + $classes = in_array($id, $closed) ? array('closed') : array(''); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | } else { |
| 1180 | - $classes = array( '' ); |
|
| 1180 | + $classes = array(''); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | /** |
@@ -1190,8 +1190,8 @@ discard block |
||
| 1190 | 1190 | * |
| 1191 | 1191 | * @param array $classes An array of postbox classes. |
| 1192 | 1192 | */ |
| 1193 | - $classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes ); |
|
| 1194 | - return implode( ' ', $classes ); |
|
| 1193 | + $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes); |
|
| 1194 | + return implode(' ', $classes); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1205,9 +1205,9 @@ discard block |
||
| 1205 | 1205 | * @return array Array with two entries of type string. |
| 1206 | 1206 | */ |
| 1207 | 1207 | function get_sample_permalink($id, $title = null, $name = null) { |
| 1208 | - $post = get_post( $id ); |
|
| 1209 | - if ( ! $post ) |
|
| 1210 | - return array( '', '' ); |
|
| 1208 | + $post = get_post($id); |
|
| 1209 | + if ( ! $post) |
|
| 1210 | + return array('', ''); |
|
| 1211 | 1211 | |
| 1212 | 1212 | $ptype = get_post_type_object($post->post_type); |
| 1213 | 1213 | |
@@ -1216,14 +1216,14 @@ discard block |
||
| 1216 | 1216 | $original_name = $post->post_name; |
| 1217 | 1217 | |
| 1218 | 1218 | // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published. |
| 1219 | - if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) { |
|
| 1219 | + if (in_array($post->post_status, array('draft', 'pending', 'future'))) { |
|
| 1220 | 1220 | $post->post_status = 'publish'; |
| 1221 | 1221 | $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | // If the user wants to set a new name -- override the current one |
| 1225 | 1225 | // Note: if empty name is supplied -- use the title instead, see #6072 |
| 1226 | - if ( !is_null($name) ) |
|
| 1226 | + if ( ! is_null($name)) |
|
| 1227 | 1227 | $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
| 1228 | 1228 | |
| 1229 | 1229 | $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); |
@@ -1236,23 +1236,23 @@ discard block |
||
| 1236 | 1236 | $permalink = str_replace("%$post->post_type%", '%pagename%', $permalink); |
| 1237 | 1237 | |
| 1238 | 1238 | // Handle page hierarchy |
| 1239 | - if ( $ptype->hierarchical ) { |
|
| 1239 | + if ($ptype->hierarchical) { |
|
| 1240 | 1240 | $uri = get_page_uri($post); |
| 1241 | - if ( $uri ) { |
|
| 1241 | + if ($uri) { |
|
| 1242 | 1242 | $uri = untrailingslashit($uri); |
| 1243 | - $uri = strrev( stristr( strrev( $uri ), '/' ) ); |
|
| 1243 | + $uri = strrev(stristr(strrev($uri), '/')); |
|
| 1244 | 1244 | $uri = untrailingslashit($uri); |
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 1248 | - $uri = apply_filters( 'editable_slug', $uri, $post ); |
|
| 1249 | - if ( !empty($uri) ) |
|
| 1248 | + $uri = apply_filters('editable_slug', $uri, $post); |
|
| 1249 | + if ( ! empty($uri)) |
|
| 1250 | 1250 | $uri .= '/'; |
| 1251 | 1251 | $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 1255 | - $permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) ); |
|
| 1255 | + $permalink = array($permalink, apply_filters('editable_slug', $post->post_name, $post)); |
|
| 1256 | 1256 | $post->post_status = $original_status; |
| 1257 | 1257 | $post->post_date = $original_date; |
| 1258 | 1258 | $post->post_name = $original_name; |
@@ -1269,7 +1269,7 @@ discard block |
||
| 1269 | 1269 | * @param string $name Post name (slug). |
| 1270 | 1270 | * @param WP_Post $post Post object. |
| 1271 | 1271 | */ |
| 1272 | - return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post ); |
|
| 1272 | + return apply_filters('get_sample_permalink', $permalink, $post->ID, $title, $name, $post); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | /** |
@@ -1282,9 +1282,9 @@ discard block |
||
| 1282 | 1282 | * @param string $new_slug Optional. New slug. Default null. |
| 1283 | 1283 | * @return string The HTML of the sample permalink slug editor. |
| 1284 | 1284 | */ |
| 1285 | -function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
|
| 1286 | - $post = get_post( $id ); |
|
| 1287 | - if ( ! $post ) |
|
| 1285 | +function get_sample_permalink_html($id, $new_title = null, $new_slug = null) { |
|
| 1286 | + $post = get_post($id); |
|
| 1287 | + if ( ! $post) |
|
| 1288 | 1288 | return ''; |
| 1289 | 1289 | |
| 1290 | 1290 | list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
@@ -1292,58 +1292,58 @@ discard block |
||
| 1292 | 1292 | $view_link = false; |
| 1293 | 1293 | $preview_target = ''; |
| 1294 | 1294 | |
| 1295 | - if ( current_user_can( 'read_post', $post->ID ) ) { |
|
| 1296 | - if ( 'draft' === $post->post_status ) { |
|
| 1297 | - $view_link = get_preview_post_link( $post ); |
|
| 1295 | + if (current_user_can('read_post', $post->ID)) { |
|
| 1296 | + if ('draft' === $post->post_status) { |
|
| 1297 | + $view_link = get_preview_post_link($post); |
|
| 1298 | 1298 | $preview_target = " target='wp-preview-{$post->ID}'"; |
| 1299 | 1299 | } else { |
| 1300 | - if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) { |
|
| 1301 | - $view_link = get_permalink( $post ); |
|
| 1300 | + if ('publish' === $post->post_status || 'attachment' === $post->post_type) { |
|
| 1301 | + $view_link = get_permalink($post); |
|
| 1302 | 1302 | } else { |
| 1303 | 1303 | // Allow non-published (private, future) to be viewed at a pretty permalink. |
| 1304 | - $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink ); |
|
| 1304 | + $view_link = str_replace(array('%pagename%', '%postname%'), $post->post_name, $permalink); |
|
| 1305 | 1305 | } |
| 1306 | 1306 | } |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | // Permalinks without a post/page name placeholder don't have anything to edit |
| 1310 | - if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { |
|
| 1311 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
| 1310 | + if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { |
|
| 1311 | + $return = '<strong>'.__('Permalink:')."</strong>\n"; |
|
| 1312 | 1312 | |
| 1313 | - if ( false !== $view_link ) { |
|
| 1314 | - $display_link = urldecode( $view_link ); |
|
| 1315 | - $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a>\n"; |
|
| 1313 | + if (false !== $view_link) { |
|
| 1314 | + $display_link = urldecode($view_link); |
|
| 1315 | + $return .= '<a id="sample-permalink" href="'.esc_url($view_link).'"'.$preview_target.'>'.$display_link."</a>\n"; |
|
| 1316 | 1316 | } else { |
| 1317 | - $return .= '<span id="sample-permalink">' . $permalink . "</span>\n"; |
|
| 1317 | + $return .= '<span id="sample-permalink">'.$permalink."</span>\n"; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | // Encourage a pretty permalink setting |
| 1321 | - if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { |
|
| 1322 | - $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; |
|
| 1321 | + if ('' == get_option('permalink_structure') && current_user_can('manage_options') && ! ('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) { |
|
| 1322 | + $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">'.__('Change Permalinks')."</a></span>\n"; |
|
| 1323 | 1323 | } |
| 1324 | 1324 | } else { |
| 1325 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 1326 | - if ( mb_strlen( $post_name ) > 34 ) { |
|
| 1327 | - $post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 ); |
|
| 1325 | + if (function_exists('mb_strlen')) { |
|
| 1326 | + if (mb_strlen($post_name) > 34) { |
|
| 1327 | + $post_name_abridged = mb_substr($post_name, 0, 16).'…'.mb_substr($post_name, -16); |
|
| 1328 | 1328 | } else { |
| 1329 | 1329 | $post_name_abridged = $post_name; |
| 1330 | 1330 | } |
| 1331 | 1331 | } else { |
| 1332 | - if ( strlen( $post_name ) > 34 ) { |
|
| 1333 | - $post_name_abridged = substr( $post_name, 0, 16 ) . '…' . substr( $post_name, -16 ); |
|
| 1332 | + if (strlen($post_name) > 34) { |
|
| 1333 | + $post_name_abridged = substr($post_name, 0, 16).'…'.substr($post_name, -16); |
|
| 1334 | 1334 | } else { |
| 1335 | 1335 | $post_name_abridged = $post_name; |
| 1336 | 1336 | } |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | - $post_name_html = '<span id="editable-post-name">' . $post_name_abridged . '</span>'; |
|
| 1340 | - $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) ); |
|
| 1339 | + $post_name_html = '<span id="editable-post-name">'.$post_name_abridged.'</span>'; |
|
| 1340 | + $display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, urldecode($permalink)); |
|
| 1341 | 1341 | |
| 1342 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
| 1343 | - $return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n"; |
|
| 1342 | + $return = '<strong>'.__('Permalink:')."</strong>\n"; |
|
| 1343 | + $return .= '<span id="sample-permalink"><a href="'.esc_url($view_link).'"'.$preview_target.'>'.$display_link."</a></span>\n"; |
|
| 1344 | 1344 | $return .= '‎'; // Fix bi-directional text display defect in RTL languages. |
| 1345 | - $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __( 'Edit permalink' ) . '">' . __( 'Edit' ) . "</button></span>\n"; |
|
| 1346 | - $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; |
|
| 1345 | + $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="'.__('Edit permalink').'">'.__('Edit')."</button></span>\n"; |
|
| 1346 | + $return .= '<span id="editable-post-name-full">'.$post_name."</span>\n"; |
|
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | /** |
@@ -1358,7 +1358,7 @@ discard block |
||
| 1358 | 1358 | * @param string $new_slug New sample permalink slug. |
| 1359 | 1359 | * @param WP_Post $post Post object. |
| 1360 | 1360 | */ |
| 1361 | - $return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post ); |
|
| 1361 | + $return = apply_filters('get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post); |
|
| 1362 | 1362 | |
| 1363 | 1363 | return $return; |
| 1364 | 1364 | } |
@@ -1375,22 +1375,22 @@ discard block |
||
| 1375 | 1375 | * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. |
| 1376 | 1376 | * @return string html |
| 1377 | 1377 | */ |
| 1378 | -function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { |
|
| 1378 | +function _wp_post_thumbnail_html($thumbnail_id = null, $post = null) { |
|
| 1379 | 1379 | global $content_width, $_wp_additional_image_sizes; |
| 1380 | 1380 | |
| 1381 | - $post = get_post( $post ); |
|
| 1382 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1381 | + $post = get_post($post); |
|
| 1382 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1383 | 1383 | $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>'; |
| 1384 | - $upload_iframe_src = get_upload_iframe_src( 'image', $post->ID ); |
|
| 1384 | + $upload_iframe_src = get_upload_iframe_src('image', $post->ID); |
|
| 1385 | 1385 | |
| 1386 | - $content = sprintf( $set_thumbnail_link, |
|
| 1387 | - esc_url( $upload_iframe_src ), |
|
| 1386 | + $content = sprintf($set_thumbnail_link, |
|
| 1387 | + esc_url($upload_iframe_src), |
|
| 1388 | 1388 | '', // Empty when there's no featured image set, `aria-describedby` attribute otherwise. |
| 1389 | - esc_html( $post_type_object->labels->set_featured_image ) |
|
| 1389 | + esc_html($post_type_object->labels->set_featured_image) |
|
| 1390 | 1390 | ); |
| 1391 | 1391 | |
| 1392 | - if ( $thumbnail_id && get_post( $thumbnail_id ) ) { |
|
| 1393 | - $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 ); |
|
| 1392 | + if ($thumbnail_id && get_post($thumbnail_id)) { |
|
| 1393 | + $size = isset($_wp_additional_image_sizes['post-thumbnail']) ? 'post-thumbnail' : array(266, 266); |
|
| 1394 | 1394 | |
| 1395 | 1395 | /** |
| 1396 | 1396 | * Filter the size used to display the post thumbnail image in the 'Featured Image' meta box. |
@@ -1409,19 +1409,19 @@ discard block |
||
| 1409 | 1409 | * @param int $thumbnail_id Post thumbnail attachment ID. |
| 1410 | 1410 | * @param WP_Post $post The post object associated with the thumbnail. |
| 1411 | 1411 | */ |
| 1412 | - $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post ); |
|
| 1412 | + $size = apply_filters('admin_post_thumbnail_size', $size, $thumbnail_id, $post); |
|
| 1413 | 1413 | |
| 1414 | - $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size ); |
|
| 1414 | + $thumbnail_html = wp_get_attachment_image($thumbnail_id, $size); |
|
| 1415 | 1415 | |
| 1416 | - if ( !empty( $thumbnail_html ) ) { |
|
| 1417 | - $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); |
|
| 1418 | - $content = sprintf( $set_thumbnail_link, |
|
| 1419 | - esc_url( $upload_iframe_src ), |
|
| 1416 | + if ( ! empty($thumbnail_html)) { |
|
| 1417 | + $ajax_nonce = wp_create_nonce('set_post_thumbnail-'.$post->ID); |
|
| 1418 | + $content = sprintf($set_thumbnail_link, |
|
| 1419 | + esc_url($upload_iframe_src), |
|
| 1420 | 1420 | ' aria-describedby="set-post-thumbnail-desc"', |
| 1421 | 1421 | $thumbnail_html |
| 1422 | 1422 | ); |
| 1423 | - $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>'; |
|
| 1424 | - $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>'; |
|
| 1423 | + $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">'.__('Click the image to edit or update').'</p>'; |
|
| 1424 | + $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\''.$ajax_nonce.'\');return false;">'.esc_html($post_type_object->labels->remove_featured_image).'</a></p>'; |
|
| 1425 | 1425 | } |
| 1426 | 1426 | } |
| 1427 | 1427 | |
@@ -1433,7 +1433,7 @@ discard block |
||
| 1433 | 1433 | * @param string $content Admin post thumbnail HTML markup. |
| 1434 | 1434 | * @param int $post_id Post ID. |
| 1435 | 1435 | */ |
| 1436 | - return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID ); |
|
| 1436 | + return apply_filters('admin_post_thumbnail_html', $content, $post->ID); |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | /** |
@@ -1444,21 +1444,21 @@ discard block |
||
| 1444 | 1444 | * @param int $post_id ID of the post to check for editing |
| 1445 | 1445 | * @return integer False: not locked or locked by current user. Int: user ID of user with lock. |
| 1446 | 1446 | */ |
| 1447 | -function wp_check_post_lock( $post_id ) { |
|
| 1448 | - if ( !$post = get_post( $post_id ) ) |
|
| 1447 | +function wp_check_post_lock($post_id) { |
|
| 1448 | + if ( ! $post = get_post($post_id)) |
|
| 1449 | 1449 | return false; |
| 1450 | 1450 | |
| 1451 | - if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) |
|
| 1451 | + if ( ! $lock = get_post_meta($post->ID, '_edit_lock', true)) |
|
| 1452 | 1452 | return false; |
| 1453 | 1453 | |
| 1454 | - $lock = explode( ':', $lock ); |
|
| 1454 | + $lock = explode(':', $lock); |
|
| 1455 | 1455 | $time = $lock[0]; |
| 1456 | - $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); |
|
| 1456 | + $user = isset($lock[1]) ? $lock[1] : get_post_meta($post->ID, '_edit_last', true); |
|
| 1457 | 1457 | |
| 1458 | 1458 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
| 1459 | - $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); |
|
| 1459 | + $time_window = apply_filters('wp_check_post_lock_window', 150); |
|
| 1460 | 1460 | |
| 1461 | - if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) |
|
| 1461 | + if ($time && $time > time() - $time_window && $user != get_current_user_id()) |
|
| 1462 | 1462 | return $user; |
| 1463 | 1463 | return false; |
| 1464 | 1464 | } |
@@ -1472,17 +1472,17 @@ discard block |
||
| 1472 | 1472 | * @return bool|array Returns false if the post doesn't exist of there is no current user, or |
| 1473 | 1473 | * an array of the lock time and the user ID. |
| 1474 | 1474 | */ |
| 1475 | -function wp_set_post_lock( $post_id ) { |
|
| 1476 | - if ( !$post = get_post( $post_id ) ) |
|
| 1475 | +function wp_set_post_lock($post_id) { |
|
| 1476 | + if ( ! $post = get_post($post_id)) |
|
| 1477 | 1477 | return false; |
| 1478 | - if ( 0 == ($user_id = get_current_user_id()) ) |
|
| 1478 | + if (0 == ($user_id = get_current_user_id())) |
|
| 1479 | 1479 | return false; |
| 1480 | 1480 | |
| 1481 | 1481 | $now = time(); |
| 1482 | 1482 | $lock = "$now:$user_id"; |
| 1483 | 1483 | |
| 1484 | - update_post_meta( $post->ID, '_edit_lock', $lock ); |
|
| 1485 | - return array( $now, $user_id ); |
|
| 1484 | + update_post_meta($post->ID, '_edit_lock', $lock); |
|
| 1485 | + return array($now, $user_id); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | /** |
@@ -1492,14 +1492,14 @@ discard block |
||
| 1492 | 1492 | * @return none |
| 1493 | 1493 | */ |
| 1494 | 1494 | function _admin_notice_post_locked() { |
| 1495 | - if ( ! $post = get_post() ) |
|
| 1495 | + if ( ! $post = get_post()) |
|
| 1496 | 1496 | return; |
| 1497 | 1497 | |
| 1498 | 1498 | $user = null; |
| 1499 | - if ( $user_id = wp_check_post_lock( $post->ID ) ) |
|
| 1500 | - $user = get_userdata( $user_id ); |
|
| 1499 | + if ($user_id = wp_check_post_lock($post->ID)) |
|
| 1500 | + $user = get_userdata($user_id); |
|
| 1501 | 1501 | |
| 1502 | - if ( $user ) { |
|
| 1502 | + if ($user) { |
|
| 1503 | 1503 | |
| 1504 | 1504 | /** |
| 1505 | 1505 | * Filter whether to show the post locked dialog. |
@@ -1511,7 +1511,7 @@ discard block |
||
| 1511 | 1511 | * @param bool $display Whether to display the dialog. Default true. |
| 1512 | 1512 | * @param WP_User|bool $user WP_User object on success, false otherwise. |
| 1513 | 1513 | */ |
| 1514 | - if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) |
|
| 1514 | + if ( ! apply_filters('show_post_locked_dialog', true, $post, $user)) |
|
| 1515 | 1515 | return; |
| 1516 | 1516 | |
| 1517 | 1517 | $locked = true; |
@@ -1519,17 +1519,17 @@ discard block |
||
| 1519 | 1519 | $locked = false; |
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | - if ( $locked && ( $sendback = wp_get_referer() ) && |
|
| 1523 | - false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) { |
|
| 1522 | + if ($locked && ($sendback = wp_get_referer()) && |
|
| 1523 | + false === strpos($sendback, 'post.php') && false === strpos($sendback, 'post-new.php')) { |
|
| 1524 | 1524 | |
| 1525 | 1525 | $sendback_text = __('Go back'); |
| 1526 | 1526 | } else { |
| 1527 | - $sendback = admin_url( 'edit.php' ); |
|
| 1527 | + $sendback = admin_url('edit.php'); |
|
| 1528 | 1528 | |
| 1529 | - if ( 'post' != $post->post_type ) |
|
| 1530 | - $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
| 1529 | + if ('post' != $post->post_type) |
|
| 1530 | + $sendback = add_query_arg('post_type', $post->post_type, $sendback); |
|
| 1531 | 1531 | |
| 1532 | - $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; |
|
| 1532 | + $sendback_text = get_post_type_object($post->post_type)->labels->all_items; |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | $hidden = $locked ? '' : ' hidden'; |
@@ -1540,18 +1540,18 @@ discard block |
||
| 1540 | 1540 | <div class="notification-dialog"> |
| 1541 | 1541 | <?php |
| 1542 | 1542 | |
| 1543 | - if ( $locked ) { |
|
| 1543 | + if ($locked) { |
|
| 1544 | 1544 | $query_args = array(); |
| 1545 | - if ( get_post_type_object( $post->post_type )->public ) { |
|
| 1546 | - if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) { |
|
| 1545 | + if (get_post_type_object($post->post_type)->public) { |
|
| 1546 | + if ('publish' == $post->post_status || $user->ID != $post->post_author) { |
|
| 1547 | 1547 | // Latest content is in autosave |
| 1548 | - $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
| 1548 | + $nonce = wp_create_nonce('post_preview_'.$post->ID); |
|
| 1549 | 1549 | $query_args['preview_id'] = $post->ID; |
| 1550 | 1550 | $query_args['preview_nonce'] = $nonce; |
| 1551 | 1551 | } |
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | - $preview_link = get_preview_post_link( $post->ID, $query_args ); |
|
| 1554 | + $preview_link = get_preview_post_link($post->ID, $query_args); |
|
| 1555 | 1555 | |
| 1556 | 1556 | /** |
| 1557 | 1557 | * Filter whether to allow the post lock to be overridden. |
@@ -1565,17 +1565,17 @@ discard block |
||
| 1565 | 1565 | * @param WP_Post $post Post object. |
| 1566 | 1566 | * @param WP_User $user User object. |
| 1567 | 1567 | */ |
| 1568 | - $override = apply_filters( 'override_post_lock', true, $post, $user ); |
|
| 1568 | + $override = apply_filters('override_post_lock', true, $post, $user); |
|
| 1569 | 1569 | $tab_last = $override ? '' : ' wp-tab-last'; |
| 1570 | 1570 | |
| 1571 | 1571 | ?> |
| 1572 | 1572 | <div class="post-locked-message"> |
| 1573 | - <div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div> |
|
| 1573 | + <div class="post-locked-avatar"><?php echo get_avatar($user->ID, 64); ?></div> |
|
| 1574 | 1574 | <p class="currently-editing wp-tab-first" tabindex="0"> |
| 1575 | 1575 | <?php |
| 1576 | - _e( 'This content is currently locked.' ); |
|
| 1577 | - if ( $override ) |
|
| 1578 | - printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
| 1576 | + _e('This content is currently locked.'); |
|
| 1577 | + if ($override) |
|
| 1578 | + printf(' '.__('If you take over, %s will be blocked from continuing to edit.'), esc_html($user->display_name)); |
|
| 1579 | 1579 | ?> |
| 1580 | 1580 | </p> |
| 1581 | 1581 | <?php |
@@ -1586,19 +1586,19 @@ discard block |
||
| 1586 | 1586 | * |
| 1587 | 1587 | * @param WP_Post $post Post object. |
| 1588 | 1588 | */ |
| 1589 | - do_action( 'post_locked_dialog', $post ); |
|
| 1589 | + do_action('post_locked_dialog', $post); |
|
| 1590 | 1590 | ?> |
| 1591 | 1591 | <p> |
| 1592 | - <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a> |
|
| 1593 | - <?php if ( $preview_link ) { ?> |
|
| 1594 | - <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a> |
|
| 1592 | + <a class="button" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a> |
|
| 1593 | + <?php if ($preview_link) { ?> |
|
| 1594 | + <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url($preview_link); ?>"><?php _e('Preview'); ?></a> |
|
| 1595 | 1595 | <?php |
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | 1598 | // Allow plugins to prevent some users overriding the post lock |
| 1599 | - if ( $override ) { |
|
| 1599 | + if ($override) { |
|
| 1600 | 1600 | ?> |
| 1601 | - <a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e('Take over'); ?></a> |
|
| 1601 | + <a class="button button-primary wp-tab-last" href="<?php echo esc_url(add_query_arg('get-post-lock', '1', wp_nonce_url(get_edit_post_link($post->ID, 'url'), 'lock-post_'.$post->ID))); ?>"><?php _e('Take over'); ?></a> |
|
| 1602 | 1602 | <?php |
| 1603 | 1603 | } |
| 1604 | 1604 | |
@@ -1612,7 +1612,7 @@ discard block |
||
| 1612 | 1612 | <div class="post-locked-avatar"></div> |
| 1613 | 1613 | <p class="wp-tab-first" tabindex="0"> |
| 1614 | 1614 | <span class="currently-editing"></span><br /> |
| 1615 | - <span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" alt="" /> <?php _e( 'Saving revision…' ); ?></span> |
|
| 1615 | + <span class="locked-saving hidden"><img src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" width="16" height="16" alt="" /> <?php _e('Saving revision…'); ?></span> |
|
| 1616 | 1616 | <span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span> |
| 1617 | 1617 | </p> |
| 1618 | 1618 | <?php |
@@ -1623,9 +1623,9 @@ discard block |
||
| 1623 | 1623 | * |
| 1624 | 1624 | * @param WP_Post $post Post object. |
| 1625 | 1625 | */ |
| 1626 | - do_action( 'post_lock_lost_dialog', $post ); |
|
| 1626 | + do_action('post_lock_lost_dialog', $post); |
|
| 1627 | 1627 | ?> |
| 1628 | - <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p> |
|
| 1628 | + <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a></p> |
|
| 1629 | 1629 | </div> |
| 1630 | 1630 | <?php |
| 1631 | 1631 | } |
@@ -1646,38 +1646,38 @@ discard block |
||
| 1646 | 1646 | * @param mixed $post_data Associative array containing the post data or int post ID. |
| 1647 | 1647 | * @return mixed The autosave revision ID. WP_Error or 0 on error. |
| 1648 | 1648 | */ |
| 1649 | -function wp_create_post_autosave( $post_data ) { |
|
| 1650 | - if ( is_numeric( $post_data ) ) { |
|
| 1649 | +function wp_create_post_autosave($post_data) { |
|
| 1650 | + if (is_numeric($post_data)) { |
|
| 1651 | 1651 | $post_id = $post_data; |
| 1652 | 1652 | $post_data = $_POST; |
| 1653 | 1653 | } else { |
| 1654 | 1654 | $post_id = (int) $post_data['post_ID']; |
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
| 1658 | - if ( is_wp_error( $post_data ) ) |
|
| 1657 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
| 1658 | + if (is_wp_error($post_data)) |
|
| 1659 | 1659 | return $post_data; |
| 1660 | 1660 | |
| 1661 | 1661 | $post_author = get_current_user_id(); |
| 1662 | 1662 | |
| 1663 | 1663 | // Store one autosave per author. If there is already an autosave, overwrite it. |
| 1664 | - if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) { |
|
| 1665 | - $new_autosave = _wp_post_revision_data( $post_data, true ); |
|
| 1664 | + if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) { |
|
| 1665 | + $new_autosave = _wp_post_revision_data($post_data, true); |
|
| 1666 | 1666 | $new_autosave['ID'] = $old_autosave->ID; |
| 1667 | 1667 | $new_autosave['post_author'] = $post_author; |
| 1668 | 1668 | |
| 1669 | 1669 | // If the new autosave has the same content as the post, delete the autosave. |
| 1670 | - $post = get_post( $post_id ); |
|
| 1670 | + $post = get_post($post_id); |
|
| 1671 | 1671 | $autosave_is_different = false; |
| 1672 | - foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { |
|
| 1673 | - if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { |
|
| 1672 | + foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields($post))) as $field) { |
|
| 1673 | + if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->$field)) { |
|
| 1674 | 1674 | $autosave_is_different = true; |
| 1675 | 1675 | break; |
| 1676 | 1676 | } |
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | - if ( ! $autosave_is_different ) { |
|
| 1680 | - wp_delete_post_revision( $old_autosave->ID ); |
|
| 1679 | + if ( ! $autosave_is_different) { |
|
| 1680 | + wp_delete_post_revision($old_autosave->ID); |
|
| 1681 | 1681 | return 0; |
| 1682 | 1682 | } |
| 1683 | 1683 | |
@@ -1688,16 +1688,16 @@ discard block |
||
| 1688 | 1688 | * |
| 1689 | 1689 | * @param array $new_autosave Post array - the autosave that is about to be saved. |
| 1690 | 1690 | */ |
| 1691 | - do_action( 'wp_creating_autosave', $new_autosave ); |
|
| 1691 | + do_action('wp_creating_autosave', $new_autosave); |
|
| 1692 | 1692 | |
| 1693 | - return wp_update_post( $new_autosave ); |
|
| 1693 | + return wp_update_post($new_autosave); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | // _wp_put_post_revision() expects unescaped. |
| 1697 | - $post_data = wp_unslash( $post_data ); |
|
| 1697 | + $post_data = wp_unslash($post_data); |
|
| 1698 | 1698 | |
| 1699 | 1699 | // Otherwise create the new autosave as a special post revision |
| 1700 | - return _wp_put_post_revision( $post_data, true ); |
|
| 1700 | + return _wp_put_post_revision($post_data, true); |
|
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | 1703 | /** |
@@ -1713,41 +1713,41 @@ discard block |
||
| 1713 | 1713 | $post_ID = (int) $_POST['post_ID']; |
| 1714 | 1714 | $_POST['ID'] = $post_ID; |
| 1715 | 1715 | |
| 1716 | - if ( ! $post = get_post( $post_ID ) ) { |
|
| 1717 | - wp_die( __( 'You are not allowed to edit this post.' ) ); |
|
| 1716 | + if ( ! $post = get_post($post_ID)) { |
|
| 1717 | + wp_die(__('You are not allowed to edit this post.')); |
|
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1721 | - wp_die( __( 'You are not allowed to edit this post.' ) ); |
|
| 1720 | + if ( ! current_user_can('edit_post', $post->ID)) { |
|
| 1721 | + wp_die(__('You are not allowed to edit this post.')); |
|
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | 1724 | $is_autosave = false; |
| 1725 | 1725 | |
| 1726 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) { |
|
| 1726 | + if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('draft' == $post->post_status || 'auto-draft' == $post->post_status)) { |
|
| 1727 | 1727 | $saved_post_id = edit_post(); |
| 1728 | 1728 | } else { |
| 1729 | 1729 | $is_autosave = true; |
| 1730 | 1730 | |
| 1731 | - if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) |
|
| 1731 | + if (isset($_POST['post_status']) && 'auto-draft' == $_POST['post_status']) |
|
| 1732 | 1732 | $_POST['post_status'] = 'draft'; |
| 1733 | 1733 | |
| 1734 | - $saved_post_id = wp_create_post_autosave( $post->ID ); |
|
| 1734 | + $saved_post_id = wp_create_post_autosave($post->ID); |
|
| 1735 | 1735 | } |
| 1736 | 1736 | |
| 1737 | - if ( is_wp_error( $saved_post_id ) ) |
|
| 1738 | - wp_die( $saved_post_id->get_error_message() ); |
|
| 1737 | + if (is_wp_error($saved_post_id)) |
|
| 1738 | + wp_die($saved_post_id->get_error_message()); |
|
| 1739 | 1739 | |
| 1740 | 1740 | $query_args = array(); |
| 1741 | 1741 | |
| 1742 | - if ( $is_autosave && $saved_post_id ) { |
|
| 1742 | + if ($is_autosave && $saved_post_id) { |
|
| 1743 | 1743 | $query_args['preview_id'] = $post->ID; |
| 1744 | - $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
| 1744 | + $query_args['preview_nonce'] = wp_create_nonce('post_preview_'.$post->ID); |
|
| 1745 | 1745 | |
| 1746 | - if ( isset( $_POST['post_format'] ) ) |
|
| 1747 | - $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
| 1746 | + if (isset($_POST['post_format'])) |
|
| 1747 | + $query_args['post_format'] = empty($_POST['post_format']) ? 'standard' : sanitize_key($_POST['post_format']); |
|
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | - return get_preview_post_link( $post, $query_args ); |
|
| 1750 | + return get_preview_post_link($post, $query_args); |
|
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | 1753 | /** |
@@ -1761,36 +1761,36 @@ discard block |
||
| 1761 | 1761 | * @return mixed The value 0 or WP_Error on failure. The saved post ID on success. |
| 1762 | 1762 | * The ID can be the draft post_id or the autosave revision post_id. |
| 1763 | 1763 | */ |
| 1764 | -function wp_autosave( $post_data ) { |
|
| 1764 | +function wp_autosave($post_data) { |
|
| 1765 | 1765 | // Back-compat |
| 1766 | - if ( ! defined( 'DOING_AUTOSAVE' ) ) |
|
| 1767 | - define( 'DOING_AUTOSAVE', true ); |
|
| 1766 | + if ( ! defined('DOING_AUTOSAVE')) |
|
| 1767 | + define('DOING_AUTOSAVE', true); |
|
| 1768 | 1768 | |
| 1769 | 1769 | $post_id = (int) $post_data['post_id']; |
| 1770 | 1770 | $post_data['ID'] = $post_data['post_ID'] = $post_id; |
| 1771 | 1771 | |
| 1772 | - if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) { |
|
| 1773 | - return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) ); |
|
| 1772 | + if (false === wp_verify_nonce($post_data['_wpnonce'], 'update-post_'.$post_id)) { |
|
| 1773 | + return new WP_Error('invalid_nonce', __('Error while saving.')); |
|
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | - $post = get_post( $post_id ); |
|
| 1776 | + $post = get_post($post_id); |
|
| 1777 | 1777 | |
| 1778 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1779 | - return new WP_Error( 'edit_posts', __( 'You are not allowed to edit this item.' ) ); |
|
| 1778 | + if ( ! current_user_can('edit_post', $post->ID)) { |
|
| 1779 | + return new WP_Error('edit_posts', __('You are not allowed to edit this item.')); |
|
| 1780 | 1780 | } |
| 1781 | 1781 | |
| 1782 | - if ( 'auto-draft' == $post->post_status ) |
|
| 1782 | + if ('auto-draft' == $post->post_status) |
|
| 1783 | 1783 | $post_data['post_status'] = 'draft'; |
| 1784 | 1784 | |
| 1785 | - if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) |
|
| 1786 | - $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
| 1785 | + if ($post_data['post_type'] != 'page' && ! empty($post_data['catslist'])) |
|
| 1786 | + $post_data['post_category'] = explode(',', $post_data['catslist']); |
|
| 1787 | 1787 | |
| 1788 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { |
|
| 1788 | + if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) { |
|
| 1789 | 1789 | // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked |
| 1790 | - return edit_post( wp_slash( $post_data ) ); |
|
| 1790 | + return edit_post(wp_slash($post_data)); |
|
| 1791 | 1791 | } else { |
| 1792 | 1792 | // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user. |
| 1793 | - return wp_create_post_autosave( wp_slash( $post_data ) ); |
|
| 1793 | + return wp_create_post_autosave(wp_slash($post_data)); |
|
| 1794 | 1794 | } |
| 1795 | 1795 | } |
| 1796 | 1796 | |
@@ -1800,11 +1800,11 @@ discard block |
||
| 1800 | 1800 | * @param int $post_id Optional. Post ID. |
| 1801 | 1801 | */ |
| 1802 | 1802 | function redirect_post($post_id = '') { |
| 1803 | - if ( isset($_POST['save']) || isset($_POST['publish']) ) { |
|
| 1804 | - $status = get_post_status( $post_id ); |
|
| 1803 | + if (isset($_POST['save']) || isset($_POST['publish'])) { |
|
| 1804 | + $status = get_post_status($post_id); |
|
| 1805 | 1805 | |
| 1806 | - if ( isset( $_POST['publish'] ) ) { |
|
| 1807 | - switch ( $status ) { |
|
| 1806 | + if (isset($_POST['publish'])) { |
|
| 1807 | + switch ($status) { |
|
| 1808 | 1808 | case 'pending': |
| 1809 | 1809 | $message = 8; |
| 1810 | 1810 | break; |
@@ -1818,17 +1818,17 @@ discard block |
||
| 1818 | 1818 | $message = 'draft' == $status ? 10 : 1; |
| 1819 | 1819 | } |
| 1820 | 1820 | |
| 1821 | - $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); |
|
| 1822 | - } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) { |
|
| 1823 | - $location = add_query_arg( 'message', 2, wp_get_referer() ); |
|
| 1821 | + $location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url')); |
|
| 1822 | + } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { |
|
| 1823 | + $location = add_query_arg('message', 2, wp_get_referer()); |
|
| 1824 | 1824 | $location = explode('#', $location); |
| 1825 | - $location = $location[0] . '#postcustom'; |
|
| 1826 | - } elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { |
|
| 1827 | - $location = add_query_arg( 'message', 3, wp_get_referer() ); |
|
| 1825 | + $location = $location[0].'#postcustom'; |
|
| 1826 | + } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { |
|
| 1827 | + $location = add_query_arg('message', 3, wp_get_referer()); |
|
| 1828 | 1828 | $location = explode('#', $location); |
| 1829 | - $location = $location[0] . '#postcustom'; |
|
| 1829 | + $location = $location[0].'#postcustom'; |
|
| 1830 | 1830 | } else { |
| 1831 | - $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); |
|
| 1831 | + $location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url')); |
|
| 1832 | 1832 | } |
| 1833 | 1833 | |
| 1834 | 1834 | /** |
@@ -1839,6 +1839,6 @@ discard block |
||
| 1839 | 1839 | * @param string $location The destination URL. |
| 1840 | 1840 | * @param int $post_id The post ID. |
| 1841 | 1841 | */ |
| 1842 | - wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); |
|
| 1842 | + wp_redirect(apply_filters('redirect_post_location', $location, $post_id)); |
|
| 1843 | 1843 | exit; |
| 1844 | 1844 | } |
@@ -20,37 +20,45 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | function _wp_translate_postdata( $update = false, $post_data = null ) { |
| 22 | 22 | |
| 23 | - if ( empty($post_data) ) |
|
| 24 | - $post_data = &$_POST; |
|
| 23 | + if ( empty($post_data) ) { |
|
| 24 | + $post_data = &$_POST; |
|
| 25 | + } |
|
| 25 | 26 | |
| 26 | - if ( $update ) |
|
| 27 | - $post_data['ID'] = (int) $post_data['post_ID']; |
|
| 27 | + if ( $update ) { |
|
| 28 | + $post_data['ID'] = (int) $post_data['post_ID']; |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | $ptype = get_post_type_object( $post_data['post_type'] ); |
| 30 | 32 | |
| 31 | 33 | if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { |
| 32 | - if ( 'page' == $post_data['post_type'] ) |
|
| 33 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
| 34 | - else |
|
| 35 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
| 34 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 35 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
| 36 | + } else { |
|
| 37 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
| 38 | + } |
|
| 36 | 39 | } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
| 37 | - if ( 'page' == $post_data['post_type'] ) |
|
| 38 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
| 39 | - else |
|
| 40 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
| 40 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 41 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
| 42 | + } else { |
|
| 43 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
| 44 | + } |
|
| 41 | 45 | } |
| 42 | 46 | |
| 43 | - if ( isset( $post_data['content'] ) ) |
|
| 44 | - $post_data['post_content'] = $post_data['content']; |
|
| 47 | + if ( isset( $post_data['content'] ) ) { |
|
| 48 | + $post_data['post_content'] = $post_data['content']; |
|
| 49 | + } |
|
| 45 | 50 | |
| 46 | - if ( isset( $post_data['excerpt'] ) ) |
|
| 47 | - $post_data['post_excerpt'] = $post_data['excerpt']; |
|
| 51 | + if ( isset( $post_data['excerpt'] ) ) { |
|
| 52 | + $post_data['post_excerpt'] = $post_data['excerpt']; |
|
| 53 | + } |
|
| 48 | 54 | |
| 49 | - if ( isset( $post_data['parent_id'] ) ) |
|
| 50 | - $post_data['post_parent'] = (int) $post_data['parent_id']; |
|
| 55 | + if ( isset( $post_data['parent_id'] ) ) { |
|
| 56 | + $post_data['post_parent'] = (int) $post_data['parent_id']; |
|
| 57 | + } |
|
| 51 | 58 | |
| 52 | - if ( isset($post_data['trackback_url']) ) |
|
| 53 | - $post_data['to_ping'] = $post_data['trackback_url']; |
|
| 59 | + if ( isset($post_data['trackback_url']) ) { |
|
| 60 | + $post_data['to_ping'] = $post_data['trackback_url']; |
|
| 61 | + } |
|
| 54 | 62 | |
| 55 | 63 | $post_data['user_ID'] = get_current_user_id(); |
| 56 | 64 | |
@@ -67,15 +75,17 @@ discard block |
||
| 67 | 75 | if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
| 68 | 76 | && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
| 69 | 77 | if ( $update ) { |
| 70 | - if ( 'page' == $post_data['post_type'] ) |
|
| 71 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
| 72 | - else |
|
| 73 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
| 78 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 79 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
| 80 | + } else { |
|
| 81 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
| 82 | + } |
|
| 74 | 83 | } else { |
| 75 | - if ( 'page' == $post_data['post_type'] ) |
|
| 76 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
| 77 | - else |
|
| 78 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
| 84 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 85 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
| 86 | + } else { |
|
| 87 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
| 88 | + } |
|
| 79 | 89 | } |
| 80 | 90 | } |
| 81 | 91 | |
@@ -93,21 +103,27 @@ discard block |
||
| 93 | 103 | } |
| 94 | 104 | |
| 95 | 105 | // What to do based on which button they pressed |
| 96 | - if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
|
| 97 | - $post_data['post_status'] = 'draft'; |
|
| 98 | - if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) |
|
| 99 | - $post_data['post_status'] = 'private'; |
|
| 100 | - if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) |
|
| 101 | - $post_data['post_status'] = 'publish'; |
|
| 102 | - if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) |
|
| 103 | - $post_data['post_status'] = 'draft'; |
|
| 104 | - if ( isset($post_data['pending']) && '' != $post_data['pending'] ) |
|
| 105 | - $post_data['post_status'] = 'pending'; |
|
| 106 | - |
|
| 107 | - if ( isset( $post_data['ID'] ) ) |
|
| 108 | - $post_id = $post_data['ID']; |
|
| 109 | - else |
|
| 110 | - $post_id = false; |
|
| 106 | + if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) { |
|
| 107 | + $post_data['post_status'] = 'draft'; |
|
| 108 | + } |
|
| 109 | + if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) { |
|
| 110 | + $post_data['post_status'] = 'private'; |
|
| 111 | + } |
|
| 112 | + if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) { |
|
| 113 | + $post_data['post_status'] = 'publish'; |
|
| 114 | + } |
|
| 115 | + if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) { |
|
| 116 | + $post_data['post_status'] = 'draft'; |
|
| 117 | + } |
|
| 118 | + if ( isset($post_data['pending']) && '' != $post_data['pending'] ) { |
|
| 119 | + $post_data['post_status'] = 'pending'; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + if ( isset( $post_data['ID'] ) ) { |
|
| 123 | + $post_id = $post_data['ID']; |
|
| 124 | + } else { |
|
| 125 | + $post_id = false; |
|
| 126 | + } |
|
| 111 | 127 | $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; |
| 112 | 128 | |
| 113 | 129 | if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { |
@@ -118,9 +134,10 @@ discard block |
||
| 118 | 134 | |
| 119 | 135 | // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. |
| 120 | 136 | // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. |
| 121 | - if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) |
|
| 122 | - if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
| 137 | + if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) { |
|
| 138 | + if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
| 123 | 139 | $post_data['post_status'] = 'pending'; |
| 140 | + } |
|
| 124 | 141 | |
| 125 | 142 | if ( ! isset( $post_data['post_status'] ) ) { |
| 126 | 143 | $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; |
@@ -130,11 +147,13 @@ discard block |
||
| 130 | 147 | unset( $post_data['post_password'] ); |
| 131 | 148 | } |
| 132 | 149 | |
| 133 | - if (!isset( $post_data['comment_status'] )) |
|
| 134 | - $post_data['comment_status'] = 'closed'; |
|
| 150 | + if (!isset( $post_data['comment_status'] )) { |
|
| 151 | + $post_data['comment_status'] = 'closed'; |
|
| 152 | + } |
|
| 135 | 153 | |
| 136 | - if (!isset( $post_data['ping_status'] )) |
|
| 137 | - $post_data['ping_status'] = 'closed'; |
|
| 154 | + if (!isset( $post_data['ping_status'] )) { |
|
| 155 | + $post_data['ping_status'] = 'closed'; |
|
| 156 | + } |
|
| 138 | 157 | |
| 139 | 158 | foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
| 140 | 159 | if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { |
@@ -181,8 +200,9 @@ discard block |
||
| 181 | 200 | function edit_post( $post_data = null ) { |
| 182 | 201 | global $wpdb; |
| 183 | 202 | |
| 184 | - if ( empty($post_data) ) |
|
| 185 | - $post_data = &$_POST; |
|
| 203 | + if ( empty($post_data) ) { |
|
| 204 | + $post_data = &$_POST; |
|
| 205 | + } |
|
| 186 | 206 | |
| 187 | 207 | // Clear out any data in internal vars. |
| 188 | 208 | unset( $post_data['filter'] ); |
@@ -202,10 +222,11 @@ discard block |
||
| 202 | 222 | |
| 203 | 223 | $ptype = get_post_type_object($post_data['post_type']); |
| 204 | 224 | if ( !current_user_can( 'edit_post', $post_ID ) ) { |
| 205 | - if ( 'page' == $post_data['post_type'] ) |
|
| 206 | - wp_die( __('You are not allowed to edit this page.' )); |
|
| 207 | - else |
|
| 208 | - wp_die( __('You are not allowed to edit this post.' )); |
|
| 225 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 226 | + wp_die( __('You are not allowed to edit this page.' )); |
|
| 227 | + } else { |
|
| 228 | + wp_die( __('You are not allowed to edit this post.' )); |
|
| 229 | + } |
|
| 209 | 230 | } |
| 210 | 231 | |
| 211 | 232 | if ( post_type_supports( $ptype->name, 'revisions' ) ) { |
@@ -213,8 +234,9 @@ discard block |
||
| 213 | 234 | $revision = current( $revisions ); |
| 214 | 235 | |
| 215 | 236 | // Check if the revisions have been upgraded |
| 216 | - if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) |
|
| 217 | - _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
| 237 | + if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) { |
|
| 238 | + _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
| 239 | + } |
|
| 218 | 240 | } |
| 219 | 241 | |
| 220 | 242 | if ( isset($post_data['visibility']) ) { |
@@ -234,18 +256,21 @@ discard block |
||
| 234 | 256 | } |
| 235 | 257 | |
| 236 | 258 | $post_data = _wp_translate_postdata( true, $post_data ); |
| 237 | - if ( is_wp_error($post_data) ) |
|
| 238 | - wp_die( $post_data->get_error_message() ); |
|
| 259 | + if ( is_wp_error($post_data) ) { |
|
| 260 | + wp_die( $post_data->get_error_message() ); |
|
| 261 | + } |
|
| 239 | 262 | |
| 240 | 263 | // Post Formats |
| 241 | - if ( isset( $post_data['post_format'] ) ) |
|
| 242 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 264 | + if ( isset( $post_data['post_format'] ) ) { |
|
| 265 | + set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 266 | + } |
|
| 243 | 267 | |
| 244 | 268 | $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); |
| 245 | 269 | foreach ( $format_meta_urls as $format_meta_url ) { |
| 246 | 270 | $keyed = '_format_' . $format_meta_url; |
| 247 | - if ( isset( $post_data[ $keyed ] ) ) |
|
| 248 | - update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
| 271 | + if ( isset( $post_data[ $keyed ] ) ) { |
|
| 272 | + update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
| 273 | + } |
|
| 249 | 274 | } |
| 250 | 275 | |
| 251 | 276 | $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); |
@@ -253,10 +278,11 @@ discard block |
||
| 253 | 278 | foreach ( $format_keys as $key ) { |
| 254 | 279 | $keyed = '_format_' . $key; |
| 255 | 280 | if ( isset( $post_data[ $keyed ] ) ) { |
| 256 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 257 | - update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
| 258 | - else |
|
| 259 | - update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
| 281 | + if ( current_user_can( 'unfiltered_html' ) ) { |
|
| 282 | + update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
| 283 | + } else { |
|
| 284 | + update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
| 285 | + } |
|
| 260 | 286 | } |
| 261 | 287 | } |
| 262 | 288 | |
@@ -277,24 +303,30 @@ discard block |
||
| 277 | 303 | // Meta Stuff |
| 278 | 304 | if ( isset($post_data['meta']) && $post_data['meta'] ) { |
| 279 | 305 | foreach ( $post_data['meta'] as $key => $value ) { |
| 280 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 281 | - continue; |
|
| 282 | - if ( $meta->post_id != $post_ID ) |
|
| 283 | - continue; |
|
| 284 | - if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) |
|
| 285 | - continue; |
|
| 306 | + if ( !$meta = get_post_meta_by_id( $key ) ) { |
|
| 307 | + continue; |
|
| 308 | + } |
|
| 309 | + if ( $meta->post_id != $post_ID ) { |
|
| 310 | + continue; |
|
| 311 | + } |
|
| 312 | + if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) { |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 286 | 315 | update_meta( $key, $value['key'], $value['value'] ); |
| 287 | 316 | } |
| 288 | 317 | } |
| 289 | 318 | |
| 290 | 319 | if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { |
| 291 | 320 | foreach ( $post_data['deletemeta'] as $key => $value ) { |
| 292 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 293 | - continue; |
|
| 294 | - if ( $meta->post_id != $post_ID ) |
|
| 295 | - continue; |
|
| 296 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) |
|
| 297 | - continue; |
|
| 321 | + if ( !$meta = get_post_meta_by_id( $key ) ) { |
|
| 322 | + continue; |
|
| 323 | + } |
|
| 324 | + if ( $meta->post_id != $post_ID ) { |
|
| 325 | + continue; |
|
| 326 | + } |
|
| 327 | + if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) { |
|
| 328 | + continue; |
|
| 329 | + } |
|
| 298 | 330 | delete_meta( $key ); |
| 299 | 331 | } |
| 300 | 332 | } |
@@ -386,10 +418,11 @@ discard block |
||
| 386 | 418 | wp_set_post_lock( $post_ID ); |
| 387 | 419 | |
| 388 | 420 | if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { |
| 389 | - if ( ! empty( $post_data['sticky'] ) ) |
|
| 390 | - stick_post( $post_ID ); |
|
| 391 | - else |
|
| 392 | - unstick_post( $post_ID ); |
|
| 421 | + if ( ! empty( $post_data['sticky'] ) ) { |
|
| 422 | + stick_post( $post_ID ); |
|
| 423 | + } else { |
|
| 424 | + unstick_post( $post_ID ); |
|
| 425 | + } |
|
| 393 | 426 | } |
| 394 | 427 | |
| 395 | 428 | return $post_ID; |
@@ -411,19 +444,22 @@ discard block |
||
| 411 | 444 | function bulk_edit_posts( $post_data = null ) { |
| 412 | 445 | global $wpdb; |
| 413 | 446 | |
| 414 | - if ( empty($post_data) ) |
|
| 415 | - $post_data = &$_POST; |
|
| 447 | + if ( empty($post_data) ) { |
|
| 448 | + $post_data = &$_POST; |
|
| 449 | + } |
|
| 416 | 450 | |
| 417 | - if ( isset($post_data['post_type']) ) |
|
| 418 | - $ptype = get_post_type_object($post_data['post_type']); |
|
| 419 | - else |
|
| 420 | - $ptype = get_post_type_object('post'); |
|
| 451 | + if ( isset($post_data['post_type']) ) { |
|
| 452 | + $ptype = get_post_type_object($post_data['post_type']); |
|
| 453 | + } else { |
|
| 454 | + $ptype = get_post_type_object('post'); |
|
| 455 | + } |
|
| 421 | 456 | |
| 422 | 457 | if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
| 423 | - if ( 'page' == $ptype->name ) |
|
| 424 | - wp_die( __('You are not allowed to edit pages.')); |
|
| 425 | - else |
|
| 426 | - wp_die( __('You are not allowed to edit posts.')); |
|
| 458 | + if ( 'page' == $ptype->name ) { |
|
| 459 | + wp_die( __('You are not allowed to edit pages.')); |
|
| 460 | + } else { |
|
| 461 | + wp_die( __('You are not allowed to edit posts.')); |
|
| 462 | + } |
|
| 427 | 463 | } |
| 428 | 464 | |
| 429 | 465 | if ( -1 == $post_data['_status'] ) { |
@@ -452,28 +488,32 @@ discard block |
||
| 452 | 488 | ); |
| 453 | 489 | |
| 454 | 490 | foreach ( $reset as $field ) { |
| 455 | - if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) |
|
| 456 | - unset($post_data[$field]); |
|
| 491 | + if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) { |
|
| 492 | + unset($post_data[$field]); |
|
| 493 | + } |
|
| 457 | 494 | } |
| 458 | 495 | |
| 459 | 496 | if ( isset($post_data['post_category']) ) { |
| 460 | - if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) |
|
| 461 | - $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
| 462 | - else |
|
| 463 | - unset($post_data['post_category']); |
|
| 497 | + if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) { |
|
| 498 | + $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
| 499 | + } else { |
|
| 500 | + unset($post_data['post_category']); |
|
| 501 | + } |
|
| 464 | 502 | } |
| 465 | 503 | |
| 466 | 504 | $tax_input = array(); |
| 467 | 505 | if ( isset($post_data['tax_input'])) { |
| 468 | 506 | foreach ( $post_data['tax_input'] as $tax_name => $terms ) { |
| 469 | - if ( empty($terms) ) |
|
| 470 | - continue; |
|
| 507 | + if ( empty($terms) ) { |
|
| 508 | + continue; |
|
| 509 | + } |
|
| 471 | 510 | if ( is_taxonomy_hierarchical( $tax_name ) ) { |
| 472 | 511 | $tax_input[ $tax_name ] = array_map( 'absint', $terms ); |
| 473 | 512 | } else { |
| 474 | 513 | $comma = _x( ',', 'tag delimiter' ); |
| 475 | - if ( ',' !== $comma ) |
|
| 476 | - $terms = str_replace( $comma, ',', $terms ); |
|
| 514 | + if ( ',' !== $comma ) { |
|
| 515 | + $terms = str_replace( $comma, ',', $terms ); |
|
| 516 | + } |
|
| 477 | 517 | $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
| 478 | 518 | } |
| 479 | 519 | } |
@@ -518,15 +558,17 @@ discard block |
||
| 518 | 558 | $tax_names = get_object_taxonomies( $post ); |
| 519 | 559 | foreach ( $tax_names as $tax_name ) { |
| 520 | 560 | $taxonomy_obj = get_taxonomy($tax_name); |
| 521 | - if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) |
|
| 522 | - $new_terms = $tax_input[$tax_name]; |
|
| 523 | - else |
|
| 524 | - $new_terms = array(); |
|
| 561 | + if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) { |
|
| 562 | + $new_terms = $tax_input[$tax_name]; |
|
| 563 | + } else { |
|
| 564 | + $new_terms = array(); |
|
| 565 | + } |
|
| 525 | 566 | |
| 526 | - if ( $taxonomy_obj->hierarchical ) |
|
| 527 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
| 528 | - else |
|
| 529 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
| 567 | + if ( $taxonomy_obj->hierarchical ) { |
|
| 568 | + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
| 569 | + } else { |
|
| 570 | + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
| 571 | + } |
|
| 530 | 572 | |
| 531 | 573 | $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms ); |
| 532 | 574 | } |
@@ -559,14 +601,16 @@ discard block |
||
| 559 | 601 | $updated[] = wp_update_post( $post_data ); |
| 560 | 602 | |
| 561 | 603 | if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { |
| 562 | - if ( 'sticky' == $post_data['sticky'] ) |
|
| 563 | - stick_post( $post_ID ); |
|
| 564 | - else |
|
| 565 | - unstick_post( $post_ID ); |
|
| 604 | + if ( 'sticky' == $post_data['sticky'] ) { |
|
| 605 | + stick_post( $post_ID ); |
|
| 606 | + } else { |
|
| 607 | + unstick_post( $post_ID ); |
|
| 608 | + } |
|
| 566 | 609 | } |
| 567 | 610 | |
| 568 | - if ( isset( $post_data['post_format'] ) ) |
|
| 569 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 611 | + if ( isset( $post_data['post_format'] ) ) { |
|
| 612 | + set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 613 | + } |
|
| 570 | 614 | } |
| 571 | 615 | |
| 572 | 616 | return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); |
@@ -583,22 +627,26 @@ discard block |
||
| 583 | 627 | */ |
| 584 | 628 | function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { |
| 585 | 629 | $post_title = ''; |
| 586 | - if ( !empty( $_REQUEST['post_title'] ) ) |
|
| 587 | - $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
| 630 | + if ( !empty( $_REQUEST['post_title'] ) ) { |
|
| 631 | + $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
| 632 | + } |
|
| 588 | 633 | |
| 589 | 634 | $post_content = ''; |
| 590 | - if ( !empty( $_REQUEST['content'] ) ) |
|
| 591 | - $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
| 635 | + if ( !empty( $_REQUEST['content'] ) ) { |
|
| 636 | + $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
| 637 | + } |
|
| 592 | 638 | |
| 593 | 639 | $post_excerpt = ''; |
| 594 | - if ( !empty( $_REQUEST['excerpt'] ) ) |
|
| 595 | - $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
| 640 | + if ( !empty( $_REQUEST['excerpt'] ) ) { |
|
| 641 | + $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
| 642 | + } |
|
| 596 | 643 | |
| 597 | 644 | if ( $create_in_db ) { |
| 598 | 645 | $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
| 599 | 646 | $post = get_post( $post_id ); |
| 600 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) |
|
| 601 | - set_post_format( $post, get_option( 'default_post_format' ) ); |
|
| 647 | + if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) { |
|
| 648 | + set_post_format( $post, get_option( 'default_post_format' ) ); |
|
| 649 | + } |
|
| 602 | 650 | } else { |
| 603 | 651 | $post = new stdClass; |
| 604 | 652 | $post->ID = 0; |
@@ -691,8 +739,9 @@ discard block |
||
| 691 | 739 | $args[] = $post_content; |
| 692 | 740 | } |
| 693 | 741 | |
| 694 | - if ( !empty ( $args ) ) |
|
| 695 | - return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
| 742 | + if ( !empty ( $args ) ) { |
|
| 743 | + return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
| 744 | + } |
|
| 696 | 745 | |
| 697 | 746 | return 0; |
| 698 | 747 | } |
@@ -707,16 +756,18 @@ discard block |
||
| 707 | 756 | * @return int|WP_Error |
| 708 | 757 | */ |
| 709 | 758 | function wp_write_post() { |
| 710 | - if ( isset($_POST['post_type']) ) |
|
| 711 | - $ptype = get_post_type_object($_POST['post_type']); |
|
| 712 | - else |
|
| 713 | - $ptype = get_post_type_object('post'); |
|
| 759 | + if ( isset($_POST['post_type']) ) { |
|
| 760 | + $ptype = get_post_type_object($_POST['post_type']); |
|
| 761 | + } else { |
|
| 762 | + $ptype = get_post_type_object('post'); |
|
| 763 | + } |
|
| 714 | 764 | |
| 715 | 765 | if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
| 716 | - if ( 'page' == $ptype->name ) |
|
| 717 | - return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) ); |
|
| 718 | - else |
|
| 719 | - return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) ); |
|
| 766 | + if ( 'page' == $ptype->name ) { |
|
| 767 | + return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) ); |
|
| 768 | + } else { |
|
| 769 | + return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) ); |
|
| 770 | + } |
|
| 720 | 771 | } |
| 721 | 772 | |
| 722 | 773 | $_POST['post_mime_type'] = ''; |
@@ -725,8 +776,9 @@ discard block |
||
| 725 | 776 | unset( $_POST['filter'] ); |
| 726 | 777 | |
| 727 | 778 | // Edit don't write if we have a post id. |
| 728 | - if ( isset( $_POST['post_ID'] ) ) |
|
| 729 | - return edit_post(); |
|
| 779 | + if ( isset( $_POST['post_ID'] ) ) { |
|
| 780 | + return edit_post(); |
|
| 781 | + } |
|
| 730 | 782 | |
| 731 | 783 | if ( isset($_POST['visibility']) ) { |
| 732 | 784 | switch ( $_POST['visibility'] ) { |
@@ -745,16 +797,19 @@ discard block |
||
| 745 | 797 | } |
| 746 | 798 | |
| 747 | 799 | $translated = _wp_translate_postdata( false ); |
| 748 | - if ( is_wp_error($translated) ) |
|
| 749 | - return $translated; |
|
| 800 | + if ( is_wp_error($translated) ) { |
|
| 801 | + return $translated; |
|
| 802 | + } |
|
| 750 | 803 | |
| 751 | 804 | // Create the post. |
| 752 | 805 | $post_ID = wp_insert_post( $_POST ); |
| 753 | - if ( is_wp_error( $post_ID ) ) |
|
| 754 | - return $post_ID; |
|
| 806 | + if ( is_wp_error( $post_ID ) ) { |
|
| 807 | + return $post_ID; |
|
| 808 | + } |
|
| 755 | 809 | |
| 756 | - if ( empty($post_ID) ) |
|
| 757 | - return 0; |
|
| 810 | + if ( empty($post_ID) ) { |
|
| 811 | + return 0; |
|
| 812 | + } |
|
| 758 | 813 | |
| 759 | 814 | add_meta( $post_ID ); |
| 760 | 815 | |
@@ -777,11 +832,12 @@ discard block |
||
| 777 | 832 | */ |
| 778 | 833 | function write_post() { |
| 779 | 834 | $result = wp_write_post(); |
| 780 | - if ( is_wp_error( $result ) ) |
|
| 781 | - wp_die( $result->get_error_message() ); |
|
| 782 | - else |
|
| 783 | - return $result; |
|
| 784 | -} |
|
| 835 | + if ( is_wp_error( $result ) ) { |
|
| 836 | + wp_die( $result->get_error_message() ); |
|
| 837 | + } else { |
|
| 838 | + return $result; |
|
| 839 | + } |
|
| 840 | + } |
|
| 785 | 841 | |
| 786 | 842 | // |
| 787 | 843 | // Post Meta |
@@ -801,22 +857,27 @@ discard block |
||
| 801 | 857 | $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; |
| 802 | 858 | $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; |
| 803 | 859 | $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; |
| 804 | - if ( is_string( $metavalue ) ) |
|
| 805 | - $metavalue = trim( $metavalue ); |
|
| 860 | + if ( is_string( $metavalue ) ) { |
|
| 861 | + $metavalue = trim( $metavalue ); |
|
| 862 | + } |
|
| 806 | 863 | |
| 807 | 864 | if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) { |
| 808 | 865 | /* |
| 809 | 866 | * We have a key/value pair. If both the select and the input |
| 810 | 867 | * for the key have data, the input takes precedence. |
| 811 | 868 | */ |
| 812 | - if ( '#NONE#' != $metakeyselect ) |
|
| 813 | - $metakey = $metakeyselect; |
|
| 869 | + if ( '#NONE#' != $metakeyselect ) { |
|
| 870 | + $metakey = $metakeyselect; |
|
| 871 | + } |
|
| 814 | 872 | |
| 815 | - if ( $metakeyinput ) |
|
| 816 | - $metakey = $metakeyinput; // default |
|
| 873 | + if ( $metakeyinput ) { |
|
| 874 | + $metakey = $metakeyinput; |
|
| 875 | + } |
|
| 876 | + // default |
|
| 817 | 877 | |
| 818 | - if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) |
|
| 819 | - return false; |
|
| 878 | + if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { |
|
| 879 | + return false; |
|
| 880 | + } |
|
| 820 | 881 | |
| 821 | 882 | $metakey = wp_slash( $metakey ); |
| 822 | 883 | |
@@ -924,12 +985,14 @@ discard block |
||
| 924 | 985 | $content = $post['post_content']; |
| 925 | 986 | |
| 926 | 987 | // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. |
| 927 | - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) |
|
| 928 | - return; |
|
| 988 | + if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) { |
|
| 989 | + return; |
|
| 990 | + } |
|
| 929 | 991 | |
| 930 | 992 | // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) |
| 931 | - if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) |
|
| 932 | - return; |
|
| 993 | + if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) { |
|
| 994 | + return; |
|
| 995 | + } |
|
| 933 | 996 | |
| 934 | 997 | $site_url = get_bloginfo('url'); |
| 935 | 998 | $site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s) |
@@ -938,15 +1001,17 @@ discard block |
||
| 938 | 1001 | foreach ( $link_matches[1] as $key => $value ) { |
| 939 | 1002 | if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') |
| 940 | 1003 | || !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) |
| 941 | - || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) |
|
| 942 | - continue; |
|
| 1004 | + || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) { |
|
| 1005 | + continue; |
|
| 1006 | + } |
|
| 943 | 1007 | |
| 944 | 1008 | $quote = $url_match[1]; // the quote (single or double) |
| 945 | 1009 | $url_id = (int) $url_match[2]; |
| 946 | 1010 | $rel_id = (int) $rel_match[1]; |
| 947 | 1011 | |
| 948 | - if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) |
|
| 949 | - continue; |
|
| 1012 | + if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) { |
|
| 1013 | + continue; |
|
| 1014 | + } |
|
| 950 | 1015 | |
| 951 | 1016 | $link = $link_matches[0][$key]; |
| 952 | 1017 | $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); |
@@ -986,16 +1051,18 @@ discard block |
||
| 986 | 1051 | * @return array |
| 987 | 1052 | */ |
| 988 | 1053 | function wp_edit_posts_query( $q = false ) { |
| 989 | - if ( false === $q ) |
|
| 990 | - $q = $_GET; |
|
| 1054 | + if ( false === $q ) { |
|
| 1055 | + $q = $_GET; |
|
| 1056 | + } |
|
| 991 | 1057 | $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
| 992 | 1058 | $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
| 993 | 1059 | $post_stati = get_post_stati(); |
| 994 | 1060 | |
| 995 | - if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) |
|
| 996 | - $post_type = $q['post_type']; |
|
| 997 | - else |
|
| 998 | - $post_type = 'post'; |
|
| 1061 | + if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) { |
|
| 1062 | + $post_type = $q['post_type']; |
|
| 1063 | + } else { |
|
| 1064 | + $post_type = 'post'; |
|
| 1065 | + } |
|
| 999 | 1066 | |
| 1000 | 1067 | $avail_post_stati = get_available_post_statuses($post_type); |
| 1001 | 1068 | |
@@ -1018,8 +1085,9 @@ discard block |
||
| 1018 | 1085 | |
| 1019 | 1086 | $per_page = "edit_{$post_type}_per_page"; |
| 1020 | 1087 | $posts_per_page = (int) get_user_option( $per_page ); |
| 1021 | - if ( empty( $posts_per_page ) || $posts_per_page < 1 ) |
|
| 1022 | - $posts_per_page = 20; |
|
| 1088 | + if ( empty( $posts_per_page ) || $posts_per_page < 1 ) { |
|
| 1089 | + $posts_per_page = 20; |
|
| 1090 | + } |
|
| 1023 | 1091 | |
| 1024 | 1092 | /** |
| 1025 | 1093 | * Filter the number of items per page to show for a specific 'per_page' type. |
@@ -1057,8 +1125,9 @@ discard block |
||
| 1057 | 1125 | $query['fields'] = 'id=>parent'; |
| 1058 | 1126 | } |
| 1059 | 1127 | |
| 1060 | - if ( ! empty( $q['show_sticky'] ) ) |
|
| 1061 | - $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
| 1128 | + if ( ! empty( $q['show_sticky'] ) ) { |
|
| 1129 | + $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
| 1130 | + } |
|
| 1062 | 1131 | |
| 1063 | 1132 | wp( $query ); |
| 1064 | 1133 | |
@@ -1206,8 +1275,9 @@ discard block |
||
| 1206 | 1275 | */ |
| 1207 | 1276 | function get_sample_permalink($id, $title = null, $name = null) { |
| 1208 | 1277 | $post = get_post( $id ); |
| 1209 | - if ( ! $post ) |
|
| 1210 | - return array( '', '' ); |
|
| 1278 | + if ( ! $post ) { |
|
| 1279 | + return array( '', '' ); |
|
| 1280 | + } |
|
| 1211 | 1281 | |
| 1212 | 1282 | $ptype = get_post_type_object($post->post_type); |
| 1213 | 1283 | |
@@ -1223,8 +1293,9 @@ discard block |
||
| 1223 | 1293 | |
| 1224 | 1294 | // If the user wants to set a new name -- override the current one |
| 1225 | 1295 | // Note: if empty name is supplied -- use the title instead, see #6072 |
| 1226 | - if ( !is_null($name) ) |
|
| 1227 | - $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
|
| 1296 | + if ( !is_null($name) ) { |
|
| 1297 | + $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
|
| 1298 | + } |
|
| 1228 | 1299 | |
| 1229 | 1300 | $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); |
| 1230 | 1301 | |
@@ -1246,8 +1317,9 @@ discard block |
||
| 1246 | 1317 | |
| 1247 | 1318 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 1248 | 1319 | $uri = apply_filters( 'editable_slug', $uri, $post ); |
| 1249 | - if ( !empty($uri) ) |
|
| 1250 | - $uri .= '/'; |
|
| 1320 | + if ( !empty($uri) ) { |
|
| 1321 | + $uri .= '/'; |
|
| 1322 | + } |
|
| 1251 | 1323 | $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); |
| 1252 | 1324 | } |
| 1253 | 1325 | |
@@ -1284,8 +1356,9 @@ discard block |
||
| 1284 | 1356 | */ |
| 1285 | 1357 | function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
| 1286 | 1358 | $post = get_post( $id ); |
| 1287 | - if ( ! $post ) |
|
| 1288 | - return ''; |
|
| 1359 | + if ( ! $post ) { |
|
| 1360 | + return ''; |
|
| 1361 | + } |
|
| 1289 | 1362 | |
| 1290 | 1363 | list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
| 1291 | 1364 | |
@@ -1445,11 +1518,13 @@ discard block |
||
| 1445 | 1518 | * @return integer False: not locked or locked by current user. Int: user ID of user with lock. |
| 1446 | 1519 | */ |
| 1447 | 1520 | function wp_check_post_lock( $post_id ) { |
| 1448 | - if ( !$post = get_post( $post_id ) ) |
|
| 1449 | - return false; |
|
| 1521 | + if ( !$post = get_post( $post_id ) ) { |
|
| 1522 | + return false; |
|
| 1523 | + } |
|
| 1450 | 1524 | |
| 1451 | - if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) |
|
| 1452 | - return false; |
|
| 1525 | + if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) { |
|
| 1526 | + return false; |
|
| 1527 | + } |
|
| 1453 | 1528 | |
| 1454 | 1529 | $lock = explode( ':', $lock ); |
| 1455 | 1530 | $time = $lock[0]; |
@@ -1458,8 +1533,9 @@ discard block |
||
| 1458 | 1533 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
| 1459 | 1534 | $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); |
| 1460 | 1535 | |
| 1461 | - if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) |
|
| 1462 | - return $user; |
|
| 1536 | + if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) { |
|
| 1537 | + return $user; |
|
| 1538 | + } |
|
| 1463 | 1539 | return false; |
| 1464 | 1540 | } |
| 1465 | 1541 | |
@@ -1473,10 +1549,12 @@ discard block |
||
| 1473 | 1549 | * an array of the lock time and the user ID. |
| 1474 | 1550 | */ |
| 1475 | 1551 | function wp_set_post_lock( $post_id ) { |
| 1476 | - if ( !$post = get_post( $post_id ) ) |
|
| 1477 | - return false; |
|
| 1478 | - if ( 0 == ($user_id = get_current_user_id()) ) |
|
| 1479 | - return false; |
|
| 1552 | + if ( !$post = get_post( $post_id ) ) { |
|
| 1553 | + return false; |
|
| 1554 | + } |
|
| 1555 | + if ( 0 == ($user_id = get_current_user_id()) ) { |
|
| 1556 | + return false; |
|
| 1557 | + } |
|
| 1480 | 1558 | |
| 1481 | 1559 | $now = time(); |
| 1482 | 1560 | $lock = "$now:$user_id"; |
@@ -1492,12 +1570,14 @@ discard block |
||
| 1492 | 1570 | * @return none |
| 1493 | 1571 | */ |
| 1494 | 1572 | function _admin_notice_post_locked() { |
| 1495 | - if ( ! $post = get_post() ) |
|
| 1496 | - return; |
|
| 1573 | + if ( ! $post = get_post() ) { |
|
| 1574 | + return; |
|
| 1575 | + } |
|
| 1497 | 1576 | |
| 1498 | 1577 | $user = null; |
| 1499 | - if ( $user_id = wp_check_post_lock( $post->ID ) ) |
|
| 1500 | - $user = get_userdata( $user_id ); |
|
| 1578 | + if ( $user_id = wp_check_post_lock( $post->ID ) ) { |
|
| 1579 | + $user = get_userdata( $user_id ); |
|
| 1580 | + } |
|
| 1501 | 1581 | |
| 1502 | 1582 | if ( $user ) { |
| 1503 | 1583 | |
@@ -1511,8 +1591,9 @@ discard block |
||
| 1511 | 1591 | * @param bool $display Whether to display the dialog. Default true. |
| 1512 | 1592 | * @param WP_User|bool $user WP_User object on success, false otherwise. |
| 1513 | 1593 | */ |
| 1514 | - if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) |
|
| 1515 | - return; |
|
| 1594 | + if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) { |
|
| 1595 | + return; |
|
| 1596 | + } |
|
| 1516 | 1597 | |
| 1517 | 1598 | $locked = true; |
| 1518 | 1599 | } else { |
@@ -1526,8 +1607,9 @@ discard block |
||
| 1526 | 1607 | } else { |
| 1527 | 1608 | $sendback = admin_url( 'edit.php' ); |
| 1528 | 1609 | |
| 1529 | - if ( 'post' != $post->post_type ) |
|
| 1530 | - $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
| 1610 | + if ( 'post' != $post->post_type ) { |
|
| 1611 | + $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
| 1612 | + } |
|
| 1531 | 1613 | |
| 1532 | 1614 | $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; |
| 1533 | 1615 | } |
@@ -1574,8 +1656,9 @@ discard block |
||
| 1574 | 1656 | <p class="currently-editing wp-tab-first" tabindex="0"> |
| 1575 | 1657 | <?php |
| 1576 | 1658 | _e( 'This content is currently locked.' ); |
| 1577 | - if ( $override ) |
|
| 1578 | - printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
| 1659 | + if ( $override ) { |
|
| 1660 | + printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
| 1661 | + } |
|
| 1579 | 1662 | ?> |
| 1580 | 1663 | </p> |
| 1581 | 1664 | <?php |
@@ -1655,8 +1738,9 @@ discard block |
||
| 1655 | 1738 | } |
| 1656 | 1739 | |
| 1657 | 1740 | $post_data = _wp_translate_postdata( true, $post_data ); |
| 1658 | - if ( is_wp_error( $post_data ) ) |
|
| 1659 | - return $post_data; |
|
| 1741 | + if ( is_wp_error( $post_data ) ) { |
|
| 1742 | + return $post_data; |
|
| 1743 | + } |
|
| 1660 | 1744 | |
| 1661 | 1745 | $post_author = get_current_user_id(); |
| 1662 | 1746 | |
@@ -1728,14 +1812,16 @@ discard block |
||
| 1728 | 1812 | } else { |
| 1729 | 1813 | $is_autosave = true; |
| 1730 | 1814 | |
| 1731 | - if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) |
|
| 1732 | - $_POST['post_status'] = 'draft'; |
|
| 1815 | + if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) { |
|
| 1816 | + $_POST['post_status'] = 'draft'; |
|
| 1817 | + } |
|
| 1733 | 1818 | |
| 1734 | 1819 | $saved_post_id = wp_create_post_autosave( $post->ID ); |
| 1735 | 1820 | } |
| 1736 | 1821 | |
| 1737 | - if ( is_wp_error( $saved_post_id ) ) |
|
| 1738 | - wp_die( $saved_post_id->get_error_message() ); |
|
| 1822 | + if ( is_wp_error( $saved_post_id ) ) { |
|
| 1823 | + wp_die( $saved_post_id->get_error_message() ); |
|
| 1824 | + } |
|
| 1739 | 1825 | |
| 1740 | 1826 | $query_args = array(); |
| 1741 | 1827 | |
@@ -1743,8 +1829,9 @@ discard block |
||
| 1743 | 1829 | $query_args['preview_id'] = $post->ID; |
| 1744 | 1830 | $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); |
| 1745 | 1831 | |
| 1746 | - if ( isset( $_POST['post_format'] ) ) |
|
| 1747 | - $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
| 1832 | + if ( isset( $_POST['post_format'] ) ) { |
|
| 1833 | + $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
| 1834 | + } |
|
| 1748 | 1835 | } |
| 1749 | 1836 | |
| 1750 | 1837 | return get_preview_post_link( $post, $query_args ); |
@@ -1763,8 +1850,9 @@ discard block |
||
| 1763 | 1850 | */ |
| 1764 | 1851 | function wp_autosave( $post_data ) { |
| 1765 | 1852 | // Back-compat |
| 1766 | - if ( ! defined( 'DOING_AUTOSAVE' ) ) |
|
| 1767 | - define( 'DOING_AUTOSAVE', true ); |
|
| 1853 | + if ( ! defined( 'DOING_AUTOSAVE' ) ) { |
|
| 1854 | + define( 'DOING_AUTOSAVE', true ); |
|
| 1855 | + } |
|
| 1768 | 1856 | |
| 1769 | 1857 | $post_id = (int) $post_data['post_id']; |
| 1770 | 1858 | $post_data['ID'] = $post_data['post_ID'] = $post_id; |
@@ -1779,11 +1867,13 @@ discard block |
||
| 1779 | 1867 | return new WP_Error( 'edit_posts', __( 'You are not allowed to edit this item.' ) ); |
| 1780 | 1868 | } |
| 1781 | 1869 | |
| 1782 | - if ( 'auto-draft' == $post->post_status ) |
|
| 1783 | - $post_data['post_status'] = 'draft'; |
|
| 1870 | + if ( 'auto-draft' == $post->post_status ) { |
|
| 1871 | + $post_data['post_status'] = 'draft'; |
|
| 1872 | + } |
|
| 1784 | 1873 | |
| 1785 | - if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) |
|
| 1786 | - $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
| 1874 | + if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) { |
|
| 1875 | + $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
| 1876 | + } |
|
| 1787 | 1877 | |
| 1788 | 1878 | if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { |
| 1789 | 1879 | // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked |
@@ -339,8 +339,8 @@ |
||
| 339 | 339 | * |
| 340 | 340 | * @since 3.4.0 |
| 341 | 341 | * |
| 342 | - * @param mixed $ajax_message AJAX return |
|
| 343 | - * @param mixed $message UI message |
|
| 342 | + * @param integer $ajax_message AJAX return |
|
| 343 | + * @param string $message UI message |
|
| 344 | 344 | */ |
| 345 | 345 | protected function wp_die( $ajax_message, $message = null ) { |
| 346 | 346 | if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) { |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress Customize Manager classes |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Customize |
|
| 7 | - * @since 3.4.0 |
|
| 8 | - */ |
|
| 3 | + * WordPress Customize Manager classes |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Customize |
|
| 7 | + * @since 3.4.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Customize Manager class. |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @access protected |
| 110 | 110 | * @var array |
| 111 | 111 | */ |
| 112 | - protected $components = array( 'widgets', 'nav_menus', 'selective_refresh' ); |
|
| 112 | + protected $components = array('widgets', 'nav_menus', 'selective_refresh'); |
|
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * Registered instances of WP_Customize_Section. |
@@ -205,41 +205,41 @@ discard block |
||
| 205 | 205 | * @since 3.4.0 |
| 206 | 206 | */ |
| 207 | 207 | public function __construct() { |
| 208 | - require_once( ABSPATH . WPINC . '/class-wp-customize-setting.php' ); |
|
| 209 | - require_once( ABSPATH . WPINC . '/class-wp-customize-panel.php' ); |
|
| 210 | - require_once( ABSPATH . WPINC . '/class-wp-customize-section.php' ); |
|
| 211 | - require_once( ABSPATH . WPINC . '/class-wp-customize-control.php' ); |
|
| 212 | - |
|
| 213 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php' ); |
|
| 214 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php' ); |
|
| 215 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php' ); |
|
| 216 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php' ); |
|
| 217 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' ); |
|
| 218 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' ); |
|
| 219 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' ); |
|
| 220 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' ); |
|
| 221 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' ); |
|
| 222 | - require_once( ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php' ); |
|
| 223 | - require_once( ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php' ); |
|
| 224 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php' ); |
|
| 225 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php' ); |
|
| 226 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php' ); |
|
| 227 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' ); |
|
| 228 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' ); |
|
| 229 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-control.php' ); |
|
| 230 | - |
|
| 231 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-panel.php' ); |
|
| 232 | - |
|
| 233 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php' ); |
|
| 234 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php' ); |
|
| 235 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php' ); |
|
| 236 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-section.php' ); |
|
| 237 | - |
|
| 238 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-filter-setting.php' ); |
|
| 239 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-setting.php' ); |
|
| 240 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-setting.php' ); |
|
| 241 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-setting.php' ); |
|
| 242 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-setting.php' ); |
|
| 208 | + require_once(ABSPATH.WPINC.'/class-wp-customize-setting.php'); |
|
| 209 | + require_once(ABSPATH.WPINC.'/class-wp-customize-panel.php'); |
|
| 210 | + require_once(ABSPATH.WPINC.'/class-wp-customize-section.php'); |
|
| 211 | + require_once(ABSPATH.WPINC.'/class-wp-customize-control.php'); |
|
| 212 | + |
|
| 213 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-color-control.php'); |
|
| 214 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-media-control.php'); |
|
| 215 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-upload-control.php'); |
|
| 216 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-image-control.php'); |
|
| 217 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-background-image-control.php'); |
|
| 218 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-cropped-image-control.php'); |
|
| 219 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-site-icon-control.php'); |
|
| 220 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-header-image-control.php'); |
|
| 221 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-theme-control.php'); |
|
| 222 | + require_once(ABSPATH.WPINC.'/customize/class-wp-widget-area-customize-control.php'); |
|
| 223 | + require_once(ABSPATH.WPINC.'/customize/class-wp-widget-form-customize-control.php'); |
|
| 224 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-control.php'); |
|
| 225 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-item-control.php'); |
|
| 226 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-location-control.php'); |
|
| 227 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-name-control.php'); |
|
| 228 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-auto-add-control.php'); |
|
| 229 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-new-menu-control.php'); |
|
| 230 | + |
|
| 231 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menus-panel.php'); |
|
| 232 | + |
|
| 233 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-themes-section.php'); |
|
| 234 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-sidebar-section.php'); |
|
| 235 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-section.php'); |
|
| 236 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-new-menu-section.php'); |
|
| 237 | + |
|
| 238 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-filter-setting.php'); |
|
| 239 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-header-image-setting.php'); |
|
| 240 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-background-image-setting.php'); |
|
| 241 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-item-setting.php'); |
|
| 242 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-setting.php'); |
|
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | 245 | * Filter the core Customizer components to load. |
@@ -256,54 +256,54 @@ discard block |
||
| 256 | 256 | * @param array $components List of core components to load. |
| 257 | 257 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 258 | 258 | */ |
| 259 | - $components = apply_filters( 'customize_loaded_components', $this->components, $this ); |
|
| 259 | + $components = apply_filters('customize_loaded_components', $this->components, $this); |
|
| 260 | 260 | |
| 261 | - if ( in_array( 'widgets', $components, true ) ) { |
|
| 262 | - require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' ); |
|
| 263 | - $this->widgets = new WP_Customize_Widgets( $this ); |
|
| 261 | + if (in_array('widgets', $components, true)) { |
|
| 262 | + require_once(ABSPATH.WPINC.'/class-wp-customize-widgets.php'); |
|
| 263 | + $this->widgets = new WP_Customize_Widgets($this); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if ( in_array( 'nav_menus', $components, true ) ) { |
|
| 267 | - require_once( ABSPATH . WPINC . '/class-wp-customize-nav-menus.php' ); |
|
| 268 | - $this->nav_menus = new WP_Customize_Nav_Menus( $this ); |
|
| 266 | + if (in_array('nav_menus', $components, true)) { |
|
| 267 | + require_once(ABSPATH.WPINC.'/class-wp-customize-nav-menus.php'); |
|
| 268 | + $this->nav_menus = new WP_Customize_Nav_Menus($this); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ( in_array( 'selective_refresh', $components, true ) ) { |
|
| 272 | - require_once( ABSPATH . WPINC . '/customize/class-wp-customize-selective-refresh.php' ); |
|
| 273 | - $this->selective_refresh = new WP_Customize_Selective_Refresh( $this ); |
|
| 271 | + if (in_array('selective_refresh', $components, true)) { |
|
| 272 | + require_once(ABSPATH.WPINC.'/customize/class-wp-customize-selective-refresh.php'); |
|
| 273 | + $this->selective_refresh = new WP_Customize_Selective_Refresh($this); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) ); |
|
| 276 | + add_filter('wp_die_handler', array($this, 'wp_die_handler')); |
|
| 277 | 277 | |
| 278 | - add_action( 'setup_theme', array( $this, 'setup_theme' ) ); |
|
| 279 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); |
|
| 278 | + add_action('setup_theme', array($this, 'setup_theme')); |
|
| 279 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 280 | 280 | |
| 281 | 281 | // Run wp_redirect_status late to make sure we override the status last. |
| 282 | - add_action( 'wp_redirect_status', array( $this, 'wp_redirect_status' ), 1000 ); |
|
| 282 | + add_action('wp_redirect_status', array($this, 'wp_redirect_status'), 1000); |
|
| 283 | 283 | |
| 284 | 284 | // Do not spawn cron (especially the alternate cron) while running the Customizer. |
| 285 | - remove_action( 'init', 'wp_cron' ); |
|
| 285 | + remove_action('init', 'wp_cron'); |
|
| 286 | 286 | |
| 287 | 287 | // Do not run update checks when rendering the controls. |
| 288 | - remove_action( 'admin_init', '_maybe_update_core' ); |
|
| 289 | - remove_action( 'admin_init', '_maybe_update_plugins' ); |
|
| 290 | - remove_action( 'admin_init', '_maybe_update_themes' ); |
|
| 288 | + remove_action('admin_init', '_maybe_update_core'); |
|
| 289 | + remove_action('admin_init', '_maybe_update_plugins'); |
|
| 290 | + remove_action('admin_init', '_maybe_update_themes'); |
|
| 291 | 291 | |
| 292 | - add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); |
|
| 293 | - add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); |
|
| 292 | + add_action('wp_ajax_customize_save', array($this, 'save')); |
|
| 293 | + add_action('wp_ajax_customize_refresh_nonces', array($this, 'refresh_nonces')); |
|
| 294 | 294 | |
| 295 | - add_action( 'customize_register', array( $this, 'register_controls' ) ); |
|
| 296 | - add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first |
|
| 297 | - add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) ); |
|
| 298 | - add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) ); |
|
| 295 | + add_action('customize_register', array($this, 'register_controls')); |
|
| 296 | + add_action('customize_register', array($this, 'register_dynamic_settings'), 11); // allow code to create settings first |
|
| 297 | + add_action('customize_controls_init', array($this, 'prepare_controls')); |
|
| 298 | + add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_control_scripts')); |
|
| 299 | 299 | |
| 300 | 300 | // Render Panel, Section, and Control templates. |
| 301 | - add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_panel_templates' ), 1 ); |
|
| 302 | - add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_section_templates' ), 1 ); |
|
| 303 | - add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_control_templates' ), 1 ); |
|
| 301 | + add_action('customize_controls_print_footer_scripts', array($this, 'render_panel_templates'), 1); |
|
| 302 | + add_action('customize_controls_print_footer_scripts', array($this, 'render_section_templates'), 1); |
|
| 303 | + add_action('customize_controls_print_footer_scripts', array($this, 'render_control_templates'), 1); |
|
| 304 | 304 | |
| 305 | 305 | // Export the settings to JS via the _wpCustomizeSettings variable. |
| 306 | - add_action( 'customize_controls_print_footer_scripts', array( $this, 'customize_pane_settings' ), 1000 ); |
|
| 306 | + add_action('customize_controls_print_footer_scripts', array($this, 'customize_pane_settings'), 1000); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -316,20 +316,20 @@ discard block |
||
| 316 | 316 | * @param string|null $action Whether the supplied AJAX action is being run. |
| 317 | 317 | * @return bool True if it's an AJAX request, false otherwise. |
| 318 | 318 | */ |
| 319 | - public function doing_ajax( $action = null ) { |
|
| 320 | - $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 321 | - if ( ! $doing_ajax ) { |
|
| 319 | + public function doing_ajax($action = null) { |
|
| 320 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
| 321 | + if ( ! $doing_ajax) { |
|
| 322 | 322 | return false; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if ( ! $action ) { |
|
| 325 | + if ( ! $action) { |
|
| 326 | 326 | return true; |
| 327 | 327 | } else { |
| 328 | 328 | /* |
| 329 | 329 | * Note: we can't just use doing_action( "wp_ajax_{$action}" ) because we need |
| 330 | 330 | * to check before admin-ajax.php gets to that point. |
| 331 | 331 | */ |
| 332 | - return isset( $_REQUEST['action'] ) && wp_unslash( $_REQUEST['action'] ) === $action; |
|
| 332 | + return isset($_REQUEST['action']) && wp_unslash($_REQUEST['action']) === $action; |
|
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
@@ -342,16 +342,16 @@ discard block |
||
| 342 | 342 | * @param mixed $ajax_message AJAX return |
| 343 | 343 | * @param mixed $message UI message |
| 344 | 344 | */ |
| 345 | - protected function wp_die( $ajax_message, $message = null ) { |
|
| 346 | - if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) { |
|
| 347 | - wp_die( $ajax_message ); |
|
| 345 | + protected function wp_die($ajax_message, $message = null) { |
|
| 346 | + if ($this->doing_ajax() || isset($_POST['customized'])) { |
|
| 347 | + wp_die($ajax_message); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if ( ! $message ) { |
|
| 351 | - $message = __( 'Cheatin’ uh?' ); |
|
| 350 | + if ( ! $message) { |
|
| 351 | + $message = __('Cheatin’ uh?'); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - wp_die( $message ); |
|
| 354 | + wp_die($message); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @return string |
| 363 | 363 | */ |
| 364 | 364 | public function wp_die_handler() { |
| 365 | - if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) { |
|
| 365 | + if ($this->doing_ajax() || isset($_POST['customized'])) { |
|
| 366 | 366 | return '_ajax_wp_die_handler'; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -379,41 +379,41 @@ discard block |
||
| 379 | 379 | public function setup_theme() { |
| 380 | 380 | send_origin_headers(); |
| 381 | 381 | |
| 382 | - $doing_ajax_or_is_customized = ( $this->doing_ajax() || isset( $_POST['customized'] ) ); |
|
| 383 | - if ( is_admin() && ! $doing_ajax_or_is_customized ) { |
|
| 382 | + $doing_ajax_or_is_customized = ($this->doing_ajax() || isset($_POST['customized'])); |
|
| 383 | + if (is_admin() && ! $doing_ajax_or_is_customized) { |
|
| 384 | 384 | auth_redirect(); |
| 385 | - } elseif ( $doing_ajax_or_is_customized && ! is_user_logged_in() ) { |
|
| 386 | - $this->wp_die( 0, __( 'You must be logged in to complete this action.' ) ); |
|
| 385 | + } elseif ($doing_ajax_or_is_customized && ! is_user_logged_in()) { |
|
| 386 | + $this->wp_die(0, __('You must be logged in to complete this action.')); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - show_admin_bar( false ); |
|
| 389 | + show_admin_bar(false); |
|
| 390 | 390 | |
| 391 | - if ( ! current_user_can( 'customize' ) ) { |
|
| 392 | - $this->wp_die( -1, __( 'You are not allowed to customize the appearance of this site.' ) ); |
|
| 391 | + if ( ! current_user_can('customize')) { |
|
| 392 | + $this->wp_die( -1, __('You are not allowed to customize the appearance of this site.') ); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $this->original_stylesheet = get_stylesheet(); |
| 396 | 396 | |
| 397 | - $this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null ); |
|
| 397 | + $this->theme = wp_get_theme(isset($_REQUEST['theme']) ? $_REQUEST['theme'] : null); |
|
| 398 | 398 | |
| 399 | - if ( $this->is_theme_active() ) { |
|
| 399 | + if ($this->is_theme_active()) { |
|
| 400 | 400 | // Once the theme is loaded, we'll validate it. |
| 401 | - add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) ); |
|
| 401 | + add_action('after_setup_theme', array($this, 'after_setup_theme')); |
|
| 402 | 402 | } else { |
| 403 | 403 | // If the requested theme is not the active theme and the user doesn't have the |
| 404 | 404 | // switch_themes cap, bail. |
| 405 | - if ( ! current_user_can( 'switch_themes' ) ) { |
|
| 406 | - $this->wp_die( -1, __( 'You are not allowed to edit theme options on this site.' ) ); |
|
| 405 | + if ( ! current_user_can('switch_themes')) { |
|
| 406 | + $this->wp_die( -1, __('You are not allowed to edit theme options on this site.') ); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | // If the theme has errors while loading, bail. |
| 410 | - if ( $this->theme()->errors() ) { |
|
| 410 | + if ($this->theme()->errors()) { |
|
| 411 | 411 | $this->wp_die( -1, $this->theme()->errors()->get_error_message() ); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // If the theme isn't allowed per multisite settings, bail. |
| 415 | - if ( ! $this->theme()->is_allowed() ) { |
|
| 416 | - $this->wp_die( -1, __( 'The requested theme does not exist.' ) ); |
|
| 415 | + if ( ! $this->theme()->is_allowed()) { |
|
| 416 | + $this->wp_die( -1, __('The requested theme does not exist.') ); |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | |
@@ -426,9 +426,9 @@ discard block |
||
| 426 | 426 | * @since 3.4.0 |
| 427 | 427 | */ |
| 428 | 428 | public function after_setup_theme() { |
| 429 | - $doing_ajax_or_is_customized = ( $this->doing_ajax() || isset( $_SERVER['customized'] ) ); |
|
| 430 | - if ( ! $doing_ajax_or_is_customized && ! validate_current_theme() ) { |
|
| 431 | - wp_redirect( 'themes.php?broken=true' ); |
|
| 429 | + $doing_ajax_or_is_customized = ($this->doing_ajax() || isset($_SERVER['customized'])); |
|
| 430 | + if ( ! $doing_ajax_or_is_customized && ! validate_current_theme()) { |
|
| 431 | + wp_redirect('themes.php?broken=true'); |
|
| 432 | 432 | exit; |
| 433 | 433 | } |
| 434 | 434 | } |
@@ -441,24 +441,24 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | public function start_previewing_theme() { |
| 443 | 443 | // Bail if we're already previewing. |
| 444 | - if ( $this->is_preview() ) { |
|
| 444 | + if ($this->is_preview()) { |
|
| 445 | 445 | return; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | $this->previewing = true; |
| 449 | 449 | |
| 450 | - if ( ! $this->is_theme_active() ) { |
|
| 451 | - add_filter( 'template', array( $this, 'get_template' ) ); |
|
| 452 | - add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); |
|
| 453 | - add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); |
|
| 450 | + if ( ! $this->is_theme_active()) { |
|
| 451 | + add_filter('template', array($this, 'get_template')); |
|
| 452 | + add_filter('stylesheet', array($this, 'get_stylesheet')); |
|
| 453 | + add_filter('pre_option_current_theme', array($this, 'current_theme')); |
|
| 454 | 454 | |
| 455 | 455 | // @link: https://core.trac.wordpress.org/ticket/20027 |
| 456 | - add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); |
|
| 457 | - add_filter( 'pre_option_template', array( $this, 'get_template' ) ); |
|
| 456 | + add_filter('pre_option_stylesheet', array($this, 'get_stylesheet')); |
|
| 457 | + add_filter('pre_option_template', array($this, 'get_template')); |
|
| 458 | 458 | |
| 459 | 459 | // Handle custom theme roots. |
| 460 | - add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); |
|
| 461 | - add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); |
|
| 460 | + add_filter('pre_option_stylesheet_root', array($this, 'get_stylesheet_root')); |
|
| 461 | + add_filter('pre_option_template_root', array($this, 'get_template_root')); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * |
| 469 | 469 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 470 | 470 | */ |
| 471 | - do_action( 'start_previewing_theme', $this ); |
|
| 471 | + do_action('start_previewing_theme', $this); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -479,24 +479,24 @@ discard block |
||
| 479 | 479 | * @since 3.4.0 |
| 480 | 480 | */ |
| 481 | 481 | public function stop_previewing_theme() { |
| 482 | - if ( ! $this->is_preview() ) { |
|
| 482 | + if ( ! $this->is_preview()) { |
|
| 483 | 483 | return; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | $this->previewing = false; |
| 487 | 487 | |
| 488 | - if ( ! $this->is_theme_active() ) { |
|
| 489 | - remove_filter( 'template', array( $this, 'get_template' ) ); |
|
| 490 | - remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); |
|
| 491 | - remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); |
|
| 488 | + if ( ! $this->is_theme_active()) { |
|
| 489 | + remove_filter('template', array($this, 'get_template')); |
|
| 490 | + remove_filter('stylesheet', array($this, 'get_stylesheet')); |
|
| 491 | + remove_filter('pre_option_current_theme', array($this, 'current_theme')); |
|
| 492 | 492 | |
| 493 | 493 | // @link: https://core.trac.wordpress.org/ticket/20027 |
| 494 | - remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); |
|
| 495 | - remove_filter( 'pre_option_template', array( $this, 'get_template' ) ); |
|
| 494 | + remove_filter('pre_option_stylesheet', array($this, 'get_stylesheet')); |
|
| 495 | + remove_filter('pre_option_template', array($this, 'get_template')); |
|
| 496 | 496 | |
| 497 | 497 | // Handle custom theme roots. |
| 498 | - remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); |
|
| 499 | - remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); |
|
| 498 | + remove_filter('pre_option_stylesheet_root', array($this, 'get_stylesheet_root')); |
|
| 499 | + remove_filter('pre_option_template_root', array($this, 'get_template_root')); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 508 | 508 | */ |
| 509 | - do_action( 'stop_previewing_theme', $this ); |
|
| 509 | + do_action('stop_previewing_theme', $this); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * @return WP_Theme |
| 518 | 518 | */ |
| 519 | 519 | public function theme() { |
| 520 | - if ( ! $this->theme ) { |
|
| 520 | + if ( ! $this->theme) { |
|
| 521 | 521 | $this->theme = wp_get_theme(); |
| 522 | 522 | } |
| 523 | 523 | return $this->theme; |
@@ -604,9 +604,9 @@ discard block |
||
| 604 | 604 | * |
| 605 | 605 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 606 | 606 | */ |
| 607 | - do_action( 'customize_register', $this ); |
|
| 607 | + do_action('customize_register', $this); |
|
| 608 | 608 | |
| 609 | - if ( $this->is_preview() && ! is_admin() ) |
|
| 609 | + if ($this->is_preview() && ! is_admin()) |
|
| 610 | 610 | $this->customize_preview_init(); |
| 611 | 611 | } |
| 612 | 612 | |
@@ -621,8 +621,8 @@ discard block |
||
| 621 | 621 | * @param $status |
| 622 | 622 | * @return int |
| 623 | 623 | */ |
| 624 | - public function wp_redirect_status( $status ) { |
|
| 625 | - if ( $this->is_preview() && ! is_admin() ) |
|
| 624 | + public function wp_redirect_status($status) { |
|
| 625 | + if ($this->is_preview() && ! is_admin()) |
|
| 626 | 626 | return 200; |
| 627 | 627 | |
| 628 | 628 | return $status; |
@@ -637,15 +637,15 @@ discard block |
||
| 637 | 637 | * @return array |
| 638 | 638 | */ |
| 639 | 639 | public function unsanitized_post_values() { |
| 640 | - if ( ! isset( $this->_post_values ) ) { |
|
| 641 | - if ( isset( $_POST['customized'] ) ) { |
|
| 642 | - $this->_post_values = json_decode( wp_unslash( $_POST['customized'] ), true ); |
|
| 640 | + if ( ! isset($this->_post_values)) { |
|
| 641 | + if (isset($_POST['customized'])) { |
|
| 642 | + $this->_post_values = json_decode(wp_unslash($_POST['customized']), true); |
|
| 643 | 643 | } |
| 644 | - if ( empty( $this->_post_values ) ) { // if not isset or if JSON error |
|
| 644 | + if (empty($this->_post_values)) { // if not isset or if JSON error |
|
| 645 | 645 | $this->_post_values = array(); |
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | - if ( empty( $this->_post_values ) ) { |
|
| 648 | + if (empty($this->_post_values)) { |
|
| 649 | 649 | return array(); |
| 650 | 650 | } else { |
| 651 | 651 | return $this->_post_values; |
@@ -662,10 +662,10 @@ discard block |
||
| 662 | 662 | * @param mixed $default value returned $setting has no post value (added in 4.2.0). |
| 663 | 663 | * @return string|mixed $post_value Sanitized value or the $default provided |
| 664 | 664 | */ |
| 665 | - public function post_value( $setting, $default = null ) { |
|
| 665 | + public function post_value($setting, $default = null) { |
|
| 666 | 666 | $post_values = $this->unsanitized_post_values(); |
| 667 | - if ( array_key_exists( $setting->id, $post_values ) ) { |
|
| 668 | - return $setting->sanitize( $post_values[ $setting->id ] ); |
|
| 667 | + if (array_key_exists($setting->id, $post_values)) { |
|
| 668 | + return $setting->sanitize($post_values[$setting->id]); |
|
| 669 | 669 | } else { |
| 670 | 670 | return $default; |
| 671 | 671 | } |
@@ -680,9 +680,9 @@ discard block |
||
| 680 | 680 | * @param string $setting_id ID for the WP_Customize_Setting instance. |
| 681 | 681 | * @param mixed $value Post value. |
| 682 | 682 | */ |
| 683 | - public function set_post_value( $setting_id, $value ) { |
|
| 683 | + public function set_post_value($setting_id, $value) { |
|
| 684 | 684 | $this->unsanitized_post_values(); |
| 685 | - $this->_post_values[ $setting_id ] = $value; |
|
| 685 | + $this->_post_values[$setting_id] = $value; |
|
| 686 | 686 | |
| 687 | 687 | /** |
| 688 | 688 | * Announce when a specific setting's unsanitized post value has been set. |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | * @param mixed $value Unsanitized setting post value. |
| 697 | 697 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 698 | 698 | */ |
| 699 | - do_action( "customize_post_value_set_{$setting_id}", $value, $this ); |
|
| 699 | + do_action("customize_post_value_set_{$setting_id}", $value, $this); |
|
| 700 | 700 | |
| 701 | 701 | /** |
| 702 | 702 | * Announce when any setting's unsanitized post value has been set. |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | * @param mixed $value Unsanitized setting post value. |
| 713 | 713 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 714 | 714 | */ |
| 715 | - do_action( 'customize_post_value_set', $setting_id, $value, $this ); |
|
| 715 | + do_action('customize_post_value_set', $setting_id, $value, $this); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
@@ -721,20 +721,20 @@ discard block |
||
| 721 | 721 | * @since 3.4.0 |
| 722 | 722 | */ |
| 723 | 723 | public function customize_preview_init() { |
| 724 | - $this->nonce_tick = check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce' ); |
|
| 724 | + $this->nonce_tick = check_ajax_referer('preview-customize_'.$this->get_stylesheet(), 'nonce'); |
|
| 725 | 725 | |
| 726 | 726 | $this->prepare_controls(); |
| 727 | 727 | |
| 728 | - wp_enqueue_script( 'customize-preview' ); |
|
| 729 | - add_action( 'wp', array( $this, 'customize_preview_override_404_status' ) ); |
|
| 730 | - add_action( 'wp_head', array( $this, 'customize_preview_base' ) ); |
|
| 731 | - add_action( 'wp_head', array( $this, 'customize_preview_html5' ) ); |
|
| 732 | - add_action( 'wp_head', array( $this, 'customize_preview_loading_style' ) ); |
|
| 733 | - add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 ); |
|
| 734 | - add_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 ); |
|
| 735 | - add_filter( 'wp_die_handler', array( $this, 'remove_preview_signature' ) ); |
|
| 728 | + wp_enqueue_script('customize-preview'); |
|
| 729 | + add_action('wp', array($this, 'customize_preview_override_404_status')); |
|
| 730 | + add_action('wp_head', array($this, 'customize_preview_base')); |
|
| 731 | + add_action('wp_head', array($this, 'customize_preview_html5')); |
|
| 732 | + add_action('wp_head', array($this, 'customize_preview_loading_style')); |
|
| 733 | + add_action('wp_footer', array($this, 'customize_preview_settings'), 20); |
|
| 734 | + add_action('shutdown', array($this, 'customize_preview_signature'), 1000); |
|
| 735 | + add_filter('wp_die_handler', array($this, 'remove_preview_signature')); |
|
| 736 | 736 | |
| 737 | - foreach ( $this->settings as $setting ) { |
|
| 737 | + foreach ($this->settings as $setting) { |
|
| 738 | 738 | $setting->preview(); |
| 739 | 739 | } |
| 740 | 740 | |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | * |
| 747 | 747 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 748 | 748 | */ |
| 749 | - do_action( 'customize_preview_init', $this ); |
|
| 749 | + do_action('customize_preview_init', $this); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
@@ -757,8 +757,8 @@ discard block |
||
| 757 | 757 | * @access public |
| 758 | 758 | */ |
| 759 | 759 | public function customize_preview_override_404_status() { |
| 760 | - if ( is_404() ) { |
|
| 761 | - status_header( 200 ); |
|
| 760 | + if (is_404()) { |
|
| 761 | + status_header(200); |
|
| 762 | 762 | } |
| 763 | 763 | } |
| 764 | 764 | |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | * @since 3.4.0 |
| 769 | 769 | */ |
| 770 | 770 | public function customize_preview_base() { |
| 771 | - ?><base href="<?php echo home_url( '/' ); ?>" /><?php |
|
| 771 | + ?><base href="<?php echo home_url('/'); ?>" /><?php |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | /** |
@@ -821,43 +821,43 @@ discard block |
||
| 821 | 821 | 'active' => $this->is_theme_active(), |
| 822 | 822 | ), |
| 823 | 823 | 'url' => array( |
| 824 | - 'self' => empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
| 824 | + 'self' => empty($_SERVER['REQUEST_URI']) ? home_url('/') : esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])), |
|
| 825 | 825 | ), |
| 826 | - 'channel' => wp_unslash( $_POST['customize_messenger_channel'] ), |
|
| 826 | + 'channel' => wp_unslash($_POST['customize_messenger_channel']), |
|
| 827 | 827 | 'activePanels' => array(), |
| 828 | 828 | 'activeSections' => array(), |
| 829 | 829 | 'activeControls' => array(), |
| 830 | 830 | 'nonce' => $this->get_nonces(), |
| 831 | 831 | 'l10n' => array( |
| 832 | - 'shiftClickToEdit' => __( 'Shift-click to edit this element.' ), |
|
| 832 | + 'shiftClickToEdit' => __('Shift-click to edit this element.'), |
|
| 833 | 833 | ), |
| 834 | - '_dirty' => array_keys( $this->unsanitized_post_values() ), |
|
| 834 | + '_dirty' => array_keys($this->unsanitized_post_values()), |
|
| 835 | 835 | ); |
| 836 | 836 | |
| 837 | - foreach ( $this->panels as $panel_id => $panel ) { |
|
| 838 | - if ( $panel->check_capabilities() ) { |
|
| 839 | - $settings['activePanels'][ $panel_id ] = $panel->active(); |
|
| 840 | - foreach ( $panel->sections as $section_id => $section ) { |
|
| 841 | - if ( $section->check_capabilities() ) { |
|
| 842 | - $settings['activeSections'][ $section_id ] = $section->active(); |
|
| 837 | + foreach ($this->panels as $panel_id => $panel) { |
|
| 838 | + if ($panel->check_capabilities()) { |
|
| 839 | + $settings['activePanels'][$panel_id] = $panel->active(); |
|
| 840 | + foreach ($panel->sections as $section_id => $section) { |
|
| 841 | + if ($section->check_capabilities()) { |
|
| 842 | + $settings['activeSections'][$section_id] = $section->active(); |
|
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | - foreach ( $this->sections as $id => $section ) { |
|
| 848 | - if ( $section->check_capabilities() ) { |
|
| 849 | - $settings['activeSections'][ $id ] = $section->active(); |
|
| 847 | + foreach ($this->sections as $id => $section) { |
|
| 848 | + if ($section->check_capabilities()) { |
|
| 849 | + $settings['activeSections'][$id] = $section->active(); |
|
| 850 | 850 | } |
| 851 | 851 | } |
| 852 | - foreach ( $this->controls as $id => $control ) { |
|
| 853 | - if ( $control->check_capabilities() ) { |
|
| 854 | - $settings['activeControls'][ $id ] = $control->active(); |
|
| 852 | + foreach ($this->controls as $id => $control) { |
|
| 853 | + if ($control->check_capabilities()) { |
|
| 854 | + $settings['activeControls'][$id] = $control->active(); |
|
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | ?> |
| 859 | 859 | <script type="text/javascript"> |
| 860 | - var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>; |
|
| 860 | + var _wpCustomizeSettings = <?php echo wp_json_encode($settings); ?>; |
|
| 861 | 861 | _wpCustomizeSettings.values = {}; |
| 862 | 862 | (function( v ) { |
| 863 | 863 | <?php |
@@ -866,12 +866,12 @@ discard block |
||
| 866 | 866 | * serialization in order to avoid a peak memory usage spike. |
| 867 | 867 | * @todo We may not even need to export the values at all since the pane syncs them anyway. |
| 868 | 868 | */ |
| 869 | - foreach ( $this->settings as $id => $setting ) { |
|
| 870 | - if ( $setting->check_capabilities() ) { |
|
| 869 | + foreach ($this->settings as $id => $setting) { |
|
| 870 | + if ($setting->check_capabilities()) { |
|
| 871 | 871 | printf( |
| 872 | 872 | "v[%s] = %s;\n", |
| 873 | - wp_json_encode( $id ), |
|
| 874 | - wp_json_encode( $setting->js_value() ) |
|
| 873 | + wp_json_encode($id), |
|
| 874 | + wp_json_encode($setting->js_value()) |
|
| 875 | 875 | ); |
| 876 | 876 | } |
| 877 | 877 | } |
@@ -898,8 +898,8 @@ discard block |
||
| 898 | 898 | * @param mixed $return Value passed through for wp_die_handler filter. |
| 899 | 899 | * @return mixed Value passed through for wp_die_handler filter. |
| 900 | 900 | */ |
| 901 | - public function remove_preview_signature( $return = null ) { |
|
| 902 | - remove_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 ); |
|
| 901 | + public function remove_preview_signature($return = null) { |
|
| 902 | + remove_action('shutdown', array($this, 'customize_preview_signature'), 1000); |
|
| 903 | 903 | |
| 904 | 904 | return $return; |
| 905 | 905 | } |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | * @return string Theme root. |
| 946 | 946 | */ |
| 947 | 947 | public function get_template_root() { |
| 948 | - return get_raw_theme_root( $this->get_template(), true ); |
|
| 948 | + return get_raw_theme_root($this->get_template(), true); |
|
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | /** |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | * @return string Theme root. |
| 957 | 957 | */ |
| 958 | 958 | public function get_stylesheet_root() { |
| 959 | - return get_raw_theme_root( $this->get_stylesheet(), true ); |
|
| 959 | + return get_raw_theme_root($this->get_stylesheet(), true); |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | /** |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | * @param $current_theme {@internal Parameter is not used} |
| 968 | 968 | * @return string Theme name. |
| 969 | 969 | */ |
| 970 | - public function current_theme( $current_theme ) { |
|
| 970 | + public function current_theme($current_theme) { |
|
| 971 | 971 | return $this->theme()->display('Name'); |
| 972 | 972 | } |
| 973 | 973 | |
@@ -977,22 +977,22 @@ discard block |
||
| 977 | 977 | * @since 3.4.0 |
| 978 | 978 | */ |
| 979 | 979 | public function save() { |
| 980 | - if ( ! $this->is_preview() ) { |
|
| 981 | - wp_send_json_error( 'not_preview' ); |
|
| 980 | + if ( ! $this->is_preview()) { |
|
| 981 | + wp_send_json_error('not_preview'); |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - $action = 'save-customize_' . $this->get_stylesheet(); |
|
| 985 | - if ( ! check_ajax_referer( $action, 'nonce', false ) ) { |
|
| 986 | - wp_send_json_error( 'invalid_nonce' ); |
|
| 984 | + $action = 'save-customize_'.$this->get_stylesheet(); |
|
| 985 | + if ( ! check_ajax_referer($action, 'nonce', false)) { |
|
| 986 | + wp_send_json_error('invalid_nonce'); |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | // Do we have to switch themes? |
| 990 | - if ( ! $this->is_theme_active() ) { |
|
| 990 | + if ( ! $this->is_theme_active()) { |
|
| 991 | 991 | // Temporarily stop previewing the theme to allow switch_themes() |
| 992 | 992 | // to operate properly. |
| 993 | 993 | $this->stop_previewing_theme(); |
| 994 | - switch_theme( $this->get_stylesheet() ); |
|
| 995 | - update_option( 'theme_switched_via_customizer', true ); |
|
| 994 | + switch_theme($this->get_stylesheet()); |
|
| 995 | + update_option('theme_switched_via_customizer', true); |
|
| 996 | 996 | $this->start_previewing_theme(); |
| 997 | 997 | } |
| 998 | 998 | |
@@ -1004,9 +1004,9 @@ discard block |
||
| 1004 | 1004 | * |
| 1005 | 1005 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 1006 | 1006 | */ |
| 1007 | - do_action( 'customize_save', $this ); |
|
| 1007 | + do_action('customize_save', $this); |
|
| 1008 | 1008 | |
| 1009 | - foreach ( $this->settings as $setting ) { |
|
| 1009 | + foreach ($this->settings as $setting) { |
|
| 1010 | 1010 | $setting->save(); |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | * |
| 1018 | 1018 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 1019 | 1019 | */ |
| 1020 | - do_action( 'customize_save_after', $this ); |
|
| 1020 | + do_action('customize_save_after', $this); |
|
| 1021 | 1021 | |
| 1022 | 1022 | /** |
| 1023 | 1023 | * Filter response data for a successful customize_save AJAX request. |
@@ -1030,8 +1030,8 @@ discard block |
||
| 1030 | 1030 | * event on `wp.customize`. |
| 1031 | 1031 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 1032 | 1032 | */ |
| 1033 | - $response = apply_filters( 'customize_save_response', array(), $this ); |
|
| 1034 | - wp_send_json_success( $response ); |
|
| 1033 | + $response = apply_filters('customize_save_response', array(), $this); |
|
| 1034 | + wp_send_json_success($response); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | /** |
@@ -1040,11 +1040,11 @@ discard block |
||
| 1040 | 1040 | * @since 4.2.0 |
| 1041 | 1041 | */ |
| 1042 | 1042 | public function refresh_nonces() { |
| 1043 | - if ( ! $this->is_preview() ) { |
|
| 1044 | - wp_send_json_error( 'not_preview' ); |
|
| 1043 | + if ( ! $this->is_preview()) { |
|
| 1044 | + wp_send_json_error('not_preview'); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | - wp_send_json_success( $this->get_nonces() ); |
|
| 1047 | + wp_send_json_success($this->get_nonces()); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | 1050 | /** |
@@ -1059,22 +1059,22 @@ discard block |
||
| 1059 | 1059 | * constructor. |
| 1060 | 1060 | * @return WP_Customize_Setting The instance of the setting that was added. |
| 1061 | 1061 | */ |
| 1062 | - public function add_setting( $id, $args = array() ) { |
|
| 1063 | - if ( $id instanceof WP_Customize_Setting ) { |
|
| 1062 | + public function add_setting($id, $args = array()) { |
|
| 1063 | + if ($id instanceof WP_Customize_Setting) { |
|
| 1064 | 1064 | $setting = $id; |
| 1065 | 1065 | } else { |
| 1066 | 1066 | $class = 'WP_Customize_Setting'; |
| 1067 | 1067 | |
| 1068 | 1068 | /** This filter is documented in wp-includes/class-wp-customize-manager.php */ |
| 1069 | - $args = apply_filters( 'customize_dynamic_setting_args', $args, $id ); |
|
| 1069 | + $args = apply_filters('customize_dynamic_setting_args', $args, $id); |
|
| 1070 | 1070 | |
| 1071 | 1071 | /** This filter is documented in wp-includes/class-wp-customize-manager.php */ |
| 1072 | - $class = apply_filters( 'customize_dynamic_setting_class', $class, $id, $args ); |
|
| 1072 | + $class = apply_filters('customize_dynamic_setting_class', $class, $id, $args); |
|
| 1073 | 1073 | |
| 1074 | - $setting = new $class( $this, $id, $args ); |
|
| 1074 | + $setting = new $class($this, $id, $args); |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | - $this->settings[ $setting->id ] = $setting; |
|
| 1077 | + $this->settings[$setting->id] = $setting; |
|
| 1078 | 1078 | return $setting; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
@@ -1093,11 +1093,11 @@ discard block |
||
| 1093 | 1093 | * @param array $setting_ids The setting IDs to add. |
| 1094 | 1094 | * @return array The WP_Customize_Setting objects added. |
| 1095 | 1095 | */ |
| 1096 | - public function add_dynamic_settings( $setting_ids ) { |
|
| 1096 | + public function add_dynamic_settings($setting_ids) { |
|
| 1097 | 1097 | $new_settings = array(); |
| 1098 | - foreach ( $setting_ids as $setting_id ) { |
|
| 1098 | + foreach ($setting_ids as $setting_id) { |
|
| 1099 | 1099 | // Skip settings already created |
| 1100 | - if ( $this->get_setting( $setting_id ) ) { |
|
| 1100 | + if ($this->get_setting($setting_id)) { |
|
| 1101 | 1101 | continue; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
@@ -1116,8 +1116,8 @@ discard block |
||
| 1116 | 1116 | * @param false|array $setting_args The arguments to the WP_Customize_Setting constructor. |
| 1117 | 1117 | * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. |
| 1118 | 1118 | */ |
| 1119 | - $setting_args = apply_filters( 'customize_dynamic_setting_args', $setting_args, $setting_id ); |
|
| 1120 | - if ( false === $setting_args ) { |
|
| 1119 | + $setting_args = apply_filters('customize_dynamic_setting_args', $setting_args, $setting_id); |
|
| 1120 | + if (false === $setting_args) { |
|
| 1121 | 1121 | continue; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
@@ -1130,11 +1130,11 @@ discard block |
||
| 1130 | 1130 | * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. |
| 1131 | 1131 | * @param array $setting_args WP_Customize_Setting or a subclass. |
| 1132 | 1132 | */ |
| 1133 | - $setting_class = apply_filters( 'customize_dynamic_setting_class', $setting_class, $setting_id, $setting_args ); |
|
| 1133 | + $setting_class = apply_filters('customize_dynamic_setting_class', $setting_class, $setting_id, $setting_args); |
|
| 1134 | 1134 | |
| 1135 | - $setting = new $setting_class( $this, $setting_id, $setting_args ); |
|
| 1135 | + $setting = new $setting_class($this, $setting_id, $setting_args); |
|
| 1136 | 1136 | |
| 1137 | - $this->add_setting( $setting ); |
|
| 1137 | + $this->add_setting($setting); |
|
| 1138 | 1138 | $new_settings[] = $setting; |
| 1139 | 1139 | } |
| 1140 | 1140 | return $new_settings; |
@@ -1148,9 +1148,9 @@ discard block |
||
| 1148 | 1148 | * @param string $id Customize Setting ID. |
| 1149 | 1149 | * @return WP_Customize_Setting|void The setting, if set. |
| 1150 | 1150 | */ |
| 1151 | - public function get_setting( $id ) { |
|
| 1152 | - if ( isset( $this->settings[ $id ] ) ) { |
|
| 1153 | - return $this->settings[ $id ]; |
|
| 1151 | + public function get_setting($id) { |
|
| 1152 | + if (isset($this->settings[$id])) { |
|
| 1153 | + return $this->settings[$id]; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | } |
| 1156 | 1156 | |
@@ -1161,8 +1161,8 @@ discard block |
||
| 1161 | 1161 | * |
| 1162 | 1162 | * @param string $id Customize Setting ID. |
| 1163 | 1163 | */ |
| 1164 | - public function remove_setting( $id ) { |
|
| 1165 | - unset( $this->settings[ $id ] ); |
|
| 1164 | + public function remove_setting($id) { |
|
| 1165 | + unset($this->settings[$id]); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1177,14 +1177,14 @@ discard block |
||
| 1177 | 1177 | * |
| 1178 | 1178 | * @return WP_Customize_Panel The instance of the panel that was added. |
| 1179 | 1179 | */ |
| 1180 | - public function add_panel( $id, $args = array() ) { |
|
| 1181 | - if ( $id instanceof WP_Customize_Panel ) { |
|
| 1180 | + public function add_panel($id, $args = array()) { |
|
| 1181 | + if ($id instanceof WP_Customize_Panel) { |
|
| 1182 | 1182 | $panel = $id; |
| 1183 | 1183 | } else { |
| 1184 | - $panel = new WP_Customize_Panel( $this, $id, $args ); |
|
| 1184 | + $panel = new WP_Customize_Panel($this, $id, $args); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - $this->panels[ $panel->id ] = $panel; |
|
| 1187 | + $this->panels[$panel->id] = $panel; |
|
| 1188 | 1188 | return $panel; |
| 1189 | 1189 | } |
| 1190 | 1190 | |
@@ -1197,9 +1197,9 @@ discard block |
||
| 1197 | 1197 | * @param string $id Panel ID to get. |
| 1198 | 1198 | * @return WP_Customize_Panel|void Requested panel instance, if set. |
| 1199 | 1199 | */ |
| 1200 | - public function get_panel( $id ) { |
|
| 1201 | - if ( isset( $this->panels[ $id ] ) ) { |
|
| 1202 | - return $this->panels[ $id ]; |
|
| 1200 | + public function get_panel($id) { |
|
| 1201 | + if (isset($this->panels[$id])) { |
|
| 1202 | + return $this->panels[$id]; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | } |
| 1205 | 1205 | |
@@ -1211,18 +1211,18 @@ discard block |
||
| 1211 | 1211 | * |
| 1212 | 1212 | * @param string $id Panel ID to remove. |
| 1213 | 1213 | */ |
| 1214 | - public function remove_panel( $id ) { |
|
| 1214 | + public function remove_panel($id) { |
|
| 1215 | 1215 | // Removing core components this way is _doing_it_wrong(). |
| 1216 | - if ( in_array( $id, $this->components, true ) ) { |
|
| 1216 | + if (in_array($id, $this->components, true)) { |
|
| 1217 | 1217 | /* translators: 1: panel id, 2: link to 'customize_loaded_components' filter reference */ |
| 1218 | - $message = sprintf( __( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ), |
|
| 1218 | + $message = sprintf(__('Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.'), |
|
| 1219 | 1219 | $id, |
| 1220 | - '<a href="' . esc_url( 'https://developer.wordpress.org/reference/hooks/customize_loaded_components/' ) . '"><code>customize_loaded_components</code></a>' |
|
| 1220 | + '<a href="'.esc_url('https://developer.wordpress.org/reference/hooks/customize_loaded_components/').'"><code>customize_loaded_components</code></a>' |
|
| 1221 | 1221 | ); |
| 1222 | 1222 | |
| 1223 | - _doing_it_wrong( __METHOD__, $message, '4.5' ); |
|
| 1223 | + _doing_it_wrong(__METHOD__, $message, '4.5'); |
|
| 1224 | 1224 | } |
| 1225 | - unset( $this->panels[ $id ] ); |
|
| 1225 | + unset($this->panels[$id]); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | /** |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | * |
| 1238 | 1238 | * @param string $panel Name of a custom panel which is a subclass of WP_Customize_Panel. |
| 1239 | 1239 | */ |
| 1240 | - public function register_panel_type( $panel ) { |
|
| 1240 | + public function register_panel_type($panel) { |
|
| 1241 | 1241 | $this->registered_panel_types[] = $panel; |
| 1242 | 1242 | } |
| 1243 | 1243 | |
@@ -1248,8 +1248,8 @@ discard block |
||
| 1248 | 1248 | * @access public |
| 1249 | 1249 | */ |
| 1250 | 1250 | public function render_panel_templates() { |
| 1251 | - foreach ( $this->registered_panel_types as $panel_type ) { |
|
| 1252 | - $panel = new $panel_type( $this, 'temp', array() ); |
|
| 1251 | + foreach ($this->registered_panel_types as $panel_type) { |
|
| 1252 | + $panel = new $panel_type($this, 'temp', array()); |
|
| 1253 | 1253 | $panel->print_template(); |
| 1254 | 1254 | } |
| 1255 | 1255 | } |
@@ -1266,14 +1266,14 @@ discard block |
||
| 1266 | 1266 | * |
| 1267 | 1267 | * @return WP_Customize_Section The instance of the section that was added. |
| 1268 | 1268 | */ |
| 1269 | - public function add_section( $id, $args = array() ) { |
|
| 1270 | - if ( $id instanceof WP_Customize_Section ) { |
|
| 1269 | + public function add_section($id, $args = array()) { |
|
| 1270 | + if ($id instanceof WP_Customize_Section) { |
|
| 1271 | 1271 | $section = $id; |
| 1272 | 1272 | } else { |
| 1273 | - $section = new WP_Customize_Section( $this, $id, $args ); |
|
| 1273 | + $section = new WP_Customize_Section($this, $id, $args); |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | - $this->sections[ $section->id ] = $section; |
|
| 1276 | + $this->sections[$section->id] = $section; |
|
| 1277 | 1277 | return $section; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
@@ -1285,9 +1285,9 @@ discard block |
||
| 1285 | 1285 | * @param string $id Section ID. |
| 1286 | 1286 | * @return WP_Customize_Section|void The section, if set. |
| 1287 | 1287 | */ |
| 1288 | - public function get_section( $id ) { |
|
| 1289 | - if ( isset( $this->sections[ $id ] ) ) |
|
| 1290 | - return $this->sections[ $id ]; |
|
| 1288 | + public function get_section($id) { |
|
| 1289 | + if (isset($this->sections[$id])) |
|
| 1290 | + return $this->sections[$id]; |
|
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | 1293 | /** |
@@ -1297,8 +1297,8 @@ discard block |
||
| 1297 | 1297 | * |
| 1298 | 1298 | * @param string $id Section ID. |
| 1299 | 1299 | */ |
| 1300 | - public function remove_section( $id ) { |
|
| 1301 | - unset( $this->sections[ $id ] ); |
|
| 1300 | + public function remove_section($id) { |
|
| 1301 | + unset($this->sections[$id]); |
|
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | /** |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | * |
| 1314 | 1314 | * @param string $section Name of a custom section which is a subclass of WP_Customize_Section. |
| 1315 | 1315 | */ |
| 1316 | - public function register_section_type( $section ) { |
|
| 1316 | + public function register_section_type($section) { |
|
| 1317 | 1317 | $this->registered_section_types[] = $section; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
@@ -1324,8 +1324,8 @@ discard block |
||
| 1324 | 1324 | * @access public |
| 1325 | 1325 | */ |
| 1326 | 1326 | public function render_section_templates() { |
| 1327 | - foreach ( $this->registered_section_types as $section_type ) { |
|
| 1328 | - $section = new $section_type( $this, 'temp', array() ); |
|
| 1327 | + foreach ($this->registered_section_types as $section_type) { |
|
| 1328 | + $section = new $section_type($this, 'temp', array()); |
|
| 1329 | 1329 | $section->print_template(); |
| 1330 | 1330 | } |
| 1331 | 1331 | } |
@@ -1342,14 +1342,14 @@ discard block |
||
| 1342 | 1342 | * constructor. |
| 1343 | 1343 | * @return WP_Customize_Control The instance of the control that was added. |
| 1344 | 1344 | */ |
| 1345 | - public function add_control( $id, $args = array() ) { |
|
| 1346 | - if ( $id instanceof WP_Customize_Control ) { |
|
| 1345 | + public function add_control($id, $args = array()) { |
|
| 1346 | + if ($id instanceof WP_Customize_Control) { |
|
| 1347 | 1347 | $control = $id; |
| 1348 | 1348 | } else { |
| 1349 | - $control = new WP_Customize_Control( $this, $id, $args ); |
|
| 1349 | + $control = new WP_Customize_Control($this, $id, $args); |
|
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | - $this->controls[ $control->id ] = $control; |
|
| 1352 | + $this->controls[$control->id] = $control; |
|
| 1353 | 1353 | return $control; |
| 1354 | 1354 | } |
| 1355 | 1355 | |
@@ -1361,9 +1361,9 @@ discard block |
||
| 1361 | 1361 | * @param string $id ID of the control. |
| 1362 | 1362 | * @return WP_Customize_Control|void The control object, if set. |
| 1363 | 1363 | */ |
| 1364 | - public function get_control( $id ) { |
|
| 1365 | - if ( isset( $this->controls[ $id ] ) ) |
|
| 1366 | - return $this->controls[ $id ]; |
|
| 1364 | + public function get_control($id) { |
|
| 1365 | + if (isset($this->controls[$id])) |
|
| 1366 | + return $this->controls[$id]; |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | /** |
@@ -1373,8 +1373,8 @@ discard block |
||
| 1373 | 1373 | * |
| 1374 | 1374 | * @param string $id ID of the control. |
| 1375 | 1375 | */ |
| 1376 | - public function remove_control( $id ) { |
|
| 1377 | - unset( $this->controls[ $id ] ); |
|
| 1376 | + public function remove_control($id) { |
|
| 1377 | + unset($this->controls[$id]); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | /** |
@@ -1388,7 +1388,7 @@ discard block |
||
| 1388 | 1388 | * @param string $control Name of a custom control which is a subclass of |
| 1389 | 1389 | * {@see WP_Customize_Control}. |
| 1390 | 1390 | */ |
| 1391 | - public function register_control_type( $control ) { |
|
| 1391 | + public function register_control_type($control) { |
|
| 1392 | 1392 | $this->registered_control_types[] = $control; |
| 1393 | 1393 | } |
| 1394 | 1394 | |
@@ -1399,10 +1399,10 @@ discard block |
||
| 1399 | 1399 | * @access public |
| 1400 | 1400 | */ |
| 1401 | 1401 | public function render_control_templates() { |
| 1402 | - foreach ( $this->registered_control_types as $control_type ) { |
|
| 1403 | - $control = new $control_type( $this, 'temp', array( |
|
| 1402 | + foreach ($this->registered_control_types as $control_type) { |
|
| 1403 | + $control = new $control_type($this, 'temp', array( |
|
| 1404 | 1404 | 'settings' => array(), |
| 1405 | - ) ); |
|
| 1405 | + )); |
|
| 1406 | 1406 | $control->print_template(); |
| 1407 | 1407 | } |
| 1408 | 1408 | } |
@@ -1416,8 +1416,8 @@ discard block |
||
| 1416 | 1416 | * @param WP_Customize_Panel|WP_Customize_Section|WP_Customize_Control $b Object B. |
| 1417 | 1417 | * @return int |
| 1418 | 1418 | */ |
| 1419 | - protected function _cmp_priority( $a, $b ) { |
|
| 1420 | - if ( $a->priority === $b->priority ) { |
|
| 1419 | + protected function _cmp_priority($a, $b) { |
|
| 1420 | + if ($a->priority === $b->priority) { |
|
| 1421 | 1421 | return $a->instance_number - $b->instance_number; |
| 1422 | 1422 | } else { |
| 1423 | 1423 | return $a->priority - $b->priority; |
@@ -1436,58 +1436,58 @@ discard block |
||
| 1436 | 1436 | public function prepare_controls() { |
| 1437 | 1437 | |
| 1438 | 1438 | $controls = array(); |
| 1439 | - uasort( $this->controls, array( $this, '_cmp_priority' ) ); |
|
| 1439 | + uasort($this->controls, array($this, '_cmp_priority')); |
|
| 1440 | 1440 | |
| 1441 | - foreach ( $this->controls as $id => $control ) { |
|
| 1442 | - if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() ) { |
|
| 1441 | + foreach ($this->controls as $id => $control) { |
|
| 1442 | + if ( ! isset($this->sections[$control->section]) || ! $control->check_capabilities()) { |
|
| 1443 | 1443 | continue; |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - $this->sections[ $control->section ]->controls[] = $control; |
|
| 1447 | - $controls[ $id ] = $control; |
|
| 1446 | + $this->sections[$control->section]->controls[] = $control; |
|
| 1447 | + $controls[$id] = $control; |
|
| 1448 | 1448 | } |
| 1449 | 1449 | $this->controls = $controls; |
| 1450 | 1450 | |
| 1451 | 1451 | // Prepare sections. |
| 1452 | - uasort( $this->sections, array( $this, '_cmp_priority' ) ); |
|
| 1452 | + uasort($this->sections, array($this, '_cmp_priority')); |
|
| 1453 | 1453 | $sections = array(); |
| 1454 | 1454 | |
| 1455 | - foreach ( $this->sections as $section ) { |
|
| 1456 | - if ( ! $section->check_capabilities() ) { |
|
| 1455 | + foreach ($this->sections as $section) { |
|
| 1456 | + if ( ! $section->check_capabilities()) { |
|
| 1457 | 1457 | continue; |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | - usort( $section->controls, array( $this, '_cmp_priority' ) ); |
|
| 1460 | + usort($section->controls, array($this, '_cmp_priority')); |
|
| 1461 | 1461 | |
| 1462 | - if ( ! $section->panel ) { |
|
| 1462 | + if ( ! $section->panel) { |
|
| 1463 | 1463 | // Top-level section. |
| 1464 | - $sections[ $section->id ] = $section; |
|
| 1464 | + $sections[$section->id] = $section; |
|
| 1465 | 1465 | } else { |
| 1466 | 1466 | // This section belongs to a panel. |
| 1467 | - if ( isset( $this->panels [ $section->panel ] ) ) { |
|
| 1468 | - $this->panels[ $section->panel ]->sections[ $section->id ] = $section; |
|
| 1467 | + if (isset($this->panels [$section->panel])) { |
|
| 1468 | + $this->panels[$section->panel]->sections[$section->id] = $section; |
|
| 1469 | 1469 | } |
| 1470 | 1470 | } |
| 1471 | 1471 | } |
| 1472 | 1472 | $this->sections = $sections; |
| 1473 | 1473 | |
| 1474 | 1474 | // Prepare panels. |
| 1475 | - uasort( $this->panels, array( $this, '_cmp_priority' ) ); |
|
| 1475 | + uasort($this->panels, array($this, '_cmp_priority')); |
|
| 1476 | 1476 | $panels = array(); |
| 1477 | 1477 | |
| 1478 | - foreach ( $this->panels as $panel ) { |
|
| 1479 | - if ( ! $panel->check_capabilities() ) { |
|
| 1478 | + foreach ($this->panels as $panel) { |
|
| 1479 | + if ( ! $panel->check_capabilities()) { |
|
| 1480 | 1480 | continue; |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - uasort( $panel->sections, array( $this, '_cmp_priority' ) ); |
|
| 1484 | - $panels[ $panel->id ] = $panel; |
|
| 1483 | + uasort($panel->sections, array($this, '_cmp_priority')); |
|
| 1484 | + $panels[$panel->id] = $panel; |
|
| 1485 | 1485 | } |
| 1486 | 1486 | $this->panels = $panels; |
| 1487 | 1487 | |
| 1488 | 1488 | // Sort panels and top-level sections together. |
| 1489 | - $this->containers = array_merge( $this->panels, $this->sections ); |
|
| 1490 | - uasort( $this->containers, array( $this, '_cmp_priority' ) ); |
|
| 1489 | + $this->containers = array_merge($this->panels, $this->sections); |
|
| 1490 | + uasort($this->containers, array($this, '_cmp_priority')); |
|
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | /** |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | * @since 3.4.0 |
| 1497 | 1497 | */ |
| 1498 | 1498 | public function enqueue_control_scripts() { |
| 1499 | - foreach ( $this->controls as $control ) { |
|
| 1499 | + foreach ($this->controls as $control) { |
|
| 1500 | 1500 | $control->enqueue(); |
| 1501 | 1501 | } |
| 1502 | 1502 | } |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | * @return bool Whether the user agent is iOS. |
| 1511 | 1511 | */ |
| 1512 | 1512 | public function is_ios() { |
| 1513 | - return wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] ); |
|
| 1513 | + return wp_is_mobile() && preg_match('/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT']); |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | /** |
@@ -1522,14 +1522,14 @@ discard block |
||
| 1522 | 1522 | * @return string The template string for the document title. |
| 1523 | 1523 | */ |
| 1524 | 1524 | public function get_document_title_template() { |
| 1525 | - if ( $this->is_theme_active() ) { |
|
| 1525 | + if ($this->is_theme_active()) { |
|
| 1526 | 1526 | /* translators: %s: document title from the preview */ |
| 1527 | - $document_title_tmpl = __( 'Customize: %s' ); |
|
| 1527 | + $document_title_tmpl = __('Customize: %s'); |
|
| 1528 | 1528 | } else { |
| 1529 | 1529 | /* translators: %s: document title from the preview */ |
| 1530 | - $document_title_tmpl = __( 'Live Preview: %s' ); |
|
| 1530 | + $document_title_tmpl = __('Live Preview: %s'); |
|
| 1531 | 1531 | } |
| 1532 | - $document_title_tmpl = html_entity_decode( $document_title_tmpl, ENT_QUOTES, 'UTF-8' ); // Because exported to JS and assigned to document.title. |
|
| 1532 | + $document_title_tmpl = html_entity_decode($document_title_tmpl, ENT_QUOTES, 'UTF-8'); // Because exported to JS and assigned to document.title. |
|
| 1533 | 1533 | return $document_title_tmpl; |
| 1534 | 1534 | } |
| 1535 | 1535 | |
@@ -1543,8 +1543,8 @@ discard block |
||
| 1543 | 1543 | * |
| 1544 | 1544 | * @param string $preview_url URL to be previewed. |
| 1545 | 1545 | */ |
| 1546 | - public function set_preview_url( $preview_url ) { |
|
| 1547 | - $this->preview_url = wp_validate_redirect( $preview_url, home_url( '/' ) ); |
|
| 1546 | + public function set_preview_url($preview_url) { |
|
| 1547 | + $this->preview_url = wp_validate_redirect($preview_url, home_url('/')); |
|
| 1548 | 1548 | } |
| 1549 | 1549 | |
| 1550 | 1550 | /** |
@@ -1556,8 +1556,8 @@ discard block |
||
| 1556 | 1556 | * @return string URL being previewed. |
| 1557 | 1557 | */ |
| 1558 | 1558 | public function get_preview_url() { |
| 1559 | - if ( empty( $this->preview_url ) ) { |
|
| 1560 | - $preview_url = home_url( '/' ); |
|
| 1559 | + if (empty($this->preview_url)) { |
|
| 1560 | + $preview_url = home_url('/'); |
|
| 1561 | 1561 | } else { |
| 1562 | 1562 | $preview_url = $this->preview_url; |
| 1563 | 1563 | } |
@@ -1574,9 +1574,9 @@ discard block |
||
| 1574 | 1574 | * |
| 1575 | 1575 | * @param string $return_url URL for return link. |
| 1576 | 1576 | */ |
| 1577 | - public function set_return_url( $return_url ) { |
|
| 1578 | - $return_url = remove_query_arg( wp_removable_query_args(), $return_url ); |
|
| 1579 | - $return_url = wp_validate_redirect( $return_url ); |
|
| 1577 | + public function set_return_url($return_url) { |
|
| 1578 | + $return_url = remove_query_arg(wp_removable_query_args(), $return_url); |
|
| 1579 | + $return_url = wp_validate_redirect($return_url); |
|
| 1580 | 1580 | $this->return_url = $return_url; |
| 1581 | 1581 | } |
| 1582 | 1582 | |
@@ -1590,16 +1590,16 @@ discard block |
||
| 1590 | 1590 | */ |
| 1591 | 1591 | public function get_return_url() { |
| 1592 | 1592 | $referer = wp_get_referer(); |
| 1593 | - $excluded_referer_basenames = array( 'customize.php', 'wp-login.php' ); |
|
| 1593 | + $excluded_referer_basenames = array('customize.php', 'wp-login.php'); |
|
| 1594 | 1594 | |
| 1595 | - if ( $this->return_url ) { |
|
| 1595 | + if ($this->return_url) { |
|
| 1596 | 1596 | $return_url = $this->return_url; |
| 1597 | - } else if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) { |
|
| 1597 | + } else if ($referer && ! in_array(basename(parse_url($referer, PHP_URL_PATH)), $excluded_referer_basenames, true)) { |
|
| 1598 | 1598 | $return_url = $referer; |
| 1599 | - } else if ( $this->preview_url ) { |
|
| 1599 | + } else if ($this->preview_url) { |
|
| 1600 | 1600 | $return_url = $this->preview_url; |
| 1601 | 1601 | } else { |
| 1602 | - $return_url = home_url( '/' ); |
|
| 1602 | + $return_url = home_url('/'); |
|
| 1603 | 1603 | } |
| 1604 | 1604 | return $return_url; |
| 1605 | 1605 | } |
@@ -1618,8 +1618,8 @@ discard block |
||
| 1618 | 1618 | * @type string [$panel] ID for panel to be autofocused. |
| 1619 | 1619 | * } |
| 1620 | 1620 | */ |
| 1621 | - public function set_autofocus( $autofocus ) { |
|
| 1622 | - $this->autofocus = array_filter( wp_array_slice_assoc( $autofocus, array( 'panel', 'section', 'control' ) ), 'is_string' ); |
|
| 1621 | + public function set_autofocus($autofocus) { |
|
| 1622 | + $this->autofocus = array_filter(wp_array_slice_assoc($autofocus, array('panel', 'section', 'control')), 'is_string'); |
|
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | 1625 | /** |
@@ -1648,8 +1648,8 @@ discard block |
||
| 1648 | 1648 | */ |
| 1649 | 1649 | public function get_nonces() { |
| 1650 | 1650 | $nonces = array( |
| 1651 | - 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ), |
|
| 1652 | - 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ), |
|
| 1651 | + 'save' => wp_create_nonce('save-customize_'.$this->get_stylesheet()), |
|
| 1652 | + 'preview' => wp_create_nonce('preview-customize_'.$this->get_stylesheet()), |
|
| 1653 | 1653 | ); |
| 1654 | 1654 | |
| 1655 | 1655 | /** |
@@ -1661,7 +1661,7 @@ discard block |
||
| 1661 | 1661 | * preview actions. |
| 1662 | 1662 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
| 1663 | 1663 | */ |
| 1664 | - $nonces = apply_filters( 'customize_refresh_nonces', $nonces, $this ); |
|
| 1664 | + $nonces = apply_filters('customize_refresh_nonces', $nonces, $this); |
|
| 1665 | 1665 | |
| 1666 | 1666 | return $nonces; |
| 1667 | 1667 | } |
@@ -1681,13 +1681,13 @@ discard block |
||
| 1681 | 1681 | * using the customize_allowed_urls filter. |
| 1682 | 1682 | */ |
| 1683 | 1683 | |
| 1684 | - $allowed_urls = array( home_url( '/' ) ); |
|
| 1685 | - $admin_origin = parse_url( admin_url() ); |
|
| 1686 | - $home_origin = parse_url( home_url() ); |
|
| 1687 | - $cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) ); |
|
| 1684 | + $allowed_urls = array(home_url('/')); |
|
| 1685 | + $admin_origin = parse_url(admin_url()); |
|
| 1686 | + $home_origin = parse_url(home_url()); |
|
| 1687 | + $cross_domain = (strtolower($admin_origin['host']) !== strtolower($home_origin['host'])); |
|
| 1688 | 1688 | |
| 1689 | - if ( is_ssl() && ! $cross_domain ) { |
|
| 1690 | - $allowed_urls[] = home_url( '/', 'https' ); |
|
| 1689 | + if (is_ssl() && ! $cross_domain) { |
|
| 1690 | + $allowed_urls[] = home_url('/', 'https'); |
|
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | 1693 | /** |
@@ -1697,12 +1697,12 @@ discard block |
||
| 1697 | 1697 | * |
| 1698 | 1698 | * @param array $allowed_urls An array of allowed URLs. |
| 1699 | 1699 | */ |
| 1700 | - $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) ); |
|
| 1700 | + $allowed_urls = array_unique(apply_filters('customize_allowed_urls', $allowed_urls)); |
|
| 1701 | 1701 | |
| 1702 | - $login_url = add_query_arg( array( |
|
| 1702 | + $login_url = add_query_arg(array( |
|
| 1703 | 1703 | 'interim-login' => 1, |
| 1704 | 1704 | 'customize-login' => 1, |
| 1705 | - ), wp_login_url() ); |
|
| 1705 | + ), wp_login_url()); |
|
| 1706 | 1706 | |
| 1707 | 1707 | // Prepare Customizer settings to pass to JavaScript. |
| 1708 | 1708 | $settings = array( |
@@ -1711,14 +1711,14 @@ discard block |
||
| 1711 | 1711 | 'active' => $this->is_theme_active(), |
| 1712 | 1712 | ), |
| 1713 | 1713 | 'url' => array( |
| 1714 | - 'preview' => esc_url_raw( $this->get_preview_url() ), |
|
| 1715 | - 'parent' => esc_url_raw( admin_url() ), |
|
| 1716 | - 'activated' => esc_url_raw( home_url( '/' ) ), |
|
| 1717 | - 'ajax' => esc_url_raw( admin_url( 'admin-ajax.php', 'relative' ) ), |
|
| 1718 | - 'allowed' => array_map( 'esc_url_raw', $allowed_urls ), |
|
| 1714 | + 'preview' => esc_url_raw($this->get_preview_url()), |
|
| 1715 | + 'parent' => esc_url_raw(admin_url()), |
|
| 1716 | + 'activated' => esc_url_raw(home_url('/')), |
|
| 1717 | + 'ajax' => esc_url_raw(admin_url('admin-ajax.php', 'relative')), |
|
| 1718 | + 'allowed' => array_map('esc_url_raw', $allowed_urls), |
|
| 1719 | 1719 | 'isCrossDomain' => $cross_domain, |
| 1720 | - 'home' => esc_url_raw( home_url( '/' ) ), |
|
| 1721 | - 'login' => esc_url_raw( $login_url ), |
|
| 1720 | + 'home' => esc_url_raw(home_url('/')), |
|
| 1721 | + 'login' => esc_url_raw($login_url), |
|
| 1722 | 1722 | ), |
| 1723 | 1723 | 'browser' => array( |
| 1724 | 1724 | 'mobile' => wp_is_mobile(), |
@@ -1730,23 +1730,23 @@ discard block |
||
| 1730 | 1730 | 'autofocus' => $this->get_autofocus(), |
| 1731 | 1731 | 'documentTitleTmpl' => $this->get_document_title_template(), |
| 1732 | 1732 | 'previewableDevices' => $this->get_previewable_devices(), |
| 1733 | - 'selectiveRefreshEnabled' => isset( $this->selective_refresh ), |
|
| 1733 | + 'selectiveRefreshEnabled' => isset($this->selective_refresh), |
|
| 1734 | 1734 | ); |
| 1735 | 1735 | |
| 1736 | 1736 | // Prepare Customize Section objects to pass to JavaScript. |
| 1737 | - foreach ( $this->sections() as $id => $section ) { |
|
| 1738 | - if ( $section->check_capabilities() ) { |
|
| 1739 | - $settings['sections'][ $id ] = $section->json(); |
|
| 1737 | + foreach ($this->sections() as $id => $section) { |
|
| 1738 | + if ($section->check_capabilities()) { |
|
| 1739 | + $settings['sections'][$id] = $section->json(); |
|
| 1740 | 1740 | } |
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | // Prepare Customize Panel objects to pass to JavaScript. |
| 1744 | - foreach ( $this->panels() as $panel_id => $panel ) { |
|
| 1745 | - if ( $panel->check_capabilities() ) { |
|
| 1746 | - $settings['panels'][ $panel_id ] = $panel->json(); |
|
| 1747 | - foreach ( $panel->sections as $section_id => $section ) { |
|
| 1748 | - if ( $section->check_capabilities() ) { |
|
| 1749 | - $settings['sections'][ $section_id ] = $section->json(); |
|
| 1744 | + foreach ($this->panels() as $panel_id => $panel) { |
|
| 1745 | + if ($panel->check_capabilities()) { |
|
| 1746 | + $settings['panels'][$panel_id] = $panel->json(); |
|
| 1747 | + foreach ($panel->sections as $section_id => $section) { |
|
| 1748 | + if ($section->check_capabilities()) { |
|
| 1749 | + $settings['sections'][$section_id] = $section->json(); |
|
| 1750 | 1750 | } |
| 1751 | 1751 | } |
| 1752 | 1752 | } |
@@ -1754,23 +1754,23 @@ discard block |
||
| 1754 | 1754 | |
| 1755 | 1755 | ?> |
| 1756 | 1756 | <script type="text/javascript"> |
| 1757 | - var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>; |
|
| 1757 | + var _wpCustomizeSettings = <?php echo wp_json_encode($settings); ?>; |
|
| 1758 | 1758 | _wpCustomizeSettings.controls = {}; |
| 1759 | 1759 | _wpCustomizeSettings.settings = {}; |
| 1760 | 1760 | <?php |
| 1761 | 1761 | |
| 1762 | 1762 | // Serialize settings one by one to improve memory usage. |
| 1763 | 1763 | echo "(function ( s ){\n"; |
| 1764 | - foreach ( $this->settings() as $setting ) { |
|
| 1765 | - if ( $setting->check_capabilities() ) { |
|
| 1764 | + foreach ($this->settings() as $setting) { |
|
| 1765 | + if ($setting->check_capabilities()) { |
|
| 1766 | 1766 | printf( |
| 1767 | 1767 | "s[%s] = %s;\n", |
| 1768 | - wp_json_encode( $setting->id ), |
|
| 1769 | - wp_json_encode( array( |
|
| 1768 | + wp_json_encode($setting->id), |
|
| 1769 | + wp_json_encode(array( |
|
| 1770 | 1770 | 'value' => $setting->js_value(), |
| 1771 | 1771 | 'transport' => $setting->transport, |
| 1772 | 1772 | 'dirty' => $setting->dirty, |
| 1773 | - ) ) |
|
| 1773 | + )) |
|
| 1774 | 1774 | ); |
| 1775 | 1775 | } |
| 1776 | 1776 | } |
@@ -1778,12 +1778,12 @@ discard block |
||
| 1778 | 1778 | |
| 1779 | 1779 | // Serialize controls one by one to improve memory usage. |
| 1780 | 1780 | echo "(function ( c ){\n"; |
| 1781 | - foreach ( $this->controls() as $control ) { |
|
| 1782 | - if ( $control->check_capabilities() ) { |
|
| 1781 | + foreach ($this->controls() as $control) { |
|
| 1782 | + if ($control->check_capabilities()) { |
|
| 1783 | 1783 | printf( |
| 1784 | 1784 | "c[%s] = %s;\n", |
| 1785 | - wp_json_encode( $control->id ), |
|
| 1786 | - wp_json_encode( $control->json() ) |
|
| 1785 | + wp_json_encode($control->id), |
|
| 1786 | + wp_json_encode($control->json()) |
|
| 1787 | 1787 | ); |
| 1788 | 1788 | } |
| 1789 | 1789 | } |
@@ -1804,14 +1804,14 @@ discard block |
||
| 1804 | 1804 | public function get_previewable_devices() { |
| 1805 | 1805 | $devices = array( |
| 1806 | 1806 | 'desktop' => array( |
| 1807 | - 'label' => __( 'Enter desktop preview mode' ), |
|
| 1807 | + 'label' => __('Enter desktop preview mode'), |
|
| 1808 | 1808 | 'default' => true, |
| 1809 | 1809 | ), |
| 1810 | 1810 | 'tablet' => array( |
| 1811 | - 'label' => __( 'Enter tablet preview mode' ), |
|
| 1811 | + 'label' => __('Enter tablet preview mode'), |
|
| 1812 | 1812 | ), |
| 1813 | 1813 | 'mobile' => array( |
| 1814 | - 'label' => __( 'Enter mobile preview mode' ), |
|
| 1814 | + 'label' => __('Enter mobile preview mode'), |
|
| 1815 | 1815 | ), |
| 1816 | 1816 | ); |
| 1817 | 1817 | |
@@ -1824,7 +1824,7 @@ discard block |
||
| 1824 | 1824 | * |
| 1825 | 1825 | * @param array $devices List of devices with labels and default setting. |
| 1826 | 1826 | */ |
| 1827 | - $devices = apply_filters( 'customize_previewable_devices', $devices ); |
|
| 1827 | + $devices = apply_filters('customize_previewable_devices', $devices); |
|
| 1828 | 1828 | |
| 1829 | 1829 | return $devices; |
| 1830 | 1830 | } |
@@ -1837,248 +1837,248 @@ discard block |
||
| 1837 | 1837 | public function register_controls() { |
| 1838 | 1838 | |
| 1839 | 1839 | /* Panel, Section, and Control Types */ |
| 1840 | - $this->register_panel_type( 'WP_Customize_Panel' ); |
|
| 1841 | - $this->register_section_type( 'WP_Customize_Section' ); |
|
| 1842 | - $this->register_section_type( 'WP_Customize_Sidebar_Section' ); |
|
| 1843 | - $this->register_control_type( 'WP_Customize_Color_Control' ); |
|
| 1844 | - $this->register_control_type( 'WP_Customize_Media_Control' ); |
|
| 1845 | - $this->register_control_type( 'WP_Customize_Upload_Control' ); |
|
| 1846 | - $this->register_control_type( 'WP_Customize_Image_Control' ); |
|
| 1847 | - $this->register_control_type( 'WP_Customize_Background_Image_Control' ); |
|
| 1848 | - $this->register_control_type( 'WP_Customize_Cropped_Image_Control' ); |
|
| 1849 | - $this->register_control_type( 'WP_Customize_Site_Icon_Control' ); |
|
| 1850 | - $this->register_control_type( 'WP_Customize_Theme_Control' ); |
|
| 1840 | + $this->register_panel_type('WP_Customize_Panel'); |
|
| 1841 | + $this->register_section_type('WP_Customize_Section'); |
|
| 1842 | + $this->register_section_type('WP_Customize_Sidebar_Section'); |
|
| 1843 | + $this->register_control_type('WP_Customize_Color_Control'); |
|
| 1844 | + $this->register_control_type('WP_Customize_Media_Control'); |
|
| 1845 | + $this->register_control_type('WP_Customize_Upload_Control'); |
|
| 1846 | + $this->register_control_type('WP_Customize_Image_Control'); |
|
| 1847 | + $this->register_control_type('WP_Customize_Background_Image_Control'); |
|
| 1848 | + $this->register_control_type('WP_Customize_Cropped_Image_Control'); |
|
| 1849 | + $this->register_control_type('WP_Customize_Site_Icon_Control'); |
|
| 1850 | + $this->register_control_type('WP_Customize_Theme_Control'); |
|
| 1851 | 1851 | |
| 1852 | 1852 | /* Themes */ |
| 1853 | 1853 | |
| 1854 | - $this->add_section( new WP_Customize_Themes_Section( $this, 'themes', array( |
|
| 1855 | - 'title' => $this->theme()->display( 'Name' ), |
|
| 1854 | + $this->add_section(new WP_Customize_Themes_Section($this, 'themes', array( |
|
| 1855 | + 'title' => $this->theme()->display('Name'), |
|
| 1856 | 1856 | 'capability' => 'switch_themes', |
| 1857 | 1857 | 'priority' => 0, |
| 1858 | - ) ) ); |
|
| 1858 | + ))); |
|
| 1859 | 1859 | |
| 1860 | 1860 | // Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience). |
| 1861 | - $this->add_setting( new WP_Customize_Filter_Setting( $this, 'active_theme', array( |
|
| 1861 | + $this->add_setting(new WP_Customize_Filter_Setting($this, 'active_theme', array( |
|
| 1862 | 1862 | 'capability' => 'switch_themes', |
| 1863 | - ) ) ); |
|
| 1863 | + ))); |
|
| 1864 | 1864 | |
| 1865 | - require_once( ABSPATH . 'wp-admin/includes/theme.php' ); |
|
| 1865 | + require_once(ABSPATH.'wp-admin/includes/theme.php'); |
|
| 1866 | 1866 | |
| 1867 | 1867 | // Theme Controls. |
| 1868 | 1868 | |
| 1869 | 1869 | // Add a control for the active/original theme. |
| 1870 | - if ( ! $this->is_theme_active() ) { |
|
| 1871 | - $themes = wp_prepare_themes_for_js( array( wp_get_theme( $this->original_stylesheet ) ) ); |
|
| 1872 | - $active_theme = current( $themes ); |
|
| 1870 | + if ( ! $this->is_theme_active()) { |
|
| 1871 | + $themes = wp_prepare_themes_for_js(array(wp_get_theme($this->original_stylesheet))); |
|
| 1872 | + $active_theme = current($themes); |
|
| 1873 | 1873 | $active_theme['isActiveTheme'] = true; |
| 1874 | - $this->add_control( new WP_Customize_Theme_Control( $this, $active_theme['id'], array( |
|
| 1874 | + $this->add_control(new WP_Customize_Theme_Control($this, $active_theme['id'], array( |
|
| 1875 | 1875 | 'theme' => $active_theme, |
| 1876 | 1876 | 'section' => 'themes', |
| 1877 | 1877 | 'settings' => 'active_theme', |
| 1878 | - ) ) ); |
|
| 1878 | + ))); |
|
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | 1881 | $themes = wp_prepare_themes_for_js(); |
| 1882 | - foreach ( $themes as $theme ) { |
|
| 1883 | - if ( $theme['active'] || $theme['id'] === $this->original_stylesheet ) { |
|
| 1882 | + foreach ($themes as $theme) { |
|
| 1883 | + if ($theme['active'] || $theme['id'] === $this->original_stylesheet) { |
|
| 1884 | 1884 | continue; |
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | - $theme_id = 'theme_' . $theme['id']; |
|
| 1887 | + $theme_id = 'theme_'.$theme['id']; |
|
| 1888 | 1888 | $theme['isActiveTheme'] = false; |
| 1889 | - $this->add_control( new WP_Customize_Theme_Control( $this, $theme_id, array( |
|
| 1889 | + $this->add_control(new WP_Customize_Theme_Control($this, $theme_id, array( |
|
| 1890 | 1890 | 'theme' => $theme, |
| 1891 | 1891 | 'section' => 'themes', |
| 1892 | 1892 | 'settings' => 'active_theme', |
| 1893 | - ) ) ); |
|
| 1893 | + ))); |
|
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | 1896 | /* Site Identity */ |
| 1897 | 1897 | |
| 1898 | - $this->add_section( 'title_tagline', array( |
|
| 1899 | - 'title' => __( 'Site Identity' ), |
|
| 1898 | + $this->add_section('title_tagline', array( |
|
| 1899 | + 'title' => __('Site Identity'), |
|
| 1900 | 1900 | 'priority' => 20, |
| 1901 | - ) ); |
|
| 1901 | + )); |
|
| 1902 | 1902 | |
| 1903 | - $this->add_setting( 'blogname', array( |
|
| 1904 | - 'default' => get_option( 'blogname' ), |
|
| 1903 | + $this->add_setting('blogname', array( |
|
| 1904 | + 'default' => get_option('blogname'), |
|
| 1905 | 1905 | 'type' => 'option', |
| 1906 | 1906 | 'capability' => 'manage_options', |
| 1907 | - ) ); |
|
| 1907 | + )); |
|
| 1908 | 1908 | |
| 1909 | - $this->add_control( 'blogname', array( |
|
| 1910 | - 'label' => __( 'Site Title' ), |
|
| 1909 | + $this->add_control('blogname', array( |
|
| 1910 | + 'label' => __('Site Title'), |
|
| 1911 | 1911 | 'section' => 'title_tagline', |
| 1912 | - ) ); |
|
| 1912 | + )); |
|
| 1913 | 1913 | |
| 1914 | - $this->add_setting( 'blogdescription', array( |
|
| 1915 | - 'default' => get_option( 'blogdescription' ), |
|
| 1914 | + $this->add_setting('blogdescription', array( |
|
| 1915 | + 'default' => get_option('blogdescription'), |
|
| 1916 | 1916 | 'type' => 'option', |
| 1917 | 1917 | 'capability' => 'manage_options', |
| 1918 | - ) ); |
|
| 1918 | + )); |
|
| 1919 | 1919 | |
| 1920 | - $this->add_control( 'blogdescription', array( |
|
| 1921 | - 'label' => __( 'Tagline' ), |
|
| 1920 | + $this->add_control('blogdescription', array( |
|
| 1921 | + 'label' => __('Tagline'), |
|
| 1922 | 1922 | 'section' => 'title_tagline', |
| 1923 | - ) ); |
|
| 1923 | + )); |
|
| 1924 | 1924 | |
| 1925 | 1925 | // Add a setting to hide header text if the theme doesn't support custom headers. |
| 1926 | - if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
| 1927 | - $this->add_setting( 'header_text', array( |
|
| 1928 | - 'theme_supports' => array( 'custom-logo', 'header-text' ), |
|
| 1926 | + if ( ! current_theme_supports('custom-header', 'header-text')) { |
|
| 1927 | + $this->add_setting('header_text', array( |
|
| 1928 | + 'theme_supports' => array('custom-logo', 'header-text'), |
|
| 1929 | 1929 | 'default' => 1, |
| 1930 | 1930 | 'sanitize_callback' => 'absint', |
| 1931 | - ) ); |
|
| 1931 | + )); |
|
| 1932 | 1932 | |
| 1933 | - $this->add_control( 'header_text', array( |
|
| 1934 | - 'label' => __( 'Display Site Title and Tagline' ), |
|
| 1933 | + $this->add_control('header_text', array( |
|
| 1934 | + 'label' => __('Display Site Title and Tagline'), |
|
| 1935 | 1935 | 'section' => 'title_tagline', |
| 1936 | 1936 | 'settings' => 'header_text', |
| 1937 | 1937 | 'type' => 'checkbox', |
| 1938 | - ) ); |
|
| 1938 | + )); |
|
| 1939 | 1939 | } |
| 1940 | 1940 | |
| 1941 | - $this->add_setting( 'site_icon', array( |
|
| 1941 | + $this->add_setting('site_icon', array( |
|
| 1942 | 1942 | 'type' => 'option', |
| 1943 | 1943 | 'capability' => 'manage_options', |
| 1944 | 1944 | 'transport' => 'postMessage', // Previewed with JS in the Customizer controls window. |
| 1945 | - ) ); |
|
| 1945 | + )); |
|
| 1946 | 1946 | |
| 1947 | - $this->add_control( new WP_Customize_Site_Icon_Control( $this, 'site_icon', array( |
|
| 1948 | - 'label' => __( 'Site Icon' ), |
|
| 1947 | + $this->add_control(new WP_Customize_Site_Icon_Control($this, 'site_icon', array( |
|
| 1948 | + 'label' => __('Site Icon'), |
|
| 1949 | 1949 | 'description' => sprintf( |
| 1950 | 1950 | /* translators: %s: site icon size in pixels */ |
| 1951 | - __( 'The Site Icon is used as a browser and app icon for your site. Icons must be square, and at least %s pixels wide and tall.' ), |
|
| 1951 | + __('The Site Icon is used as a browser and app icon for your site. Icons must be square, and at least %s pixels wide and tall.'), |
|
| 1952 | 1952 | '<strong>512</strong>' |
| 1953 | 1953 | ), |
| 1954 | 1954 | 'section' => 'title_tagline', |
| 1955 | 1955 | 'priority' => 60, |
| 1956 | 1956 | 'height' => 512, |
| 1957 | 1957 | 'width' => 512, |
| 1958 | - ) ) ); |
|
| 1958 | + ))); |
|
| 1959 | 1959 | |
| 1960 | - $this->add_setting( 'custom_logo', array( |
|
| 1961 | - 'theme_supports' => array( 'custom-logo' ), |
|
| 1960 | + $this->add_setting('custom_logo', array( |
|
| 1961 | + 'theme_supports' => array('custom-logo'), |
|
| 1962 | 1962 | 'transport' => 'postMessage', |
| 1963 | - ) ); |
|
| 1963 | + )); |
|
| 1964 | 1964 | |
| 1965 | - $this->add_control( new WP_Customize_Media_Control( $this, 'custom_logo', array( |
|
| 1966 | - 'label' => __( 'Logo' ), |
|
| 1965 | + $this->add_control(new WP_Customize_Media_Control($this, 'custom_logo', array( |
|
| 1966 | + 'label' => __('Logo'), |
|
| 1967 | 1967 | 'section' => 'title_tagline', |
| 1968 | 1968 | 'priority' => 8, |
| 1969 | 1969 | 'mime_type' => 'image', |
| 1970 | 1970 | 'button_labels' => array( |
| 1971 | - 'select' => __( 'Select logo' ), |
|
| 1972 | - 'change' => __( 'Change logo' ), |
|
| 1973 | - 'remove' => __( 'Remove' ), |
|
| 1974 | - 'default' => __( 'Default' ), |
|
| 1975 | - 'placeholder' => __( 'No logo selected' ), |
|
| 1976 | - 'frame_title' => __( 'Select logo' ), |
|
| 1977 | - 'frame_button' => __( 'Choose logo' ), |
|
| 1971 | + 'select' => __('Select logo'), |
|
| 1972 | + 'change' => __('Change logo'), |
|
| 1973 | + 'remove' => __('Remove'), |
|
| 1974 | + 'default' => __('Default'), |
|
| 1975 | + 'placeholder' => __('No logo selected'), |
|
| 1976 | + 'frame_title' => __('Select logo'), |
|
| 1977 | + 'frame_button' => __('Choose logo'), |
|
| 1978 | 1978 | ), |
| 1979 | - ) ) ); |
|
| 1979 | + ))); |
|
| 1980 | 1980 | |
| 1981 | - if ( isset( $this->selective_refresh ) ) { |
|
| 1982 | - $this->selective_refresh->add_partial( 'custom_logo', array( |
|
| 1983 | - 'settings' => array( 'custom_logo' ), |
|
| 1981 | + if (isset($this->selective_refresh)) { |
|
| 1982 | + $this->selective_refresh->add_partial('custom_logo', array( |
|
| 1983 | + 'settings' => array('custom_logo'), |
|
| 1984 | 1984 | 'selector' => '.custom-logo-link', |
| 1985 | - 'render_callback' => array( $this, '_render_custom_logo_partial' ), |
|
| 1985 | + 'render_callback' => array($this, '_render_custom_logo_partial'), |
|
| 1986 | 1986 | 'container_inclusive' => true, |
| 1987 | - ) ); |
|
| 1987 | + )); |
|
| 1988 | 1988 | } |
| 1989 | 1989 | |
| 1990 | 1990 | /* Colors */ |
| 1991 | 1991 | |
| 1992 | - $this->add_section( 'colors', array( |
|
| 1993 | - 'title' => __( 'Colors' ), |
|
| 1992 | + $this->add_section('colors', array( |
|
| 1993 | + 'title' => __('Colors'), |
|
| 1994 | 1994 | 'priority' => 40, |
| 1995 | - ) ); |
|
| 1995 | + )); |
|
| 1996 | 1996 | |
| 1997 | - $this->add_setting( 'header_textcolor', array( |
|
| 1998 | - 'theme_supports' => array( 'custom-header', 'header-text' ), |
|
| 1999 | - 'default' => get_theme_support( 'custom-header', 'default-text-color' ), |
|
| 1997 | + $this->add_setting('header_textcolor', array( |
|
| 1998 | + 'theme_supports' => array('custom-header', 'header-text'), |
|
| 1999 | + 'default' => get_theme_support('custom-header', 'default-text-color'), |
|
| 2000 | 2000 | |
| 2001 | - 'sanitize_callback' => array( $this, '_sanitize_header_textcolor' ), |
|
| 2001 | + 'sanitize_callback' => array($this, '_sanitize_header_textcolor'), |
|
| 2002 | 2002 | 'sanitize_js_callback' => 'maybe_hash_hex_color', |
| 2003 | - ) ); |
|
| 2003 | + )); |
|
| 2004 | 2004 | |
| 2005 | 2005 | // Input type: checkbox |
| 2006 | 2006 | // With custom value |
| 2007 | - $this->add_control( 'display_header_text', array( |
|
| 2007 | + $this->add_control('display_header_text', array( |
|
| 2008 | 2008 | 'settings' => 'header_textcolor', |
| 2009 | - 'label' => __( 'Display Site Title and Tagline' ), |
|
| 2009 | + 'label' => __('Display Site Title and Tagline'), |
|
| 2010 | 2010 | 'section' => 'title_tagline', |
| 2011 | 2011 | 'type' => 'checkbox', |
| 2012 | 2012 | 'priority' => 40, |
| 2013 | - ) ); |
|
| 2013 | + )); |
|
| 2014 | 2014 | |
| 2015 | - $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array( |
|
| 2016 | - 'label' => __( 'Header Text Color' ), |
|
| 2015 | + $this->add_control(new WP_Customize_Color_Control($this, 'header_textcolor', array( |
|
| 2016 | + 'label' => __('Header Text Color'), |
|
| 2017 | 2017 | 'section' => 'colors', |
| 2018 | - ) ) ); |
|
| 2018 | + ))); |
|
| 2019 | 2019 | |
| 2020 | 2020 | // Input type: Color |
| 2021 | 2021 | // With sanitize_callback |
| 2022 | - $this->add_setting( 'background_color', array( |
|
| 2023 | - 'default' => get_theme_support( 'custom-background', 'default-color' ), |
|
| 2022 | + $this->add_setting('background_color', array( |
|
| 2023 | + 'default' => get_theme_support('custom-background', 'default-color'), |
|
| 2024 | 2024 | 'theme_supports' => 'custom-background', |
| 2025 | 2025 | |
| 2026 | 2026 | 'sanitize_callback' => 'sanitize_hex_color_no_hash', |
| 2027 | 2027 | 'sanitize_js_callback' => 'maybe_hash_hex_color', |
| 2028 | - ) ); |
|
| 2028 | + )); |
|
| 2029 | 2029 | |
| 2030 | - $this->add_control( new WP_Customize_Color_Control( $this, 'background_color', array( |
|
| 2031 | - 'label' => __( 'Background Color' ), |
|
| 2030 | + $this->add_control(new WP_Customize_Color_Control($this, 'background_color', array( |
|
| 2031 | + 'label' => __('Background Color'), |
|
| 2032 | 2032 | 'section' => 'colors', |
| 2033 | - ) ) ); |
|
| 2033 | + ))); |
|
| 2034 | 2034 | |
| 2035 | 2035 | |
| 2036 | 2036 | /* Custom Header */ |
| 2037 | 2037 | |
| 2038 | - $this->add_section( 'header_image', array( |
|
| 2039 | - 'title' => __( 'Header Image' ), |
|
| 2038 | + $this->add_section('header_image', array( |
|
| 2039 | + 'title' => __('Header Image'), |
|
| 2040 | 2040 | 'theme_supports' => 'custom-header', |
| 2041 | 2041 | 'priority' => 60, |
| 2042 | - ) ); |
|
| 2042 | + )); |
|
| 2043 | 2043 | |
| 2044 | - $this->add_setting( new WP_Customize_Filter_Setting( $this, 'header_image', array( |
|
| 2045 | - 'default' => get_theme_support( 'custom-header', 'default-image' ), |
|
| 2044 | + $this->add_setting(new WP_Customize_Filter_Setting($this, 'header_image', array( |
|
| 2045 | + 'default' => get_theme_support('custom-header', 'default-image'), |
|
| 2046 | 2046 | 'theme_supports' => 'custom-header', |
| 2047 | - ) ) ); |
|
| 2047 | + ))); |
|
| 2048 | 2048 | |
| 2049 | - $this->add_setting( new WP_Customize_Header_Image_Setting( $this, 'header_image_data', array( |
|
| 2049 | + $this->add_setting(new WP_Customize_Header_Image_Setting($this, 'header_image_data', array( |
|
| 2050 | 2050 | // 'default' => get_theme_support( 'custom-header', 'default-image' ), |
| 2051 | 2051 | 'theme_supports' => 'custom-header', |
| 2052 | - ) ) ); |
|
| 2052 | + ))); |
|
| 2053 | 2053 | |
| 2054 | - $this->add_control( new WP_Customize_Header_Image_Control( $this ) ); |
|
| 2054 | + $this->add_control(new WP_Customize_Header_Image_Control($this)); |
|
| 2055 | 2055 | |
| 2056 | 2056 | /* Custom Background */ |
| 2057 | 2057 | |
| 2058 | - $this->add_section( 'background_image', array( |
|
| 2059 | - 'title' => __( 'Background Image' ), |
|
| 2058 | + $this->add_section('background_image', array( |
|
| 2059 | + 'title' => __('Background Image'), |
|
| 2060 | 2060 | 'theme_supports' => 'custom-background', |
| 2061 | 2061 | 'priority' => 80, |
| 2062 | - ) ); |
|
| 2062 | + )); |
|
| 2063 | 2063 | |
| 2064 | - $this->add_setting( 'background_image', array( |
|
| 2065 | - 'default' => get_theme_support( 'custom-background', 'default-image' ), |
|
| 2064 | + $this->add_setting('background_image', array( |
|
| 2065 | + 'default' => get_theme_support('custom-background', 'default-image'), |
|
| 2066 | 2066 | 'theme_supports' => 'custom-background', |
| 2067 | - ) ); |
|
| 2067 | + )); |
|
| 2068 | 2068 | |
| 2069 | - $this->add_setting( new WP_Customize_Background_Image_Setting( $this, 'background_image_thumb', array( |
|
| 2069 | + $this->add_setting(new WP_Customize_Background_Image_Setting($this, 'background_image_thumb', array( |
|
| 2070 | 2070 | 'theme_supports' => 'custom-background', |
| 2071 | - ) ) ); |
|
| 2071 | + ))); |
|
| 2072 | 2072 | |
| 2073 | - $this->add_control( new WP_Customize_Background_Image_Control( $this ) ); |
|
| 2073 | + $this->add_control(new WP_Customize_Background_Image_Control($this)); |
|
| 2074 | 2074 | |
| 2075 | - $this->add_setting( 'background_repeat', array( |
|
| 2076 | - 'default' => get_theme_support( 'custom-background', 'default-repeat' ), |
|
| 2075 | + $this->add_setting('background_repeat', array( |
|
| 2076 | + 'default' => get_theme_support('custom-background', 'default-repeat'), |
|
| 2077 | 2077 | 'theme_supports' => 'custom-background', |
| 2078 | - ) ); |
|
| 2078 | + )); |
|
| 2079 | 2079 | |
| 2080 | - $this->add_control( 'background_repeat', array( |
|
| 2081 | - 'label' => __( 'Background Repeat' ), |
|
| 2080 | + $this->add_control('background_repeat', array( |
|
| 2081 | + 'label' => __('Background Repeat'), |
|
| 2082 | 2082 | 'section' => 'background_image', |
| 2083 | 2083 | 'type' => 'radio', |
| 2084 | 2084 | 'choices' => array( |
@@ -2087,15 +2087,15 @@ discard block |
||
| 2087 | 2087 | 'repeat-x' => __('Tile Horizontally'), |
| 2088 | 2088 | 'repeat-y' => __('Tile Vertically'), |
| 2089 | 2089 | ), |
| 2090 | - ) ); |
|
| 2090 | + )); |
|
| 2091 | 2091 | |
| 2092 | - $this->add_setting( 'background_position_x', array( |
|
| 2093 | - 'default' => get_theme_support( 'custom-background', 'default-position-x' ), |
|
| 2092 | + $this->add_setting('background_position_x', array( |
|
| 2093 | + 'default' => get_theme_support('custom-background', 'default-position-x'), |
|
| 2094 | 2094 | 'theme_supports' => 'custom-background', |
| 2095 | - ) ); |
|
| 2095 | + )); |
|
| 2096 | 2096 | |
| 2097 | - $this->add_control( 'background_position_x', array( |
|
| 2098 | - 'label' => __( 'Background Position' ), |
|
| 2097 | + $this->add_control('background_position_x', array( |
|
| 2098 | + 'label' => __('Background Position'), |
|
| 2099 | 2099 | 'section' => 'background_image', |
| 2100 | 2100 | 'type' => 'radio', |
| 2101 | 2101 | 'choices' => array( |
@@ -2103,28 +2103,28 @@ discard block |
||
| 2103 | 2103 | 'center' => __('Center'), |
| 2104 | 2104 | 'right' => __('Right'), |
| 2105 | 2105 | ), |
| 2106 | - ) ); |
|
| 2106 | + )); |
|
| 2107 | 2107 | |
| 2108 | - $this->add_setting( 'background_attachment', array( |
|
| 2109 | - 'default' => get_theme_support( 'custom-background', 'default-attachment' ), |
|
| 2108 | + $this->add_setting('background_attachment', array( |
|
| 2109 | + 'default' => get_theme_support('custom-background', 'default-attachment'), |
|
| 2110 | 2110 | 'theme_supports' => 'custom-background', |
| 2111 | - ) ); |
|
| 2111 | + )); |
|
| 2112 | 2112 | |
| 2113 | - $this->add_control( 'background_attachment', array( |
|
| 2114 | - 'label' => __( 'Background Attachment' ), |
|
| 2113 | + $this->add_control('background_attachment', array( |
|
| 2114 | + 'label' => __('Background Attachment'), |
|
| 2115 | 2115 | 'section' => 'background_image', |
| 2116 | 2116 | 'type' => 'radio', |
| 2117 | 2117 | 'choices' => array( |
| 2118 | 2118 | 'scroll' => __('Scroll'), |
| 2119 | 2119 | 'fixed' => __('Fixed'), |
| 2120 | 2120 | ), |
| 2121 | - ) ); |
|
| 2121 | + )); |
|
| 2122 | 2122 | |
| 2123 | 2123 | // If the theme is using the default background callback, we can update |
| 2124 | 2124 | // the background CSS using postMessage. |
| 2125 | - if ( get_theme_support( 'custom-background', 'wp-head-callback' ) === '_custom_background_cb' ) { |
|
| 2126 | - foreach ( array( 'color', 'image', 'position_x', 'repeat', 'attachment' ) as $prop ) { |
|
| 2127 | - $this->get_setting( 'background_' . $prop )->transport = 'postMessage'; |
|
| 2125 | + if (get_theme_support('custom-background', 'wp-head-callback') === '_custom_background_cb') { |
|
| 2126 | + foreach (array('color', 'image', 'position_x', 'repeat', 'attachment') as $prop) { |
|
| 2127 | + $this->get_setting('background_'.$prop)->transport = 'postMessage'; |
|
| 2128 | 2128 | } |
| 2129 | 2129 | } |
| 2130 | 2130 | |
@@ -2132,54 +2132,54 @@ discard block |
||
| 2132 | 2132 | // #WP19627 |
| 2133 | 2133 | |
| 2134 | 2134 | // Replicate behavior from options-reading.php and hide front page options if there are no pages |
| 2135 | - if ( get_pages() ) { |
|
| 2136 | - $this->add_section( 'static_front_page', array( |
|
| 2137 | - 'title' => __( 'Static Front Page' ), |
|
| 2135 | + if (get_pages()) { |
|
| 2136 | + $this->add_section('static_front_page', array( |
|
| 2137 | + 'title' => __('Static Front Page'), |
|
| 2138 | 2138 | // 'theme_supports' => 'static-front-page', |
| 2139 | 2139 | 'priority' => 120, |
| 2140 | - 'description' => __( 'Your theme supports a static front page.' ), |
|
| 2141 | - ) ); |
|
| 2140 | + 'description' => __('Your theme supports a static front page.'), |
|
| 2141 | + )); |
|
| 2142 | 2142 | |
| 2143 | - $this->add_setting( 'show_on_front', array( |
|
| 2144 | - 'default' => get_option( 'show_on_front' ), |
|
| 2143 | + $this->add_setting('show_on_front', array( |
|
| 2144 | + 'default' => get_option('show_on_front'), |
|
| 2145 | 2145 | 'capability' => 'manage_options', |
| 2146 | 2146 | 'type' => 'option', |
| 2147 | 2147 | // 'theme_supports' => 'static-front-page', |
| 2148 | - ) ); |
|
| 2148 | + )); |
|
| 2149 | 2149 | |
| 2150 | - $this->add_control( 'show_on_front', array( |
|
| 2151 | - 'label' => __( 'Front page displays' ), |
|
| 2150 | + $this->add_control('show_on_front', array( |
|
| 2151 | + 'label' => __('Front page displays'), |
|
| 2152 | 2152 | 'section' => 'static_front_page', |
| 2153 | 2153 | 'type' => 'radio', |
| 2154 | 2154 | 'choices' => array( |
| 2155 | - 'posts' => __( 'Your latest posts' ), |
|
| 2156 | - 'page' => __( 'A static page' ), |
|
| 2155 | + 'posts' => __('Your latest posts'), |
|
| 2156 | + 'page' => __('A static page'), |
|
| 2157 | 2157 | ), |
| 2158 | - ) ); |
|
| 2158 | + )); |
|
| 2159 | 2159 | |
| 2160 | - $this->add_setting( 'page_on_front', array( |
|
| 2160 | + $this->add_setting('page_on_front', array( |
|
| 2161 | 2161 | 'type' => 'option', |
| 2162 | 2162 | 'capability' => 'manage_options', |
| 2163 | 2163 | // 'theme_supports' => 'static-front-page', |
| 2164 | - ) ); |
|
| 2164 | + )); |
|
| 2165 | 2165 | |
| 2166 | - $this->add_control( 'page_on_front', array( |
|
| 2167 | - 'label' => __( 'Front page' ), |
|
| 2166 | + $this->add_control('page_on_front', array( |
|
| 2167 | + 'label' => __('Front page'), |
|
| 2168 | 2168 | 'section' => 'static_front_page', |
| 2169 | 2169 | 'type' => 'dropdown-pages', |
| 2170 | - ) ); |
|
| 2170 | + )); |
|
| 2171 | 2171 | |
| 2172 | - $this->add_setting( 'page_for_posts', array( |
|
| 2172 | + $this->add_setting('page_for_posts', array( |
|
| 2173 | 2173 | 'type' => 'option', |
| 2174 | 2174 | 'capability' => 'manage_options', |
| 2175 | 2175 | // 'theme_supports' => 'static-front-page', |
| 2176 | - ) ); |
|
| 2176 | + )); |
|
| 2177 | 2177 | |
| 2178 | - $this->add_control( 'page_for_posts', array( |
|
| 2179 | - 'label' => __( 'Posts page' ), |
|
| 2178 | + $this->add_control('page_for_posts', array( |
|
| 2179 | + 'label' => __('Posts page'), |
|
| 2180 | 2180 | 'section' => 'static_front_page', |
| 2181 | 2181 | 'type' => 'dropdown-pages', |
| 2182 | - ) ); |
|
| 2182 | + )); |
|
| 2183 | 2183 | } |
| 2184 | 2184 | } |
| 2185 | 2185 | |
@@ -2192,7 +2192,7 @@ discard block |
||
| 2192 | 2192 | * @see add_dynamic_settings() |
| 2193 | 2193 | */ |
| 2194 | 2194 | public function register_dynamic_settings() { |
| 2195 | - $this->add_dynamic_settings( array_keys( $this->unsanitized_post_values() ) ); |
|
| 2195 | + $this->add_dynamic_settings(array_keys($this->unsanitized_post_values())); |
|
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | 2198 | /** |
@@ -2206,13 +2206,13 @@ discard block |
||
| 2206 | 2206 | * @param string $color |
| 2207 | 2207 | * @return mixed |
| 2208 | 2208 | */ |
| 2209 | - public function _sanitize_header_textcolor( $color ) { |
|
| 2210 | - if ( 'blank' === $color ) |
|
| 2209 | + public function _sanitize_header_textcolor($color) { |
|
| 2210 | + if ('blank' === $color) |
|
| 2211 | 2211 | return 'blank'; |
| 2212 | 2212 | |
| 2213 | - $color = sanitize_hex_color_no_hash( $color ); |
|
| 2214 | - if ( empty( $color ) ) |
|
| 2215 | - $color = get_theme_support( 'custom-header', 'default-text-color' ); |
|
| 2213 | + $color = sanitize_hex_color_no_hash($color); |
|
| 2214 | + if (empty($color)) |
|
| 2215 | + $color = get_theme_support('custom-header', 'default-text-color'); |
|
| 2216 | 2216 | |
| 2217 | 2217 | return $color; |
| 2218 | 2218 | } |
@@ -2249,12 +2249,12 @@ discard block |
||
| 2249 | 2249 | * @param string $color |
| 2250 | 2250 | * @return string|void |
| 2251 | 2251 | */ |
| 2252 | -function sanitize_hex_color( $color ) { |
|
| 2253 | - if ( '' === $color ) |
|
| 2252 | +function sanitize_hex_color($color) { |
|
| 2253 | + if ('' === $color) |
|
| 2254 | 2254 | return ''; |
| 2255 | 2255 | |
| 2256 | 2256 | // 3 or 6 hex digits, or the empty string. |
| 2257 | - if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) |
|
| 2257 | + if (preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color)) |
|
| 2258 | 2258 | return $color; |
| 2259 | 2259 | } |
| 2260 | 2260 | |
@@ -2272,13 +2272,13 @@ discard block |
||
| 2272 | 2272 | * @param string $color |
| 2273 | 2273 | * @return string|null |
| 2274 | 2274 | */ |
| 2275 | -function sanitize_hex_color_no_hash( $color ) { |
|
| 2276 | - $color = ltrim( $color, '#' ); |
|
| 2275 | +function sanitize_hex_color_no_hash($color) { |
|
| 2276 | + $color = ltrim($color, '#'); |
|
| 2277 | 2277 | |
| 2278 | - if ( '' === $color ) |
|
| 2278 | + if ('' === $color) |
|
| 2279 | 2279 | return ''; |
| 2280 | 2280 | |
| 2281 | - return sanitize_hex_color( '#' . $color ) ? $color : null; |
|
| 2281 | + return sanitize_hex_color('#'.$color) ? $color : null; |
|
| 2282 | 2282 | } |
| 2283 | 2283 | |
| 2284 | 2284 | /** |
@@ -2292,9 +2292,9 @@ discard block |
||
| 2292 | 2292 | * @param string $color |
| 2293 | 2293 | * @return string |
| 2294 | 2294 | */ |
| 2295 | -function maybe_hash_hex_color( $color ) { |
|
| 2296 | - if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) |
|
| 2297 | - return '#' . $unhashed; |
|
| 2295 | +function maybe_hash_hex_color($color) { |
|
| 2296 | + if ($unhashed = sanitize_hex_color_no_hash($color)) |
|
| 2297 | + return '#'.$unhashed; |
|
| 2298 | 2298 | |
| 2299 | 2299 | return $color; |
| 2300 | 2300 | } |
@@ -279,7 +279,7 @@ |
||
| 279 | 279 | * @param int $dst_h The destination height. |
| 280 | 280 | * @param string $filter_name Optional. The Imagick filter to use when resizing. Default 'FILTER_TRIANGLE'. |
| 281 | 281 | * @param bool $strip_meta Optional. Strip all profiles, excluding color profiles, from the image. Default true. |
| 282 | - * @return bool|WP_Error |
|
| 282 | + * @return null|WP_Error |
|
| 283 | 283 | */ |
| 284 | 284 | protected function thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true ) { |
| 285 | 285 | $allowed_filters = array( |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | protected $image; |
| 25 | 25 | |
| 26 | 26 | public function __destruct() { |
| 27 | - if ( $this->image instanceof Imagick ) { |
|
| 27 | + if ($this->image instanceof Imagick) { |
|
| 28 | 28 | // we don't need the original in memory anymore |
| 29 | 29 | $this->image->clear(); |
| 30 | 30 | $this->image->destroy(); |
@@ -45,13 +45,13 @@ discard block |
||
| 45 | 45 | * @param array $args |
| 46 | 46 | * @return bool |
| 47 | 47 | */ |
| 48 | - public static function test( $args = array() ) { |
|
| 48 | + public static function test($args = array()) { |
|
| 49 | 49 | |
| 50 | 50 | // First, test Imagick's extension and classes. |
| 51 | - if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) |
|
| 51 | + if ( ! extension_loaded('imagick') || ! class_exists('Imagick', false) || ! class_exists('ImagickPixel', false)) |
|
| 52 | 52 | return false; |
| 53 | 53 | |
| 54 | - if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) |
|
| 54 | + if (version_compare(phpversion('imagick'), '2.2.0', '<')) |
|
| 55 | 55 | return false; |
| 56 | 56 | |
| 57 | 57 | $required_methods = array( |
@@ -76,16 +76,16 @@ discard block |
||
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | 78 | // Now, test for deep requirements within Imagick. |
| 79 | - if ( ! defined( 'imagick::COMPRESSION_JPEG' ) ) |
|
| 79 | + if ( ! defined('imagick::COMPRESSION_JPEG')) |
|
| 80 | 80 | return false; |
| 81 | 81 | |
| 82 | - $class_methods = array_map( 'strtolower', get_class_methods( 'Imagick' ) ); |
|
| 83 | - if ( array_diff( $required_methods, $class_methods ) ) { |
|
| 82 | + $class_methods = array_map('strtolower', get_class_methods('Imagick')); |
|
| 83 | + if (array_diff($required_methods, $class_methods)) { |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // HHVM Imagick does not support loading from URL, so fail to allow fallback to GD. |
| 88 | - if ( defined( 'HHVM_VERSION' ) && isset( $args['path'] ) && preg_match( '|^https?://|', $args['path'] ) ) { |
|
| 88 | + if (defined('HHVM_VERSION') && isset($args['path']) && preg_match('|^https?://|', $args['path'])) { |
|
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -103,21 +103,21 @@ discard block |
||
| 103 | 103 | * @param string $mime_type |
| 104 | 104 | * @return bool |
| 105 | 105 | */ |
| 106 | - public static function supports_mime_type( $mime_type ) { |
|
| 107 | - $imagick_extension = strtoupper( self::get_extension( $mime_type ) ); |
|
| 106 | + public static function supports_mime_type($mime_type) { |
|
| 107 | + $imagick_extension = strtoupper(self::get_extension($mime_type)); |
|
| 108 | 108 | |
| 109 | - if ( ! $imagick_extension ) |
|
| 109 | + if ( ! $imagick_extension) |
|
| 110 | 110 | return false; |
| 111 | 111 | |
| 112 | 112 | // setIteratorIndex is optional unless mime is an animated format. |
| 113 | 113 | // Here, we just say no if you are missing it and aren't loading a jpeg. |
| 114 | - if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' ) |
|
| 114 | + if ( ! method_exists('Imagick', 'setIteratorIndex') && $mime_type != 'image/jpeg') |
|
| 115 | 115 | return false; |
| 116 | 116 | |
| 117 | 117 | try { |
| 118 | - return ( (bool) @Imagick::queryFormats( $imagick_extension ) ); |
|
| 118 | + return ((bool) @Imagick::queryFormats($imagick_extension)); |
|
| 119 | 119 | } |
| 120 | - catch ( Exception $e ) { |
|
| 120 | + catch (Exception $e) { |
|
| 121 | 121 | return false; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -131,34 +131,34 @@ discard block |
||
| 131 | 131 | * @return true|WP_Error True if loaded; WP_Error on failure. |
| 132 | 132 | */ |
| 133 | 133 | public function load() { |
| 134 | - if ( $this->image instanceof Imagick ) |
|
| 134 | + if ($this->image instanceof Imagick) |
|
| 135 | 135 | return true; |
| 136 | 136 | |
| 137 | - if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) |
|
| 138 | - return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); |
|
| 137 | + if ( ! is_file($this->file) && ! preg_match('|^https?://|', $this->file)) |
|
| 138 | + return new WP_Error('error_loading_image', __('File doesn’t exist?'), $this->file); |
|
| 139 | 139 | |
| 140 | 140 | /** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */ |
| 141 | 141 | // Even though Imagick uses less PHP memory than GD, set higher limit for users that have low PHP.ini limits |
| 142 | - @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
| 142 | + @ini_set('memory_limit', apply_filters('image_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
| 143 | 143 | |
| 144 | 144 | try { |
| 145 | - $this->image = new Imagick( $this->file ); |
|
| 145 | + $this->image = new Imagick($this->file); |
|
| 146 | 146 | |
| 147 | - if ( ! $this->image->valid() ) |
|
| 148 | - return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file); |
|
| 147 | + if ( ! $this->image->valid()) |
|
| 148 | + return new WP_Error('invalid_image', __('File is not an image.'), $this->file); |
|
| 149 | 149 | |
| 150 | 150 | // Select the first frame to handle animated images properly |
| 151 | - if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) |
|
| 151 | + if (is_callable(array($this->image, 'setIteratorIndex'))) |
|
| 152 | 152 | $this->image->setIteratorIndex(0); |
| 153 | 153 | |
| 154 | - $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() ); |
|
| 154 | + $this->mime_type = $this->get_mime_type($this->image->getImageFormat()); |
|
| 155 | 155 | } |
| 156 | - catch ( Exception $e ) { |
|
| 157 | - return new WP_Error( 'invalid_image', $e->getMessage(), $this->file ); |
|
| 156 | + catch (Exception $e) { |
|
| 157 | + return new WP_Error('invalid_image', $e->getMessage(), $this->file); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $updated_size = $this->update_size(); |
| 161 | - if ( is_wp_error( $updated_size ) ) { |
|
| 161 | + if (is_wp_error($updated_size)) { |
|
| 162 | 162 | return $updated_size; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -174,25 +174,25 @@ discard block |
||
| 174 | 174 | * @param int $quality Compression Quality. Range: [1,100] |
| 175 | 175 | * @return true|WP_Error True if set successfully; WP_Error on failure. |
| 176 | 176 | */ |
| 177 | - public function set_quality( $quality = null ) { |
|
| 178 | - $quality_result = parent::set_quality( $quality ); |
|
| 179 | - if ( is_wp_error( $quality_result ) ) { |
|
| 177 | + public function set_quality($quality = null) { |
|
| 178 | + $quality_result = parent::set_quality($quality); |
|
| 179 | + if (is_wp_error($quality_result)) { |
|
| 180 | 180 | return $quality_result; |
| 181 | 181 | } else { |
| 182 | 182 | $quality = $this->get_quality(); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | try { |
| 186 | - if ( 'image/jpeg' == $this->mime_type ) { |
|
| 187 | - $this->image->setImageCompressionQuality( $quality ); |
|
| 188 | - $this->image->setImageCompression( imagick::COMPRESSION_JPEG ); |
|
| 186 | + if ('image/jpeg' == $this->mime_type) { |
|
| 187 | + $this->image->setImageCompressionQuality($quality); |
|
| 188 | + $this->image->setImageCompression(imagick::COMPRESSION_JPEG); |
|
| 189 | 189 | } |
| 190 | 190 | else { |
| 191 | - $this->image->setImageCompressionQuality( $quality ); |
|
| 191 | + $this->image->setImageCompressionQuality($quality); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | - catch ( Exception $e ) { |
|
| 195 | - return new WP_Error( 'image_quality_error', $e->getMessage() ); |
|
| 194 | + catch (Exception $e) { |
|
| 195 | + return new WP_Error('image_quality_error', $e->getMessage()); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | return true; |
@@ -209,24 +209,24 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @return true|WP_Error |
| 211 | 211 | */ |
| 212 | - protected function update_size( $width = null, $height = null ) { |
|
| 212 | + protected function update_size($width = null, $height = null) { |
|
| 213 | 213 | $size = null; |
| 214 | - if ( !$width || !$height ) { |
|
| 214 | + if ( ! $width || ! $height) { |
|
| 215 | 215 | try { |
| 216 | 216 | $size = $this->image->getImageGeometry(); |
| 217 | 217 | } |
| 218 | - catch ( Exception $e ) { |
|
| 219 | - return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file ); |
|
| 218 | + catch (Exception $e) { |
|
| 219 | + return new WP_Error('invalid_image', __('Could not read image size.'), $this->file); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( ! $width ) |
|
| 223 | + if ( ! $width) |
|
| 224 | 224 | $width = $size['width']; |
| 225 | 225 | |
| 226 | - if ( ! $height ) |
|
| 226 | + if ( ! $height) |
|
| 227 | 227 | $height = $size['height']; |
| 228 | 228 | |
| 229 | - return parent::update_size( $width, $height ); |
|
| 229 | + return parent::update_size($width, $height); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -244,26 +244,26 @@ discard block |
||
| 244 | 244 | * @param bool $crop |
| 245 | 245 | * @return bool|WP_Error |
| 246 | 246 | */ |
| 247 | - public function resize( $max_w, $max_h, $crop = false ) { |
|
| 248 | - if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) |
|
| 247 | + public function resize($max_w, $max_h, $crop = false) { |
|
| 248 | + if (($this->size['width'] == $max_w) && ($this->size['height'] == $max_h)) |
|
| 249 | 249 | return true; |
| 250 | 250 | |
| 251 | - $dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop ); |
|
| 252 | - if ( ! $dims ) |
|
| 253 | - return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') ); |
|
| 254 | - list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; |
|
| 251 | + $dims = image_resize_dimensions($this->size['width'], $this->size['height'], $max_w, $max_h, $crop); |
|
| 252 | + if ( ! $dims) |
|
| 253 | + return new WP_Error('error_getting_dimensions', __('Could not calculate resized image dimensions')); |
|
| 254 | + list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims; |
|
| 255 | 255 | |
| 256 | - if ( $crop ) { |
|
| 257 | - return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h ); |
|
| 256 | + if ($crop) { |
|
| 257 | + return $this->crop($src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // Execute the resize |
| 261 | - $thumb_result = $this->thumbnail_image( $dst_w, $dst_h ); |
|
| 262 | - if ( is_wp_error( $thumb_result ) ) { |
|
| 261 | + $thumb_result = $this->thumbnail_image($dst_w, $dst_h); |
|
| 262 | + if (is_wp_error($thumb_result)) { |
|
| 263 | 263 | return $thumb_result; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - return $this->update_size( $dst_w, $dst_h ); |
|
| 266 | + return $this->update_size($dst_w, $dst_h); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * @param bool $strip_meta Optional. Strip all profiles, excluding color profiles, from the image. Default true. |
| 282 | 282 | * @return bool|WP_Error |
| 283 | 283 | */ |
| 284 | - protected function thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true ) { |
|
| 284 | + protected function thumbnail_image($dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true) { |
|
| 285 | 285 | $allowed_filters = array( |
| 286 | 286 | 'FILTER_POINT', |
| 287 | 287 | 'FILTER_BOX', |
@@ -304,10 +304,10 @@ discard block |
||
| 304 | 304 | * Set the filter value if '$filter_name' name is in our whitelist and the related |
| 305 | 305 | * Imagick constant is defined or fall back to our default filter. |
| 306 | 306 | */ |
| 307 | - if ( in_array( $filter_name, $allowed_filters ) && defined( 'Imagick::' . $filter_name ) ) { |
|
| 308 | - $filter = constant( 'Imagick::' . $filter_name ); |
|
| 307 | + if (in_array($filter_name, $allowed_filters) && defined('Imagick::'.$filter_name)) { |
|
| 308 | + $filter = constant('Imagick::'.$filter_name); |
|
| 309 | 309 | } else { |
| 310 | - $filter = defined( 'Imagick::FILTER_TRIANGLE' ) ? Imagick::FILTER_TRIANGLE : false; |
|
| 310 | + $filter = defined('Imagick::FILTER_TRIANGLE') ? Imagick::FILTER_TRIANGLE : false; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * |
| 321 | 321 | * @param bool $strip_meta Whether to strip image metadata during resizing. Default true. |
| 322 | 322 | */ |
| 323 | - if ( apply_filters( 'image_strip_meta', $strip_meta ) ) { |
|
| 323 | + if (apply_filters('image_strip_meta', $strip_meta)) { |
|
| 324 | 324 | $this->strip_meta(); // Fail silently if not supported. |
| 325 | 325 | } |
| 326 | 326 | |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | * whenever the output size is less that 1/3 of the original image size (1/3^2 ~= .111), |
| 331 | 331 | * unless we would be resampling to a scale smaller than 128x128. |
| 332 | 332 | */ |
| 333 | - if ( is_callable( array( $this->image, 'sampleImage' ) ) ) { |
|
| 334 | - $resize_ratio = ( $dst_w / $this->size['width'] ) * ( $dst_h / $this->size['height'] ); |
|
| 333 | + if (is_callable(array($this->image, 'sampleImage'))) { |
|
| 334 | + $resize_ratio = ($dst_w / $this->size['width']) * ($dst_h / $this->size['height']); |
|
| 335 | 335 | $sample_factor = 5; |
| 336 | 336 | |
| 337 | - if ( $resize_ratio < .111 && ( $dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128 ) ) { |
|
| 338 | - $this->image->sampleImage( $dst_w * $sample_factor, $dst_h * $sample_factor ); |
|
| 337 | + if ($resize_ratio < .111 && ($dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128)) { |
|
| 338 | + $this->image->sampleImage($dst_w * $sample_factor, $dst_h * $sample_factor); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
@@ -345,27 +345,27 @@ discard block |
||
| 345 | 345 | * results in better image quality over resizeImage() with default filter |
| 346 | 346 | * settings and retains backwards compatibility with pre 4.5 functionality. |
| 347 | 347 | */ |
| 348 | - if ( is_callable( array( $this->image, 'resizeImage' ) ) && $filter ) { |
|
| 349 | - $this->image->setOption( 'filter:support', '2.0' ); |
|
| 350 | - $this->image->resizeImage( $dst_w, $dst_h, $filter, 1 ); |
|
| 348 | + if (is_callable(array($this->image, 'resizeImage')) && $filter) { |
|
| 349 | + $this->image->setOption('filter:support', '2.0'); |
|
| 350 | + $this->image->resizeImage($dst_w, $dst_h, $filter, 1); |
|
| 351 | 351 | } else { |
| 352 | - $this->image->scaleImage( $dst_w, $dst_h ); |
|
| 352 | + $this->image->scaleImage($dst_w, $dst_h); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // Set appropriate quality settings after resizing. |
| 356 | - if ( 'image/jpeg' == $this->mime_type ) { |
|
| 357 | - if ( is_callable( array( $this->image, 'unsharpMaskImage' ) ) ) { |
|
| 358 | - $this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 ); |
|
| 356 | + if ('image/jpeg' == $this->mime_type) { |
|
| 357 | + if (is_callable(array($this->image, 'unsharpMaskImage'))) { |
|
| 358 | + $this->image->unsharpMaskImage(0.25, 0.25, 8, 0.065); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $this->image->setOption( 'jpeg:fancy-upsampling', 'off' ); |
|
| 361 | + $this->image->setOption('jpeg:fancy-upsampling', 'off'); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if ( 'image/png' === $this->mime_type ) { |
|
| 365 | - $this->image->setOption( 'png:compression-filter', '5' ); |
|
| 366 | - $this->image->setOption( 'png:compression-level', '9' ); |
|
| 367 | - $this->image->setOption( 'png:compression-strategy', '1' ); |
|
| 368 | - $this->image->setOption( 'png:exclude-chunk', 'all' ); |
|
| 364 | + if ('image/png' === $this->mime_type) { |
|
| 365 | + $this->image->setOption('png:compression-filter', '5'); |
|
| 366 | + $this->image->setOption('png:compression-level', '9'); |
|
| 367 | + $this->image->setOption('png:compression-strategy', '1'); |
|
| 368 | + $this->image->setOption('png:exclude-chunk', 'all'); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /* |
@@ -374,30 +374,30 @@ discard block |
||
| 374 | 374 | * Note that Imagick::getImageAlphaChannel() is only available if Imagick |
| 375 | 375 | * has been compiled against ImageMagick version 6.4.0 or newer. |
| 376 | 376 | */ |
| 377 | - if ( is_callable( array( $this->image, 'getImageAlphaChannel' ) ) |
|
| 378 | - && is_callable( array( $this->image, 'setImageAlphaChannel' ) ) |
|
| 379 | - && defined( Imagick::ALPHACHANNEL_UNDEFINED ) |
|
| 380 | - && defined( Imagick::ALPHACHANNEL_OPAQUE ) |
|
| 377 | + if (is_callable(array($this->image, 'getImageAlphaChannel')) |
|
| 378 | + && is_callable(array($this->image, 'setImageAlphaChannel')) |
|
| 379 | + && defined(Imagick::ALPHACHANNEL_UNDEFINED) |
|
| 380 | + && defined(Imagick::ALPHACHANNEL_OPAQUE) |
|
| 381 | 381 | ) { |
| 382 | - if ( $this->image->getImageAlphaChannel() === Imagick::ALPHACHANNEL_UNDEFINED ) { |
|
| 383 | - $this->image->setImageAlphaChannel( Imagick::ALPHACHANNEL_OPAQUE ); |
|
| 382 | + if ($this->image->getImageAlphaChannel() === Imagick::ALPHACHANNEL_UNDEFINED) { |
|
| 383 | + $this->image->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE); |
|
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // Limit the bit depth of resized images to 8 bits per channel. |
| 388 | - if ( is_callable( array( $this->image, 'getImageDepth' ) ) && is_callable( array( $this->image, 'setImageDepth' ) ) ) { |
|
| 389 | - if ( 8 < $this->image->getImageDepth() ) { |
|
| 390 | - $this->image->setImageDepth( 8 ); |
|
| 388 | + if (is_callable(array($this->image, 'getImageDepth')) && is_callable(array($this->image, 'setImageDepth'))) { |
|
| 389 | + if (8 < $this->image->getImageDepth()) { |
|
| 390 | + $this->image->setImageDepth(8); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if ( is_callable( array( $this->image, 'setInterlaceScheme' ) ) && defined( 'Imagick::INTERLACE_NO' ) ) { |
|
| 395 | - $this->image->setInterlaceScheme( Imagick::INTERLACE_NO ); |
|
| 394 | + if (is_callable(array($this->image, 'setInterlaceScheme')) && defined('Imagick::INTERLACE_NO')) { |
|
| 395 | + $this->image->setInterlaceScheme(Imagick::INTERLACE_NO); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | } |
| 399 | - catch ( Exception $e ) { |
|
| 400 | - return new WP_Error( 'image_resize_error', $e->getMessage() ); |
|
| 399 | + catch (Exception $e) { |
|
| 400 | + return new WP_Error('image_resize_error', $e->getMessage()); |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
@@ -424,42 +424,42 @@ discard block |
||
| 424 | 424 | * } |
| 425 | 425 | * @return array An array of resized images' metadata by size. |
| 426 | 426 | */ |
| 427 | - public function multi_resize( $sizes ) { |
|
| 427 | + public function multi_resize($sizes) { |
|
| 428 | 428 | $metadata = array(); |
| 429 | 429 | $orig_size = $this->size; |
| 430 | 430 | $orig_image = $this->image->getImage(); |
| 431 | 431 | |
| 432 | - foreach ( $sizes as $size => $size_data ) { |
|
| 433 | - if ( ! $this->image ) |
|
| 432 | + foreach ($sizes as $size => $size_data) { |
|
| 433 | + if ( ! $this->image) |
|
| 434 | 434 | $this->image = $orig_image->getImage(); |
| 435 | 435 | |
| 436 | - if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { |
|
| 436 | + if ( ! isset($size_data['width']) && ! isset($size_data['height'])) { |
|
| 437 | 437 | continue; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - if ( ! isset( $size_data['width'] ) ) { |
|
| 440 | + if ( ! isset($size_data['width'])) { |
|
| 441 | 441 | $size_data['width'] = null; |
| 442 | 442 | } |
| 443 | - if ( ! isset( $size_data['height'] ) ) { |
|
| 443 | + if ( ! isset($size_data['height'])) { |
|
| 444 | 444 | $size_data['height'] = null; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if ( ! isset( $size_data['crop'] ) ) { |
|
| 447 | + if ( ! isset($size_data['crop'])) { |
|
| 448 | 448 | $size_data['crop'] = false; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - $resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] ); |
|
| 452 | - $duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) ); |
|
| 451 | + $resize_result = $this->resize($size_data['width'], $size_data['height'], $size_data['crop']); |
|
| 452 | + $duplicate = (($orig_size['width'] == $size_data['width']) && ($orig_size['height'] == $size_data['height'])); |
|
| 453 | 453 | |
| 454 | - if ( ! is_wp_error( $resize_result ) && ! $duplicate ) { |
|
| 455 | - $resized = $this->_save( $this->image ); |
|
| 454 | + if ( ! is_wp_error($resize_result) && ! $duplicate) { |
|
| 455 | + $resized = $this->_save($this->image); |
|
| 456 | 456 | |
| 457 | 457 | $this->image->clear(); |
| 458 | 458 | $this->image->destroy(); |
| 459 | 459 | $this->image = null; |
| 460 | 460 | |
| 461 | - if ( ! is_wp_error( $resized ) && $resized ) { |
|
| 462 | - unset( $resized['path'] ); |
|
| 461 | + if ( ! is_wp_error($resized) && $resized) { |
|
| 462 | + unset($resized['path']); |
|
| 463 | 463 | $metadata[$size] = $resized; |
| 464 | 464 | } |
| 465 | 465 | } |
@@ -487,34 +487,34 @@ discard block |
||
| 487 | 487 | * @param bool $src_abs Optional. If the source crop points are absolute. |
| 488 | 488 | * @return bool|WP_Error |
| 489 | 489 | */ |
| 490 | - public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { |
|
| 491 | - if ( $src_abs ) { |
|
| 490 | + public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false) { |
|
| 491 | + if ($src_abs) { |
|
| 492 | 492 | $src_w -= $src_x; |
| 493 | 493 | $src_h -= $src_y; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | try { |
| 497 | - $this->image->cropImage( $src_w, $src_h, $src_x, $src_y ); |
|
| 498 | - $this->image->setImagePage( $src_w, $src_h, 0, 0); |
|
| 497 | + $this->image->cropImage($src_w, $src_h, $src_x, $src_y); |
|
| 498 | + $this->image->setImagePage($src_w, $src_h, 0, 0); |
|
| 499 | 499 | |
| 500 | - if ( $dst_w || $dst_h ) { |
|
| 500 | + if ($dst_w || $dst_h) { |
|
| 501 | 501 | // If destination width/height isn't specified, use same as |
| 502 | 502 | // width/height from source. |
| 503 | - if ( ! $dst_w ) |
|
| 503 | + if ( ! $dst_w) |
|
| 504 | 504 | $dst_w = $src_w; |
| 505 | - if ( ! $dst_h ) |
|
| 505 | + if ( ! $dst_h) |
|
| 506 | 506 | $dst_h = $src_h; |
| 507 | 507 | |
| 508 | - $thumb_result = $this->thumbnail_image( $dst_w, $dst_h ); |
|
| 509 | - if ( is_wp_error( $thumb_result ) ) { |
|
| 508 | + $thumb_result = $this->thumbnail_image($dst_w, $dst_h); |
|
| 509 | + if (is_wp_error($thumb_result)) { |
|
| 510 | 510 | return $thumb_result; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | return $this->update_size(); |
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | - catch ( Exception $e ) { |
|
| 517 | - return new WP_Error( 'image_crop_error', $e->getMessage() ); |
|
| 516 | + catch (Exception $e) { |
|
| 517 | + return new WP_Error('image_crop_error', $e->getMessage()); |
|
| 518 | 518 | } |
| 519 | 519 | return $this->update_size(); |
| 520 | 520 | } |
@@ -528,23 +528,23 @@ discard block |
||
| 528 | 528 | * @param float $angle |
| 529 | 529 | * @return true|WP_Error |
| 530 | 530 | */ |
| 531 | - public function rotate( $angle ) { |
|
| 531 | + public function rotate($angle) { |
|
| 532 | 532 | /** |
| 533 | 533 | * $angle is 360-$angle because Imagick rotates clockwise |
| 534 | 534 | * (GD rotates counter-clockwise) |
| 535 | 535 | */ |
| 536 | 536 | try { |
| 537 | - $this->image->rotateImage( new ImagickPixel('none'), 360-$angle ); |
|
| 537 | + $this->image->rotateImage(new ImagickPixel('none'), 360 - $angle); |
|
| 538 | 538 | |
| 539 | 539 | // Since this changes the dimensions of the image, update the size. |
| 540 | 540 | $result = $this->update_size(); |
| 541 | - if ( is_wp_error( $result ) ) |
|
| 541 | + if (is_wp_error($result)) |
|
| 542 | 542 | return $result; |
| 543 | 543 | |
| 544 | - $this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 ); |
|
| 544 | + $this->image->setImagePage($this->size['width'], $this->size['height'], 0, 0); |
|
| 545 | 545 | } |
| 546 | - catch ( Exception $e ) { |
|
| 547 | - return new WP_Error( 'image_rotate_error', $e->getMessage() ); |
|
| 546 | + catch (Exception $e) { |
|
| 547 | + return new WP_Error('image_rotate_error', $e->getMessage()); |
|
| 548 | 548 | } |
| 549 | 549 | return true; |
| 550 | 550 | } |
@@ -559,16 +559,16 @@ discard block |
||
| 559 | 559 | * @param bool $vert Flip along Vertical Axis |
| 560 | 560 | * @return true|WP_Error |
| 561 | 561 | */ |
| 562 | - public function flip( $horz, $vert ) { |
|
| 562 | + public function flip($horz, $vert) { |
|
| 563 | 563 | try { |
| 564 | - if ( $horz ) |
|
| 564 | + if ($horz) |
|
| 565 | 565 | $this->image->flipImage(); |
| 566 | 566 | |
| 567 | - if ( $vert ) |
|
| 567 | + if ($vert) |
|
| 568 | 568 | $this->image->flopImage(); |
| 569 | 569 | } |
| 570 | - catch ( Exception $e ) { |
|
| 571 | - return new WP_Error( 'image_flip_error', $e->getMessage() ); |
|
| 570 | + catch (Exception $e) { |
|
| 571 | + return new WP_Error('image_flip_error', $e->getMessage()); |
|
| 572 | 572 | } |
| 573 | 573 | return true; |
| 574 | 574 | } |
@@ -583,18 +583,18 @@ discard block |
||
| 583 | 583 | * @param string $mime_type |
| 584 | 584 | * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} |
| 585 | 585 | */ |
| 586 | - public function save( $destfilename = null, $mime_type = null ) { |
|
| 587 | - $saved = $this->_save( $this->image, $destfilename, $mime_type ); |
|
| 586 | + public function save($destfilename = null, $mime_type = null) { |
|
| 587 | + $saved = $this->_save($this->image, $destfilename, $mime_type); |
|
| 588 | 588 | |
| 589 | - if ( ! is_wp_error( $saved ) ) { |
|
| 589 | + if ( ! is_wp_error($saved)) { |
|
| 590 | 590 | $this->file = $saved['path']; |
| 591 | 591 | $this->mime_type = $saved['mime-type']; |
| 592 | 592 | |
| 593 | 593 | try { |
| 594 | - $this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) ); |
|
| 594 | + $this->image->setImageFormat(strtoupper($this->get_extension($this->mime_type))); |
|
| 595 | 595 | } |
| 596 | - catch ( Exception $e ) { |
|
| 597 | - return new WP_Error( 'image_save_error', $e->getMessage(), $this->file ); |
|
| 596 | + catch (Exception $e) { |
|
| 597 | + return new WP_Error('image_save_error', $e->getMessage(), $this->file); |
|
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
@@ -608,35 +608,35 @@ discard block |
||
| 608 | 608 | * @param string $mime_type |
| 609 | 609 | * @return array|WP_Error |
| 610 | 610 | */ |
| 611 | - protected function _save( $image, $filename = null, $mime_type = null ) { |
|
| 612 | - list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type ); |
|
| 611 | + protected function _save($image, $filename = null, $mime_type = null) { |
|
| 612 | + list($filename, $extension, $mime_type) = $this->get_output_format($filename, $mime_type); |
|
| 613 | 613 | |
| 614 | - if ( ! $filename ) |
|
| 615 | - $filename = $this->generate_filename( null, null, $extension ); |
|
| 614 | + if ( ! $filename) |
|
| 615 | + $filename = $this->generate_filename(null, null, $extension); |
|
| 616 | 616 | |
| 617 | 617 | try { |
| 618 | 618 | // Store initial Format |
| 619 | 619 | $orig_format = $this->image->getImageFormat(); |
| 620 | 620 | |
| 621 | - $this->image->setImageFormat( strtoupper( $this->get_extension( $mime_type ) ) ); |
|
| 622 | - $this->make_image( $filename, array( $image, 'writeImage' ), array( $filename ) ); |
|
| 621 | + $this->image->setImageFormat(strtoupper($this->get_extension($mime_type))); |
|
| 622 | + $this->make_image($filename, array($image, 'writeImage'), array($filename)); |
|
| 623 | 623 | |
| 624 | 624 | // Reset original Format |
| 625 | - $this->image->setImageFormat( $orig_format ); |
|
| 625 | + $this->image->setImageFormat($orig_format); |
|
| 626 | 626 | } |
| 627 | - catch ( Exception $e ) { |
|
| 628 | - return new WP_Error( 'image_save_error', $e->getMessage(), $filename ); |
|
| 627 | + catch (Exception $e) { |
|
| 628 | + return new WP_Error('image_save_error', $e->getMessage(), $filename); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | // Set correct file permissions |
| 632 | - $stat = stat( dirname( $filename ) ); |
|
| 632 | + $stat = stat(dirname($filename)); |
|
| 633 | 633 | $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits |
| 634 | - @ chmod( $filename, $perms ); |
|
| 634 | + @ chmod($filename, $perms); |
|
| 635 | 635 | |
| 636 | 636 | /** This filter is documented in wp-includes/class-wp-image-editor-gd.php */ |
| 637 | 637 | return array( |
| 638 | 638 | 'path' => $filename, |
| 639 | - 'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ), |
|
| 639 | + 'file' => wp_basename(apply_filters('image_make_intermediate_size', $filename)), |
|
| 640 | 640 | 'width' => $this->size['width'], |
| 641 | 641 | 'height' => $this->size['height'], |
| 642 | 642 | 'mime-type' => $mime_type, |
@@ -652,22 +652,22 @@ discard block |
||
| 652 | 652 | * @param string $mime_type |
| 653 | 653 | * @return true|WP_Error |
| 654 | 654 | */ |
| 655 | - public function stream( $mime_type = null ) { |
|
| 656 | - list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type ); |
|
| 655 | + public function stream($mime_type = null) { |
|
| 656 | + list($filename, $extension, $mime_type) = $this->get_output_format(null, $mime_type); |
|
| 657 | 657 | |
| 658 | 658 | try { |
| 659 | 659 | // Temporarily change format for stream |
| 660 | - $this->image->setImageFormat( strtoupper( $extension ) ); |
|
| 660 | + $this->image->setImageFormat(strtoupper($extension)); |
|
| 661 | 661 | |
| 662 | 662 | // Output stream of image content |
| 663 | - header( "Content-Type: $mime_type" ); |
|
| 663 | + header("Content-Type: $mime_type"); |
|
| 664 | 664 | print $this->image->getImageBlob(); |
| 665 | 665 | |
| 666 | 666 | // Reset Image to original Format |
| 667 | - $this->image->setImageFormat( $this->get_extension( $this->mime_type ) ); |
|
| 667 | + $this->image->setImageFormat($this->get_extension($this->mime_type)); |
|
| 668 | 668 | } |
| 669 | - catch ( Exception $e ) { |
|
| 670 | - return new WP_Error( 'image_stream_error', $e->getMessage() ); |
|
| 669 | + catch (Exception $e) { |
|
| 670 | + return new WP_Error('image_stream_error', $e->getMessage()); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | return true; |
@@ -683,14 +683,14 @@ discard block |
||
| 683 | 683 | */ |
| 684 | 684 | protected function strip_meta() { |
| 685 | 685 | |
| 686 | - if ( ! is_callable( array( $this->image, 'getImageProfiles' ) ) ) { |
|
| 686 | + if ( ! is_callable(array($this->image, 'getImageProfiles'))) { |
|
| 687 | 687 | /* translators: %s: ImageMagick method name */ |
| 688 | - return new WP_Error( 'image_strip_meta_error', sprintf( __( '%s is required to strip image meta.' ), '<code>Imagick::getImageProfiles()</code>' ) ); |
|
| 688 | + return new WP_Error('image_strip_meta_error', sprintf(__('%s is required to strip image meta.'), '<code>Imagick::getImageProfiles()</code>')); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - if ( ! is_callable( array( $this->image, 'removeImageProfile' ) ) ) { |
|
| 691 | + if ( ! is_callable(array($this->image, 'removeImageProfile'))) { |
|
| 692 | 692 | /* translators: %s: ImageMagick method name */ |
| 693 | - return new WP_Error( 'image_strip_meta_error', sprintf( __( '%s is required to strip image meta.' ), '<code>Imagick::removeImageProfile()</code>' ) ); |
|
| 693 | + return new WP_Error('image_strip_meta_error', sprintf(__('%s is required to strip image meta.'), '<code>Imagick::removeImageProfile()</code>')); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /* |
@@ -712,14 +712,14 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | try { |
| 714 | 714 | // Strip profiles. |
| 715 | - foreach ( $this->image->getImageProfiles( '*', true ) as $key => $value ) { |
|
| 716 | - if ( ! in_array( $key, $protected_profiles ) ) { |
|
| 717 | - $this->image->removeImageProfile( $key ); |
|
| 715 | + foreach ($this->image->getImageProfiles('*', true) as $key => $value) { |
|
| 716 | + if ( ! in_array($key, $protected_profiles)) { |
|
| 717 | + $this->image->removeImageProfile($key); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - } catch ( Exception $e ) { |
|
| 722 | - return new WP_Error( 'image_strip_meta_error', $e->getMessage() ); |
|
| 721 | + } catch (Exception $e) { |
|
| 722 | + return new WP_Error('image_strip_meta_error', $e->getMessage()); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | return true; |
@@ -48,11 +48,13 @@ discard block |
||
| 48 | 48 | public static function test( $args = array() ) { |
| 49 | 49 | |
| 50 | 50 | // First, test Imagick's extension and classes. |
| 51 | - if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) |
|
| 52 | - return false; |
|
| 51 | + if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) { |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | - if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) |
|
| 55 | - return false; |
|
| 55 | + if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) { |
|
| 56 | + return false; |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | $required_methods = array( |
| 58 | 60 | 'clear', |
@@ -76,8 +78,9 @@ discard block |
||
| 76 | 78 | ); |
| 77 | 79 | |
| 78 | 80 | // Now, test for deep requirements within Imagick. |
| 79 | - if ( ! defined( 'imagick::COMPRESSION_JPEG' ) ) |
|
| 80 | - return false; |
|
| 81 | + if ( ! defined( 'imagick::COMPRESSION_JPEG' ) ) { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | $class_methods = array_map( 'strtolower', get_class_methods( 'Imagick' ) ); |
| 83 | 86 | if ( array_diff( $required_methods, $class_methods ) ) { |
@@ -106,18 +109,19 @@ discard block |
||
| 106 | 109 | public static function supports_mime_type( $mime_type ) { |
| 107 | 110 | $imagick_extension = strtoupper( self::get_extension( $mime_type ) ); |
| 108 | 111 | |
| 109 | - if ( ! $imagick_extension ) |
|
| 110 | - return false; |
|
| 112 | + if ( ! $imagick_extension ) { |
|
| 113 | + return false; |
|
| 114 | + } |
|
| 111 | 115 | |
| 112 | 116 | // setIteratorIndex is optional unless mime is an animated format. |
| 113 | 117 | // Here, we just say no if you are missing it and aren't loading a jpeg. |
| 114 | - if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' ) |
|
| 115 | - return false; |
|
| 118 | + if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' ) { |
|
| 119 | + return false; |
|
| 120 | + } |
|
| 116 | 121 | |
| 117 | 122 | try { |
| 118 | 123 | return ( (bool) @Imagick::queryFormats( $imagick_extension ) ); |
| 119 | - } |
|
| 120 | - catch ( Exception $e ) { |
|
| 124 | + } catch ( Exception $e ) { |
|
| 121 | 125 | return false; |
| 122 | 126 | } |
| 123 | 127 | } |
@@ -131,11 +135,13 @@ discard block |
||
| 131 | 135 | * @return true|WP_Error True if loaded; WP_Error on failure. |
| 132 | 136 | */ |
| 133 | 137 | public function load() { |
| 134 | - if ( $this->image instanceof Imagick ) |
|
| 135 | - return true; |
|
| 138 | + if ( $this->image instanceof Imagick ) { |
|
| 139 | + return true; |
|
| 140 | + } |
|
| 136 | 141 | |
| 137 | - if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) |
|
| 138 | - return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); |
|
| 142 | + if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) { |
|
| 143 | + return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); |
|
| 144 | + } |
|
| 139 | 145 | |
| 140 | 146 | /** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */ |
| 141 | 147 | // Even though Imagick uses less PHP memory than GD, set higher limit for users that have low PHP.ini limits |
@@ -144,16 +150,17 @@ discard block |
||
| 144 | 150 | try { |
| 145 | 151 | $this->image = new Imagick( $this->file ); |
| 146 | 152 | |
| 147 | - if ( ! $this->image->valid() ) |
|
| 148 | - return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file); |
|
| 153 | + if ( ! $this->image->valid() ) { |
|
| 154 | + return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // Select the first frame to handle animated images properly |
| 151 | - if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) |
|
| 152 | - $this->image->setIteratorIndex(0); |
|
| 158 | + if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) { |
|
| 159 | + $this->image->setIteratorIndex(0); |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() ); |
| 155 | - } |
|
| 156 | - catch ( Exception $e ) { |
|
| 163 | + } catch ( Exception $e ) { |
|
| 157 | 164 | return new WP_Error( 'invalid_image', $e->getMessage(), $this->file ); |
| 158 | 165 | } |
| 159 | 166 | |
@@ -186,12 +193,10 @@ discard block |
||
| 186 | 193 | if ( 'image/jpeg' == $this->mime_type ) { |
| 187 | 194 | $this->image->setImageCompressionQuality( $quality ); |
| 188 | 195 | $this->image->setImageCompression( imagick::COMPRESSION_JPEG ); |
| 189 | - } |
|
| 190 | - else { |
|
| 196 | + } else { |
|
| 191 | 197 | $this->image->setImageCompressionQuality( $quality ); |
| 192 | 198 | } |
| 193 | - } |
|
| 194 | - catch ( Exception $e ) { |
|
| 199 | + } catch ( Exception $e ) { |
|
| 195 | 200 | return new WP_Error( 'image_quality_error', $e->getMessage() ); |
| 196 | 201 | } |
| 197 | 202 | |
@@ -214,17 +219,18 @@ discard block |
||
| 214 | 219 | if ( !$width || !$height ) { |
| 215 | 220 | try { |
| 216 | 221 | $size = $this->image->getImageGeometry(); |
| 217 | - } |
|
| 218 | - catch ( Exception $e ) { |
|
| 222 | + } catch ( Exception $e ) { |
|
| 219 | 223 | return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file ); |
| 220 | 224 | } |
| 221 | 225 | } |
| 222 | 226 | |
| 223 | - if ( ! $width ) |
|
| 224 | - $width = $size['width']; |
|
| 227 | + if ( ! $width ) { |
|
| 228 | + $width = $size['width']; |
|
| 229 | + } |
|
| 225 | 230 | |
| 226 | - if ( ! $height ) |
|
| 227 | - $height = $size['height']; |
|
| 231 | + if ( ! $height ) { |
|
| 232 | + $height = $size['height']; |
|
| 233 | + } |
|
| 228 | 234 | |
| 229 | 235 | return parent::update_size( $width, $height ); |
| 230 | 236 | } |
@@ -245,12 +251,14 @@ discard block |
||
| 245 | 251 | * @return bool|WP_Error |
| 246 | 252 | */ |
| 247 | 253 | public function resize( $max_w, $max_h, $crop = false ) { |
| 248 | - if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) |
|
| 249 | - return true; |
|
| 254 | + if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) { |
|
| 255 | + return true; |
|
| 256 | + } |
|
| 250 | 257 | |
| 251 | 258 | $dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop ); |
| 252 | - if ( ! $dims ) |
|
| 253 | - return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') ); |
|
| 259 | + if ( ! $dims ) { |
|
| 260 | + return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') ); |
|
| 261 | + } |
|
| 254 | 262 | list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; |
| 255 | 263 | |
| 256 | 264 | if ( $crop ) { |
@@ -395,8 +403,7 @@ discard block |
||
| 395 | 403 | $this->image->setInterlaceScheme( Imagick::INTERLACE_NO ); |
| 396 | 404 | } |
| 397 | 405 | |
| 398 | - } |
|
| 399 | - catch ( Exception $e ) { |
|
| 406 | + } catch ( Exception $e ) { |
|
| 400 | 407 | return new WP_Error( 'image_resize_error', $e->getMessage() ); |
| 401 | 408 | } |
| 402 | 409 | } |
@@ -430,8 +437,9 @@ discard block |
||
| 430 | 437 | $orig_image = $this->image->getImage(); |
| 431 | 438 | |
| 432 | 439 | foreach ( $sizes as $size => $size_data ) { |
| 433 | - if ( ! $this->image ) |
|
| 434 | - $this->image = $orig_image->getImage(); |
|
| 440 | + if ( ! $this->image ) { |
|
| 441 | + $this->image = $orig_image->getImage(); |
|
| 442 | + } |
|
| 435 | 443 | |
| 436 | 444 | if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { |
| 437 | 445 | continue; |
@@ -500,10 +508,12 @@ discard block |
||
| 500 | 508 | if ( $dst_w || $dst_h ) { |
| 501 | 509 | // If destination width/height isn't specified, use same as |
| 502 | 510 | // width/height from source. |
| 503 | - if ( ! $dst_w ) |
|
| 504 | - $dst_w = $src_w; |
|
| 505 | - if ( ! $dst_h ) |
|
| 506 | - $dst_h = $src_h; |
|
| 511 | + if ( ! $dst_w ) { |
|
| 512 | + $dst_w = $src_w; |
|
| 513 | + } |
|
| 514 | + if ( ! $dst_h ) { |
|
| 515 | + $dst_h = $src_h; |
|
| 516 | + } |
|
| 507 | 517 | |
| 508 | 518 | $thumb_result = $this->thumbnail_image( $dst_w, $dst_h ); |
| 509 | 519 | if ( is_wp_error( $thumb_result ) ) { |
@@ -512,8 +522,7 @@ discard block |
||
| 512 | 522 | |
| 513 | 523 | return $this->update_size(); |
| 514 | 524 | } |
| 515 | - } |
|
| 516 | - catch ( Exception $e ) { |
|
| 525 | + } catch ( Exception $e ) { |
|
| 517 | 526 | return new WP_Error( 'image_crop_error', $e->getMessage() ); |
| 518 | 527 | } |
| 519 | 528 | return $this->update_size(); |
@@ -538,12 +547,12 @@ discard block |
||
| 538 | 547 | |
| 539 | 548 | // Since this changes the dimensions of the image, update the size. |
| 540 | 549 | $result = $this->update_size(); |
| 541 | - if ( is_wp_error( $result ) ) |
|
| 542 | - return $result; |
|
| 550 | + if ( is_wp_error( $result ) ) { |
|
| 551 | + return $result; |
|
| 552 | + } |
|
| 543 | 553 | |
| 544 | 554 | $this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 ); |
| 545 | - } |
|
| 546 | - catch ( Exception $e ) { |
|
| 555 | + } catch ( Exception $e ) { |
|
| 547 | 556 | return new WP_Error( 'image_rotate_error', $e->getMessage() ); |
| 548 | 557 | } |
| 549 | 558 | return true; |
@@ -561,13 +570,14 @@ discard block |
||
| 561 | 570 | */ |
| 562 | 571 | public function flip( $horz, $vert ) { |
| 563 | 572 | try { |
| 564 | - if ( $horz ) |
|
| 565 | - $this->image->flipImage(); |
|
| 573 | + if ( $horz ) { |
|
| 574 | + $this->image->flipImage(); |
|
| 575 | + } |
|
| 566 | 576 | |
| 567 | - if ( $vert ) |
|
| 568 | - $this->image->flopImage(); |
|
| 569 | - } |
|
| 570 | - catch ( Exception $e ) { |
|
| 577 | + if ( $vert ) { |
|
| 578 | + $this->image->flopImage(); |
|
| 579 | + } |
|
| 580 | + } catch ( Exception $e ) { |
|
| 571 | 581 | return new WP_Error( 'image_flip_error', $e->getMessage() ); |
| 572 | 582 | } |
| 573 | 583 | return true; |
@@ -592,8 +602,7 @@ discard block |
||
| 592 | 602 | |
| 593 | 603 | try { |
| 594 | 604 | $this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) ); |
| 595 | - } |
|
| 596 | - catch ( Exception $e ) { |
|
| 605 | + } catch ( Exception $e ) { |
|
| 597 | 606 | return new WP_Error( 'image_save_error', $e->getMessage(), $this->file ); |
| 598 | 607 | } |
| 599 | 608 | } |
@@ -611,8 +620,9 @@ discard block |
||
| 611 | 620 | protected function _save( $image, $filename = null, $mime_type = null ) { |
| 612 | 621 | list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type ); |
| 613 | 622 | |
| 614 | - if ( ! $filename ) |
|
| 615 | - $filename = $this->generate_filename( null, null, $extension ); |
|
| 623 | + if ( ! $filename ) { |
|
| 624 | + $filename = $this->generate_filename( null, null, $extension ); |
|
| 625 | + } |
|
| 616 | 626 | |
| 617 | 627 | try { |
| 618 | 628 | // Store initial Format |
@@ -623,8 +633,7 @@ discard block |
||
| 623 | 633 | |
| 624 | 634 | // Reset original Format |
| 625 | 635 | $this->image->setImageFormat( $orig_format ); |
| 626 | - } |
|
| 627 | - catch ( Exception $e ) { |
|
| 636 | + } catch ( Exception $e ) { |
|
| 628 | 637 | return new WP_Error( 'image_save_error', $e->getMessage(), $filename ); |
| 629 | 638 | } |
| 630 | 639 | |
@@ -665,8 +674,7 @@ discard block |
||
| 665 | 674 | |
| 666 | 675 | // Reset Image to original Format |
| 667 | 676 | $this->image->setImageFormat( $this->get_extension( $this->mime_type ) ); |
| 668 | - } |
|
| 669 | - catch ( Exception $e ) { |
|
| 677 | + } catch ( Exception $e ) { |
|
| 670 | 678 | return new WP_Error( 'image_stream_error', $e->getMessage() ); |
| 671 | 679 | } |
| 672 | 680 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @param string $object_type Type of object whose meta is to be lazy-loaded. Accepts 'term' or 'comment'. |
| 76 | 76 | * @param array $object_ids Array of object IDs. |
| 77 | - * @return bool|WP_Error True on success, WP_Error on failure. |
|
| 77 | + * @return WP_Error|null True on success, WP_Error on failure. |
|
| 78 | 78 | */ |
| 79 | 79 | public function queue_objects( $object_type, $object_ids ) { |
| 80 | 80 | if ( ! isset( $this->settings[ $object_type ] ) ) { |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @access public |
| 116 | 116 | * |
| 117 | 117 | * @param string $object_type Object type. Accepts 'comment' or 'term'. |
| 118 | - * @return bool|WP_Error True on success, WP_Error on failure. |
|
| 118 | + * @return WP_Error|null True on success, WP_Error on failure. |
|
| 119 | 119 | */ |
| 120 | 120 | public function reset_queue( $object_type ) { |
| 121 | 121 | if ( ! isset( $this->settings[ $object_type ] ) ) { |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Meta API: WP_Metadata_Lazyloader class |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Meta |
|
| 7 | - * @since 4.5.0 |
|
| 8 | - */ |
|
| 3 | + * Meta API: WP_Metadata_Lazyloader class |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Meta |
|
| 7 | + * @since 4.5.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Core class used for lazy-loading object metadata. |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | $this->settings = array( |
| 58 | 58 | 'term' => array( |
| 59 | 59 | 'filter' => 'get_term_metadata', |
| 60 | - 'callback' => array( $this, 'lazyload_term_meta' ), |
|
| 60 | + 'callback' => array($this, 'lazyload_term_meta'), |
|
| 61 | 61 | ), |
| 62 | 62 | 'comment' => array( |
| 63 | 63 | 'filter' => 'get_comment_metadata', |
| 64 | - 'callback' => array( $this, 'lazyload_comment_meta' ), |
|
| 64 | + 'callback' => array($this, 'lazyload_comment_meta'), |
|
| 65 | 65 | ), |
| 66 | 66 | ); |
| 67 | 67 | } |
@@ -76,25 +76,25 @@ discard block |
||
| 76 | 76 | * @param array $object_ids Array of object IDs. |
| 77 | 77 | * @return bool|WP_Error True on success, WP_Error on failure. |
| 78 | 78 | */ |
| 79 | - public function queue_objects( $object_type, $object_ids ) { |
|
| 80 | - if ( ! isset( $this->settings[ $object_type ] ) ) { |
|
| 81 | - return new WP_Error( 'invalid_object_type', __( 'Invalid object type' ) ); |
|
| 79 | + public function queue_objects($object_type, $object_ids) { |
|
| 80 | + if ( ! isset($this->settings[$object_type])) { |
|
| 81 | + return new WP_Error('invalid_object_type', __('Invalid object type')); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $type_settings = $this->settings[ $object_type ]; |
|
| 84 | + $type_settings = $this->settings[$object_type]; |
|
| 85 | 85 | |
| 86 | - if ( ! isset( $this->pending_objects[ $object_type ] ) ) { |
|
| 87 | - $this->pending_objects[ $object_type ] = array(); |
|
| 86 | + if ( ! isset($this->pending_objects[$object_type])) { |
|
| 87 | + $this->pending_objects[$object_type] = array(); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - foreach ( $object_ids as $object_id ) { |
|
| 90 | + foreach ($object_ids as $object_id) { |
|
| 91 | 91 | // Keyed by ID for faster lookup. |
| 92 | - if ( ! isset( $this->pending_objects[ $object_type ][ $object_id ] ) ) { |
|
| 93 | - $this->pending_objects[ $object_type ][ $object_id ] = 1; |
|
| 92 | + if ( ! isset($this->pending_objects[$object_type][$object_id])) { |
|
| 93 | + $this->pending_objects[$object_type][$object_id] = 1; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - add_filter( $type_settings['filter'], $type_settings['callback'] ); |
|
| 97 | + add_filter($type_settings['filter'], $type_settings['callback']); |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Fires after objects are added to the metadata lazy-load queue. |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param string $object_type Type of object being queued. |
| 106 | 106 | * @param WP_Metadata_Lazyloader $lazyloader The lazy-loader object. |
| 107 | 107 | */ |
| 108 | - do_action( 'metadata_lazyloader_queued_objects', $object_ids, $object_type, $this ); |
|
| 108 | + do_action('metadata_lazyloader_queued_objects', $object_ids, $object_type, $this); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -117,15 +117,15 @@ discard block |
||
| 117 | 117 | * @param string $object_type Object type. Accepts 'comment' or 'term'. |
| 118 | 118 | * @return bool|WP_Error True on success, WP_Error on failure. |
| 119 | 119 | */ |
| 120 | - public function reset_queue( $object_type ) { |
|
| 121 | - if ( ! isset( $this->settings[ $object_type ] ) ) { |
|
| 122 | - return new WP_Error( 'invalid_object_type', __( 'Invalid object type' ) ); |
|
| 120 | + public function reset_queue($object_type) { |
|
| 121 | + if ( ! isset($this->settings[$object_type])) { |
|
| 122 | + return new WP_Error('invalid_object_type', __('Invalid object type')); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $type_settings = $this->settings[ $object_type ]; |
|
| 125 | + $type_settings = $this->settings[$object_type]; |
|
| 126 | 126 | |
| 127 | - $this->pending_objects[ $object_type ] = array(); |
|
| 128 | - remove_filter( $type_settings['filter'], $type_settings['callback'] ); |
|
| 127 | + $this->pending_objects[$object_type] = array(); |
|
| 128 | + remove_filter($type_settings['filter'], $type_settings['callback']); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | * @return mixed In order not to short-circuit `get_metadata()`. Generally, this is `null`, but it could be |
| 142 | 142 | * another value if filtered by a plugin. |
| 143 | 143 | */ |
| 144 | - public function lazyload_term_meta( $check ) { |
|
| 145 | - if ( ! empty( $this->pending_objects['term'] ) ) { |
|
| 146 | - update_termmeta_cache( array_keys( $this->pending_objects['term'] ) ); |
|
| 144 | + public function lazyload_term_meta($check) { |
|
| 145 | + if ( ! empty($this->pending_objects['term'])) { |
|
| 146 | + update_termmeta_cache(array_keys($this->pending_objects['term'])); |
|
| 147 | 147 | |
| 148 | 148 | // No need to run again for this set of terms. |
| 149 | - $this->reset_queue( 'term' ); |
|
| 149 | + $this->reset_queue('term'); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return $check; |
@@ -163,12 +163,12 @@ discard block |
||
| 163 | 163 | * @param mixed $check The `$check` param passed from the 'get_comment_metadata' hook. |
| 164 | 164 | * @return mixed The original value of `$check`, so as not to short-circuit `get_comment_metadata()`. |
| 165 | 165 | */ |
| 166 | - public function lazyload_comment_meta( $check ) { |
|
| 167 | - if ( ! empty( $this->pending_objects['comment'] ) ) { |
|
| 168 | - update_meta_cache( 'comment', array_keys( $this->pending_objects['comment'] ) ); |
|
| 166 | + public function lazyload_comment_meta($check) { |
|
| 167 | + if ( ! empty($this->pending_objects['comment'])) { |
|
| 168 | + update_meta_cache('comment', array_keys($this->pending_objects['comment'])); |
|
| 169 | 169 | |
| 170 | 170 | // No need to run again for this set of comments. |
| 171 | - $this->reset_queue( 'comment' ); |
|
| 171 | + $this->reset_queue('comment'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $check; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @since 1.5.0 |
| 18 | 18 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 19 | 19 | * |
| 20 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author. |
|
| 20 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author. |
|
| 21 | 21 | * Default current comment. |
| 22 | 22 | * @return string The comment author |
| 23 | 23 | */ |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @since 0.71 |
| 53 | 53 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 54 | 54 | * |
| 55 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. |
|
| 55 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. |
|
| 56 | 56 | * Default current comment. |
| 57 | 57 | */ |
| 58 | 58 | function comment_author( $comment_ID = 0 ) { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @since 1.5.0 |
| 78 | 78 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 79 | 79 | * |
| 80 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email. |
|
| 80 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email. |
|
| 81 | 81 | * Default current comment. |
| 82 | 82 | * @return string The current comment author's email |
| 83 | 83 | */ |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @since 0.71 |
| 110 | 110 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 111 | 111 | * |
| 112 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. |
|
| 112 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. |
|
| 113 | 113 | * Default current comment. |
| 114 | 114 | */ |
| 115 | 115 | function comment_author_email( $comment_ID = 0 ) { |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @since 1.5.0 |
| 202 | 202 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 203 | 203 | * |
| 204 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. |
|
| 204 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. |
|
| 205 | 205 | * Default current comment. |
| 206 | 206 | * @return string The comment author name or HTML link for author's URL. |
| 207 | 207 | */ |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @since 0.71 |
| 236 | 236 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 237 | 237 | * |
| 238 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. |
|
| 238 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. |
|
| 239 | 239 | * Default current comment. |
| 240 | 240 | */ |
| 241 | 241 | function comment_author_link( $comment_ID = 0 ) { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * @since 1.5.0 |
| 249 | 249 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 250 | 250 | * |
| 251 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. |
|
| 251 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. |
|
| 252 | 252 | * Default current comment. |
| 253 | 253 | * @return string Comment author's IP address. |
| 254 | 254 | */ |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @since 0.71 |
| 275 | 275 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 276 | 276 | * |
| 277 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. |
|
| 277 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. |
|
| 278 | 278 | * Default current comment. |
| 279 | 279 | */ |
| 280 | 280 | function comment_author_IP( $comment_ID = 0 ) { |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @since 1.5.0 |
| 288 | 288 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 289 | 289 | * |
| 290 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. |
|
| 290 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. |
|
| 291 | 291 | * Default current comment. |
| 292 | 292 | * @return string Comment author URL. |
| 293 | 293 | */ |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @since 0.71 |
| 316 | 316 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 317 | 317 | * |
| 318 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. |
|
| 318 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. |
|
| 319 | 319 | * Default current comment. |
| 320 | 320 | */ |
| 321 | 321 | function comment_author_url( $comment_ID = 0 ) { |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 514 | 514 | * |
| 515 | 515 | * @param string $d Optional. The format of the date. Default user's setting. |
| 516 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date. |
|
| 516 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to get the date. |
|
| 517 | 517 | * Default current comment. |
| 518 | 518 | * @return string The comment's date. |
| 519 | 519 | */ |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 543 | 543 | * |
| 544 | 544 | * @param string $d Optional. The format of the date. Default user's settings. |
| 545 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date. |
|
| 545 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to print the date. |
|
| 546 | 546 | * Default current comment. |
| 547 | 547 | */ |
| 548 | 548 | function comment_date( $d = '', $comment_ID = 0 ) { |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | * @since 1.5.0 |
| 560 | 560 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 561 | 561 | * |
| 562 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. |
|
| 562 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to get the excerpt. |
|
| 563 | 563 | * Default current comment. |
| 564 | 564 | * @return string The maybe truncated comment with 20 words or less. |
| 565 | 565 | */ |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | * @since 1.2.0 |
| 606 | 606 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 607 | 607 | * |
| 608 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the excerpt. |
|
| 608 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to print the excerpt. |
|
| 609 | 609 | * Default current comment. |
| 610 | 610 | */ |
| 611 | 611 | function comment_excerpt( $comment_ID = 0 ) { |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | * |
| 776 | 776 | * @since 1.5.0 |
| 777 | 777 | * |
| 778 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 778 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 779 | 779 | * @return string The link to the comments. |
| 780 | 780 | */ |
| 781 | 781 | function get_comments_link( $post_id = 0 ) { |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | * |
| 815 | 815 | * @since 1.5.0 |
| 816 | 816 | * |
| 817 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 817 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 818 | 818 | * @return int The number of comments a post has. |
| 819 | 819 | */ |
| 820 | 820 | function get_comments_number( $post_id = 0 ) { |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | * |
| 903 | 903 | * @see Walker_Comment::comment() |
| 904 | 904 | * |
| 905 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the text. |
|
| 905 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to get the text. |
|
| 906 | 906 | * Default current comment. |
| 907 | 907 | * @param array $args Optional. An array of arguments. Default empty. |
| 908 | 908 | * @return string The comment content. |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | * |
| 933 | 933 | * @see Walker_Comment::comment() |
| 934 | 934 | * |
| 935 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the text. |
|
| 935 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to print the text. |
|
| 936 | 936 | * Default current comment. |
| 937 | 937 | * @param array $args Optional. An array of arguments. Default empty array. Default empty. |
| 938 | 938 | */ |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | * @since 1.5.0 |
| 1006 | 1006 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
| 1007 | 1007 | * |
| 1008 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type. |
|
| 1008 | + * @param integer $comment_ID Optional. WP_Comment or ID of the comment for which to get the type. |
|
| 1009 | 1009 | * Default current comment. |
| 1010 | 1010 | * @return string The comment type. |
| 1011 | 1011 | */ |
@@ -2126,11 +2126,11 @@ discard block |
||
| 2126 | 2126 | $html5 = 'html5' === $args['format']; |
| 2127 | 2127 | $fields = array( |
| 2128 | 2128 | 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
| 2129 | - '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', |
|
| 2129 | + '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', |
|
| 2130 | 2130 | 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
| 2131 | - '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
| 2131 | + '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
| 2132 | 2132 | 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
| 2133 | - '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
|
| 2133 | + '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
|
| 2134 | 2134 | ); |
| 2135 | 2135 | |
| 2136 | 2136 | $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
@@ -2148,20 +2148,20 @@ discard block |
||
| 2148 | 2148 | 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', |
| 2149 | 2149 | /** This filter is documented in wp-includes/link-template.php */ |
| 2150 | 2150 | 'must_log_in' => '<p class="must-log-in">' . sprintf( |
| 2151 | - /* translators: %s: login URL */ |
|
| 2152 | - __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
|
| 2153 | - wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
| 2154 | - ) . '</p>', |
|
| 2151 | + /* translators: %s: login URL */ |
|
| 2152 | + __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
|
| 2153 | + wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
| 2154 | + ) . '</p>', |
|
| 2155 | 2155 | /** This filter is documented in wp-includes/link-template.php */ |
| 2156 | 2156 | 'logged_in_as' => '<p class="logged-in-as">' . sprintf( |
| 2157 | - /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
|
| 2158 | - __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
|
| 2159 | - get_edit_user_link(), |
|
| 2160 | - /* translators: %s: user name */ |
|
| 2161 | - esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
|
| 2162 | - $user_identity, |
|
| 2163 | - wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
| 2164 | - ) . '</p>', |
|
| 2157 | + /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
|
| 2158 | + __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
|
| 2159 | + get_edit_user_link(), |
|
| 2160 | + /* translators: %s: user name */ |
|
| 2161 | + esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
|
| 2162 | + $user_identity, |
|
| 2163 | + wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
| 2164 | + ) . '</p>', |
|
| 2165 | 2165 | 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>', |
| 2166 | 2166 | 'comment_notes_after' => '', |
| 2167 | 2167 | 'id_form' => 'commentform', |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | * Default current comment. |
| 22 | 22 | * @return string The comment author |
| 23 | 23 | */ |
| 24 | -function get_comment_author( $comment_ID = 0 ) { |
|
| 25 | - $comment = get_comment( $comment_ID ); |
|
| 24 | +function get_comment_author($comment_ID = 0) { |
|
| 25 | + $comment = get_comment($comment_ID); |
|
| 26 | 26 | |
| 27 | - if ( empty( $comment->comment_author ) ) { |
|
| 28 | - if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) |
|
| 27 | + if (empty($comment->comment_author)) { |
|
| 28 | + if ($comment->user_id && $user = get_userdata($comment->user_id)) |
|
| 29 | 29 | $author = $user->display_name; |
| 30 | 30 | else |
| 31 | 31 | $author = __('Anonymous'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param int $comment_ID The comment ID. |
| 44 | 44 | * @param WP_Comment $comment The comment object. |
| 45 | 45 | */ |
| 46 | - return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment ); |
|
| 46 | + return apply_filters('get_comment_author', $author, $comment->comment_ID, $comment); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. |
| 56 | 56 | * Default current comment. |
| 57 | 57 | */ |
| 58 | -function comment_author( $comment_ID = 0 ) { |
|
| 59 | - $comment = get_comment( $comment_ID ); |
|
| 60 | - $author = get_comment_author( $comment ); |
|
| 58 | +function comment_author($comment_ID = 0) { |
|
| 59 | + $comment = get_comment($comment_ID); |
|
| 60 | + $author = get_comment_author($comment); |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Filter the comment author's name for display. |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $author The comment author's username. |
| 69 | 69 | * @param int $comment_ID The comment ID. |
| 70 | 70 | */ |
| 71 | - echo apply_filters( 'comment_author', $author, $comment->comment_ID ); |
|
| 71 | + echo apply_filters('comment_author', $author, $comment->comment_ID); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | * Default current comment. |
| 82 | 82 | * @return string The current comment author's email |
| 83 | 83 | */ |
| 84 | -function get_comment_author_email( $comment_ID = 0 ) { |
|
| 85 | - $comment = get_comment( $comment_ID ); |
|
| 84 | +function get_comment_author_email($comment_ID = 0) { |
|
| 85 | + $comment = get_comment($comment_ID); |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Filter the comment author's returned email address. |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @param int $comment_ID The comment ID. |
| 95 | 95 | * @param WP_Comment $comment The comment object. |
| 96 | 96 | */ |
| 97 | - return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment ); |
|
| 97 | + return apply_filters('get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. |
| 113 | 113 | * Default current comment. |
| 114 | 114 | */ |
| 115 | -function comment_author_email( $comment_ID = 0 ) { |
|
| 116 | - $comment = get_comment( $comment_ID ); |
|
| 117 | - $author_email = get_comment_author_email( $comment ); |
|
| 115 | +function comment_author_email($comment_ID = 0) { |
|
| 116 | + $comment = get_comment($comment_ID); |
|
| 117 | + $author_email = get_comment_author_email($comment); |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Filter the comment author's email for display. |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @param string $author_email The comment author's email address. |
| 126 | 126 | * @param int $comment_ID The comment ID. |
| 127 | 127 | */ |
| 128 | - echo apply_filters( 'author_email', $author_email, $comment->comment_ID ); |
|
| 128 | + echo apply_filters('author_email', $author_email, $comment->comment_ID); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * @param string $before Optional. Text or HTML to display before the email link. Default empty. |
| 145 | 145 | * @param string $after Optional. Text or HTML to display after the email link. Default empty. |
| 146 | 146 | */ |
| 147 | -function comment_author_email_link( $linktext = '', $before = '', $after = '' ) { |
|
| 148 | - if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) |
|
| 147 | +function comment_author_email_link($linktext = '', $before = '', $after = '') { |
|
| 148 | + if ($link = get_comment_author_email_link($linktext, $before, $after)) |
|
| 149 | 149 | echo $link; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param string $after Optional. Text or HTML to display after the email link. Default empty. |
| 167 | 167 | * @return string |
| 168 | 168 | */ |
| 169 | -function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) { |
|
| 169 | +function get_comment_author_email_link($linktext = '', $before = '', $after = '') { |
|
| 170 | 170 | $comment = get_comment(); |
| 171 | 171 | /** |
| 172 | 172 | * Filter the comment author's email for display. |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | * @param string $comment_author_email The comment author's email address. |
| 181 | 181 | * @param WP_Comment $comment The comment object. |
| 182 | 182 | */ |
| 183 | - $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); |
|
| 184 | - if ((!empty($email)) && ($email != '@')) { |
|
| 183 | + $email = apply_filters('comment_email', $comment->comment_author_email, $comment); |
|
| 184 | + if (( ! empty($email)) && ($email != '@')) { |
|
| 185 | 185 | $display = ($linktext != '') ? $linktext : $email; |
| 186 | 186 | $return = $before; |
| 187 | - $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) ); |
|
| 187 | + $return .= sprintf('<a href="%1$s">%2$s</a>', esc_url('mailto:'.$email), esc_html($display)); |
|
| 188 | 188 | $return .= $after; |
| 189 | 189 | return $return; |
| 190 | 190 | } else { |
@@ -205,12 +205,12 @@ discard block |
||
| 205 | 205 | * Default current comment. |
| 206 | 206 | * @return string The comment author name or HTML link for author's URL. |
| 207 | 207 | */ |
| 208 | -function get_comment_author_link( $comment_ID = 0 ) { |
|
| 209 | - $comment = get_comment( $comment_ID ); |
|
| 210 | - $url = get_comment_author_url( $comment ); |
|
| 211 | - $author = get_comment_author( $comment ); |
|
| 208 | +function get_comment_author_link($comment_ID = 0) { |
|
| 209 | + $comment = get_comment($comment_ID); |
|
| 210 | + $url = get_comment_author_url($comment); |
|
| 211 | + $author = get_comment_author($comment); |
|
| 212 | 212 | |
| 213 | - if ( empty( $url ) || 'http://' == $url ) |
|
| 213 | + if (empty($url) || 'http://' == $url) |
|
| 214 | 214 | $return = $author; |
| 215 | 215 | else |
| 216 | 216 | $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * @param string $author The comment author's username. |
| 227 | 227 | * @param int $comment_ID The comment ID. |
| 228 | 228 | */ |
| 229 | - return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID ); |
|
| 229 | + return apply_filters('get_comment_author_link', $return, $author, $comment->comment_ID); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. |
| 239 | 239 | * Default current comment. |
| 240 | 240 | */ |
| 241 | -function comment_author_link( $comment_ID = 0 ) { |
|
| 242 | - echo get_comment_author_link( $comment_ID ); |
|
| 241 | +function comment_author_link($comment_ID = 0) { |
|
| 242 | + echo get_comment_author_link($comment_ID); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | * Default current comment. |
| 253 | 253 | * @return string Comment author's IP address. |
| 254 | 254 | */ |
| 255 | -function get_comment_author_IP( $comment_ID = 0 ) { |
|
| 256 | - $comment = get_comment( $comment_ID ); |
|
| 255 | +function get_comment_author_IP($comment_ID = 0) { |
|
| 256 | + $comment = get_comment($comment_ID); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * Filter the comment author's returned IP address. |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @param int $comment_ID The comment ID. |
| 266 | 266 | * @param WP_Comment $comment The comment object. |
| 267 | 267 | */ |
| 268 | - return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment ); |
|
| 268 | + return apply_filters('get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -277,8 +277,8 @@ discard block |
||
| 277 | 277 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. |
| 278 | 278 | * Default current comment. |
| 279 | 279 | */ |
| 280 | -function comment_author_IP( $comment_ID = 0 ) { |
|
| 281 | - echo esc_html( get_comment_author_IP( $comment_ID ) ); |
|
| 280 | +function comment_author_IP($comment_ID = 0) { |
|
| 281 | + echo esc_html(get_comment_author_IP($comment_ID)); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -291,10 +291,10 @@ discard block |
||
| 291 | 291 | * Default current comment. |
| 292 | 292 | * @return string Comment author URL. |
| 293 | 293 | */ |
| 294 | -function get_comment_author_url( $comment_ID = 0 ) { |
|
| 295 | - $comment = get_comment( $comment_ID ); |
|
| 294 | +function get_comment_author_url($comment_ID = 0) { |
|
| 295 | + $comment = get_comment($comment_ID); |
|
| 296 | 296 | $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; |
| 297 | - $url = esc_url( $url, array('http', 'https') ); |
|
| 297 | + $url = esc_url($url, array('http', 'https')); |
|
| 298 | 298 | |
| 299 | 299 | /** |
| 300 | 300 | * Filter the comment author's URL. |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param int $comment_ID The comment ID. |
| 307 | 307 | * @param WP_Comment $comment The comment object. |
| 308 | 308 | */ |
| 309 | - return apply_filters( 'get_comment_author_url', $url, $comment->comment_ID, $comment ); |
|
| 309 | + return apply_filters('get_comment_author_url', $url, $comment->comment_ID, $comment); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. |
| 319 | 319 | * Default current comment. |
| 320 | 320 | */ |
| 321 | -function comment_author_url( $comment_ID = 0 ) { |
|
| 322 | - $comment = get_comment( $comment_ID ); |
|
| 323 | - $author_url = get_comment_author_url( $comment ); |
|
| 321 | +function comment_author_url($comment_ID = 0) { |
|
| 322 | + $comment = get_comment($comment_ID); |
|
| 323 | + $author_url = get_comment_author_url($comment); |
|
| 324 | 324 | |
| 325 | 325 | /** |
| 326 | 326 | * Filter the comment author's URL for display. |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @param string $author_url The comment author's URL. |
| 332 | 332 | * @param int $comment_ID The comment ID. |
| 333 | 333 | */ |
| 334 | - echo apply_filters( 'comment_url', $author_url, $comment->comment_ID ); |
|
| 334 | + echo apply_filters('comment_url', $author_url, $comment->comment_ID); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -354,13 +354,13 @@ discard block |
||
| 354 | 354 | * Default empty. |
| 355 | 355 | * @return string The HTML link between the $before and $after parameters. |
| 356 | 356 | */ |
| 357 | -function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|
| 357 | +function get_comment_author_url_link($linktext = '', $before = '', $after = '') { |
|
| 358 | 358 | $url = get_comment_author_url(); |
| 359 | 359 | $display = ($linktext != '') ? $linktext : $url; |
| 360 | - $display = str_replace( 'http://www.', '', $display ); |
|
| 361 | - $display = str_replace( 'http://', '', $display ); |
|
| 360 | + $display = str_replace('http://www.', '', $display); |
|
| 361 | + $display = str_replace('http://', '', $display); |
|
| 362 | 362 | |
| 363 | - if ( '/' == substr($display, -1) ) { |
|
| 363 | + if ('/' == substr($display, -1)) { |
|
| 364 | 364 | $display = substr($display, 0, -1); |
| 365 | 365 | } |
| 366 | 366 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | * |
| 374 | 374 | * @param string $return The HTML-formatted comment author URL link. |
| 375 | 375 | */ |
| 376 | - return apply_filters( 'get_comment_author_url_link', $return ); |
|
| 376 | + return apply_filters('get_comment_author_url_link', $return); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
@@ -388,8 +388,8 @@ discard block |
||
| 388 | 388 | * @param string $after Optional. Text or HTML to display after the email link. |
| 389 | 389 | * Default empty. |
| 390 | 390 | */ |
| 391 | -function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|
| 392 | - echo get_comment_author_url_link( $linktext, $before, $after ); |
|
| 391 | +function comment_author_url_link($linktext = '', $before = '', $after = '') { |
|
| 392 | + echo get_comment_author_url_link($linktext, $before, $after); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -406,10 +406,10 @@ discard block |
||
| 406 | 406 | * Default true. |
| 407 | 407 | * @return string If `$echo` is false, the class will be returned. Void otherwise. |
| 408 | 408 | */ |
| 409 | -function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
|
| 409 | +function comment_class($class = '', $comment = null, $post_id = null, $echo = true) { |
|
| 410 | 410 | // Separates classes with a single space, collates classes for comment DIV |
| 411 | - $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
|
| 412 | - if ( $echo) |
|
| 411 | + $class = 'class="'.join(' ', get_comment_class($class, $comment, $post_id)).'"'; |
|
| 412 | + if ($echo) |
|
| 413 | 413 | echo $class; |
| 414 | 414 | else |
| 415 | 415 | return $class; |
@@ -430,39 +430,39 @@ discard block |
||
| 430 | 430 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
| 431 | 431 | * @return array An array of classes. |
| 432 | 432 | */ |
| 433 | -function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { |
|
| 433 | +function get_comment_class($class = '', $comment_id = null, $post_id = null) { |
|
| 434 | 434 | global $comment_alt, $comment_depth, $comment_thread_alt; |
| 435 | 435 | |
| 436 | 436 | $classes = array(); |
| 437 | 437 | |
| 438 | - $comment = get_comment( $comment_id ); |
|
| 439 | - if ( ! $comment ) { |
|
| 438 | + $comment = get_comment($comment_id); |
|
| 439 | + if ( ! $comment) { |
|
| 440 | 440 | return $classes; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | // Get the comment type (comment, trackback), |
| 444 | - $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; |
|
| 444 | + $classes[] = (empty($comment->comment_type)) ? 'comment' : $comment->comment_type; |
|
| 445 | 445 | |
| 446 | 446 | // Add classes for comment authors that are registered users. |
| 447 | - if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { |
|
| 447 | + if ($comment->user_id > 0 && $user = get_userdata($comment->user_id)) { |
|
| 448 | 448 | $classes[] = 'byuser'; |
| 449 | - $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); |
|
| 449 | + $classes[] = 'comment-author-'.sanitize_html_class($user->user_nicename, $comment->user_id); |
|
| 450 | 450 | // For comment authors who are the author of the post |
| 451 | - if ( $post = get_post($post_id) ) { |
|
| 452 | - if ( $comment->user_id === $post->post_author ) { |
|
| 451 | + if ($post = get_post($post_id)) { |
|
| 452 | + if ($comment->user_id === $post->post_author) { |
|
| 453 | 453 | $classes[] = 'bypostauthor'; |
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if ( empty($comment_alt) ) |
|
| 458 | + if (empty($comment_alt)) |
|
| 459 | 459 | $comment_alt = 0; |
| 460 | - if ( empty($comment_depth) ) |
|
| 460 | + if (empty($comment_depth)) |
|
| 461 | 461 | $comment_depth = 1; |
| 462 | - if ( empty($comment_thread_alt) ) |
|
| 462 | + if (empty($comment_thread_alt)) |
|
| 463 | 463 | $comment_thread_alt = 0; |
| 464 | 464 | |
| 465 | - if ( $comment_alt % 2 ) { |
|
| 465 | + if ($comment_alt % 2) { |
|
| 466 | 466 | $classes[] = 'odd'; |
| 467 | 467 | $classes[] = 'alt'; |
| 468 | 468 | } else { |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | $comment_alt++; |
| 473 | 473 | |
| 474 | 474 | // Alt for top-level comments |
| 475 | - if ( 1 == $comment_depth ) { |
|
| 476 | - if ( $comment_thread_alt % 2 ) { |
|
| 475 | + if (1 == $comment_depth) { |
|
| 476 | + if ($comment_thread_alt % 2) { |
|
| 477 | 477 | $classes[] = 'thread-odd'; |
| 478 | 478 | $classes[] = 'thread-alt'; |
| 479 | 479 | } else { |
@@ -484,8 +484,8 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | $classes[] = "depth-$comment_depth"; |
| 486 | 486 | |
| 487 | - if ( !empty($class) ) { |
|
| 488 | - if ( !is_array( $class ) ) |
|
| 487 | + if ( ! empty($class)) { |
|
| 488 | + if ( ! is_array($class)) |
|
| 489 | 489 | $class = preg_split('#\s+#', $class); |
| 490 | 490 | $classes = array_merge($classes, $class); |
| 491 | 491 | } |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | * @param WP_Comment $comment The comment object. |
| 504 | 504 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
| 505 | 505 | */ |
| 506 | - return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id ); |
|
| 506 | + return apply_filters('comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -517,9 +517,9 @@ discard block |
||
| 517 | 517 | * Default current comment. |
| 518 | 518 | * @return string The comment's date. |
| 519 | 519 | */ |
| 520 | -function get_comment_date( $d = '', $comment_ID = 0 ) { |
|
| 521 | - $comment = get_comment( $comment_ID ); |
|
| 522 | - if ( '' == $d ) |
|
| 520 | +function get_comment_date($d = '', $comment_ID = 0) { |
|
| 521 | + $comment = get_comment($comment_ID); |
|
| 522 | + if ('' == $d) |
|
| 523 | 523 | $date = mysql2date(get_option('date_format'), $comment->comment_date); |
| 524 | 524 | else |
| 525 | 525 | $date = mysql2date($d, $comment->comment_date); |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | * @param string $d The format of the date. |
| 533 | 533 | * @param WP_Comment $comment The comment object. |
| 534 | 534 | */ |
| 535 | - return apply_filters( 'get_comment_date', $date, $d, $comment ); |
|
| 535 | + return apply_filters('get_comment_date', $date, $d, $comment); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -545,8 +545,8 @@ discard block |
||
| 545 | 545 | * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date. |
| 546 | 546 | * Default current comment. |
| 547 | 547 | */ |
| 548 | -function comment_date( $d = '', $comment_ID = 0 ) { |
|
| 549 | - echo get_comment_date( $d, $comment_ID ); |
|
| 548 | +function comment_date($d = '', $comment_ID = 0) { |
|
| 549 | + echo get_comment_date($d, $comment_ID); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -563,10 +563,10 @@ discard block |
||
| 563 | 563 | * Default current comment. |
| 564 | 564 | * @return string The maybe truncated comment with 20 words or less. |
| 565 | 565 | */ |
| 566 | -function get_comment_excerpt( $comment_ID = 0 ) { |
|
| 567 | - $comment = get_comment( $comment_ID ); |
|
| 568 | - $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); |
|
| 569 | - $words = explode( ' ', $comment_text ); |
|
| 566 | +function get_comment_excerpt($comment_ID = 0) { |
|
| 567 | + $comment = get_comment($comment_ID); |
|
| 568 | + $comment_text = strip_tags(str_replace(array("\n", "\r"), ' ', $comment->comment_content)); |
|
| 569 | + $words = explode(' ', $comment_text); |
|
| 570 | 570 | |
| 571 | 571 | /** |
| 572 | 572 | * Filter the amount of words used in the comment excerpt. |
@@ -575,15 +575,15 @@ discard block |
||
| 575 | 575 | * |
| 576 | 576 | * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt. |
| 577 | 577 | */ |
| 578 | - $comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 ); |
|
| 578 | + $comment_excerpt_length = apply_filters('comment_excerpt_length', 20); |
|
| 579 | 579 | |
| 580 | - $use_ellipsis = count( $words ) > $comment_excerpt_length; |
|
| 581 | - if ( $use_ellipsis ) { |
|
| 582 | - $words = array_slice( $words, 0, $comment_excerpt_length ); |
|
| 580 | + $use_ellipsis = count($words) > $comment_excerpt_length; |
|
| 581 | + if ($use_ellipsis) { |
|
| 582 | + $words = array_slice($words, 0, $comment_excerpt_length); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - $excerpt = trim( join( ' ', $words ) ); |
|
| 586 | - if ( $use_ellipsis ) { |
|
| 585 | + $excerpt = trim(join(' ', $words)); |
|
| 586 | + if ($use_ellipsis) { |
|
| 587 | 587 | $excerpt .= '…'; |
| 588 | 588 | } |
| 589 | 589 | /** |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * @param int $comment_ID The comment ID. |
| 597 | 597 | * @param WP_Comment $comment The comment object. |
| 598 | 598 | */ |
| 599 | - return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment ); |
|
| 599 | + return apply_filters('get_comment_excerpt', $excerpt, $comment->comment_ID, $comment); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -608,9 +608,9 @@ discard block |
||
| 608 | 608 | * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the excerpt. |
| 609 | 609 | * Default current comment. |
| 610 | 610 | */ |
| 611 | -function comment_excerpt( $comment_ID = 0 ) { |
|
| 612 | - $comment = get_comment( $comment_ID ); |
|
| 613 | - $comment_excerpt = get_comment_excerpt( $comment ); |
|
| 611 | +function comment_excerpt($comment_ID = 0) { |
|
| 612 | + $comment = get_comment($comment_ID); |
|
| 613 | + $comment_excerpt = get_comment_excerpt($comment); |
|
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | 616 | * Filter the comment excerpt for display. |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @param string $comment_excerpt The comment excerpt text. |
| 622 | 622 | * @param int $comment_ID The comment ID. |
| 623 | 623 | */ |
| 624 | - echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID ); |
|
| 624 | + echo apply_filters('comment_excerpt', $comment_excerpt, $comment->comment_ID); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | /** |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | * @param int $comment_ID The current comment ID. |
| 644 | 644 | * @param WP_Comment $comment The comment object. |
| 645 | 645 | */ |
| 646 | - return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment ); |
|
| 646 | + return apply_filters('get_comment_ID', $comment->comment_ID, $comment); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /** |
@@ -679,14 +679,14 @@ discard block |
||
| 679 | 679 | * } |
| 680 | 680 | * @return string The permalink to the given comment. |
| 681 | 681 | */ |
| 682 | -function get_comment_link( $comment = null, $args = array() ) { |
|
| 682 | +function get_comment_link($comment = null, $args = array()) { |
|
| 683 | 683 | global $wp_rewrite, $in_comment_loop; |
| 684 | 684 | |
| 685 | 685 | $comment = get_comment($comment); |
| 686 | 686 | |
| 687 | 687 | // Backwards compat |
| 688 | - if ( ! is_array( $args ) ) { |
|
| 689 | - $args = array( 'page' => $args ); |
|
| 688 | + if ( ! is_array($args)) { |
|
| 689 | + $args = array('page' => $args); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | $defaults = array( |
@@ -696,33 +696,33 @@ discard block |
||
| 696 | 696 | 'max_depth' => '', |
| 697 | 697 | 'cpage' => null, |
| 698 | 698 | ); |
| 699 | - $args = wp_parse_args( $args, $defaults ); |
|
| 699 | + $args = wp_parse_args($args, $defaults); |
|
| 700 | 700 | |
| 701 | - $link = get_permalink( $comment->comment_post_ID ); |
|
| 701 | + $link = get_permalink($comment->comment_post_ID); |
|
| 702 | 702 | |
| 703 | 703 | // The 'cpage' param takes precedence. |
| 704 | - if ( ! is_null( $args['cpage'] ) ) { |
|
| 704 | + if ( ! is_null($args['cpage'])) { |
|
| 705 | 705 | $cpage = $args['cpage']; |
| 706 | 706 | |
| 707 | 707 | // No 'cpage' is provided, so we calculate one. |
| 708 | 708 | } else { |
| 709 | - if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) { |
|
| 709 | + if ('' === $args['per_page'] && get_option('page_comments')) { |
|
| 710 | 710 | $args['per_page'] = get_option('comments_per_page'); |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - if ( empty( $args['per_page'] ) ) { |
|
| 713 | + if (empty($args['per_page'])) { |
|
| 714 | 714 | $args['per_page'] = 0; |
| 715 | 715 | $args['page'] = 0; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | $cpage = $args['page']; |
| 719 | 719 | |
| 720 | - if ( '' == $cpage ) { |
|
| 721 | - if ( ! empty( $in_comment_loop ) ) { |
|
| 722 | - $cpage = get_query_var( 'cpage' ); |
|
| 720 | + if ('' == $cpage) { |
|
| 721 | + if ( ! empty($in_comment_loop)) { |
|
| 722 | + $cpage = get_query_var('cpage'); |
|
| 723 | 723 | } else { |
| 724 | 724 | // Requires a database hit, so we only do it when we can't figure out from context. |
| 725 | - $cpage = get_page_of_comment( $comment->comment_ID, $args ); |
|
| 725 | + $cpage = get_page_of_comment($comment->comment_ID, $args); |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | |
@@ -730,29 +730,29 @@ discard block |
||
| 730 | 730 | * If the default page displays the oldest comments, the permalinks for comments on the default page |
| 731 | 731 | * do not need a 'cpage' query var. |
| 732 | 732 | */ |
| 733 | - if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) { |
|
| 733 | + if ('oldest' === get_option('default_comments_page') && 1 === $cpage) { |
|
| 734 | 734 | $cpage = ''; |
| 735 | 735 | } |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - if ( $cpage && get_option( 'page_comments' ) ) { |
|
| 739 | - if ( $wp_rewrite->using_permalinks() ) { |
|
| 740 | - if ( $cpage ) { |
|
| 741 | - $link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage; |
|
| 738 | + if ($cpage && get_option('page_comments')) { |
|
| 739 | + if ($wp_rewrite->using_permalinks()) { |
|
| 740 | + if ($cpage) { |
|
| 741 | + $link = trailingslashit($link).$wp_rewrite->comments_pagination_base.'-'.$cpage; |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - $link = user_trailingslashit( $link, 'comment' ); |
|
| 745 | - } elseif ( $cpage ) { |
|
| 746 | - $link = add_query_arg( 'cpage', $cpage, $link ); |
|
| 744 | + $link = user_trailingslashit($link, 'comment'); |
|
| 745 | + } elseif ($cpage) { |
|
| 746 | + $link = add_query_arg('cpage', $cpage, $link); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - if ( $wp_rewrite->using_permalinks() ) { |
|
| 752 | - $link = user_trailingslashit( $link, 'comment' ); |
|
| 751 | + if ($wp_rewrite->using_permalinks()) { |
|
| 752 | + $link = user_trailingslashit($link, 'comment'); |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - $link = $link . '#comment-' . $comment->comment_ID; |
|
| 755 | + $link = $link.'#comment-'.$comment->comment_ID; |
|
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | 758 | * Filter the returned single comment permalink. |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | * @param array $args An array of arguments to override the defaults. |
| 768 | 768 | * @param int $cpage The calculated 'cpage' value. |
| 769 | 769 | */ |
| 770 | - return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage ); |
|
| 770 | + return apply_filters('get_comment_link', $link, $comment, $args, $cpage); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
@@ -778,9 +778,9 @@ discard block |
||
| 778 | 778 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
| 779 | 779 | * @return string The link to the comments. |
| 780 | 780 | */ |
| 781 | -function get_comments_link( $post_id = 0 ) { |
|
| 782 | - $hash = get_comments_number( $post_id ) ? '#comments' : '#respond'; |
|
| 783 | - $comments_link = get_permalink( $post_id ) . $hash; |
|
| 781 | +function get_comments_link($post_id = 0) { |
|
| 782 | + $hash = get_comments_number($post_id) ? '#comments' : '#respond'; |
|
| 783 | + $comments_link = get_permalink($post_id).$hash; |
|
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | 786 | * Filter the returned post comments permalink. |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @param string $comments_link Post comments permalink with '#comments' appended. |
| 791 | 791 | * @param int|WP_Post $post_id Post ID or WP_Post object. |
| 792 | 792 | */ |
| 793 | - return apply_filters( 'get_comments_link', $comments_link, $post_id ); |
|
| 793 | + return apply_filters('get_comments_link', $comments_link, $post_id); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /** |
@@ -801,12 +801,12 @@ discard block |
||
| 801 | 801 | * @param string $deprecated Not Used. |
| 802 | 802 | * @param string $deprecated_2 Not Used. |
| 803 | 803 | */ |
| 804 | -function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
|
| 805 | - if ( !empty( $deprecated ) ) |
|
| 806 | - _deprecated_argument( __FUNCTION__, '0.72' ); |
|
| 807 | - if ( !empty( $deprecated_2 ) ) |
|
| 808 | - _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 809 | - echo esc_url( get_comments_link() ); |
|
| 804 | +function comments_link($deprecated = '', $deprecated_2 = '') { |
|
| 805 | + if ( ! empty($deprecated)) |
|
| 806 | + _deprecated_argument(__FUNCTION__, '0.72'); |
|
| 807 | + if ( ! empty($deprecated_2)) |
|
| 808 | + _deprecated_argument(__FUNCTION__, '1.3'); |
|
| 809 | + echo esc_url(get_comments_link()); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | /** |
@@ -817,10 +817,10 @@ discard block |
||
| 817 | 817 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
| 818 | 818 | * @return int The number of comments a post has. |
| 819 | 819 | */ |
| 820 | -function get_comments_number( $post_id = 0 ) { |
|
| 821 | - $post = get_post( $post_id ); |
|
| 820 | +function get_comments_number($post_id = 0) { |
|
| 821 | + $post = get_post($post_id); |
|
| 822 | 822 | |
| 823 | - if ( ! $post ) { |
|
| 823 | + if ( ! $post) { |
|
| 824 | 824 | $count = 0; |
| 825 | 825 | } else { |
| 826 | 826 | $count = $post->comment_count; |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | * @param int $count Number of comments a post has. |
| 836 | 836 | * @param int $post_id Post ID. |
| 837 | 837 | */ |
| 838 | - return apply_filters( 'get_comments_number', $count, $post_id ); |
|
| 838 | + return apply_filters('get_comments_number', $count, $post_id); |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | /** |
@@ -848,11 +848,11 @@ discard block |
||
| 848 | 848 | * @param string $more Optional. Text for more than one comment. Default false. |
| 849 | 849 | * @param string $deprecated Not used. |
| 850 | 850 | */ |
| 851 | -function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { |
|
| 852 | - if ( ! empty( $deprecated ) ) { |
|
| 853 | - _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 851 | +function comments_number($zero = false, $one = false, $more = false, $deprecated = '') { |
|
| 852 | + if ( ! empty($deprecated)) { |
|
| 853 | + _deprecated_argument(__FUNCTION__, '1.3'); |
|
| 854 | 854 | } |
| 855 | - echo get_comments_number_text( $zero, $one, $more ); |
|
| 855 | + echo get_comments_number_text($zero, $one, $more); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -864,21 +864,21 @@ discard block |
||
| 864 | 864 | * @param string $one Optional. Text for one comment. Default false. |
| 865 | 865 | * @param string $more Optional. Text for more than one comment. Default false. |
| 866 | 866 | */ |
| 867 | -function get_comments_number_text( $zero = false, $one = false, $more = false ) { |
|
| 867 | +function get_comments_number_text($zero = false, $one = false, $more = false) { |
|
| 868 | 868 | $number = get_comments_number(); |
| 869 | 869 | |
| 870 | - if ( $number > 1 ) { |
|
| 871 | - if ( false === $more ) { |
|
| 870 | + if ($number > 1) { |
|
| 871 | + if (false === $more) { |
|
| 872 | 872 | /* translators: %s: number of comments */ |
| 873 | - $output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) ); |
|
| 873 | + $output = sprintf(_n('%s Comment', '%s Comments', $number), number_format_i18n($number)); |
|
| 874 | 874 | } else { |
| 875 | 875 | // % Comments |
| 876 | - $output = str_replace( '%', number_format_i18n( $number ), $more ); |
|
| 876 | + $output = str_replace('%', number_format_i18n($number), $more); |
|
| 877 | 877 | } |
| 878 | - } elseif ( $number == 0 ) { |
|
| 879 | - $output = ( false === $zero ) ? __( 'No Comments' ) : $zero; |
|
| 878 | + } elseif ($number == 0) { |
|
| 879 | + $output = (false === $zero) ? __('No Comments') : $zero; |
|
| 880 | 880 | } else { // must be one |
| 881 | - $output = ( false === $one ) ? __( '1 Comment' ) : $one; |
|
| 881 | + $output = (false === $one) ? __('1 Comment') : $one; |
|
| 882 | 882 | } |
| 883 | 883 | /** |
| 884 | 884 | * Filter the comments count for display. |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | * is equal to 0, 1, or 1+. |
| 892 | 892 | * @param int $number The number of post comments. |
| 893 | 893 | */ |
| 894 | - return apply_filters( 'comments_number', $output, $number ); |
|
| 894 | + return apply_filters('comments_number', $output, $number); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | /** |
@@ -907,8 +907,8 @@ discard block |
||
| 907 | 907 | * @param array $args Optional. An array of arguments. Default empty. |
| 908 | 908 | * @return string The comment content. |
| 909 | 909 | */ |
| 910 | -function get_comment_text( $comment_ID = 0, $args = array() ) { |
|
| 911 | - $comment = get_comment( $comment_ID ); |
|
| 910 | +function get_comment_text($comment_ID = 0, $args = array()) { |
|
| 911 | + $comment = get_comment($comment_ID); |
|
| 912 | 912 | |
| 913 | 913 | /** |
| 914 | 914 | * Filter the text of a comment. |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @param WP_Comment $comment The comment object. |
| 922 | 922 | * @param array $args An array of arguments. |
| 923 | 923 | */ |
| 924 | - return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args ); |
|
| 924 | + return apply_filters('get_comment_text', $comment->comment_content, $comment, $args); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
@@ -936,10 +936,10 @@ discard block |
||
| 936 | 936 | * Default current comment. |
| 937 | 937 | * @param array $args Optional. An array of arguments. Default empty array. Default empty. |
| 938 | 938 | */ |
| 939 | -function comment_text( $comment_ID = 0, $args = array() ) { |
|
| 940 | - $comment = get_comment( $comment_ID ); |
|
| 939 | +function comment_text($comment_ID = 0, $args = array()) { |
|
| 940 | + $comment = get_comment($comment_ID); |
|
| 941 | 941 | |
| 942 | - $comment_text = get_comment_text( $comment, $args ); |
|
| 942 | + $comment_text = get_comment_text($comment, $args); |
|
| 943 | 943 | /** |
| 944 | 944 | * Filter the text of a comment to be displayed. |
| 945 | 945 | * |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | * @param WP_Comment $comment The comment object. |
| 952 | 952 | * @param array $args An array of arguments. |
| 953 | 953 | */ |
| 954 | - echo apply_filters( 'comment_text', $comment_text, $comment, $args ); |
|
| 954 | + echo apply_filters('comment_text', $comment_text, $comment, $args); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | /** |
@@ -965,11 +965,11 @@ discard block |
||
| 965 | 965 | * Default true. |
| 966 | 966 | * @return string The formatted time. |
| 967 | 967 | */ |
| 968 | -function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
|
| 968 | +function get_comment_time($d = '', $gmt = false, $translate = true) { |
|
| 969 | 969 | $comment = get_comment(); |
| 970 | 970 | |
| 971 | 971 | $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
| 972 | - if ( '' == $d ) |
|
| 972 | + if ('' == $d) |
|
| 973 | 973 | $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
| 974 | 974 | else |
| 975 | 975 | $date = mysql2date($d, $comment_date, $translate); |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | * @param bool $translate Whether the time is translated. |
| 986 | 986 | * @param WP_Comment $comment The comment object. |
| 987 | 987 | */ |
| 988 | - return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment ); |
|
| 988 | + return apply_filters('get_comment_time', $date, $d, $gmt, $translate, $comment); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | /** |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | * |
| 996 | 996 | * @param string $d Optional. The format of the time. Default user's settings. |
| 997 | 997 | */ |
| 998 | -function comment_time( $d = '' ) { |
|
| 998 | +function comment_time($d = '') { |
|
| 999 | 999 | echo get_comment_time($d); |
| 1000 | 1000 | } |
| 1001 | 1001 | |
@@ -1009,9 +1009,9 @@ discard block |
||
| 1009 | 1009 | * Default current comment. |
| 1010 | 1010 | * @return string The comment type. |
| 1011 | 1011 | */ |
| 1012 | -function get_comment_type( $comment_ID = 0 ) { |
|
| 1013 | - $comment = get_comment( $comment_ID ); |
|
| 1014 | - if ( '' == $comment->comment_type ) |
|
| 1012 | +function get_comment_type($comment_ID = 0) { |
|
| 1013 | + $comment = get_comment($comment_ID); |
|
| 1014 | + if ('' == $comment->comment_type) |
|
| 1015 | 1015 | $comment->comment_type = 'comment'; |
| 1016 | 1016 | |
| 1017 | 1017 | /** |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | * @param int $comment_ID The comment ID. |
| 1025 | 1025 | * @param WP_Comment $comment The comment object. |
| 1026 | 1026 | */ |
| 1027 | - return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); |
|
| 1027 | + return apply_filters('get_comment_type', $comment->comment_type, $comment->comment_ID, $comment); |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | /** |
@@ -1036,12 +1036,12 @@ discard block |
||
| 1036 | 1036 | * @param string $trackbacktxt Optional. String to display for trackback type. Default false. |
| 1037 | 1037 | * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
| 1038 | 1038 | */ |
| 1039 | -function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
|
| 1040 | - if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
|
| 1041 | - if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
|
| 1042 | - if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
|
| 1039 | +function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) { |
|
| 1040 | + if (false === $commenttxt) $commenttxt = _x('Comment', 'noun'); |
|
| 1041 | + if (false === $trackbacktxt) $trackbacktxt = __('Trackback'); |
|
| 1042 | + if (false === $pingbacktxt) $pingbacktxt = __('Pingback'); |
|
| 1043 | 1043 | $type = get_comment_type(); |
| 1044 | - switch( $type ) { |
|
| 1044 | + switch ($type) { |
|
| 1045 | 1045 | case 'trackback' : |
| 1046 | 1046 | echo $trackbacktxt; |
| 1047 | 1047 | break; |
@@ -1065,10 +1065,10 @@ discard block |
||
| 1065 | 1065 | * @return string The trackback URL after being filtered. |
| 1066 | 1066 | */ |
| 1067 | 1067 | function get_trackback_url() { |
| 1068 | - if ( '' != get_option('permalink_structure') ) |
|
| 1069 | - $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
| 1068 | + if ('' != get_option('permalink_structure')) |
|
| 1069 | + $tb_url = trailingslashit(get_permalink()).user_trailingslashit('trackback', 'single_trackback'); |
|
| 1070 | 1070 | else |
| 1071 | - $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
| 1071 | + $tb_url = get_option('siteurl').'/wp-trackback.php?p='.get_the_ID(); |
|
| 1072 | 1072 | |
| 1073 | 1073 | /** |
| 1074 | 1074 | * Filter the returned trackback URL. |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | * |
| 1078 | 1078 | * @param string $tb_url The trackback URL. |
| 1079 | 1079 | */ |
| 1080 | - return apply_filters( 'trackback_url', $tb_url ); |
|
| 1080 | + return apply_filters('trackback_url', $tb_url); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | /** |
@@ -1089,17 +1089,17 @@ discard block |
||
| 1089 | 1089 | * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() |
| 1090 | 1090 | * for the result instead. |
| 1091 | 1091 | */ |
| 1092 | -function trackback_url( $deprecated_echo = true ) { |
|
| 1093 | - if ( true !== $deprecated_echo ) { |
|
| 1094 | - _deprecated_argument( __FUNCTION__, '2.5', |
|
| 1092 | +function trackback_url($deprecated_echo = true) { |
|
| 1093 | + if (true !== $deprecated_echo) { |
|
| 1094 | + _deprecated_argument(__FUNCTION__, '2.5', |
|
| 1095 | 1095 | /* translators: %s: get_trackback_url() */ |
| 1096 | - sprintf( __( 'Use %s instead if you do not want the value echoed.' ), |
|
| 1096 | + sprintf(__('Use %s instead if you do not want the value echoed.'), |
|
| 1097 | 1097 | '<code>get_trackback_url()</code>' |
| 1098 | 1098 | ) |
| 1099 | 1099 | ); |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | - if ( $deprecated_echo ) { |
|
| 1102 | + if ($deprecated_echo) { |
|
| 1103 | 1103 | echo get_trackback_url(); |
| 1104 | 1104 | } else { |
| 1105 | 1105 | return get_trackback_url(); |
@@ -1115,12 +1115,12 @@ discard block |
||
| 1115 | 1115 | * |
| 1116 | 1116 | * @param int $deprecated Not used (Was $timezone = 0). |
| 1117 | 1117 | */ |
| 1118 | -function trackback_rdf( $deprecated = '' ) { |
|
| 1119 | - if ( ! empty( $deprecated ) ) { |
|
| 1120 | - _deprecated_argument( __FUNCTION__, '2.5' ); |
|
| 1118 | +function trackback_rdf($deprecated = '') { |
|
| 1119 | + if ( ! empty($deprecated)) { |
|
| 1120 | + _deprecated_argument(__FUNCTION__, '2.5'); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) { |
|
| 1123 | + if (isset($_SERVER['HTTP_USER_AGENT']) && false !== stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { |
|
| 1124 | 1124 | return; |
| 1125 | 1125 | } |
| 1126 | 1126 | |
@@ -1146,11 +1146,11 @@ discard block |
||
| 1146 | 1146 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
| 1147 | 1147 | * @return bool True if the comments are open. |
| 1148 | 1148 | */ |
| 1149 | -function comments_open( $post_id = null ) { |
|
| 1149 | +function comments_open($post_id = null) { |
|
| 1150 | 1150 | |
| 1151 | 1151 | $_post = get_post($post_id); |
| 1152 | 1152 | |
| 1153 | - $open = ( 'open' == $_post->comment_status ); |
|
| 1153 | + $open = ('open' == $_post->comment_status); |
|
| 1154 | 1154 | |
| 1155 | 1155 | /** |
| 1156 | 1156 | * Filter whether the current post is open for comments. |
@@ -1160,7 +1160,7 @@ discard block |
||
| 1160 | 1160 | * @param bool $open Whether the current post is open for comments. |
| 1161 | 1161 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
| 1162 | 1162 | */ |
| 1163 | - return apply_filters( 'comments_open', $open, $post_id ); |
|
| 1163 | + return apply_filters('comments_open', $open, $post_id); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | /** |
@@ -1171,11 +1171,11 @@ discard block |
||
| 1171 | 1171 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
| 1172 | 1172 | * @return bool True if pings are accepted |
| 1173 | 1173 | */ |
| 1174 | -function pings_open( $post_id = null ) { |
|
| 1174 | +function pings_open($post_id = null) { |
|
| 1175 | 1175 | |
| 1176 | 1176 | $_post = get_post($post_id); |
| 1177 | 1177 | |
| 1178 | - $open = ( 'open' == $_post->ping_status ); |
|
| 1178 | + $open = ('open' == $_post->ping_status); |
|
| 1179 | 1179 | |
| 1180 | 1180 | /** |
| 1181 | 1181 | * Filter whether the current post is open for pings. |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | * @param bool $open Whether the current post is open for pings. |
| 1186 | 1186 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
| 1187 | 1187 | */ |
| 1188 | - return apply_filters( 'pings_open', $open, $post_id ); |
|
| 1188 | + return apply_filters('pings_open', $open, $post_id); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1206,8 +1206,8 @@ discard block |
||
| 1206 | 1206 | $post = get_post(); |
| 1207 | 1207 | $post_id = $post ? $post->ID : 0; |
| 1208 | 1208 | |
| 1209 | - if ( current_user_can( 'unfiltered_html' ) ) { |
|
| 1210 | - wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); |
|
| 1209 | + if (current_user_can('unfiltered_html')) { |
|
| 1210 | + wp_nonce_field('unfiltered-html-comment_'.$post_id, '_wp_unfiltered_html_comment_disabled', false); |
|
| 1211 | 1211 | echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; |
| 1212 | 1212 | } |
| 1213 | 1213 | } |
@@ -1247,13 +1247,13 @@ discard block |
||
| 1247 | 1247 | * @param bool $separate_comments Optional. Whether to separate the comments by comment type. |
| 1248 | 1248 | * Default false. |
| 1249 | 1249 | */ |
| 1250 | -function comments_template( $file = '/comments.php', $separate_comments = false ) { |
|
| 1250 | +function comments_template($file = '/comments.php', $separate_comments = false) { |
|
| 1251 | 1251 | global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
| 1252 | 1252 | |
| 1253 | - if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
|
| 1253 | + if ( ! (is_single() || is_page() || $withcomments) || empty($post)) |
|
| 1254 | 1254 | return; |
| 1255 | 1255 | |
| 1256 | - if ( empty($file) ) |
|
| 1256 | + if (empty($file)) |
|
| 1257 | 1257 | $file = '/comments.php'; |
| 1258 | 1258 | |
| 1259 | 1259 | $req = get_option('require_name_email'); |
@@ -1289,31 +1289,31 @@ discard block |
||
| 1289 | 1289 | 'update_comment_meta_cache' => false, // We lazy-load comment meta for performance. |
| 1290 | 1290 | ); |
| 1291 | 1291 | |
| 1292 | - if ( get_option('thread_comments') ) { |
|
| 1292 | + if (get_option('thread_comments')) { |
|
| 1293 | 1293 | $comment_args['hierarchical'] = 'threaded'; |
| 1294 | 1294 | } else { |
| 1295 | 1295 | $comment_args['hierarchical'] = false; |
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | - if ( $user_ID ) { |
|
| 1299 | - $comment_args['include_unapproved'] = array( $user_ID ); |
|
| 1300 | - } elseif ( ! empty( $comment_author_email ) ) { |
|
| 1301 | - $comment_args['include_unapproved'] = array( $comment_author_email ); |
|
| 1298 | + if ($user_ID) { |
|
| 1299 | + $comment_args['include_unapproved'] = array($user_ID); |
|
| 1300 | + } elseif ( ! empty($comment_author_email)) { |
|
| 1301 | + $comment_args['include_unapproved'] = array($comment_author_email); |
|
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | $per_page = 0; |
| 1305 | - if ( get_option( 'page_comments' ) ) { |
|
| 1306 | - $per_page = (int) get_query_var( 'comments_per_page' ); |
|
| 1307 | - if ( 0 === $per_page ) { |
|
| 1308 | - $per_page = (int) get_option( 'comments_per_page' ); |
|
| 1305 | + if (get_option('page_comments')) { |
|
| 1306 | + $per_page = (int) get_query_var('comments_per_page'); |
|
| 1307 | + if (0 === $per_page) { |
|
| 1308 | + $per_page = (int) get_option('comments_per_page'); |
|
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | 1311 | $comment_args['number'] = $per_page; |
| 1312 | - $page = (int) get_query_var( 'cpage' ); |
|
| 1312 | + $page = (int) get_query_var('cpage'); |
|
| 1313 | 1313 | |
| 1314 | - if ( $page ) { |
|
| 1315 | - $comment_args['offset'] = ( $page - 1 ) * $per_page; |
|
| 1316 | - } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { |
|
| 1314 | + if ($page) { |
|
| 1315 | + $comment_args['offset'] = ($page - 1) * $per_page; |
|
| 1316 | + } elseif ('oldest' === get_option('default_comments_page')) { |
|
| 1317 | 1317 | $comment_args['offset'] = 0; |
| 1318 | 1318 | } else { |
| 1319 | 1319 | // If fetching the first page of 'newest', we need a top-level comment count. |
@@ -1325,17 +1325,17 @@ discard block |
||
| 1325 | 1325 | 'status' => 'approve', |
| 1326 | 1326 | ); |
| 1327 | 1327 | |
| 1328 | - if ( $comment_args['hierarchical'] ) { |
|
| 1328 | + if ($comment_args['hierarchical']) { |
|
| 1329 | 1329 | $top_level_args['parent'] = 0; |
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | - if ( isset( $comment_args['include_unapproved'] ) ) { |
|
| 1332 | + if (isset($comment_args['include_unapproved'])) { |
|
| 1333 | 1333 | $top_level_args['include_unapproved'] = $comment_args['include_unapproved']; |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | - $top_level_count = $top_level_query->query( $top_level_args ); |
|
| 1336 | + $top_level_count = $top_level_query->query($top_level_args); |
|
| 1337 | 1337 | |
| 1338 | - $comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page; |
|
| 1338 | + $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page; |
|
| 1339 | 1339 | } |
| 1340 | 1340 | } |
| 1341 | 1341 | |
@@ -1362,22 +1362,22 @@ discard block |
||
| 1362 | 1362 | * @type int $number Number of comments to fetch. |
| 1363 | 1363 | * } |
| 1364 | 1364 | */ |
| 1365 | - $comment_args = apply_filters( 'comments_template_query_args', $comment_args ); |
|
| 1366 | - $comment_query = new WP_Comment_Query( $comment_args ); |
|
| 1365 | + $comment_args = apply_filters('comments_template_query_args', $comment_args); |
|
| 1366 | + $comment_query = new WP_Comment_Query($comment_args); |
|
| 1367 | 1367 | $_comments = $comment_query->comments; |
| 1368 | 1368 | |
| 1369 | 1369 | // Trees must be flattened before they're passed to the walker. |
| 1370 | - if ( $comment_args['hierarchical'] ) { |
|
| 1370 | + if ($comment_args['hierarchical']) { |
|
| 1371 | 1371 | $comments_flat = array(); |
| 1372 | - foreach ( $_comments as $_comment ) { |
|
| 1372 | + foreach ($_comments as $_comment) { |
|
| 1373 | 1373 | $comments_flat[] = $_comment; |
| 1374 | - $comment_children = $_comment->get_children( array( |
|
| 1374 | + $comment_children = $_comment->get_children(array( |
|
| 1375 | 1375 | 'format' => 'flat', |
| 1376 | 1376 | 'status' => $comment_args['status'], |
| 1377 | 1377 | 'orderby' => $comment_args['orderby'] |
| 1378 | - ) ); |
|
| 1378 | + )); |
|
| 1379 | 1379 | |
| 1380 | - foreach ( $comment_children as $comment_child ) { |
|
| 1380 | + foreach ($comment_children as $comment_child) { |
|
| 1381 | 1381 | $comments_flat[] = $comment_child; |
| 1382 | 1382 | } |
| 1383 | 1383 | } |
@@ -1393,13 +1393,13 @@ discard block |
||
| 1393 | 1393 | * @param array $comments Array of comments supplied to the comments template. |
| 1394 | 1394 | * @param int $post_ID Post ID. |
| 1395 | 1395 | */ |
| 1396 | - $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID ); |
|
| 1396 | + $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID); |
|
| 1397 | 1397 | |
| 1398 | 1398 | $comments = &$wp_query->comments; |
| 1399 | 1399 | $wp_query->comment_count = count($wp_query->comments); |
| 1400 | 1400 | $wp_query->max_num_comment_pages = $comment_query->max_num_pages; |
| 1401 | 1401 | |
| 1402 | - if ( $separate_comments ) { |
|
| 1402 | + if ($separate_comments) { |
|
| 1403 | 1403 | $wp_query->comments_by_type = separate_comments($comments); |
| 1404 | 1404 | $comments_by_type = &$wp_query->comments_by_type; |
| 1405 | 1405 | } else { |
@@ -1407,15 +1407,15 @@ discard block |
||
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | 1409 | $overridden_cpage = false; |
| 1410 | - if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { |
|
| 1411 | - set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
|
| 1410 | + if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) { |
|
| 1411 | + set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1); |
|
| 1412 | 1412 | $overridden_cpage = true; |
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | - if ( !defined('COMMENTS_TEMPLATE') ) |
|
| 1415 | + if ( ! defined('COMMENTS_TEMPLATE')) |
|
| 1416 | 1416 | define('COMMENTS_TEMPLATE', true); |
| 1417 | 1417 | |
| 1418 | - $theme_template = STYLESHEETPATH . $file; |
|
| 1418 | + $theme_template = STYLESHEETPATH.$file; |
|
| 1419 | 1419 | /** |
| 1420 | 1420 | * Filter the path to the theme template file used for the comments template. |
| 1421 | 1421 | * |
@@ -1423,13 +1423,13 @@ discard block |
||
| 1423 | 1423 | * |
| 1424 | 1424 | * @param string $theme_template The path to the theme template file. |
| 1425 | 1425 | */ |
| 1426 | - $include = apply_filters( 'comments_template', $theme_template ); |
|
| 1427 | - if ( file_exists( $include ) ) |
|
| 1428 | - require( $include ); |
|
| 1429 | - elseif ( file_exists( TEMPLATEPATH . $file ) ) |
|
| 1430 | - require( TEMPLATEPATH . $file ); |
|
| 1426 | + $include = apply_filters('comments_template', $theme_template); |
|
| 1427 | + if (file_exists($include)) |
|
| 1428 | + require($include); |
|
| 1429 | + elseif (file_exists(TEMPLATEPATH.$file)) |
|
| 1430 | + require(TEMPLATEPATH.$file); |
|
| 1431 | 1431 | else // Backward compat code will be removed in a future release |
| 1432 | - require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
|
| 1432 | + require(ABSPATH.WPINC.'/theme-compat/comments.php'); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | /** |
@@ -1446,45 +1446,45 @@ discard block |
||
| 1446 | 1446 | * @param string $none Optional. String to display when comments have been turned off. |
| 1447 | 1447 | * Default false. |
| 1448 | 1448 | */ |
| 1449 | -function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
|
| 1449 | +function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false) { |
|
| 1450 | 1450 | $id = get_the_ID(); |
| 1451 | 1451 | $title = get_the_title(); |
| 1452 | - $number = get_comments_number( $id ); |
|
| 1452 | + $number = get_comments_number($id); |
|
| 1453 | 1453 | |
| 1454 | - if ( false === $zero ) { |
|
| 1454 | + if (false === $zero) { |
|
| 1455 | 1455 | /* translators: %s: post title */ |
| 1456 | - $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
| 1456 | + $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | - if ( false === $one ) { |
|
| 1459 | + if (false === $one) { |
|
| 1460 | 1460 | /* translators: %s: post title */ |
| 1461 | - $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
| 1461 | + $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title); |
|
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | - if ( false === $more ) { |
|
| 1464 | + if (false === $more) { |
|
| 1465 | 1465 | /* translators: 1: Number of comments 2: post title */ |
| 1466 | - $more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number ); |
|
| 1467 | - $more = sprintf( $more, number_format_i18n( $number ), $title ); |
|
| 1466 | + $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number); |
|
| 1467 | + $more = sprintf($more, number_format_i18n($number), $title); |
|
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - if ( false === $none ) { |
|
| 1470 | + if (false === $none) { |
|
| 1471 | 1471 | /* translators: %s: post title */ |
| 1472 | - $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
| 1472 | + $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title); |
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | - if ( 0 == $number && !comments_open() && !pings_open() ) { |
|
| 1476 | - echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; |
|
| 1475 | + if (0 == $number && ! comments_open() && ! pings_open()) { |
|
| 1476 | + echo '<span'.(( ! empty($css_class)) ? ' class="'.esc_attr($css_class).'"' : '').'>'.$none.'</span>'; |
|
| 1477 | 1477 | return; |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | - if ( post_password_required() ) { |
|
| 1481 | - _e( 'Enter your password to view comments.' ); |
|
| 1480 | + if (post_password_required()) { |
|
| 1481 | + _e('Enter your password to view comments.'); |
|
| 1482 | 1482 | return; |
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | echo '<a href="'; |
| 1486 | - if ( 0 == $number ) { |
|
| 1487 | - $respond_link = get_permalink() . '#respond'; |
|
| 1486 | + if (0 == $number) { |
|
| 1487 | + $respond_link = get_permalink().'#respond'; |
|
| 1488 | 1488 | /** |
| 1489 | 1489 | * Filter the respond link when a post has no comments. |
| 1490 | 1490 | * |
@@ -1493,13 +1493,13 @@ discard block |
||
| 1493 | 1493 | * @param string $respond_link The default response link. |
| 1494 | 1494 | * @param integer $id The post ID. |
| 1495 | 1495 | */ |
| 1496 | - echo apply_filters( 'respond_link', $respond_link, $id ); |
|
| 1496 | + echo apply_filters('respond_link', $respond_link, $id); |
|
| 1497 | 1497 | } else { |
| 1498 | 1498 | comments_link(); |
| 1499 | 1499 | } |
| 1500 | 1500 | echo '"'; |
| 1501 | 1501 | |
| 1502 | - if ( !empty( $css_class ) ) { |
|
| 1502 | + if ( ! empty($css_class)) { |
|
| 1503 | 1503 | echo ' class="'.$css_class.'" '; |
| 1504 | 1504 | } |
| 1505 | 1505 | |
@@ -1511,10 +1511,10 @@ discard block |
||
| 1511 | 1511 | * |
| 1512 | 1512 | * @param string $attributes The comments link attributes. Default empty. |
| 1513 | 1513 | */ |
| 1514 | - echo apply_filters( 'comments_popup_link_attributes', $attributes ); |
|
| 1514 | + echo apply_filters('comments_popup_link_attributes', $attributes); |
|
| 1515 | 1515 | |
| 1516 | 1516 | echo '>'; |
| 1517 | - comments_number( $zero, $one, $more ); |
|
| 1517 | + comments_number($zero, $one, $more); |
|
| 1518 | 1518 | echo '</a>'; |
| 1519 | 1519 | } |
| 1520 | 1520 | |
@@ -1545,33 +1545,33 @@ discard block |
||
| 1545 | 1545 | * Default current post. |
| 1546 | 1546 | * @return void|false|string Link to show comment form, if successful. False, if comments are closed. |
| 1547 | 1547 | */ |
| 1548 | -function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { |
|
| 1548 | +function get_comment_reply_link($args = array(), $comment = null, $post = null) { |
|
| 1549 | 1549 | $defaults = array( |
| 1550 | 1550 | 'add_below' => 'comment', |
| 1551 | 1551 | 'respond_id' => 'respond', |
| 1552 | - 'reply_text' => __( 'Reply' ), |
|
| 1553 | - 'reply_to_text' => __( 'Reply to %s' ), |
|
| 1554 | - 'login_text' => __( 'Log in to Reply' ), |
|
| 1552 | + 'reply_text' => __('Reply'), |
|
| 1553 | + 'reply_to_text' => __('Reply to %s'), |
|
| 1554 | + 'login_text' => __('Log in to Reply'), |
|
| 1555 | 1555 | 'depth' => 0, |
| 1556 | 1556 | 'before' => '', |
| 1557 | 1557 | 'after' => '' |
| 1558 | 1558 | ); |
| 1559 | 1559 | |
| 1560 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1560 | + $args = wp_parse_args($args, $defaults); |
|
| 1561 | 1561 | |
| 1562 | - if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) { |
|
| 1562 | + if (0 == $args['depth'] || $args['max_depth'] <= $args['depth']) { |
|
| 1563 | 1563 | return; |
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | - $comment = get_comment( $comment ); |
|
| 1566 | + $comment = get_comment($comment); |
|
| 1567 | 1567 | |
| 1568 | - if ( empty( $post ) ) { |
|
| 1568 | + if (empty($post)) { |
|
| 1569 | 1569 | $post = $comment->comment_post_ID; |
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | - $post = get_post( $post ); |
|
| 1572 | + $post = get_post($post); |
|
| 1573 | 1573 | |
| 1574 | - if ( ! comments_open( $post->ID ) ) { |
|
| 1574 | + if ( ! comments_open($post->ID)) { |
|
| 1575 | 1575 | return false; |
| 1576 | 1576 | } |
| 1577 | 1577 | |
@@ -1585,22 +1585,22 @@ discard block |
||
| 1585 | 1585 | * @param WP_Comment $comment The object of the comment being replied to. |
| 1586 | 1586 | * @param WP_Post $post The WP_Post object. |
| 1587 | 1587 | */ |
| 1588 | - $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); |
|
| 1588 | + $args = apply_filters('comment_reply_link_args', $args, $comment, $post); |
|
| 1589 | 1589 | |
| 1590 | - if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
|
| 1591 | - $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1592 | - esc_url( wp_login_url( get_permalink() ) ), |
|
| 1590 | + if (get_option('comment_registration') && ! is_user_logged_in()) { |
|
| 1591 | + $link = sprintf('<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1592 | + esc_url(wp_login_url(get_permalink())), |
|
| 1593 | 1593 | $args['login_text'] |
| 1594 | 1594 | ); |
| 1595 | 1595 | } else { |
| 1596 | - $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', |
|
| 1596 | + $onclick = sprintf('return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', |
|
| 1597 | 1597 | $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID |
| 1598 | 1598 | ); |
| 1599 | 1599 | |
| 1600 | - $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>", |
|
| 1601 | - esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'], |
|
| 1600 | + $link = sprintf("<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>", |
|
| 1601 | + esc_url(add_query_arg('replytocom', $comment->comment_ID, get_permalink($post->ID)))."#".$args['respond_id'], |
|
| 1602 | 1602 | $onclick, |
| 1603 | - esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), |
|
| 1603 | + esc_attr(sprintf($args['reply_to_text'], $comment->comment_author)), |
|
| 1604 | 1604 | $args['reply_text'] |
| 1605 | 1605 | ); |
| 1606 | 1606 | } |
@@ -1615,7 +1615,7 @@ discard block |
||
| 1615 | 1615 | * @param object $comment The object of the comment being replied. |
| 1616 | 1616 | * @param WP_Post $post The WP_Post object. |
| 1617 | 1617 | */ |
| 1618 | - return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post ); |
|
| 1618 | + return apply_filters('comment_reply_link', $args['before'].$link.$args['after'], $args, $comment, $post); |
|
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | /** |
@@ -1672,27 +1672,27 @@ discard block |
||
| 1672 | 1672 | |
| 1673 | 1673 | $post = get_post($post); |
| 1674 | 1674 | |
| 1675 | - if ( ! comments_open( $post->ID ) ) { |
|
| 1675 | + if ( ! comments_open($post->ID)) { |
|
| 1676 | 1676 | return false; |
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | - if ( get_option('comment_registration') && ! is_user_logged_in() ) { |
|
| 1680 | - $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1681 | - wp_login_url( get_permalink() ), |
|
| 1679 | + if (get_option('comment_registration') && ! is_user_logged_in()) { |
|
| 1680 | + $link = sprintf('<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1681 | + wp_login_url(get_permalink()), |
|
| 1682 | 1682 | $args['login_text'] |
| 1683 | 1683 | ); |
| 1684 | 1684 | } else { |
| 1685 | - $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
| 1685 | + $onclick = sprintf('return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
| 1686 | 1686 | $args['add_below'], $post->ID, $args['respond_id'] |
| 1687 | 1687 | ); |
| 1688 | 1688 | |
| 1689 | - $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
|
| 1690 | - get_permalink( $post->ID ) . '#' . $args['respond_id'], |
|
| 1689 | + $link = sprintf("<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
|
| 1690 | + get_permalink($post->ID).'#'.$args['respond_id'], |
|
| 1691 | 1691 | $onclick, |
| 1692 | 1692 | $args['reply_text'] |
| 1693 | 1693 | ); |
| 1694 | 1694 | } |
| 1695 | - $formatted_link = $args['before'] . $link . $args['after']; |
|
| 1695 | + $formatted_link = $args['before'].$link.$args['after']; |
|
| 1696 | 1696 | |
| 1697 | 1697 | /** |
| 1698 | 1698 | * Filter the formatted post comments link HTML. |
@@ -1702,7 +1702,7 @@ discard block |
||
| 1702 | 1702 | * @param string $formatted The HTML-formatted post comments link. |
| 1703 | 1703 | * @param int|WP_Post $post The post ID or WP_Post object. |
| 1704 | 1704 | */ |
| 1705 | - return apply_filters( 'post_comments_link', $formatted_link, $post ); |
|
| 1705 | + return apply_filters('post_comments_link', $formatted_link, $post); |
|
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | 1708 | /** |
@@ -1729,14 +1729,14 @@ discard block |
||
| 1729 | 1729 | * @param string $text Optional. Text to display for cancel reply link. Default empty. |
| 1730 | 1730 | * @return string |
| 1731 | 1731 | */ |
| 1732 | -function get_cancel_comment_reply_link( $text = '' ) { |
|
| 1733 | - if ( empty($text) ) |
|
| 1732 | +function get_cancel_comment_reply_link($text = '') { |
|
| 1733 | + if (empty($text)) |
|
| 1734 | 1734 | $text = __('Click here to cancel reply.'); |
| 1735 | 1735 | |
| 1736 | 1736 | $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; |
| 1737 | - $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; |
|
| 1737 | + $link = esc_html(remove_query_arg('replytocom')).'#respond'; |
|
| 1738 | 1738 | |
| 1739 | - $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; |
|
| 1739 | + $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="'.$link.'"'.$style.'>'.$text.'</a>'; |
|
| 1740 | 1740 | |
| 1741 | 1741 | /** |
| 1742 | 1742 | * Filter the cancel comment reply link HTML. |
@@ -1747,7 +1747,7 @@ discard block |
||
| 1747 | 1747 | * @param string $link Cancel comment reply link URL. |
| 1748 | 1748 | * @param string $text Cancel comment reply link text. |
| 1749 | 1749 | */ |
| 1750 | - return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text ); |
|
| 1750 | + return apply_filters('cancel_comment_reply_link', $formatted_link, $link, $text); |
|
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | 1753 | /** |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | * |
| 1758 | 1758 | * @param string $text Optional. Text to display for cancel reply link. Default empty. |
| 1759 | 1759 | */ |
| 1760 | -function cancel_comment_reply_link( $text = '' ) { |
|
| 1760 | +function cancel_comment_reply_link($text = '') { |
|
| 1761 | 1761 | echo get_cancel_comment_reply_link($text); |
| 1762 | 1762 | } |
| 1763 | 1763 | |
@@ -1769,8 +1769,8 @@ discard block |
||
| 1769 | 1769 | * @param int $id Optional. Post ID. Default current post ID. |
| 1770 | 1770 | * @return string Hidden input HTML for replying to comments |
| 1771 | 1771 | */ |
| 1772 | -function get_comment_id_fields( $id = 0 ) { |
|
| 1773 | - if ( empty( $id ) ) |
|
| 1772 | +function get_comment_id_fields($id = 0) { |
|
| 1773 | + if (empty($id)) |
|
| 1774 | 1774 | $id = get_the_ID(); |
| 1775 | 1775 | |
| 1776 | 1776 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
@@ -1786,7 +1786,7 @@ discard block |
||
| 1786 | 1786 | * @param int $id The post ID. |
| 1787 | 1787 | * @param int $replytoid The id of the comment being replied to. |
| 1788 | 1788 | */ |
| 1789 | - return apply_filters( 'comment_id_fields', $result, $id, $replytoid ); |
|
| 1789 | + return apply_filters('comment_id_fields', $result, $id, $replytoid); |
|
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | 1792 | /** |
@@ -1796,8 +1796,8 @@ discard block |
||
| 1796 | 1796 | * |
| 1797 | 1797 | * @param int $id Optional. Post ID. Default current post ID. |
| 1798 | 1798 | */ |
| 1799 | -function comment_id_fields( $id = 0 ) { |
|
| 1800 | - echo get_comment_id_fields( $id ); |
|
| 1799 | +function comment_id_fields($id = 0) { |
|
| 1800 | + echo get_comment_id_fields($id); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | 1803 | /** |
@@ -1820,21 +1820,21 @@ discard block |
||
| 1820 | 1820 | * @param string $linktoparent Optional. Boolean to control making the author's name a link |
| 1821 | 1821 | * to their comment. Default true. |
| 1822 | 1822 | */ |
| 1823 | -function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
|
| 1823 | +function comment_form_title($noreplytext = false, $replytext = false, $linktoparent = true) { |
|
| 1824 | 1824 | global $comment; |
| 1825 | 1825 | |
| 1826 | - if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
|
| 1827 | - if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
|
| 1826 | + if (false === $noreplytext) $noreplytext = __('Leave a Reply'); |
|
| 1827 | + if (false === $replytext) $replytext = __('Leave a Reply to %s'); |
|
| 1828 | 1828 | |
| 1829 | 1829 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
| 1830 | 1830 | |
| 1831 | - if ( 0 == $replytoid ) |
|
| 1831 | + if (0 == $replytoid) |
|
| 1832 | 1832 | echo $noreplytext; |
| 1833 | 1833 | else { |
| 1834 | 1834 | // Sets the global so that template tags can be used in the comment form. |
| 1835 | 1835 | $comment = get_comment($replytoid); |
| 1836 | - $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment ); |
|
| 1837 | - printf( $replytext, $author ); |
|
| 1836 | + $author = ($linktoparent) ? '<a href="#comment-'.get_comment_ID().'">'.get_comment_author($comment).'</a>' : get_comment_author($comment); |
|
| 1837 | + printf($replytext, $author); |
|
| 1838 | 1838 | } |
| 1839 | 1839 | } |
| 1840 | 1840 | |
@@ -1876,7 +1876,7 @@ discard block |
||
| 1876 | 1876 | * } |
| 1877 | 1877 | * @param array $comments Optional. Array of WP_Comment objects. |
| 1878 | 1878 | */ |
| 1879 | -function wp_list_comments( $args = array(), $comments = null ) { |
|
| 1879 | +function wp_list_comments($args = array(), $comments = null) { |
|
| 1880 | 1880 | global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop; |
| 1881 | 1881 | |
| 1882 | 1882 | $in_comment_loop = true; |
@@ -1896,12 +1896,12 @@ discard block |
||
| 1896 | 1896 | 'avatar_size' => 32, |
| 1897 | 1897 | 'reverse_top_level' => null, |
| 1898 | 1898 | 'reverse_children' => '', |
| 1899 | - 'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml', |
|
| 1899 | + 'format' => current_theme_supports('html5', 'comment-list') ? 'html5' : 'xhtml', |
|
| 1900 | 1900 | 'short_ping' => false, |
| 1901 | 1901 | 'echo' => true, |
| 1902 | 1902 | ); |
| 1903 | 1903 | |
| 1904 | - $r = wp_parse_args( $args, $defaults ); |
|
| 1904 | + $r = wp_parse_args($args, $defaults); |
|
| 1905 | 1905 | |
| 1906 | 1906 | /** |
| 1907 | 1907 | * Filter the arguments used in retrieving the comment list. |
@@ -1912,16 +1912,16 @@ discard block |
||
| 1912 | 1912 | * |
| 1913 | 1913 | * @param array $r An array of arguments for displaying comments. |
| 1914 | 1914 | */ |
| 1915 | - $r = apply_filters( 'wp_list_comments_args', $r ); |
|
| 1915 | + $r = apply_filters('wp_list_comments_args', $r); |
|
| 1916 | 1916 | |
| 1917 | 1917 | // Figure out what comments we'll be looping through ($_comments) |
| 1918 | - if ( null !== $comments ) { |
|
| 1918 | + if (null !== $comments) { |
|
| 1919 | 1919 | $comments = (array) $comments; |
| 1920 | - if ( empty($comments) ) |
|
| 1920 | + if (empty($comments)) |
|
| 1921 | 1921 | return; |
| 1922 | - if ( 'all' != $r['type'] ) { |
|
| 1922 | + if ('all' != $r['type']) { |
|
| 1923 | 1923 | $comments_by_type = separate_comments($comments); |
| 1924 | - if ( empty($comments_by_type[$r['type']]) ) |
|
| 1924 | + if (empty($comments_by_type[$r['type']])) |
|
| 1925 | 1925 | return; |
| 1926 | 1926 | $_comments = $comments_by_type[$r['type']]; |
| 1927 | 1927 | } else { |
@@ -1932,29 +1932,29 @@ discard block |
||
| 1932 | 1932 | * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query, |
| 1933 | 1933 | * perform a separate comment query and allow Walker_Comment to paginate. |
| 1934 | 1934 | */ |
| 1935 | - if ( $r['page'] || $r['per_page'] ) { |
|
| 1936 | - $current_cpage = get_query_var( 'cpage' ); |
|
| 1937 | - if ( ! $current_cpage ) { |
|
| 1938 | - $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages; |
|
| 1935 | + if ($r['page'] || $r['per_page']) { |
|
| 1936 | + $current_cpage = get_query_var('cpage'); |
|
| 1937 | + if ( ! $current_cpage) { |
|
| 1938 | + $current_cpage = 'newest' === get_option('default_comments_page') ? 1 : $wp_query->max_num_comment_pages; |
|
| 1939 | 1939 | } |
| 1940 | 1940 | |
| 1941 | - $current_per_page = get_query_var( 'comments_per_page' ); |
|
| 1942 | - if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { |
|
| 1941 | + $current_per_page = get_query_var('comments_per_page'); |
|
| 1942 | + if ($r['page'] != $current_cpage || $r['per_page'] != $current_per_page) { |
|
| 1943 | 1943 | |
| 1944 | - $comments = get_comments( array( |
|
| 1944 | + $comments = get_comments(array( |
|
| 1945 | 1945 | 'post_id' => get_the_ID(), |
| 1946 | 1946 | 'orderby' => 'comment_date_gmt', |
| 1947 | 1947 | 'order' => 'ASC', |
| 1948 | 1948 | 'status' => 'all', |
| 1949 | - ) ); |
|
| 1949 | + )); |
|
| 1950 | 1950 | |
| 1951 | - if ( 'all' != $r['type'] ) { |
|
| 1952 | - $comments_by_type = separate_comments( $comments ); |
|
| 1953 | - if ( empty( $comments_by_type[ $r['type'] ] ) ) { |
|
| 1951 | + if ('all' != $r['type']) { |
|
| 1952 | + $comments_by_type = separate_comments($comments); |
|
| 1953 | + if (empty($comments_by_type[$r['type']])) { |
|
| 1954 | 1954 | return; |
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | - $_comments = $comments_by_type[ $r['type'] ]; |
|
| 1957 | + $_comments = $comments_by_type[$r['type']]; |
|
| 1958 | 1958 | } else { |
| 1959 | 1959 | $_comments = $comments; |
| 1960 | 1960 | } |
@@ -1962,29 +1962,29 @@ discard block |
||
| 1962 | 1962 | |
| 1963 | 1963 | // Otherwise, fall back on the comments from `$wp_query->comments`. |
| 1964 | 1964 | } else { |
| 1965 | - if ( empty($wp_query->comments) ) |
|
| 1965 | + if (empty($wp_query->comments)) |
|
| 1966 | 1966 | return; |
| 1967 | - if ( 'all' != $r['type'] ) { |
|
| 1968 | - if ( empty($wp_query->comments_by_type) ) |
|
| 1967 | + if ('all' != $r['type']) { |
|
| 1968 | + if (empty($wp_query->comments_by_type)) |
|
| 1969 | 1969 | $wp_query->comments_by_type = separate_comments($wp_query->comments); |
| 1970 | - if ( empty($wp_query->comments_by_type[$r['type']]) ) |
|
| 1970 | + if (empty($wp_query->comments_by_type[$r['type']])) |
|
| 1971 | 1971 | return; |
| 1972 | 1972 | $_comments = $wp_query->comments_by_type[$r['type']]; |
| 1973 | 1973 | } else { |
| 1974 | 1974 | $_comments = $wp_query->comments; |
| 1975 | 1975 | } |
| 1976 | 1976 | |
| 1977 | - if ( $wp_query->max_num_comment_pages ) { |
|
| 1978 | - $default_comments_page = get_option( 'default_comments_page' ); |
|
| 1979 | - $cpage = get_query_var( 'cpage' ); |
|
| 1980 | - if ( 'newest' === $default_comments_page ) { |
|
| 1977 | + if ($wp_query->max_num_comment_pages) { |
|
| 1978 | + $default_comments_page = get_option('default_comments_page'); |
|
| 1979 | + $cpage = get_query_var('cpage'); |
|
| 1980 | + if ('newest' === $default_comments_page) { |
|
| 1981 | 1981 | $r['cpage'] = $cpage; |
| 1982 | 1982 | |
| 1983 | 1983 | /* |
| 1984 | 1984 | * When first page shows oldest comments, post permalink is the same as |
| 1985 | 1985 | * the comment permalink. |
| 1986 | 1986 | */ |
| 1987 | - } elseif ( $cpage == 1 ) { |
|
| 1987 | + } elseif ($cpage == 1) { |
|
| 1988 | 1988 | $r['cpage'] = ''; |
| 1989 | 1989 | } else { |
| 1990 | 1990 | $r['cpage'] = $cpage; |
@@ -1996,52 +1996,52 @@ discard block |
||
| 1996 | 1996 | } |
| 1997 | 1997 | } |
| 1998 | 1998 | |
| 1999 | - if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { |
|
| 1999 | + if ('' === $r['per_page'] && get_option('page_comments')) { |
|
| 2000 | 2000 | $r['per_page'] = get_query_var('comments_per_page'); |
| 2001 | 2001 | } |
| 2002 | 2002 | |
| 2003 | - if ( empty($r['per_page']) ) { |
|
| 2003 | + if (empty($r['per_page'])) { |
|
| 2004 | 2004 | $r['per_page'] = 0; |
| 2005 | 2005 | $r['page'] = 0; |
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | - if ( '' === $r['max_depth'] ) { |
|
| 2009 | - if ( get_option('thread_comments') ) |
|
| 2008 | + if ('' === $r['max_depth']) { |
|
| 2009 | + if (get_option('thread_comments')) |
|
| 2010 | 2010 | $r['max_depth'] = get_option('thread_comments_depth'); |
| 2011 | 2011 | else |
| 2012 | 2012 | $r['max_depth'] = -1; |
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | - if ( '' === $r['page'] ) { |
|
| 2016 | - if ( empty($overridden_cpage) ) { |
|
| 2015 | + if ('' === $r['page']) { |
|
| 2016 | + if (empty($overridden_cpage)) { |
|
| 2017 | 2017 | $r['page'] = get_query_var('cpage'); |
| 2018 | 2018 | } else { |
| 2019 | 2019 | $threaded = ( -1 != $r['max_depth'] ); |
| 2020 | - $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
|
| 2021 | - set_query_var( 'cpage', $r['page'] ); |
|
| 2020 | + $r['page'] = ('newest' == get_option('default_comments_page')) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
|
| 2021 | + set_query_var('cpage', $r['page']); |
|
| 2022 | 2022 | } |
| 2023 | 2023 | } |
| 2024 | 2024 | // Validation check |
| 2025 | 2025 | $r['page'] = intval($r['page']); |
| 2026 | - if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
|
| 2026 | + if (0 == $r['page'] && 0 != $r['per_page']) |
|
| 2027 | 2027 | $r['page'] = 1; |
| 2028 | 2028 | |
| 2029 | - if ( null === $r['reverse_top_level'] ) |
|
| 2030 | - $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
| 2029 | + if (null === $r['reverse_top_level']) |
|
| 2030 | + $r['reverse_top_level'] = ('desc' == get_option('comment_order')); |
|
| 2031 | 2031 | |
| 2032 | - wp_queue_comments_for_comment_meta_lazyload( $_comments ); |
|
| 2032 | + wp_queue_comments_for_comment_meta_lazyload($_comments); |
|
| 2033 | 2033 | |
| 2034 | - if ( empty( $r['walker'] ) ) { |
|
| 2034 | + if (empty($r['walker'])) { |
|
| 2035 | 2035 | $walker = new Walker_Comment; |
| 2036 | 2036 | } else { |
| 2037 | 2037 | $walker = $r['walker']; |
| 2038 | 2038 | } |
| 2039 | 2039 | |
| 2040 | - $output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r ); |
|
| 2040 | + $output = $walker->paged_walk($_comments, $r['max_depth'], $r['page'], $r['per_page'], $r); |
|
| 2041 | 2041 | |
| 2042 | 2042 | $in_comment_loop = false; |
| 2043 | 2043 | |
| 2044 | - if ( $r['echo'] ) { |
|
| 2044 | + if ($r['echo']) { |
|
| 2045 | 2045 | echo $output; |
| 2046 | 2046 | } else { |
| 2047 | 2047 | return $output; |
@@ -2108,32 +2108,32 @@ discard block |
||
| 2108 | 2108 | * } |
| 2109 | 2109 | * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
| 2110 | 2110 | */ |
| 2111 | -function comment_form( $args = array(), $post_id = null ) { |
|
| 2112 | - if ( null === $post_id ) |
|
| 2111 | +function comment_form($args = array(), $post_id = null) { |
|
| 2112 | + if (null === $post_id) |
|
| 2113 | 2113 | $post_id = get_the_ID(); |
| 2114 | 2114 | |
| 2115 | 2115 | $commenter = wp_get_current_commenter(); |
| 2116 | 2116 | $user = wp_get_current_user(); |
| 2117 | 2117 | $user_identity = $user->exists() ? $user->display_name : ''; |
| 2118 | 2118 | |
| 2119 | - $args = wp_parse_args( $args ); |
|
| 2120 | - if ( ! isset( $args['format'] ) ) |
|
| 2121 | - $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
| 2119 | + $args = wp_parse_args($args); |
|
| 2120 | + if ( ! isset($args['format'])) |
|
| 2121 | + $args['format'] = current_theme_supports('html5', 'comment-form') ? 'html5' : 'xhtml'; |
|
| 2122 | 2122 | |
| 2123 | - $req = get_option( 'require_name_email' ); |
|
| 2124 | - $aria_req = ( $req ? " aria-required='true'" : '' ); |
|
| 2125 | - $html_req = ( $req ? " required='required'" : '' ); |
|
| 2123 | + $req = get_option('require_name_email'); |
|
| 2124 | + $aria_req = ($req ? " aria-required='true'" : ''); |
|
| 2125 | + $html_req = ($req ? " required='required'" : ''); |
|
| 2126 | 2126 | $html5 = 'html5' === $args['format']; |
| 2127 | - $fields = array( |
|
| 2128 | - 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
|
| 2129 | - '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', |
|
| 2130 | - 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
|
| 2131 | - '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
| 2132 | - 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
|
| 2133 | - '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
|
| 2127 | + $fields = array( |
|
| 2128 | + 'author' => '<p class="comment-form-author">'.'<label for="author">'.__('Name').($req ? ' <span class="required">*</span>' : '').'</label> '. |
|
| 2129 | + '<input id="author" name="author" type="text" value="'.esc_attr($commenter['comment_author']).'" size="30" maxlength="245"'.$aria_req.$html_req.' /></p>', |
|
| 2130 | + 'email' => '<p class="comment-form-email"><label for="email">'.__('Email').($req ? ' <span class="required">*</span>' : '').'</label> '. |
|
| 2131 | + '<input id="email" name="email" '.($html5 ? 'type="email"' : 'type="text"').' value="'.esc_attr($commenter['comment_author_email']).'" size="30" maxlength="100" aria-describedby="email-notes"'.$aria_req.$html_req.' /></p>', |
|
| 2132 | + 'url' => '<p class="comment-form-url"><label for="url">'.__('Website').'</label> '. |
|
| 2133 | + '<input id="url" name="url" '.($html5 ? 'type="url"' : 'type="text"').' value="'.esc_attr($commenter['comment_author_url']).'" size="30" maxlength="200" /></p>', |
|
| 2134 | 2134 | ); |
| 2135 | 2135 | |
| 2136 | - $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
|
| 2136 | + $required_text = sprintf(' '.__('Required fields are marked %s'), '<span class="required">*</span>'); |
|
| 2137 | 2137 | |
| 2138 | 2138 | /** |
| 2139 | 2139 | * Filter the default comment form fields. |
@@ -2142,41 +2142,41 @@ discard block |
||
| 2142 | 2142 | * |
| 2143 | 2143 | * @param array $fields The default comment fields. |
| 2144 | 2144 | */ |
| 2145 | - $fields = apply_filters( 'comment_form_default_fields', $fields ); |
|
| 2145 | + $fields = apply_filters('comment_form_default_fields', $fields); |
|
| 2146 | 2146 | $defaults = array( |
| 2147 | 2147 | 'fields' => $fields, |
| 2148 | - 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', |
|
| 2148 | + 'comment_field' => '<p class="comment-form-comment"><label for="comment">'._x('Comment', 'noun').'</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', |
|
| 2149 | 2149 | /** This filter is documented in wp-includes/link-template.php */ |
| 2150 | - 'must_log_in' => '<p class="must-log-in">' . sprintf( |
|
| 2150 | + 'must_log_in' => '<p class="must-log-in">'.sprintf( |
|
| 2151 | 2151 | /* translators: %s: login URL */ |
| 2152 | - __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
|
| 2153 | - wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
| 2154 | - ) . '</p>', |
|
| 2152 | + __('You must be <a href="%s">logged in</a> to post a comment.'), |
|
| 2153 | + wp_login_url(apply_filters('the_permalink', get_permalink($post_id))) |
|
| 2154 | + ).'</p>', |
|
| 2155 | 2155 | /** This filter is documented in wp-includes/link-template.php */ |
| 2156 | - 'logged_in_as' => '<p class="logged-in-as">' . sprintf( |
|
| 2156 | + 'logged_in_as' => '<p class="logged-in-as">'.sprintf( |
|
| 2157 | 2157 | /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
| 2158 | - __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
|
| 2158 | + __('<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>'), |
|
| 2159 | 2159 | get_edit_user_link(), |
| 2160 | 2160 | /* translators: %s: user name */ |
| 2161 | - esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
|
| 2161 | + esc_attr(sprintf(__('Logged in as %s. Edit your profile.'), $user_identity)), |
|
| 2162 | 2162 | $user_identity, |
| 2163 | - wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
| 2164 | - ) . '</p>', |
|
| 2165 | - 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>', |
|
| 2163 | + wp_logout_url(apply_filters('the_permalink', get_permalink($post_id))) |
|
| 2164 | + ).'</p>', |
|
| 2165 | + 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">'.__('Your email address will not be published.').'</span>'.($req ? $required_text : '').'</p>', |
|
| 2166 | 2166 | 'comment_notes_after' => '', |
| 2167 | 2167 | 'id_form' => 'commentform', |
| 2168 | 2168 | 'id_submit' => 'submit', |
| 2169 | 2169 | 'class_form' => 'comment-form', |
| 2170 | 2170 | 'class_submit' => 'submit', |
| 2171 | 2171 | 'name_submit' => 'submit', |
| 2172 | - 'title_reply' => __( 'Leave a Reply' ), |
|
| 2173 | - 'title_reply_to' => __( 'Leave a Reply to %s' ), |
|
| 2172 | + 'title_reply' => __('Leave a Reply'), |
|
| 2173 | + 'title_reply_to' => __('Leave a Reply to %s'), |
|
| 2174 | 2174 | 'title_reply_before' => '<h3 id="reply-title" class="comment-reply-title">', |
| 2175 | 2175 | 'title_reply_after' => '</h3>', |
| 2176 | 2176 | 'cancel_reply_before' => ' <small>', |
| 2177 | 2177 | 'cancel_reply_after' => '</small>', |
| 2178 | - 'cancel_reply_link' => __( 'Cancel reply' ), |
|
| 2179 | - 'label_submit' => __( 'Post Comment' ), |
|
| 2178 | + 'cancel_reply_link' => __('Cancel reply'), |
|
| 2179 | + 'label_submit' => __('Post Comment'), |
|
| 2180 | 2180 | 'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />', |
| 2181 | 2181 | 'submit_field' => '<p class="form-submit">%1$s %2$s</p>', |
| 2182 | 2182 | 'format' => 'xhtml', |
@@ -2191,53 +2191,53 @@ discard block |
||
| 2191 | 2191 | * |
| 2192 | 2192 | * @param array $defaults The default comment form arguments. |
| 2193 | 2193 | */ |
| 2194 | - $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); |
|
| 2194 | + $args = wp_parse_args($args, apply_filters('comment_form_defaults', $defaults)); |
|
| 2195 | 2195 | |
| 2196 | 2196 | // Ensure that the filtered args contain all required default values. |
| 2197 | - $args = array_merge( $defaults, $args ); |
|
| 2197 | + $args = array_merge($defaults, $args); |
|
| 2198 | 2198 | |
| 2199 | - if ( comments_open( $post_id ) ) : ?> |
|
| 2199 | + if (comments_open($post_id)) : ?> |
|
| 2200 | 2200 | <?php |
| 2201 | 2201 | /** |
| 2202 | 2202 | * Fires before the comment form. |
| 2203 | 2203 | * |
| 2204 | 2204 | * @since 3.0.0 |
| 2205 | 2205 | */ |
| 2206 | - do_action( 'comment_form_before' ); |
|
| 2206 | + do_action('comment_form_before'); |
|
| 2207 | 2207 | ?> |
| 2208 | 2208 | <div id="respond" class="comment-respond"> |
| 2209 | 2209 | <?php |
| 2210 | 2210 | echo $args['title_reply_before']; |
| 2211 | 2211 | |
| 2212 | - comment_form_title( $args['title_reply'], $args['title_reply_to'] ); |
|
| 2212 | + comment_form_title($args['title_reply'], $args['title_reply_to']); |
|
| 2213 | 2213 | |
| 2214 | 2214 | echo $args['cancel_reply_before']; |
| 2215 | 2215 | |
| 2216 | - cancel_comment_reply_link( $args['cancel_reply_link'] ); |
|
| 2216 | + cancel_comment_reply_link($args['cancel_reply_link']); |
|
| 2217 | 2217 | |
| 2218 | 2218 | echo $args['cancel_reply_after']; |
| 2219 | 2219 | |
| 2220 | 2220 | echo $args['title_reply_after']; |
| 2221 | 2221 | |
| 2222 | - if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : |
|
| 2222 | + if (get_option('comment_registration') && ! is_user_logged_in()) : |
|
| 2223 | 2223 | echo $args['must_log_in']; |
| 2224 | 2224 | /** |
| 2225 | 2225 | * Fires after the HTML-formatted 'must log in after' message in the comment form. |
| 2226 | 2226 | * |
| 2227 | 2227 | * @since 3.0.0 |
| 2228 | 2228 | */ |
| 2229 | - do_action( 'comment_form_must_log_in_after' ); |
|
| 2229 | + do_action('comment_form_must_log_in_after'); |
|
| 2230 | 2230 | else : ?> |
| 2231 | - <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2231 | + <form action="<?php echo site_url('/wp-comments-post.php'); ?>" method="post" id="<?php echo esc_attr($args['id_form']); ?>" class="<?php echo esc_attr($args['class_form']); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2232 | 2232 | <?php |
| 2233 | 2233 | /** |
| 2234 | 2234 | * Fires at the top of the comment form, inside the form tag. |
| 2235 | 2235 | * |
| 2236 | 2236 | * @since 3.0.0 |
| 2237 | 2237 | */ |
| 2238 | - do_action( 'comment_form_top' ); |
|
| 2238 | + do_action('comment_form_top'); |
|
| 2239 | 2239 | |
| 2240 | - if ( is_user_logged_in() ) : |
|
| 2240 | + if (is_user_logged_in()) : |
|
| 2241 | 2241 | /** |
| 2242 | 2242 | * Filter the 'logged in' message for the comment form for display. |
| 2243 | 2243 | * |
@@ -2249,7 +2249,7 @@ discard block |
||
| 2249 | 2249 | * @param string $user_identity If the commenter is a registered user, |
| 2250 | 2250 | * the display name, blank otherwise. |
| 2251 | 2251 | */ |
| 2252 | - echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); |
|
| 2252 | + echo apply_filters('comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity); |
|
| 2253 | 2253 | |
| 2254 | 2254 | /** |
| 2255 | 2255 | * Fires after the is_user_logged_in() check in the comment form. |
@@ -2261,7 +2261,7 @@ discard block |
||
| 2261 | 2261 | * @param string $user_identity If the commenter is a registered user, |
| 2262 | 2262 | * the display name, blank otherwise. |
| 2263 | 2263 | */ |
| 2264 | - do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
|
| 2264 | + do_action('comment_form_logged_in_after', $commenter, $user_identity); |
|
| 2265 | 2265 | |
| 2266 | 2266 | else : |
| 2267 | 2267 | |
@@ -2270,7 +2270,7 @@ discard block |
||
| 2270 | 2270 | endif; |
| 2271 | 2271 | |
| 2272 | 2272 | // Prepare an array of all fields, including the textarea |
| 2273 | - $comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields']; |
|
| 2273 | + $comment_fields = array('comment' => $args['comment_field']) + (array) $args['fields']; |
|
| 2274 | 2274 | |
| 2275 | 2275 | /** |
| 2276 | 2276 | * Filter the comment form fields, including the textarea. |
@@ -2279,18 +2279,18 @@ discard block |
||
| 2279 | 2279 | * |
| 2280 | 2280 | * @param array $comment_fields The comment fields. |
| 2281 | 2281 | */ |
| 2282 | - $comment_fields = apply_filters( 'comment_form_fields', $comment_fields ); |
|
| 2282 | + $comment_fields = apply_filters('comment_form_fields', $comment_fields); |
|
| 2283 | 2283 | |
| 2284 | 2284 | // Get an array of field names, excluding the textarea |
| 2285 | - $comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) ); |
|
| 2285 | + $comment_field_keys = array_diff(array_keys($comment_fields), array('comment')); |
|
| 2286 | 2286 | |
| 2287 | 2287 | // Get the first and the last field name, excluding the textarea |
| 2288 | - $first_field = reset( $comment_field_keys ); |
|
| 2289 | - $last_field = end( $comment_field_keys ); |
|
| 2288 | + $first_field = reset($comment_field_keys); |
|
| 2289 | + $last_field = end($comment_field_keys); |
|
| 2290 | 2290 | |
| 2291 | - foreach ( $comment_fields as $name => $field ) { |
|
| 2291 | + foreach ($comment_fields as $name => $field) { |
|
| 2292 | 2292 | |
| 2293 | - if ( 'comment' === $name ) { |
|
| 2293 | + if ('comment' === $name) { |
|
| 2294 | 2294 | |
| 2295 | 2295 | /** |
| 2296 | 2296 | * Filter the content of the comment textarea field for display. |
@@ -2299,19 +2299,19 @@ discard block |
||
| 2299 | 2299 | * |
| 2300 | 2300 | * @param string $args_comment_field The content of the comment textarea field. |
| 2301 | 2301 | */ |
| 2302 | - echo apply_filters( 'comment_form_field_comment', $field ); |
|
| 2302 | + echo apply_filters('comment_form_field_comment', $field); |
|
| 2303 | 2303 | |
| 2304 | 2304 | echo $args['comment_notes_after']; |
| 2305 | 2305 | |
| 2306 | - } elseif ( ! is_user_logged_in() ) { |
|
| 2306 | + } elseif ( ! is_user_logged_in()) { |
|
| 2307 | 2307 | |
| 2308 | - if ( $first_field === $name ) { |
|
| 2308 | + if ($first_field === $name) { |
|
| 2309 | 2309 | /** |
| 2310 | 2310 | * Fires before the comment fields in the comment form, excluding the textarea. |
| 2311 | 2311 | * |
| 2312 | 2312 | * @since 3.0.0 |
| 2313 | 2313 | */ |
| 2314 | - do_action( 'comment_form_before_fields' ); |
|
| 2314 | + do_action('comment_form_before_fields'); |
|
| 2315 | 2315 | } |
| 2316 | 2316 | |
| 2317 | 2317 | /** |
@@ -2324,25 +2324,25 @@ discard block |
||
| 2324 | 2324 | * |
| 2325 | 2325 | * @param string $field The HTML-formatted output of the comment form field. |
| 2326 | 2326 | */ |
| 2327 | - echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; |
|
| 2327 | + echo apply_filters("comment_form_field_{$name}", $field)."\n"; |
|
| 2328 | 2328 | |
| 2329 | - if ( $last_field === $name ) { |
|
| 2329 | + if ($last_field === $name) { |
|
| 2330 | 2330 | /** |
| 2331 | 2331 | * Fires after the comment fields in the comment form, excluding the textarea. |
| 2332 | 2332 | * |
| 2333 | 2333 | * @since 3.0.0 |
| 2334 | 2334 | */ |
| 2335 | - do_action( 'comment_form_after_fields' ); |
|
| 2335 | + do_action('comment_form_after_fields'); |
|
| 2336 | 2336 | } |
| 2337 | 2337 | } |
| 2338 | 2338 | } |
| 2339 | 2339 | |
| 2340 | 2340 | $submit_button = sprintf( |
| 2341 | 2341 | $args['submit_button'], |
| 2342 | - esc_attr( $args['name_submit'] ), |
|
| 2343 | - esc_attr( $args['id_submit'] ), |
|
| 2344 | - esc_attr( $args['class_submit'] ), |
|
| 2345 | - esc_attr( $args['label_submit'] ) |
|
| 2342 | + esc_attr($args['name_submit']), |
|
| 2343 | + esc_attr($args['id_submit']), |
|
| 2344 | + esc_attr($args['class_submit']), |
|
| 2345 | + esc_attr($args['label_submit']) |
|
| 2346 | 2346 | ); |
| 2347 | 2347 | |
| 2348 | 2348 | /** |
@@ -2353,12 +2353,12 @@ discard block |
||
| 2353 | 2353 | * @param string $submit_button HTML markup for the submit button. |
| 2354 | 2354 | * @param array $args Arguments passed to `comment_form()`. |
| 2355 | 2355 | */ |
| 2356 | - $submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args ); |
|
| 2356 | + $submit_button = apply_filters('comment_form_submit_button', $submit_button, $args); |
|
| 2357 | 2357 | |
| 2358 | 2358 | $submit_field = sprintf( |
| 2359 | 2359 | $args['submit_field'], |
| 2360 | 2360 | $submit_button, |
| 2361 | - get_comment_id_fields( $post_id ) |
|
| 2361 | + get_comment_id_fields($post_id) |
|
| 2362 | 2362 | ); |
| 2363 | 2363 | |
| 2364 | 2364 | /** |
@@ -2372,7 +2372,7 @@ discard block |
||
| 2372 | 2372 | * @param string $submit_field HTML markup for the submit field. |
| 2373 | 2373 | * @param array $args Arguments passed to comment_form(). |
| 2374 | 2374 | */ |
| 2375 | - echo apply_filters( 'comment_form_submit_field', $submit_field, $args ); |
|
| 2375 | + echo apply_filters('comment_form_submit_field', $submit_field, $args); |
|
| 2376 | 2376 | |
| 2377 | 2377 | /** |
| 2378 | 2378 | * Fires at the bottom of the comment form, inside the closing </form> tag. |
@@ -2381,7 +2381,7 @@ discard block |
||
| 2381 | 2381 | * |
| 2382 | 2382 | * @param int $post_id The post ID. |
| 2383 | 2383 | */ |
| 2384 | - do_action( 'comment_form', $post_id ); |
|
| 2384 | + do_action('comment_form', $post_id); |
|
| 2385 | 2385 | ?> |
| 2386 | 2386 | </form> |
| 2387 | 2387 | <?php endif; ?> |
@@ -2392,13 +2392,13 @@ discard block |
||
| 2392 | 2392 | * |
| 2393 | 2393 | * @since 3.0.0 |
| 2394 | 2394 | */ |
| 2395 | - do_action( 'comment_form_after' ); |
|
| 2395 | + do_action('comment_form_after'); |
|
| 2396 | 2396 | else : |
| 2397 | 2397 | /** |
| 2398 | 2398 | * Fires after the comment form if comments are closed. |
| 2399 | 2399 | * |
| 2400 | 2400 | * @since 3.0.0 |
| 2401 | 2401 | */ |
| 2402 | - do_action( 'comment_form_comments_closed' ); |
|
| 2402 | + do_action('comment_form_comments_closed'); |
|
| 2403 | 2403 | endif; |
| 2404 | 2404 | } |
@@ -25,10 +25,11 @@ discard block |
||
| 25 | 25 | $comment = get_comment( $comment_ID ); |
| 26 | 26 | |
| 27 | 27 | if ( empty( $comment->comment_author ) ) { |
| 28 | - if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) |
|
| 29 | - $author = $user->display_name; |
|
| 30 | - else |
|
| 31 | - $author = __('Anonymous'); |
|
| 28 | + if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) { |
|
| 29 | + $author = $user->display_name; |
|
| 30 | + } else { |
|
| 31 | + $author = __('Anonymous'); |
|
| 32 | + } |
|
| 32 | 33 | } else { |
| 33 | 34 | $author = $comment->comment_author; |
| 34 | 35 | } |
@@ -145,9 +146,10 @@ discard block |
||
| 145 | 146 | * @param string $after Optional. Text or HTML to display after the email link. Default empty. |
| 146 | 147 | */ |
| 147 | 148 | function comment_author_email_link( $linktext = '', $before = '', $after = '' ) { |
| 148 | - if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) |
|
| 149 | - echo $link; |
|
| 150 | -} |
|
| 149 | + if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) { |
|
| 150 | + echo $link; |
|
| 151 | + } |
|
| 152 | + } |
|
| 151 | 153 | |
| 152 | 154 | /** |
| 153 | 155 | * Return the html email link to the author of the current comment. |
@@ -210,10 +212,11 @@ discard block |
||
| 210 | 212 | $url = get_comment_author_url( $comment ); |
| 211 | 213 | $author = get_comment_author( $comment ); |
| 212 | 214 | |
| 213 | - if ( empty( $url ) || 'http://' == $url ) |
|
| 214 | - $return = $author; |
|
| 215 | - else |
|
| 216 | - $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
| 215 | + if ( empty( $url ) || 'http://' == $url ) { |
|
| 216 | + $return = $author; |
|
| 217 | + } else { |
|
| 218 | + $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
| 219 | + } |
|
| 217 | 220 | |
| 218 | 221 | /** |
| 219 | 222 | * Filter the comment author's link for display. |
@@ -409,11 +412,12 @@ discard block |
||
| 409 | 412 | function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
| 410 | 413 | // Separates classes with a single space, collates classes for comment DIV |
| 411 | 414 | $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
| 412 | - if ( $echo) |
|
| 413 | - echo $class; |
|
| 414 | - else |
|
| 415 | - return $class; |
|
| 416 | -} |
|
| 415 | + if ( $echo) { |
|
| 416 | + echo $class; |
|
| 417 | + } else { |
|
| 418 | + return $class; |
|
| 419 | + } |
|
| 420 | + } |
|
| 417 | 421 | |
| 418 | 422 | /** |
| 419 | 423 | * Returns the classes for the comment div as an array. |
@@ -455,12 +459,15 @@ discard block |
||
| 455 | 459 | } |
| 456 | 460 | } |
| 457 | 461 | |
| 458 | - if ( empty($comment_alt) ) |
|
| 459 | - $comment_alt = 0; |
|
| 460 | - if ( empty($comment_depth) ) |
|
| 461 | - $comment_depth = 1; |
|
| 462 | - if ( empty($comment_thread_alt) ) |
|
| 463 | - $comment_thread_alt = 0; |
|
| 462 | + if ( empty($comment_alt) ) { |
|
| 463 | + $comment_alt = 0; |
|
| 464 | + } |
|
| 465 | + if ( empty($comment_depth) ) { |
|
| 466 | + $comment_depth = 1; |
|
| 467 | + } |
|
| 468 | + if ( empty($comment_thread_alt) ) { |
|
| 469 | + $comment_thread_alt = 0; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | if ( $comment_alt % 2 ) { |
| 466 | 473 | $classes[] = 'odd'; |
@@ -485,8 +492,9 @@ discard block |
||
| 485 | 492 | $classes[] = "depth-$comment_depth"; |
| 486 | 493 | |
| 487 | 494 | if ( !empty($class) ) { |
| 488 | - if ( !is_array( $class ) ) |
|
| 489 | - $class = preg_split('#\s+#', $class); |
|
| 495 | + if ( !is_array( $class ) ) { |
|
| 496 | + $class = preg_split('#\s+#', $class); |
|
| 497 | + } |
|
| 490 | 498 | $classes = array_merge($classes, $class); |
| 491 | 499 | } |
| 492 | 500 | |
@@ -519,10 +527,11 @@ discard block |
||
| 519 | 527 | */ |
| 520 | 528 | function get_comment_date( $d = '', $comment_ID = 0 ) { |
| 521 | 529 | $comment = get_comment( $comment_ID ); |
| 522 | - if ( '' == $d ) |
|
| 523 | - $date = mysql2date(get_option('date_format'), $comment->comment_date); |
|
| 524 | - else |
|
| 525 | - $date = mysql2date($d, $comment->comment_date); |
|
| 530 | + if ( '' == $d ) { |
|
| 531 | + $date = mysql2date(get_option('date_format'), $comment->comment_date); |
|
| 532 | + } else { |
|
| 533 | + $date = mysql2date($d, $comment->comment_date); |
|
| 534 | + } |
|
| 526 | 535 | /** |
| 527 | 536 | * Filter the returned comment date. |
| 528 | 537 | * |
@@ -802,10 +811,12 @@ discard block |
||
| 802 | 811 | * @param string $deprecated_2 Not Used. |
| 803 | 812 | */ |
| 804 | 813 | function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
| 805 | - if ( !empty( $deprecated ) ) |
|
| 806 | - _deprecated_argument( __FUNCTION__, '0.72' ); |
|
| 807 | - if ( !empty( $deprecated_2 ) ) |
|
| 808 | - _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 814 | + if ( !empty( $deprecated ) ) { |
|
| 815 | + _deprecated_argument( __FUNCTION__, '0.72' ); |
|
| 816 | + } |
|
| 817 | + if ( !empty( $deprecated_2 ) ) { |
|
| 818 | + _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 819 | + } |
|
| 809 | 820 | echo esc_url( get_comments_link() ); |
| 810 | 821 | } |
| 811 | 822 | |
@@ -969,10 +980,11 @@ discard block |
||
| 969 | 980 | $comment = get_comment(); |
| 970 | 981 | |
| 971 | 982 | $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
| 972 | - if ( '' == $d ) |
|
| 973 | - $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
|
| 974 | - else |
|
| 975 | - $date = mysql2date($d, $comment_date, $translate); |
|
| 983 | + if ( '' == $d ) { |
|
| 984 | + $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
|
| 985 | + } else { |
|
| 986 | + $date = mysql2date($d, $comment_date, $translate); |
|
| 987 | + } |
|
| 976 | 988 | |
| 977 | 989 | /** |
| 978 | 990 | * Filter the returned comment time. |
@@ -1011,8 +1023,9 @@ discard block |
||
| 1011 | 1023 | */ |
| 1012 | 1024 | function get_comment_type( $comment_ID = 0 ) { |
| 1013 | 1025 | $comment = get_comment( $comment_ID ); |
| 1014 | - if ( '' == $comment->comment_type ) |
|
| 1015 | - $comment->comment_type = 'comment'; |
|
| 1026 | + if ( '' == $comment->comment_type ) { |
|
| 1027 | + $comment->comment_type = 'comment'; |
|
| 1028 | + } |
|
| 1016 | 1029 | |
| 1017 | 1030 | /** |
| 1018 | 1031 | * Filter the returned comment type. |
@@ -1037,9 +1050,15 @@ discard block |
||
| 1037 | 1050 | * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
| 1038 | 1051 | */ |
| 1039 | 1052 | function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
| 1040 | - if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
|
| 1041 | - if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
|
| 1042 | - if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
|
| 1053 | + if ( false === $commenttxt ) { |
|
| 1054 | + $commenttxt = _x( 'Comment', 'noun' ); |
|
| 1055 | + } |
|
| 1056 | + if ( false === $trackbacktxt ) { |
|
| 1057 | + $trackbacktxt = __( 'Trackback' ); |
|
| 1058 | + } |
|
| 1059 | + if ( false === $pingbacktxt ) { |
|
| 1060 | + $pingbacktxt = __( 'Pingback' ); |
|
| 1061 | + } |
|
| 1043 | 1062 | $type = get_comment_type(); |
| 1044 | 1063 | switch( $type ) { |
| 1045 | 1064 | case 'trackback' : |
@@ -1065,10 +1084,11 @@ discard block |
||
| 1065 | 1084 | * @return string The trackback URL after being filtered. |
| 1066 | 1085 | */ |
| 1067 | 1086 | function get_trackback_url() { |
| 1068 | - if ( '' != get_option('permalink_structure') ) |
|
| 1069 | - $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
| 1070 | - else |
|
| 1071 | - $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
| 1087 | + if ( '' != get_option('permalink_structure') ) { |
|
| 1088 | + $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
| 1089 | + } else { |
|
| 1090 | + $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
| 1091 | + } |
|
| 1072 | 1092 | |
| 1073 | 1093 | /** |
| 1074 | 1094 | * Filter the returned trackback URL. |
@@ -1250,11 +1270,13 @@ discard block |
||
| 1250 | 1270 | function comments_template( $file = '/comments.php', $separate_comments = false ) { |
| 1251 | 1271 | global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
| 1252 | 1272 | |
| 1253 | - if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
|
| 1254 | - return; |
|
| 1273 | + if ( !(is_single() || is_page() || $withcomments) || empty($post) ) { |
|
| 1274 | + return; |
|
| 1275 | + } |
|
| 1255 | 1276 | |
| 1256 | - if ( empty($file) ) |
|
| 1257 | - $file = '/comments.php'; |
|
| 1277 | + if ( empty($file) ) { |
|
| 1278 | + $file = '/comments.php'; |
|
| 1279 | + } |
|
| 1258 | 1280 | |
| 1259 | 1281 | $req = get_option('require_name_email'); |
| 1260 | 1282 | |
@@ -1412,8 +1434,9 @@ discard block |
||
| 1412 | 1434 | $overridden_cpage = true; |
| 1413 | 1435 | } |
| 1414 | 1436 | |
| 1415 | - if ( !defined('COMMENTS_TEMPLATE') ) |
|
| 1416 | - define('COMMENTS_TEMPLATE', true); |
|
| 1437 | + if ( !defined('COMMENTS_TEMPLATE') ) { |
|
| 1438 | + define('COMMENTS_TEMPLATE', true); |
|
| 1439 | + } |
|
| 1417 | 1440 | |
| 1418 | 1441 | $theme_template = STYLESHEETPATH . $file; |
| 1419 | 1442 | /** |
@@ -1424,13 +1447,15 @@ discard block |
||
| 1424 | 1447 | * @param string $theme_template The path to the theme template file. |
| 1425 | 1448 | */ |
| 1426 | 1449 | $include = apply_filters( 'comments_template', $theme_template ); |
| 1427 | - if ( file_exists( $include ) ) |
|
| 1428 | - require( $include ); |
|
| 1429 | - elseif ( file_exists( TEMPLATEPATH . $file ) ) |
|
| 1430 | - require( TEMPLATEPATH . $file ); |
|
| 1431 | - else // Backward compat code will be removed in a future release |
|
| 1450 | + if ( file_exists( $include ) ) { |
|
| 1451 | + require( $include ); |
|
| 1452 | + } elseif ( file_exists( TEMPLATEPATH . $file ) ) { |
|
| 1453 | + require( TEMPLATEPATH . $file ); |
|
| 1454 | + } else { |
|
| 1455 | + // Backward compat code will be removed in a future release |
|
| 1432 | 1456 | require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
| 1433 | -} |
|
| 1457 | + } |
|
| 1458 | + } |
|
| 1434 | 1459 | |
| 1435 | 1460 | /** |
| 1436 | 1461 | * Displays the link to the comments for the current post ID. |
@@ -1730,8 +1755,9 @@ discard block |
||
| 1730 | 1755 | * @return string |
| 1731 | 1756 | */ |
| 1732 | 1757 | function get_cancel_comment_reply_link( $text = '' ) { |
| 1733 | - if ( empty($text) ) |
|
| 1734 | - $text = __('Click here to cancel reply.'); |
|
| 1758 | + if ( empty($text) ) { |
|
| 1759 | + $text = __('Click here to cancel reply.'); |
|
| 1760 | + } |
|
| 1735 | 1761 | |
| 1736 | 1762 | $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; |
| 1737 | 1763 | $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; |
@@ -1770,8 +1796,9 @@ discard block |
||
| 1770 | 1796 | * @return string Hidden input HTML for replying to comments |
| 1771 | 1797 | */ |
| 1772 | 1798 | function get_comment_id_fields( $id = 0 ) { |
| 1773 | - if ( empty( $id ) ) |
|
| 1774 | - $id = get_the_ID(); |
|
| 1799 | + if ( empty( $id ) ) { |
|
| 1800 | + $id = get_the_ID(); |
|
| 1801 | + } |
|
| 1775 | 1802 | |
| 1776 | 1803 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
| 1777 | 1804 | $result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; |
@@ -1823,14 +1850,18 @@ discard block |
||
| 1823 | 1850 | function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
| 1824 | 1851 | global $comment; |
| 1825 | 1852 | |
| 1826 | - if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
|
| 1827 | - if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
|
| 1853 | + if ( false === $noreplytext ) { |
|
| 1854 | + $noreplytext = __( 'Leave a Reply' ); |
|
| 1855 | + } |
|
| 1856 | + if ( false === $replytext ) { |
|
| 1857 | + $replytext = __( 'Leave a Reply to %s' ); |
|
| 1858 | + } |
|
| 1828 | 1859 | |
| 1829 | 1860 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
| 1830 | 1861 | |
| 1831 | - if ( 0 == $replytoid ) |
|
| 1832 | - echo $noreplytext; |
|
| 1833 | - else { |
|
| 1862 | + if ( 0 == $replytoid ) { |
|
| 1863 | + echo $noreplytext; |
|
| 1864 | + } else { |
|
| 1834 | 1865 | // Sets the global so that template tags can be used in the comment form. |
| 1835 | 1866 | $comment = get_comment($replytoid); |
| 1836 | 1867 | $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment ); |
@@ -1917,12 +1948,14 @@ discard block |
||
| 1917 | 1948 | // Figure out what comments we'll be looping through ($_comments) |
| 1918 | 1949 | if ( null !== $comments ) { |
| 1919 | 1950 | $comments = (array) $comments; |
| 1920 | - if ( empty($comments) ) |
|
| 1921 | - return; |
|
| 1951 | + if ( empty($comments) ) { |
|
| 1952 | + return; |
|
| 1953 | + } |
|
| 1922 | 1954 | if ( 'all' != $r['type'] ) { |
| 1923 | 1955 | $comments_by_type = separate_comments($comments); |
| 1924 | - if ( empty($comments_by_type[$r['type']]) ) |
|
| 1925 | - return; |
|
| 1956 | + if ( empty($comments_by_type[$r['type']]) ) { |
|
| 1957 | + return; |
|
| 1958 | + } |
|
| 1926 | 1959 | $_comments = $comments_by_type[$r['type']]; |
| 1927 | 1960 | } else { |
| 1928 | 1961 | $_comments = $comments; |
@@ -1962,13 +1995,16 @@ discard block |
||
| 1962 | 1995 | |
| 1963 | 1996 | // Otherwise, fall back on the comments from `$wp_query->comments`. |
| 1964 | 1997 | } else { |
| 1965 | - if ( empty($wp_query->comments) ) |
|
| 1966 | - return; |
|
| 1998 | + if ( empty($wp_query->comments) ) { |
|
| 1999 | + return; |
|
| 2000 | + } |
|
| 1967 | 2001 | if ( 'all' != $r['type'] ) { |
| 1968 | - if ( empty($wp_query->comments_by_type) ) |
|
| 1969 | - $wp_query->comments_by_type = separate_comments($wp_query->comments); |
|
| 1970 | - if ( empty($wp_query->comments_by_type[$r['type']]) ) |
|
| 1971 | - return; |
|
| 2002 | + if ( empty($wp_query->comments_by_type) ) { |
|
| 2003 | + $wp_query->comments_by_type = separate_comments($wp_query->comments); |
|
| 2004 | + } |
|
| 2005 | + if ( empty($wp_query->comments_by_type[$r['type']]) ) { |
|
| 2006 | + return; |
|
| 2007 | + } |
|
| 1972 | 2008 | $_comments = $wp_query->comments_by_type[$r['type']]; |
| 1973 | 2009 | } else { |
| 1974 | 2010 | $_comments = $wp_query->comments; |
@@ -2006,10 +2042,11 @@ discard block |
||
| 2006 | 2042 | } |
| 2007 | 2043 | |
| 2008 | 2044 | if ( '' === $r['max_depth'] ) { |
| 2009 | - if ( get_option('thread_comments') ) |
|
| 2010 | - $r['max_depth'] = get_option('thread_comments_depth'); |
|
| 2011 | - else |
|
| 2012 | - $r['max_depth'] = -1; |
|
| 2045 | + if ( get_option('thread_comments') ) { |
|
| 2046 | + $r['max_depth'] = get_option('thread_comments_depth'); |
|
| 2047 | + } else { |
|
| 2048 | + $r['max_depth'] = -1; |
|
| 2049 | + } |
|
| 2013 | 2050 | } |
| 2014 | 2051 | |
| 2015 | 2052 | if ( '' === $r['page'] ) { |
@@ -2023,11 +2060,13 @@ discard block |
||
| 2023 | 2060 | } |
| 2024 | 2061 | // Validation check |
| 2025 | 2062 | $r['page'] = intval($r['page']); |
| 2026 | - if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
|
| 2027 | - $r['page'] = 1; |
|
| 2063 | + if ( 0 == $r['page'] && 0 != $r['per_page'] ) { |
|
| 2064 | + $r['page'] = 1; |
|
| 2065 | + } |
|
| 2028 | 2066 | |
| 2029 | - if ( null === $r['reverse_top_level'] ) |
|
| 2030 | - $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
| 2067 | + if ( null === $r['reverse_top_level'] ) { |
|
| 2068 | + $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
| 2069 | + } |
|
| 2031 | 2070 | |
| 2032 | 2071 | wp_queue_comments_for_comment_meta_lazyload( $_comments ); |
| 2033 | 2072 | |
@@ -2109,16 +2148,18 @@ discard block |
||
| 2109 | 2148 | * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
| 2110 | 2149 | */ |
| 2111 | 2150 | function comment_form( $args = array(), $post_id = null ) { |
| 2112 | - if ( null === $post_id ) |
|
| 2113 | - $post_id = get_the_ID(); |
|
| 2151 | + if ( null === $post_id ) { |
|
| 2152 | + $post_id = get_the_ID(); |
|
| 2153 | + } |
|
| 2114 | 2154 | |
| 2115 | 2155 | $commenter = wp_get_current_commenter(); |
| 2116 | 2156 | $user = wp_get_current_user(); |
| 2117 | 2157 | $user_identity = $user->exists() ? $user->display_name : ''; |
| 2118 | 2158 | |
| 2119 | 2159 | $args = wp_parse_args( $args ); |
| 2120 | - if ( ! isset( $args['format'] ) ) |
|
| 2121 | - $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
| 2160 | + if ( ! isset( $args['format'] ) ) { |
|
| 2161 | + $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
| 2162 | + } |
|
| 2122 | 2163 | |
| 2123 | 2164 | $req = get_option( 'require_name_email' ); |
| 2124 | 2165 | $aria_req = ( $req ? " aria-required='true'" : '' ); |
@@ -2227,8 +2268,11 @@ discard block |
||
| 2227 | 2268 | * @since 3.0.0 |
| 2228 | 2269 | */ |
| 2229 | 2270 | do_action( 'comment_form_must_log_in_after' ); |
| 2230 | - else : ?> |
|
| 2231 | - <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2271 | + else { |
|
| 2272 | + : ?> |
|
| 2273 | + <form action="<?php echo site_url( '/wp-comments-post.php' ); |
|
| 2274 | + } |
|
| 2275 | + ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2232 | 2276 | <?php |
| 2233 | 2277 | /** |
| 2234 | 2278 | * Fires at the top of the comment form, inside the form tag. |
@@ -2263,9 +2307,11 @@ discard block |
||
| 2263 | 2307 | */ |
| 2264 | 2308 | do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
| 2265 | 2309 | |
| 2266 | - else : |
|
| 2310 | + else { |
|
| 2311 | + : |
|
| 2267 | 2312 | |
| 2268 | 2313 | echo $args['comment_notes_before']; |
| 2314 | + } |
|
| 2269 | 2315 | |
| 2270 | 2316 | endif; |
| 2271 | 2317 | |
@@ -2393,12 +2439,14 @@ discard block |
||
| 2393 | 2439 | * @since 3.0.0 |
| 2394 | 2440 | */ |
| 2395 | 2441 | do_action( 'comment_form_after' ); |
| 2396 | - else : |
|
| 2442 | + else { |
|
| 2443 | + : |
|
| 2397 | 2444 | /** |
| 2398 | 2445 | * Fires after the comment form if comments are closed. |
| 2399 | 2446 | * |
| 2400 | 2447 | * @since 3.0.0 |
| 2401 | 2448 | */ |
| 2402 | 2449 | do_action( 'comment_form_comments_closed' ); |
| 2450 | + } |
|
| 2403 | 2451 | endif; |
| 2404 | 2452 | } |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | * |
| 979 | 979 | * @global wpdb $wpdb WordPress database abstraction object. |
| 980 | 980 | * |
| 981 | - * @return array Maximum character length for the comment form fields. |
|
| 981 | + * @return string Maximum character length for the comment form fields. |
|
| 982 | 982 | */ |
| 983 | 983 | function wp_get_comment_fields_max_lengths() { |
| 984 | 984 | global $wpdb; |
@@ -1492,7 +1492,7 @@ discard block |
||
| 1492 | 1492 | * |
| 1493 | 1493 | * @since 2.0.4 |
| 1494 | 1494 | * |
| 1495 | - * @return array Comment author, email, url respectively. |
|
| 1495 | + * @return string Comment author, email, url respectively. |
|
| 1496 | 1496 | */ |
| 1497 | 1497 | function wp_get_current_commenter() { |
| 1498 | 1498 | // Cookies should already be sanitized. |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | * new comment. |
| 1559 | 1559 | * @type int $user_id ID of the user who submitted the comment. Default 0. |
| 1560 | 1560 | * } |
| 1561 | - * @return int|false The new comment's ID on success, false on failure. |
|
| 1561 | + * @return string The new comment's ID on success, false on failure. |
|
| 1562 | 1562 | */ |
| 1563 | 1563 | function wp_insert_comment( $commentdata ) { |
| 1564 | 1564 | global $wpdb; |
@@ -2644,7 +2644,7 @@ discard block |
||
| 2644 | 2644 | * |
| 2645 | 2645 | * @param WP_Post $posts Post data object. |
| 2646 | 2646 | * @param WP_Query $query Query object. |
| 2647 | - * @return array |
|
| 2647 | + * @return WP_Post |
|
| 2648 | 2648 | */ |
| 2649 | 2649 | function _close_comments_for_old_posts( $posts, $query ) { |
| 2650 | 2650 | if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Core Comment API |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Comment |
|
| 7 | - */ |
|
| 3 | + * Core Comment API |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Comment |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Check whether a comment passes internal checks to be allowed to add. |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | global $wpdb; |
| 41 | 41 | |
| 42 | 42 | // If manual moderation is enabled, skip all checks and return false. |
| 43 | - if ( 1 == get_option('comment_moderation') ) |
|
| 43 | + if (1 == get_option('comment_moderation')) |
|
| 44 | 44 | return false; |
| 45 | 45 | |
| 46 | 46 | /** This filter is documented in wp-includes/comment-template.php */ |
| 47 | - $comment = apply_filters( 'comment_text', $comment ); |
|
| 47 | + $comment = apply_filters('comment_text', $comment); |
|
| 48 | 48 | |
| 49 | 49 | // Check for the number of external links if a max allowed number is set. |
| 50 | - if ( $max_links = get_option( 'comment_max_links' ) ) { |
|
| 51 | - $num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out ); |
|
| 50 | + if ($max_links = get_option('comment_max_links')) { |
|
| 51 | + $num_links = preg_match_all('/<a [^>]*href/i', $comment, $out); |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Filter the maximum number of links allowed in a comment. |
@@ -58,27 +58,27 @@ discard block |
||
| 58 | 58 | * @param int $num_links The number of links allowed. |
| 59 | 59 | * @param string $url Comment author's URL. Included in allowed links total. |
| 60 | 60 | */ |
| 61 | - $num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); |
|
| 61 | + $num_links = apply_filters('comment_max_links_url', $num_links, $url); |
|
| 62 | 62 | |
| 63 | 63 | /* |
| 64 | 64 | * If the number of links in the comment exceeds the allowed amount, |
| 65 | 65 | * fail the check by returning false. |
| 66 | 66 | */ |
| 67 | - if ( $num_links >= $max_links ) |
|
| 67 | + if ($num_links >= $max_links) |
|
| 68 | 68 | return false; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $mod_keys = trim(get_option('moderation_keys')); |
| 72 | 72 | |
| 73 | 73 | // If moderation 'keys' (keywords) are set, process them. |
| 74 | - if ( !empty($mod_keys) ) { |
|
| 75 | - $words = explode("\n", $mod_keys ); |
|
| 74 | + if ( ! empty($mod_keys)) { |
|
| 75 | + $words = explode("\n", $mod_keys); |
|
| 76 | 76 | |
| 77 | - foreach ( (array) $words as $word) { |
|
| 77 | + foreach ((array) $words as $word) { |
|
| 78 | 78 | $word = trim($word); |
| 79 | 79 | |
| 80 | 80 | // Skip empty lines. |
| 81 | - if ( empty($word) ) |
|
| 81 | + if (empty($word)) |
|
| 82 | 82 | continue; |
| 83 | 83 | |
| 84 | 84 | /* |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * fail the check for the given field by returning false. |
| 93 | 93 | */ |
| 94 | 94 | $pattern = "#$word#i"; |
| 95 | - if ( preg_match($pattern, $author) ) return false; |
|
| 96 | - if ( preg_match($pattern, $email) ) return false; |
|
| 97 | - if ( preg_match($pattern, $url) ) return false; |
|
| 98 | - if ( preg_match($pattern, $comment) ) return false; |
|
| 99 | - if ( preg_match($pattern, $user_ip) ) return false; |
|
| 100 | - if ( preg_match($pattern, $user_agent) ) return false; |
|
| 95 | + if (preg_match($pattern, $author)) return false; |
|
| 96 | + if (preg_match($pattern, $email)) return false; |
|
| 97 | + if (preg_match($pattern, $url)) return false; |
|
| 98 | + if (preg_match($pattern, $comment)) return false; |
|
| 99 | + if (preg_match($pattern, $user_ip)) return false; |
|
| 100 | + if (preg_match($pattern, $user_agent)) return false; |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | * as well as whether there are any moderation keywords (if set) present in the author |
| 109 | 109 | * email address. If both checks pass, return true. Otherwise, return false. |
| 110 | 110 | */ |
| 111 | - if ( 1 == get_option('comment_whitelist')) { |
|
| 112 | - if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) { |
|
| 111 | + if (1 == get_option('comment_whitelist')) { |
|
| 112 | + if ('trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '') { |
|
| 113 | 113 | // expected_slashed ($author, $email) |
| 114 | 114 | $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1"); |
| 115 | - if ( ( 1 == $ok_to_comment ) && |
|
| 116 | - ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) |
|
| 115 | + if ((1 == $ok_to_comment) && |
|
| 116 | + (empty($mod_keys) || false === strpos($email, $mod_keys))) |
|
| 117 | 117 | return true; |
| 118 | 118 | else |
| 119 | 119 | return false; |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * @return int|array $comments The approved comments, or number of comments if `$count` |
| 137 | 137 | * argument is true. |
| 138 | 138 | */ |
| 139 | -function get_approved_comments( $post_id, $args = array() ) { |
|
| 140 | - if ( ! $post_id ) { |
|
| 139 | +function get_approved_comments($post_id, $args = array()) { |
|
| 140 | + if ( ! $post_id) { |
|
| 141 | 141 | return array(); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | 'post_id' => $post_id, |
| 147 | 147 | 'order' => 'ASC', |
| 148 | 148 | ); |
| 149 | - $r = wp_parse_args( $args, $defaults ); |
|
| 149 | + $r = wp_parse_args($args, $defaults); |
|
| 150 | 150 | |
| 151 | 151 | $query = new WP_Comment_Query; |
| 152 | - return $query->query( $r ); |
|
| 152 | + return $query->query($r); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -167,20 +167,20 @@ discard block |
||
| 167 | 167 | * @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants. |
| 168 | 168 | * @return WP_Comment|array|null Depends on $output value. |
| 169 | 169 | */ |
| 170 | -function get_comment( &$comment = null, $output = OBJECT ) { |
|
| 171 | - if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) { |
|
| 170 | +function get_comment(&$comment = null, $output = OBJECT) { |
|
| 171 | + if (empty($comment) && isset($GLOBALS['comment'])) { |
|
| 172 | 172 | $comment = $GLOBALS['comment']; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( $comment instanceof WP_Comment ) { |
|
| 175 | + if ($comment instanceof WP_Comment) { |
|
| 176 | 176 | $_comment = $comment; |
| 177 | - } elseif ( is_object( $comment ) ) { |
|
| 178 | - $_comment = new WP_Comment( $comment ); |
|
| 177 | + } elseif (is_object($comment)) { |
|
| 178 | + $_comment = new WP_Comment($comment); |
|
| 179 | 179 | } else { |
| 180 | - $_comment = WP_Comment::get_instance( $comment ); |
|
| 180 | + $_comment = WP_Comment::get_instance($comment); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( ! $_comment ) { |
|
| 183 | + if ( ! $_comment) { |
|
| 184 | 184 | return null; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -191,14 +191,14 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @param mixed $_comment Comment data. |
| 193 | 193 | */ |
| 194 | - $_comment = apply_filters( 'get_comment', $_comment ); |
|
| 194 | + $_comment = apply_filters('get_comment', $_comment); |
|
| 195 | 195 | |
| 196 | - if ( $output == OBJECT ) { |
|
| 196 | + if ($output == OBJECT) { |
|
| 197 | 197 | return $_comment; |
| 198 | - } elseif ( $output == ARRAY_A ) { |
|
| 198 | + } elseif ($output == ARRAY_A) { |
|
| 199 | 199 | return $_comment->to_array(); |
| 200 | - } elseif ( $output == ARRAY_N ) { |
|
| 201 | - return array_values( $_comment->to_array() ); |
|
| 200 | + } elseif ($output == ARRAY_N) { |
|
| 201 | + return array_values($_comment->to_array()); |
|
| 202 | 202 | } |
| 203 | 203 | return $_comment; |
| 204 | 204 | } |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | * for information on accepted arguments. Default empty. |
| 215 | 215 | * @return int|array List of comments or number of found comments if `$count` argument is true. |
| 216 | 216 | */ |
| 217 | -function get_comments( $args = '' ) { |
|
| 217 | +function get_comments($args = '') { |
|
| 218 | 218 | $query = new WP_Comment_Query; |
| 219 | - return $query->query( $args ); |
|
| 219 | + return $query->query($args); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | function get_comment_statuses() { |
| 233 | 233 | $status = array( |
| 234 | - 'hold' => __( 'Unapproved' ), |
|
| 235 | - 'approve' => _x( 'Approved', 'comment status' ), |
|
| 236 | - 'spam' => _x( 'Spam', 'comment status' ), |
|
| 237 | - 'trash' => _x( 'Trash', 'comment status' ), |
|
| 234 | + 'hold' => __('Unapproved'), |
|
| 235 | + 'approve' => _x('Approved', 'comment status'), |
|
| 236 | + 'spam' => _x('Spam', 'comment status'), |
|
| 237 | + 'trash' => _x('Trash', 'comment status'), |
|
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | 240 | return $status; |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | * @param string $comment_type Optional. Comment type. Default 'comment'. |
| 250 | 250 | * @return string Expected return value is 'open' or 'closed'. |
| 251 | 251 | */ |
| 252 | -function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) { |
|
| 253 | - switch ( $comment_type ) { |
|
| 252 | +function get_default_comment_status($post_type = 'post', $comment_type = 'comment') { |
|
| 253 | + switch ($comment_type) { |
|
| 254 | 254 | case 'pingback' : |
| 255 | 255 | case 'trackback' : |
| 256 | 256 | $supports = 'trackbacks'; |
@@ -262,10 +262,10 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Set the status. |
| 265 | - if ( 'page' === $post_type ) { |
|
| 265 | + if ('page' === $post_type) { |
|
| 266 | 266 | $status = 'closed'; |
| 267 | - } elseif ( post_type_supports( $post_type, $supports ) ) { |
|
| 268 | - $status = get_option( "default_{$option}_status" ); |
|
| 267 | + } elseif (post_type_supports($post_type, $supports)) { |
|
| 268 | + $status = get_option("default_{$option}_status"); |
|
| 269 | 269 | } else { |
| 270 | 270 | $status = 'closed'; |
| 271 | 271 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param string $post_type Post type. Default is `post`. |
| 281 | 281 | * @param string $comment_type Type of comment. Default is `comment`. |
| 282 | 282 | */ |
| 283 | - return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type ); |
|
| 283 | + return apply_filters('get_default_comment_status', $status, $post_type, $comment_type); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -299,12 +299,12 @@ discard block |
||
| 299 | 299 | global $wpdb; |
| 300 | 300 | static $cache_lastcommentmodified = array(); |
| 301 | 301 | |
| 302 | - if ( isset($cache_lastcommentmodified[$timezone]) ) |
|
| 302 | + if (isset($cache_lastcommentmodified[$timezone])) |
|
| 303 | 303 | return $cache_lastcommentmodified[$timezone]; |
| 304 | 304 | |
| 305 | 305 | $add_seconds_server = date('Z'); |
| 306 | 306 | |
| 307 | - switch ( strtolower($timezone)) { |
|
| 307 | + switch (strtolower($timezone)) { |
|
| 308 | 308 | case 'gmt': |
| 309 | 309 | $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); |
| 310 | 310 | break; |
@@ -335,13 +335,13 @@ discard block |
||
| 335 | 335 | * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide. |
| 336 | 336 | * @return array The amount of spam, approved, awaiting moderation, and total comments. |
| 337 | 337 | */ |
| 338 | -function get_comment_count( $post_id = 0 ) { |
|
| 338 | +function get_comment_count($post_id = 0) { |
|
| 339 | 339 | global $wpdb; |
| 340 | 340 | |
| 341 | 341 | $post_id = (int) $post_id; |
| 342 | 342 | |
| 343 | 343 | $where = ''; |
| 344 | - if ( $post_id > 0 ) { |
|
| 344 | + if ($post_id > 0) { |
|
| 345 | 345 | $where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id); |
| 346 | 346 | } |
| 347 | 347 | |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | 'all' => 0, |
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | - foreach ( $totals as $row ) { |
|
| 366 | - switch ( $row['comment_approved'] ) { |
|
| 365 | + foreach ($totals as $row) { |
|
| 366 | + switch ($row['comment_approved']) { |
|
| 367 | 367 | case 'trash': |
| 368 | 368 | $comment_count['trash'] = $row['total']; |
| 369 | 369 | break; |
@@ -475,20 +475,20 @@ discard block |
||
| 475 | 475 | * |
| 476 | 476 | * @param array $comments Array of comment objects. |
| 477 | 477 | */ |
| 478 | -function wp_queue_comments_for_comment_meta_lazyload( $comments ) { |
|
| 478 | +function wp_queue_comments_for_comment_meta_lazyload($comments) { |
|
| 479 | 479 | // Don't use `wp_list_pluck()` to avoid by-reference manipulation. |
| 480 | 480 | $comment_ids = array(); |
| 481 | - if ( is_array( $comments ) ) { |
|
| 482 | - foreach ( $comments as $comment ) { |
|
| 483 | - if ( $comment instanceof WP_Comment ) { |
|
| 481 | + if (is_array($comments)) { |
|
| 482 | + foreach ($comments as $comment) { |
|
| 483 | + if ($comment instanceof WP_Comment) { |
|
| 484 | 484 | $comment_ids[] = $comment->comment_ID; |
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - if ( $comment_ids ) { |
|
| 489 | + if ($comment_ids) { |
|
| 490 | 490 | $lazyloader = wp_metadata_lazyloader(); |
| 491 | - $lazyloader->queue_objects( 'comment', $comment_ids ); |
|
| 491 | + $lazyloader->queue_objects('comment', $comment_ids); |
|
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 | |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * @since 3.4.0 |
| 503 | 503 | */ |
| 504 | 504 | function wp_set_comment_cookies($comment, $user) { |
| 505 | - if ( $user->exists() ) |
|
| 505 | + if ($user->exists()) |
|
| 506 | 506 | return; |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -512,11 +512,11 @@ discard block |
||
| 512 | 512 | * |
| 513 | 513 | * @param int $seconds Comment cookie lifetime. Default 30000000. |
| 514 | 514 | */ |
| 515 | - $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 ); |
|
| 516 | - $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
|
| 517 | - setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
| 518 | - setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
| 519 | - setcookie( 'comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
| 515 | + $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000); |
|
| 516 | + $secure = ('https' === parse_url(home_url(), PHP_URL_SCHEME)); |
|
| 517 | + setcookie('comment_author_'.COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
| 518 | + setcookie('comment_author_email_'.COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
| 519 | + setcookie('comment_author_url_'.COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | * @since 2.0.4 |
| 529 | 529 | */ |
| 530 | 530 | function sanitize_comment_cookies() { |
| 531 | - if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) { |
|
| 531 | + if (isset($_COOKIE['comment_author_'.COOKIEHASH])) { |
|
| 532 | 532 | /** |
| 533 | 533 | * Filter the comment author's name cookie before it is set. |
| 534 | 534 | * |
@@ -539,13 +539,13 @@ discard block |
||
| 539 | 539 | * |
| 540 | 540 | * @param string $author_cookie The comment author name cookie. |
| 541 | 541 | */ |
| 542 | - $comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] ); |
|
| 542 | + $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); |
|
| 543 | 543 | $comment_author = wp_unslash($comment_author); |
| 544 | 544 | $comment_author = esc_attr($comment_author); |
| 545 | - $_COOKIE['comment_author_' . COOKIEHASH] = $comment_author; |
|
| 545 | + $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) { |
|
| 548 | + if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) { |
|
| 549 | 549 | /** |
| 550 | 550 | * Filter the comment author's email cookie before it is set. |
| 551 | 551 | * |
@@ -556,13 +556,13 @@ discard block |
||
| 556 | 556 | * |
| 557 | 557 | * @param string $author_email_cookie The comment author email cookie. |
| 558 | 558 | */ |
| 559 | - $comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] ); |
|
| 559 | + $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]); |
|
| 560 | 560 | $comment_author_email = wp_unslash($comment_author_email); |
| 561 | 561 | $comment_author_email = esc_attr($comment_author_email); |
| 562 | 562 | $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) { |
|
| 565 | + if (isset($_COOKIE['comment_author_url_'.COOKIEHASH])) { |
|
| 566 | 566 | /** |
| 567 | 567 | * Filter the comment author's URL cookie before it is set. |
| 568 | 568 | * |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * |
| 574 | 574 | * @param string $author_url_cookie The comment author URL cookie. |
| 575 | 575 | */ |
| 576 | - $comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] ); |
|
| 576 | + $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); |
|
| 577 | 577 | $comment_author_url = wp_unslash($comment_author_url); |
| 578 | 578 | $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; |
| 579 | 579 | } |
@@ -589,29 +589,29 @@ discard block |
||
| 589 | 589 | * @param array $commentdata Contains information on the comment |
| 590 | 590 | * @return int|string Signifies the approval status (0|1|'spam') |
| 591 | 591 | */ |
| 592 | -function wp_allow_comment( $commentdata ) { |
|
| 592 | +function wp_allow_comment($commentdata) { |
|
| 593 | 593 | global $wpdb; |
| 594 | 594 | |
| 595 | 595 | // Simple duplicate check |
| 596 | 596 | // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) |
| 597 | 597 | $dupe = $wpdb->prepare( |
| 598 | 598 | "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", |
| 599 | - wp_unslash( $commentdata['comment_post_ID'] ), |
|
| 600 | - wp_unslash( $commentdata['comment_parent'] ), |
|
| 601 | - wp_unslash( $commentdata['comment_author'] ) |
|
| 599 | + wp_unslash($commentdata['comment_post_ID']), |
|
| 600 | + wp_unslash($commentdata['comment_parent']), |
|
| 601 | + wp_unslash($commentdata['comment_author']) |
|
| 602 | 602 | ); |
| 603 | - if ( $commentdata['comment_author_email'] ) { |
|
| 603 | + if ($commentdata['comment_author_email']) { |
|
| 604 | 604 | $dupe .= $wpdb->prepare( |
| 605 | 605 | "OR comment_author_email = %s ", |
| 606 | - wp_unslash( $commentdata['comment_author_email'] ) |
|
| 606 | + wp_unslash($commentdata['comment_author_email']) |
|
| 607 | 607 | ); |
| 608 | 608 | } |
| 609 | 609 | $dupe .= $wpdb->prepare( |
| 610 | 610 | ") AND comment_content = %s LIMIT 1", |
| 611 | - wp_unslash( $commentdata['comment_content'] ) |
|
| 611 | + wp_unslash($commentdata['comment_content']) |
|
| 612 | 612 | ); |
| 613 | 613 | |
| 614 | - $dupe_id = $wpdb->get_var( $dupe ); |
|
| 614 | + $dupe_id = $wpdb->get_var($dupe); |
|
| 615 | 615 | |
| 616 | 616 | /** |
| 617 | 617 | * Filters the ID, if any, of the duplicate comment found when creating a new comment. |
@@ -623,9 +623,9 @@ discard block |
||
| 623 | 623 | * @param int $dupe_id ID of the comment identified as a duplicate. |
| 624 | 624 | * @param array $commentdata Data for the comment being created. |
| 625 | 625 | */ |
| 626 | - $dupe_id = apply_filters( 'duplicate_comment_id', $dupe_id, $commentdata ); |
|
| 626 | + $dupe_id = apply_filters('duplicate_comment_id', $dupe_id, $commentdata); |
|
| 627 | 627 | |
| 628 | - if ( $dupe_id ) { |
|
| 628 | + if ($dupe_id) { |
|
| 629 | 629 | /** |
| 630 | 630 | * Fires immediately after a duplicate comment is detected. |
| 631 | 631 | * |
@@ -633,11 +633,11 @@ discard block |
||
| 633 | 633 | * |
| 634 | 634 | * @param array $commentdata Comment data. |
| 635 | 635 | */ |
| 636 | - do_action( 'comment_duplicate_trigger', $commentdata ); |
|
| 637 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 638 | - die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); |
|
| 636 | + do_action('comment_duplicate_trigger', $commentdata); |
|
| 637 | + if (defined('DOING_AJAX')) { |
|
| 638 | + die(__('Duplicate comment detected; it looks as though you’ve already said that!')); |
|
| 639 | 639 | } |
| 640 | - wp_die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 ); |
|
| 640 | + wp_die(__('Duplicate comment detected; it looks as though you’ve already said that!'), 409); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -658,20 +658,20 @@ discard block |
||
| 658 | 658 | $commentdata['comment_date_gmt'] |
| 659 | 659 | ); |
| 660 | 660 | |
| 661 | - if ( ! empty( $commentdata['user_id'] ) ) { |
|
| 662 | - $user = get_userdata( $commentdata['user_id'] ); |
|
| 663 | - $post_author = $wpdb->get_var( $wpdb->prepare( |
|
| 661 | + if ( ! empty($commentdata['user_id'])) { |
|
| 662 | + $user = get_userdata($commentdata['user_id']); |
|
| 663 | + $post_author = $wpdb->get_var($wpdb->prepare( |
|
| 664 | 664 | "SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", |
| 665 | 665 | $commentdata['comment_post_ID'] |
| 666 | - ) ); |
|
| 666 | + )); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { |
|
| 669 | + if (isset($user) && ($commentdata['user_id'] == $post_author || $user->has_cap('moderate_comments'))) { |
|
| 670 | 670 | // The author and the admins get respect. |
| 671 | 671 | $approved = 1; |
| 672 | 672 | } else { |
| 673 | 673 | // Everyone else's comments will be checked. |
| 674 | - if ( check_comment( |
|
| 674 | + if (check_comment( |
|
| 675 | 675 | $commentdata['comment_author'], |
| 676 | 676 | $commentdata['comment_author_email'], |
| 677 | 677 | $commentdata['comment_author_url'], |
@@ -679,20 +679,20 @@ discard block |
||
| 679 | 679 | $commentdata['comment_author_IP'], |
| 680 | 680 | $commentdata['comment_agent'], |
| 681 | 681 | $commentdata['comment_type'] |
| 682 | - ) ) { |
|
| 682 | + )) { |
|
| 683 | 683 | $approved = 1; |
| 684 | 684 | } else { |
| 685 | 685 | $approved = 0; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - if ( wp_blacklist_check( |
|
| 688 | + if (wp_blacklist_check( |
|
| 689 | 689 | $commentdata['comment_author'], |
| 690 | 690 | $commentdata['comment_author_email'], |
| 691 | 691 | $commentdata['comment_author_url'], |
| 692 | 692 | $commentdata['comment_content'], |
| 693 | 693 | $commentdata['comment_author_IP'], |
| 694 | 694 | $commentdata['comment_agent'] |
| 695 | - ) ) { |
|
| 695 | + )) { |
|
| 696 | 696 | $approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam'; |
| 697 | 697 | } |
| 698 | 698 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | * @param bool|string $approved The approval status. Accepts 1, 0, or 'spam'. |
| 706 | 706 | * @param array $commentdata Comment data. |
| 707 | 707 | */ |
| 708 | - $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); |
|
| 708 | + $approved = apply_filters('pre_comment_approved', $approved, $commentdata); |
|
| 709 | 709 | return $approved; |
| 710 | 710 | } |
| 711 | 711 | |
@@ -723,15 +723,15 @@ discard block |
||
| 723 | 723 | * @param string $email Comment author email address. |
| 724 | 724 | * @param string $date MySQL time string. |
| 725 | 725 | */ |
| 726 | -function check_comment_flood_db( $ip, $email, $date ) { |
|
| 726 | +function check_comment_flood_db($ip, $email, $date) { |
|
| 727 | 727 | global $wpdb; |
| 728 | 728 | // don't throttle admins or moderators |
| 729 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) { |
|
| 729 | + if (current_user_can('manage_options') || current_user_can('moderate_comments')) { |
|
| 730 | 730 | return; |
| 731 | 731 | } |
| 732 | - $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS ); |
|
| 732 | + $hour_ago = gmdate('Y-m-d H:i:s', time() - HOUR_IN_SECONDS); |
|
| 733 | 733 | |
| 734 | - if ( is_user_logged_in() ) { |
|
| 734 | + if (is_user_logged_in()) { |
|
| 735 | 735 | $user = get_current_user_id(); |
| 736 | 736 | $check_column = '`user_id`'; |
| 737 | 737 | } else { |
@@ -745,8 +745,8 @@ discard block |
||
| 745 | 745 | $user, |
| 746 | 746 | |
| 747 | 747 | ); |
| 748 | - $lasttime = $wpdb->get_var( $sql ); |
|
| 749 | - if ( $lasttime ) { |
|
| 748 | + $lasttime = $wpdb->get_var($sql); |
|
| 749 | + if ($lasttime) { |
|
| 750 | 750 | $time_lastcomment = mysql2date('U', $lasttime, false); |
| 751 | 751 | $time_newcomment = mysql2date('U', $date, false); |
| 752 | 752 | /** |
@@ -758,8 +758,8 @@ discard block |
||
| 758 | 758 | * @param int $time_lastcomment Timestamp of when the last comment was posted. |
| 759 | 759 | * @param int $time_newcomment Timestamp of when the new comment was posted. |
| 760 | 760 | */ |
| 761 | - $flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment ); |
|
| 762 | - if ( $flood_die ) { |
|
| 761 | + $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); |
|
| 762 | + if ($flood_die) { |
|
| 763 | 763 | /** |
| 764 | 764 | * Fires before the comment flood message is triggered. |
| 765 | 765 | * |
@@ -768,12 +768,12 @@ discard block |
||
| 768 | 768 | * @param int $time_lastcomment Timestamp of when the last comment was posted. |
| 769 | 769 | * @param int $time_newcomment Timestamp of when the new comment was posted. |
| 770 | 770 | */ |
| 771 | - do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); |
|
| 771 | + do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); |
|
| 772 | 772 | |
| 773 | - if ( defined('DOING_AJAX') ) |
|
| 774 | - die( __('You are posting comments too quickly. Slow down.') ); |
|
| 773 | + if (defined('DOING_AJAX')) |
|
| 774 | + die(__('You are posting comments too quickly. Slow down.')); |
|
| 775 | 775 | |
| 776 | - wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 ); |
|
| 776 | + wp_die(__('You are posting comments too quickly. Slow down.'), 429); |
|
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | } |
@@ -789,12 +789,12 @@ discard block |
||
| 789 | 789 | function separate_comments(&$comments) { |
| 790 | 790 | $comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array()); |
| 791 | 791 | $count = count($comments); |
| 792 | - for ( $i = 0; $i < $count; $i++ ) { |
|
| 792 | + for ($i = 0; $i < $count; $i++) { |
|
| 793 | 793 | $type = $comments[$i]->comment_type; |
| 794 | - if ( empty($type) ) |
|
| 794 | + if (empty($type)) |
|
| 795 | 795 | $type = 'comment'; |
| 796 | 796 | $comments_by_type[$type][] = &$comments[$i]; |
| 797 | - if ( 'trackback' == $type || 'pingback' == $type ) |
|
| 797 | + if ('trackback' == $type || 'pingback' == $type) |
|
| 798 | 798 | $comments_by_type['pings'][] = &$comments[$i]; |
| 799 | 799 | } |
| 800 | 800 | |
@@ -815,37 +815,37 @@ discard block |
||
| 815 | 815 | * @param bool $threaded Optional control over flat or threaded comments. |
| 816 | 816 | * @return int Number of comment pages. |
| 817 | 817 | */ |
| 818 | -function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) { |
|
| 818 | +function get_comment_pages_count($comments = null, $per_page = null, $threaded = null) { |
|
| 819 | 819 | global $wp_query; |
| 820 | 820 | |
| 821 | - if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) |
|
| 821 | + if (null === $comments && null === $per_page && null === $threaded && ! empty($wp_query->max_num_comment_pages)) |
|
| 822 | 822 | return $wp_query->max_num_comment_pages; |
| 823 | 823 | |
| 824 | - if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) |
|
| 824 | + if (( ! $comments || ! is_array($comments)) && ! empty($wp_query->comments)) |
|
| 825 | 825 | $comments = $wp_query->comments; |
| 826 | 826 | |
| 827 | - if ( empty($comments) ) |
|
| 827 | + if (empty($comments)) |
|
| 828 | 828 | return 0; |
| 829 | 829 | |
| 830 | - if ( ! get_option( 'page_comments' ) ) { |
|
| 830 | + if ( ! get_option('page_comments')) { |
|
| 831 | 831 | return 1; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | - if ( !isset($per_page) ) |
|
| 834 | + if ( ! isset($per_page)) |
|
| 835 | 835 | $per_page = (int) get_query_var('comments_per_page'); |
| 836 | - if ( 0 === $per_page ) |
|
| 836 | + if (0 === $per_page) |
|
| 837 | 837 | $per_page = (int) get_option('comments_per_page'); |
| 838 | - if ( 0 === $per_page ) |
|
| 838 | + if (0 === $per_page) |
|
| 839 | 839 | return 1; |
| 840 | 840 | |
| 841 | - if ( !isset($threaded) ) |
|
| 841 | + if ( ! isset($threaded)) |
|
| 842 | 842 | $threaded = get_option('thread_comments'); |
| 843 | 843 | |
| 844 | - if ( $threaded ) { |
|
| 844 | + if ($threaded) { |
|
| 845 | 845 | $walker = new Walker_Comment; |
| 846 | - $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page ); |
|
| 846 | + $count = ceil($walker->get_number_of_root_elements($comments) / $per_page); |
|
| 847 | 847 | } else { |
| 848 | - $count = ceil( count( $comments ) / $per_page ); |
|
| 848 | + $count = ceil(count($comments) / $per_page); |
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | return $count; |
@@ -871,49 +871,49 @@ discard block |
||
| 871 | 871 | * } * |
| 872 | 872 | * @return int|null Comment page number or null on error. |
| 873 | 873 | */ |
| 874 | -function get_page_of_comment( $comment_ID, $args = array() ) { |
|
| 874 | +function get_page_of_comment($comment_ID, $args = array()) { |
|
| 875 | 875 | global $wpdb; |
| 876 | 876 | |
| 877 | 877 | $page = null; |
| 878 | 878 | |
| 879 | - if ( !$comment = get_comment( $comment_ID ) ) |
|
| 879 | + if ( ! $comment = get_comment($comment_ID)) |
|
| 880 | 880 | return; |
| 881 | 881 | |
| 882 | - $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); |
|
| 883 | - $args = wp_parse_args( $args, $defaults ); |
|
| 882 | + $defaults = array('type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => ''); |
|
| 883 | + $args = wp_parse_args($args, $defaults); |
|
| 884 | 884 | $original_args = $args; |
| 885 | 885 | |
| 886 | 886 | // Order of precedence: 1. `$args['per_page']`, 2. 'comments_per_page' query_var, 3. 'comments_per_page' option. |
| 887 | - if ( get_option( 'page_comments' ) ) { |
|
| 888 | - if ( '' === $args['per_page'] ) { |
|
| 889 | - $args['per_page'] = get_query_var( 'comments_per_page' ); |
|
| 887 | + if (get_option('page_comments')) { |
|
| 888 | + if ('' === $args['per_page']) { |
|
| 889 | + $args['per_page'] = get_query_var('comments_per_page'); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if ( '' === $args['per_page'] ) { |
|
| 893 | - $args['per_page'] = get_option( 'comments_per_page' ); |
|
| 892 | + if ('' === $args['per_page']) { |
|
| 893 | + $args['per_page'] = get_option('comments_per_page'); |
|
| 894 | 894 | } |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - if ( empty($args['per_page']) ) { |
|
| 897 | + if (empty($args['per_page'])) { |
|
| 898 | 898 | $args['per_page'] = 0; |
| 899 | 899 | $args['page'] = 0; |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | - if ( $args['per_page'] < 1 ) { |
|
| 902 | + if ($args['per_page'] < 1) { |
|
| 903 | 903 | $page = 1; |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | - if ( null === $page ) { |
|
| 907 | - if ( '' === $args['max_depth'] ) { |
|
| 908 | - if ( get_option('thread_comments') ) |
|
| 906 | + if (null === $page) { |
|
| 907 | + if ('' === $args['max_depth']) { |
|
| 908 | + if (get_option('thread_comments')) |
|
| 909 | 909 | $args['max_depth'] = get_option('thread_comments_depth'); |
| 910 | 910 | else |
| 911 | 911 | $args['max_depth'] = -1; |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | // Find this comment's top level parent if threading is enabled |
| 915 | - if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) |
|
| 916 | - return get_page_of_comment( $comment->comment_parent, $args ); |
|
| 915 | + if ($args['max_depth'] > 1 && 0 != $comment->comment_parent) |
|
| 916 | + return get_page_of_comment($comment->comment_parent, $args); |
|
| 917 | 917 | |
| 918 | 918 | $comment_args = array( |
| 919 | 919 | 'type' => $args['type'], |
@@ -931,15 +931,15 @@ discard block |
||
| 931 | 931 | ); |
| 932 | 932 | |
| 933 | 933 | $comment_query = new WP_Comment_Query(); |
| 934 | - $older_comment_count = $comment_query->query( $comment_args ); |
|
| 934 | + $older_comment_count = $comment_query->query($comment_args); |
|
| 935 | 935 | |
| 936 | 936 | // No older comments? Then it's page #1. |
| 937 | - if ( 0 == $older_comment_count ) { |
|
| 937 | + if (0 == $older_comment_count) { |
|
| 938 | 938 | $page = 1; |
| 939 | 939 | |
| 940 | 940 | // Divide comments older than this one by comments per page to get this comment's page number |
| 941 | 941 | } else { |
| 942 | - $page = ceil( ( $older_comment_count + 1 ) / $args['per_page'] ); |
|
| 942 | + $page = ceil(($older_comment_count + 1) / $args['per_page']); |
|
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | * @type int $max_depth Maximum comment threading depth allowed. |
| 969 | 969 | * } |
| 970 | 970 | */ |
| 971 | - return apply_filters( 'get_page_of_comment', (int) $page, $args, $original_args ); |
|
| 971 | + return apply_filters('get_page_of_comment', (int) $page, $args, $original_args); |
|
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | /** |
@@ -990,28 +990,28 @@ discard block |
||
| 990 | 990 | 'comment_content' => 65525, |
| 991 | 991 | ); |
| 992 | 992 | |
| 993 | - if ( $wpdb->is_mysql ) { |
|
| 994 | - foreach ( $lengths as $column => $length ) { |
|
| 995 | - $col_length = $wpdb->get_col_length( $wpdb->comments, $column ); |
|
| 993 | + if ($wpdb->is_mysql) { |
|
| 994 | + foreach ($lengths as $column => $length) { |
|
| 995 | + $col_length = $wpdb->get_col_length($wpdb->comments, $column); |
|
| 996 | 996 | $max_length = 0; |
| 997 | 997 | |
| 998 | 998 | // No point if we can't get the DB column lengths |
| 999 | - if ( is_wp_error( $col_length ) ) { |
|
| 999 | + if (is_wp_error($col_length)) { |
|
| 1000 | 1000 | break; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - if ( ! is_array( $col_length ) && (int) $col_length > 0 ) { |
|
| 1003 | + if ( ! is_array($col_length) && (int) $col_length > 0) { |
|
| 1004 | 1004 | $max_length = (int) $col_length; |
| 1005 | - } elseif ( is_array( $col_length ) && isset( $col_length['length'] ) && intval( $col_length['length'] ) > 0 ) { |
|
| 1005 | + } elseif (is_array($col_length) && isset($col_length['length']) && intval($col_length['length']) > 0) { |
|
| 1006 | 1006 | $max_length = (int) $col_length['length']; |
| 1007 | 1007 | |
| 1008 | - if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) { |
|
| 1008 | + if ( ! empty($col_length['type']) && 'byte' === $col_length['type']) { |
|
| 1009 | 1009 | $max_length = $max_length - 10; |
| 1010 | 1010 | } |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - if ( $max_length > 0 ) { |
|
| 1014 | - $lengths[ $column ] = $max_length; |
|
| 1013 | + if ($max_length > 0) { |
|
| 1014 | + $lengths[$column] = $max_length; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | } |
| 1017 | 1017 | } |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | * |
| 1024 | 1024 | * @param array $lengths Associative array `'field_name' => 'maximum length'`. |
| 1025 | 1025 | */ |
| 1026 | - return apply_filters( 'wp_get_comment_fields_max_lengths', $lengths ); |
|
| 1026 | + return apply_filters('wp_get_comment_fields_max_lengths', $lengths); |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | /** |
@@ -1052,18 +1052,18 @@ discard block |
||
| 1052 | 1052 | * @param string $user_ip Comment author's IP address. |
| 1053 | 1053 | * @param string $user_agent Comment author's browser user agent. |
| 1054 | 1054 | */ |
| 1055 | - do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent ); |
|
| 1055 | + do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); |
|
| 1056 | 1056 | |
| 1057 | - $mod_keys = trim( get_option('blacklist_keys') ); |
|
| 1058 | - if ( '' == $mod_keys ) |
|
| 1057 | + $mod_keys = trim(get_option('blacklist_keys')); |
|
| 1058 | + if ('' == $mod_keys) |
|
| 1059 | 1059 | return false; // If moderation keys are empty |
| 1060 | - $words = explode("\n", $mod_keys ); |
|
| 1060 | + $words = explode("\n", $mod_keys); |
|
| 1061 | 1061 | |
| 1062 | - foreach ( (array) $words as $word ) { |
|
| 1062 | + foreach ((array) $words as $word) { |
|
| 1063 | 1063 | $word = trim($word); |
| 1064 | 1064 | |
| 1065 | 1065 | // Skip empty lines |
| 1066 | - if ( empty($word) ) { continue; } |
|
| 1066 | + if (empty($word)) { continue; } |
|
| 1067 | 1067 | |
| 1068 | 1068 | // Do some escaping magic so that '#' chars in the |
| 1069 | 1069 | // spam words don't break things: |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | * @param int $post_id Optional. Post ID. |
| 1100 | 1100 | * @return object|array Comment stats. |
| 1101 | 1101 | */ |
| 1102 | -function wp_count_comments( $post_id = 0 ) { |
|
| 1102 | +function wp_count_comments($post_id = 0) { |
|
| 1103 | 1103 | $post_id = (int) $post_id; |
| 1104 | 1104 | |
| 1105 | 1105 | /** |
@@ -1110,22 +1110,22 @@ discard block |
||
| 1110 | 1110 | * @param array $count An empty array. |
| 1111 | 1111 | * @param int $post_id The post ID. |
| 1112 | 1112 | */ |
| 1113 | - $filtered = apply_filters( 'wp_count_comments', array(), $post_id ); |
|
| 1114 | - if ( ! empty( $filtered ) ) { |
|
| 1113 | + $filtered = apply_filters('wp_count_comments', array(), $post_id); |
|
| 1114 | + if ( ! empty($filtered)) { |
|
| 1115 | 1115 | return $filtered; |
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | - $count = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
| 1119 | - if ( false !== $count ) { |
|
| 1118 | + $count = wp_cache_get("comments-{$post_id}", 'counts'); |
|
| 1119 | + if (false !== $count) { |
|
| 1120 | 1120 | return $count; |
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | - $stats = get_comment_count( $post_id ); |
|
| 1123 | + $stats = get_comment_count($post_id); |
|
| 1124 | 1124 | $stats['moderated'] = $stats['awaiting_moderation']; |
| 1125 | - unset( $stats['awaiting_moderation'] ); |
|
| 1125 | + unset($stats['awaiting_moderation']); |
|
| 1126 | 1126 | |
| 1127 | 1127 | $stats_object = (object) $stats; |
| 1128 | - wp_cache_set( "comments-{$post_id}", $stats_object, 'counts' ); |
|
| 1128 | + wp_cache_set("comments-{$post_id}", $stats_object, 'counts'); |
|
| 1129 | 1129 | |
| 1130 | 1130 | return $stats_object; |
| 1131 | 1131 | } |
@@ -1149,10 +1149,10 @@ discard block |
||
| 1149 | 1149 | */ |
| 1150 | 1150 | function wp_delete_comment($comment_id, $force_delete = false) { |
| 1151 | 1151 | global $wpdb; |
| 1152 | - if (!$comment = get_comment($comment_id)) |
|
| 1152 | + if ( ! $comment = get_comment($comment_id)) |
|
| 1153 | 1153 | return false; |
| 1154 | 1154 | |
| 1155 | - if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) |
|
| 1155 | + if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array(wp_get_comment_status($comment), array('trash', 'spam'))) |
|
| 1156 | 1156 | return wp_trash_comment($comment_id); |
| 1157 | 1157 | |
| 1158 | 1158 | /** |
@@ -1162,21 +1162,21 @@ discard block |
||
| 1162 | 1162 | * |
| 1163 | 1163 | * @param int $comment_id The comment ID. |
| 1164 | 1164 | */ |
| 1165 | - do_action( 'delete_comment', $comment->comment_ID ); |
|
| 1165 | + do_action('delete_comment', $comment->comment_ID); |
|
| 1166 | 1166 | |
| 1167 | 1167 | // Move children up a level. |
| 1168 | - $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID) ); |
|
| 1169 | - if ( !empty($children) ) { |
|
| 1168 | + $children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID)); |
|
| 1169 | + if ( ! empty($children)) { |
|
| 1170 | 1170 | $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment->comment_ID)); |
| 1171 | 1171 | clean_comment_cache($children); |
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | // Delete metadata |
| 1175 | - $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) ); |
|
| 1176 | - foreach ( $meta_ids as $mid ) |
|
| 1177 | - delete_metadata_by_mid( 'comment', $mid ); |
|
| 1175 | + $meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID)); |
|
| 1176 | + foreach ($meta_ids as $mid) |
|
| 1177 | + delete_metadata_by_mid('comment', $mid); |
|
| 1178 | 1178 | |
| 1179 | - if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) ) |
|
| 1179 | + if ( ! $wpdb->delete($wpdb->comments, array('comment_ID' => $comment->comment_ID))) |
|
| 1180 | 1180 | return false; |
| 1181 | 1181 | |
| 1182 | 1182 | /** |
@@ -1186,16 +1186,16 @@ discard block |
||
| 1186 | 1186 | * |
| 1187 | 1187 | * @param int $comment_id The comment ID. |
| 1188 | 1188 | */ |
| 1189 | - do_action( 'deleted_comment', $comment->comment_ID ); |
|
| 1189 | + do_action('deleted_comment', $comment->comment_ID); |
|
| 1190 | 1190 | |
| 1191 | 1191 | $post_id = $comment->comment_post_ID; |
| 1192 | - if ( $post_id && $comment->comment_approved == 1 ) |
|
| 1192 | + if ($post_id && $comment->comment_approved == 1) |
|
| 1193 | 1193 | wp_update_comment_count($post_id); |
| 1194 | 1194 | |
| 1195 | - clean_comment_cache( $comment->comment_ID ); |
|
| 1195 | + clean_comment_cache($comment->comment_ID); |
|
| 1196 | 1196 | |
| 1197 | 1197 | /** This action is documented in wp-includes/comment.php */ |
| 1198 | - do_action( 'wp_set_comment_status', $comment->comment_ID, 'delete' ); |
|
| 1198 | + do_action('wp_set_comment_status', $comment->comment_ID, 'delete'); |
|
| 1199 | 1199 | |
| 1200 | 1200 | wp_transition_comment_status('delete', $comment->comment_approved, $comment); |
| 1201 | 1201 | return true; |
@@ -1212,10 +1212,10 @@ discard block |
||
| 1212 | 1212 | * @return bool True on success, false on failure. |
| 1213 | 1213 | */ |
| 1214 | 1214 | function wp_trash_comment($comment_id) { |
| 1215 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 1215 | + if ( ! EMPTY_TRASH_DAYS) |
|
| 1216 | 1216 | return wp_delete_comment($comment_id, true); |
| 1217 | 1217 | |
| 1218 | - if ( !$comment = get_comment($comment_id) ) |
|
| 1218 | + if ( ! $comment = get_comment($comment_id)) |
|
| 1219 | 1219 | return false; |
| 1220 | 1220 | |
| 1221 | 1221 | /** |
@@ -1225,13 +1225,13 @@ discard block |
||
| 1225 | 1225 | * |
| 1226 | 1226 | * @param int $comment_id The comment ID. |
| 1227 | 1227 | */ |
| 1228 | - do_action( 'trash_comment', $comment->comment_ID ); |
|
| 1228 | + do_action('trash_comment', $comment->comment_ID); |
|
| 1229 | 1229 | |
| 1230 | - if ( wp_set_comment_status( $comment, 'trash' ) ) { |
|
| 1231 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); |
|
| 1232 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); |
|
| 1233 | - add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved ); |
|
| 1234 | - add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() ); |
|
| 1230 | + if (wp_set_comment_status($comment, 'trash')) { |
|
| 1231 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status'); |
|
| 1232 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time'); |
|
| 1233 | + add_comment_meta($comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved); |
|
| 1234 | + add_comment_meta($comment->comment_ID, '_wp_trash_meta_time', time()); |
|
| 1235 | 1235 | |
| 1236 | 1236 | /** |
| 1237 | 1237 | * Fires immediately after a comment is sent to Trash. |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | * |
| 1241 | 1241 | * @param int $comment_id The comment ID. |
| 1242 | 1242 | */ |
| 1243 | - do_action( 'trashed_comment', $comment->comment_ID ); |
|
| 1243 | + do_action('trashed_comment', $comment->comment_ID); |
|
| 1244 | 1244 | return true; |
| 1245 | 1245 | } |
| 1246 | 1246 | |
@@ -1256,8 +1256,8 @@ discard block |
||
| 1256 | 1256 | * @return bool True on success, false on failure. |
| 1257 | 1257 | */ |
| 1258 | 1258 | function wp_untrash_comment($comment_id) { |
| 1259 | - $comment = get_comment( $comment_id ); |
|
| 1260 | - if ( ! $comment ) { |
|
| 1259 | + $comment = get_comment($comment_id); |
|
| 1260 | + if ( ! $comment) { |
|
| 1261 | 1261 | return false; |
| 1262 | 1262 | } |
| 1263 | 1263 | |
@@ -1268,15 +1268,15 @@ discard block |
||
| 1268 | 1268 | * |
| 1269 | 1269 | * @param int $comment_id The comment ID. |
| 1270 | 1270 | */ |
| 1271 | - do_action( 'untrash_comment', $comment->comment_ID ); |
|
| 1271 | + do_action('untrash_comment', $comment->comment_ID); |
|
| 1272 | 1272 | |
| 1273 | - $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); |
|
| 1274 | - if ( empty($status) ) |
|
| 1273 | + $status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true); |
|
| 1274 | + if (empty($status)) |
|
| 1275 | 1275 | $status = '0'; |
| 1276 | 1276 | |
| 1277 | - if ( wp_set_comment_status( $comment, $status ) ) { |
|
| 1278 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); |
|
| 1279 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); |
|
| 1277 | + if (wp_set_comment_status($comment, $status)) { |
|
| 1278 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time'); |
|
| 1279 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status'); |
|
| 1280 | 1280 | /** |
| 1281 | 1281 | * Fires immediately after a comment is restored from the Trash. |
| 1282 | 1282 | * |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | * |
| 1285 | 1285 | * @param int $comment_id The comment ID. |
| 1286 | 1286 | */ |
| 1287 | - do_action( 'untrashed_comment', $comment->comment_ID ); |
|
| 1287 | + do_action('untrashed_comment', $comment->comment_ID); |
|
| 1288 | 1288 | return true; |
| 1289 | 1289 | } |
| 1290 | 1290 | |
@@ -1299,9 +1299,9 @@ discard block |
||
| 1299 | 1299 | * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. |
| 1300 | 1300 | * @return bool True on success, false on failure. |
| 1301 | 1301 | */ |
| 1302 | -function wp_spam_comment( $comment_id ) { |
|
| 1303 | - $comment = get_comment( $comment_id ); |
|
| 1304 | - if ( ! $comment ) { |
|
| 1302 | +function wp_spam_comment($comment_id) { |
|
| 1303 | + $comment = get_comment($comment_id); |
|
| 1304 | + if ( ! $comment) { |
|
| 1305 | 1305 | return false; |
| 1306 | 1306 | } |
| 1307 | 1307 | |
@@ -1312,13 +1312,13 @@ discard block |
||
| 1312 | 1312 | * |
| 1313 | 1313 | * @param int $comment_id The comment ID. |
| 1314 | 1314 | */ |
| 1315 | - do_action( 'spam_comment', $comment->comment_ID ); |
|
| 1315 | + do_action('spam_comment', $comment->comment_ID); |
|
| 1316 | 1316 | |
| 1317 | - if ( wp_set_comment_status( $comment, 'spam' ) ) { |
|
| 1318 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); |
|
| 1319 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); |
|
| 1320 | - add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved ); |
|
| 1321 | - add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() ); |
|
| 1317 | + if (wp_set_comment_status($comment, 'spam')) { |
|
| 1318 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status'); |
|
| 1319 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time'); |
|
| 1320 | + add_comment_meta($comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved); |
|
| 1321 | + add_comment_meta($comment->comment_ID, '_wp_trash_meta_time', time()); |
|
| 1322 | 1322 | /** |
| 1323 | 1323 | * Fires immediately after a comment is marked as Spam. |
| 1324 | 1324 | * |
@@ -1326,7 +1326,7 @@ discard block |
||
| 1326 | 1326 | * |
| 1327 | 1327 | * @param int $comment_id The comment ID. |
| 1328 | 1328 | */ |
| 1329 | - do_action( 'spammed_comment', $comment->comment_ID ); |
|
| 1329 | + do_action('spammed_comment', $comment->comment_ID); |
|
| 1330 | 1330 | return true; |
| 1331 | 1331 | } |
| 1332 | 1332 | |
@@ -1341,9 +1341,9 @@ discard block |
||
| 1341 | 1341 | * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. |
| 1342 | 1342 | * @return bool True on success, false on failure. |
| 1343 | 1343 | */ |
| 1344 | -function wp_unspam_comment( $comment_id ) { |
|
| 1345 | - $comment = get_comment( $comment_id ); |
|
| 1346 | - if ( ! $comment ) { |
|
| 1344 | +function wp_unspam_comment($comment_id) { |
|
| 1345 | + $comment = get_comment($comment_id); |
|
| 1346 | + if ( ! $comment) { |
|
| 1347 | 1347 | return false; |
| 1348 | 1348 | } |
| 1349 | 1349 | |
@@ -1354,15 +1354,15 @@ discard block |
||
| 1354 | 1354 | * |
| 1355 | 1355 | * @param int $comment_id The comment ID. |
| 1356 | 1356 | */ |
| 1357 | - do_action( 'unspam_comment', $comment->comment_ID ); |
|
| 1357 | + do_action('unspam_comment', $comment->comment_ID); |
|
| 1358 | 1358 | |
| 1359 | - $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); |
|
| 1360 | - if ( empty($status) ) |
|
| 1359 | + $status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true); |
|
| 1360 | + if (empty($status)) |
|
| 1361 | 1361 | $status = '0'; |
| 1362 | 1362 | |
| 1363 | - if ( wp_set_comment_status( $comment, $status ) ) { |
|
| 1364 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); |
|
| 1365 | - delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); |
|
| 1363 | + if (wp_set_comment_status($comment, $status)) { |
|
| 1364 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status'); |
|
| 1365 | + delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time'); |
|
| 1366 | 1366 | /** |
| 1367 | 1367 | * Fires immediately after a comment is unmarked as Spam. |
| 1368 | 1368 | * |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | * |
| 1371 | 1371 | * @param int $comment_id The comment ID. |
| 1372 | 1372 | */ |
| 1373 | - do_action( 'unspammed_comment', $comment->comment_ID ); |
|
| 1373 | + do_action('unspammed_comment', $comment->comment_ID); |
|
| 1374 | 1374 | return true; |
| 1375 | 1375 | } |
| 1376 | 1376 | |
@@ -1387,20 +1387,20 @@ discard block |
||
| 1387 | 1387 | */ |
| 1388 | 1388 | function wp_get_comment_status($comment_id) { |
| 1389 | 1389 | $comment = get_comment($comment_id); |
| 1390 | - if ( !$comment ) |
|
| 1390 | + if ( ! $comment) |
|
| 1391 | 1391 | return false; |
| 1392 | 1392 | |
| 1393 | 1393 | $approved = $comment->comment_approved; |
| 1394 | 1394 | |
| 1395 | - if ( $approved == null ) |
|
| 1395 | + if ($approved == null) |
|
| 1396 | 1396 | return false; |
| 1397 | - elseif ( $approved == '1' ) |
|
| 1397 | + elseif ($approved == '1') |
|
| 1398 | 1398 | return 'approved'; |
| 1399 | - elseif ( $approved == '0' ) |
|
| 1399 | + elseif ($approved == '0') |
|
| 1400 | 1400 | return 'unapproved'; |
| 1401 | - elseif ( $approved == 'spam' ) |
|
| 1401 | + elseif ($approved == 'spam') |
|
| 1402 | 1402 | return 'spam'; |
| 1403 | - elseif ( $approved == 'trash' ) |
|
| 1403 | + elseif ($approved == 'trash') |
|
| 1404 | 1404 | return 'trash'; |
| 1405 | 1405 | else |
| 1406 | 1406 | return false; |
@@ -1438,11 +1438,11 @@ discard block |
||
| 1438 | 1438 | 1 => 'approved', |
| 1439 | 1439 | 'approve' => 'approved', // wp_set_comment_status() uses "approve" |
| 1440 | 1440 | ); |
| 1441 | - if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status]; |
|
| 1442 | - if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status]; |
|
| 1441 | + if (isset($comment_statuses[$new_status])) $new_status = $comment_statuses[$new_status]; |
|
| 1442 | + if (isset($comment_statuses[$old_status])) $old_status = $comment_statuses[$old_status]; |
|
| 1443 | 1443 | |
| 1444 | 1444 | // Call the hooks |
| 1445 | - if ( $new_status != $old_status ) { |
|
| 1445 | + if ($new_status != $old_status) { |
|
| 1446 | 1446 | /** |
| 1447 | 1447 | * Fires when the comment status is in transition. |
| 1448 | 1448 | * |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | * @param int|string $old_status The old comment status. |
| 1453 | 1453 | * @param object $comment The comment data. |
| 1454 | 1454 | */ |
| 1455 | - do_action( 'transition_comment_status', $new_status, $old_status, $comment ); |
|
| 1455 | + do_action('transition_comment_status', $new_status, $old_status, $comment); |
|
| 1456 | 1456 | /** |
| 1457 | 1457 | * Fires when the comment status is in transition from one specific status to another. |
| 1458 | 1458 | * |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | * |
| 1464 | 1464 | * @param WP_Comment $comment Comment object. |
| 1465 | 1465 | */ |
| 1466 | - do_action( "comment_{$old_status}_to_{$new_status}", $comment ); |
|
| 1466 | + do_action("comment_{$old_status}_to_{$new_status}", $comment); |
|
| 1467 | 1467 | } |
| 1468 | 1468 | /** |
| 1469 | 1469 | * Fires when the status of a specific comment type is in transition. |
@@ -1479,7 +1479,7 @@ discard block |
||
| 1479 | 1479 | * @param int $comment_ID The comment ID. |
| 1480 | 1480 | * @param WP_Comment $comment Comment object. |
| 1481 | 1481 | */ |
| 1482 | - do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment ); |
|
| 1482 | + do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment); |
|
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | /** |
@@ -1498,15 +1498,15 @@ discard block |
||
| 1498 | 1498 | // Cookies should already be sanitized. |
| 1499 | 1499 | |
| 1500 | 1500 | $comment_author = ''; |
| 1501 | - if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) |
|
| 1501 | + if (isset($_COOKIE['comment_author_'.COOKIEHASH])) |
|
| 1502 | 1502 | $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; |
| 1503 | 1503 | |
| 1504 | 1504 | $comment_author_email = ''; |
| 1505 | - if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) |
|
| 1505 | + if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) |
|
| 1506 | 1506 | $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; |
| 1507 | 1507 | |
| 1508 | 1508 | $comment_author_url = ''; |
| 1509 | - if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) |
|
| 1509 | + if (isset($_COOKIE['comment_author_url_'.COOKIEHASH])) |
|
| 1510 | 1510 | $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; |
| 1511 | 1511 | |
| 1512 | 1512 | /** |
@@ -1522,7 +1522,7 @@ discard block |
||
| 1522 | 1522 | * @type string $comment_author_url The URL address of the `$comment_author`. Default empty. |
| 1523 | 1523 | * } |
| 1524 | 1524 | */ |
| 1525 | - return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') ); |
|
| 1525 | + return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url')); |
|
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | 1528 | /** |
@@ -1560,44 +1560,44 @@ discard block |
||
| 1560 | 1560 | * } |
| 1561 | 1561 | * @return int|false The new comment's ID on success, false on failure. |
| 1562 | 1562 | */ |
| 1563 | -function wp_insert_comment( $commentdata ) { |
|
| 1563 | +function wp_insert_comment($commentdata) { |
|
| 1564 | 1564 | global $wpdb; |
| 1565 | - $data = wp_unslash( $commentdata ); |
|
| 1565 | + $data = wp_unslash($commentdata); |
|
| 1566 | 1566 | |
| 1567 | - $comment_author = ! isset( $data['comment_author'] ) ? '' : $data['comment_author']; |
|
| 1568 | - $comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email']; |
|
| 1569 | - $comment_author_url = ! isset( $data['comment_author_url'] ) ? '' : $data['comment_author_url']; |
|
| 1570 | - $comment_author_IP = ! isset( $data['comment_author_IP'] ) ? '' : $data['comment_author_IP']; |
|
| 1567 | + $comment_author = ! isset($data['comment_author']) ? '' : $data['comment_author']; |
|
| 1568 | + $comment_author_email = ! isset($data['comment_author_email']) ? '' : $data['comment_author_email']; |
|
| 1569 | + $comment_author_url = ! isset($data['comment_author_url']) ? '' : $data['comment_author_url']; |
|
| 1570 | + $comment_author_IP = ! isset($data['comment_author_IP']) ? '' : $data['comment_author_IP']; |
|
| 1571 | 1571 | |
| 1572 | - $comment_date = ! isset( $data['comment_date'] ) ? current_time( 'mysql' ) : $data['comment_date']; |
|
| 1573 | - $comment_date_gmt = ! isset( $data['comment_date_gmt'] ) ? get_gmt_from_date( $comment_date ) : $data['comment_date_gmt']; |
|
| 1572 | + $comment_date = ! isset($data['comment_date']) ? current_time('mysql') : $data['comment_date']; |
|
| 1573 | + $comment_date_gmt = ! isset($data['comment_date_gmt']) ? get_gmt_from_date($comment_date) : $data['comment_date_gmt']; |
|
| 1574 | 1574 | |
| 1575 | - $comment_post_ID = ! isset( $data['comment_post_ID'] ) ? 0 : $data['comment_post_ID']; |
|
| 1576 | - $comment_content = ! isset( $data['comment_content'] ) ? '' : $data['comment_content']; |
|
| 1577 | - $comment_karma = ! isset( $data['comment_karma'] ) ? 0 : $data['comment_karma']; |
|
| 1578 | - $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved']; |
|
| 1579 | - $comment_agent = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent']; |
|
| 1580 | - $comment_type = ! isset( $data['comment_type'] ) ? '' : $data['comment_type']; |
|
| 1581 | - $comment_parent = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent']; |
|
| 1575 | + $comment_post_ID = ! isset($data['comment_post_ID']) ? 0 : $data['comment_post_ID']; |
|
| 1576 | + $comment_content = ! isset($data['comment_content']) ? '' : $data['comment_content']; |
|
| 1577 | + $comment_karma = ! isset($data['comment_karma']) ? 0 : $data['comment_karma']; |
|
| 1578 | + $comment_approved = ! isset($data['comment_approved']) ? 1 : $data['comment_approved']; |
|
| 1579 | + $comment_agent = ! isset($data['comment_agent']) ? '' : $data['comment_agent']; |
|
| 1580 | + $comment_type = ! isset($data['comment_type']) ? '' : $data['comment_type']; |
|
| 1581 | + $comment_parent = ! isset($data['comment_parent']) ? 0 : $data['comment_parent']; |
|
| 1582 | 1582 | |
| 1583 | - $user_id = ! isset( $data['user_id'] ) ? 0 : $data['user_id']; |
|
| 1583 | + $user_id = ! isset($data['user_id']) ? 0 : $data['user_id']; |
|
| 1584 | 1584 | |
| 1585 | - $compacted = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id' ); |
|
| 1586 | - if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) { |
|
| 1585 | + $compacted = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id'); |
|
| 1586 | + if ( ! $wpdb->insert($wpdb->comments, $compacted)) { |
|
| 1587 | 1587 | return false; |
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | 1590 | $id = (int) $wpdb->insert_id; |
| 1591 | 1591 | |
| 1592 | - if ( $comment_approved == 1 ) { |
|
| 1593 | - wp_update_comment_count( $comment_post_ID ); |
|
| 1592 | + if ($comment_approved == 1) { |
|
| 1593 | + wp_update_comment_count($comment_post_ID); |
|
| 1594 | 1594 | } |
| 1595 | - $comment = get_comment( $id ); |
|
| 1595 | + $comment = get_comment($id); |
|
| 1596 | 1596 | |
| 1597 | 1597 | // If metadata is provided, store it. |
| 1598 | - if ( isset( $commentdata['comment_meta'] ) && is_array( $commentdata['comment_meta'] ) ) { |
|
| 1599 | - foreach ( $commentdata['comment_meta'] as $meta_key => $meta_value ) { |
|
| 1600 | - add_comment_meta( $comment->comment_ID, $meta_key, $meta_value, true ); |
|
| 1598 | + if (isset($commentdata['comment_meta']) && is_array($commentdata['comment_meta'])) { |
|
| 1599 | + foreach ($commentdata['comment_meta'] as $meta_key => $meta_value) { |
|
| 1600 | + add_comment_meta($comment->comment_ID, $meta_key, $meta_value, true); |
|
| 1601 | 1601 | } |
| 1602 | 1602 | } |
| 1603 | 1603 | |
@@ -1609,9 +1609,9 @@ discard block |
||
| 1609 | 1609 | * @param int $id The comment ID. |
| 1610 | 1610 | * @param WP_Comment $comment Comment object. |
| 1611 | 1611 | */ |
| 1612 | - do_action( 'wp_insert_comment', $id, $comment ); |
|
| 1612 | + do_action('wp_insert_comment', $id, $comment); |
|
| 1613 | 1613 | |
| 1614 | - wp_cache_set( 'last_changed', microtime(), 'comment' ); |
|
| 1614 | + wp_cache_set('last_changed', microtime(), 'comment'); |
|
| 1615 | 1615 | |
| 1616 | 1616 | return $id; |
| 1617 | 1617 | } |
@@ -1629,7 +1629,7 @@ discard block |
||
| 1629 | 1629 | * @return array Parsed comment information. |
| 1630 | 1630 | */ |
| 1631 | 1631 | function wp_filter_comment($commentdata) { |
| 1632 | - if ( isset( $commentdata['user_ID'] ) ) { |
|
| 1632 | + if (isset($commentdata['user_ID'])) { |
|
| 1633 | 1633 | /** |
| 1634 | 1634 | * Filter the comment author's user id before it is set. |
| 1635 | 1635 | * |
@@ -1640,10 +1640,10 @@ discard block |
||
| 1640 | 1640 | * |
| 1641 | 1641 | * @param int $user_ID The comment author's user ID. |
| 1642 | 1642 | */ |
| 1643 | - $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] ); |
|
| 1644 | - } elseif ( isset( $commentdata['user_id'] ) ) { |
|
| 1643 | + $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); |
|
| 1644 | + } elseif (isset($commentdata['user_id'])) { |
|
| 1645 | 1645 | /** This filter is documented in wp-includes/comment.php */ |
| 1646 | - $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] ); |
|
| 1646 | + $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_id']); |
|
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | 1649 | /** |
@@ -1653,9 +1653,9 @@ discard block |
||
| 1653 | 1653 | * |
| 1654 | 1654 | * @param string $comment_agent The comment author's browser user agent. |
| 1655 | 1655 | */ |
| 1656 | - $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) ); |
|
| 1656 | + $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', (isset($commentdata['comment_agent']) ? $commentdata['comment_agent'] : '')); |
|
| 1657 | 1657 | /** This filter is documented in wp-includes/comment.php */ |
| 1658 | - $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] ); |
|
| 1658 | + $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']); |
|
| 1659 | 1659 | /** |
| 1660 | 1660 | * Filter the comment content before it is set. |
| 1661 | 1661 | * |
@@ -1663,7 +1663,7 @@ discard block |
||
| 1663 | 1663 | * |
| 1664 | 1664 | * @param string $comment_content The comment content. |
| 1665 | 1665 | */ |
| 1666 | - $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] ); |
|
| 1666 | + $commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']); |
|
| 1667 | 1667 | /** |
| 1668 | 1668 | * Filter the comment author's IP before it is set. |
| 1669 | 1669 | * |
@@ -1671,11 +1671,11 @@ discard block |
||
| 1671 | 1671 | * |
| 1672 | 1672 | * @param string $comment_author_ip The comment author's IP. |
| 1673 | 1673 | */ |
| 1674 | - $commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] ); |
|
| 1674 | + $commentdata['comment_author_IP'] = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']); |
|
| 1675 | 1675 | /** This filter is documented in wp-includes/comment.php */ |
| 1676 | - $commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] ); |
|
| 1676 | + $commentdata['comment_author_url'] = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']); |
|
| 1677 | 1677 | /** This filter is documented in wp-includes/comment.php */ |
| 1678 | - $commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] ); |
|
| 1678 | + $commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']); |
|
| 1679 | 1679 | $commentdata['filtered'] = true; |
| 1680 | 1680 | return $commentdata; |
| 1681 | 1681 | } |
@@ -1691,9 +1691,9 @@ discard block |
||
| 1691 | 1691 | * @return bool Whether comment should be blocked. |
| 1692 | 1692 | */ |
| 1693 | 1693 | function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { |
| 1694 | - if ( $block ) // a plugin has already blocked... we'll let that decision stand |
|
| 1694 | + if ($block) // a plugin has already blocked... we'll let that decision stand |
|
| 1695 | 1695 | return $block; |
| 1696 | - if ( ($time_newcomment - $time_lastcomment) < 15 ) |
|
| 1696 | + if (($time_newcomment - $time_lastcomment) < 15) |
|
| 1697 | 1697 | return true; |
| 1698 | 1698 | return false; |
| 1699 | 1699 | } |
@@ -1737,14 +1737,14 @@ discard block |
||
| 1737 | 1737 | * } |
| 1738 | 1738 | * @return int|false The ID of the comment on success, false on failure. |
| 1739 | 1739 | */ |
| 1740 | -function wp_new_comment( $commentdata ) { |
|
| 1740 | +function wp_new_comment($commentdata) { |
|
| 1741 | 1741 | global $wpdb; |
| 1742 | 1742 | |
| 1743 | - if ( isset( $commentdata['user_ID'] ) ) { |
|
| 1743 | + if (isset($commentdata['user_ID'])) { |
|
| 1744 | 1744 | $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; |
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | - $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0; |
|
| 1747 | + $prefiltered_user_id = (isset($commentdata['user_id'])) ? (int) $commentdata['user_id'] : 0; |
|
| 1748 | 1748 | |
| 1749 | 1749 | /** |
| 1750 | 1750 | * Filter a comment's data before it is sanitized and inserted into the database. |
@@ -1753,35 +1753,35 @@ discard block |
||
| 1753 | 1753 | * |
| 1754 | 1754 | * @param array $commentdata Comment data. |
| 1755 | 1755 | */ |
| 1756 | - $commentdata = apply_filters( 'preprocess_comment', $commentdata ); |
|
| 1756 | + $commentdata = apply_filters('preprocess_comment', $commentdata); |
|
| 1757 | 1757 | |
| 1758 | 1758 | $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; |
| 1759 | - if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) { |
|
| 1759 | + if (isset($commentdata['user_ID']) && $prefiltered_user_id !== (int) $commentdata['user_ID']) { |
|
| 1760 | 1760 | $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; |
| 1761 | - } elseif ( isset( $commentdata['user_id'] ) ) { |
|
| 1761 | + } elseif (isset($commentdata['user_id'])) { |
|
| 1762 | 1762 | $commentdata['user_id'] = (int) $commentdata['user_id']; |
| 1763 | 1763 | } |
| 1764 | 1764 | |
| 1765 | 1765 | $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0; |
| 1766 | - $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : ''; |
|
| 1767 | - $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; |
|
| 1766 | + $parent_status = (0 < $commentdata['comment_parent']) ? wp_get_comment_status($commentdata['comment_parent']) : ''; |
|
| 1767 | + $commentdata['comment_parent'] = ('approved' == $parent_status || 'unapproved' == $parent_status) ? $commentdata['comment_parent'] : 0; |
|
| 1768 | 1768 | |
| 1769 | - if ( ! isset( $commentdata['comment_author_IP'] ) ) { |
|
| 1769 | + if ( ! isset($commentdata['comment_author_IP'])) { |
|
| 1770 | 1770 | $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; |
| 1771 | 1771 | } |
| 1772 | - $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] ); |
|
| 1772 | + $commentdata['comment_author_IP'] = preg_replace('/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP']); |
|
| 1773 | 1773 | |
| 1774 | - if ( ! isset( $commentdata['comment_agent'] ) ) { |
|
| 1775 | - $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT']: ''; |
|
| 1774 | + if ( ! isset($commentdata['comment_agent'])) { |
|
| 1775 | + $commentdata['comment_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 1776 | 1776 | } |
| 1777 | - $commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 ); |
|
| 1777 | + $commentdata['comment_agent'] = substr($commentdata['comment_agent'], 0, 254); |
|
| 1778 | 1778 | |
| 1779 | - if ( empty( $commentdata['comment_date'] ) ) { |
|
| 1779 | + if (empty($commentdata['comment_date'])) { |
|
| 1780 | 1780 | $commentdata['comment_date'] = current_time('mysql'); |
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | - if ( empty( $commentdata['comment_date_gmt'] ) ) { |
|
| 1784 | - $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 ); |
|
| 1783 | + if (empty($commentdata['comment_date_gmt'])) { |
|
| 1784 | + $commentdata['comment_date_gmt'] = current_time('mysql', 1); |
|
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | $commentdata = wp_filter_comment($commentdata); |
@@ -1789,21 +1789,21 @@ discard block |
||
| 1789 | 1789 | $commentdata['comment_approved'] = wp_allow_comment($commentdata); |
| 1790 | 1790 | |
| 1791 | 1791 | $comment_ID = wp_insert_comment($commentdata); |
| 1792 | - if ( ! $comment_ID ) { |
|
| 1793 | - $fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' ); |
|
| 1792 | + if ( ! $comment_ID) { |
|
| 1793 | + $fields = array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_content'); |
|
| 1794 | 1794 | |
| 1795 | - foreach ( $fields as $field ) { |
|
| 1796 | - if ( isset( $commentdata[ $field ] ) ) { |
|
| 1797 | - $commentdata[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $commentdata[ $field ] ); |
|
| 1795 | + foreach ($fields as $field) { |
|
| 1796 | + if (isset($commentdata[$field])) { |
|
| 1797 | + $commentdata[$field] = $wpdb->strip_invalid_text_for_column($wpdb->comments, $field, $commentdata[$field]); |
|
| 1798 | 1798 | } |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | - $commentdata = wp_filter_comment( $commentdata ); |
|
| 1801 | + $commentdata = wp_filter_comment($commentdata); |
|
| 1802 | 1802 | |
| 1803 | - $commentdata['comment_approved'] = wp_allow_comment( $commentdata ); |
|
| 1803 | + $commentdata['comment_approved'] = wp_allow_comment($commentdata); |
|
| 1804 | 1804 | |
| 1805 | - $comment_ID = wp_insert_comment( $commentdata ); |
|
| 1806 | - if ( ! $comment_ID ) { |
|
| 1805 | + $comment_ID = wp_insert_comment($commentdata); |
|
| 1806 | + if ( ! $comment_ID) { |
|
| 1807 | 1807 | return false; |
| 1808 | 1808 | } |
| 1809 | 1809 | } |
@@ -1818,7 +1818,7 @@ discard block |
||
| 1818 | 1818 | * @param int|string $comment_approved 1 if the comment is approved, 0 if not, 'spam' if spam. |
| 1819 | 1819 | * @param array $commentdata Comment data. |
| 1820 | 1820 | */ |
| 1821 | - do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata ); |
|
| 1821 | + do_action('comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata); |
|
| 1822 | 1822 | |
| 1823 | 1823 | return $comment_ID; |
| 1824 | 1824 | } |
@@ -1831,20 +1831,20 @@ discard block |
||
| 1831 | 1831 | * @param int $comment_ID ID of the comment. |
| 1832 | 1832 | * @return bool True on success, false on failure. |
| 1833 | 1833 | */ |
| 1834 | -function wp_new_comment_notify_moderator( $comment_ID ) { |
|
| 1835 | - $comment = get_comment( $comment_ID ); |
|
| 1834 | +function wp_new_comment_notify_moderator($comment_ID) { |
|
| 1835 | + $comment = get_comment($comment_ID); |
|
| 1836 | 1836 | |
| 1837 | 1837 | // Only send notifications for pending comments. |
| 1838 | - $maybe_notify = ( '0' == $comment->comment_approved ); |
|
| 1838 | + $maybe_notify = ('0' == $comment->comment_approved); |
|
| 1839 | 1839 | |
| 1840 | 1840 | /** This filter is documented in wp-includes/comment.php */ |
| 1841 | - $maybe_notify = apply_filters( 'notify_moderator', $maybe_notify, $comment_ID ); |
|
| 1841 | + $maybe_notify = apply_filters('notify_moderator', $maybe_notify, $comment_ID); |
|
| 1842 | 1842 | |
| 1843 | - if ( ! $maybe_notify ) { |
|
| 1843 | + if ( ! $maybe_notify) { |
|
| 1844 | 1844 | return false; |
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | - return wp_notify_moderator( $comment_ID ); |
|
| 1847 | + return wp_notify_moderator($comment_ID); |
|
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | 1850 | /** |
@@ -1858,10 +1858,10 @@ discard block |
||
| 1858 | 1858 | * @param int $comment_ID Comment ID. |
| 1859 | 1859 | * @return bool True on success, false on failure. |
| 1860 | 1860 | */ |
| 1861 | -function wp_new_comment_notify_postauthor( $comment_ID ) { |
|
| 1862 | - $comment = get_comment( $comment_ID ); |
|
| 1861 | +function wp_new_comment_notify_postauthor($comment_ID) { |
|
| 1862 | + $comment = get_comment($comment_ID); |
|
| 1863 | 1863 | |
| 1864 | - $maybe_notify = get_option( 'comments_notify' ); |
|
| 1864 | + $maybe_notify = get_option('comments_notify'); |
|
| 1865 | 1865 | |
| 1866 | 1866 | /** |
| 1867 | 1867 | * Filter whether to send the post author new comment notification emails, |
@@ -1872,22 +1872,22 @@ discard block |
||
| 1872 | 1872 | * @param bool $maybe_notify Whether to notify the post author about the new comment. |
| 1873 | 1873 | * @param int $comment_ID The ID of the comment for the notification. |
| 1874 | 1874 | */ |
| 1875 | - $maybe_notify = apply_filters( 'notify_post_author', $maybe_notify, $comment_ID ); |
|
| 1875 | + $maybe_notify = apply_filters('notify_post_author', $maybe_notify, $comment_ID); |
|
| 1876 | 1876 | |
| 1877 | 1877 | /* |
| 1878 | 1878 | * wp_notify_postauthor() checks if notifying the author of their own comment. |
| 1879 | 1879 | * By default, it won't, but filters can override this. |
| 1880 | 1880 | */ |
| 1881 | - if ( ! $maybe_notify ) { |
|
| 1881 | + if ( ! $maybe_notify) { |
|
| 1882 | 1882 | return false; |
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | 1885 | // Only send notifications for approved comments. |
| 1886 | - if ( ! isset( $comment->comment_approved ) || '1' != $comment->comment_approved ) { |
|
| 1886 | + if ( ! isset($comment->comment_approved) || '1' != $comment->comment_approved) { |
|
| 1887 | 1887 | return false; |
| 1888 | 1888 | } |
| 1889 | 1889 | |
| 1890 | - return wp_notify_postauthor( $comment_ID ); |
|
| 1890 | + return wp_notify_postauthor($comment_ID); |
|
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | /** |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { |
| 1909 | 1909 | global $wpdb; |
| 1910 | 1910 | |
| 1911 | - switch ( $comment_status ) { |
|
| 1911 | + switch ($comment_status) { |
|
| 1912 | 1912 | case 'hold': |
| 1913 | 1913 | case '0': |
| 1914 | 1914 | $status = '0'; |
@@ -1916,7 +1916,7 @@ discard block |
||
| 1916 | 1916 | case 'approve': |
| 1917 | 1917 | case '1': |
| 1918 | 1918 | $status = '1'; |
| 1919 | - add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' ); |
|
| 1919 | + add_action('wp_set_comment_status', 'wp_new_comment_notify_postauthor'); |
|
| 1920 | 1920 | break; |
| 1921 | 1921 | case 'spam': |
| 1922 | 1922 | $status = 'spam'; |
@@ -1930,16 +1930,16 @@ discard block |
||
| 1930 | 1930 | |
| 1931 | 1931 | $comment_old = clone get_comment($comment_id); |
| 1932 | 1932 | |
| 1933 | - if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_old->comment_ID ) ) ) { |
|
| 1934 | - if ( $wp_error ) |
|
| 1933 | + if ( ! $wpdb->update($wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_old->comment_ID))) { |
|
| 1934 | + if ($wp_error) |
|
| 1935 | 1935 | return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); |
| 1936 | 1936 | else |
| 1937 | 1937 | return false; |
| 1938 | 1938 | } |
| 1939 | 1939 | |
| 1940 | - clean_comment_cache( $comment_old->comment_ID ); |
|
| 1940 | + clean_comment_cache($comment_old->comment_ID); |
|
| 1941 | 1941 | |
| 1942 | - $comment = get_comment( $comment_old->comment_ID ); |
|
| 1942 | + $comment = get_comment($comment_old->comment_ID); |
|
| 1943 | 1943 | |
| 1944 | 1944 | /** |
| 1945 | 1945 | * Fires immediately before transitioning a comment's status from one to another |
@@ -1951,7 +1951,7 @@ discard block |
||
| 1951 | 1951 | * @param string|bool $comment_status Current comment status. Possible values include |
| 1952 | 1952 | * 'hold', 'approve', 'spam', 'trash', or false. |
| 1953 | 1953 | */ |
| 1954 | - do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status ); |
|
| 1954 | + do_action('wp_set_comment_status', $comment->comment_ID, $comment_status); |
|
| 1955 | 1955 | |
| 1956 | 1956 | wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment); |
| 1957 | 1957 | |
@@ -1977,12 +1977,12 @@ discard block |
||
| 1977 | 1977 | |
| 1978 | 1978 | // First, get all of the original fields |
| 1979 | 1979 | $comment = get_comment($commentarr['comment_ID'], ARRAY_A); |
| 1980 | - if ( empty( $comment ) ) { |
|
| 1980 | + if (empty($comment)) { |
|
| 1981 | 1981 | return 0; |
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | 1984 | // Make sure that the comment post ID is valid (if specified). |
| 1985 | - if ( ! empty( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) { |
|
| 1985 | + if ( ! empty($commentarr['comment_post_ID']) && ! get_post($commentarr['comment_post_ID'])) { |
|
| 1986 | 1986 | return 0; |
| 1987 | 1987 | } |
| 1988 | 1988 | |
@@ -1994,10 +1994,10 @@ discard block |
||
| 1994 | 1994 | // Merge old and new fields with new fields overwriting old ones. |
| 1995 | 1995 | $commentarr = array_merge($comment, $commentarr); |
| 1996 | 1996 | |
| 1997 | - $commentarr = wp_filter_comment( $commentarr ); |
|
| 1997 | + $commentarr = wp_filter_comment($commentarr); |
|
| 1998 | 1998 | |
| 1999 | 1999 | // Now extract the merged array. |
| 2000 | - $data = wp_unslash( $commentarr ); |
|
| 2000 | + $data = wp_unslash($commentarr); |
|
| 2001 | 2001 | |
| 2002 | 2002 | /** |
| 2003 | 2003 | * Filter the comment content before it is updated in the database. |
@@ -2006,26 +2006,26 @@ discard block |
||
| 2006 | 2006 | * |
| 2007 | 2007 | * @param string $comment_content The comment data. |
| 2008 | 2008 | */ |
| 2009 | - $data['comment_content'] = apply_filters( 'comment_save_pre', $data['comment_content'] ); |
|
| 2009 | + $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']); |
|
| 2010 | 2010 | |
| 2011 | - $data['comment_date_gmt'] = get_gmt_from_date( $data['comment_date'] ); |
|
| 2011 | + $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']); |
|
| 2012 | 2012 | |
| 2013 | - if ( ! isset( $data['comment_approved'] ) ) { |
|
| 2013 | + if ( ! isset($data['comment_approved'])) { |
|
| 2014 | 2014 | $data['comment_approved'] = 1; |
| 2015 | - } elseif ( 'hold' == $data['comment_approved'] ) { |
|
| 2015 | + } elseif ('hold' == $data['comment_approved']) { |
|
| 2016 | 2016 | $data['comment_approved'] = 0; |
| 2017 | - } elseif ( 'approve' == $data['comment_approved'] ) { |
|
| 2017 | + } elseif ('approve' == $data['comment_approved']) { |
|
| 2018 | 2018 | $data['comment_approved'] = 1; |
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | $comment_ID = $data['comment_ID']; |
| 2022 | 2022 | $comment_post_ID = $data['comment_post_ID']; |
| 2023 | - $keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP' ); |
|
| 2024 | - $data = wp_array_slice_assoc( $data, $keys ); |
|
| 2025 | - $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); |
|
| 2023 | + $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP'); |
|
| 2024 | + $data = wp_array_slice_assoc($data, $keys); |
|
| 2025 | + $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID')); |
|
| 2026 | 2026 | |
| 2027 | - clean_comment_cache( $comment_ID ); |
|
| 2028 | - wp_update_comment_count( $comment_post_ID ); |
|
| 2027 | + clean_comment_cache($comment_ID); |
|
| 2028 | + wp_update_comment_count($comment_post_ID); |
|
| 2029 | 2029 | /** |
| 2030 | 2030 | * Fires immediately after a comment is updated in the database. |
| 2031 | 2031 | * |
@@ -2035,7 +2035,7 @@ discard block |
||
| 2035 | 2035 | * |
| 2036 | 2036 | * @param int $comment_ID The comment ID. |
| 2037 | 2037 | */ |
| 2038 | - do_action( 'edit_comment', $comment_ID ); |
|
| 2038 | + do_action('edit_comment', $comment_ID); |
|
| 2039 | 2039 | $comment = get_comment($comment_ID); |
| 2040 | 2040 | wp_transition_comment_status($comment->comment_approved, $old_status, $comment); |
| 2041 | 2041 | return $rval; |
@@ -2055,14 +2055,14 @@ discard block |
||
| 2055 | 2055 | * @param bool $defer |
| 2056 | 2056 | * @return bool |
| 2057 | 2057 | */ |
| 2058 | -function wp_defer_comment_counting($defer=null) { |
|
| 2058 | +function wp_defer_comment_counting($defer = null) { |
|
| 2059 | 2059 | static $_defer = false; |
| 2060 | 2060 | |
| 2061 | - if ( is_bool($defer) ) { |
|
| 2061 | + if (is_bool($defer)) { |
|
| 2062 | 2062 | $_defer = $defer; |
| 2063 | 2063 | // flush any deferred counts |
| 2064 | - if ( !$defer ) |
|
| 2065 | - wp_update_comment_count( null, true ); |
|
| 2064 | + if ( ! $defer) |
|
| 2065 | + wp_update_comment_count(null, true); |
|
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | 2068 | return $_defer; |
@@ -2090,26 +2090,26 @@ discard block |
||
| 2090 | 2090 | * @return bool|void True on success, false on failure or if post with ID does |
| 2091 | 2091 | * not exist. |
| 2092 | 2092 | */ |
| 2093 | -function wp_update_comment_count($post_id, $do_deferred=false) { |
|
| 2093 | +function wp_update_comment_count($post_id, $do_deferred = false) { |
|
| 2094 | 2094 | static $_deferred = array(); |
| 2095 | 2095 | |
| 2096 | - if ( empty( $post_id ) && ! $do_deferred ) { |
|
| 2096 | + if (empty($post_id) && ! $do_deferred) { |
|
| 2097 | 2097 | return false; |
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | - if ( $do_deferred ) { |
|
| 2100 | + if ($do_deferred) { |
|
| 2101 | 2101 | $_deferred = array_unique($_deferred); |
| 2102 | - foreach ( $_deferred as $i => $_post_id ) { |
|
| 2102 | + foreach ($_deferred as $i => $_post_id) { |
|
| 2103 | 2103 | wp_update_comment_count_now($_post_id); |
| 2104 | - unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */ |
|
| 2104 | + unset($_deferred[$i]); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */ |
|
| 2105 | 2105 | } |
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | - if ( wp_defer_comment_counting() ) { |
|
| 2108 | + if (wp_defer_comment_counting()) { |
|
| 2109 | 2109 | $_deferred[] = $post_id; |
| 2110 | 2110 | return true; |
| 2111 | 2111 | } |
| 2112 | - elseif ( $post_id ) { |
|
| 2112 | + elseif ($post_id) { |
|
| 2113 | 2113 | return wp_update_comment_count_now($post_id); |
| 2114 | 2114 | } |
| 2115 | 2115 | |
@@ -2128,13 +2128,13 @@ discard block |
||
| 2128 | 2128 | function wp_update_comment_count_now($post_id) { |
| 2129 | 2129 | global $wpdb; |
| 2130 | 2130 | $post_id = (int) $post_id; |
| 2131 | - if ( !$post_id ) |
|
| 2131 | + if ( ! $post_id) |
|
| 2132 | 2132 | return false; |
| 2133 | 2133 | |
| 2134 | - wp_cache_delete( 'comments-0', 'counts' ); |
|
| 2135 | - wp_cache_delete( "comments-{$post_id}", 'counts' ); |
|
| 2134 | + wp_cache_delete('comments-0', 'counts'); |
|
| 2135 | + wp_cache_delete("comments-{$post_id}", 'counts'); |
|
| 2136 | 2136 | |
| 2137 | - if ( !$post = get_post($post_id) ) |
|
| 2137 | + if ( ! $post = get_post($post_id)) |
|
| 2138 | 2138 | return false; |
| 2139 | 2139 | |
| 2140 | 2140 | $old = (int) $post->comment_count; |
@@ -2148,17 +2148,17 @@ discard block |
||
| 2148 | 2148 | * @param int $old The old comment count. |
| 2149 | 2149 | * @param int $post_id Post ID. |
| 2150 | 2150 | */ |
| 2151 | - $new = apply_filters( 'pre_wp_update_comment_count_now', null, $old, $post_id ); |
|
| 2151 | + $new = apply_filters('pre_wp_update_comment_count_now', null, $old, $post_id); |
|
| 2152 | 2152 | |
| 2153 | - if ( is_null( $new ) ) { |
|
| 2154 | - $new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id ) ); |
|
| 2153 | + if (is_null($new)) { |
|
| 2154 | + $new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id)); |
|
| 2155 | 2155 | } else { |
| 2156 | 2156 | $new = (int) $new; |
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | - $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) ); |
|
| 2159 | + $wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post_id)); |
|
| 2160 | 2160 | |
| 2161 | - clean_post_cache( $post ); |
|
| 2161 | + clean_post_cache($post); |
|
| 2162 | 2162 | |
| 2163 | 2163 | /** |
| 2164 | 2164 | * Fires immediately after a post's comment count is updated in the database. |
@@ -2169,9 +2169,9 @@ discard block |
||
| 2169 | 2169 | * @param int $new The new comment count. |
| 2170 | 2170 | * @param int $old The old comment count. |
| 2171 | 2171 | */ |
| 2172 | - do_action( 'wp_update_comment_count', $post_id, $new, $old ); |
|
| 2172 | + do_action('wp_update_comment_count', $post_id, $new, $old); |
|
| 2173 | 2173 | /** This action is documented in wp-includes/post.php */ |
| 2174 | - do_action( 'edit_post', $post_id, $post ); |
|
| 2174 | + do_action('edit_post', $post_id, $post); |
|
| 2175 | 2175 | |
| 2176 | 2176 | return true; |
| 2177 | 2177 | } |
@@ -2193,9 +2193,9 @@ discard block |
||
| 2193 | 2193 | * @param int $deprecated Not Used. |
| 2194 | 2194 | * @return false|string False on failure, string containing URI on success. |
| 2195 | 2195 | */ |
| 2196 | -function discover_pingback_server_uri( $url, $deprecated = '' ) { |
|
| 2197 | - if ( !empty( $deprecated ) ) |
|
| 2198 | - _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 2196 | +function discover_pingback_server_uri($url, $deprecated = '') { |
|
| 2197 | + if ( ! empty($deprecated)) |
|
| 2198 | + _deprecated_argument(__FUNCTION__, '2.7'); |
|
| 2199 | 2199 | |
| 2200 | 2200 | $pingback_str_dquote = 'rel="pingback"'; |
| 2201 | 2201 | $pingback_str_squote = 'rel=\'pingback\''; |
@@ -2203,47 +2203,47 @@ discard block |
||
| 2203 | 2203 | /** @todo Should use Filter Extension or custom preg_match instead. */ |
| 2204 | 2204 | $parsed_url = parse_url($url); |
| 2205 | 2205 | |
| 2206 | - if ( ! isset( $parsed_url['host'] ) ) // Not a URL. This should never happen. |
|
| 2206 | + if ( ! isset($parsed_url['host'])) // Not a URL. This should never happen. |
|
| 2207 | 2207 | return false; |
| 2208 | 2208 | |
| 2209 | 2209 | //Do not search for a pingback server on our own uploads |
| 2210 | 2210 | $uploads_dir = wp_get_upload_dir(); |
| 2211 | - if ( 0 === strpos($url, $uploads_dir['baseurl']) ) |
|
| 2211 | + if (0 === strpos($url, $uploads_dir['baseurl'])) |
|
| 2212 | 2212 | return false; |
| 2213 | 2213 | |
| 2214 | - $response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
|
| 2214 | + $response = wp_safe_remote_head($url, array('timeout' => 2, 'httpversion' => '1.0')); |
|
| 2215 | 2215 | |
| 2216 | - if ( is_wp_error( $response ) ) |
|
| 2216 | + if (is_wp_error($response)) |
|
| 2217 | 2217 | return false; |
| 2218 | 2218 | |
| 2219 | - if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) |
|
| 2220 | - return wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 2219 | + if (wp_remote_retrieve_header($response, 'x-pingback')) |
|
| 2220 | + return wp_remote_retrieve_header($response, 'x-pingback'); |
|
| 2221 | 2221 | |
| 2222 | 2222 | // Not an (x)html, sgml, or xml page, no use going further. |
| 2223 | - if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) |
|
| 2223 | + if (preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header($response, 'content-type'))) |
|
| 2224 | 2224 | return false; |
| 2225 | 2225 | |
| 2226 | 2226 | // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file) |
| 2227 | - $response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
|
| 2227 | + $response = wp_safe_remote_get($url, array('timeout' => 2, 'httpversion' => '1.0')); |
|
| 2228 | 2228 | |
| 2229 | - if ( is_wp_error( $response ) ) |
|
| 2229 | + if (is_wp_error($response)) |
|
| 2230 | 2230 | return false; |
| 2231 | 2231 | |
| 2232 | - $contents = wp_remote_retrieve_body( $response ); |
|
| 2232 | + $contents = wp_remote_retrieve_body($response); |
|
| 2233 | 2233 | |
| 2234 | 2234 | $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote); |
| 2235 | 2235 | $pingback_link_offset_squote = strpos($contents, $pingback_str_squote); |
| 2236 | - if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) { |
|
| 2236 | + if ($pingback_link_offset_dquote || $pingback_link_offset_squote) { |
|
| 2237 | 2237 | $quote = ($pingback_link_offset_dquote) ? '"' : '\''; |
| 2238 | - $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote; |
|
| 2238 | + $pingback_link_offset = ($quote == '"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote; |
|
| 2239 | 2239 | $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset); |
| 2240 | - $pingback_href_start = $pingback_href_pos+6; |
|
| 2240 | + $pingback_href_start = $pingback_href_pos + 6; |
|
| 2241 | 2241 | $pingback_href_end = @strpos($contents, $quote, $pingback_href_start); |
| 2242 | 2242 | $pingback_server_url_len = $pingback_href_end - $pingback_href_start; |
| 2243 | 2243 | $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len); |
| 2244 | 2244 | |
| 2245 | 2245 | // We may find rel="pingback" but an incomplete pingback URL |
| 2246 | - if ( $pingback_server_url_len > 0 ) { // We got it! |
|
| 2246 | + if ($pingback_server_url_len > 0) { // We got it! |
|
| 2247 | 2247 | return $pingback_server_url; |
| 2248 | 2248 | } |
| 2249 | 2249 | } |
@@ -2263,20 +2263,20 @@ discard block |
||
| 2263 | 2263 | |
| 2264 | 2264 | // Do pingbacks |
| 2265 | 2265 | while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { |
| 2266 | - delete_metadata_by_mid( 'post', $ping->meta_id ); |
|
| 2267 | - pingback( $ping->post_content, $ping->ID ); |
|
| 2266 | + delete_metadata_by_mid('post', $ping->meta_id); |
|
| 2267 | + pingback($ping->post_content, $ping->ID); |
|
| 2268 | 2268 | } |
| 2269 | 2269 | |
| 2270 | 2270 | // Do Enclosures |
| 2271 | 2271 | while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { |
| 2272 | - delete_metadata_by_mid( 'post', $enclosure->meta_id ); |
|
| 2273 | - do_enclose( $enclosure->post_content, $enclosure->ID ); |
|
| 2272 | + delete_metadata_by_mid('post', $enclosure->meta_id); |
|
| 2273 | + do_enclose($enclosure->post_content, $enclosure->ID); |
|
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | 2276 | // Do Trackbacks |
| 2277 | 2277 | $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'"); |
| 2278 | - if ( is_array($trackbacks) ) |
|
| 2279 | - foreach ( $trackbacks as $trackback ) |
|
| 2278 | + if (is_array($trackbacks)) |
|
| 2279 | + foreach ($trackbacks as $trackback) |
|
| 2280 | 2280 | do_trackbacks($trackback); |
| 2281 | 2281 | |
| 2282 | 2282 | //Do Update Services/Generic Pings |
@@ -2295,37 +2295,37 @@ discard block |
||
| 2295 | 2295 | function do_trackbacks($post_id) { |
| 2296 | 2296 | global $wpdb; |
| 2297 | 2297 | |
| 2298 | - $post = get_post( $post_id ); |
|
| 2298 | + $post = get_post($post_id); |
|
| 2299 | 2299 | $to_ping = get_to_ping($post_id); |
| 2300 | 2300 | $pinged = get_pung($post_id); |
| 2301 | - if ( empty($to_ping) ) { |
|
| 2302 | - $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) ); |
|
| 2301 | + if (empty($to_ping)) { |
|
| 2302 | + $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id)); |
|
| 2303 | 2303 | return; |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | - if ( empty($post->post_excerpt) ) { |
|
| 2306 | + if (empty($post->post_excerpt)) { |
|
| 2307 | 2307 | /** This filter is documented in wp-includes/post-template.php */ |
| 2308 | - $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID ); |
|
| 2308 | + $excerpt = apply_filters('the_content', $post->post_content, $post->ID); |
|
| 2309 | 2309 | } else { |
| 2310 | 2310 | /** This filter is documented in wp-includes/post-template.php */ |
| 2311 | - $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); |
|
| 2311 | + $excerpt = apply_filters('the_excerpt', $post->post_excerpt); |
|
| 2312 | 2312 | } |
| 2313 | 2313 | |
| 2314 | 2314 | $excerpt = str_replace(']]>', ']]>', $excerpt); |
| 2315 | 2315 | $excerpt = wp_html_excerpt($excerpt, 252, '…'); |
| 2316 | 2316 | |
| 2317 | 2317 | /** This filter is documented in wp-includes/post-template.php */ |
| 2318 | - $post_title = apply_filters( 'the_title', $post->post_title, $post->ID ); |
|
| 2318 | + $post_title = apply_filters('the_title', $post->post_title, $post->ID); |
|
| 2319 | 2319 | $post_title = strip_tags($post_title); |
| 2320 | 2320 | |
| 2321 | - if ( $to_ping ) { |
|
| 2322 | - foreach ( (array) $to_ping as $tb_ping ) { |
|
| 2321 | + if ($to_ping) { |
|
| 2322 | + foreach ((array) $to_ping as $tb_ping) { |
|
| 2323 | 2323 | $tb_ping = trim($tb_ping); |
| 2324 | - if ( !in_array($tb_ping, $pinged) ) { |
|
| 2324 | + if ( ! in_array($tb_ping, $pinged)) { |
|
| 2325 | 2325 | trackback($tb_ping, $post_title, $excerpt, $post_id); |
| 2326 | 2326 | $pinged[] = $tb_ping; |
| 2327 | 2327 | } else { |
| 2328 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) ); |
|
| 2328 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id)); |
|
| 2329 | 2329 | } |
| 2330 | 2330 | } |
| 2331 | 2331 | } |
@@ -2339,13 +2339,13 @@ discard block |
||
| 2339 | 2339 | * @param int $post_id Post ID. |
| 2340 | 2340 | * @return int Same as Post ID from parameter |
| 2341 | 2341 | */ |
| 2342 | -function generic_ping( $post_id = 0 ) { |
|
| 2342 | +function generic_ping($post_id = 0) { |
|
| 2343 | 2343 | $services = get_option('ping_sites'); |
| 2344 | 2344 | |
| 2345 | 2345 | $services = explode("\n", $services); |
| 2346 | - foreach ( (array) $services as $service ) { |
|
| 2346 | + foreach ((array) $services as $service) { |
|
| 2347 | 2347 | $service = trim($service); |
| 2348 | - if ( '' != $service ) |
|
| 2348 | + if ('' != $service) |
|
| 2349 | 2349 | weblog_ping($service); |
| 2350 | 2350 | } |
| 2351 | 2351 | |
@@ -2364,8 +2364,8 @@ discard block |
||
| 2364 | 2364 | */ |
| 2365 | 2365 | function pingback($content, $post_ID) { |
| 2366 | 2366 | global $wp_version; |
| 2367 | - include_once(ABSPATH . WPINC . '/class-IXR.php'); |
|
| 2368 | - include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php'); |
|
| 2367 | + include_once(ABSPATH.WPINC.'/class-IXR.php'); |
|
| 2368 | + include_once(ABSPATH.WPINC.'/class-wp-http-ixr-client.php'); |
|
| 2369 | 2369 | |
| 2370 | 2370 | // original code by Mort (http://mort.mine.nu:8080) |
| 2371 | 2371 | $post_links = array(); |
@@ -2374,7 +2374,7 @@ discard block |
||
| 2374 | 2374 | |
| 2375 | 2375 | // Step 1 |
| 2376 | 2376 | // Parsing the post, external links (if any) are stored in the $post_links array |
| 2377 | - $post_links_temp = wp_extract_urls( $content ); |
|
| 2377 | + $post_links_temp = wp_extract_urls($content); |
|
| 2378 | 2378 | |
| 2379 | 2379 | // Step 2. |
| 2380 | 2380 | // Walking thru the links array |
@@ -2385,19 +2385,19 @@ discard block |
||
| 2385 | 2385 | // http://dummy-weblog.org/post.php |
| 2386 | 2386 | // We don't wanna ping first and second types, even if they have a valid <link/> |
| 2387 | 2387 | |
| 2388 | - foreach ( (array) $post_links_temp as $link_test ) : |
|
| 2389 | - if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself |
|
| 2390 | - && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. |
|
| 2391 | - if ( $test = @parse_url($link_test) ) { |
|
| 2392 | - if ( isset($test['query']) ) |
|
| 2388 | + foreach ((array) $post_links_temp as $link_test) : |
|
| 2389 | + if ( ! in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself |
|
| 2390 | + && ! is_local_attachment($link_test)) : // Also, let's never ping local attachments. |
|
| 2391 | + if ($test = @parse_url($link_test)) { |
|
| 2392 | + if (isset($test['query'])) |
|
| 2393 | 2393 | $post_links[] = $link_test; |
| 2394 | - elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) |
|
| 2394 | + elseif (isset($test['path']) && ($test['path'] != '/') && ($test['path'] != '')) |
|
| 2395 | 2395 | $post_links[] = $link_test; |
| 2396 | 2396 | } |
| 2397 | 2397 | endif; |
| 2398 | 2398 | endforeach; |
| 2399 | 2399 | |
| 2400 | - $post_links = array_unique( $post_links ); |
|
| 2400 | + $post_links = array_unique($post_links); |
|
| 2401 | 2401 | /** |
| 2402 | 2402 | * Fires just before pinging back links found in a post. |
| 2403 | 2403 | * |
@@ -2407,13 +2407,13 @@ discard block |
||
| 2407 | 2407 | * @param array &$pung Whether a link has already been pinged, passed by reference. |
| 2408 | 2408 | * @param int $post_ID The post ID. |
| 2409 | 2409 | */ |
| 2410 | - do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) ); |
|
| 2410 | + do_action_ref_array('pre_ping', array(&$post_links, &$pung, $post_ID)); |
|
| 2411 | 2411 | |
| 2412 | - foreach ( (array) $post_links as $pagelinkedto ) { |
|
| 2413 | - $pingback_server_url = discover_pingback_server_uri( $pagelinkedto ); |
|
| 2412 | + foreach ((array) $post_links as $pagelinkedto) { |
|
| 2413 | + $pingback_server_url = discover_pingback_server_uri($pagelinkedto); |
|
| 2414 | 2414 | |
| 2415 | - if ( $pingback_server_url ) { |
|
| 2416 | - @ set_time_limit( 60 ); |
|
| 2415 | + if ($pingback_server_url) { |
|
| 2416 | + @ set_time_limit(60); |
|
| 2417 | 2417 | // Now, the RPC call |
| 2418 | 2418 | $pagelinkedfrom = get_permalink($post_ID); |
| 2419 | 2419 | |
@@ -2432,12 +2432,12 @@ discard block |
||
| 2432 | 2432 | * @param string $pagelinkedto URL of page linked to. |
| 2433 | 2433 | * @param string $pagelinkedfrom URL of page linked from. |
| 2434 | 2434 | */ |
| 2435 | - $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom ); |
|
| 2435 | + $client->useragent = apply_filters('pingback_useragent', $client->useragent.' -- WordPress/'.$wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom); |
|
| 2436 | 2436 | // when set to true, this outputs debug messages by itself |
| 2437 | 2437 | $client->debug = false; |
| 2438 | 2438 | |
| 2439 | - if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered |
|
| 2440 | - add_ping( $post_ID, $pagelinkedto ); |
|
| 2439 | + if ($client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || (isset($client->error->code) && 48 == $client->error->code)) // Already registered |
|
| 2440 | + add_ping($post_ID, $pagelinkedto); |
|
| 2441 | 2441 | } |
| 2442 | 2442 | } |
| 2443 | 2443 | } |
@@ -2451,7 +2451,7 @@ discard block |
||
| 2451 | 2451 | * @return mixed Empty string if blog is not public, returns $sites, if site is public. |
| 2452 | 2452 | */ |
| 2453 | 2453 | function privacy_ping_filter($sites) { |
| 2454 | - if ( '0' != get_option('blog_public') ) |
|
| 2454 | + if ('0' != get_option('blog_public')) |
|
| 2455 | 2455 | return $sites; |
| 2456 | 2456 | else |
| 2457 | 2457 | return ''; |
@@ -2475,7 +2475,7 @@ discard block |
||
| 2475 | 2475 | function trackback($trackback_url, $title, $excerpt, $ID) { |
| 2476 | 2476 | global $wpdb; |
| 2477 | 2477 | |
| 2478 | - if ( empty($trackback_url) ) |
|
| 2478 | + if (empty($trackback_url)) |
|
| 2479 | 2479 | return; |
| 2480 | 2480 | |
| 2481 | 2481 | $options = array(); |
@@ -2487,13 +2487,13 @@ discard block |
||
| 2487 | 2487 | 'excerpt' => $excerpt |
| 2488 | 2488 | ); |
| 2489 | 2489 | |
| 2490 | - $response = wp_safe_remote_post( $trackback_url, $options ); |
|
| 2490 | + $response = wp_safe_remote_post($trackback_url, $options); |
|
| 2491 | 2491 | |
| 2492 | - if ( is_wp_error( $response ) ) |
|
| 2492 | + if (is_wp_error($response)) |
|
| 2493 | 2493 | return; |
| 2494 | 2494 | |
| 2495 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) ); |
|
| 2496 | - return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) ); |
|
| 2495 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID)); |
|
| 2496 | + return $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID)); |
|
| 2497 | 2497 | } |
| 2498 | 2498 | |
| 2499 | 2499 | /** |
@@ -2508,18 +2508,18 @@ discard block |
||
| 2508 | 2508 | */ |
| 2509 | 2509 | function weblog_ping($server = '', $path = '') { |
| 2510 | 2510 | global $wp_version; |
| 2511 | - include_once(ABSPATH . WPINC . '/class-IXR.php'); |
|
| 2512 | - include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php'); |
|
| 2511 | + include_once(ABSPATH.WPINC.'/class-IXR.php'); |
|
| 2512 | + include_once(ABSPATH.WPINC.'/class-wp-http-ixr-client.php'); |
|
| 2513 | 2513 | |
| 2514 | 2514 | // using a timeout of 3 seconds should be enough to cover slow servers |
| 2515 | - $client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); |
|
| 2515 | + $client = new WP_HTTP_IXR_Client($server, (( ! strlen(trim($path)) || ('/' == $path)) ? false : $path)); |
|
| 2516 | 2516 | $client->timeout = 3; |
| 2517 | 2517 | $client->useragent .= ' -- WordPress/'.$wp_version; |
| 2518 | 2518 | |
| 2519 | 2519 | // when set to true, this outputs debug messages by itself |
| 2520 | 2520 | $client->debug = false; |
| 2521 | - $home = trailingslashit( home_url() ); |
|
| 2522 | - if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping |
|
| 2521 | + $home = trailingslashit(home_url()); |
|
| 2522 | + if ( ! $client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url'))) // then try a normal ping |
|
| 2523 | 2523 | $client->query('weblogUpdates.ping', get_option('blogname'), $home); |
| 2524 | 2524 | } |
| 2525 | 2525 | |
@@ -2532,8 +2532,8 @@ discard block |
||
| 2532 | 2532 | * @param string $source_uri |
| 2533 | 2533 | * @return string |
| 2534 | 2534 | */ |
| 2535 | -function pingback_ping_source_uri( $source_uri ) { |
|
| 2536 | - return (string) wp_http_validate_url( $source_uri ); |
|
| 2535 | +function pingback_ping_source_uri($source_uri) { |
|
| 2536 | + return (string) wp_http_validate_url($source_uri); |
|
| 2537 | 2537 | } |
| 2538 | 2538 | |
| 2539 | 2539 | /** |
@@ -2548,10 +2548,10 @@ discard block |
||
| 2548 | 2548 | * @param IXR_Error $ixr_error |
| 2549 | 2549 | * @return IXR_Error |
| 2550 | 2550 | */ |
| 2551 | -function xmlrpc_pingback_error( $ixr_error ) { |
|
| 2552 | - if ( $ixr_error->code === 48 ) |
|
| 2551 | +function xmlrpc_pingback_error($ixr_error) { |
|
| 2552 | + if ($ixr_error->code === 48) |
|
| 2553 | 2553 | return $ixr_error; |
| 2554 | - return new IXR_Error( 0, '' ); |
|
| 2554 | + return new IXR_Error(0, ''); |
|
| 2555 | 2555 | } |
| 2556 | 2556 | |
| 2557 | 2557 | // |
@@ -2566,8 +2566,8 @@ discard block |
||
| 2566 | 2566 | * @param int|array $ids Comment ID or an array of comment IDs to remove from cache. |
| 2567 | 2567 | */ |
| 2568 | 2568 | function clean_comment_cache($ids) { |
| 2569 | - foreach ( (array) $ids as $id ) { |
|
| 2570 | - wp_cache_delete( $id, 'comment' ); |
|
| 2569 | + foreach ((array) $ids as $id) { |
|
| 2570 | + wp_cache_delete($id, 'comment'); |
|
| 2571 | 2571 | |
| 2572 | 2572 | /** |
| 2573 | 2573 | * Fires immediately after a comment has been removed from the object cache. |
@@ -2576,10 +2576,10 @@ discard block |
||
| 2576 | 2576 | * |
| 2577 | 2577 | * @param int $id Comment ID. |
| 2578 | 2578 | */ |
| 2579 | - do_action( 'clean_comment_cache', $id ); |
|
| 2579 | + do_action('clean_comment_cache', $id); |
|
| 2580 | 2580 | } |
| 2581 | 2581 | |
| 2582 | - wp_cache_set( 'last_changed', microtime(), 'comment' ); |
|
| 2582 | + wp_cache_set('last_changed', microtime(), 'comment'); |
|
| 2583 | 2583 | } |
| 2584 | 2584 | |
| 2585 | 2585 | /** |
@@ -2595,17 +2595,17 @@ discard block |
||
| 2595 | 2595 | * @param array $comments Array of comment row objects |
| 2596 | 2596 | * @param bool $update_meta_cache Whether to update commentmeta cache. Default true. |
| 2597 | 2597 | */ |
| 2598 | -function update_comment_cache( $comments, $update_meta_cache = true ) { |
|
| 2599 | - foreach ( (array) $comments as $comment ) |
|
| 2598 | +function update_comment_cache($comments, $update_meta_cache = true) { |
|
| 2599 | + foreach ((array) $comments as $comment) |
|
| 2600 | 2600 | wp_cache_add($comment->comment_ID, $comment, 'comment'); |
| 2601 | 2601 | |
| 2602 | - if ( $update_meta_cache ) { |
|
| 2602 | + if ($update_meta_cache) { |
|
| 2603 | 2603 | // Avoid `wp_list_pluck()` in case `$comments` is passed by reference. |
| 2604 | 2604 | $comment_ids = array(); |
| 2605 | - foreach ( $comments as $comment ) { |
|
| 2605 | + foreach ($comments as $comment) { |
|
| 2606 | 2606 | $comment_ids[] = $comment->comment_ID; |
| 2607 | 2607 | } |
| 2608 | - update_meta_cache( 'comment', $comment_ids ); |
|
| 2608 | + update_meta_cache('comment', $comment_ids); |
|
| 2609 | 2609 | } |
| 2610 | 2610 | } |
| 2611 | 2611 | |
@@ -2621,14 +2621,14 @@ discard block |
||
| 2621 | 2621 | * @param array $comment_ids Array of comment IDs. |
| 2622 | 2622 | * @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true. |
| 2623 | 2623 | */ |
| 2624 | -function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) { |
|
| 2624 | +function _prime_comment_caches($comment_ids, $update_meta_cache = true) { |
|
| 2625 | 2625 | global $wpdb; |
| 2626 | 2626 | |
| 2627 | - $non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' ); |
|
| 2628 | - if ( !empty( $non_cached_ids ) ) { |
|
| 2629 | - $fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) ); |
|
| 2627 | + $non_cached_ids = _get_non_cached_ids($comment_ids, 'comment'); |
|
| 2628 | + if ( ! empty($non_cached_ids)) { |
|
| 2629 | + $fresh_comments = $wpdb->get_results(sprintf("SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", join(",", array_map('intval', $non_cached_ids)))); |
|
| 2630 | 2630 | |
| 2631 | - update_comment_cache( $fresh_comments, $update_meta_cache ); |
|
| 2631 | + update_comment_cache($fresh_comments, $update_meta_cache); |
|
| 2632 | 2632 | } |
| 2633 | 2633 | } |
| 2634 | 2634 | |
@@ -2646,8 +2646,8 @@ discard block |
||
| 2646 | 2646 | * @param WP_Query $query Query object. |
| 2647 | 2647 | * @return array |
| 2648 | 2648 | */ |
| 2649 | -function _close_comments_for_old_posts( $posts, $query ) { |
|
| 2650 | - if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
|
| 2649 | +function _close_comments_for_old_posts($posts, $query) { |
|
| 2650 | + if (empty($posts) || ! $query->is_singular() || ! get_option('close_comments_for_old_posts')) |
|
| 2651 | 2651 | return $posts; |
| 2652 | 2652 | |
| 2653 | 2653 | /** |
@@ -2657,15 +2657,15 @@ discard block |
||
| 2657 | 2657 | * |
| 2658 | 2658 | * @param array $post_types An array of registered post types. Default array with 'post'. |
| 2659 | 2659 | */ |
| 2660 | - $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
|
| 2661 | - if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
|
| 2660 | + $post_types = apply_filters('close_comments_for_post_types', array('post')); |
|
| 2661 | + if ( ! in_array($posts[0]->post_type, $post_types)) |
|
| 2662 | 2662 | return $posts; |
| 2663 | 2663 | |
| 2664 | - $days_old = (int) get_option( 'close_comments_days_old' ); |
|
| 2665 | - if ( ! $days_old ) |
|
| 2664 | + $days_old = (int) get_option('close_comments_days_old'); |
|
| 2665 | + if ( ! $days_old) |
|
| 2666 | 2666 | return $posts; |
| 2667 | 2667 | |
| 2668 | - if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
|
| 2668 | + if (time() - strtotime($posts[0]->post_date_gmt) > ($days_old * DAY_IN_SECONDS)) { |
|
| 2669 | 2669 | $posts[0]->comment_status = 'closed'; |
| 2670 | 2670 | $posts[0]->ping_status = 'closed'; |
| 2671 | 2671 | } |
@@ -2683,30 +2683,30 @@ discard block |
||
| 2683 | 2683 | * @param int $post_id Post ID |
| 2684 | 2684 | * @return bool $open |
| 2685 | 2685 | */ |
| 2686 | -function _close_comments_for_old_post( $open, $post_id ) { |
|
| 2687 | - if ( ! $open ) |
|
| 2686 | +function _close_comments_for_old_post($open, $post_id) { |
|
| 2687 | + if ( ! $open) |
|
| 2688 | 2688 | return $open; |
| 2689 | 2689 | |
| 2690 | - if ( !get_option('close_comments_for_old_posts') ) |
|
| 2690 | + if ( ! get_option('close_comments_for_old_posts')) |
|
| 2691 | 2691 | return $open; |
| 2692 | 2692 | |
| 2693 | 2693 | $days_old = (int) get_option('close_comments_days_old'); |
| 2694 | - if ( !$days_old ) |
|
| 2694 | + if ( ! $days_old) |
|
| 2695 | 2695 | return $open; |
| 2696 | 2696 | |
| 2697 | 2697 | $post = get_post($post_id); |
| 2698 | 2698 | |
| 2699 | 2699 | /** This filter is documented in wp-includes/comment.php */ |
| 2700 | - $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
|
| 2701 | - if ( ! in_array( $post->post_type, $post_types ) ) |
|
| 2700 | + $post_types = apply_filters('close_comments_for_post_types', array('post')); |
|
| 2701 | + if ( ! in_array($post->post_type, $post_types)) |
|
| 2702 | 2702 | return $open; |
| 2703 | 2703 | |
| 2704 | 2704 | // Undated drafts should not show up as comments closed. |
| 2705 | - if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { |
|
| 2705 | + if ('0000-00-00 00:00:00' === $post->post_date_gmt) { |
|
| 2706 | 2706 | return $open; |
| 2707 | 2707 | } |
| 2708 | 2708 | |
| 2709 | - if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) |
|
| 2709 | + if (time() - strtotime($post->post_date_gmt) > ($days_old * DAY_IN_SECONDS)) |
|
| 2710 | 2710 | return false; |
| 2711 | 2711 | |
| 2712 | 2712 | return $open; |
@@ -2733,36 +2733,36 @@ discard block |
||
| 2733 | 2733 | * } |
| 2734 | 2734 | * @return WP_Comment|WP_Error A WP_Comment object on success, a WP_Error object on failure. |
| 2735 | 2735 | */ |
| 2736 | -function wp_handle_comment_submission( $comment_data ) { |
|
| 2736 | +function wp_handle_comment_submission($comment_data) { |
|
| 2737 | 2737 | |
| 2738 | 2738 | $comment_post_ID = $comment_parent = 0; |
| 2739 | 2739 | $comment_author = $comment_author_email = $comment_author_url = $comment_content = $_wp_unfiltered_html_comment = null; |
| 2740 | 2740 | |
| 2741 | - if ( isset( $comment_data['comment_post_ID'] ) ) { |
|
| 2741 | + if (isset($comment_data['comment_post_ID'])) { |
|
| 2742 | 2742 | $comment_post_ID = (int) $comment_data['comment_post_ID']; |
| 2743 | 2743 | } |
| 2744 | - if ( isset( $comment_data['author'] ) && is_string( $comment_data['author'] ) ) { |
|
| 2745 | - $comment_author = trim( strip_tags( $comment_data['author'] ) ); |
|
| 2744 | + if (isset($comment_data['author']) && is_string($comment_data['author'])) { |
|
| 2745 | + $comment_author = trim(strip_tags($comment_data['author'])); |
|
| 2746 | 2746 | } |
| 2747 | - if ( isset( $comment_data['email'] ) && is_string( $comment_data['email'] ) ) { |
|
| 2748 | - $comment_author_email = trim( $comment_data['email'] ); |
|
| 2747 | + if (isset($comment_data['email']) && is_string($comment_data['email'])) { |
|
| 2748 | + $comment_author_email = trim($comment_data['email']); |
|
| 2749 | 2749 | } |
| 2750 | - if ( isset( $comment_data['url'] ) && is_string( $comment_data['url'] ) ) { |
|
| 2751 | - $comment_author_url = trim( $comment_data['url'] ); |
|
| 2750 | + if (isset($comment_data['url']) && is_string($comment_data['url'])) { |
|
| 2751 | + $comment_author_url = trim($comment_data['url']); |
|
| 2752 | 2752 | } |
| 2753 | - if ( isset( $comment_data['comment'] ) && is_string( $comment_data['comment'] ) ) { |
|
| 2754 | - $comment_content = trim( $comment_data['comment'] ); |
|
| 2753 | + if (isset($comment_data['comment']) && is_string($comment_data['comment'])) { |
|
| 2754 | + $comment_content = trim($comment_data['comment']); |
|
| 2755 | 2755 | } |
| 2756 | - if ( isset( $comment_data['comment_parent'] ) ) { |
|
| 2757 | - $comment_parent = absint( $comment_data['comment_parent'] ); |
|
| 2756 | + if (isset($comment_data['comment_parent'])) { |
|
| 2757 | + $comment_parent = absint($comment_data['comment_parent']); |
|
| 2758 | 2758 | } |
| 2759 | - if ( isset( $comment_data['_wp_unfiltered_html_comment'] ) && is_string( $comment_data['_wp_unfiltered_html_comment'] ) ) { |
|
| 2760 | - $_wp_unfiltered_html_comment = trim( $comment_data['_wp_unfiltered_html_comment'] ); |
|
| 2759 | + if (isset($comment_data['_wp_unfiltered_html_comment']) && is_string($comment_data['_wp_unfiltered_html_comment'])) { |
|
| 2760 | + $_wp_unfiltered_html_comment = trim($comment_data['_wp_unfiltered_html_comment']); |
|
| 2761 | 2761 | } |
| 2762 | 2762 | |
| 2763 | - $post = get_post( $comment_post_ID ); |
|
| 2763 | + $post = get_post($comment_post_ID); |
|
| 2764 | 2764 | |
| 2765 | - if ( empty( $post->comment_status ) ) { |
|
| 2765 | + if (empty($post->comment_status)) { |
|
| 2766 | 2766 | |
| 2767 | 2767 | /** |
| 2768 | 2768 | * Fires when a comment is attempted on a post that does not exist. |
@@ -2771,22 +2771,22 @@ discard block |
||
| 2771 | 2771 | * |
| 2772 | 2772 | * @param int $comment_post_ID Post ID. |
| 2773 | 2773 | */ |
| 2774 | - do_action( 'comment_id_not_found', $comment_post_ID ); |
|
| 2774 | + do_action('comment_id_not_found', $comment_post_ID); |
|
| 2775 | 2775 | |
| 2776 | - return new WP_Error( 'comment_id_not_found' ); |
|
| 2776 | + return new WP_Error('comment_id_not_found'); |
|
| 2777 | 2777 | |
| 2778 | 2778 | } |
| 2779 | 2779 | |
| 2780 | 2780 | // get_post_status() will get the parent status for attachments. |
| 2781 | - $status = get_post_status( $post ); |
|
| 2781 | + $status = get_post_status($post); |
|
| 2782 | 2782 | |
| 2783 | - if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) { |
|
| 2784 | - return new WP_Error( 'comment_id_not_found' ); |
|
| 2783 | + if (('private' == $status) && ! current_user_can('read_post', $comment_post_ID)) { |
|
| 2784 | + return new WP_Error('comment_id_not_found'); |
|
| 2785 | 2785 | } |
| 2786 | 2786 | |
| 2787 | - $status_obj = get_post_status_object( $status ); |
|
| 2787 | + $status_obj = get_post_status_object($status); |
|
| 2788 | 2788 | |
| 2789 | - if ( ! comments_open( $comment_post_ID ) ) { |
|
| 2789 | + if ( ! comments_open($comment_post_ID)) { |
|
| 2790 | 2790 | |
| 2791 | 2791 | /** |
| 2792 | 2792 | * Fires when a comment is attempted on a post that has comments closed. |
@@ -2795,11 +2795,11 @@ discard block |
||
| 2795 | 2795 | * |
| 2796 | 2796 | * @param int $comment_post_ID Post ID. |
| 2797 | 2797 | */ |
| 2798 | - do_action( 'comment_closed', $comment_post_ID ); |
|
| 2798 | + do_action('comment_closed', $comment_post_ID); |
|
| 2799 | 2799 | |
| 2800 | - return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 ); |
|
| 2800 | + return new WP_Error('comment_closed', __('Sorry, comments are closed for this item.'), 403); |
|
| 2801 | 2801 | |
| 2802 | - } elseif ( 'trash' == $status ) { |
|
| 2802 | + } elseif ('trash' == $status) { |
|
| 2803 | 2803 | |
| 2804 | 2804 | /** |
| 2805 | 2805 | * Fires when a comment is attempted on a trashed post. |
@@ -2808,11 +2808,11 @@ discard block |
||
| 2808 | 2808 | * |
| 2809 | 2809 | * @param int $comment_post_ID Post ID. |
| 2810 | 2810 | */ |
| 2811 | - do_action( 'comment_on_trash', $comment_post_ID ); |
|
| 2811 | + do_action('comment_on_trash', $comment_post_ID); |
|
| 2812 | 2812 | |
| 2813 | - return new WP_Error( 'comment_on_trash' ); |
|
| 2813 | + return new WP_Error('comment_on_trash'); |
|
| 2814 | 2814 | |
| 2815 | - } elseif ( ! $status_obj->public && ! $status_obj->private ) { |
|
| 2815 | + } elseif ( ! $status_obj->public && ! $status_obj->private) { |
|
| 2816 | 2816 | |
| 2817 | 2817 | /** |
| 2818 | 2818 | * Fires when a comment is attempted on a post in draft mode. |
@@ -2821,11 +2821,11 @@ discard block |
||
| 2821 | 2821 | * |
| 2822 | 2822 | * @param int $comment_post_ID Post ID. |
| 2823 | 2823 | */ |
| 2824 | - do_action( 'comment_on_draft', $comment_post_ID ); |
|
| 2824 | + do_action('comment_on_draft', $comment_post_ID); |
|
| 2825 | 2825 | |
| 2826 | - return new WP_Error( 'comment_on_draft' ); |
|
| 2826 | + return new WP_Error('comment_on_draft'); |
|
| 2827 | 2827 | |
| 2828 | - } elseif ( post_password_required( $comment_post_ID ) ) { |
|
| 2828 | + } elseif (post_password_required($comment_post_ID)) { |
|
| 2829 | 2829 | |
| 2830 | 2830 | /** |
| 2831 | 2831 | * Fires when a comment is attempted on a password-protected post. |
@@ -2834,9 +2834,9 @@ discard block |
||
| 2834 | 2834 | * |
| 2835 | 2835 | * @param int $comment_post_ID Post ID. |
| 2836 | 2836 | */ |
| 2837 | - do_action( 'comment_on_password_protected', $comment_post_ID ); |
|
| 2837 | + do_action('comment_on_password_protected', $comment_post_ID); |
|
| 2838 | 2838 | |
| 2839 | - return new WP_Error( 'comment_on_password_protected' ); |
|
| 2839 | + return new WP_Error('comment_on_password_protected'); |
|
| 2840 | 2840 | |
| 2841 | 2841 | } else { |
| 2842 | 2842 | |
@@ -2847,61 +2847,61 @@ discard block |
||
| 2847 | 2847 | * |
| 2848 | 2848 | * @param int $comment_post_ID Post ID. |
| 2849 | 2849 | */ |
| 2850 | - do_action( 'pre_comment_on_post', $comment_post_ID ); |
|
| 2850 | + do_action('pre_comment_on_post', $comment_post_ID); |
|
| 2851 | 2851 | |
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | // If the user is logged in |
| 2855 | 2855 | $user = wp_get_current_user(); |
| 2856 | - if ( $user->exists() ) { |
|
| 2857 | - if ( empty( $user->display_name ) ) { |
|
| 2858 | - $user->display_name=$user->user_login; |
|
| 2856 | + if ($user->exists()) { |
|
| 2857 | + if (empty($user->display_name)) { |
|
| 2858 | + $user->display_name = $user->user_login; |
|
| 2859 | 2859 | } |
| 2860 | 2860 | $comment_author = $user->display_name; |
| 2861 | 2861 | $comment_author_email = $user->user_email; |
| 2862 | 2862 | $comment_author_url = $user->user_url; |
| 2863 | 2863 | $user_ID = $user->ID; |
| 2864 | - if ( current_user_can( 'unfiltered_html' ) ) { |
|
| 2865 | - if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] ) |
|
| 2866 | - || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID ) |
|
| 2864 | + if (current_user_can('unfiltered_html')) { |
|
| 2865 | + if ( ! isset($comment_data['_wp_unfiltered_html_comment']) |
|
| 2866 | + || ! wp_verify_nonce($comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_'.$comment_post_ID) |
|
| 2867 | 2867 | ) { |
| 2868 | 2868 | kses_remove_filters(); // start with a clean slate |
| 2869 | 2869 | kses_init_filters(); // set up the filters |
| 2870 | 2870 | } |
| 2871 | 2871 | } |
| 2872 | 2872 | } else { |
| 2873 | - if ( get_option( 'comment_registration' ) ) { |
|
| 2874 | - return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to post a comment.' ), 403 ); |
|
| 2873 | + if (get_option('comment_registration')) { |
|
| 2874 | + return new WP_Error('not_logged_in', __('Sorry, you must be logged in to post a comment.'), 403); |
|
| 2875 | 2875 | } |
| 2876 | 2876 | } |
| 2877 | 2877 | |
| 2878 | 2878 | $comment_type = ''; |
| 2879 | 2879 | $max_lengths = wp_get_comment_fields_max_lengths(); |
| 2880 | 2880 | |
| 2881 | - if ( get_option( 'require_name_email' ) && ! $user->exists() ) { |
|
| 2882 | - if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) { |
|
| 2883 | - return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 ); |
|
| 2884 | - } elseif ( ! is_email( $comment_author_email ) ) { |
|
| 2885 | - return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 ); |
|
| 2881 | + if (get_option('require_name_email') && ! $user->exists()) { |
|
| 2882 | + if (6 > strlen($comment_author_email) || '' == $comment_author) { |
|
| 2883 | + return new WP_Error('require_name_email', __('<strong>ERROR</strong>: please fill the required fields (name, email).'), 200); |
|
| 2884 | + } elseif ( ! is_email($comment_author_email)) { |
|
| 2885 | + return new WP_Error('require_valid_email', __('<strong>ERROR</strong>: please enter a valid email address.'), 200); |
|
| 2886 | 2886 | } |
| 2887 | 2887 | } |
| 2888 | 2888 | |
| 2889 | - if ( isset( $comment_author ) && $max_lengths['comment_author'] < mb_strlen( $comment_author, '8bit' ) ) { |
|
| 2890 | - return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 ); |
|
| 2889 | + if (isset($comment_author) && $max_lengths['comment_author'] < mb_strlen($comment_author, '8bit')) { |
|
| 2890 | + return new WP_Error('comment_author_column_length', __('<strong>ERROR</strong>: your name is too long.'), 200); |
|
| 2891 | 2891 | } |
| 2892 | 2892 | |
| 2893 | - if ( isset( $comment_author_email ) && $max_lengths['comment_author_email'] < strlen( $comment_author_email ) ) { |
|
| 2894 | - return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 ); |
|
| 2893 | + if (isset($comment_author_email) && $max_lengths['comment_author_email'] < strlen($comment_author_email)) { |
|
| 2894 | + return new WP_Error('comment_author_email_column_length', __('<strong>ERROR</strong>: your email address is too long.'), 200); |
|
| 2895 | 2895 | } |
| 2896 | 2896 | |
| 2897 | - if ( isset( $comment_author_url ) && $max_lengths['comment_author_url'] < strlen( $comment_author_url ) ) { |
|
| 2898 | - return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 ); |
|
| 2897 | + if (isset($comment_author_url) && $max_lengths['comment_author_url'] < strlen($comment_author_url)) { |
|
| 2898 | + return new WP_Error('comment_author_url_column_length', __('<strong>ERROR</strong>: your url is too long.'), 200); |
|
| 2899 | 2899 | } |
| 2900 | 2900 | |
| 2901 | - if ( '' == $comment_content ) { |
|
| 2902 | - return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 ); |
|
| 2903 | - } elseif ( $max_lengths['comment_content'] < mb_strlen( $comment_content, '8bit' ) ) { |
|
| 2904 | - return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 ); |
|
| 2901 | + if ('' == $comment_content) { |
|
| 2902 | + return new WP_Error('require_valid_comment', __('<strong>ERROR</strong>: please type a comment.'), 200); |
|
| 2903 | + } elseif ($max_lengths['comment_content'] < mb_strlen($comment_content, '8bit')) { |
|
| 2904 | + return new WP_Error('comment_content_column_length', __('<strong>ERROR</strong>: your comment is too long.'), 200); |
|
| 2905 | 2905 | } |
| 2906 | 2906 | |
| 2907 | 2907 | $commentdata = compact( |
@@ -2915,11 +2915,11 @@ discard block |
||
| 2915 | 2915 | 'user_ID' |
| 2916 | 2916 | ); |
| 2917 | 2917 | |
| 2918 | - $comment_id = wp_new_comment( wp_slash( $commentdata ) ); |
|
| 2919 | - if ( ! $comment_id ) { |
|
| 2920 | - return new WP_Error( 'comment_save_error', __( '<strong>ERROR</strong>: The comment could not be saved. Please try again later.' ), 500 ); |
|
| 2918 | + $comment_id = wp_new_comment(wp_slash($commentdata)); |
|
| 2919 | + if ( ! $comment_id) { |
|
| 2920 | + return new WP_Error('comment_save_error', __('<strong>ERROR</strong>: The comment could not be saved. Please try again later.'), 500); |
|
| 2921 | 2921 | } |
| 2922 | 2922 | |
| 2923 | - return get_comment( $comment_id ); |
|
| 2923 | + return get_comment($comment_id); |
|
| 2924 | 2924 | |
| 2925 | 2925 | } |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | global $wpdb; |
| 41 | 41 | |
| 42 | 42 | // If manual moderation is enabled, skip all checks and return false. |
| 43 | - if ( 1 == get_option('comment_moderation') ) |
|
| 44 | - return false; |
|
| 43 | + if ( 1 == get_option('comment_moderation') ) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 45 | 46 | |
| 46 | 47 | /** This filter is documented in wp-includes/comment-template.php */ |
| 47 | 48 | $comment = apply_filters( 'comment_text', $comment ); |
@@ -64,8 +65,9 @@ discard block |
||
| 64 | 65 | * If the number of links in the comment exceeds the allowed amount, |
| 65 | 66 | * fail the check by returning false. |
| 66 | 67 | */ |
| 67 | - if ( $num_links >= $max_links ) |
|
| 68 | - return false; |
|
| 68 | + if ( $num_links >= $max_links ) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 69 | 71 | } |
| 70 | 72 | |
| 71 | 73 | $mod_keys = trim(get_option('moderation_keys')); |
@@ -78,8 +80,9 @@ discard block |
||
| 78 | 80 | $word = trim($word); |
| 79 | 81 | |
| 80 | 82 | // Skip empty lines. |
| 81 | - if ( empty($word) ) |
|
| 82 | - continue; |
|
| 83 | + if ( empty($word) ) { |
|
| 84 | + continue; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | /* |
| 85 | 88 | * Do some escaping magic so that '#' (number of) characters in the spam |
@@ -92,12 +95,24 @@ discard block |
||
| 92 | 95 | * fail the check for the given field by returning false. |
| 93 | 96 | */ |
| 94 | 97 | $pattern = "#$word#i"; |
| 95 | - if ( preg_match($pattern, $author) ) return false; |
|
| 96 | - if ( preg_match($pattern, $email) ) return false; |
|
| 97 | - if ( preg_match($pattern, $url) ) return false; |
|
| 98 | - if ( preg_match($pattern, $comment) ) return false; |
|
| 99 | - if ( preg_match($pattern, $user_ip) ) return false; |
|
| 100 | - if ( preg_match($pattern, $user_agent) ) return false; |
|
| 98 | + if ( preg_match($pattern, $author) ) { |
|
| 99 | + return false; |
|
| 100 | + } |
|
| 101 | + if ( preg_match($pattern, $email) ) { |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | + if ( preg_match($pattern, $url) ) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 107 | + if ( preg_match($pattern, $comment) ) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | + if ( preg_match($pattern, $user_ip) ) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + if ( preg_match($pattern, $user_agent) ) { |
|
| 114 | + return false; |
|
| 115 | + } |
|
| 101 | 116 | } |
| 102 | 117 | } |
| 103 | 118 | |
@@ -113,10 +128,11 @@ discard block |
||
| 113 | 128 | // expected_slashed ($author, $email) |
| 114 | 129 | $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1"); |
| 115 | 130 | if ( ( 1 == $ok_to_comment ) && |
| 116 | - ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) |
|
| 117 | - return true; |
|
| 118 | - else |
|
| 119 | - return false; |
|
| 131 | + ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) { |
|
| 132 | + return true; |
|
| 133 | + } else { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 120 | 136 | } else { |
| 121 | 137 | return false; |
| 122 | 138 | } |
@@ -299,8 +315,9 @@ discard block |
||
| 299 | 315 | global $wpdb; |
| 300 | 316 | static $cache_lastcommentmodified = array(); |
| 301 | 317 | |
| 302 | - if ( isset($cache_lastcommentmodified[$timezone]) ) |
|
| 303 | - return $cache_lastcommentmodified[$timezone]; |
|
| 318 | + if ( isset($cache_lastcommentmodified[$timezone]) ) { |
|
| 319 | + return $cache_lastcommentmodified[$timezone]; |
|
| 320 | + } |
|
| 304 | 321 | |
| 305 | 322 | $add_seconds_server = date('Z'); |
| 306 | 323 | |
@@ -502,8 +519,9 @@ discard block |
||
| 502 | 519 | * @since 3.4.0 |
| 503 | 520 | */ |
| 504 | 521 | function wp_set_comment_cookies($comment, $user) { |
| 505 | - if ( $user->exists() ) |
|
| 506 | - return; |
|
| 522 | + if ( $user->exists() ) { |
|
| 523 | + return; |
|
| 524 | + } |
|
| 507 | 525 | |
| 508 | 526 | /** |
| 509 | 527 | * Filter the lifetime of the comment cookie in seconds. |
@@ -770,8 +788,9 @@ discard block |
||
| 770 | 788 | */ |
| 771 | 789 | do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); |
| 772 | 790 | |
| 773 | - if ( defined('DOING_AJAX') ) |
|
| 774 | - die( __('You are posting comments too quickly. Slow down.') ); |
|
| 791 | + if ( defined('DOING_AJAX') ) { |
|
| 792 | + die( __('You are posting comments too quickly. Slow down.') ); |
|
| 793 | + } |
|
| 775 | 794 | |
| 776 | 795 | wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 ); |
| 777 | 796 | } |
@@ -791,11 +810,13 @@ discard block |
||
| 791 | 810 | $count = count($comments); |
| 792 | 811 | for ( $i = 0; $i < $count; $i++ ) { |
| 793 | 812 | $type = $comments[$i]->comment_type; |
| 794 | - if ( empty($type) ) |
|
| 795 | - $type = 'comment'; |
|
| 813 | + if ( empty($type) ) { |
|
| 814 | + $type = 'comment'; |
|
| 815 | + } |
|
| 796 | 816 | $comments_by_type[$type][] = &$comments[$i]; |
| 797 | - if ( 'trackback' == $type || 'pingback' == $type ) |
|
| 798 | - $comments_by_type['pings'][] = &$comments[$i]; |
|
| 817 | + if ( 'trackback' == $type || 'pingback' == $type ) { |
|
| 818 | + $comments_by_type['pings'][] = &$comments[$i]; |
|
| 819 | + } |
|
| 799 | 820 | } |
| 800 | 821 | |
| 801 | 822 | return $comments_by_type; |
@@ -818,28 +839,35 @@ discard block |
||
| 818 | 839 | function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) { |
| 819 | 840 | global $wp_query; |
| 820 | 841 | |
| 821 | - if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) |
|
| 822 | - return $wp_query->max_num_comment_pages; |
|
| 842 | + if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) { |
|
| 843 | + return $wp_query->max_num_comment_pages; |
|
| 844 | + } |
|
| 823 | 845 | |
| 824 | - if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) |
|
| 825 | - $comments = $wp_query->comments; |
|
| 846 | + if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) { |
|
| 847 | + $comments = $wp_query->comments; |
|
| 848 | + } |
|
| 826 | 849 | |
| 827 | - if ( empty($comments) ) |
|
| 828 | - return 0; |
|
| 850 | + if ( empty($comments) ) { |
|
| 851 | + return 0; |
|
| 852 | + } |
|
| 829 | 853 | |
| 830 | 854 | if ( ! get_option( 'page_comments' ) ) { |
| 831 | 855 | return 1; |
| 832 | 856 | } |
| 833 | 857 | |
| 834 | - if ( !isset($per_page) ) |
|
| 835 | - $per_page = (int) get_query_var('comments_per_page'); |
|
| 836 | - if ( 0 === $per_page ) |
|
| 837 | - $per_page = (int) get_option('comments_per_page'); |
|
| 838 | - if ( 0 === $per_page ) |
|
| 839 | - return 1; |
|
| 858 | + if ( !isset($per_page) ) { |
|
| 859 | + $per_page = (int) get_query_var('comments_per_page'); |
|
| 860 | + } |
|
| 861 | + if ( 0 === $per_page ) { |
|
| 862 | + $per_page = (int) get_option('comments_per_page'); |
|
| 863 | + } |
|
| 864 | + if ( 0 === $per_page ) { |
|
| 865 | + return 1; |
|
| 866 | + } |
|
| 840 | 867 | |
| 841 | - if ( !isset($threaded) ) |
|
| 842 | - $threaded = get_option('thread_comments'); |
|
| 868 | + if ( !isset($threaded) ) { |
|
| 869 | + $threaded = get_option('thread_comments'); |
|
| 870 | + } |
|
| 843 | 871 | |
| 844 | 872 | if ( $threaded ) { |
| 845 | 873 | $walker = new Walker_Comment; |
@@ -876,8 +904,9 @@ discard block |
||
| 876 | 904 | |
| 877 | 905 | $page = null; |
| 878 | 906 | |
| 879 | - if ( !$comment = get_comment( $comment_ID ) ) |
|
| 880 | - return; |
|
| 907 | + if ( !$comment = get_comment( $comment_ID ) ) { |
|
| 908 | + return; |
|
| 909 | + } |
|
| 881 | 910 | |
| 882 | 911 | $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); |
| 883 | 912 | $args = wp_parse_args( $args, $defaults ); |
@@ -905,15 +934,17 @@ discard block |
||
| 905 | 934 | |
| 906 | 935 | if ( null === $page ) { |
| 907 | 936 | if ( '' === $args['max_depth'] ) { |
| 908 | - if ( get_option('thread_comments') ) |
|
| 909 | - $args['max_depth'] = get_option('thread_comments_depth'); |
|
| 910 | - else |
|
| 911 | - $args['max_depth'] = -1; |
|
| 937 | + if ( get_option('thread_comments') ) { |
|
| 938 | + $args['max_depth'] = get_option('thread_comments_depth'); |
|
| 939 | + } else { |
|
| 940 | + $args['max_depth'] = -1; |
|
| 941 | + } |
|
| 912 | 942 | } |
| 913 | 943 | |
| 914 | 944 | // Find this comment's top level parent if threading is enabled |
| 915 | - if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) |
|
| 916 | - return get_page_of_comment( $comment->comment_parent, $args ); |
|
| 945 | + if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) { |
|
| 946 | + return get_page_of_comment( $comment->comment_parent, $args ); |
|
| 947 | + } |
|
| 917 | 948 | |
| 918 | 949 | $comment_args = array( |
| 919 | 950 | 'type' => $args['type'], |
@@ -1055,8 +1086,10 @@ discard block |
||
| 1055 | 1086 | do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent ); |
| 1056 | 1087 | |
| 1057 | 1088 | $mod_keys = trim( get_option('blacklist_keys') ); |
| 1058 | - if ( '' == $mod_keys ) |
|
| 1059 | - return false; // If moderation keys are empty |
|
| 1089 | + if ( '' == $mod_keys ) { |
|
| 1090 | + return false; |
|
| 1091 | + } |
|
| 1092 | + // If moderation keys are empty |
|
| 1060 | 1093 | $words = explode("\n", $mod_keys ); |
| 1061 | 1094 | |
| 1062 | 1095 | foreach ( (array) $words as $word ) { |
@@ -1077,8 +1110,9 @@ discard block |
||
| 1077 | 1110 | || preg_match($pattern, $comment) |
| 1078 | 1111 | || preg_match($pattern, $user_ip) |
| 1079 | 1112 | || preg_match($pattern, $user_agent) |
| 1080 | - ) |
|
| 1081 | - return true; |
|
| 1113 | + ) { |
|
| 1114 | + return true; |
|
| 1115 | + } |
|
| 1082 | 1116 | } |
| 1083 | 1117 | return false; |
| 1084 | 1118 | } |
@@ -1149,11 +1183,13 @@ discard block |
||
| 1149 | 1183 | */ |
| 1150 | 1184 | function wp_delete_comment($comment_id, $force_delete = false) { |
| 1151 | 1185 | global $wpdb; |
| 1152 | - if (!$comment = get_comment($comment_id)) |
|
| 1153 | - return false; |
|
| 1186 | + if (!$comment = get_comment($comment_id)) { |
|
| 1187 | + return false; |
|
| 1188 | + } |
|
| 1154 | 1189 | |
| 1155 | - if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) |
|
| 1156 | - return wp_trash_comment($comment_id); |
|
| 1190 | + if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) { |
|
| 1191 | + return wp_trash_comment($comment_id); |
|
| 1192 | + } |
|
| 1157 | 1193 | |
| 1158 | 1194 | /** |
| 1159 | 1195 | * Fires immediately before a comment is deleted from the database. |
@@ -1173,11 +1209,13 @@ discard block |
||
| 1173 | 1209 | |
| 1174 | 1210 | // Delete metadata |
| 1175 | 1211 | $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) ); |
| 1176 | - foreach ( $meta_ids as $mid ) |
|
| 1177 | - delete_metadata_by_mid( 'comment', $mid ); |
|
| 1212 | + foreach ( $meta_ids as $mid ) { |
|
| 1213 | + delete_metadata_by_mid( 'comment', $mid ); |
|
| 1214 | + } |
|
| 1178 | 1215 | |
| 1179 | - if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) ) |
|
| 1180 | - return false; |
|
| 1216 | + if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) ) { |
|
| 1217 | + return false; |
|
| 1218 | + } |
|
| 1181 | 1219 | |
| 1182 | 1220 | /** |
| 1183 | 1221 | * Fires immediately after a comment is deleted from the database. |
@@ -1189,8 +1227,9 @@ discard block |
||
| 1189 | 1227 | do_action( 'deleted_comment', $comment->comment_ID ); |
| 1190 | 1228 | |
| 1191 | 1229 | $post_id = $comment->comment_post_ID; |
| 1192 | - if ( $post_id && $comment->comment_approved == 1 ) |
|
| 1193 | - wp_update_comment_count($post_id); |
|
| 1230 | + if ( $post_id && $comment->comment_approved == 1 ) { |
|
| 1231 | + wp_update_comment_count($post_id); |
|
| 1232 | + } |
|
| 1194 | 1233 | |
| 1195 | 1234 | clean_comment_cache( $comment->comment_ID ); |
| 1196 | 1235 | |
@@ -1212,11 +1251,13 @@ discard block |
||
| 1212 | 1251 | * @return bool True on success, false on failure. |
| 1213 | 1252 | */ |
| 1214 | 1253 | function wp_trash_comment($comment_id) { |
| 1215 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 1216 | - return wp_delete_comment($comment_id, true); |
|
| 1254 | + if ( !EMPTY_TRASH_DAYS ) { |
|
| 1255 | + return wp_delete_comment($comment_id, true); |
|
| 1256 | + } |
|
| 1217 | 1257 | |
| 1218 | - if ( !$comment = get_comment($comment_id) ) |
|
| 1219 | - return false; |
|
| 1258 | + if ( !$comment = get_comment($comment_id) ) { |
|
| 1259 | + return false; |
|
| 1260 | + } |
|
| 1220 | 1261 | |
| 1221 | 1262 | /** |
| 1222 | 1263 | * Fires immediately before a comment is sent to the Trash. |
@@ -1271,8 +1312,9 @@ discard block |
||
| 1271 | 1312 | do_action( 'untrash_comment', $comment->comment_ID ); |
| 1272 | 1313 | |
| 1273 | 1314 | $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); |
| 1274 | - if ( empty($status) ) |
|
| 1275 | - $status = '0'; |
|
| 1315 | + if ( empty($status) ) { |
|
| 1316 | + $status = '0'; |
|
| 1317 | + } |
|
| 1276 | 1318 | |
| 1277 | 1319 | if ( wp_set_comment_status( $comment, $status ) ) { |
| 1278 | 1320 | delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); |
@@ -1357,8 +1399,9 @@ discard block |
||
| 1357 | 1399 | do_action( 'unspam_comment', $comment->comment_ID ); |
| 1358 | 1400 | |
| 1359 | 1401 | $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); |
| 1360 | - if ( empty($status) ) |
|
| 1361 | - $status = '0'; |
|
| 1402 | + if ( empty($status) ) { |
|
| 1403 | + $status = '0'; |
|
| 1404 | + } |
|
| 1362 | 1405 | |
| 1363 | 1406 | if ( wp_set_comment_status( $comment, $status ) ) { |
| 1364 | 1407 | delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); |
@@ -1387,24 +1430,26 @@ discard block |
||
| 1387 | 1430 | */ |
| 1388 | 1431 | function wp_get_comment_status($comment_id) { |
| 1389 | 1432 | $comment = get_comment($comment_id); |
| 1390 | - if ( !$comment ) |
|
| 1391 | - return false; |
|
| 1433 | + if ( !$comment ) { |
|
| 1434 | + return false; |
|
| 1435 | + } |
|
| 1392 | 1436 | |
| 1393 | 1437 | $approved = $comment->comment_approved; |
| 1394 | 1438 | |
| 1395 | - if ( $approved == null ) |
|
| 1396 | - return false; |
|
| 1397 | - elseif ( $approved == '1' ) |
|
| 1398 | - return 'approved'; |
|
| 1399 | - elseif ( $approved == '0' ) |
|
| 1400 | - return 'unapproved'; |
|
| 1401 | - elseif ( $approved == 'spam' ) |
|
| 1402 | - return 'spam'; |
|
| 1403 | - elseif ( $approved == 'trash' ) |
|
| 1404 | - return 'trash'; |
|
| 1405 | - else |
|
| 1406 | - return false; |
|
| 1407 | -} |
|
| 1439 | + if ( $approved == null ) { |
|
| 1440 | + return false; |
|
| 1441 | + } elseif ( $approved == '1' ) { |
|
| 1442 | + return 'approved'; |
|
| 1443 | + } elseif ( $approved == '0' ) { |
|
| 1444 | + return 'unapproved'; |
|
| 1445 | + } elseif ( $approved == 'spam' ) { |
|
| 1446 | + return 'spam'; |
|
| 1447 | + } elseif ( $approved == 'trash' ) { |
|
| 1448 | + return 'trash'; |
|
| 1449 | + } else { |
|
| 1450 | + return false; |
|
| 1451 | + } |
|
| 1452 | + } |
|
| 1408 | 1453 | |
| 1409 | 1454 | /** |
| 1410 | 1455 | * Call hooks for when a comment status transition occurs. |
@@ -1438,8 +1483,12 @@ discard block |
||
| 1438 | 1483 | 1 => 'approved', |
| 1439 | 1484 | 'approve' => 'approved', // wp_set_comment_status() uses "approve" |
| 1440 | 1485 | ); |
| 1441 | - if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status]; |
|
| 1442 | - if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status]; |
|
| 1486 | + if ( isset($comment_statuses[$new_status]) ) { |
|
| 1487 | + $new_status = $comment_statuses[$new_status]; |
|
| 1488 | + } |
|
| 1489 | + if ( isset($comment_statuses[$old_status]) ) { |
|
| 1490 | + $old_status = $comment_statuses[$old_status]; |
|
| 1491 | + } |
|
| 1443 | 1492 | |
| 1444 | 1493 | // Call the hooks |
| 1445 | 1494 | if ( $new_status != $old_status ) { |
@@ -1498,16 +1547,19 @@ discard block |
||
| 1498 | 1547 | // Cookies should already be sanitized. |
| 1499 | 1548 | |
| 1500 | 1549 | $comment_author = ''; |
| 1501 | - if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) |
|
| 1502 | - $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; |
|
| 1550 | + if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { |
|
| 1551 | + $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; |
|
| 1552 | + } |
|
| 1503 | 1553 | |
| 1504 | 1554 | $comment_author_email = ''; |
| 1505 | - if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) |
|
| 1506 | - $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; |
|
| 1555 | + if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { |
|
| 1556 | + $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; |
|
| 1557 | + } |
|
| 1507 | 1558 | |
| 1508 | 1559 | $comment_author_url = ''; |
| 1509 | - if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) |
|
| 1510 | - $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; |
|
| 1560 | + if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { |
|
| 1561 | + $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; |
|
| 1562 | + } |
|
| 1511 | 1563 | |
| 1512 | 1564 | /** |
| 1513 | 1565 | * Filter the current commenter's name, email, and URL. |
@@ -1691,10 +1743,13 @@ discard block |
||
| 1691 | 1743 | * @return bool Whether comment should be blocked. |
| 1692 | 1744 | */ |
| 1693 | 1745 | function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { |
| 1694 | - if ( $block ) // a plugin has already blocked... we'll let that decision stand |
|
| 1746 | + if ( $block ) { |
|
| 1747 | + // a plugin has already blocked... we'll let that decision stand |
|
| 1695 | 1748 | return $block; |
| 1696 | - if ( ($time_newcomment - $time_lastcomment) < 15 ) |
|
| 1697 | - return true; |
|
| 1749 | + } |
|
| 1750 | + if ( ($time_newcomment - $time_lastcomment) < 15 ) { |
|
| 1751 | + return true; |
|
| 1752 | + } |
|
| 1698 | 1753 | return false; |
| 1699 | 1754 | } |
| 1700 | 1755 | |
@@ -1931,10 +1986,11 @@ discard block |
||
| 1931 | 1986 | $comment_old = clone get_comment($comment_id); |
| 1932 | 1987 | |
| 1933 | 1988 | if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_old->comment_ID ) ) ) { |
| 1934 | - if ( $wp_error ) |
|
| 1935 | - return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); |
|
| 1936 | - else |
|
| 1937 | - return false; |
|
| 1989 | + if ( $wp_error ) { |
|
| 1990 | + return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); |
|
| 1991 | + } else { |
|
| 1992 | + return false; |
|
| 1993 | + } |
|
| 1938 | 1994 | } |
| 1939 | 1995 | |
| 1940 | 1996 | clean_comment_cache( $comment_old->comment_ID ); |
@@ -2061,8 +2117,9 @@ discard block |
||
| 2061 | 2117 | if ( is_bool($defer) ) { |
| 2062 | 2118 | $_defer = $defer; |
| 2063 | 2119 | // flush any deferred counts |
| 2064 | - if ( !$defer ) |
|
| 2065 | - wp_update_comment_count( null, true ); |
|
| 2120 | + if ( !$defer ) { |
|
| 2121 | + wp_update_comment_count( null, true ); |
|
| 2122 | + } |
|
| 2066 | 2123 | } |
| 2067 | 2124 | |
| 2068 | 2125 | return $_defer; |
@@ -2108,8 +2165,7 @@ discard block |
||
| 2108 | 2165 | if ( wp_defer_comment_counting() ) { |
| 2109 | 2166 | $_deferred[] = $post_id; |
| 2110 | 2167 | return true; |
| 2111 | - } |
|
| 2112 | - elseif ( $post_id ) { |
|
| 2168 | + } elseif ( $post_id ) { |
|
| 2113 | 2169 | return wp_update_comment_count_now($post_id); |
| 2114 | 2170 | } |
| 2115 | 2171 | |
@@ -2128,14 +2184,16 @@ discard block |
||
| 2128 | 2184 | function wp_update_comment_count_now($post_id) { |
| 2129 | 2185 | global $wpdb; |
| 2130 | 2186 | $post_id = (int) $post_id; |
| 2131 | - if ( !$post_id ) |
|
| 2132 | - return false; |
|
| 2187 | + if ( !$post_id ) { |
|
| 2188 | + return false; |
|
| 2189 | + } |
|
| 2133 | 2190 | |
| 2134 | 2191 | wp_cache_delete( 'comments-0', 'counts' ); |
| 2135 | 2192 | wp_cache_delete( "comments-{$post_id}", 'counts' ); |
| 2136 | 2193 | |
| 2137 | - if ( !$post = get_post($post_id) ) |
|
| 2138 | - return false; |
|
| 2194 | + if ( !$post = get_post($post_id) ) { |
|
| 2195 | + return false; |
|
| 2196 | + } |
|
| 2139 | 2197 | |
| 2140 | 2198 | $old = (int) $post->comment_count; |
| 2141 | 2199 | |
@@ -2194,8 +2252,9 @@ discard block |
||
| 2194 | 2252 | * @return false|string False on failure, string containing URI on success. |
| 2195 | 2253 | */ |
| 2196 | 2254 | function discover_pingback_server_uri( $url, $deprecated = '' ) { |
| 2197 | - if ( !empty( $deprecated ) ) |
|
| 2198 | - _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 2255 | + if ( !empty( $deprecated ) ) { |
|
| 2256 | + _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 2257 | + } |
|
| 2199 | 2258 | |
| 2200 | 2259 | $pingback_str_dquote = 'rel="pingback"'; |
| 2201 | 2260 | $pingback_str_squote = 'rel=\'pingback\''; |
@@ -2203,31 +2262,38 @@ discard block |
||
| 2203 | 2262 | /** @todo Should use Filter Extension or custom preg_match instead. */ |
| 2204 | 2263 | $parsed_url = parse_url($url); |
| 2205 | 2264 | |
| 2206 | - if ( ! isset( $parsed_url['host'] ) ) // Not a URL. This should never happen. |
|
| 2265 | + if ( ! isset( $parsed_url['host'] ) ) { |
|
| 2266 | + // Not a URL. This should never happen. |
|
| 2207 | 2267 | return false; |
| 2268 | + } |
|
| 2208 | 2269 | |
| 2209 | 2270 | //Do not search for a pingback server on our own uploads |
| 2210 | 2271 | $uploads_dir = wp_get_upload_dir(); |
| 2211 | - if ( 0 === strpos($url, $uploads_dir['baseurl']) ) |
|
| 2212 | - return false; |
|
| 2272 | + if ( 0 === strpos($url, $uploads_dir['baseurl']) ) { |
|
| 2273 | + return false; |
|
| 2274 | + } |
|
| 2213 | 2275 | |
| 2214 | 2276 | $response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
| 2215 | 2277 | |
| 2216 | - if ( is_wp_error( $response ) ) |
|
| 2217 | - return false; |
|
| 2278 | + if ( is_wp_error( $response ) ) { |
|
| 2279 | + return false; |
|
| 2280 | + } |
|
| 2218 | 2281 | |
| 2219 | - if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) |
|
| 2220 | - return wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 2282 | + if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) { |
|
| 2283 | + return wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 2284 | + } |
|
| 2221 | 2285 | |
| 2222 | 2286 | // Not an (x)html, sgml, or xml page, no use going further. |
| 2223 | - if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) |
|
| 2224 | - return false; |
|
| 2287 | + if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) { |
|
| 2288 | + return false; |
|
| 2289 | + } |
|
| 2225 | 2290 | |
| 2226 | 2291 | // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file) |
| 2227 | 2292 | $response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
| 2228 | 2293 | |
| 2229 | - if ( is_wp_error( $response ) ) |
|
| 2230 | - return false; |
|
| 2294 | + if ( is_wp_error( $response ) ) { |
|
| 2295 | + return false; |
|
| 2296 | + } |
|
| 2231 | 2297 | |
| 2232 | 2298 | $contents = wp_remote_retrieve_body( $response ); |
| 2233 | 2299 | |
@@ -2275,9 +2341,10 @@ discard block |
||
| 2275 | 2341 | |
| 2276 | 2342 | // Do Trackbacks |
| 2277 | 2343 | $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'"); |
| 2278 | - if ( is_array($trackbacks) ) |
|
| 2279 | - foreach ( $trackbacks as $trackback ) |
|
| 2344 | + if ( is_array($trackbacks) ) { |
|
| 2345 | + foreach ( $trackbacks as $trackback ) |
|
| 2280 | 2346 | do_trackbacks($trackback); |
| 2347 | + } |
|
| 2281 | 2348 | |
| 2282 | 2349 | //Do Update Services/Generic Pings |
| 2283 | 2350 | generic_ping(); |
@@ -2345,8 +2412,9 @@ discard block |
||
| 2345 | 2412 | $services = explode("\n", $services); |
| 2346 | 2413 | foreach ( (array) $services as $service ) { |
| 2347 | 2414 | $service = trim($service); |
| 2348 | - if ( '' != $service ) |
|
| 2349 | - weblog_ping($service); |
|
| 2415 | + if ( '' != $service ) { |
|
| 2416 | + weblog_ping($service); |
|
| 2417 | + } |
|
| 2350 | 2418 | } |
| 2351 | 2419 | |
| 2352 | 2420 | return $post_id; |
@@ -2389,10 +2457,11 @@ discard block |
||
| 2389 | 2457 | if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself |
| 2390 | 2458 | && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. |
| 2391 | 2459 | if ( $test = @parse_url($link_test) ) { |
| 2392 | - if ( isset($test['query']) ) |
|
| 2393 | - $post_links[] = $link_test; |
|
| 2394 | - elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) |
|
| 2395 | - $post_links[] = $link_test; |
|
| 2460 | + if ( isset($test['query']) ) { |
|
| 2461 | + $post_links[] = $link_test; |
|
| 2462 | + } elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) { |
|
| 2463 | + $post_links[] = $link_test; |
|
| 2464 | + } |
|
| 2396 | 2465 | } |
| 2397 | 2466 | endif; |
| 2398 | 2467 | endforeach; |
@@ -2436,8 +2505,10 @@ discard block |
||
| 2436 | 2505 | // when set to true, this outputs debug messages by itself |
| 2437 | 2506 | $client->debug = false; |
| 2438 | 2507 | |
| 2439 | - if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered |
|
| 2508 | + if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) { |
|
| 2509 | + // Already registered |
|
| 2440 | 2510 | add_ping( $post_ID, $pagelinkedto ); |
| 2511 | + } |
|
| 2441 | 2512 | } |
| 2442 | 2513 | } |
| 2443 | 2514 | } |
@@ -2451,11 +2522,12 @@ discard block |
||
| 2451 | 2522 | * @return mixed Empty string if blog is not public, returns $sites, if site is public. |
| 2452 | 2523 | */ |
| 2453 | 2524 | function privacy_ping_filter($sites) { |
| 2454 | - if ( '0' != get_option('blog_public') ) |
|
| 2455 | - return $sites; |
|
| 2456 | - else |
|
| 2457 | - return ''; |
|
| 2458 | -} |
|
| 2525 | + if ( '0' != get_option('blog_public') ) { |
|
| 2526 | + return $sites; |
|
| 2527 | + } else { |
|
| 2528 | + return ''; |
|
| 2529 | + } |
|
| 2530 | + } |
|
| 2459 | 2531 | |
| 2460 | 2532 | /** |
| 2461 | 2533 | * Send a Trackback. |
@@ -2475,8 +2547,9 @@ discard block |
||
| 2475 | 2547 | function trackback($trackback_url, $title, $excerpt, $ID) { |
| 2476 | 2548 | global $wpdb; |
| 2477 | 2549 | |
| 2478 | - if ( empty($trackback_url) ) |
|
| 2479 | - return; |
|
| 2550 | + if ( empty($trackback_url) ) { |
|
| 2551 | + return; |
|
| 2552 | + } |
|
| 2480 | 2553 | |
| 2481 | 2554 | $options = array(); |
| 2482 | 2555 | $options['timeout'] = 10; |
@@ -2489,8 +2562,9 @@ discard block |
||
| 2489 | 2562 | |
| 2490 | 2563 | $response = wp_safe_remote_post( $trackback_url, $options ); |
| 2491 | 2564 | |
| 2492 | - if ( is_wp_error( $response ) ) |
|
| 2493 | - return; |
|
| 2565 | + if ( is_wp_error( $response ) ) { |
|
| 2566 | + return; |
|
| 2567 | + } |
|
| 2494 | 2568 | |
| 2495 | 2569 | $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) ); |
| 2496 | 2570 | return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) ); |
@@ -2519,9 +2593,11 @@ discard block |
||
| 2519 | 2593 | // when set to true, this outputs debug messages by itself |
| 2520 | 2594 | $client->debug = false; |
| 2521 | 2595 | $home = trailingslashit( home_url() ); |
| 2522 | - if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping |
|
| 2596 | + if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) { |
|
| 2597 | + // then try a normal ping |
|
| 2523 | 2598 | $client->query('weblogUpdates.ping', get_option('blogname'), $home); |
| 2524 | -} |
|
| 2599 | + } |
|
| 2600 | + } |
|
| 2525 | 2601 | |
| 2526 | 2602 | /** |
| 2527 | 2603 | * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI |
@@ -2549,8 +2625,9 @@ discard block |
||
| 2549 | 2625 | * @return IXR_Error |
| 2550 | 2626 | */ |
| 2551 | 2627 | function xmlrpc_pingback_error( $ixr_error ) { |
| 2552 | - if ( $ixr_error->code === 48 ) |
|
| 2553 | - return $ixr_error; |
|
| 2628 | + if ( $ixr_error->code === 48 ) { |
|
| 2629 | + return $ixr_error; |
|
| 2630 | + } |
|
| 2554 | 2631 | return new IXR_Error( 0, '' ); |
| 2555 | 2632 | } |
| 2556 | 2633 | |
@@ -2596,8 +2673,9 @@ discard block |
||
| 2596 | 2673 | * @param bool $update_meta_cache Whether to update commentmeta cache. Default true. |
| 2597 | 2674 | */ |
| 2598 | 2675 | function update_comment_cache( $comments, $update_meta_cache = true ) { |
| 2599 | - foreach ( (array) $comments as $comment ) |
|
| 2600 | - wp_cache_add($comment->comment_ID, $comment, 'comment'); |
|
| 2676 | + foreach ( (array) $comments as $comment ) { |
|
| 2677 | + wp_cache_add($comment->comment_ID, $comment, 'comment'); |
|
| 2678 | + } |
|
| 2601 | 2679 | |
| 2602 | 2680 | if ( $update_meta_cache ) { |
| 2603 | 2681 | // Avoid `wp_list_pluck()` in case `$comments` is passed by reference. |
@@ -2647,8 +2725,9 @@ discard block |
||
| 2647 | 2725 | * @return array |
| 2648 | 2726 | */ |
| 2649 | 2727 | function _close_comments_for_old_posts( $posts, $query ) { |
| 2650 | - if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
|
| 2651 | - return $posts; |
|
| 2728 | + if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) { |
|
| 2729 | + return $posts; |
|
| 2730 | + } |
|
| 2652 | 2731 | |
| 2653 | 2732 | /** |
| 2654 | 2733 | * Filter the list of post types to automatically close comments for. |
@@ -2658,12 +2737,14 @@ discard block |
||
| 2658 | 2737 | * @param array $post_types An array of registered post types. Default array with 'post'. |
| 2659 | 2738 | */ |
| 2660 | 2739 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
| 2661 | - if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
|
| 2662 | - return $posts; |
|
| 2740 | + if ( ! in_array( $posts[0]->post_type, $post_types ) ) { |
|
| 2741 | + return $posts; |
|
| 2742 | + } |
|
| 2663 | 2743 | |
| 2664 | 2744 | $days_old = (int) get_option( 'close_comments_days_old' ); |
| 2665 | - if ( ! $days_old ) |
|
| 2666 | - return $posts; |
|
| 2745 | + if ( ! $days_old ) { |
|
| 2746 | + return $posts; |
|
| 2747 | + } |
|
| 2667 | 2748 | |
| 2668 | 2749 | if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
| 2669 | 2750 | $posts[0]->comment_status = 'closed'; |
@@ -2684,30 +2765,35 @@ discard block |
||
| 2684 | 2765 | * @return bool $open |
| 2685 | 2766 | */ |
| 2686 | 2767 | function _close_comments_for_old_post( $open, $post_id ) { |
| 2687 | - if ( ! $open ) |
|
| 2688 | - return $open; |
|
| 2768 | + if ( ! $open ) { |
|
| 2769 | + return $open; |
|
| 2770 | + } |
|
| 2689 | 2771 | |
| 2690 | - if ( !get_option('close_comments_for_old_posts') ) |
|
| 2691 | - return $open; |
|
| 2772 | + if ( !get_option('close_comments_for_old_posts') ) { |
|
| 2773 | + return $open; |
|
| 2774 | + } |
|
| 2692 | 2775 | |
| 2693 | 2776 | $days_old = (int) get_option('close_comments_days_old'); |
| 2694 | - if ( !$days_old ) |
|
| 2695 | - return $open; |
|
| 2777 | + if ( !$days_old ) { |
|
| 2778 | + return $open; |
|
| 2779 | + } |
|
| 2696 | 2780 | |
| 2697 | 2781 | $post = get_post($post_id); |
| 2698 | 2782 | |
| 2699 | 2783 | /** This filter is documented in wp-includes/comment.php */ |
| 2700 | 2784 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
| 2701 | - if ( ! in_array( $post->post_type, $post_types ) ) |
|
| 2702 | - return $open; |
|
| 2785 | + if ( ! in_array( $post->post_type, $post_types ) ) { |
|
| 2786 | + return $open; |
|
| 2787 | + } |
|
| 2703 | 2788 | |
| 2704 | 2789 | // Undated drafts should not show up as comments closed. |
| 2705 | 2790 | if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { |
| 2706 | 2791 | return $open; |
| 2707 | 2792 | } |
| 2708 | 2793 | |
| 2709 | - if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) |
|
| 2710 | - return false; |
|
| 2794 | + if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
|
| 2795 | + return false; |
|
| 2796 | + } |
|
| 2711 | 2797 | |
| 2712 | 2798 | return $open; |
| 2713 | 2799 | } |
@@ -274,7 +274,7 @@ |
||
| 274 | 274 | * |
| 275 | 275 | * @param WP_Customize_Partial $partial Partial. |
| 276 | 276 | * @param array $context Context. |
| 277 | - * @return string|array|false |
|
| 277 | + * @return boolean |
|
| 278 | 278 | */ |
| 279 | 279 | public function render_callback( WP_Customize_Partial $partial, $context = array() ) { |
| 280 | 280 | unset( $partial, $context ); |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Customize API: WP_Customize_Partial class |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Customize |
|
| 7 | - * @since 4.5.0 |
|
| 8 | - */ |
|
| 3 | + * Customize API: WP_Customize_Partial class |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Customize |
|
| 7 | + * @since 4.5.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Core Customizer class for implementing selective refresh partials. |
@@ -151,32 +151,32 @@ discard block |
||
| 151 | 151 | * @type array|string $settings All settings IDs tied to the partial. If undefined, `$id` will be used. |
| 152 | 152 | * } |
| 153 | 153 | */ |
| 154 | - public function __construct( WP_Customize_Selective_Refresh $component, $id, $args = array() ) { |
|
| 155 | - $keys = array_keys( get_object_vars( $this ) ); |
|
| 156 | - foreach ( $keys as $key ) { |
|
| 157 | - if ( isset( $args[ $key ] ) ) { |
|
| 158 | - $this->$key = $args[ $key ]; |
|
| 154 | + public function __construct(WP_Customize_Selective_Refresh $component, $id, $args = array()) { |
|
| 155 | + $keys = array_keys(get_object_vars($this)); |
|
| 156 | + foreach ($keys as $key) { |
|
| 157 | + if (isset($args[$key])) { |
|
| 158 | + $this->$key = $args[$key]; |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $this->component = $component; |
| 163 | 163 | $this->id = $id; |
| 164 | - $this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) ); |
|
| 165 | - $this->id_data['base'] = array_shift( $this->id_data['keys'] ); |
|
| 164 | + $this->id_data['keys'] = preg_split('/\[/', str_replace(']', '', $this->id)); |
|
| 165 | + $this->id_data['base'] = array_shift($this->id_data['keys']); |
|
| 166 | 166 | |
| 167 | - if ( empty( $this->render_callback ) ) { |
|
| 168 | - $this->render_callback = array( $this, 'render_callback' ); |
|
| 167 | + if (empty($this->render_callback)) { |
|
| 168 | + $this->render_callback = array($this, 'render_callback'); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Process settings. |
| 172 | - if ( ! isset( $this->settings ) ) { |
|
| 173 | - $this->settings = array( $id ); |
|
| 174 | - } else if ( is_string( $this->settings ) ) { |
|
| 175 | - $this->settings = array( $this->settings ); |
|
| 172 | + if ( ! isset($this->settings)) { |
|
| 173 | + $this->settings = array($id); |
|
| 174 | + } else if (is_string($this->settings)) { |
|
| 175 | + $this->settings = array($this->settings); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ( empty( $this->primary_setting ) ) { |
|
| 179 | - $this->primary_setting = current( $this->settings ); |
|
| 178 | + if (empty($this->primary_setting)) { |
|
| 179 | + $this->primary_setting = current($this->settings); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -208,17 +208,17 @@ discard block |
||
| 208 | 208 | * @return string|array|false The rendered partial as a string, raw data array (for client-side JS template), |
| 209 | 209 | * or false if no render applied. |
| 210 | 210 | */ |
| 211 | - final public function render( $container_context = array() ) { |
|
| 211 | + final public function render($container_context = array()) { |
|
| 212 | 212 | $partial = $this; |
| 213 | 213 | $rendered = false; |
| 214 | 214 | |
| 215 | - if ( ! empty( $this->render_callback ) ) { |
|
| 215 | + if ( ! empty($this->render_callback)) { |
|
| 216 | 216 | ob_start(); |
| 217 | - $return_render = call_user_func( $this->render_callback, $this, $container_context ); |
|
| 217 | + $return_render = call_user_func($this->render_callback, $this, $container_context); |
|
| 218 | 218 | $ob_render = ob_get_clean(); |
| 219 | 219 | |
| 220 | - if ( null !== $return_render && '' !== $ob_render ) { |
|
| 221 | - _doing_it_wrong( __FUNCTION__, __( 'Partial render must echo the content or return the content string (or array), but not both.' ), '4.5.0' ); |
|
| 220 | + if (null !== $return_render && '' !== $ob_render) { |
|
| 221 | + _doing_it_wrong(__FUNCTION__, __('Partial render must echo the content or return the content string (or array), but not both.'), '4.5.0'); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /* |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @param array $container_context Optional array of context data associated with |
| 239 | 239 | * the target container. |
| 240 | 240 | */ |
| 241 | - $rendered = apply_filters( 'customize_partial_render', $rendered, $partial, $container_context ); |
|
| 241 | + $rendered = apply_filters('customize_partial_render', $rendered, $partial, $container_context); |
|
| 242 | 242 | |
| 243 | 243 | /** |
| 244 | 244 | * Filters partial rendering for a specific partial. |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param array $container_context Optional array of context data associated with |
| 253 | 253 | * the target container. |
| 254 | 254 | */ |
| 255 | - $rendered = apply_filters( "customize_partial_render_{$partial->id}", $rendered, $partial, $container_context ); |
|
| 255 | + $rendered = apply_filters("customize_partial_render_{$partial->id}", $rendered, $partial, $container_context); |
|
| 256 | 256 | |
| 257 | 257 | return $rendered; |
| 258 | 258 | } |
@@ -276,8 +276,8 @@ discard block |
||
| 276 | 276 | * @param array $context Context. |
| 277 | 277 | * @return string|array|false |
| 278 | 278 | */ |
| 279 | - public function render_callback( WP_Customize_Partial $partial, $context = array() ) { |
|
| 280 | - unset( $partial, $context ); |
|
| 279 | + public function render_callback(WP_Customize_Partial $partial, $context = array()) { |
|
| 280 | + unset($partial, $context); |
|
| 281 | 281 | return false; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | * or if one of the associated settings does not exist. |
| 315 | 315 | */ |
| 316 | 316 | final public function check_capabilities() { |
| 317 | - if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) { |
|
| 317 | + if ( ! empty($this->capability) && ! current_user_can($this->capability)) { |
|
| 318 | 318 | return false; |
| 319 | 319 | } |
| 320 | - foreach ( $this->settings as $setting_id ) { |
|
| 321 | - $setting = $this->component->manager->get_setting( $setting_id ); |
|
| 322 | - if ( ! $setting || ! $setting->check_capabilities() ) { |
|
| 320 | + foreach ($this->settings as $setting_id) { |
|
| 321 | + $setting = $this->component->manager->get_setting($setting_id); |
|
| 322 | + if ( ! $setting || ! $setting->check_capabilities()) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | } |