@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | -if ( !current_user_can('upload_files') ) |
|
12 | +if ( !current_user_can('upload_files') ) { |
|
13 | 13 | wp_die( __( 'You do not have permission to upload files.' ) ); |
14 | +} |
|
14 | 15 | |
15 | 16 | $mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; |
16 | 17 | $modes = array( 'grid', 'list' ); |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | |
115 | 116 | $location = 'upload.php'; |
116 | 117 | if ( $referer = wp_get_referer() ) { |
117 | - if ( false !== strpos( $referer, 'upload.php' ) ) |
|
118 | - $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); |
|
118 | + if ( false !== strpos( $referer, 'upload.php' ) ) { |
|
119 | + $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); |
|
120 | + } |
|
119 | 121 | } |
120 | 122 | |
121 | 123 | switch ( $doaction ) { |
@@ -128,38 +130,47 @@ discard block |
||
128 | 130 | break; |
129 | 131 | |
130 | 132 | case 'trash': |
131 | - if ( !isset( $post_ids ) ) |
|
132 | - break; |
|
133 | + if ( !isset( $post_ids ) ) { |
|
134 | + break; |
|
135 | + } |
|
133 | 136 | foreach ( (array) $post_ids as $post_id ) { |
134 | - if ( !current_user_can( 'delete_post', $post_id ) ) |
|
135 | - wp_die( __( 'You are not allowed to move this item to the Trash.' ) ); |
|
137 | + if ( !current_user_can( 'delete_post', $post_id ) ) { |
|
138 | + wp_die( __( 'You are not allowed to move this item to the Trash.' ) ); |
|
139 | + } |
|
136 | 140 | |
137 | - if ( !wp_trash_post( $post_id ) ) |
|
138 | - wp_die( __( 'Error in moving to Trash.' ) ); |
|
141 | + if ( !wp_trash_post( $post_id ) ) { |
|
142 | + wp_die( __( 'Error in moving to Trash.' ) ); |
|
143 | + } |
|
139 | 144 | } |
140 | 145 | $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); |
141 | 146 | break; |
142 | 147 | case 'untrash': |
143 | - if ( !isset( $post_ids ) ) |
|
144 | - break; |
|
148 | + if ( !isset( $post_ids ) ) { |
|
149 | + break; |
|
150 | + } |
|
145 | 151 | foreach ( (array) $post_ids as $post_id ) { |
146 | - if ( !current_user_can( 'delete_post', $post_id ) ) |
|
147 | - wp_die( __( 'You are not allowed to move this item out of the Trash.' ) ); |
|
152 | + if ( !current_user_can( 'delete_post', $post_id ) ) { |
|
153 | + wp_die( __( 'You are not allowed to move this item out of the Trash.' ) ); |
|
154 | + } |
|
148 | 155 | |
149 | - if ( !wp_untrash_post( $post_id ) ) |
|
150 | - wp_die( __( 'Error in restoring from Trash.' ) ); |
|
156 | + if ( !wp_untrash_post( $post_id ) ) { |
|
157 | + wp_die( __( 'Error in restoring from Trash.' ) ); |
|
158 | + } |
|
151 | 159 | } |
152 | 160 | $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); |
153 | 161 | break; |
154 | 162 | case 'delete': |
155 | - if ( !isset( $post_ids ) ) |
|
156 | - break; |
|
163 | + if ( !isset( $post_ids ) ) { |
|
164 | + break; |
|
165 | + } |
|
157 | 166 | foreach ( (array) $post_ids as $post_id_del ) { |
158 | - if ( !current_user_can( 'delete_post', $post_id_del ) ) |
|
159 | - wp_die( __( 'You are not allowed to delete this item.' ) ); |
|
167 | + if ( !current_user_can( 'delete_post', $post_id_del ) ) { |
|
168 | + wp_die( __( 'You are not allowed to delete this item.' ) ); |
|
169 | + } |
|
160 | 170 | |
161 | - if ( !wp_delete_attachment( $post_id_del ) ) |
|
162 | - wp_die( __( 'Error in deleting.' ) ); |
|
171 | + if ( !wp_delete_attachment( $post_id_del ) ) { |
|
172 | + wp_die( __( 'Error in deleting.' ) ); |
|
173 | + } |
|
163 | 174 | } |
164 | 175 | $location = add_query_arg( 'deleted', count( $post_ids ), $location ); |
165 | 176 | break; |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | /** Include user install customize script. */ |
12 | -if ( file_exists(WP_CONTENT_DIR . '/install.php') ) |
|
12 | +if ( file_exists(WP_CONTENT_DIR . '/install.php') ) { |
|
13 | 13 | require (WP_CONTENT_DIR . '/install.php'); |
14 | +} |
|
14 | 15 | |
15 | 16 | /** WordPress Administration API */ |
16 | 17 | require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | * @return array Array keys 'url', 'user_id', 'password', and 'password_message'. |
38 | 39 | */ |
39 | 40 | function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { |
40 | - if ( !empty( $deprecated ) ) |
|
41 | - _deprecated_argument( __FUNCTION__, '2.6' ); |
|
41 | + if ( !empty( $deprecated ) ) { |
|
42 | + _deprecated_argument( __FUNCTION__, '2.6' ); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | wp_check_mysql_version(); |
44 | 46 | wp_cache_flush(); |
@@ -59,8 +61,9 @@ discard block |
||
59 | 61 | update_option('siteurl', $guessurl); |
60 | 62 | |
61 | 63 | // If not a public blog, don't ping. |
62 | - if ( ! $public ) |
|
63 | - update_option('default_pingback_flag', 0); |
|
64 | + if ( ! $public ) { |
|
65 | + update_option('default_pingback_flag', 0); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | /* |
66 | 69 | * Create default user. If the user already exists, the user tables are |
@@ -220,8 +223,9 @@ discard block |
||
220 | 223 | <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote> |
221 | 224 | |
222 | 225 | As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() ); |
223 | - if ( is_multisite() ) |
|
224 | - $first_page = get_site_option( 'first_page', $first_page ); |
|
226 | + if ( is_multisite() ) { |
|
227 | + $first_page = get_site_option( 'first_page', $first_page ); |
|
228 | + } |
|
225 | 229 | $first_post_guid = get_option('home') . '/?page_id=2'; |
226 | 230 | $wpdb->insert( $wpdb->posts, array( |
227 | 231 | 'post_author' => $user_id, |
@@ -252,10 +256,11 @@ discard block |
||
252 | 256 | update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); |
253 | 257 | update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) ); |
254 | 258 | |
255 | - if ( ! is_multisite() ) |
|
256 | - update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
257 | - elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) |
|
258 | - update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
259 | + if ( ! is_multisite() ) { |
|
260 | + update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
261 | + } elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) { |
|
262 | + update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
263 | + } |
|
259 | 264 | |
260 | 265 | if ( is_multisite() ) { |
261 | 266 | // Flush rules to pick up the new page. |
@@ -270,8 +275,9 @@ discard block |
||
270 | 275 | $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') ); |
271 | 276 | |
272 | 277 | // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. |
273 | - if ( !is_super_admin( $user_id ) && $user_id != 1 ) |
|
274 | - $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
278 | + if ( !is_super_admin( $user_id ) && $user_id != 1 ) { |
|
279 | + $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
280 | + } |
|
275 | 281 | } |
276 | 282 | } |
277 | 283 | endif; |
@@ -407,26 +413,30 @@ discard block |
||
407 | 413 | $wp_current_db_version = __get_option('db_version'); |
408 | 414 | |
409 | 415 | // We are up-to-date. Nothing to do. |
410 | - if ( $wp_db_version == $wp_current_db_version ) |
|
411 | - return; |
|
416 | + if ( $wp_db_version == $wp_current_db_version ) { |
|
417 | + return; |
|
418 | + } |
|
412 | 419 | |
413 | - if ( ! is_blog_installed() ) |
|
414 | - return; |
|
420 | + if ( ! is_blog_installed() ) { |
|
421 | + return; |
|
422 | + } |
|
415 | 423 | |
416 | 424 | wp_check_mysql_version(); |
417 | 425 | wp_cache_flush(); |
418 | 426 | pre_schema_upgrade(); |
419 | 427 | make_db_current_silent(); |
420 | 428 | upgrade_all(); |
421 | - if ( is_multisite() && is_main_site() ) |
|
422 | - upgrade_network(); |
|
429 | + if ( is_multisite() && is_main_site() ) { |
|
430 | + upgrade_network(); |
|
431 | + } |
|
423 | 432 | wp_cache_flush(); |
424 | 433 | |
425 | 434 | if ( is_multisite() ) { |
426 | - if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) |
|
427 | - $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
428 | - else |
|
429 | - $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
435 | + if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) { |
|
436 | + $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
437 | + } else { |
|
438 | + $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
439 | + } |
|
430 | 440 | } |
431 | 441 | |
432 | 442 | /** |
@@ -458,8 +468,9 @@ discard block |
||
458 | 468 | $wp_current_db_version = __get_option('db_version'); |
459 | 469 | |
460 | 470 | // We are up-to-date. Nothing to do. |
461 | - if ( $wp_db_version == $wp_current_db_version ) |
|
462 | - return; |
|
471 | + if ( $wp_db_version == $wp_current_db_version ) { |
|
472 | + return; |
|
473 | + } |
|
463 | 474 | |
464 | 475 | // If the version is not set in the DB, try to guess the version. |
465 | 476 | if ( empty($wp_current_db_version) ) { |
@@ -467,12 +478,14 @@ discard block |
||
467 | 478 | |
468 | 479 | // If the template option exists, we have 1.5. |
469 | 480 | $template = __get_option('template'); |
470 | - if ( !empty($template) ) |
|
471 | - $wp_current_db_version = 2541; |
|
481 | + if ( !empty($template) ) { |
|
482 | + $wp_current_db_version = 2541; |
|
483 | + } |
|
472 | 484 | } |
473 | 485 | |
474 | - if ( $wp_current_db_version < 6039 ) |
|
475 | - upgrade_230_options_table(); |
|
486 | + if ( $wp_current_db_version < 6039 ) { |
|
487 | + upgrade_230_options_table(); |
|
488 | + } |
|
476 | 489 | |
477 | 490 | populate_options(); |
478 | 491 | |
@@ -483,74 +496,97 @@ discard block |
||
483 | 496 | upgrade_130(); |
484 | 497 | } |
485 | 498 | |
486 | - if ( $wp_current_db_version < 3308 ) |
|
487 | - upgrade_160(); |
|
499 | + if ( $wp_current_db_version < 3308 ) { |
|
500 | + upgrade_160(); |
|
501 | + } |
|
488 | 502 | |
489 | - if ( $wp_current_db_version < 4772 ) |
|
490 | - upgrade_210(); |
|
503 | + if ( $wp_current_db_version < 4772 ) { |
|
504 | + upgrade_210(); |
|
505 | + } |
|
491 | 506 | |
492 | - if ( $wp_current_db_version < 4351 ) |
|
493 | - upgrade_old_slugs(); |
|
507 | + if ( $wp_current_db_version < 4351 ) { |
|
508 | + upgrade_old_slugs(); |
|
509 | + } |
|
494 | 510 | |
495 | - if ( $wp_current_db_version < 5539 ) |
|
496 | - upgrade_230(); |
|
511 | + if ( $wp_current_db_version < 5539 ) { |
|
512 | + upgrade_230(); |
|
513 | + } |
|
497 | 514 | |
498 | - if ( $wp_current_db_version < 6124 ) |
|
499 | - upgrade_230_old_tables(); |
|
515 | + if ( $wp_current_db_version < 6124 ) { |
|
516 | + upgrade_230_old_tables(); |
|
517 | + } |
|
500 | 518 | |
501 | - if ( $wp_current_db_version < 7499 ) |
|
502 | - upgrade_250(); |
|
519 | + if ( $wp_current_db_version < 7499 ) { |
|
520 | + upgrade_250(); |
|
521 | + } |
|
503 | 522 | |
504 | - if ( $wp_current_db_version < 7935 ) |
|
505 | - upgrade_252(); |
|
523 | + if ( $wp_current_db_version < 7935 ) { |
|
524 | + upgrade_252(); |
|
525 | + } |
|
506 | 526 | |
507 | - if ( $wp_current_db_version < 8201 ) |
|
508 | - upgrade_260(); |
|
527 | + if ( $wp_current_db_version < 8201 ) { |
|
528 | + upgrade_260(); |
|
529 | + } |
|
509 | 530 | |
510 | - if ( $wp_current_db_version < 8989 ) |
|
511 | - upgrade_270(); |
|
531 | + if ( $wp_current_db_version < 8989 ) { |
|
532 | + upgrade_270(); |
|
533 | + } |
|
512 | 534 | |
513 | - if ( $wp_current_db_version < 10360 ) |
|
514 | - upgrade_280(); |
|
535 | + if ( $wp_current_db_version < 10360 ) { |
|
536 | + upgrade_280(); |
|
537 | + } |
|
515 | 538 | |
516 | - if ( $wp_current_db_version < 11958 ) |
|
517 | - upgrade_290(); |
|
539 | + if ( $wp_current_db_version < 11958 ) { |
|
540 | + upgrade_290(); |
|
541 | + } |
|
518 | 542 | |
519 | - if ( $wp_current_db_version < 15260 ) |
|
520 | - upgrade_300(); |
|
543 | + if ( $wp_current_db_version < 15260 ) { |
|
544 | + upgrade_300(); |
|
545 | + } |
|
521 | 546 | |
522 | - if ( $wp_current_db_version < 19389 ) |
|
523 | - upgrade_330(); |
|
547 | + if ( $wp_current_db_version < 19389 ) { |
|
548 | + upgrade_330(); |
|
549 | + } |
|
524 | 550 | |
525 | - if ( $wp_current_db_version < 20080 ) |
|
526 | - upgrade_340(); |
|
551 | + if ( $wp_current_db_version < 20080 ) { |
|
552 | + upgrade_340(); |
|
553 | + } |
|
527 | 554 | |
528 | - if ( $wp_current_db_version < 22422 ) |
|
529 | - upgrade_350(); |
|
555 | + if ( $wp_current_db_version < 22422 ) { |
|
556 | + upgrade_350(); |
|
557 | + } |
|
530 | 558 | |
531 | - if ( $wp_current_db_version < 25824 ) |
|
532 | - upgrade_370(); |
|
559 | + if ( $wp_current_db_version < 25824 ) { |
|
560 | + upgrade_370(); |
|
561 | + } |
|
533 | 562 | |
534 | - if ( $wp_current_db_version < 26148 ) |
|
535 | - upgrade_372(); |
|
563 | + if ( $wp_current_db_version < 26148 ) { |
|
564 | + upgrade_372(); |
|
565 | + } |
|
536 | 566 | |
537 | - if ( $wp_current_db_version < 26691 ) |
|
538 | - upgrade_380(); |
|
567 | + if ( $wp_current_db_version < 26691 ) { |
|
568 | + upgrade_380(); |
|
569 | + } |
|
539 | 570 | |
540 | - if ( $wp_current_db_version < 29630 ) |
|
541 | - upgrade_400(); |
|
571 | + if ( $wp_current_db_version < 29630 ) { |
|
572 | + upgrade_400(); |
|
573 | + } |
|
542 | 574 | |
543 | - if ( $wp_current_db_version < 33055 ) |
|
544 | - upgrade_430(); |
|
575 | + if ( $wp_current_db_version < 33055 ) { |
|
576 | + upgrade_430(); |
|
577 | + } |
|
545 | 578 | |
546 | - if ( $wp_current_db_version < 33056 ) |
|
547 | - upgrade_431(); |
|
579 | + if ( $wp_current_db_version < 33056 ) { |
|
580 | + upgrade_431(); |
|
581 | + } |
|
548 | 582 | |
549 | - if ( $wp_current_db_version < 35700 ) |
|
550 | - upgrade_440(); |
|
583 | + if ( $wp_current_db_version < 35700 ) { |
|
584 | + upgrade_440(); |
|
585 | + } |
|
551 | 586 | |
552 | - if ( $wp_current_db_version < 36686 ) |
|
553 | - upgrade_450(); |
|
587 | + if ( $wp_current_db_version < 36686 ) { |
|
588 | + upgrade_450(); |
|
589 | + } |
|
554 | 590 | |
555 | 591 | maybe_disable_link_manager(); |
556 | 592 | |
@@ -603,8 +639,10 @@ discard block |
||
603 | 639 | $done_posts[] = $done_id->post_id; |
604 | 640 | endforeach; |
605 | 641 | $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; |
606 | - else: |
|
642 | + else { |
|
643 | + : |
|
607 | 644 | $catwhere = ''; |
645 | + } |
|
608 | 646 | endif; |
609 | 647 | |
610 | 648 | $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); |
@@ -721,10 +759,11 @@ discard block |
||
721 | 759 | $post_content = addslashes(deslash($post->post_content)); |
722 | 760 | $post_title = addslashes(deslash($post->post_title)); |
723 | 761 | $post_excerpt = addslashes(deslash($post->post_excerpt)); |
724 | - if ( empty($post->guid) ) |
|
725 | - $guid = get_permalink($post->ID); |
|
726 | - else |
|
727 | - $guid = $post->guid; |
|
762 | + if ( empty($post->guid) ) { |
|
763 | + $guid = get_permalink($post->ID); |
|
764 | + } else { |
|
765 | + $guid = $post->guid; |
|
766 | + } |
|
728 | 767 | |
729 | 768 | $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); |
730 | 769 | |
@@ -806,34 +845,57 @@ discard block |
||
806 | 845 | |
807 | 846 | $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); |
808 | 847 | foreach ( $users as $user ) : |
809 | - if ( !empty( $user->user_firstname ) ) |
|
810 | - update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
811 | - if ( !empty( $user->user_lastname ) ) |
|
812 | - update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
813 | - if ( !empty( $user->user_nickname ) ) |
|
814 | - update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
815 | - if ( !empty( $user->user_level ) ) |
|
816 | - update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
817 | - if ( !empty( $user->user_icq ) ) |
|
818 | - update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
819 | - if ( !empty( $user->user_aim ) ) |
|
820 | - update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
821 | - if ( !empty( $user->user_msn ) ) |
|
822 | - update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
823 | - if ( !empty( $user->user_yim ) ) |
|
824 | - update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
825 | - if ( !empty( $user->user_description ) ) |
|
826 | - update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
848 | + if ( !empty( $user->user_firstname ) ) { |
|
849 | + update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
850 | + } |
|
851 | + if ( !empty( $user->user_lastname ) ) { |
|
852 | + update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
853 | + } |
|
854 | + if ( !empty( $user->user_nickname ) ) { |
|
855 | + update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
856 | + } |
|
857 | + if ( !empty( $user->user_level ) ) { |
|
858 | + update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
859 | + } |
|
860 | + if ( !empty( $user->user_icq ) ) { |
|
861 | + update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
862 | + } |
|
863 | + if ( !empty( $user->user_aim ) ) { |
|
864 | + update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
865 | + } |
|
866 | + if ( !empty( $user->user_msn ) ) { |
|
867 | + update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
868 | + } |
|
869 | + if ( !empty( $user->user_yim ) ) { |
|
870 | + update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
871 | + } |
|
872 | + if ( !empty( $user->user_description ) ) { |
|
873 | + update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
874 | + } |
|
827 | 875 | |
828 | 876 | if ( isset( $user->user_idmode ) ): |
829 | 877 | $idmode = $user->user_idmode; |
830 | - if ($idmode == 'nickname') $id = $user->user_nickname; |
|
831 | - if ($idmode == 'login') $id = $user->user_login; |
|
832 | - if ($idmode == 'firstname') $id = $user->user_firstname; |
|
833 | - if ($idmode == 'lastname') $id = $user->user_lastname; |
|
834 | - if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; |
|
835 | - if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; |
|
836 | - if (!$idmode) $id = $user->user_nickname; |
|
878 | + if ($idmode == 'nickname') { |
|
879 | + $id = $user->user_nickname; |
|
880 | + } |
|
881 | + if ($idmode == 'login') { |
|
882 | + $id = $user->user_login; |
|
883 | + } |
|
884 | + if ($idmode == 'firstname') { |
|
885 | + $id = $user->user_firstname; |
|
886 | + } |
|
887 | + if ($idmode == 'lastname') { |
|
888 | + $id = $user->user_lastname; |
|
889 | + } |
|
890 | + if ($idmode == 'namefl') { |
|
891 | + $id = $user->user_firstname.' '.$user->user_lastname; |
|
892 | + } |
|
893 | + if ($idmode == 'namelf') { |
|
894 | + $id = $user->user_lastname.' '.$user->user_firstname; |
|
895 | + } |
|
896 | + if (!$idmode) { |
|
897 | + $id = $user->user_nickname; |
|
898 | + } |
|
837 | 899 | $wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) ); |
838 | 900 | endif; |
839 | 901 | |
@@ -848,15 +910,17 @@ discard block |
||
848 | 910 | endforeach; |
849 | 911 | $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); |
850 | 912 | $wpdb->hide_errors(); |
851 | - foreach ( $old_user_fields as $old ) |
|
852 | - $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
|
913 | + foreach ( $old_user_fields as $old ) { |
|
914 | + $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
|
915 | + } |
|
853 | 916 | $wpdb->show_errors(); |
854 | 917 | |
855 | 918 | // Populate comment_count field of posts table. |
856 | 919 | $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); |
857 | - if ( is_array( $comments ) ) |
|
858 | - foreach ($comments as $comment) |
|
920 | + if ( is_array( $comments ) ) { |
|
921 | + foreach ($comments as $comment) |
|
859 | 922 | $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); |
923 | + } |
|
860 | 924 | |
861 | 925 | /* |
862 | 926 | * Some alpha versions used a post status of object instead of attachment |
@@ -871,8 +935,9 @@ discard block |
||
871 | 935 | array( 'ID' => $object->ID ) ); |
872 | 936 | |
873 | 937 | $meta = get_post_meta($object->ID, 'imagedata', true); |
874 | - if ( ! empty($meta['file']) ) |
|
875 | - update_attached_file( $object->ID, $meta['file'] ); |
|
938 | + if ( ! empty($meta['file']) ) { |
|
939 | + update_attached_file( $object->ID, $meta['file'] ); |
|
940 | + } |
|
876 | 941 | } |
877 | 942 | } |
878 | 943 | } |
@@ -893,8 +958,10 @@ discard block |
||
893 | 958 | // Update status and type. |
894 | 959 | $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); |
895 | 960 | |
896 | - if ( ! empty($posts) ) foreach ($posts as $post) { |
|
961 | + if ( ! empty($posts) ) { |
|
962 | + foreach ($posts as $post) { |
|
897 | 963 | $status = $post->post_status; |
964 | + } |
|
898 | 965 | $type = 'post'; |
899 | 966 | |
900 | 967 | if ( 'static' == $status ) { |
@@ -919,9 +986,10 @@ discard block |
||
919 | 986 | $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
920 | 987 | |
921 | 988 | $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'"); |
922 | - if ( !empty($posts) ) |
|
923 | - foreach ( $posts as $post ) |
|
989 | + if ( !empty($posts) ) { |
|
990 | + foreach ( $posts as $post ) |
|
924 | 991 | wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID)); |
992 | + } |
|
925 | 993 | } |
926 | 994 | } |
927 | 995 | |
@@ -1007,19 +1075,22 @@ discard block |
||
1007 | 1075 | } |
1008 | 1076 | |
1009 | 1077 | $select = 'post_id, category_id'; |
1010 | - if ( $have_tags ) |
|
1011 | - $select .= ', rel_type'; |
|
1078 | + if ( $have_tags ) { |
|
1079 | + $select .= ', rel_type'; |
|
1080 | + } |
|
1012 | 1081 | |
1013 | 1082 | $posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id"); |
1014 | 1083 | foreach ( $posts as $post ) { |
1015 | 1084 | $post_id = (int) $post->post_id; |
1016 | 1085 | $term_id = (int) $post->category_id; |
1017 | 1086 | $taxonomy = 'category'; |
1018 | - if ( !empty($post->rel_type) && 'tag' == $post->rel_type) |
|
1019 | - $taxonomy = 'tag'; |
|
1087 | + if ( !empty($post->rel_type) && 'tag' == $post->rel_type) { |
|
1088 | + $taxonomy = 'tag'; |
|
1089 | + } |
|
1020 | 1090 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
1021 | - if ( empty($tt_id) ) |
|
1022 | - continue; |
|
1091 | + if ( empty($tt_id) ) { |
|
1092 | + continue; |
|
1093 | + } |
|
1023 | 1094 | |
1024 | 1095 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) ); |
1025 | 1096 | } |
@@ -1061,15 +1132,19 @@ discard block |
||
1061 | 1132 | |
1062 | 1133 | // Associate links to cats. |
1063 | 1134 | $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); |
1064 | - if ( !empty($links) ) foreach ( $links as $link ) { |
|
1135 | + if ( !empty($links) ) { |
|
1136 | + foreach ( $links as $link ) { |
|
1065 | 1137 | if ( 0 == $link->link_category ) |
1066 | 1138 | continue; |
1067 | - if ( ! isset($link_cat_id_map[$link->link_category]) ) |
|
1068 | - continue; |
|
1139 | + } |
|
1140 | + if ( ! isset($link_cat_id_map[$link->link_category]) ) { |
|
1141 | + continue; |
|
1142 | + } |
|
1069 | 1143 | $term_id = $link_cat_id_map[$link->link_category]; |
1070 | 1144 | $tt_id = $tt_ids[$term_id]; |
1071 | - if ( empty($tt_id) ) |
|
1072 | - continue; |
|
1145 | + if ( empty($tt_id) ) { |
|
1146 | + continue; |
|
1147 | + } |
|
1073 | 1148 | |
1074 | 1149 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) ); |
1075 | 1150 | } |
@@ -1083,8 +1158,9 @@ discard block |
||
1083 | 1158 | $term_id = (int) $link->category_id; |
1084 | 1159 | $taxonomy = 'link_category'; |
1085 | 1160 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
1086 | - if ( empty($tt_id) ) |
|
1087 | - continue; |
|
1161 | + if ( empty($tt_id) ) { |
|
1162 | + continue; |
|
1163 | + } |
|
1088 | 1164 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) ); |
1089 | 1165 | } |
1090 | 1166 | } |
@@ -1097,10 +1173,11 @@ discard block |
||
1097 | 1173 | // Recalculate all counts |
1098 | 1174 | $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); |
1099 | 1175 | foreach ( (array) $terms as $term ) { |
1100 | - if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) |
|
1101 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
1102 | - else |
|
1103 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
1176 | + if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) { |
|
1177 | + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
1178 | + } else { |
|
1179 | + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
1180 | + } |
|
1104 | 1181 | $wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) ); |
1105 | 1182 | } |
1106 | 1183 | } |
@@ -1117,8 +1194,9 @@ discard block |
||
1117 | 1194 | global $wpdb; |
1118 | 1195 | $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' ); |
1119 | 1196 | $wpdb->hide_errors(); |
1120 | - foreach ( $old_options_fields as $old ) |
|
1121 | - $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
|
1197 | + foreach ( $old_options_fields as $old ) { |
|
1198 | + $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
|
1199 | + } |
|
1122 | 1200 | $wpdb->show_errors(); |
1123 | 1201 | } |
1124 | 1202 | |
@@ -1193,9 +1271,10 @@ discard block |
||
1193 | 1271 | function upgrade_260() { |
1194 | 1272 | global $wp_current_db_version; |
1195 | 1273 | |
1196 | - if ( $wp_current_db_version < 8000 ) |
|
1197 | - populate_roles_260(); |
|
1198 | -} |
|
1274 | + if ( $wp_current_db_version < 8000 ) { |
|
1275 | + populate_roles_260(); |
|
1276 | + } |
|
1277 | + } |
|
1199 | 1278 | |
1200 | 1279 | /** |
1201 | 1280 | * Execute changes made in WordPress 2.7. |
@@ -1209,13 +1288,15 @@ discard block |
||
1209 | 1288 | function upgrade_270() { |
1210 | 1289 | global $wpdb, $wp_current_db_version; |
1211 | 1290 | |
1212 | - if ( $wp_current_db_version < 8980 ) |
|
1213 | - populate_roles_270(); |
|
1291 | + if ( $wp_current_db_version < 8980 ) { |
|
1292 | + populate_roles_270(); |
|
1293 | + } |
|
1214 | 1294 | |
1215 | 1295 | // Update post_date for unpublished posts with empty timestamp |
1216 | - if ( $wp_current_db_version < 8921 ) |
|
1217 | - $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
1218 | -} |
|
1296 | + if ( $wp_current_db_version < 8921 ) { |
|
1297 | + $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
1298 | + } |
|
1299 | + } |
|
1219 | 1300 | |
1220 | 1301 | /** |
1221 | 1302 | * Execute changes made in WordPress 2.8. |
@@ -1229,15 +1310,17 @@ discard block |
||
1229 | 1310 | function upgrade_280() { |
1230 | 1311 | global $wp_current_db_version, $wpdb; |
1231 | 1312 | |
1232 | - if ( $wp_current_db_version < 10360 ) |
|
1233 | - populate_roles_280(); |
|
1313 | + if ( $wp_current_db_version < 10360 ) { |
|
1314 | + populate_roles_280(); |
|
1315 | + } |
|
1234 | 1316 | if ( is_multisite() ) { |
1235 | 1317 | $start = 0; |
1236 | 1318 | while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) { |
1237 | 1319 | foreach ( $rows as $row ) { |
1238 | 1320 | $value = $row->option_value; |
1239 | - if ( !@unserialize( $value ) ) |
|
1240 | - $value = stripslashes( $value ); |
|
1321 | + if ( !@unserialize( $value ) ) { |
|
1322 | + $value = stripslashes( $value ); |
|
1323 | + } |
|
1241 | 1324 | if ( $value !== $row->option_value ) { |
1242 | 1325 | update_option( $row->option_name, $value ); |
1243 | 1326 | } |
@@ -1280,11 +1363,13 @@ discard block |
||
1280 | 1363 | function upgrade_300() { |
1281 | 1364 | global $wp_current_db_version, $wpdb; |
1282 | 1365 | |
1283 | - if ( $wp_current_db_version < 15093 ) |
|
1284 | - populate_roles_300(); |
|
1366 | + if ( $wp_current_db_version < 15093 ) { |
|
1367 | + populate_roles_300(); |
|
1368 | + } |
|
1285 | 1369 | |
1286 | - if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) |
|
1287 | - add_site_option( 'siteurl', '' ); |
|
1370 | + if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) { |
|
1371 | + add_site_option( 'siteurl', '' ); |
|
1372 | + } |
|
1288 | 1373 | |
1289 | 1374 | // 3.0 screen options key name changes. |
1290 | 1375 | if ( wp_should_upgrade_global_tables() ) { |
@@ -1332,23 +1417,26 @@ discard block |
||
1332 | 1417 | $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" ); |
1333 | 1418 | } |
1334 | 1419 | |
1335 | - if ( $wp_current_db_version >= 11548 ) |
|
1336 | - return; |
|
1420 | + if ( $wp_current_db_version >= 11548 ) { |
|
1421 | + return; |
|
1422 | + } |
|
1337 | 1423 | |
1338 | 1424 | $sidebars_widgets = get_option( 'sidebars_widgets', array() ); |
1339 | 1425 | $_sidebars_widgets = array(); |
1340 | 1426 | |
1341 | - if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) |
|
1342 | - $sidebars_widgets['array_version'] = 3; |
|
1343 | - elseif ( !isset($sidebars_widgets['array_version']) ) |
|
1344 | - $sidebars_widgets['array_version'] = 1; |
|
1427 | + if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) { |
|
1428 | + $sidebars_widgets['array_version'] = 3; |
|
1429 | + } elseif ( !isset($sidebars_widgets['array_version']) ) { |
|
1430 | + $sidebars_widgets['array_version'] = 1; |
|
1431 | + } |
|
1345 | 1432 | |
1346 | 1433 | switch ( $sidebars_widgets['array_version'] ) { |
1347 | 1434 | case 1 : |
1348 | - foreach ( (array) $sidebars_widgets as $index => $sidebar ) |
|
1349 | - if ( is_array($sidebar) ) |
|
1435 | + foreach ( (array) $sidebars_widgets as $index => $sidebar ) { |
|
1436 | + if ( is_array($sidebar) ) |
|
1350 | 1437 | foreach ( (array) $sidebar as $i => $name ) { |
1351 | 1438 | $id = strtolower($name); |
1439 | + } |
|
1352 | 1440 | if ( isset($wp_registered_widgets[$id]) ) { |
1353 | 1441 | $_sidebars_widgets[$index][$i] = $id; |
1354 | 1442 | continue; |
@@ -1373,8 +1461,9 @@ discard block |
||
1373 | 1461 | } |
1374 | 1462 | } |
1375 | 1463 | |
1376 | - if ( $found ) |
|
1377 | - continue; |
|
1464 | + if ( $found ) { |
|
1465 | + continue; |
|
1466 | + } |
|
1378 | 1467 | |
1379 | 1468 | unset($_sidebars_widgets[$index][$i]); |
1380 | 1469 | } |
@@ -1438,14 +1527,17 @@ discard block |
||
1438 | 1527 | function upgrade_350() { |
1439 | 1528 | global $wp_current_db_version, $wpdb; |
1440 | 1529 | |
1441 | - if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
1442 | - update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options() |
|
1530 | + if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
1531 | + update_option( 'link_manager_enabled', 1 ); |
|
1532 | + } |
|
1533 | + // Previously set to 0 by populate_options() |
|
1443 | 1534 | |
1444 | 1535 | if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
1445 | 1536 | $meta_keys = array(); |
1446 | 1537 | foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
1447 | - if ( false !== strpos( $name, '-' ) ) |
|
1448 | - $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
1538 | + if ( false !== strpos( $name, '-' ) ) { |
|
1539 | + $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
1540 | + } |
|
1449 | 1541 | } |
1450 | 1542 | if ( $meta_keys ) { |
1451 | 1543 | $meta_keys = implode( "', '", $meta_keys ); |
@@ -1453,9 +1545,10 @@ discard block |
||
1453 | 1545 | } |
1454 | 1546 | } |
1455 | 1547 | |
1456 | - if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) |
|
1457 | - wp_delete_term( $term->term_id, 'post_format' ); |
|
1458 | -} |
|
1548 | + if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) { |
|
1549 | + wp_delete_term( $term->term_id, 'post_format' ); |
|
1550 | + } |
|
1551 | + } |
|
1459 | 1552 | |
1460 | 1553 | /** |
1461 | 1554 | * Execute changes made in WordPress 3.7. |
@@ -1467,9 +1560,10 @@ discard block |
||
1467 | 1560 | */ |
1468 | 1561 | function upgrade_370() { |
1469 | 1562 | global $wp_current_db_version; |
1470 | - if ( $wp_current_db_version < 25824 ) |
|
1471 | - wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
1472 | -} |
|
1563 | + if ( $wp_current_db_version < 25824 ) { |
|
1564 | + wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
1565 | + } |
|
1566 | + } |
|
1473 | 1567 | |
1474 | 1568 | /** |
1475 | 1569 | * Execute changes made in WordPress 3.7.2. |
@@ -1482,9 +1576,10 @@ discard block |
||
1482 | 1576 | */ |
1483 | 1577 | function upgrade_372() { |
1484 | 1578 | global $wp_current_db_version; |
1485 | - if ( $wp_current_db_version < 26148 ) |
|
1486 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
1487 | -} |
|
1579 | + if ( $wp_current_db_version < 26148 ) { |
|
1580 | + wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
1581 | + } |
|
1582 | + } |
|
1488 | 1583 | |
1489 | 1584 | /** |
1490 | 1585 | * Execute changes made in WordPress 3.8.0. |
@@ -1719,10 +1814,11 @@ discard block |
||
1719 | 1814 | $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); |
1720 | 1815 | $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' ); |
1721 | 1816 | if ( $wpmu_sitewide_plugins ) { |
1722 | - if ( !$active_sitewide_plugins ) |
|
1723 | - $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
|
1724 | - else |
|
1725 | - $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
1817 | + if ( !$active_sitewide_plugins ) { |
|
1818 | + $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
|
1819 | + } else { |
|
1820 | + $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
1821 | + } |
|
1726 | 1822 | |
1727 | 1823 | update_site_option( 'active_sitewide_plugins', $sitewide_plugins ); |
1728 | 1824 | } |
@@ -1733,8 +1829,9 @@ discard block |
||
1733 | 1829 | while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) { |
1734 | 1830 | foreach ( $rows as $row ) { |
1735 | 1831 | $value = $row->meta_value; |
1736 | - if ( !@unserialize( $value ) ) |
|
1737 | - $value = stripslashes( $value ); |
|
1832 | + if ( !@unserialize( $value ) ) { |
|
1833 | + $value = stripslashes( $value ); |
|
1834 | + } |
|
1738 | 1835 | if ( $value !== $row->meta_value ) { |
1739 | 1836 | update_site_option( $row->meta_key, $value ); |
1740 | 1837 | } |
@@ -1744,16 +1841,19 @@ discard block |
||
1744 | 1841 | } |
1745 | 1842 | |
1746 | 1843 | // 3.0 |
1747 | - if ( $wp_current_db_version < 13576 ) |
|
1748 | - update_site_option( 'global_terms_enabled', '1' ); |
|
1844 | + if ( $wp_current_db_version < 13576 ) { |
|
1845 | + update_site_option( 'global_terms_enabled', '1' ); |
|
1846 | + } |
|
1749 | 1847 | |
1750 | 1848 | // 3.3 |
1751 | - if ( $wp_current_db_version < 19390 ) |
|
1752 | - update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
1849 | + if ( $wp_current_db_version < 19390 ) { |
|
1850 | + update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
1851 | + } |
|
1753 | 1852 | |
1754 | 1853 | if ( $wp_current_db_version < 19470 ) { |
1755 | - if ( false === get_site_option( 'active_sitewide_plugins' ) ) |
|
1756 | - update_site_option( 'active_sitewide_plugins', array() ); |
|
1854 | + if ( false === get_site_option( 'active_sitewide_plugins' ) ) { |
|
1855 | + update_site_option( 'active_sitewide_plugins', array() ); |
|
1856 | + } |
|
1757 | 1857 | } |
1758 | 1858 | |
1759 | 1859 | // 3.4 |
@@ -1765,8 +1865,9 @@ discard block |
||
1765 | 1865 | $converted = array(); |
1766 | 1866 | $themes = wp_get_themes(); |
1767 | 1867 | foreach ( $themes as $stylesheet => $theme_data ) { |
1768 | - if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) |
|
1769 | - $converted[ $stylesheet ] = true; |
|
1868 | + if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) { |
|
1869 | + $converted[ $stylesheet ] = true; |
|
1870 | + } |
|
1770 | 1871 | } |
1771 | 1872 | update_site_option( 'allowedthemes', $converted ); |
1772 | 1873 | delete_site_option( 'allowed_themes' ); |
@@ -1774,8 +1875,9 @@ discard block |
||
1774 | 1875 | } |
1775 | 1876 | |
1776 | 1877 | // 3.5 |
1777 | - if ( $wp_current_db_version < 21823 ) |
|
1778 | - update_site_option( 'ms_files_rewriting', '1' ); |
|
1878 | + if ( $wp_current_db_version < 21823 ) { |
|
1879 | + update_site_option( 'ms_files_rewriting', '1' ); |
|
1880 | + } |
|
1779 | 1881 | |
1780 | 1882 | // 3.5.2 |
1781 | 1883 | if ( $wp_current_db_version < 24448 ) { |
@@ -2006,8 +2108,9 @@ discard block |
||
2006 | 2108 | $all_options = new stdClass; |
2007 | 2109 | if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) { |
2008 | 2110 | foreach ( $options as $option ) { |
2009 | - if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) |
|
2010 | - $option->option_value = untrailingslashit( $option->option_value ); |
|
2111 | + if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) { |
|
2112 | + $option->option_value = untrailingslashit( $option->option_value ); |
|
2113 | + } |
|
2011 | 2114 | $all_options->{$option->option_name} = stripslashes( $option->option_value ); |
2012 | 2115 | } |
2013 | 2116 | } |
@@ -2029,19 +2132,23 @@ discard block |
||
2029 | 2132 | function __get_option($setting) { |
2030 | 2133 | global $wpdb; |
2031 | 2134 | |
2032 | - if ( $setting == 'home' && defined( 'WP_HOME' ) ) |
|
2033 | - return untrailingslashit( WP_HOME ); |
|
2135 | + if ( $setting == 'home' && defined( 'WP_HOME' ) ) { |
|
2136 | + return untrailingslashit( WP_HOME ); |
|
2137 | + } |
|
2034 | 2138 | |
2035 | - if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) |
|
2036 | - return untrailingslashit( WP_SITEURL ); |
|
2139 | + if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) { |
|
2140 | + return untrailingslashit( WP_SITEURL ); |
|
2141 | + } |
|
2037 | 2142 | |
2038 | 2143 | $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) ); |
2039 | 2144 | |
2040 | - if ( 'home' == $setting && '' == $option ) |
|
2041 | - return __get_option( 'siteurl' ); |
|
2145 | + if ( 'home' == $setting && '' == $option ) { |
|
2146 | + return __get_option( 'siteurl' ); |
|
2147 | + } |
|
2042 | 2148 | |
2043 | - if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) |
|
2044 | - $option = untrailingslashit( $option ); |
|
2149 | + if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) { |
|
2150 | + $option = untrailingslashit( $option ); |
|
2151 | + } |
|
2045 | 2152 | |
2046 | 2153 | return maybe_unserialize( $option ); |
2047 | 2154 | } |
@@ -2094,8 +2201,9 @@ discard block |
||
2094 | 2201 | function dbDelta( $queries = '', $execute = true ) { |
2095 | 2202 | global $wpdb; |
2096 | 2203 | |
2097 | - if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) |
|
2098 | - $queries = wp_get_db_schema( $queries ); |
|
2204 | + if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) { |
|
2205 | + $queries = wp_get_db_schema( $queries ); |
|
2206 | + } |
|
2099 | 2207 | |
2100 | 2208 | // Separate individual queries into an array |
2101 | 2209 | if ( !is_array($queries) ) { |
@@ -2167,8 +2275,9 @@ discard block |
||
2167 | 2275 | $tablefields = $wpdb->get_results("DESCRIBE {$table};"); |
2168 | 2276 | $wpdb->suppress_errors( $suppress ); |
2169 | 2277 | |
2170 | - if ( ! $tablefields ) |
|
2171 | - continue; |
|
2278 | + if ( ! $tablefields ) { |
|
2279 | + continue; |
|
2280 | + } |
|
2172 | 2281 | |
2173 | 2282 | // Clear the field and index arrays. |
2174 | 2283 | $cfields = $indices = array(); |
@@ -2292,7 +2401,9 @@ discard block |
||
2292 | 2401 | |
2293 | 2402 | // For each column in the index. |
2294 | 2403 | foreach ($index_data['columns'] as $column_data) { |
2295 | - if ($index_columns != '') $index_columns .= ','; |
|
2404 | + if ($index_columns != '') { |
|
2405 | + $index_columns .= ','; |
|
2406 | + } |
|
2296 | 2407 | |
2297 | 2408 | // Add the field to the column list string. |
2298 | 2409 | $index_columns .= $column_data['fieldname']; |
@@ -2361,7 +2472,9 @@ discard block |
||
2361 | 2472 | function make_db_current( $tables = 'all' ) { |
2362 | 2473 | $alterations = dbDelta( $tables ); |
2363 | 2474 | echo "<ol>\n"; |
2364 | - foreach ($alterations as $alteration) echo "<li>$alteration</li>\n"; |
|
2475 | + foreach ($alterations as $alteration) { |
|
2476 | + echo "<li>$alteration</li>\n"; |
|
2477 | + } |
|
2365 | 2478 | echo "</ol>\n"; |
2366 | 2479 | } |
2367 | 2480 | |
@@ -2396,8 +2509,9 @@ discard block |
||
2396 | 2509 | $home_path = get_home_path(); |
2397 | 2510 | $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
2398 | 2511 | |
2399 | - if (! file_exists("$home_path/index.php")) |
|
2400 | - return false; |
|
2512 | + if (! file_exists("$home_path/index.php")) { |
|
2513 | + return false; |
|
2514 | + } |
|
2401 | 2515 | |
2402 | 2516 | /* |
2403 | 2517 | * Copy files from the old locations to the site theme. |
@@ -2406,25 +2520,28 @@ discard block |
||
2406 | 2520 | $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php'); |
2407 | 2521 | |
2408 | 2522 | foreach ($files as $oldfile => $newfile) { |
2409 | - if ($oldfile == 'index.php') |
|
2410 | - $oldpath = $home_path; |
|
2411 | - else |
|
2412 | - $oldpath = ABSPATH; |
|
2523 | + if ($oldfile == 'index.php') { |
|
2524 | + $oldpath = $home_path; |
|
2525 | + } else { |
|
2526 | + $oldpath = ABSPATH; |
|
2527 | + } |
|
2413 | 2528 | |
2414 | 2529 | // Check to make sure it's not a new index. |
2415 | 2530 | if ($oldfile == 'index.php') { |
2416 | 2531 | $index = implode('', file("$oldpath/$oldfile")); |
2417 | 2532 | if (strpos($index, 'WP_USE_THEMES') !== false) { |
2418 | - if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) |
|
2419 | - return false; |
|
2533 | + if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) { |
|
2534 | + return false; |
|
2535 | + } |
|
2420 | 2536 | |
2421 | 2537 | // Don't copy anything. |
2422 | 2538 | continue; |
2423 | 2539 | } |
2424 | 2540 | } |
2425 | 2541 | |
2426 | - if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) |
|
2427 | - return false; |
|
2542 | + if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) { |
|
2543 | + return false; |
|
2544 | + } |
|
2428 | 2545 | |
2429 | 2546 | chmod("$site_dir/$newfile", 0777); |
2430 | 2547 | |
@@ -2434,8 +2551,9 @@ discard block |
||
2434 | 2551 | $f = fopen("$site_dir/$newfile", 'w'); |
2435 | 2552 | |
2436 | 2553 | foreach ($lines as $line) { |
2437 | - if (preg_match('/require.*wp-blog-header/', $line)) |
|
2438 | - $line = '//' . $line; |
|
2554 | + if (preg_match('/require.*wp-blog-header/', $line)) { |
|
2555 | + $line = '//' . $line; |
|
2556 | + } |
|
2439 | 2557 | |
2440 | 2558 | // Update stylesheet references. |
2441 | 2559 | $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line); |
@@ -2485,10 +2603,12 @@ discard block |
||
2485 | 2603 | $theme_dir = @ opendir($default_dir); |
2486 | 2604 | if ($theme_dir) { |
2487 | 2605 | while(($theme_file = readdir( $theme_dir )) !== false) { |
2488 | - if (is_dir("$default_dir/$theme_file")) |
|
2489 | - continue; |
|
2490 | - if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) |
|
2491 | - return; |
|
2606 | + if (is_dir("$default_dir/$theme_file")) { |
|
2607 | + continue; |
|
2608 | + } |
|
2609 | + if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) { |
|
2610 | + return; |
|
2611 | + } |
|
2492 | 2612 | chmod("$site_dir/$theme_file", 0777); |
2493 | 2613 | } |
2494 | 2614 | } |
@@ -2500,11 +2620,17 @@ discard block |
||
2500 | 2620 | $f = fopen("$site_dir/style.css", 'w'); |
2501 | 2621 | |
2502 | 2622 | foreach ($stylelines as $line) { |
2503 | - if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; |
|
2504 | - elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); |
|
2505 | - elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; |
|
2506 | - elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; |
|
2507 | - elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; |
|
2623 | + if (strpos($line, 'Theme Name:') !== false) { |
|
2624 | + $line = 'Theme Name: ' . $theme_name; |
|
2625 | + } elseif (strpos($line, 'Theme URI:') !== false) { |
|
2626 | + $line = 'Theme URI: ' . __get_option('url'); |
|
2627 | + } elseif (strpos($line, 'Description:') !== false) { |
|
2628 | + $line = 'Description: Your theme.'; |
|
2629 | + } elseif (strpos($line, 'Version:') !== false) { |
|
2630 | + $line = 'Version: 1'; |
|
2631 | + } elseif (strpos($line, 'Author:') !== false) { |
|
2632 | + $line = 'Author: You'; |
|
2633 | + } |
|
2508 | 2634 | fwrite($f, $line . "\n"); |
2509 | 2635 | } |
2510 | 2636 | fclose($f); |
@@ -2519,10 +2645,12 @@ discard block |
||
2519 | 2645 | $images_dir = @ opendir("$default_dir/images"); |
2520 | 2646 | if ($images_dir) { |
2521 | 2647 | while(($image = readdir($images_dir)) !== false) { |
2522 | - if (is_dir("$default_dir/images/$image")) |
|
2523 | - continue; |
|
2524 | - if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) |
|
2525 | - return; |
|
2648 | + if (is_dir("$default_dir/images/$image")) { |
|
2649 | + continue; |
|
2650 | + } |
|
2651 | + if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) { |
|
2652 | + return; |
|
2653 | + } |
|
2526 | 2654 | chmod("$site_dir/images/$image", 0777); |
2527 | 2655 | } |
2528 | 2656 | } |
@@ -2565,9 +2693,10 @@ discard block |
||
2565 | 2693 | return false; |
2566 | 2694 | } |
2567 | 2695 | } else { |
2568 | - if (! make_site_theme_from_default($theme_name, $template)) |
|
2569 | - // TODO: rm -rf the site theme directory. |
|
2696 | + if (! make_site_theme_from_default($theme_name, $template)) { |
|
2697 | + // TODO: rm -rf the site theme directory. |
|
2570 | 2698 | return false; |
2699 | + } |
|
2571 | 2700 | } |
2572 | 2701 | |
2573 | 2702 | // Make the new site theme active. |
@@ -2618,9 +2747,10 @@ discard block |
||
2618 | 2747 | function wp_check_mysql_version() { |
2619 | 2748 | global $wpdb; |
2620 | 2749 | $result = $wpdb->check_database_version(); |
2621 | - if ( is_wp_error( $result ) ) |
|
2622 | - die( $result->get_error_message() ); |
|
2623 | -} |
|
2750 | + if ( is_wp_error( $result ) ) { |
|
2751 | + die( $result->get_error_message() ); |
|
2752 | + } |
|
2753 | + } |
|
2624 | 2754 | |
2625 | 2755 | /** |
2626 | 2756 | * Disables the Automattic widgets plugin, which was merged into core. |
@@ -2650,9 +2780,10 @@ discard block |
||
2650 | 2780 | function maybe_disable_link_manager() { |
2651 | 2781 | global $wp_current_db_version, $wpdb; |
2652 | 2782 | |
2653 | - if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
2654 | - update_option( 'link_manager_enabled', 0 ); |
|
2655 | -} |
|
2783 | + if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
2784 | + update_option( 'link_manager_enabled', 0 ); |
|
2785 | + } |
|
2786 | + } |
|
2656 | 2787 | |
2657 | 2788 | /** |
2658 | 2789 | * Runs before the schema is upgraded. |
@@ -123,8 +123,9 @@ discard block |
||
123 | 123 | $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); |
124 | 124 | |
125 | 125 | // If a non-valid menu tab has been selected, And it's not a non-menu action. |
126 | - if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) |
|
127 | - $tab = key( $tabs ); |
|
126 | + if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) { |
|
127 | + $tab = key( $tabs ); |
|
128 | + } |
|
128 | 129 | |
129 | 130 | $args = array( |
130 | 131 | 'page' => $paged, |
@@ -172,10 +173,11 @@ discard block |
||
172 | 173 | case 'favorites': |
173 | 174 | $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
174 | 175 | update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); |
175 | - if ( $user ) |
|
176 | - $args['user'] = $user; |
|
177 | - else |
|
178 | - $args = false; |
|
176 | + if ( $user ) { |
|
177 | + $args['user'] = $user; |
|
178 | + } else { |
|
179 | + $args = false; |
|
180 | + } |
|
179 | 181 | |
180 | 182 | add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); |
181 | 183 | break; |
@@ -197,8 +199,9 @@ discard block |
||
197 | 199 | */ |
198 | 200 | $args = apply_filters( "install_plugins_table_api_args_$tab", $args ); |
199 | 201 | |
200 | - if ( !$args ) |
|
201 | - return; |
|
202 | + if ( !$args ) { |
|
203 | + return; |
|
204 | + } |
|
202 | 205 | |
203 | 206 | $api = plugins_api( 'query_plugins', $args ); |
204 | 207 |
@@ -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 |
@@ -39,11 +39,13 @@ discard block |
||
39 | 39 | ) ); |
40 | 40 | |
41 | 41 | $status = 'all'; |
42 | - if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) |
|
43 | - $status = $_REQUEST['plugin_status']; |
|
42 | + if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) { |
|
43 | + $status = $_REQUEST['plugin_status']; |
|
44 | + } |
|
44 | 45 | |
45 | - if ( isset($_REQUEST['s']) ) |
|
46 | - $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) ); |
|
46 | + if ( isset($_REQUEST['s']) ) { |
|
47 | + $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) ); |
|
48 | + } |
|
47 | 49 | |
48 | 50 | $page = $this->get_pagenum(); |
49 | 51 | } |
@@ -123,8 +125,9 @@ discard block |
||
123 | 125 | } |
124 | 126 | |
125 | 127 | /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */ |
126 | - if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) |
|
127 | - $plugins['dropins'] = get_dropins(); |
|
128 | + if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) { |
|
129 | + $plugins['dropins'] = get_dropins(); |
|
130 | + } |
|
128 | 131 | |
129 | 132 | if ( current_user_can( 'update_plugins' ) ) { |
130 | 133 | $current = get_site_transient( 'update_plugins' ); |
@@ -232,11 +235,13 @@ discard block |
||
232 | 235 | } |
233 | 236 | |
234 | 237 | $totals = array(); |
235 | - foreach ( $plugins as $type => $list ) |
|
236 | - $totals[ $type ] = count( $list ); |
|
238 | + foreach ( $plugins as $type => $list ) { |
|
239 | + $totals[ $type ] = count( $list ); |
|
240 | + } |
|
237 | 241 | |
238 | - if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) |
|
239 | - $status = 'all'; |
|
242 | + if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) { |
|
243 | + $status = 'all'; |
|
244 | + } |
|
240 | 245 | |
241 | 246 | $this->items = array(); |
242 | 247 | foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) { |
@@ -260,8 +265,9 @@ discard block |
||
260 | 265 | |
261 | 266 | $start = ( $page - 1 ) * $plugins_per_page; |
262 | 267 | |
263 | - if ( $total_this_page > $plugins_per_page ) |
|
264 | - $this->items = array_slice( $this->items, $start, $plugins_per_page ); |
|
268 | + if ( $total_this_page > $plugins_per_page ) { |
|
269 | + $this->items = array_slice( $this->items, $start, $plugins_per_page ); |
|
270 | + } |
|
265 | 271 | |
266 | 272 | $this->set_pagination_args( array( |
267 | 273 | 'total_items' => $total_this_page, |
@@ -300,8 +306,9 @@ discard block |
||
300 | 306 | $a = $plugin_a[$orderby]; |
301 | 307 | $b = $plugin_b[$orderby]; |
302 | 308 | |
303 | - if ( $a == $b ) |
|
304 | - return 0; |
|
309 | + if ( $a == $b ) { |
|
310 | + return 0; |
|
311 | + } |
|
305 | 312 | |
306 | 313 | if ( 'DESC' === $order ) { |
307 | 314 | return strcasecmp( $b, $a ); |
@@ -326,10 +333,11 @@ discard block |
||
326 | 333 | if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) { |
327 | 334 | echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>'; |
328 | 335 | } |
329 | - } elseif ( ! empty( $plugins['all'] ) ) |
|
330 | - _e( 'No plugins found.' ); |
|
331 | - else |
|
332 | - _e( 'You do not appear to have any plugins available at this time.' ); |
|
336 | + } elseif ( ! empty( $plugins['all'] ) ) { |
|
337 | + _e( 'No plugins found.' ); |
|
338 | + } else { |
|
339 | + _e( 'You do not appear to have any plugins available at this time.' ); |
|
340 | + } |
|
333 | 341 | } |
334 | 342 | |
335 | 343 | /** |
@@ -365,8 +373,9 @@ discard block |
||
365 | 373 | |
366 | 374 | $status_links = array(); |
367 | 375 | foreach ( $totals as $type => $count ) { |
368 | - if ( !$count ) |
|
369 | - continue; |
|
376 | + if ( !$count ) { |
|
377 | + continue; |
|
378 | + } |
|
370 | 379 | |
371 | 380 | switch ( $type ) { |
372 | 381 | case 'all': |
@@ -414,17 +423,21 @@ discard block |
||
414 | 423 | |
415 | 424 | $actions = array(); |
416 | 425 | |
417 | - if ( 'active' != $status ) |
|
418 | - $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' ); |
|
426 | + if ( 'active' != $status ) { |
|
427 | + $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' ); |
|
428 | + } |
|
419 | 429 | |
420 | - if ( 'inactive' != $status && 'recent' != $status ) |
|
421 | - $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' ); |
|
430 | + if ( 'inactive' != $status && 'recent' != $status ) { |
|
431 | + $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' ); |
|
432 | + } |
|
422 | 433 | |
423 | 434 | if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) { |
424 | - if ( current_user_can( 'update_plugins' ) ) |
|
425 | - $actions['update-selected'] = __( 'Update' ); |
|
426 | - if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) |
|
427 | - $actions['delete-selected'] = __( 'Delete' ); |
|
435 | + if ( current_user_can( 'update_plugins' ) ) { |
|
436 | + $actions['update-selected'] = __( 'Update' ); |
|
437 | + } |
|
438 | + if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) { |
|
439 | + $actions['delete-selected'] = __( 'Delete' ); |
|
440 | + } |
|
428 | 441 | } |
429 | 442 | |
430 | 443 | return $actions; |
@@ -437,8 +450,9 @@ discard block |
||
437 | 450 | public function bulk_actions( $which = '' ) { |
438 | 451 | global $status; |
439 | 452 | |
440 | - if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) |
|
441 | - return; |
|
453 | + if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) { |
|
454 | + return; |
|
455 | + } |
|
442 | 456 | |
443 | 457 | parent::bulk_actions( $which ); |
444 | 458 | } |
@@ -450,8 +464,9 @@ discard block |
||
450 | 464 | protected function extra_tablenav( $which ) { |
451 | 465 | global $status; |
452 | 466 | |
453 | - if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) ) |
|
454 | - return; |
|
467 | + if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) ) { |
|
468 | + return; |
|
469 | + } |
|
455 | 470 | |
456 | 471 | echo '<div class="alignleft actions">'; |
457 | 472 | |
@@ -475,8 +490,9 @@ discard block |
||
475 | 490 | * @return string |
476 | 491 | */ |
477 | 492 | public function current_action() { |
478 | - if ( isset($_POST['clear-recent-list']) ) |
|
479 | - return 'clear-recent-list'; |
|
493 | + if ( isset($_POST['clear-recent-list']) ) { |
|
494 | + return 'clear-recent-list'; |
|
495 | + } |
|
480 | 496 | |
481 | 497 | return parent::current_action(); |
482 | 498 | } |
@@ -488,11 +504,13 @@ discard block |
||
488 | 504 | public function display_rows() { |
489 | 505 | global $status; |
490 | 506 | |
491 | - if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) |
|
492 | - return; |
|
507 | + if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) { |
|
508 | + return; |
|
509 | + } |
|
493 | 510 | |
494 | - foreach ( $this->items as $plugin_file => $plugin_data ) |
|
495 | - $this->single_row( array( $plugin_file, $plugin_data ) ); |
|
511 | + foreach ( $this->items as $plugin_file => $plugin_data ) { |
|
512 | + $this->single_row( array( $plugin_file, $plugin_data ) ); |
|
513 | + } |
|
496 | 514 | } |
497 | 515 | |
498 | 516 | /** |
@@ -528,8 +546,9 @@ discard block |
||
528 | 546 | } elseif ( 'dropins' === $context ) { |
529 | 547 | $dropins = _get_dropins(); |
530 | 548 | $plugin_name = $plugin_file; |
531 | - if ( $plugin_file != $plugin_data['Name'] ) |
|
532 | - $plugin_name .= '<br/>' . $plugin_data['Name']; |
|
549 | + if ( $plugin_file != $plugin_data['Name'] ) { |
|
550 | + $plugin_name .= '<br/>' . $plugin_data['Name']; |
|
551 | + } |
|
533 | 552 | if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant |
534 | 553 | $is_active = true; |
535 | 554 | $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; |
@@ -545,8 +564,9 @@ discard block |
||
545 | 564 | '<code>wp-config.php</code>' |
546 | 565 | ) . '</p>'; |
547 | 566 | } |
548 | - if ( $plugin_data['Description'] ) |
|
549 | - $description .= '<p>' . $plugin_data['Description'] . '</p>'; |
|
567 | + if ( $plugin_data['Description'] ) { |
|
568 | + $description .= '<p>' . $plugin_data['Description'] . '</p>'; |
|
569 | + } |
|
550 | 570 | } else { |
551 | 571 | if ( $screen->in_admin( 'network' ) ) { |
552 | 572 | $is_active = is_plugin_active_for_network( $plugin_file ); |
@@ -696,8 +716,9 @@ discard block |
||
696 | 716 | $plugin_name = $plugin_data['Name']; |
697 | 717 | } |
698 | 718 | |
699 | - if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) |
|
700 | - $class .= ' update'; |
|
719 | + if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) { |
|
720 | + $class .= ' update'; |
|
721 | + } |
|
701 | 722 | |
702 | 723 | $plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name ); |
703 | 724 | printf( '<tr class="%s" data-slug="%s" data-plugin="%s">', |
@@ -731,12 +752,14 @@ discard block |
||
731 | 752 | <div class='$class second plugin-version-author-uri'>"; |
732 | 753 | |
733 | 754 | $plugin_meta = array(); |
734 | - if ( !empty( $plugin_data['Version'] ) ) |
|
735 | - $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); |
|
755 | + if ( !empty( $plugin_data['Version'] ) ) { |
|
756 | + $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); |
|
757 | + } |
|
736 | 758 | if ( !empty( $plugin_data['Author'] ) ) { |
737 | 759 | $author = $plugin_data['Author']; |
738 | - if ( !empty( $plugin_data['AuthorURI'] ) ) |
|
739 | - $author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
|
760 | + if ( !empty( $plugin_data['AuthorURI'] ) ) { |
|
761 | + $author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
|
762 | + } |
|
740 | 763 | $plugin_meta[] = sprintf( __( 'By %s' ), $author ); |
741 | 764 | } |
742 | 765 |
@@ -75,8 +75,9 @@ discard block |
||
75 | 75 | 'post_type' => $matches[2], |
76 | 76 | 's' => $query, |
77 | 77 | )); |
78 | - if ( ! have_posts() ) |
|
79 | - return; |
|
78 | + if ( ! have_posts() ) { |
|
79 | + return; |
|
80 | + } |
|
80 | 81 | while ( have_posts() ) { |
81 | 82 | the_post(); |
82 | 83 | if ( 'markup' == $response_format ) { |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | 'name__like' => $query, |
99 | 100 | 'number' => 10, |
100 | 101 | )); |
101 | - if ( empty( $terms ) || is_wp_error( $terms ) ) |
|
102 | - return; |
|
102 | + if ( empty( $terms ) || is_wp_error( $terms ) ) { |
|
103 | + return; |
|
104 | + } |
|
103 | 105 | foreach ( (array) $terms as $term ) { |
104 | 106 | if ( 'markup' == $response_format ) { |
105 | 107 | echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); |
@@ -151,8 +153,9 @@ discard block |
||
151 | 153 | function wp_initial_nav_menu_meta_boxes() { |
152 | 154 | global $wp_meta_boxes; |
153 | 155 | |
154 | - if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) |
|
155 | - return; |
|
156 | + if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) { |
|
157 | + return; |
|
158 | + } |
|
156 | 159 | |
157 | 160 | $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); |
158 | 161 | $hidden_meta_boxes = array(); |
@@ -181,8 +184,9 @@ discard block |
||
181 | 184 | function wp_nav_menu_post_type_meta_boxes() { |
182 | 185 | $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
183 | 186 | |
184 | - if ( ! $post_types ) |
|
185 | - return; |
|
187 | + if ( ! $post_types ) { |
|
188 | + return; |
|
189 | + } |
|
186 | 190 | |
187 | 191 | foreach ( $post_types as $post_type ) { |
188 | 192 | /** |
@@ -215,8 +219,9 @@ discard block |
||
215 | 219 | function wp_nav_menu_taxonomy_meta_boxes() { |
216 | 220 | $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
217 | 221 | |
218 | - if ( !$taxonomies ) |
|
219 | - return; |
|
222 | + if ( !$taxonomies ) { |
|
223 | + return; |
|
224 | + } |
|
220 | 225 | |
221 | 226 | foreach ( $taxonomies as $tax ) { |
222 | 227 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
@@ -241,8 +246,9 @@ discard block |
||
241 | 246 | function wp_nav_menu_disabled_check( $nav_menu_selected_id ) { |
242 | 247 | global $one_theme_location_no_menus; |
243 | 248 | |
244 | - if ( $one_theme_location_no_menus ) |
|
245 | - return false; |
|
249 | + if ( $one_theme_location_no_menus ) { |
|
250 | + return false; |
|
251 | + } |
|
246 | 252 | |
247 | 253 | return disabled( $nav_menu_selected_id, 0 ); |
248 | 254 | } |
@@ -316,8 +322,9 @@ discard block |
||
316 | 322 | 'update_post_meta_cache' => false |
317 | 323 | ); |
318 | 324 | |
319 | - if ( isset( $post_type['args']->_default_query ) ) |
|
320 | - $args = array_merge($args, (array) $post_type['args']->_default_query ); |
|
325 | + if ( isset( $post_type['args']->_default_query ) ) { |
|
326 | + $args = array_merge($args, (array) $post_type['args']->_default_query ); |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // @todo transient caching of these results with proper invalidation on updating of a post of this type |
323 | 330 | $get_posts = new WP_Query; |
@@ -374,17 +381,26 @@ discard block |
||
374 | 381 | <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> |
375 | 382 | <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> |
376 | 383 | <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>> |
377 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
384 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) { |
|
385 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); |
|
386 | +} |
|
387 | +?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
378 | 388 | <?php _e( 'Most Recent' ); ?> |
379 | 389 | </a> |
380 | 390 | </li> |
381 | 391 | <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
382 | - <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"> |
|
392 | + <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) { |
|
393 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); |
|
394 | +} |
|
395 | +?>#<?php echo $post_type_name; ?>-all"> |
|
383 | 396 | <?php _e( 'View All' ); ?> |
384 | 397 | </a> |
385 | 398 | </li> |
386 | 399 | <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
387 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
400 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) { |
|
401 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); |
|
402 | +} |
|
403 | +?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
388 | 404 | <?php _e( 'Search'); ?> |
389 | 405 | </a> |
390 | 406 | </li> |
@@ -649,17 +665,26 @@ discard block |
||
649 | 665 | <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> |
650 | 666 | <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> |
651 | 667 | <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>> |
652 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
668 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) { |
|
669 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); |
|
670 | +} |
|
671 | +?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
653 | 672 | <?php _e( 'Most Used' ); ?> |
654 | 673 | </a> |
655 | 674 | </li> |
656 | 675 | <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
657 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
676 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) { |
|
677 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); |
|
678 | +} |
|
679 | +?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
658 | 680 | <?php _e( 'View All' ); ?> |
659 | 681 | </a> |
660 | 682 | </li> |
661 | 683 | <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
662 | - <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
684 | + <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) { |
|
685 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); |
|
686 | +} |
|
687 | +?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
663 | 688 | <?php _e( 'Search' ); ?> |
664 | 689 | </a> |
665 | 690 | </li> |
@@ -884,8 +909,9 @@ discard block |
||
884 | 909 | $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; |
885 | 910 | $result .= '</div>'; |
886 | 911 | |
887 | - if ( empty($menu_items) ) |
|
888 | - return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
912 | + if ( empty($menu_items) ) { |
|
913 | + return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
914 | + } |
|
889 | 915 | |
890 | 916 | /** |
891 | 917 | * Filter the Walker class used when adding nav menu items. |
@@ -910,17 +936,21 @@ discard block |
||
910 | 936 | |
911 | 937 | $some_pending_menu_items = $some_invalid_menu_items = false; |
912 | 938 | foreach ( (array) $menu_items as $menu_item ) { |
913 | - if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) |
|
914 | - $some_pending_menu_items = true; |
|
915 | - if ( ! empty( $menu_item->_invalid ) ) |
|
916 | - $some_invalid_menu_items = true; |
|
939 | + if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) { |
|
940 | + $some_pending_menu_items = true; |
|
941 | + } |
|
942 | + if ( ! empty( $menu_item->_invalid ) ) { |
|
943 | + $some_invalid_menu_items = true; |
|
944 | + } |
|
917 | 945 | } |
918 | 946 | |
919 | - if ( $some_pending_menu_items ) |
|
920 | - $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>'; |
|
947 | + if ( $some_pending_menu_items ) { |
|
948 | + $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>'; |
|
949 | + } |
|
921 | 950 | |
922 | - if ( $some_invalid_menu_items ) |
|
923 | - $result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>'; |
|
951 | + if ( $some_invalid_menu_items ) { |
|
952 | + $result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>'; |
|
953 | + } |
|
924 | 954 | |
925 | 955 | $result .= '<ul class="menu" id="menu-to-edit"> '; |
926 | 956 | $result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) ); |
@@ -966,9 +996,10 @@ discard block |
||
966 | 996 | // Delete orphaned draft menu items. |
967 | 997 | $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) ); |
968 | 998 | |
969 | - foreach ( (array) $menu_items_to_delete as $menu_item_id ) |
|
970 | - wp_delete_post( $menu_item_id, true ); |
|
971 | -} |
|
999 | + foreach ( (array) $menu_items_to_delete as $menu_item_id ) { |
|
1000 | + wp_delete_post( $menu_item_id, true ); |
|
1001 | + } |
|
1002 | + } |
|
972 | 1003 | |
973 | 1004 | /** |
974 | 1005 | * Saves nav menu items |
@@ -984,8 +1015,9 @@ discard block |
||
984 | 1015 | $messages = array(); |
985 | 1016 | $menu_items = array(); |
986 | 1017 | // Index menu items by db ID |
987 | - foreach ( $unsorted_menu_items as $_item ) |
|
988 | - $menu_items[$_item->db_id] = $_item; |
|
1018 | + foreach ( $unsorted_menu_items as $_item ) { |
|
1019 | + $menu_items[$_item->db_id] = $_item; |
|
1020 | + } |
|
989 | 1021 | |
990 | 1022 | $post_fields = array( |
991 | 1023 | 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', |
@@ -1000,12 +1032,14 @@ discard block |
||
1000 | 1032 | foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { |
1001 | 1033 | |
1002 | 1034 | // Menu item title can't be blank |
1003 | - if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) |
|
1004 | - continue; |
|
1035 | + if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) { |
|
1036 | + continue; |
|
1037 | + } |
|
1005 | 1038 | |
1006 | 1039 | $args = array(); |
1007 | - foreach ( $post_fields as $field ) |
|
1008 | - $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
1040 | + foreach ( $post_fields as $field ) { |
|
1041 | + $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
1042 | + } |
|
1009 | 1043 | |
1010 | 1044 | $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); |
1011 | 1045 | |
@@ -1029,14 +1063,17 @@ discard block |
||
1029 | 1063 | // Store 'auto-add' pages. |
1030 | 1064 | $auto_add = ! empty( $_POST['auto-add-pages'] ); |
1031 | 1065 | $nav_menu_option = (array) get_option( 'nav_menu_options' ); |
1032 | - if ( ! isset( $nav_menu_option['auto_add'] ) ) |
|
1033 | - $nav_menu_option['auto_add'] = array(); |
|
1066 | + if ( ! isset( $nav_menu_option['auto_add'] ) ) { |
|
1067 | + $nav_menu_option['auto_add'] = array(); |
|
1068 | + } |
|
1034 | 1069 | if ( $auto_add ) { |
1035 | - if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) |
|
1036 | - $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
|
1070 | + if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) { |
|
1071 | + $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
|
1072 | + } |
|
1037 | 1073 | } else { |
1038 | - if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) |
|
1039 | - unset( $nav_menu_option['auto_add'][$key] ); |
|
1074 | + if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) { |
|
1075 | + unset( $nav_menu_option['auto_add'][$key] ); |
|
1076 | + } |
|
1040 | 1077 | } |
1041 | 1078 | // Remove nonexistent/deleted menus |
1042 | 1079 | $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); |
@@ -118,23 +118,27 @@ discard block |
||
118 | 118 | * @return bool|array False on failure, Else array of files |
119 | 119 | */ |
120 | 120 | function list_files( $folder = '', $levels = 100 ) { |
121 | - if ( empty($folder) ) |
|
122 | - return false; |
|
121 | + if ( empty($folder) ) { |
|
122 | + return false; |
|
123 | + } |
|
123 | 124 | |
124 | - if ( ! $levels ) |
|
125 | - return false; |
|
125 | + if ( ! $levels ) { |
|
126 | + return false; |
|
127 | + } |
|
126 | 128 | |
127 | 129 | $files = array(); |
128 | 130 | if ( $dir = @opendir( $folder ) ) { |
129 | 131 | while (($file = readdir( $dir ) ) !== false ) { |
130 | - if ( in_array($file, array('.', '..') ) ) |
|
131 | - continue; |
|
132 | + if ( in_array($file, array('.', '..') ) ) { |
|
133 | + continue; |
|
134 | + } |
|
132 | 135 | if ( is_dir( $folder . '/' . $file ) ) { |
133 | 136 | $files2 = list_files( $folder . '/' . $file, $levels - 1); |
134 | - if ( $files2 ) |
|
135 | - $files = array_merge($files, $files2 ); |
|
136 | - else |
|
137 | - $files[] = $folder . '/' . $file . '/'; |
|
137 | + if ( $files2 ) { |
|
138 | + $files = array_merge($files, $files2 ); |
|
139 | + } else { |
|
140 | + $files[] = $folder . '/' . $file . '/'; |
|
141 | + } |
|
138 | 142 | } else { |
139 | 143 | $files[] = $folder . '/' . $file; |
140 | 144 | } |
@@ -205,8 +209,9 @@ discard block |
||
205 | 209 | function validate_file_to_edit( $file, $allowed_files = '' ) { |
206 | 210 | $code = validate_file( $file, $allowed_files ); |
207 | 211 | |
208 | - if (!$code ) |
|
209 | - return $file; |
|
212 | + if (!$code ) { |
|
213 | + return $file; |
|
214 | + } |
|
210 | 215 | |
211 | 216 | switch ( $code ) { |
212 | 217 | case 1 : |
@@ -480,12 +485,14 @@ discard block |
||
480 | 485 | */ |
481 | 486 | function download_url( $url, $timeout = 300 ) { |
482 | 487 | //WARNING: The file is not automatically deleted, The script must unlink() the file. |
483 | - if ( ! $url ) |
|
484 | - return new WP_Error('http_no_url', __('Invalid URL Provided.')); |
|
488 | + if ( ! $url ) { |
|
489 | + return new WP_Error('http_no_url', __('Invalid URL Provided.')); |
|
490 | + } |
|
485 | 491 | |
486 | 492 | $tmpfname = wp_tempnam($url); |
487 | - if ( ! $tmpfname ) |
|
488 | - return new WP_Error('http_no_file', __('Could not create Temporary file.')); |
|
493 | + if ( ! $tmpfname ) { |
|
494 | + return new WP_Error('http_no_file', __('Could not create Temporary file.')); |
|
495 | + } |
|
489 | 496 | |
490 | 497 | $response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) ); |
491 | 498 | |
@@ -521,17 +528,20 @@ discard block |
||
521 | 528 | * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected |
522 | 529 | */ |
523 | 530 | function verify_file_md5( $filename, $expected_md5 ) { |
524 | - if ( 32 == strlen( $expected_md5 ) ) |
|
525 | - $expected_raw_md5 = pack( 'H*', $expected_md5 ); |
|
526 | - elseif ( 24 == strlen( $expected_md5 ) ) |
|
527 | - $expected_raw_md5 = base64_decode( $expected_md5 ); |
|
528 | - else |
|
529 | - return false; // unknown format |
|
531 | + if ( 32 == strlen( $expected_md5 ) ) { |
|
532 | + $expected_raw_md5 = pack( 'H*', $expected_md5 ); |
|
533 | + } elseif ( 24 == strlen( $expected_md5 ) ) { |
|
534 | + $expected_raw_md5 = base64_decode( $expected_md5 ); |
|
535 | + } else { |
|
536 | + return false; |
|
537 | + } |
|
538 | + // unknown format |
|
530 | 539 | |
531 | 540 | $file_md5 = md5_file( $filename, true ); |
532 | 541 | |
533 | - if ( $file_md5 === $expected_raw_md5 ) |
|
534 | - return true; |
|
542 | + if ( $file_md5 === $expected_raw_md5 ) { |
|
543 | + return true; |
|
544 | + } |
|
535 | 545 | |
536 | 546 | return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) ); |
537 | 547 | } |
@@ -554,8 +564,9 @@ discard block |
||
554 | 564 | function unzip_file($file, $to) { |
555 | 565 | global $wp_filesystem; |
556 | 566 | |
557 | - if ( ! $wp_filesystem || !is_object($wp_filesystem) ) |
|
558 | - return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
567 | + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) { |
|
568 | + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
569 | + } |
|
559 | 570 | |
560 | 571 | // Unzip can use a lot of memory, but not this much hopefully |
561 | 572 | /** This filter is documented in wp-admin/admin.php */ |
@@ -568,17 +579,22 @@ discard block |
||
568 | 579 | if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist |
569 | 580 | $path = preg_split('![/\\\]!', untrailingslashit($to)); |
570 | 581 | for ( $i = count($path); $i >= 0; $i-- ) { |
571 | - if ( empty($path[$i]) ) |
|
572 | - continue; |
|
582 | + if ( empty($path[$i]) ) { |
|
583 | + continue; |
|
584 | + } |
|
573 | 585 | |
574 | 586 | $dir = implode('/', array_slice($path, 0, $i+1) ); |
575 | - if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter. |
|
587 | + if ( preg_match('!^[a-z]:$!i', $dir) ) { |
|
588 | + // Skip it if it looks like a Windows Drive letter. |
|
576 | 589 | continue; |
590 | + } |
|
577 | 591 | |
578 | - if ( ! $wp_filesystem->is_dir($dir) ) |
|
579 | - $needed_dirs[] = $dir; |
|
580 | - else |
|
581 | - break; // A folder exists, therefor, we dont need the check the levels below this |
|
592 | + if ( ! $wp_filesystem->is_dir($dir) ) { |
|
593 | + $needed_dirs[] = $dir; |
|
594 | + } else { |
|
595 | + break; |
|
596 | + } |
|
597 | + // A folder exists, therefor, we dont need the check the levels below this |
|
582 | 598 | } |
583 | 599 | } |
584 | 600 | |
@@ -594,8 +610,9 @@ discard block |
||
594 | 610 | if ( true === $result ) { |
595 | 611 | return $result; |
596 | 612 | } elseif ( is_wp_error($result) ) { |
597 | - if ( 'incompatible_archive' != $result->get_error_code() ) |
|
598 | - return $result; |
|
613 | + if ( 'incompatible_archive' != $result->get_error_code() ) { |
|
614 | + return $result; |
|
615 | + } |
|
599 | 616 | } |
600 | 617 | } |
601 | 618 | // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file. |
@@ -623,24 +640,30 @@ discard block |
||
623 | 640 | $z = new ZipArchive(); |
624 | 641 | |
625 | 642 | $zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS ); |
626 | - if ( true !== $zopen ) |
|
627 | - return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) ); |
|
643 | + if ( true !== $zopen ) { |
|
644 | + return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) ); |
|
645 | + } |
|
628 | 646 | |
629 | 647 | $uncompressed_size = 0; |
630 | 648 | |
631 | 649 | for ( $i = 0; $i < $z->numFiles; $i++ ) { |
632 | - if ( ! $info = $z->statIndex($i) ) |
|
633 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
650 | + if ( ! $info = $z->statIndex($i) ) { |
|
651 | + return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
652 | + } |
|
634 | 653 | |
635 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
654 | + if ( '__MACOSX/' === substr($info['name'], 0, 9) ) { |
|
655 | + // Skip the OS X-created __MACOSX directory |
|
636 | 656 | continue; |
657 | + } |
|
637 | 658 | |
638 | 659 | $uncompressed_size += $info['size']; |
639 | 660 | |
640 | - if ( '/' == substr($info['name'], -1) ) // directory |
|
661 | + if ( '/' == substr($info['name'], -1) ) { |
|
662 | + // directory |
|
641 | 663 | $needed_dirs[] = $to . untrailingslashit($info['name']); |
642 | - else |
|
643 | - $needed_dirs[] = $to . untrailingslashit(dirname($info['name'])); |
|
664 | + } else { |
|
665 | + $needed_dirs[] = $to . untrailingslashit(dirname($info['name'])); |
|
666 | + } |
|
644 | 667 | } |
645 | 668 | |
646 | 669 | /* |
@@ -650,17 +673,22 @@ discard block |
||
650 | 673 | */ |
651 | 674 | if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
652 | 675 | $available_space = @disk_free_space( WP_CONTENT_DIR ); |
653 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
654 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
676 | + if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
|
677 | + return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
678 | + } |
|
655 | 679 | } |
656 | 680 | |
657 | 681 | $needed_dirs = array_unique($needed_dirs); |
658 | 682 | foreach ( $needed_dirs as $dir ) { |
659 | 683 | // Check the parent folders of the folders all exist within the creation array. |
660 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
684 | + if ( untrailingslashit($to) == $dir ) { |
|
685 | + // Skip over the working directory, We know this exists (or will exist) |
|
661 | 686 | continue; |
662 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
687 | + } |
|
688 | + if ( strpos($dir, $to) === false ) { |
|
689 | + // If the directory is not within the working directory, Skip it |
|
663 | 690 | continue; |
691 | + } |
|
664 | 692 | |
665 | 693 | $parent_folder = dirname($dir); |
666 | 694 | while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
@@ -680,21 +708,28 @@ discard block |
||
680 | 708 | unset($needed_dirs); |
681 | 709 | |
682 | 710 | for ( $i = 0; $i < $z->numFiles; $i++ ) { |
683 | - if ( ! $info = $z->statIndex($i) ) |
|
684 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
711 | + if ( ! $info = $z->statIndex($i) ) { |
|
712 | + return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
713 | + } |
|
685 | 714 | |
686 | - if ( '/' == substr($info['name'], -1) ) // directory |
|
715 | + if ( '/' == substr($info['name'], -1) ) { |
|
716 | + // directory |
|
687 | 717 | continue; |
718 | + } |
|
688 | 719 | |
689 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
720 | + if ( '__MACOSX/' === substr($info['name'], 0, 9) ) { |
|
721 | + // Don't extract the OS X-created __MACOSX directory files |
|
690 | 722 | continue; |
723 | + } |
|
691 | 724 | |
692 | 725 | $contents = $z->getFromIndex($i); |
693 | - if ( false === $contents ) |
|
694 | - return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); |
|
726 | + if ( false === $contents ) { |
|
727 | + return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); |
|
728 | + } |
|
695 | 729 | |
696 | - if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) |
|
697 | - return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] ); |
|
730 | + if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) { |
|
731 | + return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] ); |
|
732 | + } |
|
698 | 733 | } |
699 | 734 | |
700 | 735 | $z->close(); |
@@ -731,18 +766,22 @@ discard block |
||
731 | 766 | reset_mbstring_encoding(); |
732 | 767 | |
733 | 768 | // Is the archive valid? |
734 | - if ( !is_array($archive_files) ) |
|
735 | - return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); |
|
769 | + if ( !is_array($archive_files) ) { |
|
770 | + return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); |
|
771 | + } |
|
736 | 772 | |
737 | - if ( 0 == count($archive_files) ) |
|
738 | - return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) ); |
|
773 | + if ( 0 == count($archive_files) ) { |
|
774 | + return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) ); |
|
775 | + } |
|
739 | 776 | |
740 | 777 | $uncompressed_size = 0; |
741 | 778 | |
742 | 779 | // Determine any children directories needed (From within the archive) |
743 | 780 | foreach ( $archive_files as $file ) { |
744 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
781 | + if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) { |
|
782 | + // Skip the OS X-created __MACOSX directory |
|
745 | 783 | continue; |
784 | + } |
|
746 | 785 | |
747 | 786 | $uncompressed_size += $file['size']; |
748 | 787 | |
@@ -756,17 +795,22 @@ discard block |
||
756 | 795 | */ |
757 | 796 | if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
758 | 797 | $available_space = @disk_free_space( WP_CONTENT_DIR ); |
759 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
760 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
798 | + if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
|
799 | + return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
800 | + } |
|
761 | 801 | } |
762 | 802 | |
763 | 803 | $needed_dirs = array_unique($needed_dirs); |
764 | 804 | foreach ( $needed_dirs as $dir ) { |
765 | 805 | // Check the parent folders of the folders all exist within the creation array. |
766 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
806 | + if ( untrailingslashit($to) == $dir ) { |
|
807 | + // Skip over the working directory, We know this exists (or will exist) |
|
767 | 808 | continue; |
768 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
809 | + } |
|
810 | + if ( strpos($dir, $to) === false ) { |
|
811 | + // If the directory is not within the working directory, Skip it |
|
769 | 812 | continue; |
813 | + } |
|
770 | 814 | |
771 | 815 | $parent_folder = dirname($dir); |
772 | 816 | while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
@@ -779,21 +823,26 @@ discard block |
||
779 | 823 | // Create those directories if need be: |
780 | 824 | foreach ( $needed_dirs as $_dir ) { |
781 | 825 | // Only check to see if the dir exists upon creation failure. Less I/O this way. |
782 | - if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) |
|
783 | - return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
826 | + if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
827 | + return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
828 | + } |
|
784 | 829 | } |
785 | 830 | unset($needed_dirs); |
786 | 831 | |
787 | 832 | // Extract the files from the zip |
788 | 833 | foreach ( $archive_files as $file ) { |
789 | - if ( $file['folder'] ) |
|
790 | - continue; |
|
834 | + if ( $file['folder'] ) { |
|
835 | + continue; |
|
836 | + } |
|
791 | 837 | |
792 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
838 | + if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) { |
|
839 | + // Don't extract the OS X-created __MACOSX directory files |
|
793 | 840 | continue; |
841 | + } |
|
794 | 842 | |
795 | - if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) |
|
796 | - return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); |
|
843 | + if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) { |
|
844 | + return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); |
|
845 | + } |
|
797 | 846 | } |
798 | 847 | return true; |
799 | 848 | } |
@@ -820,32 +869,37 @@ discard block |
||
820 | 869 | $to = trailingslashit($to); |
821 | 870 | |
822 | 871 | foreach ( (array) $dirlist as $filename => $fileinfo ) { |
823 | - if ( in_array( $filename, $skip_list ) ) |
|
824 | - continue; |
|
872 | + if ( in_array( $filename, $skip_list ) ) { |
|
873 | + continue; |
|
874 | + } |
|
825 | 875 | |
826 | 876 | if ( 'f' == $fileinfo['type'] ) { |
827 | 877 | if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { |
828 | 878 | // If copy failed, chmod file to 0644 and try again. |
829 | 879 | $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); |
830 | - if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) |
|
831 | - return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
|
880 | + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { |
|
881 | + return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
|
882 | + } |
|
832 | 883 | } |
833 | 884 | } elseif ( 'd' == $fileinfo['type'] ) { |
834 | 885 | if ( !$wp_filesystem->is_dir($to . $filename) ) { |
835 | - if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) |
|
836 | - return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); |
|
886 | + if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) { |
|
887 | + return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); |
|
888 | + } |
|
837 | 889 | } |
838 | 890 | |
839 | 891 | // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list |
840 | 892 | $sub_skip_list = array(); |
841 | 893 | foreach ( $skip_list as $skip_item ) { |
842 | - if ( 0 === strpos( $skip_item, $filename . '/' ) ) |
|
843 | - $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); |
|
894 | + if ( 0 === strpos( $skip_item, $filename . '/' ) ) { |
|
895 | + $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); |
|
896 | + } |
|
844 | 897 | } |
845 | 898 | |
846 | 899 | $result = copy_dir($from . $filename, $to . $filename, $sub_skip_list); |
847 | - if ( is_wp_error($result) ) |
|
848 | - return $result; |
|
900 | + if ( is_wp_error($result) ) { |
|
901 | + return $result; |
|
902 | + } |
|
849 | 903 | } |
850 | 904 | } |
851 | 905 | return true; |
@@ -875,8 +929,9 @@ discard block |
||
875 | 929 | |
876 | 930 | $method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership ); |
877 | 931 | |
878 | - if ( ! $method ) |
|
879 | - return false; |
|
932 | + if ( ! $method ) { |
|
933 | + return false; |
|
934 | + } |
|
880 | 935 | |
881 | 936 | if ( ! class_exists( "WP_Filesystem_$method" ) ) { |
882 | 937 | |
@@ -892,8 +947,9 @@ discard block |
||
892 | 947 | */ |
893 | 948 | $abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
894 | 949 | |
895 | - if ( ! file_exists($abstraction_file) ) |
|
896 | - return; |
|
950 | + if ( ! file_exists($abstraction_file) ) { |
|
951 | + return; |
|
952 | + } |
|
897 | 953 | |
898 | 954 | require_once($abstraction_file); |
899 | 955 | } |
@@ -902,22 +958,29 @@ discard block |
||
902 | 958 | $wp_filesystem = new $method($args); |
903 | 959 | |
904 | 960 | //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default. |
905 | - if ( ! defined('FS_CONNECT_TIMEOUT') ) |
|
906 | - define('FS_CONNECT_TIMEOUT', 30); |
|
907 | - if ( ! defined('FS_TIMEOUT') ) |
|
908 | - define('FS_TIMEOUT', 30); |
|
961 | + if ( ! defined('FS_CONNECT_TIMEOUT') ) { |
|
962 | + define('FS_CONNECT_TIMEOUT', 30); |
|
963 | + } |
|
964 | + if ( ! defined('FS_TIMEOUT') ) { |
|
965 | + define('FS_TIMEOUT', 30); |
|
966 | + } |
|
909 | 967 | |
910 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
911 | - return false; |
|
968 | + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) { |
|
969 | + return false; |
|
970 | + } |
|
912 | 971 | |
913 | - if ( !$wp_filesystem->connect() ) |
|
914 | - return false; //There was an error connecting to the server. |
|
972 | + if ( !$wp_filesystem->connect() ) { |
|
973 | + return false; |
|
974 | + } |
|
975 | + //There was an error connecting to the server. |
|
915 | 976 | |
916 | 977 | // Set the permission constants if not already set. |
917 | - if ( ! defined('FS_CHMOD_DIR') ) |
|
918 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
919 | - if ( ! defined('FS_CHMOD_FILE') ) |
|
920 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
978 | + if ( ! defined('FS_CHMOD_DIR') ) { |
|
979 | + define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
980 | + } |
|
981 | + if ( ! defined('FS_CHMOD_FILE') ) { |
|
982 | + define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
983 | + } |
|
921 | 984 | |
922 | 985 | return true; |
923 | 986 | } |
@@ -992,9 +1055,16 @@ discard block |
||
992 | 1055 | } |
993 | 1056 | } |
994 | 1057 | |
995 | - if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2'; |
|
996 | - if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; |
|
997 | - if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
1058 | + if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) { |
|
1059 | + $method = 'ssh2'; |
|
1060 | + } |
|
1061 | + if ( ! $method && extension_loaded('ftp') ) { |
|
1062 | + $method = 'ftpext'; |
|
1063 | + } |
|
1064 | + if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) { |
|
1065 | + $method = 'ftpsockets'; |
|
1066 | + } |
|
1067 | + //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
998 | 1068 | |
999 | 1069 | /** |
1000 | 1070 | * Filter the filesystem method to use. |
@@ -1061,18 +1131,21 @@ discard block |
||
1061 | 1131 | * @param array $extra_fields Extra POST fields. |
1062 | 1132 | */ |
1063 | 1133 | $req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership ); |
1064 | - if ( '' !== $req_cred ) |
|
1065 | - return $req_cred; |
|
1134 | + if ( '' !== $req_cred ) { |
|
1135 | + return $req_cred; |
|
1136 | + } |
|
1066 | 1137 | |
1067 | 1138 | if ( empty($type) ) { |
1068 | 1139 | $type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership ); |
1069 | 1140 | } |
1070 | 1141 | |
1071 | - if ( 'direct' == $type ) |
|
1072 | - return true; |
|
1142 | + if ( 'direct' == $type ) { |
|
1143 | + return true; |
|
1144 | + } |
|
1073 | 1145 | |
1074 | - if ( is_null( $extra_fields ) ) |
|
1075 | - $extra_fields = array( 'version', 'locale' ); |
|
1146 | + if ( is_null( $extra_fields ) ) { |
|
1147 | + $extra_fields = array( 'version', 'locale' ); |
|
1148 | + } |
|
1076 | 1149 | |
1077 | 1150 | $credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => '')); |
1078 | 1151 | |
@@ -1090,8 +1163,9 @@ discard block |
||
1090 | 1163 | |
1091 | 1164 | if ( strpos($credentials['hostname'], ':') ) { |
1092 | 1165 | list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2); |
1093 | - if ( ! is_numeric($credentials['port']) ) |
|
1094 | - unset($credentials['port']); |
|
1166 | + if ( ! is_numeric($credentials['port']) ) { |
|
1167 | + unset($credentials['port']); |
|
1168 | + } |
|
1095 | 1169 | } else { |
1096 | 1170 | unset($credentials['port']); |
1097 | 1171 | } |
@@ -1111,8 +1185,10 @@ discard block |
||
1111 | 1185 | ( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) ) |
1112 | 1186 | ) ) { |
1113 | 1187 | $stored_credentials = $credentials; |
1114 | - if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code. |
|
1188 | + if ( !empty($stored_credentials['port']) ) { |
|
1189 | + //save port as part of hostname to simplify above code. |
|
1115 | 1190 | $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; |
1191 | + } |
|
1116 | 1192 | |
1117 | 1193 | unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']); |
1118 | 1194 | if ( ! wp_installing() ) { |
@@ -1129,18 +1205,23 @@ discard block |
||
1129 | 1205 | |
1130 | 1206 | if ( $error ) { |
1131 | 1207 | $error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.'); |
1132 | - if ( is_wp_error($error) ) |
|
1133 | - $error_string = esc_html( $error->get_error_message() ); |
|
1208 | + if ( is_wp_error($error) ) { |
|
1209 | + $error_string = esc_html( $error->get_error_message() ); |
|
1210 | + } |
|
1134 | 1211 | echo '<div id="message" class="error"><p>' . $error_string . '</p></div>'; |
1135 | 1212 | } |
1136 | 1213 | |
1137 | 1214 | $types = array(); |
1138 | - if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) |
|
1139 | - $types[ 'ftp' ] = __('FTP'); |
|
1140 | - if ( extension_loaded('ftp') ) //Only this supports FTPS |
|
1215 | + if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) { |
|
1216 | + $types[ 'ftp' ] = __('FTP'); |
|
1217 | + } |
|
1218 | + if ( extension_loaded('ftp') ) { |
|
1219 | + //Only this supports FTPS |
|
1141 | 1220 | $types[ 'ftps' ] = __('FTPS (SSL)'); |
1142 | - if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) |
|
1143 | - $types[ 'ssh' ] = __('SSH2'); |
|
1221 | + } |
|
1222 | + if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) { |
|
1223 | + $types[ 'ssh' ] = __('SSH2'); |
|
1224 | + } |
|
1144 | 1225 | |
1145 | 1226 | /** |
1146 | 1227 | * Filter the connection types to output to the filesystem credentials form. |
@@ -1201,7 +1282,10 @@ discard block |
||
1201 | 1282 | ?></p> |
1202 | 1283 | <label for="hostname"> |
1203 | 1284 | <span class="field-title"><?php _e( 'Hostname' ) ?></span> |
1204 | - <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> /> |
|
1285 | + <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) { |
|
1286 | + echo ":$port"; |
|
1287 | +} |
|
1288 | +?>"<?php disabled( defined('FTP_HOST') ); ?> /> |
|
1205 | 1289 | </label> |
1206 | 1290 | <div class="ftp-username"> |
1207 | 1291 | <label for="username"> |
@@ -1212,8 +1296,14 @@ discard block |
||
1212 | 1296 | <div class="ftp-password"> |
1213 | 1297 | <label for="password"> |
1214 | 1298 | <span class="field-title"><?php echo $label_pass; ?></span> |
1215 | - <input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> /> |
|
1216 | - <em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em> |
|
1299 | + <input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) { |
|
1300 | + echo '*****'; |
|
1301 | +} |
|
1302 | +?>"<?php disabled( defined('FTP_PASS') ); ?> /> |
|
1303 | + <em><?php if ( ! defined('FTP_PASS') ) { |
|
1304 | + _e( 'This password will not be stored on the server.' ); |
|
1305 | +} |
|
1306 | +?></em> |
|
1217 | 1307 | </label> |
1218 | 1308 | </div> |
1219 | 1309 | <?php if ( isset($types['ssh']) ) : ?> |
@@ -1243,9 +1333,10 @@ discard block |
||
1243 | 1333 | </fieldset> |
1244 | 1334 | <?php |
1245 | 1335 | foreach ( (array) $extra_fields as $field ) { |
1246 | - if ( isset( $_POST[ $field ] ) ) |
|
1247 | - echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; |
|
1248 | -} |
|
1336 | + if ( isset( $_POST[ $field ] ) ) { |
|
1337 | + echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; |
|
1338 | + } |
|
1339 | + } |
|
1249 | 1340 | ?> |
1250 | 1341 | <p class="request-filesystem-credentials-action-buttons"> |
1251 | 1342 | <button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button> |
@@ -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 |
@@ -28,18 +28,21 @@ discard block |
||
28 | 28 | |
29 | 29 | if ( $response && $response['upgrade'] ) { |
30 | 30 | add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); |
31 | - if ( $response['insecure'] ) |
|
32 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
|
33 | - else |
|
34 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
|
31 | + if ( $response['insecure'] ) { |
|
32 | + wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
|
33 | + } else { |
|
34 | + wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
|
35 | + } |
|
35 | 36 | } |
36 | 37 | |
37 | 38 | // Right Now |
38 | - if ( is_blog_admin() && current_user_can('edit_posts') ) |
|
39 | - wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
|
39 | + if ( is_blog_admin() && current_user_can('edit_posts') ) { |
|
40 | + wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
|
41 | + } |
|
40 | 42 | |
41 | - if ( is_network_admin() ) |
|
42 | - wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
|
43 | + if ( is_network_admin() ) { |
|
44 | + wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
|
45 | + } |
|
43 | 46 | |
44 | 47 | // Activity Widget |
45 | 48 | if ( is_blog_admin() ) { |
@@ -163,12 +166,14 @@ discard block |
||
163 | 166 | $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); |
164 | 167 | |
165 | 168 | $location = 'normal'; |
166 | - if ( in_array($widget_id, $side_widgets) ) |
|
167 | - $location = 'side'; |
|
169 | + if ( in_array($widget_id, $side_widgets) ) { |
|
170 | + $location = 'side'; |
|
171 | + } |
|
168 | 172 | |
169 | 173 | $priority = 'core'; |
170 | - if ( 'dashboard_browser_nag' === $widget_id ) |
|
171 | - $priority = 'high'; |
|
174 | + if ( 'dashboard_browser_nag' === $widget_id ) { |
|
175 | + $priority = 'high'; |
|
176 | + } |
|
172 | 177 | |
173 | 178 | add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); |
174 | 179 | } |
@@ -376,10 +381,12 @@ discard block |
||
376 | 381 | */ |
377 | 382 | function wp_network_dashboard_right_now() { |
378 | 383 | $actions = array(); |
379 | - if ( current_user_can('create_sites') ) |
|
380 | - $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>'; |
|
381 | - if ( current_user_can('create_users') ) |
|
382 | - $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>'; |
|
384 | + if ( current_user_can('create_sites') ) { |
|
385 | + $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>'; |
|
386 | + } |
|
387 | + if ( current_user_can('create_users') ) { |
|
388 | + $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>'; |
|
389 | + } |
|
383 | 390 | |
384 | 391 | $c_users = get_user_count(); |
385 | 392 | $c_blogs = get_blog_count(); |
@@ -476,8 +483,10 @@ discard block |
||
476 | 483 | $post = get_default_post_to_edit( 'post' , true); |
477 | 484 | $user_id = get_current_user_id(); |
478 | 485 | // Don't create an option if this is a super admin who does not belong to this site. |
479 | - if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) |
|
480 | - update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
|
486 | + if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) { |
|
487 | + update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); |
|
488 | + } |
|
489 | + // Save post_ID |
|
481 | 490 | } |
482 | 491 | |
483 | 492 | $post_ID = (int) $post->ID; |
@@ -653,8 +662,9 @@ discard block |
||
653 | 662 | ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
654 | 663 | |
655 | 664 | // Reply and quickedit need a hide-if-no-js span |
656 | - if ( 'reply' == $action || 'quickedit' == $action ) |
|
657 | - $action .= ' hide-if-no-js'; |
|
665 | + if ( 'reply' == $action || 'quickedit' == $action ) { |
|
666 | + $action .= ' hide-if-no-js'; |
|
667 | + } |
|
658 | 668 | |
659 | 669 | $actions_string .= "<span class='$action'>$sep$link</span>"; |
660 | 670 | } |
@@ -691,10 +701,12 @@ discard block |
||
691 | 701 | </p> |
692 | 702 | |
693 | 703 | <?php |
694 | - else : |
|
704 | + else { |
|
705 | + : |
|
695 | 706 | switch ( $comment->comment_type ) { |
696 | 707 | case 'pingback' : |
697 | 708 | $type = __( 'Pingback' ); |
709 | + } |
|
698 | 710 | break; |
699 | 711 | case 'trackback' : |
700 | 712 | $type = __( 'Trackback' ); |
@@ -883,19 +895,22 @@ discard block |
||
883 | 895 | 'number' => $total_items * 5, |
884 | 896 | 'offset' => 0 |
885 | 897 | ); |
886 | - if ( ! current_user_can( 'edit_posts' ) ) |
|
887 | - $comments_query['status'] = 'approve'; |
|
898 | + if ( ! current_user_can( 'edit_posts' ) ) { |
|
899 | + $comments_query['status'] = 'approve'; |
|
900 | + } |
|
888 | 901 | |
889 | 902 | while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { |
890 | 903 | if ( ! is_array( $possible ) ) { |
891 | 904 | break; |
892 | 905 | } |
893 | 906 | foreach ( $possible as $comment ) { |
894 | - if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) |
|
895 | - continue; |
|
907 | + if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) { |
|
908 | + continue; |
|
909 | + } |
|
896 | 910 | $comments[] = $comment; |
897 | - if ( count( $comments ) == $total_items ) |
|
898 | - break 2; |
|
911 | + if ( count( $comments ) == $total_items ) { |
|
912 | + break 2; |
|
913 | + } |
|
899 | 914 | } |
900 | 915 | $comments_query['offset'] += $comments_query['number']; |
901 | 916 | $comments_query['number'] = $total_items * 10; |
@@ -906,8 +921,9 @@ discard block |
||
906 | 921 | echo '<h3>' . __( 'Recent Comments' ) . '</h3>'; |
907 | 922 | |
908 | 923 | echo '<ul id="the-comment-list" data-wp-lists="list:comment">'; |
909 | - foreach ( $comments as $comment ) |
|
910 | - _wp_dashboard_recent_comments_row( $comment ); |
|
924 | + foreach ( $comments as $comment ) { |
|
925 | + _wp_dashboard_recent_comments_row( $comment ); |
|
926 | + } |
|
911 | 927 | echo '</ul>'; |
912 | 928 | |
913 | 929 | if ( current_user_can( 'edit_posts' ) ) { |
@@ -1023,11 +1039,13 @@ discard block |
||
1023 | 1039 | * @param array $form_inputs |
1024 | 1040 | */ |
1025 | 1041 | function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
1026 | - if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) |
|
1027 | - $widget_options = array(); |
|
1042 | + if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) { |
|
1043 | + $widget_options = array(); |
|
1044 | + } |
|
1028 | 1045 | |
1029 | - if ( !isset($widget_options[$widget_id]) ) |
|
1030 | - $widget_options[$widget_id] = array(); |
|
1046 | + if ( !isset($widget_options[$widget_id]) ) { |
|
1047 | + $widget_options[$widget_id] = array(); |
|
1048 | + } |
|
1031 | 1049 | |
1032 | 1050 | $number = 1; // Hack to use wp_widget_rss_form() |
1033 | 1051 | $widget_options[$widget_id]['number'] = $number; |
@@ -1197,16 +1215,18 @@ discard block |
||
1197 | 1215 | echo '<ul>'; |
1198 | 1216 | |
1199 | 1217 | foreach ( array( $popular ) as $feed ) { |
1200 | - if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) |
|
1201 | - continue; |
|
1218 | + if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) { |
|
1219 | + continue; |
|
1220 | + } |
|
1202 | 1221 | |
1203 | 1222 | $items = $feed->get_items(0, 5); |
1204 | 1223 | |
1205 | 1224 | // Pick a random, non-installed plugin |
1206 | 1225 | while ( true ) { |
1207 | 1226 | // Abort this foreach loop iteration if there's no plugins left of this type |
1208 | - if ( 0 == count($items) ) |
|
1209 | - continue 2; |
|
1227 | + if ( 0 == count($items) ) { |
|
1228 | + continue 2; |
|
1229 | + } |
|
1210 | 1230 | |
1211 | 1231 | $item_key = array_rand($items); |
1212 | 1232 | $item = $items[$item_key]; |
@@ -1214,9 +1234,9 @@ discard block |
||
1214 | 1234 | list($link, $frag) = explode( '#', $item->get_link() ); |
1215 | 1235 | |
1216 | 1236 | $link = esc_url($link); |
1217 | - if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) |
|
1218 | - $slug = $matches[1]; |
|
1219 | - else { |
|
1237 | + if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) { |
|
1238 | + $slug = $matches[1]; |
|
1239 | + } else { |
|
1220 | 1240 | unset( $items[$item_key] ); |
1221 | 1241 | continue; |
1222 | 1242 | } |
@@ -1235,11 +1255,13 @@ discard block |
||
1235 | 1255 | } |
1236 | 1256 | |
1237 | 1257 | // Eliminate some common badly formed plugin descriptions |
1238 | - while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) |
|
1239 | - unset($items[$item_key]); |
|
1258 | + while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) { |
|
1259 | + unset($items[$item_key]); |
|
1260 | + } |
|
1240 | 1261 | |
1241 | - if ( !isset($items[$item_key]) ) |
|
1242 | - continue; |
|
1262 | + if ( !isset($items[$item_key]) ) { |
|
1263 | + continue; |
|
1264 | + } |
|
1243 | 1265 | |
1244 | 1266 | $raw_title = $item->get_title(); |
1245 | 1267 | |
@@ -1266,16 +1288,18 @@ discard block |
||
1266 | 1288 | * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled. |
1267 | 1289 | */ |
1268 | 1290 | function wp_dashboard_quota() { |
1269 | - if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) |
|
1270 | - return true; |
|
1291 | + if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) { |
|
1292 | + return true; |
|
1293 | + } |
|
1271 | 1294 | |
1272 | 1295 | $quota = get_space_allowed(); |
1273 | 1296 | $used = get_space_used(); |
1274 | 1297 | |
1275 | - if ( $used > $quota ) |
|
1276 | - $percentused = '100'; |
|
1277 | - else |
|
1278 | - $percentused = ( $used / $quota ) * 100; |
|
1298 | + if ( $used > $quota ) { |
|
1299 | + $percentused = '100'; |
|
1300 | + } else { |
|
1301 | + $percentused = ( $used / $quota ) * 100; |
|
1302 | + } |
|
1279 | 1303 | $used_class = ( $percentused >= 70 ) ? ' warning' : ''; |
1280 | 1304 | $used = round( $used, 2 ); |
1281 | 1305 | $percentused = number_format( $percentused ); |
@@ -1344,8 +1368,9 @@ discard block |
||
1344 | 1368 | |
1345 | 1369 | $browsehappy = 'http://browsehappy.com/'; |
1346 | 1370 | $locale = get_locale(); |
1347 | - if ( 'en_US' !== $locale ) |
|
1348 | - $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
|
1371 | + if ( 'en_US' !== $locale ) { |
|
1372 | + $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
|
1373 | + } |
|
1349 | 1374 | |
1350 | 1375 | $notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>'; |
1351 | 1376 | $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>'; |
@@ -1372,8 +1397,9 @@ discard block |
||
1372 | 1397 | function dashboard_browser_nag_class( $classes ) { |
1373 | 1398 | $response = wp_check_browser_version(); |
1374 | 1399 | |
1375 | - if ( $response && $response['insecure'] ) |
|
1376 | - $classes[] = 'browser-insecure'; |
|
1400 | + if ( $response && $response['insecure'] ) { |
|
1401 | + $classes[] = 'browser-insecure'; |
|
1402 | + } |
|
1377 | 1403 | |
1378 | 1404 | return $classes; |
1379 | 1405 | } |
@@ -1388,8 +1414,9 @@ discard block |
||
1388 | 1414 | * @return array|bool False on failure, array of browser data on success. |
1389 | 1415 | */ |
1390 | 1416 | function wp_check_browser_version() { |
1391 | - if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) |
|
1392 | - return false; |
|
1417 | + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1418 | + return false; |
|
1419 | + } |
|
1393 | 1420 | |
1394 | 1421 | $key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
1395 | 1422 | |
@@ -1403,8 +1430,9 @@ discard block |
||
1403 | 1430 | |
1404 | 1431 | $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options ); |
1405 | 1432 | |
1406 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
1407 | - return false; |
|
1433 | + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
1434 | + return false; |
|
1435 | + } |
|
1408 | 1436 | |
1409 | 1437 | /** |
1410 | 1438 | * Response should be an array with: |
@@ -1419,8 +1447,9 @@ discard block |
||
1419 | 1447 | */ |
1420 | 1448 | $response = json_decode( wp_remote_retrieve_body( $response ), true ); |
1421 | 1449 | |
1422 | - if ( ! is_array( $response ) ) |
|
1423 | - return false; |
|
1450 | + if ( ! is_array( $response ) ) { |
|
1451 | + return false; |
|
1452 | + } |
|
1424 | 1453 | |
1425 | 1454 | set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); |
1426 | 1455 | } |
@@ -1464,8 +1493,11 @@ discard block |
||
1464 | 1493 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
1465 | 1494 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
1466 | 1495 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
1467 | - <?php else : ?> |
|
1468 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
1496 | + <?php else { |
|
1497 | + : ?> |
|
1498 | + <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); |
|
1499 | +} |
|
1500 | +?></li> |
|
1469 | 1501 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
1470 | 1502 | <?php endif; ?> |
1471 | 1503 | <li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li> |