@@ -52,12 +52,12 @@ |
||
52 | 52 | $add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) ); |
53 | 53 | } else { |
54 | 54 | /** |
55 | - * Fires after a new user has been created via the network user-new.php page. |
|
56 | - * |
|
57 | - * @since 4.4.0 |
|
58 | - * |
|
59 | - * @param int $user_id ID of the newly created user. |
|
60 | - */ |
|
55 | + * Fires after a new user has been created via the network user-new.php page. |
|
56 | + * |
|
57 | + * @since 4.4.0 |
|
58 | + * |
|
59 | + * @param int $user_id ID of the newly created user. |
|
60 | + */ |
|
61 | 61 | do_action( 'network_user_new_created_user', $user_id ); |
62 | 62 | wp_redirect( add_query_arg( array('update' => 'added', 'user_id' => $user_id ), 'user-new.php' ) ); |
63 | 63 | exit; |
@@ -8,45 +8,45 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** Load WordPress Administration Bootstrap */ |
11 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 | +require_once(dirname(__FILE__).'/admin.php'); |
|
12 | 12 | |
13 | -if ( ! current_user_can('create_users') ) |
|
13 | +if ( ! current_user_can('create_users')) |
|
14 | 14 | wp_die(__('Sorry, you are not allowed to add users to this network.')); |
15 | 15 | |
16 | -get_current_screen()->add_help_tab( array( |
|
16 | +get_current_screen()->add_help_tab(array( |
|
17 | 17 | 'id' => 'overview', |
18 | 18 | 'title' => __('Overview'), |
19 | 19 | 'content' => |
20 | - '<p>' . __('Add User will set up a new user account on the network and send that person an email with username and password.') . '</p>' . |
|
21 | - '<p>' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '</p>' |
|
22 | -) ); |
|
20 | + '<p>'.__('Add User will set up a new user account on the network and send that person an email with username and password.').'</p>'. |
|
21 | + '<p>'.__('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.').'</p>' |
|
22 | +)); |
|
23 | 23 | |
24 | 24 | get_current_screen()->set_help_sidebar( |
25 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
26 | - '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen">Documentation on Network Users</a>') . '</p>' . |
|
27 | - '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>' |
|
25 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
26 | + '<p>'.__('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen">Documentation on Network Users</a>').'</p>'. |
|
27 | + '<p>'.__('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>').'</p>' |
|
28 | 28 | ); |
29 | 29 | |
30 | -if ( isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action'] ) { |
|
31 | - check_admin_referer( 'add-user', '_wpnonce_add-user' ); |
|
30 | +if (isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action']) { |
|
31 | + check_admin_referer('add-user', '_wpnonce_add-user'); |
|
32 | 32 | |
33 | - if ( ! current_user_can( 'manage_network_users' ) ) |
|
34 | - wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
|
33 | + if ( ! current_user_can('manage_network_users')) |
|
34 | + wp_die(__('Sorry, you are not allowed to access this page.'), 403); |
|
35 | 35 | |
36 | - if ( ! is_array( $_POST['user'] ) ) |
|
37 | - wp_die( __( 'Cannot create an empty user.' ) ); |
|
36 | + if ( ! is_array($_POST['user'])) |
|
37 | + wp_die(__('Cannot create an empty user.')); |
|
38 | 38 | |
39 | - $user = wp_unslash( $_POST['user'] ); |
|
39 | + $user = wp_unslash($_POST['user']); |
|
40 | 40 | |
41 | - $user_details = wpmu_validate_user_signup( $user['username'], $user['email'] ); |
|
42 | - if ( is_wp_error( $user_details[ 'errors' ] ) && ! empty( $user_details[ 'errors' ]->errors ) ) { |
|
43 | - $add_user_errors = $user_details[ 'errors' ]; |
|
41 | + $user_details = wpmu_validate_user_signup($user['username'], $user['email']); |
|
42 | + if (is_wp_error($user_details['errors']) && ! empty($user_details['errors']->errors)) { |
|
43 | + $add_user_errors = $user_details['errors']; |
|
44 | 44 | } else { |
45 | - $password = wp_generate_password( 12, false); |
|
46 | - $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, sanitize_email( $user['email'] ) ); |
|
45 | + $password = wp_generate_password(12, false); |
|
46 | + $user_id = wpmu_create_user(esc_html(strtolower($user['username'])), $password, sanitize_email($user['email'])); |
|
47 | 47 | |
48 | - if ( ! $user_id ) { |
|
49 | - $add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) ); |
|
48 | + if ( ! $user_id) { |
|
49 | + $add_user_errors = new WP_Error('add_user_fail', __('Cannot add user.')); |
|
50 | 50 | } else { |
51 | 51 | /** |
52 | 52 | * Fires after a new user has been created via the network user-new.php page. |
@@ -55,29 +55,29 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param int $user_id ID of the newly created user. |
57 | 57 | */ |
58 | - do_action( 'network_user_new_created_user', $user_id ); |
|
59 | - wp_redirect( add_query_arg( array('update' => 'added', 'user_id' => $user_id ), 'user-new.php' ) ); |
|
58 | + do_action('network_user_new_created_user', $user_id); |
|
59 | + wp_redirect(add_query_arg(array('update' => 'added', 'user_id' => $user_id), 'user-new.php')); |
|
60 | 60 | exit; |
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | -if ( isset($_GET['update']) ) { |
|
65 | +if (isset($_GET['update'])) { |
|
66 | 66 | $messages = array(); |
67 | - if ( 'added' == $_GET['update'] ) { |
|
67 | + if ('added' == $_GET['update']) { |
|
68 | 68 | $edit_link = ''; |
69 | - if ( isset( $_GET['user_id'] ) ) { |
|
70 | - $user_id_new = absint( $_GET['user_id'] ); |
|
71 | - if ( $user_id_new ) { |
|
72 | - $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) ); |
|
69 | + if (isset($_GET['user_id'])) { |
|
70 | + $user_id_new = absint($_GET['user_id']); |
|
71 | + if ($user_id_new) { |
|
72 | + $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user_id_new))); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - if ( empty( $edit_link ) ) { |
|
77 | - $messages[] = __( 'User added.' ); |
|
76 | + if (empty($edit_link)) { |
|
77 | + $messages[] = __('User added.'); |
|
78 | 78 | } else { |
79 | 79 | /* translators: %s: edit page url */ |
80 | - $messages[] = sprintf( __( 'User added. <a href="%s">Edit user</a>' ), $edit_link ); |
|
80 | + $messages[] = sprintf(__('User added. <a href="%s">Edit user</a>'), $edit_link); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | $title = __('Add New User'); |
86 | 86 | $parent_file = 'users.php'; |
87 | 87 | |
88 | -require( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
|
88 | +require(ABSPATH.'wp-admin/admin-header.php'); ?> |
|
89 | 89 | |
90 | 90 | <div class="wrap"> |
91 | -<h1 id="add-new-user"><?php _e( 'Add New User' ); ?></h1> |
|
91 | +<h1 id="add-new-user"><?php _e('Add New User'); ?></h1> |
|
92 | 92 | <?php |
93 | -if ( ! empty( $messages ) ) { |
|
94 | - foreach ( $messages as $msg ) |
|
95 | - echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
93 | +if ( ! empty($messages)) { |
|
94 | + foreach ($messages as $msg) |
|
95 | + echo '<div id="message" class="updated notice is-dismissible"><p>'.$msg.'</p></div>'; |
|
96 | 96 | } |
97 | 97 | |
98 | -if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) { ?> |
|
98 | +if (isset($add_user_errors) && is_wp_error($add_user_errors)) { ?> |
|
99 | 99 | <div class="error"> |
100 | 100 | <?php |
101 | - foreach ( $add_user_errors->get_error_messages() as $message ) |
|
101 | + foreach ($add_user_errors->get_error_messages() as $message) |
|
102 | 102 | echo "<p>$message</p>"; |
103 | 103 | ?> |
104 | 104 | </div> |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | <form action="<?php echo network_admin_url('user-new.php?action=add-user'); ?>" id="adduser" method="post" novalidate="novalidate"> |
107 | 107 | <table class="form-table"> |
108 | 108 | <tr class="form-field form-required"> |
109 | - <th scope="row"><label for="username"><?php _e( 'Username' ) ?></label></th> |
|
109 | + <th scope="row"><label for="username"><?php _e('Username') ?></label></th> |
|
110 | 110 | <td><input type="text" class="regular-text" name="user[username]" id="username" autocapitalize="none" autocorrect="off" maxlength="60" /></td> |
111 | 111 | </tr> |
112 | 112 | <tr class="form-field form-required"> |
113 | - <th scope="row"><label for="email"><?php _e( 'Email' ) ?></label></th> |
|
113 | + <th scope="row"><label for="email"><?php _e('Email') ?></label></th> |
|
114 | 114 | <td><input type="email" class="regular-text" name="user[email]" id="email"/></td> |
115 | 115 | </tr> |
116 | 116 | <tr class="form-field"> |
117 | - <td colspan="2"><?php _e( 'A password reset link will be sent to the user via email.' ) ?></td> |
|
117 | + <td colspan="2"><?php _e('A password reset link will be sent to the user via email.') ?></td> |
|
118 | 118 | </tr> |
119 | 119 | </table> |
120 | 120 | <?php |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @since 4.5.0 |
125 | 125 | */ |
126 | - do_action( 'network_user_new_form' ); |
|
126 | + do_action('network_user_new_form'); |
|
127 | 127 | |
128 | - wp_nonce_field( 'add-user', '_wpnonce_add-user' ); |
|
129 | - submit_button( __('Add User'), 'primary', 'add-user' ); |
|
128 | + wp_nonce_field('add-user', '_wpnonce_add-user'); |
|
129 | + submit_button(__('Add User'), 'primary', 'add-user'); |
|
130 | 130 | ?> |
131 | 131 | </form> |
132 | 132 | </div> |
133 | 133 | <?php |
134 | -require( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
134 | +require(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | /** Load WordPress Administration Bootstrap */ |
11 | 11 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
12 | 12 | |
13 | -if ( ! current_user_can('create_users') ) |
|
13 | +if ( ! current_user_can('create_users') ) { |
|
14 | 14 | wp_die(__('Sorry, you are not allowed to add users to this network.')); |
15 | +} |
|
15 | 16 | |
16 | 17 | get_current_screen()->add_help_tab( array( |
17 | 18 | 'id' => 'overview', |
@@ -30,11 +31,13 @@ discard block |
||
30 | 31 | if ( isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action'] ) { |
31 | 32 | check_admin_referer( 'add-user', '_wpnonce_add-user' ); |
32 | 33 | |
33 | - if ( ! current_user_can( 'manage_network_users' ) ) |
|
34 | - wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
|
34 | + if ( ! current_user_can( 'manage_network_users' ) ) { |
|
35 | + wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
|
36 | + } |
|
35 | 37 | |
36 | - if ( ! is_array( $_POST['user'] ) ) |
|
37 | - wp_die( __( 'Cannot create an empty user.' ) ); |
|
38 | + if ( ! is_array( $_POST['user'] ) ) { |
|
39 | + wp_die( __( 'Cannot create an empty user.' ) ); |
|
40 | + } |
|
38 | 41 | |
39 | 42 | $user = wp_unslash( $_POST['user'] ); |
40 | 43 | |
@@ -91,15 +94,17 @@ discard block |
||
91 | 94 | <h1 id="add-new-user"><?php _e( 'Add New User' ); ?></h1> |
92 | 95 | <?php |
93 | 96 | if ( ! empty( $messages ) ) { |
94 | - foreach ( $messages as $msg ) |
|
95 | - echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
96 | -} |
|
97 | + foreach ( $messages as $msg ) { |
|
98 | + echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
99 | + } |
|
100 | + } |
|
97 | 101 | |
98 | 102 | if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) { ?> |
99 | 103 | <div class="error"> |
100 | 104 | <?php |
101 | - foreach ( $add_user_errors->get_error_messages() as $message ) |
|
102 | - echo "<p>$message</p>"; |
|
105 | + foreach ( $add_user_errors->get_error_messages() as $message ) { |
|
106 | + echo "<p>$message</p>"; |
|
107 | + } |
|
103 | 108 | ?> |
104 | 109 | </div> |
105 | 110 | <?php } ?> |
@@ -45,8 +45,8 @@ |
||
45 | 45 | |
46 | 46 | $sendback = wp_get_referer(); |
47 | 47 | if ( ! $sendback || |
48 | - strpos( $sendback, 'post.php' ) !== false || |
|
49 | - strpos( $sendback, 'post-new.php' ) !== false ) { |
|
48 | + strpos( $sendback, 'post.php' ) !== false || |
|
49 | + strpos( $sendback, 'post-new.php' ) !== false ) { |
|
50 | 50 | if ( 'attachment' == $post_type ) { |
51 | 51 | $sendback = admin_url( 'upload.php' ); |
52 | 52 | } else { |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | /** WordPress Administration Bootstrap */ |
12 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
12 | +require_once(dirname(__FILE__).'/admin.php'); |
|
13 | 13 | |
14 | 14 | $parent_file = 'edit.php'; |
15 | 15 | $submenu_file = 'edit.php'; |
16 | 16 | |
17 | -wp_reset_vars( array( 'action' ) ); |
|
17 | +wp_reset_vars(array('action')); |
|
18 | 18 | |
19 | -if ( isset( $_GET['post'] ) ) |
|
19 | +if (isset($_GET['post'])) |
|
20 | 20 | $post_id = $post_ID = (int) $_GET['post']; |
21 | -elseif ( isset( $_POST['post_ID'] ) ) |
|
21 | +elseif (isset($_POST['post_ID'])) |
|
22 | 22 | $post_id = $post_ID = (int) $_POST['post_ID']; |
23 | 23 | else |
24 | 24 | $post_id = $post_ID = 0; |
@@ -30,59 +30,59 @@ discard block |
||
30 | 30 | */ |
31 | 31 | global $post_type, $post_type_object, $post; |
32 | 32 | |
33 | -if ( $post_id ) |
|
34 | - $post = get_post( $post_id ); |
|
33 | +if ($post_id) |
|
34 | + $post = get_post($post_id); |
|
35 | 35 | |
36 | -if ( $post ) { |
|
36 | +if ($post) { |
|
37 | 37 | $post_type = $post->post_type; |
38 | - $post_type_object = get_post_type_object( $post_type ); |
|
38 | + $post_type_object = get_post_type_object($post_type); |
|
39 | 39 | } |
40 | 40 | |
41 | -if ( isset( $_POST['deletepost'] ) ) |
|
41 | +if (isset($_POST['deletepost'])) |
|
42 | 42 | $action = 'delete'; |
43 | -elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] ) |
|
43 | +elseif (isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview']) |
|
44 | 44 | $action = 'preview'; |
45 | 45 | |
46 | 46 | $sendback = wp_get_referer(); |
47 | 47 | if ( ! $sendback || |
48 | - strpos( $sendback, 'post.php' ) !== false || |
|
49 | - strpos( $sendback, 'post-new.php' ) !== false ) { |
|
50 | - if ( 'attachment' == $post_type ) { |
|
51 | - $sendback = admin_url( 'upload.php' ); |
|
48 | + strpos($sendback, 'post.php') !== false || |
|
49 | + strpos($sendback, 'post-new.php') !== false) { |
|
50 | + if ('attachment' == $post_type) { |
|
51 | + $sendback = admin_url('upload.php'); |
|
52 | 52 | } else { |
53 | - $sendback = admin_url( 'edit.php' ); |
|
54 | - if ( ! empty( $post_type ) ) { |
|
55 | - $sendback = add_query_arg( 'post_type', $post_type, $sendback ); |
|
53 | + $sendback = admin_url('edit.php'); |
|
54 | + if ( ! empty($post_type)) { |
|
55 | + $sendback = add_query_arg('post_type', $post_type, $sendback); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } else { |
59 | - $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback ); |
|
59 | + $sendback = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'ids'), $sendback); |
|
60 | 60 | } |
61 | 61 | |
62 | -switch($action) { |
|
62 | +switch ($action) { |
|
63 | 63 | case 'post-quickdraft-save': |
64 | 64 | // Check nonce and capabilities |
65 | 65 | $nonce = $_REQUEST['_wpnonce']; |
66 | 66 | $error_msg = false; |
67 | 67 | |
68 | 68 | // For output of the quickdraft dashboard widget |
69 | - require_once ABSPATH . 'wp-admin/includes/dashboard.php'; |
|
69 | + require_once ABSPATH.'wp-admin/includes/dashboard.php'; |
|
70 | 70 | |
71 | - if ( ! wp_verify_nonce( $nonce, 'add-post' ) ) |
|
72 | - $error_msg = __( 'Unable to submit this form, please refresh and try again.' ); |
|
71 | + if ( ! wp_verify_nonce($nonce, 'add-post')) |
|
72 | + $error_msg = __('Unable to submit this form, please refresh and try again.'); |
|
73 | 73 | |
74 | - if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
|
74 | + if ( ! current_user_can(get_post_type_object('post')->cap->create_posts)) { |
|
75 | 75 | exit; |
76 | 76 | } |
77 | 77 | |
78 | - if ( $error_msg ) |
|
79 | - return wp_dashboard_quick_press( $error_msg ); |
|
78 | + if ($error_msg) |
|
79 | + return wp_dashboard_quick_press($error_msg); |
|
80 | 80 | |
81 | - $post = get_post( $_REQUEST['post_ID'] ); |
|
82 | - check_admin_referer( 'add-' . $post->post_type ); |
|
81 | + $post = get_post($_REQUEST['post_ID']); |
|
82 | + check_admin_referer('add-'.$post->post_type); |
|
83 | 83 | |
84 | - $_POST['comment_status'] = get_default_comment_status( $post->post_type ); |
|
85 | - $_POST['ping_status'] = get_default_comment_status( $post->post_type, 'pingback' ); |
|
84 | + $_POST['comment_status'] = get_default_comment_status($post->post_type); |
|
85 | + $_POST['ping_status'] = get_default_comment_status($post->post_type, 'pingback'); |
|
86 | 86 | |
87 | 87 | edit_post(); |
88 | 88 | wp_dashboard_quick_press(); |
@@ -90,53 +90,53 @@ discard block |
||
90 | 90 | |
91 | 91 | case 'postajaxpost': |
92 | 92 | case 'post': |
93 | - check_admin_referer( 'add-' . $post_type ); |
|
93 | + check_admin_referer('add-'.$post_type); |
|
94 | 94 | $post_id = 'postajaxpost' == $action ? edit_post() : write_post(); |
95 | - redirect_post( $post_id ); |
|
95 | + redirect_post($post_id); |
|
96 | 96 | exit(); |
97 | 97 | |
98 | 98 | case 'edit': |
99 | 99 | $editing = true; |
100 | 100 | |
101 | - if ( empty( $post_id ) ) { |
|
102 | - wp_redirect( admin_url('post.php') ); |
|
101 | + if (empty($post_id)) { |
|
102 | + wp_redirect(admin_url('post.php')); |
|
103 | 103 | exit(); |
104 | 104 | } |
105 | 105 | |
106 | - if ( ! $post ) |
|
107 | - wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
106 | + if ( ! $post) |
|
107 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
108 | 108 | |
109 | - if ( ! $post_type_object ) |
|
110 | - wp_die( __( 'Unknown post type.' ) ); |
|
109 | + if ( ! $post_type_object) |
|
110 | + wp_die(__('Unknown post type.')); |
|
111 | 111 | |
112 | - if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ) ) ) { |
|
113 | - wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
|
112 | + if ( ! in_array($typenow, get_post_types(array('show_ui' => true)))) { |
|
113 | + wp_die(__('Sorry, you are not allowed to edit posts in this post type.')); |
|
114 | 114 | } |
115 | 115 | |
116 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
117 | - wp_die( __( 'Sorry, you are not allowed to edit this item.' ) ); |
|
116 | + if ( ! current_user_can('edit_post', $post_id)) |
|
117 | + wp_die(__('Sorry, you are not allowed to edit this item.')); |
|
118 | 118 | |
119 | - if ( 'trash' == $post->post_status ) |
|
120 | - wp_die( __( 'You can’t edit this item because it is in the Trash. Please restore it and try again.' ) ); |
|
119 | + if ('trash' == $post->post_status) |
|
120 | + wp_die(__('You can’t edit this item because it is in the Trash. Please restore it and try again.')); |
|
121 | 121 | |
122 | - if ( ! empty( $_GET['get-post-lock'] ) ) { |
|
123 | - check_admin_referer( 'lock-post_' . $post_id ); |
|
124 | - wp_set_post_lock( $post_id ); |
|
125 | - wp_redirect( get_edit_post_link( $post_id, 'url' ) ); |
|
122 | + if ( ! empty($_GET['get-post-lock'])) { |
|
123 | + check_admin_referer('lock-post_'.$post_id); |
|
124 | + wp_set_post_lock($post_id); |
|
125 | + wp_redirect(get_edit_post_link($post_id, 'url')); |
|
126 | 126 | exit(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $post_type = $post->post_type; |
130 | - if ( 'post' == $post_type ) { |
|
130 | + if ('post' == $post_type) { |
|
131 | 131 | $parent_file = "edit.php"; |
132 | 132 | $submenu_file = "edit.php"; |
133 | 133 | $post_new_file = "post-new.php"; |
134 | - } elseif ( 'attachment' == $post_type ) { |
|
134 | + } elseif ('attachment' == $post_type) { |
|
135 | 135 | $parent_file = 'upload.php'; |
136 | 136 | $submenu_file = 'upload.php'; |
137 | 137 | $post_new_file = 'media-new.php'; |
138 | 138 | } else { |
139 | - if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) |
|
139 | + if (isset($post_type_object) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true) |
|
140 | 140 | $parent_file = $post_type_object->show_in_menu; |
141 | 141 | else |
142 | 142 | $parent_file = "edit.php?post_type=$post_type"; |
@@ -144,57 +144,57 @@ discard block |
||
144 | 144 | $post_new_file = "post-new.php?post_type=$post_type"; |
145 | 145 | } |
146 | 146 | |
147 | - if ( ! wp_check_post_lock( $post->ID ) ) { |
|
148 | - $active_post_lock = wp_set_post_lock( $post->ID ); |
|
147 | + if ( ! wp_check_post_lock($post->ID)) { |
|
148 | + $active_post_lock = wp_set_post_lock($post->ID); |
|
149 | 149 | |
150 | - if ( 'attachment' !== $post_type ) |
|
150 | + if ('attachment' !== $post_type) |
|
151 | 151 | wp_enqueue_script('autosave'); |
152 | 152 | } |
153 | 153 | |
154 | - if ( is_multisite() ) { |
|
155 | - add_action( 'admin_footer', '_admin_notice_post_locked' ); |
|
154 | + if (is_multisite()) { |
|
155 | + add_action('admin_footer', '_admin_notice_post_locked'); |
|
156 | 156 | } else { |
157 | - $check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) ); |
|
157 | + $check_users = get_users(array('fields' => 'ID', 'number' => 2)); |
|
158 | 158 | |
159 | - if ( count( $check_users ) > 1 ) |
|
160 | - add_action( 'admin_footer', '_admin_notice_post_locked' ); |
|
159 | + if (count($check_users) > 1) |
|
160 | + add_action('admin_footer', '_admin_notice_post_locked'); |
|
161 | 161 | |
162 | - unset( $check_users ); |
|
162 | + unset($check_users); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $title = $post_type_object->labels->edit_item; |
166 | 166 | $post = get_post($post_id, OBJECT, 'edit'); |
167 | 167 | |
168 | - if ( post_type_supports($post_type, 'comments') ) { |
|
168 | + if (post_type_supports($post_type, 'comments')) { |
|
169 | 169 | wp_enqueue_script('admin-comments'); |
170 | 170 | enqueue_comment_hotkeys_js(); |
171 | 171 | } |
172 | 172 | |
173 | - include( ABSPATH . 'wp-admin/edit-form-advanced.php' ); |
|
173 | + include(ABSPATH.'wp-admin/edit-form-advanced.php'); |
|
174 | 174 | |
175 | 175 | break; |
176 | 176 | |
177 | 177 | case 'editattachment': |
178 | - check_admin_referer('update-post_' . $post_id); |
|
178 | + check_admin_referer('update-post_'.$post_id); |
|
179 | 179 | |
180 | 180 | // Don't let these be changed |
181 | 181 | unset($_POST['guid']); |
182 | 182 | $_POST['post_type'] = 'attachment'; |
183 | 183 | |
184 | 184 | // Update the thumbnail filename |
185 | - $newmeta = wp_get_attachment_metadata( $post_id, true ); |
|
185 | + $newmeta = wp_get_attachment_metadata($post_id, true); |
|
186 | 186 | $newmeta['thumb'] = $_POST['thumb']; |
187 | 187 | |
188 | - wp_update_attachment_metadata( $post_id, $newmeta ); |
|
188 | + wp_update_attachment_metadata($post_id, $newmeta); |
|
189 | 189 | |
190 | 190 | case 'editpost': |
191 | - check_admin_referer('update-post_' . $post_id); |
|
191 | + check_admin_referer('update-post_'.$post_id); |
|
192 | 192 | |
193 | 193 | $post_id = edit_post(); |
194 | 194 | |
195 | 195 | // Session cookie flag that the post was saved |
196 | - if ( isset( $_COOKIE['wp-saving-post'] ) && $_COOKIE['wp-saving-post'] === $post_id . '-check' ) { |
|
197 | - setcookie( 'wp-saving-post', $post_id . '-saved', time() + DAY_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, is_ssl() ); |
|
196 | + if (isset($_COOKIE['wp-saving-post']) && $_COOKIE['wp-saving-post'] === $post_id.'-check') { |
|
197 | + setcookie('wp-saving-post', $post_id.'-saved', time() + DAY_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, is_ssl()); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | redirect_post($post_id); // Send user on their way while we keep working |
@@ -202,72 +202,72 @@ discard block |
||
202 | 202 | exit(); |
203 | 203 | |
204 | 204 | case 'trash': |
205 | - check_admin_referer('trash-post_' . $post_id); |
|
205 | + check_admin_referer('trash-post_'.$post_id); |
|
206 | 206 | |
207 | - if ( ! $post ) |
|
208 | - wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) ); |
|
207 | + if ( ! $post) |
|
208 | + wp_die(__('The item you are trying to move to the Trash no longer exists.')); |
|
209 | 209 | |
210 | - if ( ! $post_type_object ) |
|
211 | - wp_die( __( 'Unknown post type.' ) ); |
|
210 | + if ( ! $post_type_object) |
|
211 | + wp_die(__('Unknown post type.')); |
|
212 | 212 | |
213 | - if ( ! current_user_can( 'delete_post', $post_id ) ) |
|
214 | - wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); |
|
213 | + if ( ! current_user_can('delete_post', $post_id)) |
|
214 | + wp_die(__('Sorry, you are not allowed to move this item to the Trash.')); |
|
215 | 215 | |
216 | - if ( $user_id = wp_check_post_lock( $post_id ) ) { |
|
217 | - $user = get_userdata( $user_id ); |
|
218 | - wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) ); |
|
216 | + if ($user_id = wp_check_post_lock($post_id)) { |
|
217 | + $user = get_userdata($user_id); |
|
218 | + wp_die(sprintf(__('You cannot move this item to the Trash. %s is currently editing.'), $user->display_name)); |
|
219 | 219 | } |
220 | 220 | |
221 | - if ( ! wp_trash_post( $post_id ) ) |
|
222 | - wp_die( __( 'Error in moving to Trash.' ) ); |
|
221 | + if ( ! wp_trash_post($post_id)) |
|
222 | + wp_die(__('Error in moving to Trash.')); |
|
223 | 223 | |
224 | - wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) ); |
|
224 | + wp_redirect(add_query_arg(array('trashed' => 1, 'ids' => $post_id), $sendback)); |
|
225 | 225 | exit(); |
226 | 226 | |
227 | 227 | case 'untrash': |
228 | - check_admin_referer('untrash-post_' . $post_id); |
|
228 | + check_admin_referer('untrash-post_'.$post_id); |
|
229 | 229 | |
230 | - if ( ! $post ) |
|
231 | - wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) ); |
|
230 | + if ( ! $post) |
|
231 | + wp_die(__('The item you are trying to restore from the Trash no longer exists.')); |
|
232 | 232 | |
233 | - if ( ! $post_type_object ) |
|
234 | - wp_die( __( 'Unknown post type.' ) ); |
|
233 | + if ( ! $post_type_object) |
|
234 | + wp_die(__('Unknown post type.')); |
|
235 | 235 | |
236 | - if ( ! current_user_can( 'delete_post', $post_id ) ) |
|
237 | - wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
|
236 | + if ( ! current_user_can('delete_post', $post_id)) |
|
237 | + wp_die(__('Sorry, you are not allowed to restore this item from the Trash.')); |
|
238 | 238 | |
239 | - if ( ! wp_untrash_post( $post_id ) ) |
|
240 | - wp_die( __( 'Error in restoring from Trash.' ) ); |
|
239 | + if ( ! wp_untrash_post($post_id)) |
|
240 | + wp_die(__('Error in restoring from Trash.')); |
|
241 | 241 | |
242 | - wp_redirect( add_query_arg('untrashed', 1, $sendback) ); |
|
242 | + wp_redirect(add_query_arg('untrashed', 1, $sendback)); |
|
243 | 243 | exit(); |
244 | 244 | |
245 | 245 | case 'delete': |
246 | - check_admin_referer('delete-post_' . $post_id); |
|
246 | + check_admin_referer('delete-post_'.$post_id); |
|
247 | 247 | |
248 | - if ( ! $post ) |
|
249 | - wp_die( __( 'This item has already been deleted.' ) ); |
|
248 | + if ( ! $post) |
|
249 | + wp_die(__('This item has already been deleted.')); |
|
250 | 250 | |
251 | - if ( ! $post_type_object ) |
|
252 | - wp_die( __( 'Unknown post type.' ) ); |
|
251 | + if ( ! $post_type_object) |
|
252 | + wp_die(__('Unknown post type.')); |
|
253 | 253 | |
254 | - if ( ! current_user_can( 'delete_post', $post_id ) ) |
|
255 | - wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); |
|
254 | + if ( ! current_user_can('delete_post', $post_id)) |
|
255 | + wp_die(__('Sorry, you are not allowed to delete this item.')); |
|
256 | 256 | |
257 | - if ( $post->post_type == 'attachment' ) { |
|
258 | - $force = ( ! MEDIA_TRASH ); |
|
259 | - if ( ! wp_delete_attachment( $post_id, $force ) ) |
|
260 | - wp_die( __( 'Error in deleting.' ) ); |
|
257 | + if ($post->post_type == 'attachment') { |
|
258 | + $force = ( ! MEDIA_TRASH); |
|
259 | + if ( ! wp_delete_attachment($post_id, $force)) |
|
260 | + wp_die(__('Error in deleting.')); |
|
261 | 261 | } else { |
262 | - if ( ! wp_delete_post( $post_id, true ) ) |
|
263 | - wp_die( __( 'Error in deleting.' ) ); |
|
262 | + if ( ! wp_delete_post($post_id, true)) |
|
263 | + wp_die(__('Error in deleting.')); |
|
264 | 264 | } |
265 | 265 | |
266 | - wp_redirect( add_query_arg('deleted', 1, $sendback) ); |
|
266 | + wp_redirect(add_query_arg('deleted', 1, $sendback)); |
|
267 | 267 | exit(); |
268 | 268 | |
269 | 269 | case 'preview': |
270 | - check_admin_referer( 'update-post_' . $post_id ); |
|
270 | + check_admin_referer('update-post_'.$post_id); |
|
271 | 271 | |
272 | 272 | $url = post_preview(); |
273 | 273 | |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param int $post_id Post ID sent with the request. |
286 | 286 | */ |
287 | - do_action( "post_action_{$action}", $post_id ); |
|
287 | + do_action("post_action_{$action}", $post_id); |
|
288 | 288 | |
289 | - wp_redirect( admin_url('edit.php') ); |
|
289 | + wp_redirect(admin_url('edit.php')); |
|
290 | 290 | exit(); |
291 | 291 | } // end switch |
292 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
292 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -16,12 +16,13 @@ discard block |
||
16 | 16 | |
17 | 17 | wp_reset_vars( array( 'action' ) ); |
18 | 18 | |
19 | -if ( isset( $_GET['post'] ) ) |
|
19 | +if ( isset( $_GET['post'] ) ) { |
|
20 | 20 | $post_id = $post_ID = (int) $_GET['post']; |
21 | -elseif ( isset( $_POST['post_ID'] ) ) |
|
21 | +} elseif ( isset( $_POST['post_ID'] ) ) { |
|
22 | 22 | $post_id = $post_ID = (int) $_POST['post_ID']; |
23 | -else |
|
23 | +} else { |
|
24 | 24 | $post_id = $post_ID = 0; |
25 | +} |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * @global string $post_type |
@@ -30,18 +31,20 @@ discard block |
||
30 | 31 | */ |
31 | 32 | global $post_type, $post_type_object, $post; |
32 | 33 | |
33 | -if ( $post_id ) |
|
34 | +if ( $post_id ) { |
|
34 | 35 | $post = get_post( $post_id ); |
36 | +} |
|
35 | 37 | |
36 | 38 | if ( $post ) { |
37 | 39 | $post_type = $post->post_type; |
38 | 40 | $post_type_object = get_post_type_object( $post_type ); |
39 | 41 | } |
40 | 42 | |
41 | -if ( isset( $_POST['deletepost'] ) ) |
|
43 | +if ( isset( $_POST['deletepost'] ) ) { |
|
42 | 44 | $action = 'delete'; |
43 | -elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] ) |
|
45 | +} elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] ) { |
|
44 | 46 | $action = 'preview'; |
47 | +} |
|
45 | 48 | |
46 | 49 | $sendback = wp_get_referer(); |
47 | 50 | if ( ! $sendback || |
@@ -68,15 +71,17 @@ discard block |
||
68 | 71 | // For output of the quickdraft dashboard widget |
69 | 72 | require_once ABSPATH . 'wp-admin/includes/dashboard.php'; |
70 | 73 | |
71 | - if ( ! wp_verify_nonce( $nonce, 'add-post' ) ) |
|
72 | - $error_msg = __( 'Unable to submit this form, please refresh and try again.' ); |
|
74 | + if ( ! wp_verify_nonce( $nonce, 'add-post' ) ) { |
|
75 | + $error_msg = __( 'Unable to submit this form, please refresh and try again.' ); |
|
76 | + } |
|
73 | 77 | |
74 | 78 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
75 | 79 | exit; |
76 | 80 | } |
77 | 81 | |
78 | - if ( $error_msg ) |
|
79 | - return wp_dashboard_quick_press( $error_msg ); |
|
82 | + if ( $error_msg ) { |
|
83 | + return wp_dashboard_quick_press( $error_msg ); |
|
84 | + } |
|
80 | 85 | |
81 | 86 | $post = get_post( $_REQUEST['post_ID'] ); |
82 | 87 | check_admin_referer( 'add-' . $post->post_type ); |
@@ -103,21 +108,25 @@ discard block |
||
103 | 108 | exit(); |
104 | 109 | } |
105 | 110 | |
106 | - if ( ! $post ) |
|
107 | - wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
111 | + if ( ! $post ) { |
|
112 | + wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
113 | + } |
|
108 | 114 | |
109 | - if ( ! $post_type_object ) |
|
110 | - wp_die( __( 'Unknown post type.' ) ); |
|
115 | + if ( ! $post_type_object ) { |
|
116 | + wp_die( __( 'Unknown post type.' ) ); |
|
117 | + } |
|
111 | 118 | |
112 | 119 | if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ) ) ) { |
113 | 120 | wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
114 | 121 | } |
115 | 122 | |
116 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
117 | - wp_die( __( 'Sorry, you are not allowed to edit this item.' ) ); |
|
123 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
124 | + wp_die( __( 'Sorry, you are not allowed to edit this item.' ) ); |
|
125 | + } |
|
118 | 126 | |
119 | - if ( 'trash' == $post->post_status ) |
|
120 | - wp_die( __( 'You can’t edit this item because it is in the Trash. Please restore it and try again.' ) ); |
|
127 | + if ( 'trash' == $post->post_status ) { |
|
128 | + wp_die( __( 'You can’t edit this item because it is in the Trash. Please restore it and try again.' ) ); |
|
129 | + } |
|
121 | 130 | |
122 | 131 | if ( ! empty( $_GET['get-post-lock'] ) ) { |
123 | 132 | check_admin_referer( 'lock-post_' . $post_id ); |
@@ -136,10 +145,11 @@ discard block |
||
136 | 145 | $submenu_file = 'upload.php'; |
137 | 146 | $post_new_file = 'media-new.php'; |
138 | 147 | } else { |
139 | - if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) |
|
140 | - $parent_file = $post_type_object->show_in_menu; |
|
141 | - else |
|
142 | - $parent_file = "edit.php?post_type=$post_type"; |
|
148 | + if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) { |
|
149 | + $parent_file = $post_type_object->show_in_menu; |
|
150 | + } else { |
|
151 | + $parent_file = "edit.php?post_type=$post_type"; |
|
152 | + } |
|
143 | 153 | $submenu_file = "edit.php?post_type=$post_type"; |
144 | 154 | $post_new_file = "post-new.php?post_type=$post_type"; |
145 | 155 | } |
@@ -147,8 +157,9 @@ discard block |
||
147 | 157 | if ( ! wp_check_post_lock( $post->ID ) ) { |
148 | 158 | $active_post_lock = wp_set_post_lock( $post->ID ); |
149 | 159 | |
150 | - if ( 'attachment' !== $post_type ) |
|
151 | - wp_enqueue_script('autosave'); |
|
160 | + if ( 'attachment' !== $post_type ) { |
|
161 | + wp_enqueue_script('autosave'); |
|
162 | + } |
|
152 | 163 | } |
153 | 164 | |
154 | 165 | if ( is_multisite() ) { |
@@ -156,8 +167,9 @@ discard block |
||
156 | 167 | } else { |
157 | 168 | $check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) ); |
158 | 169 | |
159 | - if ( count( $check_users ) > 1 ) |
|
160 | - add_action( 'admin_footer', '_admin_notice_post_locked' ); |
|
170 | + if ( count( $check_users ) > 1 ) { |
|
171 | + add_action( 'admin_footer', '_admin_notice_post_locked' ); |
|
172 | + } |
|
161 | 173 | |
162 | 174 | unset( $check_users ); |
163 | 175 | } |
@@ -204,22 +216,26 @@ discard block |
||
204 | 216 | case 'trash': |
205 | 217 | check_admin_referer('trash-post_' . $post_id); |
206 | 218 | |
207 | - if ( ! $post ) |
|
208 | - wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) ); |
|
219 | + if ( ! $post ) { |
|
220 | + wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) ); |
|
221 | + } |
|
209 | 222 | |
210 | - if ( ! $post_type_object ) |
|
211 | - wp_die( __( 'Unknown post type.' ) ); |
|
223 | + if ( ! $post_type_object ) { |
|
224 | + wp_die( __( 'Unknown post type.' ) ); |
|
225 | + } |
|
212 | 226 | |
213 | - if ( ! current_user_can( 'delete_post', $post_id ) ) |
|
214 | - wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); |
|
227 | + if ( ! current_user_can( 'delete_post', $post_id ) ) { |
|
228 | + wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); |
|
229 | + } |
|
215 | 230 | |
216 | 231 | if ( $user_id = wp_check_post_lock( $post_id ) ) { |
217 | 232 | $user = get_userdata( $user_id ); |
218 | 233 | wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) ); |
219 | 234 | } |
220 | 235 | |
221 | - if ( ! wp_trash_post( $post_id ) ) |
|
222 | - wp_die( __( 'Error in moving to Trash.' ) ); |
|
236 | + if ( ! wp_trash_post( $post_id ) ) { |
|
237 | + wp_die( __( 'Error in moving to Trash.' ) ); |
|
238 | + } |
|
223 | 239 | |
224 | 240 | wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) ); |
225 | 241 | exit(); |
@@ -227,17 +243,21 @@ discard block |
||
227 | 243 | case 'untrash': |
228 | 244 | check_admin_referer('untrash-post_' . $post_id); |
229 | 245 | |
230 | - if ( ! $post ) |
|
231 | - wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) ); |
|
246 | + if ( ! $post ) { |
|
247 | + wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) ); |
|
248 | + } |
|
232 | 249 | |
233 | - if ( ! $post_type_object ) |
|
234 | - wp_die( __( 'Unknown post type.' ) ); |
|
250 | + if ( ! $post_type_object ) { |
|
251 | + wp_die( __( 'Unknown post type.' ) ); |
|
252 | + } |
|
235 | 253 | |
236 | - if ( ! current_user_can( 'delete_post', $post_id ) ) |
|
237 | - wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
|
254 | + if ( ! current_user_can( 'delete_post', $post_id ) ) { |
|
255 | + wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
|
256 | + } |
|
238 | 257 | |
239 | - if ( ! wp_untrash_post( $post_id ) ) |
|
240 | - wp_die( __( 'Error in restoring from Trash.' ) ); |
|
258 | + if ( ! wp_untrash_post( $post_id ) ) { |
|
259 | + wp_die( __( 'Error in restoring from Trash.' ) ); |
|
260 | + } |
|
241 | 261 | |
242 | 262 | wp_redirect( add_query_arg('untrashed', 1, $sendback) ); |
243 | 263 | exit(); |
@@ -245,22 +265,27 @@ discard block |
||
245 | 265 | case 'delete': |
246 | 266 | check_admin_referer('delete-post_' . $post_id); |
247 | 267 | |
248 | - if ( ! $post ) |
|
249 | - wp_die( __( 'This item has already been deleted.' ) ); |
|
268 | + if ( ! $post ) { |
|
269 | + wp_die( __( 'This item has already been deleted.' ) ); |
|
270 | + } |
|
250 | 271 | |
251 | - if ( ! $post_type_object ) |
|
252 | - wp_die( __( 'Unknown post type.' ) ); |
|
272 | + if ( ! $post_type_object ) { |
|
273 | + wp_die( __( 'Unknown post type.' ) ); |
|
274 | + } |
|
253 | 275 | |
254 | - if ( ! current_user_can( 'delete_post', $post_id ) ) |
|
255 | - wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); |
|
276 | + if ( ! current_user_can( 'delete_post', $post_id ) ) { |
|
277 | + wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); |
|
278 | + } |
|
256 | 279 | |
257 | 280 | if ( $post->post_type == 'attachment' ) { |
258 | 281 | $force = ( ! MEDIA_TRASH ); |
259 | - if ( ! wp_delete_attachment( $post_id, $force ) ) |
|
260 | - wp_die( __( 'Error in deleting.' ) ); |
|
282 | + if ( ! wp_delete_attachment( $post_id, $force ) ) { |
|
283 | + wp_die( __( 'Error in deleting.' ) ); |
|
284 | + } |
|
261 | 285 | } else { |
262 | - if ( ! wp_delete_post( $post_id, true ) ) |
|
263 | - wp_die( __( 'Error in deleting.' ) ); |
|
286 | + if ( ! wp_delete_post( $post_id, true ) ) { |
|
287 | + wp_die( __( 'Error in deleting.' ) ); |
|
288 | + } |
|
264 | 289 | } |
265 | 290 | |
266 | 291 | wp_redirect( add_query_arg('deleted', 1, $sendback) ); |
@@ -25,20 +25,24 @@ discard block |
||
25 | 25 | $revision_id = absint( $revision ); |
26 | 26 | |
27 | 27 | $from = is_numeric( $from ) ? absint( $from ) : null; |
28 | -if ( ! $revision_id ) |
|
28 | +if ( ! $revision_id ) { |
|
29 | 29 | $revision_id = absint( $to ); |
30 | +} |
|
30 | 31 | $redirect = 'edit.php'; |
31 | 32 | |
32 | 33 | switch ( $action ) { |
33 | 34 | case 'restore' : |
34 | - if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
35 | - break; |
|
35 | + if ( ! $revision = wp_get_post_revision( $revision_id ) ) { |
|
36 | + break; |
|
37 | + } |
|
36 | 38 | |
37 | - if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
38 | - break; |
|
39 | + if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) { |
|
40 | + break; |
|
41 | + } |
|
39 | 42 | |
40 | - if ( ! $post = get_post( $revision->post_parent ) ) |
|
41 | - break; |
|
43 | + if ( ! $post = get_post( $revision->post_parent ) ) { |
|
44 | + break; |
|
45 | + } |
|
42 | 46 | |
43 | 47 | // Revisions disabled (previously checked autosaves && ! wp_is_post_autosave( $revision )) |
44 | 48 | if ( ! wp_revisions_enabled( $post ) ) { |
@@ -47,8 +51,9 @@ discard block |
||
47 | 51 | } |
48 | 52 | |
49 | 53 | // Don't allow revision restore when post is locked |
50 | - if ( wp_check_post_lock( $post->ID ) ) |
|
51 | - break; |
|
54 | + if ( wp_check_post_lock( $post->ID ) ) { |
|
55 | + break; |
|
56 | + } |
|
52 | 57 | |
53 | 58 | check_admin_referer( "restore-post_{$revision->ID}" ); |
54 | 59 | |
@@ -58,13 +63,16 @@ discard block |
||
58 | 63 | case 'view' : |
59 | 64 | case 'edit' : |
60 | 65 | default : |
61 | - if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
62 | - break; |
|
63 | - if ( ! $post = get_post( $revision->post_parent ) ) |
|
64 | - break; |
|
66 | + if ( ! $revision = wp_get_post_revision( $revision_id ) ) { |
|
67 | + break; |
|
68 | + } |
|
69 | + if ( ! $post = get_post( $revision->post_parent ) ) { |
|
70 | + break; |
|
71 | + } |
|
65 | 72 | |
66 | - if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
67 | - break; |
|
73 | + if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'edit_post', $revision->post_parent ) ) { |
|
74 | + break; |
|
75 | + } |
|
68 | 76 | |
69 | 77 | // Revisions disabled and we're not looking at an autosave |
70 | 78 | if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
@@ -83,8 +91,9 @@ discard block |
||
83 | 91 | } |
84 | 92 | |
85 | 93 | // Empty post_type means either malformed object found, or no valid parent was found. |
86 | -if ( ! $redirect && empty( $post->post_type ) ) |
|
94 | +if ( ! $redirect && empty( $post->post_type ) ) { |
|
87 | 95 | $redirect = 'edit.php'; |
96 | +} |
|
88 | 97 | |
89 | 98 | if ( ! empty( $redirect ) ) { |
90 | 99 | wp_redirect( $redirect ); |
@@ -92,10 +101,11 @@ discard block |
||
92 | 101 | } |
93 | 102 | |
94 | 103 | // This is so that the correct "Edit" menu item is selected. |
95 | -if ( ! empty( $post->post_type ) && 'post' != $post->post_type ) |
|
104 | +if ( ! empty( $post->post_type ) && 'post' != $post->post_type ) { |
|
96 | 105 | $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; |
97 | -else |
|
106 | +} else { |
|
98 | 107 | $parent_file = $submenu_file = 'edit.php'; |
108 | +} |
|
99 | 109 | |
100 | 110 | wp_enqueue_script( 'revisions' ); |
101 | 111 | wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $post, $revision_id, $from ) ); |
@@ -30,57 +30,57 @@ |
||
30 | 30 | $redirect = 'edit.php'; |
31 | 31 | |
32 | 32 | switch ( $action ) { |
33 | -case 'restore' : |
|
34 | - if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
35 | - break; |
|
33 | + case 'restore' : |
|
34 | + if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
35 | + break; |
|
36 | 36 | |
37 | - if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
38 | - break; |
|
37 | + if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
38 | + break; |
|
39 | 39 | |
40 | - if ( ! $post = get_post( $revision->post_parent ) ) |
|
41 | - break; |
|
40 | + if ( ! $post = get_post( $revision->post_parent ) ) |
|
41 | + break; |
|
42 | 42 | |
43 | - // Restore if revisions are enabled or this is an autosave. |
|
44 | - if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
|
45 | - $redirect = 'edit.php?post_type=' . $post->post_type; |
|
46 | - break; |
|
47 | - } |
|
43 | + // Restore if revisions are enabled or this is an autosave. |
|
44 | + if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
|
45 | + $redirect = 'edit.php?post_type=' . $post->post_type; |
|
46 | + break; |
|
47 | + } |
|
48 | 48 | |
49 | - // Don't allow revision restore when post is locked |
|
50 | - if ( wp_check_post_lock( $post->ID ) ) |
|
51 | - break; |
|
49 | + // Don't allow revision restore when post is locked |
|
50 | + if ( wp_check_post_lock( $post->ID ) ) |
|
51 | + break; |
|
52 | 52 | |
53 | - check_admin_referer( "restore-post_{$revision->ID}" ); |
|
53 | + check_admin_referer( "restore-post_{$revision->ID}" ); |
|
54 | 54 | |
55 | - wp_restore_post_revision( $revision->ID ); |
|
56 | - $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); |
|
57 | - break; |
|
58 | -case 'view' : |
|
59 | -case 'edit' : |
|
60 | -default : |
|
61 | - if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
55 | + wp_restore_post_revision( $revision->ID ); |
|
56 | + $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); |
|
62 | 57 | break; |
63 | - if ( ! $post = get_post( $revision->post_parent ) ) |
|
58 | + case 'view' : |
|
59 | + case 'edit' : |
|
60 | + default : |
|
61 | + if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
62 | + break; |
|
63 | + if ( ! $post = get_post( $revision->post_parent ) ) |
|
64 | + break; |
|
65 | + |
|
66 | + if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
67 | + break; |
|
68 | + |
|
69 | + // Revisions disabled and we're not looking at an autosave |
|
70 | + if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
|
71 | + $redirect = 'edit.php?post_type=' . $post->post_type; |
|
72 | + break; |
|
73 | + } |
|
74 | + |
|
75 | + $post_edit_link = get_edit_post_link(); |
|
76 | + $post_title = '<a href="' . $post_edit_link . '">' . _draft_or_post_title() . '</a>'; |
|
77 | + /* translators: 1: Post title */ |
|
78 | + $h1 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); |
|
79 | + $return_to_post = '<a href="' . $post_edit_link . '">' . __( '← Return to editor' ) . '</a>'; |
|
80 | + $title = __( 'Revisions' ); |
|
81 | + |
|
82 | + $redirect = false; |
|
64 | 83 | break; |
65 | - |
|
66 | - if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
67 | - break; |
|
68 | - |
|
69 | - // Revisions disabled and we're not looking at an autosave |
|
70 | - if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
|
71 | - $redirect = 'edit.php?post_type=' . $post->post_type; |
|
72 | - break; |
|
73 | - } |
|
74 | - |
|
75 | - $post_edit_link = get_edit_post_link(); |
|
76 | - $post_title = '<a href="' . $post_edit_link . '">' . _draft_or_post_title() . '</a>'; |
|
77 | - /* translators: 1: Post title */ |
|
78 | - $h1 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); |
|
79 | - $return_to_post = '<a href="' . $post_edit_link . '">' . __( '← Return to editor' ) . '</a>'; |
|
80 | - $title = __( 'Revisions' ); |
|
81 | - |
|
82 | - $redirect = false; |
|
83 | - break; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Empty post_type means either malformed object found, or no valid parent was found. |
@@ -16,113 +16,113 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | /** WordPress Administration Bootstrap */ |
19 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
19 | +require_once(dirname(__FILE__).'/admin.php'); |
|
20 | 20 | |
21 | -require ABSPATH . 'wp-admin/includes/revision.php'; |
|
21 | +require ABSPATH.'wp-admin/includes/revision.php'; |
|
22 | 22 | |
23 | -wp_reset_vars( array( 'revision', 'action', 'from', 'to' ) ); |
|
23 | +wp_reset_vars(array('revision', 'action', 'from', 'to')); |
|
24 | 24 | |
25 | -$revision_id = absint( $revision ); |
|
25 | +$revision_id = absint($revision); |
|
26 | 26 | |
27 | -$from = is_numeric( $from ) ? absint( $from ) : null; |
|
28 | -if ( ! $revision_id ) |
|
29 | - $revision_id = absint( $to ); |
|
27 | +$from = is_numeric($from) ? absint($from) : null; |
|
28 | +if ( ! $revision_id) |
|
29 | + $revision_id = absint($to); |
|
30 | 30 | $redirect = 'edit.php'; |
31 | 31 | |
32 | -switch ( $action ) { |
|
32 | +switch ($action) { |
|
33 | 33 | case 'restore' : |
34 | - if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
34 | + if ( ! $revision = wp_get_post_revision($revision_id)) |
|
35 | 35 | break; |
36 | 36 | |
37 | - if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
37 | + if ( ! current_user_can('edit_post', $revision->post_parent)) |
|
38 | 38 | break; |
39 | 39 | |
40 | - if ( ! $post = get_post( $revision->post_parent ) ) |
|
40 | + if ( ! $post = get_post($revision->post_parent)) |
|
41 | 41 | break; |
42 | 42 | |
43 | 43 | // Restore if revisions are enabled or this is an autosave. |
44 | - if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
|
45 | - $redirect = 'edit.php?post_type=' . $post->post_type; |
|
44 | + if ( ! wp_revisions_enabled($post) && ! wp_is_post_autosave($revision)) { |
|
45 | + $redirect = 'edit.php?post_type='.$post->post_type; |
|
46 | 46 | break; |
47 | 47 | } |
48 | 48 | |
49 | 49 | // Don't allow revision restore when post is locked |
50 | - if ( wp_check_post_lock( $post->ID ) ) |
|
50 | + if (wp_check_post_lock($post->ID)) |
|
51 | 51 | break; |
52 | 52 | |
53 | - check_admin_referer( "restore-post_{$revision->ID}" ); |
|
53 | + check_admin_referer("restore-post_{$revision->ID}"); |
|
54 | 54 | |
55 | - wp_restore_post_revision( $revision->ID ); |
|
56 | - $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); |
|
55 | + wp_restore_post_revision($revision->ID); |
|
56 | + $redirect = add_query_arg(array('message' => 5, 'revision' => $revision->ID), get_edit_post_link($post->ID, 'url')); |
|
57 | 57 | break; |
58 | 58 | case 'view' : |
59 | 59 | case 'edit' : |
60 | 60 | default : |
61 | - if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
|
61 | + if ( ! $revision = wp_get_post_revision($revision_id)) |
|
62 | 62 | break; |
63 | - if ( ! $post = get_post( $revision->post_parent ) ) |
|
63 | + if ( ! $post = get_post($revision->post_parent)) |
|
64 | 64 | break; |
65 | 65 | |
66 | - if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'edit_post', $revision->post_parent ) ) |
|
66 | + if ( ! current_user_can('read_post', $revision->ID) || ! current_user_can('edit_post', $revision->post_parent)) |
|
67 | 67 | break; |
68 | 68 | |
69 | 69 | // Revisions disabled and we're not looking at an autosave |
70 | - if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { |
|
71 | - $redirect = 'edit.php?post_type=' . $post->post_type; |
|
70 | + if ( ! wp_revisions_enabled($post) && ! wp_is_post_autosave($revision)) { |
|
71 | + $redirect = 'edit.php?post_type='.$post->post_type; |
|
72 | 72 | break; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $post_edit_link = get_edit_post_link(); |
76 | - $post_title = '<a href="' . $post_edit_link . '">' . _draft_or_post_title() . '</a>'; |
|
76 | + $post_title = '<a href="'.$post_edit_link.'">'._draft_or_post_title().'</a>'; |
|
77 | 77 | /* translators: 1: Post title */ |
78 | - $h1 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); |
|
79 | - $return_to_post = '<a href="' . $post_edit_link . '">' . __( '← Return to editor' ) . '</a>'; |
|
80 | - $title = __( 'Revisions' ); |
|
78 | + $h1 = sprintf(__('Compare Revisions of “%1$s”'), $post_title); |
|
79 | + $return_to_post = '<a href="'.$post_edit_link.'">'.__('← Return to editor').'</a>'; |
|
80 | + $title = __('Revisions'); |
|
81 | 81 | |
82 | 82 | $redirect = false; |
83 | 83 | break; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Empty post_type means either malformed object found, or no valid parent was found. |
87 | -if ( ! $redirect && empty( $post->post_type ) ) |
|
87 | +if ( ! $redirect && empty($post->post_type)) |
|
88 | 88 | $redirect = 'edit.php'; |
89 | 89 | |
90 | -if ( ! empty( $redirect ) ) { |
|
91 | - wp_redirect( $redirect ); |
|
90 | +if ( ! empty($redirect)) { |
|
91 | + wp_redirect($redirect); |
|
92 | 92 | exit; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // This is so that the correct "Edit" menu item is selected. |
96 | -if ( ! empty( $post->post_type ) && 'post' != $post->post_type ) |
|
97 | - $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; |
|
96 | +if ( ! empty($post->post_type) && 'post' != $post->post_type) |
|
97 | + $parent_file = $submenu_file = 'edit.php?post_type='.$post->post_type; |
|
98 | 98 | else |
99 | 99 | $parent_file = $submenu_file = 'edit.php'; |
100 | 100 | |
101 | -wp_enqueue_script( 'revisions' ); |
|
102 | -wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $post, $revision_id, $from ) ); |
|
101 | +wp_enqueue_script('revisions'); |
|
102 | +wp_localize_script('revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js($post, $revision_id, $from)); |
|
103 | 103 | |
104 | 104 | /* Revisions Help Tab */ |
105 | 105 | |
106 | -$revisions_overview = '<p>' . __( 'This screen is used for managing your content revisions.' ) . '</p>'; |
|
107 | -$revisions_overview .= '<p>' . __( 'Revisions are saved copies of your post or page, which are periodically created as you update your content. The red text on the left shows the content that was removed. The green text on the right shows the content that was added.' ) . '</p>'; |
|
108 | -$revisions_overview .= '<p>' . __( 'From this screen you can review, compare, and restore revisions:' ) . '</p>'; |
|
109 | -$revisions_overview .= '<ul><li>' . __( 'To navigate between revisions, <strong>drag the slider handle left or right</strong> or <strong>use the Previous or Next buttons</strong>.' ) . '</li>'; |
|
110 | -$revisions_overview .= '<li>' . __( 'Compare two different revisions by <strong>selecting the “Compare any two revisions” box</strong> to the side.' ) . '</li>'; |
|
111 | -$revisions_overview .= '<li>' . __( 'To restore a revision, <strong>click Restore This Revision</strong>.' ) . '</li></ul>'; |
|
106 | +$revisions_overview = '<p>'.__('This screen is used for managing your content revisions.').'</p>'; |
|
107 | +$revisions_overview .= '<p>'.__('Revisions are saved copies of your post or page, which are periodically created as you update your content. The red text on the left shows the content that was removed. The green text on the right shows the content that was added.').'</p>'; |
|
108 | +$revisions_overview .= '<p>'.__('From this screen you can review, compare, and restore revisions:').'</p>'; |
|
109 | +$revisions_overview .= '<ul><li>'.__('To navigate between revisions, <strong>drag the slider handle left or right</strong> or <strong>use the Previous or Next buttons</strong>.').'</li>'; |
|
110 | +$revisions_overview .= '<li>'.__('Compare two different revisions by <strong>selecting the “Compare any two revisions” box</strong> to the side.').'</li>'; |
|
111 | +$revisions_overview .= '<li>'.__('To restore a revision, <strong>click Restore This Revision</strong>.').'</li></ul>'; |
|
112 | 112 | |
113 | -get_current_screen()->add_help_tab( array( |
|
113 | +get_current_screen()->add_help_tab(array( |
|
114 | 114 | 'id' => 'revisions-overview', |
115 | - 'title' => __( 'Overview' ), |
|
115 | + 'title' => __('Overview'), |
|
116 | 116 | 'content' => $revisions_overview |
117 | -) ); |
|
117 | +)); |
|
118 | 118 | |
119 | -$revisions_sidebar = '<p><strong>' . __( 'For more information:' ) . '</strong></p>'; |
|
120 | -$revisions_sidebar .= '<p>' . __( '<a href="https://codex.wordpress.org/Revision_Management">Revisions Management</a>' ) . '</p>'; |
|
121 | -$revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'; |
|
119 | +$revisions_sidebar = '<p><strong>'.__('For more information:').'</strong></p>'; |
|
120 | +$revisions_sidebar .= '<p>'.__('<a href="https://codex.wordpress.org/Revision_Management">Revisions Management</a>').'</p>'; |
|
121 | +$revisions_sidebar .= '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>'; |
|
122 | 122 | |
123 | -get_current_screen()->set_help_sidebar( $revisions_sidebar ); |
|
123 | +get_current_screen()->set_help_sidebar($revisions_sidebar); |
|
124 | 124 | |
125 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
125 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
126 | 126 | |
127 | 127 | ?> |
128 | 128 | |
@@ -133,4 +133,4 @@ discard block |
||
133 | 133 | <?php |
134 | 134 | wp_print_revision_templates(); |
135 | 135 | |
136 | -require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
136 | +require_once(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -575,7 +575,7 @@ |
||
575 | 575 | $shortlink = wp_get_shortlink($post->ID, 'post'); |
576 | 576 | |
577 | 577 | if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) ) { |
578 | - $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; |
|
578 | + $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // don't load directly |
10 | -if ( !defined('ABSPATH') ) |
|
10 | +if ( ! defined('ABSPATH')) |
|
11 | 11 | die('-1'); |
12 | 12 | |
13 | 13 | /** |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | * @param bool $expand Whether to enable the 'expand' functionality. Default true. |
30 | 30 | * @param string $post_type Post type. |
31 | 31 | */ |
32 | -if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() && |
|
33 | - ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) && |
|
34 | - apply_filters( 'wp_editor_expand', true, $post_type ) ) { |
|
32 | +if (post_type_supports($post_type, 'editor') && ! wp_is_mobile() && |
|
33 | + ! ($is_IE && preg_match('/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'])) && |
|
34 | + apply_filters('wp_editor_expand', true, $post_type)) { |
|
35 | 35 | |
36 | 36 | wp_enqueue_script('editor-expand'); |
37 | 37 | $_content_editor_dfw = true; |
38 | - $_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' ); |
|
38 | + $_wp_editor_expand = (get_user_setting('editor_expand', 'on') === 'on'); |
|
39 | 39 | } |
40 | 40 | |
41 | -if ( wp_is_mobile() ) |
|
42 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
41 | +if (wp_is_mobile()) |
|
42 | + wp_enqueue_script('jquery-touch-punch'); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Post ID global |
@@ -50,33 +50,33 @@ discard block |
||
50 | 50 | $user_ID = isset($user_ID) ? (int) $user_ID : 0; |
51 | 51 | $action = isset($action) ? $action : ''; |
52 | 52 | |
53 | -if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) { |
|
54 | - add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); |
|
55 | - remove_post_type_support( $post_type, 'editor' ); |
|
53 | +if ($post_ID == get_option('page_for_posts') && empty($post->post_content)) { |
|
54 | + add_action('edit_form_after_title', '_wp_posts_page_notice'); |
|
55 | + remove_post_type_support($post_type, 'editor'); |
|
56 | 56 | } |
57 | 57 | |
58 | -$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); |
|
59 | -if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { |
|
60 | - if ( wp_attachment_is( 'audio', $post ) ) { |
|
61 | - $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); |
|
62 | - } elseif ( wp_attachment_is( 'video', $post ) ) { |
|
63 | - $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); |
|
58 | +$thumbnail_support = current_theme_supports('post-thumbnails', $post_type) && post_type_supports($post_type, 'thumbnail'); |
|
59 | +if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type) { |
|
60 | + if (wp_attachment_is('audio', $post)) { |
|
61 | + $thumbnail_support = post_type_supports('attachment:audio', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:audio'); |
|
62 | + } elseif (wp_attachment_is('video', $post)) { |
|
63 | + $thumbnail_support = post_type_supports('attachment:video', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:video'); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | -if ( $thumbnail_support ) { |
|
67 | +if ($thumbnail_support) { |
|
68 | 68 | add_thickbox(); |
69 | - wp_enqueue_media( array( 'post' => $post_ID ) ); |
|
69 | + wp_enqueue_media(array('post' => $post_ID)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Add the local autosave notice HTML |
73 | -add_action( 'admin_footer', '_local_storage_notice' ); |
|
73 | +add_action('admin_footer', '_local_storage_notice'); |
|
74 | 74 | |
75 | 75 | /* |
76 | 76 | * @todo Document the $messages array(s). |
77 | 77 | */ |
78 | -$permalink = get_permalink( $post_ID ); |
|
79 | -if ( ! $permalink ) { |
|
78 | +$permalink = get_permalink($post_ID); |
|
79 | +if ( ! $permalink) { |
|
80 | 80 | $permalink = ''; |
81 | 81 | } |
82 | 82 | |
@@ -85,82 +85,82 @@ discard block |
||
85 | 85 | $preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = ''; |
86 | 86 | $preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = ''; |
87 | 87 | |
88 | -$preview_url = get_preview_post_link( $post ); |
|
88 | +$preview_url = get_preview_post_link($post); |
|
89 | 89 | |
90 | -$viewable = is_post_type_viewable( $post_type_object ); |
|
90 | +$viewable = is_post_type_viewable($post_type_object); |
|
91 | 91 | |
92 | -if ( $viewable ) { |
|
92 | +if ($viewable) { |
|
93 | 93 | |
94 | 94 | // Preview post link. |
95 | - $preview_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', |
|
96 | - esc_url( $preview_url ), |
|
97 | - __( 'Preview post' ) |
|
95 | + $preview_post_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', |
|
96 | + esc_url($preview_url), |
|
97 | + __('Preview post') |
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | // Scheduled post preview link. |
101 | - $scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', |
|
102 | - esc_url( $permalink ), |
|
103 | - __( 'Preview post' ) |
|
101 | + $scheduled_post_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', |
|
102 | + esc_url($permalink), |
|
103 | + __('Preview post') |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | // View post link. |
107 | - $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>', |
|
108 | - esc_url( $permalink ), |
|
109 | - __( 'View post' ) |
|
107 | + $view_post_link_html = sprintf(' <a href="%1$s">%2$s</a>', |
|
108 | + esc_url($permalink), |
|
109 | + __('View post') |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | // Preview page link. |
113 | - $preview_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', |
|
114 | - esc_url( $preview_url ), |
|
115 | - __( 'Preview page' ) |
|
113 | + $preview_page_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', |
|
114 | + esc_url($preview_url), |
|
115 | + __('Preview page') |
|
116 | 116 | ); |
117 | 117 | |
118 | 118 | // Scheduled page preview link. |
119 | - $scheduled_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', |
|
120 | - esc_url( $permalink ), |
|
121 | - __( 'Preview page' ) |
|
119 | + $scheduled_page_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', |
|
120 | + esc_url($permalink), |
|
121 | + __('Preview page') |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | // View page link. |
125 | - $view_page_link_html = sprintf( ' <a href="%1$s">%2$s</a>', |
|
126 | - esc_url( $permalink ), |
|
127 | - __( 'View page' ) |
|
125 | + $view_page_link_html = sprintf(' <a href="%1$s">%2$s</a>', |
|
126 | + esc_url($permalink), |
|
127 | + __('View page') |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | /* translators: Publish box date format, see https://secure.php.net/date */ |
133 | -$scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ); |
|
133 | +$scheduled_date = date_i18n(__('M j, Y @ H:i'), strtotime($post->post_date)); |
|
134 | 134 | |
135 | 135 | $messages['post'] = array( |
136 | 136 | 0 => '', // Unused. Messages start at index 1. |
137 | - 1 => __( 'Post updated.' ) . $view_post_link_html, |
|
138 | - 2 => __( 'Custom field updated.' ), |
|
139 | - 3 => __( 'Custom field deleted.' ), |
|
140 | - 4 => __( 'Post updated.' ), |
|
137 | + 1 => __('Post updated.').$view_post_link_html, |
|
138 | + 2 => __('Custom field updated.'), |
|
139 | + 3 => __('Custom field deleted.'), |
|
140 | + 4 => __('Post updated.'), |
|
141 | 141 | /* translators: %s: date and time of the revision */ |
142 | - 5 => isset($_GET['revision']) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
143 | - 6 => __( 'Post published.' ) . $view_post_link_html, |
|
144 | - 7 => __( 'Post saved.' ), |
|
145 | - 8 => __( 'Post submitted.' ) . $preview_post_link_html, |
|
146 | - 9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html, |
|
147 | - 10 => __( 'Post draft updated.' ) . $preview_post_link_html, |
|
142 | + 5 => isset($_GET['revision']) ? sprintf(__('Post restored to revision from %s.'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
143 | + 6 => __('Post published.').$view_post_link_html, |
|
144 | + 7 => __('Post saved.'), |
|
145 | + 8 => __('Post submitted.').$preview_post_link_html, |
|
146 | + 9 => sprintf(__('Post scheduled for: %s.'), '<strong>'.$scheduled_date.'</strong>').$scheduled_post_link_html, |
|
147 | + 10 => __('Post draft updated.').$preview_post_link_html, |
|
148 | 148 | ); |
149 | 149 | $messages['page'] = array( |
150 | 150 | 0 => '', // Unused. Messages start at index 1. |
151 | - 1 => __( 'Page updated.' ) . $view_page_link_html, |
|
152 | - 2 => __( 'Custom field updated.' ), |
|
153 | - 3 => __( 'Custom field deleted.' ), |
|
154 | - 4 => __( 'Page updated.' ), |
|
151 | + 1 => __('Page updated.').$view_page_link_html, |
|
152 | + 2 => __('Custom field updated.'), |
|
153 | + 3 => __('Custom field deleted.'), |
|
154 | + 4 => __('Page updated.'), |
|
155 | 155 | /* translators: %s: date and time of the revision */ |
156 | - 5 => isset($_GET['revision']) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
157 | - 6 => __( 'Page published.' ) . $view_page_link_html, |
|
158 | - 7 => __( 'Page saved.' ), |
|
159 | - 8 => __( 'Page submitted.' ) . $preview_page_link_html, |
|
160 | - 9 => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html, |
|
161 | - 10 => __( 'Page draft updated.' ) . $preview_page_link_html, |
|
156 | + 5 => isset($_GET['revision']) ? sprintf(__('Page restored to revision from %s.'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
157 | + 6 => __('Page published.').$view_page_link_html, |
|
158 | + 7 => __('Page saved.'), |
|
159 | + 8 => __('Page submitted.').$preview_page_link_html, |
|
160 | + 9 => sprintf(__('Page scheduled for: %s.'), '<strong>'.$scheduled_date.'</strong>').$scheduled_page_link_html, |
|
161 | + 10 => __('Page draft updated.').$preview_page_link_html, |
|
162 | 162 | ); |
163 | -$messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now. |
|
163 | +$messages['attachment'] = array_fill(1, 10, __('Media file updated.')); // Hack, for now. |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Filters the post updated messages. |
@@ -169,110 +169,110 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @param array $messages Post updated messages. For defaults @see $messages declarations above. |
171 | 171 | */ |
172 | -$messages = apply_filters( 'post_updated_messages', $messages ); |
|
172 | +$messages = apply_filters('post_updated_messages', $messages); |
|
173 | 173 | |
174 | 174 | $message = false; |
175 | -if ( isset($_GET['message']) ) { |
|
176 | - $_GET['message'] = absint( $_GET['message'] ); |
|
177 | - if ( isset($messages[$post_type][$_GET['message']]) ) |
|
175 | +if (isset($_GET['message'])) { |
|
176 | + $_GET['message'] = absint($_GET['message']); |
|
177 | + if (isset($messages[$post_type][$_GET['message']])) |
|
178 | 178 | $message = $messages[$post_type][$_GET['message']]; |
179 | - elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) ) |
|
179 | + elseif ( ! isset($messages[$post_type]) && isset($messages['post'][$_GET['message']])) |
|
180 | 180 | $message = $messages['post'][$_GET['message']]; |
181 | 181 | } |
182 | 182 | |
183 | 183 | $notice = false; |
184 | 184 | $form_extra = ''; |
185 | -if ( 'auto-draft' == $post->post_status ) { |
|
186 | - if ( 'edit' == $action ) |
|
185 | +if ('auto-draft' == $post->post_status) { |
|
186 | + if ('edit' == $action) |
|
187 | 187 | $post->post_title = ''; |
188 | 188 | $autosave = false; |
189 | 189 | $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; |
190 | 190 | } else { |
191 | - $autosave = wp_get_post_autosave( $post_ID ); |
|
191 | + $autosave = wp_get_post_autosave($post_ID); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $form_action = 'editpost'; |
195 | -$nonce_action = 'update-post_' . $post_ID; |
|
196 | -$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />"; |
|
195 | +$nonce_action = 'update-post_'.$post_ID; |
|
196 | +$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='".esc_attr($post_ID)."' />"; |
|
197 | 197 | |
198 | 198 | // Detect if there exists an autosave newer than the post and if that autosave is different than the post |
199 | -if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { |
|
200 | - foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { |
|
201 | - if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { |
|
202 | - $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) ); |
|
199 | +if ($autosave && mysql2date('U', $autosave->post_modified_gmt, false) > mysql2date('U', $post->post_modified_gmt, false)) { |
|
200 | + foreach (_wp_post_revision_fields($post) as $autosave_field => $_autosave_field) { |
|
201 | + if (normalize_whitespace($autosave->$autosave_field) != normalize_whitespace($post->$autosave_field)) { |
|
202 | + $notice = sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>'), get_edit_post_link($autosave->ID)); |
|
203 | 203 | break; |
204 | 204 | } |
205 | 205 | } |
206 | 206 | // If this autosave isn't different from the current post, begone. |
207 | - if ( ! $notice ) |
|
208 | - wp_delete_post_revision( $autosave->ID ); |
|
207 | + if ( ! $notice) |
|
208 | + wp_delete_post_revision($autosave->ID); |
|
209 | 209 | unset($autosave_field, $_autosave_field); |
210 | 210 | } |
211 | 211 | |
212 | 212 | $post_type_object = get_post_type_object($post_type); |
213 | 213 | |
214 | 214 | // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). |
215 | -require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); |
|
215 | +require_once(ABSPATH.'wp-admin/includes/meta-boxes.php'); |
|
216 | 216 | |
217 | 217 | |
218 | 218 | $publish_callback_args = null; |
219 | -if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) { |
|
220 | - $revisions = wp_get_post_revisions( $post_ID ); |
|
219 | +if (post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status) { |
|
220 | + $revisions = wp_get_post_revisions($post_ID); |
|
221 | 221 | |
222 | 222 | // We should aim to show the revisions meta box only when there are revisions. |
223 | - if ( count( $revisions ) > 1 ) { |
|
224 | - reset( $revisions ); // Reset pointer for key() |
|
225 | - $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) ); |
|
223 | + if (count($revisions) > 1) { |
|
224 | + reset($revisions); // Reset pointer for key() |
|
225 | + $publish_callback_args = array('revisions_count' => count($revisions), 'revision_id' => key($revisions)); |
|
226 | 226 | add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | -if ( 'attachment' == $post_type ) { |
|
231 | - wp_enqueue_script( 'image-edit' ); |
|
232 | - wp_enqueue_style( 'imgareaselect' ); |
|
233 | - add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' ); |
|
234 | - add_action( 'edit_form_after_title', 'edit_form_image_editor' ); |
|
230 | +if ('attachment' == $post_type) { |
|
231 | + wp_enqueue_script('image-edit'); |
|
232 | + wp_enqueue_style('imgareaselect'); |
|
233 | + add_meta_box('submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core'); |
|
234 | + add_action('edit_form_after_title', 'edit_form_image_editor'); |
|
235 | 235 | |
236 | - if ( wp_attachment_is( 'audio', $post ) ) { |
|
237 | - add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' ); |
|
236 | + if (wp_attachment_is('audio', $post)) { |
|
237 | + add_meta_box('attachment-id3', __('Metadata'), 'attachment_id3_data_meta_box', null, 'normal', 'core'); |
|
238 | 238 | } |
239 | 239 | } else { |
240 | - add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); |
|
240 | + add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args); |
|
241 | 241 | } |
242 | 242 | |
243 | -if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) |
|
244 | - add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' ); |
|
243 | +if (current_theme_supports('post-formats') && post_type_supports($post_type, 'post-formats')) |
|
244 | + add_meta_box('formatdiv', _x('Format', 'post format'), 'post_format_meta_box', null, 'side', 'core'); |
|
245 | 245 | |
246 | 246 | // all taxonomies |
247 | -foreach ( get_object_taxonomies( $post ) as $tax_name ) { |
|
248 | - $taxonomy = get_taxonomy( $tax_name ); |
|
249 | - if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) |
|
247 | +foreach (get_object_taxonomies($post) as $tax_name) { |
|
248 | + $taxonomy = get_taxonomy($tax_name); |
|
249 | + if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb) |
|
250 | 250 | continue; |
251 | 251 | |
252 | 252 | $label = $taxonomy->labels->name; |
253 | 253 | |
254 | - if ( ! is_taxonomy_hierarchical( $tax_name ) ) |
|
255 | - $tax_meta_box_id = 'tagsdiv-' . $tax_name; |
|
254 | + if ( ! is_taxonomy_hierarchical($tax_name)) |
|
255 | + $tax_meta_box_id = 'tagsdiv-'.$tax_name; |
|
256 | 256 | else |
257 | - $tax_meta_box_id = $tax_name . 'div'; |
|
257 | + $tax_meta_box_id = $tax_name.'div'; |
|
258 | 258 | |
259 | - add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) ); |
|
259 | + add_meta_box($tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array('taxonomy' => $tax_name)); |
|
260 | 260 | } |
261 | 261 | |
262 | -if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) { |
|
263 | - add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core' ); |
|
262 | +if (post_type_supports($post_type, 'page-attributes') || count(get_page_templates($post)) > 0) { |
|
263 | + add_meta_box('pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core'); |
|
264 | 264 | } |
265 | 265 | |
266 | -if ( $thumbnail_support && current_user_can( 'upload_files' ) ) |
|
267 | - add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low'); |
|
266 | +if ($thumbnail_support && current_user_can('upload_files')) |
|
267 | + add_meta_box('postimagediv', esc_html($post_type_object->labels->featured_image), 'post_thumbnail_meta_box', null, 'side', 'low'); |
|
268 | 268 | |
269 | -if ( post_type_supports($post_type, 'excerpt') ) |
|
269 | +if (post_type_supports($post_type, 'excerpt')) |
|
270 | 270 | add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core'); |
271 | 271 | |
272 | -if ( post_type_supports($post_type, 'trackbacks') ) |
|
272 | +if (post_type_supports($post_type, 'trackbacks')) |
|
273 | 273 | add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core'); |
274 | 274 | |
275 | -if ( post_type_supports($post_type, 'custom-fields') ) |
|
275 | +if (post_type_supports($post_type, 'custom-fields')) |
|
276 | 276 | add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', null, 'normal', 'core'); |
277 | 277 | |
278 | 278 | /** |
@@ -283,33 +283,33 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @param WP_Post $post Post object. |
285 | 285 | */ |
286 | -do_action( 'dbx_post_advanced', $post ); |
|
286 | +do_action('dbx_post_advanced', $post); |
|
287 | 287 | |
288 | 288 | // Allow the Discussion meta box to show up if the post type supports comments, |
289 | 289 | // or if comments or pings are open. |
290 | -if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { |
|
291 | - add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core' ); |
|
290 | +if (comments_open($post) || pings_open($post) || post_type_supports($post_type, 'comments')) { |
|
291 | + add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core'); |
|
292 | 292 | } |
293 | 293 | |
294 | -$stati = get_post_stati( array( 'public' => true ) ); |
|
295 | -if ( empty( $stati ) ) { |
|
296 | - $stati = array( 'publish' ); |
|
294 | +$stati = get_post_stati(array('public' => true)); |
|
295 | +if (empty($stati)) { |
|
296 | + $stati = array('publish'); |
|
297 | 297 | } |
298 | 298 | $stati[] = 'private'; |
299 | 299 | |
300 | -if ( in_array( get_post_status( $post ), $stati ) ) { |
|
300 | +if (in_array(get_post_status($post), $stati)) { |
|
301 | 301 | // If the post type support comments, or the post has comments, allow the |
302 | 302 | // Comments meta box. |
303 | - if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { |
|
304 | - add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core' ); |
|
303 | + if (comments_open($post) || pings_open($post) || $post->comment_count > 0 || post_type_supports($post_type, 'comments')) { |
|
304 | + add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | -if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) |
|
308 | +if ( ! ('pending' == get_post_status($post) && ! current_user_can($post_type_object->cap->publish_posts))) |
|
309 | 309 | add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); |
310 | 310 | |
311 | -if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
|
312 | - add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core' ); |
|
311 | +if (post_type_supports($post_type, 'author') && current_user_can($post_type_object->cap->edit_others_posts)) { |
|
312 | + add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param string $post_type Post type. |
321 | 321 | * @param WP_Post $post Post object. |
322 | 322 | */ |
323 | -do_action( 'add_meta_boxes', $post_type, $post ); |
|
323 | +do_action('add_meta_boxes', $post_type, $post); |
|
324 | 324 | |
325 | 325 | /** |
326 | 326 | * Fires after all built-in meta boxes have been added, contextually for the given post type. |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @param WP_Post $post Post object. |
333 | 333 | */ |
334 | -do_action( "add_meta_boxes_{$post_type}", $post ); |
|
334 | +do_action("add_meta_boxes_{$post_type}", $post); |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Fires after meta boxes have been added. |
@@ -344,156 +344,156 @@ discard block |
||
344 | 344 | * @param string $context string Meta box context. |
345 | 345 | * @param WP_Post $post Post object. |
346 | 346 | */ |
347 | -do_action( 'do_meta_boxes', $post_type, 'normal', $post ); |
|
347 | +do_action('do_meta_boxes', $post_type, 'normal', $post); |
|
348 | 348 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
349 | -do_action( 'do_meta_boxes', $post_type, 'advanced', $post ); |
|
349 | +do_action('do_meta_boxes', $post_type, 'advanced', $post); |
|
350 | 350 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
351 | -do_action( 'do_meta_boxes', $post_type, 'side', $post ); |
|
351 | +do_action('do_meta_boxes', $post_type, 'side', $post); |
|
352 | 352 | |
353 | -add_screen_option('layout_columns', array('max' => 2, 'default' => 2) ); |
|
353 | +add_screen_option('layout_columns', array('max' => 2, 'default' => 2)); |
|
354 | 354 | |
355 | -if ( 'post' == $post_type ) { |
|
356 | - $customize_display = '<p>' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '</p>'; |
|
355 | +if ('post' == $post_type) { |
|
356 | + $customize_display = '<p>'.__('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.').'</p>'; |
|
357 | 357 | |
358 | - get_current_screen()->add_help_tab( array( |
|
358 | + get_current_screen()->add_help_tab(array( |
|
359 | 359 | 'id' => 'customize-display', |
360 | 360 | 'title' => __('Customizing This Display'), |
361 | 361 | 'content' => $customize_display, |
362 | - ) ); |
|
362 | + )); |
|
363 | 363 | |
364 | - $title_and_editor = '<p>' . __('<strong>Title</strong> — Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.') . '</p>'; |
|
365 | - $title_and_editor .= '<p>' . __( '<strong>Post editor</strong> — Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.' ) . '</p>'; |
|
366 | - $title_and_editor .= '<p>' . __( 'Visual mode gives you an editor that is similar to a word processor. Click the Toolbar Toggle button to get a second row of controls.' ) . '</p>'; |
|
367 | - $title_and_editor .= '<p>' . __( 'The Text mode allows you to enter HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the Text editor to make it less cluttered. When you type, a single line break can be used instead of typing <br>, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.' ) . '</p>'; |
|
368 | - $title_and_editor .= '<p>' . __( 'You can insert media files by clicking the icons above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.' ) . '</p>'; |
|
369 | - $title_and_editor .= '<p>' . __( 'You can enable distraction-free writing mode using the icon to the right. This feature is not available for old browsers or devices with small screens, and requires that the full-height editor be enabled in Screen Options.' ) . '</p>'; |
|
370 | - $title_and_editor .= '<p>' . __( 'Keyboard users: When you’re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>'; |
|
364 | + $title_and_editor = '<p>'.__('<strong>Title</strong> — Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.').'</p>'; |
|
365 | + $title_and_editor .= '<p>'.__('<strong>Post editor</strong> — Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.').'</p>'; |
|
366 | + $title_and_editor .= '<p>'.__('Visual mode gives you an editor that is similar to a word processor. Click the Toolbar Toggle button to get a second row of controls.').'</p>'; |
|
367 | + $title_and_editor .= '<p>'.__('The Text mode allows you to enter HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the Text editor to make it less cluttered. When you type, a single line break can be used instead of typing <br>, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.').'</p>'; |
|
368 | + $title_and_editor .= '<p>'.__('You can insert media files by clicking the icons above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.').'</p>'; |
|
369 | + $title_and_editor .= '<p>'.__('You can enable distraction-free writing mode using the icon to the right. This feature is not available for old browsers or devices with small screens, and requires that the full-height editor be enabled in Screen Options.').'</p>'; |
|
370 | + $title_and_editor .= '<p>'.__('Keyboard users: When you’re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.').'</p>'; |
|
371 | 371 | |
372 | - get_current_screen()->add_help_tab( array( |
|
372 | + get_current_screen()->add_help_tab(array( |
|
373 | 373 | 'id' => 'title-post-editor', |
374 | 374 | 'title' => __('Title and Post Editor'), |
375 | 375 | 'content' => $title_and_editor, |
376 | - ) ); |
|
376 | + )); |
|
377 | 377 | |
378 | 378 | get_current_screen()->set_help_sidebar( |
379 | - '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'tools.php') . '</p>' . |
|
380 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
381 | - '<p>' . __('<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>') . '</p>' . |
|
382 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
379 | + '<p>'.sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'tools.php').'</p>'. |
|
380 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
381 | + '<p>'.__('<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>').'</p>'. |
|
382 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
383 | 383 | ); |
384 | -} elseif ( 'page' == $post_type ) { |
|
385 | - $about_pages = '<p>' . __('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.') . '</p>' . |
|
386 | - '<p>' . __('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.') . '</p>'; |
|
384 | +} elseif ('page' == $post_type) { |
|
385 | + $about_pages = '<p>'.__('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.').'</p>'. |
|
386 | + '<p>'.__('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.').'</p>'; |
|
387 | 387 | |
388 | - get_current_screen()->add_help_tab( array( |
|
388 | + get_current_screen()->add_help_tab(array( |
|
389 | 389 | 'id' => 'about-pages', |
390 | 390 | 'title' => __('About Pages'), |
391 | 391 | 'content' => $about_pages, |
392 | - ) ); |
|
392 | + )); |
|
393 | 393 | |
394 | 394 | get_current_screen()->set_help_sidebar( |
395 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
396 | - '<p>' . __('<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>') . '</p>' . |
|
397 | - '<p>' . __('<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>') . '</p>' . |
|
398 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
395 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
396 | + '<p>'.__('<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>').'</p>'. |
|
397 | + '<p>'.__('<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>').'</p>'. |
|
398 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
399 | 399 | ); |
400 | -} elseif ( 'attachment' == $post_type ) { |
|
401 | - get_current_screen()->add_help_tab( array( |
|
400 | +} elseif ('attachment' == $post_type) { |
|
401 | + get_current_screen()->add_help_tab(array( |
|
402 | 402 | 'id' => 'overview', |
403 | 403 | 'title' => __('Overview'), |
404 | 404 | 'content' => |
405 | - '<p>' . __('This screen allows you to edit four fields for metadata in a file within the media library.') . '</p>' . |
|
406 | - '<p>' . __('For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.') . '</p>' . |
|
407 | - '<p>' . __('Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.') . '</p>' . |
|
408 | - '<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>' |
|
409 | - ) ); |
|
405 | + '<p>'.__('This screen allows you to edit four fields for metadata in a file within the media library.').'</p>'. |
|
406 | + '<p>'.__('For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.').'</p>'. |
|
407 | + '<p>'.__('Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.').'</p>'. |
|
408 | + '<p>'.__('Remember to click Update Media to save metadata entered or changed.').'</p>' |
|
409 | + )); |
|
410 | 410 | |
411 | 411 | get_current_screen()->set_help_sidebar( |
412 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
413 | - '<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>') . '</p>' . |
|
414 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
412 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
413 | + '<p>'.__('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>').'</p>'. |
|
414 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
415 | 415 | ); |
416 | 416 | } |
417 | 417 | |
418 | -if ( 'post' == $post_type || 'page' == $post_type ) { |
|
419 | - $inserting_media = '<p>' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the “Create a new gallery” button.' ) . '</p>'; |
|
420 | - $inserting_media .= '<p>' . __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. Please refer to the Codex to <a href="https://codex.wordpress.org/Embeds">learn more about embeds</a>.' ) . '</p>'; |
|
418 | +if ('post' == $post_type || 'page' == $post_type) { |
|
419 | + $inserting_media = '<p>'.__('You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the “Create a new gallery” button.').'</p>'; |
|
420 | + $inserting_media .= '<p>'.__('You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. Please refer to the Codex to <a href="https://codex.wordpress.org/Embeds">learn more about embeds</a>.').'</p>'; |
|
421 | 421 | |
422 | - get_current_screen()->add_help_tab( array( |
|
422 | + get_current_screen()->add_help_tab(array( |
|
423 | 423 | 'id' => 'inserting-media', |
424 | - 'title' => __( 'Inserting Media' ), |
|
424 | + 'title' => __('Inserting Media'), |
|
425 | 425 | 'content' => $inserting_media, |
426 | - ) ); |
|
426 | + )); |
|
427 | 427 | } |
428 | 428 | |
429 | -if ( 'post' == $post_type ) { |
|
430 | - $publish_box = '<p>' . __('Several boxes on this screen contain settings for how your content will be published, including:') . '</p>'; |
|
431 | - $publish_box .= '<ul><li>' . |
|
432 | - __( '<strong>Publish</strong> — You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.' ) . |
|
429 | +if ('post' == $post_type) { |
|
430 | + $publish_box = '<p>'.__('Several boxes on this screen contain settings for how your content will be published, including:').'</p>'; |
|
431 | + $publish_box .= '<ul><li>'. |
|
432 | + __('<strong>Publish</strong> — You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.'). |
|
433 | 433 | '</li>'; |
434 | 434 | |
435 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) { |
|
436 | - $publish_box .= '<li>' . __( '<strong>Format</strong> — Post Formats designate how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="https://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</li>'; |
|
435 | + if (current_theme_supports('post-formats') && post_type_supports('post', 'post-formats')) { |
|
436 | + $publish_box .= '<li>'.__('<strong>Format</strong> — Post Formats designate how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="https://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.').'</li>'; |
|
437 | 437 | } |
438 | 438 | |
439 | - if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) { |
|
439 | + if (current_theme_supports('post-thumbnails') && post_type_supports('post', 'thumbnail')) { |
|
440 | 440 | /* translators: %s: Featured Image */ |
441 | - $publish_box .= '<li>' . sprintf( __( '<strong>%s</strong> — This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the image as a post thumbnail on the home page, a custom header, etc.' ), esc_html( $post_type_object->labels->featured_image ) ) . '</li>'; |
|
441 | + $publish_box .= '<li>'.sprintf(__('<strong>%s</strong> — This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the image as a post thumbnail on the home page, a custom header, etc.'), esc_html($post_type_object->labels->featured_image)).'</li>'; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | $publish_box .= '</ul>'; |
445 | 445 | |
446 | - get_current_screen()->add_help_tab( array( |
|
446 | + get_current_screen()->add_help_tab(array( |
|
447 | 447 | 'id' => 'publish-box', |
448 | 448 | 'title' => __('Publish Settings'), |
449 | 449 | 'content' => $publish_box, |
450 | - ) ); |
|
450 | + )); |
|
451 | 451 | |
452 | - $discussion_settings = '<p>' . __('<strong>Send Trackbacks</strong> — Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>'; |
|
453 | - $discussion_settings .= '<p>' . __('<strong>Discussion</strong> — You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>'; |
|
452 | + $discussion_settings = '<p>'.__('<strong>Send Trackbacks</strong> — Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.').'</p>'; |
|
453 | + $discussion_settings .= '<p>'.__('<strong>Discussion</strong> — You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.').'</p>'; |
|
454 | 454 | |
455 | - get_current_screen()->add_help_tab( array( |
|
455 | + get_current_screen()->add_help_tab(array( |
|
456 | 456 | 'id' => 'discussion-settings', |
457 | 457 | 'title' => __('Discussion Settings'), |
458 | 458 | 'content' => $discussion_settings, |
459 | - ) ); |
|
460 | -} elseif ( 'page' == $post_type ) { |
|
461 | - $page_attributes = '<p>' . __('<strong>Parent</strong> — You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.') . '</p>' . |
|
462 | - '<p>' . __('<strong>Template</strong> — Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.') . '</p>' . |
|
463 | - '<p>' . __('<strong>Order</strong> — Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '</p>'; |
|
459 | + )); |
|
460 | +} elseif ('page' == $post_type) { |
|
461 | + $page_attributes = '<p>'.__('<strong>Parent</strong> — You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.').'</p>'. |
|
462 | + '<p>'.__('<strong>Template</strong> — Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.').'</p>'. |
|
463 | + '<p>'.__('<strong>Order</strong> — Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.').'</p>'; |
|
464 | 464 | |
465 | - get_current_screen()->add_help_tab( array( |
|
465 | + get_current_screen()->add_help_tab(array( |
|
466 | 466 | 'id' => 'page-attributes', |
467 | 467 | 'title' => __('Page Attributes'), |
468 | 468 | 'content' => $page_attributes, |
469 | - ) ); |
|
469 | + )); |
|
470 | 470 | } |
471 | 471 | |
472 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
472 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
473 | 473 | ?> |
474 | 474 | |
475 | 475 | <div class="wrap"> |
476 | 476 | <h1 class="wp-heading-inline"><?php |
477 | -echo esc_html( $title ); |
|
477 | +echo esc_html($title); |
|
478 | 478 | ?></h1> |
479 | 479 | |
480 | 480 | <?php |
481 | -if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) { |
|
482 | - echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>'; |
|
481 | +if (isset($post_new_file) && current_user_can($post_type_object->cap->create_posts)) { |
|
482 | + echo ' <a href="'.esc_url(admin_url($post_new_file)).'" class="page-title-action">'.esc_html($post_type_object->labels->add_new).'</a>'; |
|
483 | 483 | } |
484 | 484 | ?> |
485 | 485 | |
486 | 486 | <hr class="wp-header-end"> |
487 | 487 | |
488 | -<?php if ( $notice ) : ?> |
|
488 | +<?php if ($notice) : ?> |
|
489 | 489 | <div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice ?></p></div> |
490 | 490 | <?php endif; ?> |
491 | -<?php if ( $message ) : ?> |
|
491 | +<?php if ($message) : ?> |
|
492 | 492 | <div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div> |
493 | 493 | <?php endif; ?> |
494 | 494 | <div id="lost-connection-notice" class="error hidden"> |
495 | - <p><span class="spinner"></span> <?php _e( '<strong>Connection lost.</strong> Saving has been disabled until you’re reconnected.' ); ?> |
|
496 | - <span class="hide-if-no-sessionstorage"><?php _e( 'We’re backing up this post in your browser, just in case.' ); ?></span> |
|
495 | + <p><span class="spinner"></span> <?php _e('<strong>Connection lost.</strong> Saving has been disabled until you’re reconnected.'); ?> |
|
496 | + <span class="hide-if-no-sessionstorage"><?php _e('We’re backing up this post in your browser, just in case.'); ?></span> |
|
497 | 497 | </p> |
498 | 498 | </div> |
499 | 499 | <form name="post" action="post.php" method="post" id="post"<?php |
@@ -504,29 +504,29 @@ discard block |
||
504 | 504 | * |
505 | 505 | * @param WP_Post $post Post object. |
506 | 506 | */ |
507 | -do_action( 'post_edit_form_tag', $post ); |
|
507 | +do_action('post_edit_form_tag', $post); |
|
508 | 508 | |
509 | 509 | $referer = wp_get_referer(); |
510 | 510 | ?>> |
511 | 511 | <?php wp_nonce_field($nonce_action); ?> |
512 | 512 | <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" /> |
513 | -<input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ) ?>" /> |
|
514 | -<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ) ?>" /> |
|
515 | -<input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
|
516 | -<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ) ?>" /> |
|
517 | -<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status) ?>" /> |
|
518 | -<input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" /> |
|
519 | -<?php if ( ! empty( $active_post_lock ) ) { ?> |
|
520 | -<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" /> |
|
513 | +<input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" /> |
|
514 | +<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" /> |
|
515 | +<input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr($post->post_author); ?>" /> |
|
516 | +<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post_type) ?>" /> |
|
517 | +<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" /> |
|
518 | +<input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url($referer) : ''; ?>" /> |
|
519 | +<?php if ( ! empty($active_post_lock)) { ?> |
|
520 | +<input type="hidden" id="active_post_lock" value="<?php echo esc_attr(implode(':', $active_post_lock)); ?>" /> |
|
521 | 521 | <?php |
522 | 522 | } |
523 | -if ( 'draft' != get_post_status( $post ) ) |
|
523 | +if ('draft' != get_post_status($post)) |
|
524 | 524 | wp_original_referer_field(true, 'previous'); |
525 | 525 | |
526 | 526 | echo $form_extra; |
527 | 527 | |
528 | -wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
529 | -wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
528 | +wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
529 | +wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
530 | 530 | ?> |
531 | 531 | |
532 | 532 | <?php |
@@ -539,13 +539,13 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @param WP_Post $post Post object. |
541 | 541 | */ |
542 | -do_action( 'edit_form_top', $post ); ?> |
|
542 | +do_action('edit_form_top', $post); ?> |
|
543 | 543 | |
544 | 544 | <div id="poststuff"> |
545 | 545 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
546 | 546 | <div id="post-body-content"> |
547 | 547 | |
548 | -<?php if ( post_type_supports($post_type, 'title') ) { ?> |
|
548 | +<?php if (post_type_supports($post_type, 'title')) { ?> |
|
549 | 549 | <div id="titlediv"> |
550 | 550 | <div id="titlewrap"> |
551 | 551 | <?php |
@@ -557,10 +557,10 @@ discard block |
||
557 | 557 | * @param string $text Placeholder text. Default 'Enter title here'. |
558 | 558 | * @param WP_Post $post Post object. |
559 | 559 | */ |
560 | - $title_placeholder = apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); |
|
560 | + $title_placeholder = apply_filters('enter_title_here', __('Enter title here'), $post); |
|
561 | 561 | ?> |
562 | 562 | <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label> |
563 | - <input type="text" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" /> |
|
563 | + <input type="text" name="post_title" size="30" value="<?php echo esc_attr($post->post_title); ?>" id="title" spellcheck="true" autocomplete="off" /> |
|
564 | 564 | </div> |
565 | 565 | <?php |
566 | 566 | /** |
@@ -570,28 +570,28 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @param WP_Post $post Post object. |
572 | 572 | */ |
573 | -do_action( 'edit_form_before_permalink', $post ); |
|
573 | +do_action('edit_form_before_permalink', $post); |
|
574 | 574 | ?> |
575 | 575 | <div class="inside"> |
576 | 576 | <?php |
577 | -if ( $viewable ) : |
|
577 | +if ($viewable) : |
|
578 | 578 | $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : ''; |
579 | 579 | |
580 | 580 | // As of 4.4, the Get Shortlink button is hidden by default. |
581 | -if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) { |
|
581 | +if (has_filter('pre_get_shortlink') || has_filter('get_shortlink')) { |
|
582 | 582 | $shortlink = wp_get_shortlink($post->ID, 'post'); |
583 | 583 | |
584 | - if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) ) { |
|
585 | - $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; |
|
584 | + if ( ! empty($shortlink) && $shortlink !== $permalink && $permalink !== home_url('?page_id='.$post->ID)) { |
|
585 | + $sample_permalink_html .= '<input id="shortlink" type="hidden" value="'.esc_attr($shortlink).'" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">'.__('Get Shortlink').'</a>'; |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | -if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { |
|
589 | +if ($post_type_object->public && ! ('pending' == get_post_status($post) && ! current_user_can($post_type_object->cap->publish_posts))) { |
|
590 | 590 | $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status; |
591 | 591 | ?> |
592 | 592 | <div id="edit-slug-box" class="hide-if-no-js"> |
593 | 593 | <?php |
594 | - if ( $has_sample_permalink ) |
|
594 | + if ($has_sample_permalink) |
|
595 | 595 | echo $sample_permalink_html; |
596 | 596 | ?> |
597 | 597 | </div> |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | ?> |
602 | 602 | </div> |
603 | 603 | <?php |
604 | -wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); |
|
604 | +wp_nonce_field('samplepermalink', 'samplepermalinknonce', false); |
|
605 | 605 | ?> |
606 | 606 | </div><!-- /titlediv --> |
607 | 607 | <?php |
@@ -613,13 +613,13 @@ discard block |
||
613 | 613 | * |
614 | 614 | * @param WP_Post $post Post object. |
615 | 615 | */ |
616 | -do_action( 'edit_form_after_title', $post ); |
|
616 | +do_action('edit_form_after_title', $post); |
|
617 | 617 | |
618 | -if ( post_type_supports($post_type, 'editor') ) { |
|
618 | +if (post_type_supports($post_type, 'editor')) { |
|
619 | 619 | ?> |
620 | -<div id="postdivrich" class="postarea<?php if ( $_wp_editor_expand ) { echo ' wp-editor-expand'; } ?>"> |
|
620 | +<div id="postdivrich" class="postarea<?php if ($_wp_editor_expand) { echo ' wp-editor-expand'; } ?>"> |
|
621 | 621 | |
622 | -<?php wp_editor( $post->post_content, 'content', array( |
|
622 | +<?php wp_editor($post->post_content, 'content', array( |
|
623 | 623 | '_content_editor_dfw' => $_content_editor_dfw, |
624 | 624 | 'drag_drop_upload' => true, |
625 | 625 | 'tabfocus_elements' => 'content-html,save-post', |
@@ -629,20 +629,20 @@ discard block |
||
629 | 629 | 'wp_autoresize_on' => $_wp_editor_expand, |
630 | 630 | 'add_unload_trigger' => false, |
631 | 631 | ), |
632 | -) ); ?> |
|
632 | +)); ?> |
|
633 | 633 | <table id="post-status-info"><tbody><tr> |
634 | - <td id="wp-word-count" class="hide-if-no-js"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td> |
|
634 | + <td id="wp-word-count" class="hide-if-no-js"><?php printf(__('Word count: %s'), '<span class="word-count">0</span>'); ?></td> |
|
635 | 635 | <td class="autosave-info"> |
636 | 636 | <span class="autosave-message"> </span> |
637 | 637 | <?php |
638 | - if ( 'auto-draft' != $post->post_status ) { |
|
638 | + if ('auto-draft' != $post->post_status) { |
|
639 | 639 | echo '<span id="last-edit">'; |
640 | - if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) { |
|
640 | + if ($last_user = get_userdata(get_post_meta($post_ID, '_edit_last', true))) { |
|
641 | 641 | /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */ |
642 | - printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) ); |
|
642 | + printf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), mysql2date(__('F j, Y'), $post->post_modified), mysql2date(__('g:i a'), $post->post_modified)); |
|
643 | 643 | } else { |
644 | 644 | /* translators: 1: Post edited date, 2: Post edited time */ |
645 | - printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) ); |
|
645 | + printf(__('Last edited on %1$s at %2$s'), mysql2date(__('F j, Y'), $post->post_modified), mysql2date(__('g:i a'), $post->post_modified)); |
|
646 | 646 | } |
647 | 647 | echo '</span>'; |
648 | 648 | } ?> |
@@ -659,14 +659,14 @@ discard block |
||
659 | 659 | * |
660 | 660 | * @param WP_Post $post Post object. |
661 | 661 | */ |
662 | -do_action( 'edit_form_after_editor', $post ); |
|
662 | +do_action('edit_form_after_editor', $post); |
|
663 | 663 | ?> |
664 | 664 | </div><!-- /post-body-content --> |
665 | 665 | |
666 | 666 | <div id="postbox-container-1" class="postbox-container"> |
667 | 667 | <?php |
668 | 668 | |
669 | -if ( 'page' == $post_type ) { |
|
669 | +if ('page' == $post_type) { |
|
670 | 670 | /** |
671 | 671 | * Fires before meta boxes with 'side' context are output for the 'page' post type. |
672 | 672 | * |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @param WP_Post $post Post object. |
678 | 678 | */ |
679 | - do_action( 'submitpage_box', $post ); |
|
679 | + do_action('submitpage_box', $post); |
|
680 | 680 | } |
681 | 681 | else { |
682 | 682 | /** |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * |
689 | 689 | * @param WP_Post $post Post object. |
690 | 690 | */ |
691 | - do_action( 'submitpost_box', $post ); |
|
691 | + do_action('submitpost_box', $post); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | |
702 | 702 | do_meta_boxes(null, 'normal', $post); |
703 | 703 | |
704 | -if ( 'page' == $post_type ) { |
|
704 | +if ('page' == $post_type) { |
|
705 | 705 | /** |
706 | 706 | * Fires after 'normal' context meta boxes have been output for the 'page' post type. |
707 | 707 | * |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @param WP_Post $post Post object. |
711 | 711 | */ |
712 | - do_action( 'edit_page_form', $post ); |
|
712 | + do_action('edit_page_form', $post); |
|
713 | 713 | } |
714 | 714 | else { |
715 | 715 | /** |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @param WP_Post $post Post object. |
721 | 721 | */ |
722 | - do_action( 'edit_form_advanced', $post ); |
|
722 | + do_action('edit_form_advanced', $post); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @param WP_Post $post Post object. |
737 | 737 | */ |
738 | -do_action( 'dbx_post_sidebar', $post ); |
|
738 | +do_action('dbx_post_sidebar', $post); |
|
739 | 739 | |
740 | 740 | ?> |
741 | 741 | </div><!-- /post-body --> |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | </div> |
746 | 746 | |
747 | 747 | <?php |
748 | -if ( post_type_supports( $post_type, 'comments' ) ) |
|
748 | +if (post_type_supports($post_type, 'comments')) |
|
749 | 749 | wp_comment_reply(); |
750 | 750 | ?> |
751 | 751 | |
752 | -<?php if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?> |
|
752 | +<?php if ( ! wp_is_mobile() && post_type_supports($post_type, 'title') && '' === $post->post_title) : ?> |
|
753 | 753 | <script type="text/javascript"> |
754 | 754 | try{document.post.title.focus();}catch(e){} |
755 | 755 | </script> |
@@ -7,8 +7,9 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // don't load directly |
10 | -if ( !defined('ABSPATH') ) |
|
10 | +if ( !defined('ABSPATH') ) { |
|
11 | 11 | die('-1'); |
12 | +} |
|
12 | 13 | |
13 | 14 | /** |
14 | 15 | * @global string $post_type |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | $_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' ); |
39 | 40 | } |
40 | 41 | |
41 | -if ( wp_is_mobile() ) |
|
42 | +if ( wp_is_mobile() ) { |
|
42 | 43 | wp_enqueue_script( 'jquery-touch-punch' ); |
44 | +} |
|
43 | 45 | |
44 | 46 | /** |
45 | 47 | * Post ID global |
@@ -174,17 +176,19 @@ discard block |
||
174 | 176 | $message = false; |
175 | 177 | if ( isset($_GET['message']) ) { |
176 | 178 | $_GET['message'] = absint( $_GET['message'] ); |
177 | - if ( isset($messages[$post_type][$_GET['message']]) ) |
|
178 | - $message = $messages[$post_type][$_GET['message']]; |
|
179 | - elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) ) |
|
180 | - $message = $messages['post'][$_GET['message']]; |
|
181 | -} |
|
179 | + if ( isset($messages[$post_type][$_GET['message']]) ) { |
|
180 | + $message = $messages[$post_type][$_GET['message']]; |
|
181 | + } elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) ) { |
|
182 | + $message = $messages['post'][$_GET['message']]; |
|
183 | + } |
|
184 | + } |
|
182 | 185 | |
183 | 186 | $notice = false; |
184 | 187 | $form_extra = ''; |
185 | 188 | if ( 'auto-draft' == $post->post_status ) { |
186 | - if ( 'edit' == $action ) |
|
187 | - $post->post_title = ''; |
|
189 | + if ( 'edit' == $action ) { |
|
190 | + $post->post_title = ''; |
|
191 | + } |
|
188 | 192 | $autosave = false; |
189 | 193 | $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; |
190 | 194 | } else { |
@@ -204,8 +208,9 @@ discard block |
||
204 | 208 | } |
205 | 209 | } |
206 | 210 | // If this autosave isn't different from the current post, begone. |
207 | - if ( ! $notice ) |
|
208 | - wp_delete_post_revision( $autosave->ID ); |
|
211 | + if ( ! $notice ) { |
|
212 | + wp_delete_post_revision( $autosave->ID ); |
|
213 | + } |
|
209 | 214 | unset($autosave_field, $_autosave_field); |
210 | 215 | } |
211 | 216 | |
@@ -240,21 +245,24 @@ discard block |
||
240 | 245 | add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); |
241 | 246 | } |
242 | 247 | |
243 | -if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) |
|
248 | +if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) { |
|
244 | 249 | add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' ); |
250 | +} |
|
245 | 251 | |
246 | 252 | // all taxonomies |
247 | 253 | foreach ( get_object_taxonomies( $post ) as $tax_name ) { |
248 | 254 | $taxonomy = get_taxonomy( $tax_name ); |
249 | - if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) |
|
250 | - continue; |
|
255 | + if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) { |
|
256 | + continue; |
|
257 | + } |
|
251 | 258 | |
252 | 259 | $label = $taxonomy->labels->name; |
253 | 260 | |
254 | - if ( ! is_taxonomy_hierarchical( $tax_name ) ) |
|
255 | - $tax_meta_box_id = 'tagsdiv-' . $tax_name; |
|
256 | - else |
|
257 | - $tax_meta_box_id = $tax_name . 'div'; |
|
261 | + if ( ! is_taxonomy_hierarchical( $tax_name ) ) { |
|
262 | + $tax_meta_box_id = 'tagsdiv-' . $tax_name; |
|
263 | + } else { |
|
264 | + $tax_meta_box_id = $tax_name . 'div'; |
|
265 | + } |
|
258 | 266 | |
259 | 267 | add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) ); |
260 | 268 | } |
@@ -263,17 +271,21 @@ discard block |
||
263 | 271 | add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core' ); |
264 | 272 | } |
265 | 273 | |
266 | -if ( $thumbnail_support && current_user_can( 'upload_files' ) ) |
|
274 | +if ( $thumbnail_support && current_user_can( 'upload_files' ) ) { |
|
267 | 275 | add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low'); |
276 | +} |
|
268 | 277 | |
269 | -if ( post_type_supports($post_type, 'excerpt') ) |
|
278 | +if ( post_type_supports($post_type, 'excerpt') ) { |
|
270 | 279 | add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core'); |
280 | +} |
|
271 | 281 | |
272 | -if ( post_type_supports($post_type, 'trackbacks') ) |
|
282 | +if ( post_type_supports($post_type, 'trackbacks') ) { |
|
273 | 283 | add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core'); |
284 | +} |
|
274 | 285 | |
275 | -if ( post_type_supports($post_type, 'custom-fields') ) |
|
286 | +if ( post_type_supports($post_type, 'custom-fields') ) { |
|
276 | 287 | add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', null, 'normal', 'core'); |
288 | +} |
|
277 | 289 | |
278 | 290 | /** |
279 | 291 | * Fires in the middle of built-in meta box registration. |
@@ -305,8 +317,9 @@ discard block |
||
305 | 317 | } |
306 | 318 | } |
307 | 319 | |
308 | -if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) |
|
320 | +if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { |
|
309 | 321 | add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); |
322 | +} |
|
310 | 323 | |
311 | 324 | if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
312 | 325 | add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core' ); |
@@ -520,8 +533,9 @@ discard block |
||
520 | 533 | <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" /> |
521 | 534 | <?php |
522 | 535 | } |
523 | -if ( 'draft' != get_post_status( $post ) ) |
|
536 | +if ( 'draft' != get_post_status( $post ) ) { |
|
524 | 537 | wp_original_referer_field(true, 'previous'); |
538 | +} |
|
525 | 539 | |
526 | 540 | echo $form_extra; |
527 | 541 | |
@@ -591,8 +605,9 @@ discard block |
||
591 | 605 | ?> |
592 | 606 | <div id="edit-slug-box" class="hide-if-no-js"> |
593 | 607 | <?php |
594 | - if ( $has_sample_permalink ) |
|
595 | - echo $sample_permalink_html; |
|
608 | + if ( $has_sample_permalink ) { |
|
609 | + echo $sample_permalink_html; |
|
610 | + } |
|
596 | 611 | ?> |
597 | 612 | </div> |
598 | 613 | <?php |
@@ -677,8 +692,7 @@ discard block |
||
677 | 692 | * @param WP_Post $post Post object. |
678 | 693 | */ |
679 | 694 | do_action( 'submitpage_box', $post ); |
680 | -} |
|
681 | -else { |
|
695 | +} else { |
|
682 | 696 | /** |
683 | 697 | * Fires before meta boxes with 'side' context are output for all post types other than 'page'. |
684 | 698 | * |
@@ -710,8 +724,7 @@ discard block |
||
710 | 724 | * @param WP_Post $post Post object. |
711 | 725 | */ |
712 | 726 | do_action( 'edit_page_form', $post ); |
713 | -} |
|
714 | -else { |
|
727 | +} else { |
|
715 | 728 | /** |
716 | 729 | * Fires after 'normal' context meta boxes have been output for all post types other than 'page'. |
717 | 730 | * |
@@ -745,8 +758,9 @@ discard block |
||
745 | 758 | </div> |
746 | 759 | |
747 | 760 | <?php |
748 | -if ( post_type_supports( $post_type, 'comments' ) ) |
|
761 | +if ( post_type_supports( $post_type, 'comments' ) ) { |
|
749 | 762 | wp_comment_reply(); |
763 | +} |
|
750 | 764 | ?> |
751 | 765 | |
752 | 766 | <?php if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?> |
@@ -43,10 +43,10 @@ |
||
43 | 43 | * Fires before the Site Activation page is loaded. |
44 | 44 | * |
45 | 45 | * Fires on the {@see 'wp_head'} action. |
46 | - * |
|
47 | - * @since 3.0.0 |
|
48 | - */ |
|
49 | - do_action( 'activate_wp_head' ); |
|
46 | + * |
|
47 | + * @since 3.0.0 |
|
48 | + */ |
|
49 | + do_action( 'activate_wp_head' ); |
|
50 | 50 | } |
51 | 51 | add_action( 'wp_head', 'do_activate_header' ); |
52 | 52 |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | die(); |
19 | 19 | } |
20 | 20 | |
21 | -if ( is_object( $wp_object_cache ) ) |
|
21 | +if ( is_object( $wp_object_cache ) ) { |
|
22 | 22 | $wp_object_cache->cache_enabled = false; |
23 | +} |
|
23 | 24 | |
24 | 25 | // Fix for page title |
25 | 26 | $wp_query->is_404 = false; |
@@ -144,10 +145,12 @@ discard block |
||
144 | 145 | /* translators: 1: site URL, 2: login URL */ |
145 | 146 | printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) ); |
146 | 147 | ?></p> |
147 | - <?php else: ?> |
|
148 | + <?php else { |
|
149 | + : ?> |
|
148 | 150 | <p class="view"><?php |
149 | 151 | /* translators: 1: login URL, 2: network home URL */ |
150 | 152 | printf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() ); |
153 | +} |
|
151 | 154 | ?></p> |
152 | 155 | <?php endif; |
153 | 156 | } |
@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | * @package WordPress |
7 | 7 | */ |
8 | 8 | |
9 | -define( 'WP_INSTALLING', true ); |
|
9 | +define('WP_INSTALLING', true); |
|
10 | 10 | |
11 | 11 | /** Sets up the WordPress Environment. */ |
12 | -require( dirname(__FILE__) . '/wp-load.php' ); |
|
12 | +require(dirname(__FILE__).'/wp-load.php'); |
|
13 | 13 | |
14 | -require( dirname( __FILE__ ) . '/wp-blog-header.php' ); |
|
14 | +require(dirname(__FILE__).'/wp-blog-header.php'); |
|
15 | 15 | |
16 | -if ( !is_multisite() ) { |
|
17 | - wp_redirect( wp_registration_url() ); |
|
16 | +if ( ! is_multisite()) { |
|
17 | + wp_redirect(wp_registration_url()); |
|
18 | 18 | die(); |
19 | 19 | } |
20 | 20 | |
21 | -if ( is_object( $wp_object_cache ) ) |
|
21 | +if (is_object($wp_object_cache)) |
|
22 | 22 | $wp_object_cache->cache_enabled = false; |
23 | 23 | |
24 | 24 | // Fix for page title |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 3.0.0 |
31 | 31 | */ |
32 | -do_action( 'activate_header' ); |
|
32 | +do_action('activate_header'); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Adds an action hook specific to this page. |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @since 3.0.0 |
48 | 48 | */ |
49 | - do_action( 'activate_wp_head' ); |
|
49 | + do_action('activate_wp_head'); |
|
50 | 50 | } |
51 | -add_action( 'wp_head', 'do_activate_header' ); |
|
51 | +add_action('wp_head', 'do_activate_header'); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Loads styles specific to this page. |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | </style> |
67 | 67 | <?php |
68 | 68 | } |
69 | -add_action( 'wp_head', 'wpmu_activate_stylesheet' ); |
|
69 | +add_action('wp_head', 'wpmu_activate_stylesheet'); |
|
70 | 70 | |
71 | -get_header( 'wp-activate' ); |
|
71 | +get_header('wp-activate'); |
|
72 | 72 | ?> |
73 | 73 | |
74 | 74 | <div id="signup-content" class="widecolumn"> |
75 | 75 | <div class="wp-activate-container"> |
76 | - <?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?> |
|
76 | + <?php if (empty($_GET['key']) && empty($_POST['key'])) { ?> |
|
77 | 77 | |
78 | 78 | <h2><?php _e('Activation Key Required') ?></h2> |
79 | 79 | <form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>"> |
@@ -88,20 +88,20 @@ discard block |
||
88 | 88 | |
89 | 89 | <?php } else { |
90 | 90 | |
91 | - $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key']; |
|
92 | - $result = wpmu_activate_signup( $key ); |
|
93 | - if ( is_wp_error($result) ) { |
|
94 | - if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) { |
|
91 | + $key = ! empty($_GET['key']) ? $_GET['key'] : $_POST['key']; |
|
92 | + $result = wpmu_activate_signup($key); |
|
93 | + if (is_wp_error($result)) { |
|
94 | + if ('already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code()) { |
|
95 | 95 | $signup = $result->get_error_data(); |
96 | 96 | ?> |
97 | 97 | <h2><?php _e('Your account is now active!'); ?></h2> |
98 | 98 | <?php |
99 | 99 | echo '<p class="lead-in">'; |
100 | - if ( $signup->domain . $signup->path == '' ) { |
|
100 | + if ($signup->domain.$signup->path == '') { |
|
101 | 101 | printf( |
102 | 102 | /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */ |
103 | - __( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ), |
|
104 | - network_site_url( 'wp-login.php', 'login' ), |
|
103 | + __('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), |
|
104 | + network_site_url('wp-login.php', 'login'), |
|
105 | 105 | $signup->user_login, |
106 | 106 | $signup->user_email, |
107 | 107 | wp_lostpassword_url() |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | } else { |
110 | 110 | printf( |
111 | 111 | /* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */ |
112 | - __( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.' ), |
|
113 | - 'http://' . $signup->domain, |
|
112 | + __('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), |
|
113 | + 'http://'.$signup->domain, |
|
114 | 114 | $signup->domain, |
115 | 115 | $signup->user_login, |
116 | 116 | $signup->user_email, |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | echo '</p>'; |
121 | 121 | } else { |
122 | 122 | ?> |
123 | - <h2><?php _e( 'An error occurred during the activation' ); ?></h2> |
|
123 | + <h2><?php _e('An error occurred during the activation'); ?></h2> |
|
124 | 124 | <p><?php echo $result->get_error_message(); ?></p> |
125 | 125 | <?php |
126 | 126 | } |
127 | 127 | } else { |
128 | - $url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : ''; |
|
129 | - $user = get_userdata( (int) $result['user_id'] ); |
|
128 | + $url = isset($result['blog_id']) ? get_home_url((int) $result['blog_id']) : ''; |
|
129 | + $user = get_userdata((int) $result['user_id']); |
|
130 | 130 | ?> |
131 | 131 | <h2><?php _e('Your account is now active!'); ?></h2> |
132 | 132 | |
@@ -135,19 +135,19 @@ discard block |
||
135 | 135 | <p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $result['password']; ?></p> |
136 | 136 | </div> |
137 | 137 | |
138 | - <?php if ( $url && $url != network_home_url( '', 'http' ) ) : |
|
139 | - switch_to_blog( (int) $result['blog_id'] ); |
|
138 | + <?php if ($url && $url != network_home_url('', 'http')) : |
|
139 | + switch_to_blog((int) $result['blog_id']); |
|
140 | 140 | $login_url = wp_login_url(); |
141 | 141 | restore_current_blog(); |
142 | 142 | ?> |
143 | 143 | <p class="view"><?php |
144 | 144 | /* translators: 1: site URL, 2: login URL */ |
145 | - printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) ); |
|
145 | + printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>'), $url, esc_url($login_url)); |
|
146 | 146 | ?></p> |
147 | 147 | <?php else: ?> |
148 | 148 | <p class="view"><?php |
149 | 149 | /* translators: 1: login URL, 2: network home URL */ |
150 | - printf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() ); |
|
150 | + printf(__('Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.'), network_site_url('wp-login.php', 'login'), network_home_url()); |
|
151 | 151 | ?></p> |
152 | 152 | <?php endif; |
153 | 153 | } |
@@ -159,4 +159,4 @@ discard block |
||
159 | 159 | var key_input = document.getElementById('key'); |
160 | 160 | key_input && key_input.focus(); |
161 | 161 | </script> |
162 | -<?php get_footer( 'wp-activate' ); |
|
162 | +<?php get_footer('wp-activate'); |
@@ -125,8 +125,9 @@ discard block |
||
125 | 125 | register_shutdown_function( 'shutdown_action_hook' ); |
126 | 126 | |
127 | 127 | // Stop most of WordPress from being loaded if we just want the basics. |
128 | -if ( SHORTINIT ) |
|
128 | +if ( SHORTINIT ) { |
|
129 | 129 | return false; |
130 | +} |
|
130 | 131 | |
131 | 132 | // Load the L10n library. |
132 | 133 | require_once( ABSPATH . WPINC . '/l10n.php' ); |
@@ -249,8 +250,9 @@ discard block |
||
249 | 250 | */ |
250 | 251 | do_action( 'muplugins_loaded' ); |
251 | 252 | |
252 | -if ( is_multisite() ) |
|
253 | +if ( is_multisite() ) { |
|
253 | 254 | ms_cookie_constants( ); |
255 | +} |
|
254 | 256 | |
255 | 257 | // Define constants after multisite is loaded. |
256 | 258 | wp_cookie_constants(); |
@@ -284,8 +286,9 @@ discard block |
||
284 | 286 | wp_set_internal_encoding(); |
285 | 287 | |
286 | 288 | // Run wp_cache_postload() if object cache is enabled and the function exists. |
287 | -if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) |
|
289 | +if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) { |
|
288 | 290 | wp_cache_postload(); |
291 | +} |
|
289 | 292 | |
290 | 293 | /** |
291 | 294 | * Fires once activated plugins have loaded. |
@@ -367,8 +370,9 @@ discard block |
||
367 | 370 | |
368 | 371 | $locale = get_locale(); |
369 | 372 | $locale_file = WP_LANG_DIR . "/$locale.php"; |
370 | -if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) |
|
373 | +if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) { |
|
371 | 374 | require( $locale_file ); |
375 | +} |
|
372 | 376 | unset( $locale_file ); |
373 | 377 | |
374 | 378 | // Pull in locale data after loading text domain. |
@@ -383,11 +387,13 @@ discard block |
||
383 | 387 | |
384 | 388 | // Load the functions for the active theme, for both parent and child theme if applicable. |
385 | 389 | if ( ! wp_installing() || 'wp-activate.php' === $pagenow ) { |
386 | - if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) ) |
|
387 | - include( STYLESHEETPATH . '/functions.php' ); |
|
388 | - if ( file_exists( TEMPLATEPATH . '/functions.php' ) ) |
|
389 | - include( TEMPLATEPATH . '/functions.php' ); |
|
390 | -} |
|
390 | + if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) ) { |
|
391 | + include( STYLESHEETPATH . '/functions.php' ); |
|
392 | + } |
|
393 | + if ( file_exists( TEMPLATEPATH . '/functions.php' ) ) { |
|
394 | + include( TEMPLATEPATH . '/functions.php' ); |
|
395 | + } |
|
396 | + } |
|
391 | 397 | |
392 | 398 | /** |
393 | 399 | * Fires after the theme is loaded. |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @since 1.0.0 |
15 | 15 | */ |
16 | -define( 'WPINC', 'wp-includes' ); |
|
16 | +define('WPINC', 'wp-includes'); |
|
17 | 17 | |
18 | 18 | // Include files required for initialization. |
19 | -require( ABSPATH . WPINC . '/load.php' ); |
|
20 | -require( ABSPATH . WPINC . '/default-constants.php' ); |
|
21 | -require_once( ABSPATH . WPINC . '/plugin.php' ); |
|
19 | +require(ABSPATH.WPINC.'/load.php'); |
|
20 | +require(ABSPATH.WPINC.'/default-constants.php'); |
|
21 | +require_once(ABSPATH.WPINC.'/plugin.php'); |
|
22 | 22 | |
23 | 23 | /* |
24 | 24 | * These can't be directly globalized in version.php. When updating, |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * these values to be overridden if already set. |
27 | 27 | */ |
28 | 28 | global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package; |
29 | -require( ABSPATH . WPINC . '/version.php' ); |
|
29 | +require(ABSPATH.WPINC.'/version.php'); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * If not already configured, `$blog_id` will default to 1 in a single site |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | wp_check_php_mysql_versions(); |
45 | 45 | |
46 | 46 | // Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php. |
47 | -@ini_set( 'magic_quotes_runtime', 0 ); |
|
48 | -@ini_set( 'magic_quotes_sybase', 0 ); |
|
47 | +@ini_set('magic_quotes_runtime', 0); |
|
48 | +@ini_set('magic_quotes_sybase', 0); |
|
49 | 49 | |
50 | 50 | // WordPress calculates offsets from UTC. |
51 | -date_default_timezone_set( 'UTC' ); |
|
51 | +date_default_timezone_set('UTC'); |
|
52 | 52 | |
53 | 53 | // Turn register_globals off. |
54 | 54 | wp_unregister_GLOBALS(); |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | * @param bool $enable_advanced_cache Whether to enable loading advanced-cache.php (if present). |
80 | 80 | * Default true. |
81 | 81 | */ |
82 | -if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) ) { |
|
82 | +if (WP_CACHE && apply_filters('enable_loading_advanced_cache_dropin', true)) { |
|
83 | 83 | // For an advanced caching plugin to use. Uses a static drop-in because you would only want one. |
84 | - WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' ); |
|
84 | + WP_DEBUG ? include(WP_CONTENT_DIR.'/advanced-cache.php') : @include(WP_CONTENT_DIR.'/advanced-cache.php'); |
|
85 | 85 | |
86 | 86 | // Re-initialize any hooks added manually by advanced-cache.php |
87 | - if ( $wp_filter ) { |
|
88 | - $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
|
87 | + if ($wp_filter) { |
|
88 | + $wp_filter = WP_Hook::build_preinitialized_hooks($wp_filter); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | wp_set_lang_dir(); |
94 | 94 | |
95 | 95 | // Load early WordPress files. |
96 | -require( ABSPATH . WPINC . '/compat.php' ); |
|
97 | -require( ABSPATH . WPINC . '/class-wp-list-util.php' ); |
|
98 | -require( ABSPATH . WPINC . '/functions.php' ); |
|
99 | -require( ABSPATH . WPINC . '/class-wp-matchesmapregex.php' ); |
|
100 | -require( ABSPATH . WPINC . '/class-wp.php' ); |
|
101 | -require( ABSPATH . WPINC . '/class-wp-error.php' ); |
|
102 | -require( ABSPATH . WPINC . '/pomo/mo.php' ); |
|
103 | -require( ABSPATH . WPINC . '/class-phpass.php' ); |
|
96 | +require(ABSPATH.WPINC.'/compat.php'); |
|
97 | +require(ABSPATH.WPINC.'/class-wp-list-util.php'); |
|
98 | +require(ABSPATH.WPINC.'/functions.php'); |
|
99 | +require(ABSPATH.WPINC.'/class-wp-matchesmapregex.php'); |
|
100 | +require(ABSPATH.WPINC.'/class-wp.php'); |
|
101 | +require(ABSPATH.WPINC.'/class-wp-error.php'); |
|
102 | +require(ABSPATH.WPINC.'/pomo/mo.php'); |
|
103 | +require(ABSPATH.WPINC.'/class-phpass.php'); |
|
104 | 104 | |
105 | 105 | // Include the wpdb class and, if present, a db.php database drop-in. |
106 | 106 | global $wpdb; |
@@ -114,140 +114,140 @@ discard block |
||
114 | 114 | wp_start_object_cache(); |
115 | 115 | |
116 | 116 | // Attach the default filters. |
117 | -require( ABSPATH . WPINC . '/default-filters.php' ); |
|
117 | +require(ABSPATH.WPINC.'/default-filters.php'); |
|
118 | 118 | |
119 | 119 | // Initialize multisite if enabled. |
120 | -if ( is_multisite() ) { |
|
121 | - require( ABSPATH . WPINC . '/class-wp-site-query.php' ); |
|
122 | - require( ABSPATH . WPINC . '/class-wp-network-query.php' ); |
|
123 | - require( ABSPATH . WPINC . '/ms-blogs.php' ); |
|
124 | - require( ABSPATH . WPINC . '/ms-settings.php' ); |
|
125 | -} elseif ( ! defined( 'MULTISITE' ) ) { |
|
126 | - define( 'MULTISITE', false ); |
|
120 | +if (is_multisite()) { |
|
121 | + require(ABSPATH.WPINC.'/class-wp-site-query.php'); |
|
122 | + require(ABSPATH.WPINC.'/class-wp-network-query.php'); |
|
123 | + require(ABSPATH.WPINC.'/ms-blogs.php'); |
|
124 | + require(ABSPATH.WPINC.'/ms-settings.php'); |
|
125 | +} elseif ( ! defined('MULTISITE')) { |
|
126 | + define('MULTISITE', false); |
|
127 | 127 | } |
128 | 128 | |
129 | -register_shutdown_function( 'shutdown_action_hook' ); |
|
129 | +register_shutdown_function('shutdown_action_hook'); |
|
130 | 130 | |
131 | 131 | // Stop most of WordPress from being loaded if we just want the basics. |
132 | -if ( SHORTINIT ) |
|
132 | +if (SHORTINIT) |
|
133 | 133 | return false; |
134 | 134 | |
135 | 135 | // Load the L10n library. |
136 | -require_once( ABSPATH . WPINC . '/l10n.php' ); |
|
137 | -require_once( ABSPATH . WPINC . '/class-wp-locale.php' ); |
|
138 | -require_once( ABSPATH . WPINC . '/class-wp-locale-switcher.php' ); |
|
136 | +require_once(ABSPATH.WPINC.'/l10n.php'); |
|
137 | +require_once(ABSPATH.WPINC.'/class-wp-locale.php'); |
|
138 | +require_once(ABSPATH.WPINC.'/class-wp-locale-switcher.php'); |
|
139 | 139 | |
140 | 140 | // Run the installer if WordPress is not installed. |
141 | 141 | wp_not_installed(); |
142 | 142 | |
143 | 143 | // Load most of WordPress. |
144 | -require( ABSPATH . WPINC . '/class-wp-walker.php' ); |
|
145 | -require( ABSPATH . WPINC . '/class-wp-ajax-response.php' ); |
|
146 | -require( ABSPATH . WPINC . '/formatting.php' ); |
|
147 | -require( ABSPATH . WPINC . '/capabilities.php' ); |
|
148 | -require( ABSPATH . WPINC . '/class-wp-roles.php' ); |
|
149 | -require( ABSPATH . WPINC . '/class-wp-role.php' ); |
|
150 | -require( ABSPATH . WPINC . '/class-wp-user.php' ); |
|
151 | -require( ABSPATH . WPINC . '/class-wp-query.php' ); |
|
152 | -require( ABSPATH . WPINC . '/query.php' ); |
|
153 | -require( ABSPATH . WPINC . '/date.php' ); |
|
154 | -require( ABSPATH . WPINC . '/theme.php' ); |
|
155 | -require( ABSPATH . WPINC . '/class-wp-theme.php' ); |
|
156 | -require( ABSPATH . WPINC . '/template.php' ); |
|
157 | -require( ABSPATH . WPINC . '/user.php' ); |
|
158 | -require( ABSPATH . WPINC . '/class-wp-user-query.php' ); |
|
159 | -require( ABSPATH . WPINC . '/class-wp-session-tokens.php' ); |
|
160 | -require( ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php' ); |
|
161 | -require( ABSPATH . WPINC . '/meta.php' ); |
|
162 | -require( ABSPATH . WPINC . '/class-wp-meta-query.php' ); |
|
163 | -require( ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php' ); |
|
164 | -require( ABSPATH . WPINC . '/general-template.php' ); |
|
165 | -require( ABSPATH . WPINC . '/link-template.php' ); |
|
166 | -require( ABSPATH . WPINC . '/author-template.php' ); |
|
167 | -require( ABSPATH . WPINC . '/post.php' ); |
|
168 | -require( ABSPATH . WPINC . '/class-walker-page.php' ); |
|
169 | -require( ABSPATH . WPINC . '/class-walker-page-dropdown.php' ); |
|
170 | -require( ABSPATH . WPINC . '/class-wp-post-type.php' ); |
|
171 | -require( ABSPATH . WPINC . '/class-wp-post.php' ); |
|
172 | -require( ABSPATH . WPINC . '/post-template.php' ); |
|
173 | -require( ABSPATH . WPINC . '/revision.php' ); |
|
174 | -require( ABSPATH . WPINC . '/post-formats.php' ); |
|
175 | -require( ABSPATH . WPINC . '/post-thumbnail-template.php' ); |
|
176 | -require( ABSPATH . WPINC . '/category.php' ); |
|
177 | -require( ABSPATH . WPINC . '/class-walker-category.php' ); |
|
178 | -require( ABSPATH . WPINC . '/class-walker-category-dropdown.php' ); |
|
179 | -require( ABSPATH . WPINC . '/category-template.php' ); |
|
180 | -require( ABSPATH . WPINC . '/comment.php' ); |
|
181 | -require( ABSPATH . WPINC . '/class-wp-comment.php' ); |
|
182 | -require( ABSPATH . WPINC . '/class-wp-comment-query.php' ); |
|
183 | -require( ABSPATH . WPINC . '/class-walker-comment.php' ); |
|
184 | -require( ABSPATH . WPINC . '/comment-template.php' ); |
|
185 | -require( ABSPATH . WPINC . '/rewrite.php' ); |
|
186 | -require( ABSPATH . WPINC . '/class-wp-rewrite.php' ); |
|
187 | -require( ABSPATH . WPINC . '/feed.php' ); |
|
188 | -require( ABSPATH . WPINC . '/bookmark.php' ); |
|
189 | -require( ABSPATH . WPINC . '/bookmark-template.php' ); |
|
190 | -require( ABSPATH . WPINC . '/kses.php' ); |
|
191 | -require( ABSPATH . WPINC . '/cron.php' ); |
|
192 | -require( ABSPATH . WPINC . '/deprecated.php' ); |
|
193 | -require( ABSPATH . WPINC . '/script-loader.php' ); |
|
194 | -require( ABSPATH . WPINC . '/taxonomy.php' ); |
|
195 | -require( ABSPATH . WPINC . '/class-wp-taxonomy.php' ); |
|
196 | -require( ABSPATH . WPINC . '/class-wp-term.php' ); |
|
197 | -require( ABSPATH . WPINC . '/class-wp-term-query.php' ); |
|
198 | -require( ABSPATH . WPINC . '/class-wp-tax-query.php' ); |
|
199 | -require( ABSPATH . WPINC . '/update.php' ); |
|
200 | -require( ABSPATH . WPINC . '/canonical.php' ); |
|
201 | -require( ABSPATH . WPINC . '/shortcodes.php' ); |
|
202 | -require( ABSPATH . WPINC . '/embed.php' ); |
|
203 | -require( ABSPATH . WPINC . '/class-wp-embed.php' ); |
|
204 | -require( ABSPATH . WPINC . '/class-oembed.php' ); |
|
205 | -require( ABSPATH . WPINC . '/class-wp-oembed-controller.php' ); |
|
206 | -require( ABSPATH . WPINC . '/media.php' ); |
|
207 | -require( ABSPATH . WPINC . '/http.php' ); |
|
208 | -require( ABSPATH . WPINC . '/class-http.php' ); |
|
209 | -require( ABSPATH . WPINC . '/class-wp-http-streams.php' ); |
|
210 | -require( ABSPATH . WPINC . '/class-wp-http-curl.php' ); |
|
211 | -require( ABSPATH . WPINC . '/class-wp-http-proxy.php' ); |
|
212 | -require( ABSPATH . WPINC . '/class-wp-http-cookie.php' ); |
|
213 | -require( ABSPATH . WPINC . '/class-wp-http-encoding.php' ); |
|
214 | -require( ABSPATH . WPINC . '/class-wp-http-response.php' ); |
|
215 | -require( ABSPATH . WPINC . '/class-wp-http-requests-response.php' ); |
|
216 | -require( ABSPATH . WPINC . '/class-wp-http-requests-hooks.php' ); |
|
217 | -require( ABSPATH . WPINC . '/widgets.php' ); |
|
218 | -require( ABSPATH . WPINC . '/class-wp-widget.php' ); |
|
219 | -require( ABSPATH . WPINC . '/class-wp-widget-factory.php' ); |
|
220 | -require( ABSPATH . WPINC . '/nav-menu.php' ); |
|
221 | -require( ABSPATH . WPINC . '/nav-menu-template.php' ); |
|
222 | -require( ABSPATH . WPINC . '/admin-bar.php' ); |
|
223 | -require( ABSPATH . WPINC . '/rest-api.php' ); |
|
224 | -require( ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php' ); |
|
225 | -require( ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php' ); |
|
226 | -require( ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php' ); |
|
227 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-controller.php' ); |
|
228 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-posts-controller.php' ); |
|
229 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php' ); |
|
230 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php' ); |
|
231 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php' ); |
|
232 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php' ); |
|
233 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-taxonomies-controller.php' ); |
|
234 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.php' ); |
|
235 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-users-controller.php' ); |
|
236 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php' ); |
|
237 | -require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php' ); |
|
238 | -require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php' ); |
|
239 | -require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php' ); |
|
240 | -require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-post-meta-fields.php' ); |
|
241 | -require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-term-meta-fields.php' ); |
|
242 | -require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-user-meta-fields.php' ); |
|
144 | +require(ABSPATH.WPINC.'/class-wp-walker.php'); |
|
145 | +require(ABSPATH.WPINC.'/class-wp-ajax-response.php'); |
|
146 | +require(ABSPATH.WPINC.'/formatting.php'); |
|
147 | +require(ABSPATH.WPINC.'/capabilities.php'); |
|
148 | +require(ABSPATH.WPINC.'/class-wp-roles.php'); |
|
149 | +require(ABSPATH.WPINC.'/class-wp-role.php'); |
|
150 | +require(ABSPATH.WPINC.'/class-wp-user.php'); |
|
151 | +require(ABSPATH.WPINC.'/class-wp-query.php'); |
|
152 | +require(ABSPATH.WPINC.'/query.php'); |
|
153 | +require(ABSPATH.WPINC.'/date.php'); |
|
154 | +require(ABSPATH.WPINC.'/theme.php'); |
|
155 | +require(ABSPATH.WPINC.'/class-wp-theme.php'); |
|
156 | +require(ABSPATH.WPINC.'/template.php'); |
|
157 | +require(ABSPATH.WPINC.'/user.php'); |
|
158 | +require(ABSPATH.WPINC.'/class-wp-user-query.php'); |
|
159 | +require(ABSPATH.WPINC.'/class-wp-session-tokens.php'); |
|
160 | +require(ABSPATH.WPINC.'/class-wp-user-meta-session-tokens.php'); |
|
161 | +require(ABSPATH.WPINC.'/meta.php'); |
|
162 | +require(ABSPATH.WPINC.'/class-wp-meta-query.php'); |
|
163 | +require(ABSPATH.WPINC.'/class-wp-metadata-lazyloader.php'); |
|
164 | +require(ABSPATH.WPINC.'/general-template.php'); |
|
165 | +require(ABSPATH.WPINC.'/link-template.php'); |
|
166 | +require(ABSPATH.WPINC.'/author-template.php'); |
|
167 | +require(ABSPATH.WPINC.'/post.php'); |
|
168 | +require(ABSPATH.WPINC.'/class-walker-page.php'); |
|
169 | +require(ABSPATH.WPINC.'/class-walker-page-dropdown.php'); |
|
170 | +require(ABSPATH.WPINC.'/class-wp-post-type.php'); |
|
171 | +require(ABSPATH.WPINC.'/class-wp-post.php'); |
|
172 | +require(ABSPATH.WPINC.'/post-template.php'); |
|
173 | +require(ABSPATH.WPINC.'/revision.php'); |
|
174 | +require(ABSPATH.WPINC.'/post-formats.php'); |
|
175 | +require(ABSPATH.WPINC.'/post-thumbnail-template.php'); |
|
176 | +require(ABSPATH.WPINC.'/category.php'); |
|
177 | +require(ABSPATH.WPINC.'/class-walker-category.php'); |
|
178 | +require(ABSPATH.WPINC.'/class-walker-category-dropdown.php'); |
|
179 | +require(ABSPATH.WPINC.'/category-template.php'); |
|
180 | +require(ABSPATH.WPINC.'/comment.php'); |
|
181 | +require(ABSPATH.WPINC.'/class-wp-comment.php'); |
|
182 | +require(ABSPATH.WPINC.'/class-wp-comment-query.php'); |
|
183 | +require(ABSPATH.WPINC.'/class-walker-comment.php'); |
|
184 | +require(ABSPATH.WPINC.'/comment-template.php'); |
|
185 | +require(ABSPATH.WPINC.'/rewrite.php'); |
|
186 | +require(ABSPATH.WPINC.'/class-wp-rewrite.php'); |
|
187 | +require(ABSPATH.WPINC.'/feed.php'); |
|
188 | +require(ABSPATH.WPINC.'/bookmark.php'); |
|
189 | +require(ABSPATH.WPINC.'/bookmark-template.php'); |
|
190 | +require(ABSPATH.WPINC.'/kses.php'); |
|
191 | +require(ABSPATH.WPINC.'/cron.php'); |
|
192 | +require(ABSPATH.WPINC.'/deprecated.php'); |
|
193 | +require(ABSPATH.WPINC.'/script-loader.php'); |
|
194 | +require(ABSPATH.WPINC.'/taxonomy.php'); |
|
195 | +require(ABSPATH.WPINC.'/class-wp-taxonomy.php'); |
|
196 | +require(ABSPATH.WPINC.'/class-wp-term.php'); |
|
197 | +require(ABSPATH.WPINC.'/class-wp-term-query.php'); |
|
198 | +require(ABSPATH.WPINC.'/class-wp-tax-query.php'); |
|
199 | +require(ABSPATH.WPINC.'/update.php'); |
|
200 | +require(ABSPATH.WPINC.'/canonical.php'); |
|
201 | +require(ABSPATH.WPINC.'/shortcodes.php'); |
|
202 | +require(ABSPATH.WPINC.'/embed.php'); |
|
203 | +require(ABSPATH.WPINC.'/class-wp-embed.php'); |
|
204 | +require(ABSPATH.WPINC.'/class-oembed.php'); |
|
205 | +require(ABSPATH.WPINC.'/class-wp-oembed-controller.php'); |
|
206 | +require(ABSPATH.WPINC.'/media.php'); |
|
207 | +require(ABSPATH.WPINC.'/http.php'); |
|
208 | +require(ABSPATH.WPINC.'/class-http.php'); |
|
209 | +require(ABSPATH.WPINC.'/class-wp-http-streams.php'); |
|
210 | +require(ABSPATH.WPINC.'/class-wp-http-curl.php'); |
|
211 | +require(ABSPATH.WPINC.'/class-wp-http-proxy.php'); |
|
212 | +require(ABSPATH.WPINC.'/class-wp-http-cookie.php'); |
|
213 | +require(ABSPATH.WPINC.'/class-wp-http-encoding.php'); |
|
214 | +require(ABSPATH.WPINC.'/class-wp-http-response.php'); |
|
215 | +require(ABSPATH.WPINC.'/class-wp-http-requests-response.php'); |
|
216 | +require(ABSPATH.WPINC.'/class-wp-http-requests-hooks.php'); |
|
217 | +require(ABSPATH.WPINC.'/widgets.php'); |
|
218 | +require(ABSPATH.WPINC.'/class-wp-widget.php'); |
|
219 | +require(ABSPATH.WPINC.'/class-wp-widget-factory.php'); |
|
220 | +require(ABSPATH.WPINC.'/nav-menu.php'); |
|
221 | +require(ABSPATH.WPINC.'/nav-menu-template.php'); |
|
222 | +require(ABSPATH.WPINC.'/admin-bar.php'); |
|
223 | +require(ABSPATH.WPINC.'/rest-api.php'); |
|
224 | +require(ABSPATH.WPINC.'/rest-api/class-wp-rest-server.php'); |
|
225 | +require(ABSPATH.WPINC.'/rest-api/class-wp-rest-response.php'); |
|
226 | +require(ABSPATH.WPINC.'/rest-api/class-wp-rest-request.php'); |
|
227 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-controller.php'); |
|
228 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-posts-controller.php'); |
|
229 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-attachments-controller.php'); |
|
230 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-post-types-controller.php'); |
|
231 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-post-statuses-controller.php'); |
|
232 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-revisions-controller.php'); |
|
233 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-taxonomies-controller.php'); |
|
234 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-terms-controller.php'); |
|
235 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-users-controller.php'); |
|
236 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-comments-controller.php'); |
|
237 | +require(ABSPATH.WPINC.'/rest-api/endpoints/class-wp-rest-settings-controller.php'); |
|
238 | +require(ABSPATH.WPINC.'/rest-api/fields/class-wp-rest-meta-fields.php'); |
|
239 | +require(ABSPATH.WPINC.'/rest-api/fields/class-wp-rest-comment-meta-fields.php'); |
|
240 | +require(ABSPATH.WPINC.'/rest-api/fields/class-wp-rest-post-meta-fields.php'); |
|
241 | +require(ABSPATH.WPINC.'/rest-api/fields/class-wp-rest-term-meta-fields.php'); |
|
242 | +require(ABSPATH.WPINC.'/rest-api/fields/class-wp-rest-user-meta-fields.php'); |
|
243 | 243 | |
244 | 244 | $GLOBALS['wp_embed'] = new WP_Embed(); |
245 | 245 | |
246 | 246 | // Load multisite-specific files. |
247 | -if ( is_multisite() ) { |
|
248 | - require( ABSPATH . WPINC . '/ms-functions.php' ); |
|
249 | - require( ABSPATH . WPINC . '/ms-default-filters.php' ); |
|
250 | - require( ABSPATH . WPINC . '/ms-deprecated.php' ); |
|
247 | +if (is_multisite()) { |
|
248 | + require(ABSPATH.WPINC.'/ms-functions.php'); |
|
249 | + require(ABSPATH.WPINC.'/ms-default-filters.php'); |
|
250 | + require(ABSPATH.WPINC.'/ms-deprecated.php'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | // Define constants that rely on the API to obtain the default value. |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | $GLOBALS['wp_plugin_paths'] = array(); |
258 | 258 | |
259 | 259 | // Load must-use plugins. |
260 | -foreach ( wp_get_mu_plugins() as $mu_plugin ) { |
|
261 | - include_once( $mu_plugin ); |
|
260 | +foreach (wp_get_mu_plugins() as $mu_plugin) { |
|
261 | + include_once($mu_plugin); |
|
262 | 262 | } |
263 | -unset( $mu_plugin ); |
|
263 | +unset($mu_plugin); |
|
264 | 264 | |
265 | 265 | // Load network activated plugins. |
266 | -if ( is_multisite() ) { |
|
267 | - foreach ( wp_get_active_network_plugins() as $network_plugin ) { |
|
268 | - wp_register_plugin_realpath( $network_plugin ); |
|
269 | - include_once( $network_plugin ); |
|
266 | +if (is_multisite()) { |
|
267 | + foreach (wp_get_active_network_plugins() as $network_plugin) { |
|
268 | + wp_register_plugin_realpath($network_plugin); |
|
269 | + include_once($network_plugin); |
|
270 | 270 | } |
271 | - unset( $network_plugin ); |
|
271 | + unset($network_plugin); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @since 2.8.0 |
278 | 278 | */ |
279 | -do_action( 'muplugins_loaded' ); |
|
279 | +do_action('muplugins_loaded'); |
|
280 | 280 | |
281 | -if ( is_multisite() ) |
|
281 | +if (is_multisite()) |
|
282 | 282 | ms_cookie_constants( ); |
283 | 283 | |
284 | 284 | // Define constants after multisite is loaded. |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | wp_ssl_constants(); |
289 | 289 | |
290 | 290 | // Create common globals. |
291 | -require( ABSPATH . WPINC . '/vars.php' ); |
|
291 | +require(ABSPATH.WPINC.'/vars.php'); |
|
292 | 292 | |
293 | 293 | // Make taxonomies and posts available to plugins and themes. |
294 | 294 | // @plugin authors: warning: these get registered again on the init hook. |
@@ -296,24 +296,24 @@ discard block |
||
296 | 296 | create_initial_post_types(); |
297 | 297 | |
298 | 298 | // Register the default theme directory root |
299 | -register_theme_directory( get_theme_root() ); |
|
299 | +register_theme_directory(get_theme_root()); |
|
300 | 300 | |
301 | 301 | // Load active plugins. |
302 | -foreach ( wp_get_active_and_valid_plugins() as $plugin ) { |
|
303 | - wp_register_plugin_realpath( $plugin ); |
|
304 | - include_once( $plugin ); |
|
302 | +foreach (wp_get_active_and_valid_plugins() as $plugin) { |
|
303 | + wp_register_plugin_realpath($plugin); |
|
304 | + include_once($plugin); |
|
305 | 305 | } |
306 | -unset( $plugin ); |
|
306 | +unset($plugin); |
|
307 | 307 | |
308 | 308 | // Load pluggable functions. |
309 | -require( ABSPATH . WPINC . '/pluggable.php' ); |
|
310 | -require( ABSPATH . WPINC . '/pluggable-deprecated.php' ); |
|
309 | +require(ABSPATH.WPINC.'/pluggable.php'); |
|
310 | +require(ABSPATH.WPINC.'/pluggable-deprecated.php'); |
|
311 | 311 | |
312 | 312 | // Set internal encoding. |
313 | 313 | wp_set_internal_encoding(); |
314 | 314 | |
315 | 315 | // Run wp_cache_postload() if object cache is enabled and the function exists. |
316 | -if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) |
|
316 | +if (WP_CACHE && function_exists('wp_cache_postload')) |
|
317 | 317 | wp_cache_postload(); |
318 | 318 | |
319 | 319 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @since 1.5.0 |
325 | 325 | */ |
326 | -do_action( 'plugins_loaded' ); |
|
326 | +do_action('plugins_loaded'); |
|
327 | 327 | |
328 | 328 | // Define constants which affect functionality if not already defined. |
329 | 329 | wp_functionality_constants(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @since 2.0.11 |
338 | 338 | */ |
339 | -do_action( 'sanitize_comment_cookies' ); |
|
339 | +do_action('sanitize_comment_cookies'); |
|
340 | 340 | |
341 | 341 | /** |
342 | 342 | * WordPress Query object |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @since 2.6.0 |
388 | 388 | */ |
389 | -do_action( 'setup_theme' ); |
|
389 | +do_action('setup_theme'); |
|
390 | 390 | |
391 | 391 | // Define the template related constants. |
392 | 392 | wp_templating_constants( ); |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | load_default_textdomain(); |
396 | 396 | |
397 | 397 | $locale = get_locale(); |
398 | -$locale_file = WP_LANG_DIR . "/$locale.php"; |
|
399 | -if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) |
|
400 | - require( $locale_file ); |
|
401 | -unset( $locale_file ); |
|
398 | +$locale_file = WP_LANG_DIR."/$locale.php"; |
|
399 | +if ((0 === validate_file($locale)) && is_readable($locale_file)) |
|
400 | + require($locale_file); |
|
401 | +unset($locale_file); |
|
402 | 402 | |
403 | 403 | /** |
404 | 404 | * WordPress Locale object for loading locale domain date and various strings. |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | $GLOBALS['wp_locale_switcher']->init(); |
419 | 419 | |
420 | 420 | // Load the functions for the active theme, for both parent and child theme if applicable. |
421 | -if ( ! wp_installing() || 'wp-activate.php' === $pagenow ) { |
|
422 | - if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) ) |
|
423 | - include( STYLESHEETPATH . '/functions.php' ); |
|
424 | - if ( file_exists( TEMPLATEPATH . '/functions.php' ) ) |
|
425 | - include( TEMPLATEPATH . '/functions.php' ); |
|
421 | +if ( ! wp_installing() || 'wp-activate.php' === $pagenow) { |
|
422 | + if (TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH.'/functions.php')) |
|
423 | + include(STYLESHEETPATH.'/functions.php'); |
|
424 | + if (file_exists(TEMPLATEPATH.'/functions.php')) |
|
425 | + include(TEMPLATEPATH.'/functions.php'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @since 3.0.0 |
432 | 432 | */ |
433 | -do_action( 'after_setup_theme' ); |
|
433 | +do_action('after_setup_theme'); |
|
434 | 434 | |
435 | 435 | // Set up current user. |
436 | 436 | $GLOBALS['wp']->init(); |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @since 1.5.0 |
448 | 448 | */ |
449 | -do_action( 'init' ); |
|
449 | +do_action('init'); |
|
450 | 450 | |
451 | 451 | // Check site status |
452 | -if ( is_multisite() ) { |
|
453 | - if ( true !== ( $file = ms_site_check() ) ) { |
|
454 | - require( $file ); |
|
452 | +if (is_multisite()) { |
|
453 | + if (true !== ($file = ms_site_check())) { |
|
454 | + require($file); |
|
455 | 455 | die(); |
456 | 456 | } |
457 | 457 | unset($file); |
@@ -467,4 +467,4 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @since 3.0.0 |
469 | 469 | */ |
470 | -do_action( 'wp_loaded' ); |
|
470 | +do_action('wp_loaded'); |
@@ -804,7 +804,7 @@ |
||
804 | 804 | * |
805 | 805 | * @param string $compare The compare operator to use |
806 | 806 | * @param string|array $value The value |
807 | - * @return string|false|int The value to be used in SQL or false on error. |
|
807 | + * @return string The value to be used in SQL or false on error. |
|
808 | 808 | */ |
809 | 809 | public function build_value( $compare, $value ) { |
810 | 810 | if ( ! isset( $value ) ) |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @access public |
61 | 61 | * @var array |
62 | 62 | */ |
63 | - public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second' ); |
|
63 | + public $time_keys = array('after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second'); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Constructor. |
@@ -150,37 +150,37 @@ discard block |
||
150 | 150 | * Accepts 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt', |
151 | 151 | * 'comment_date', 'comment_date_gmt'. |
152 | 152 | */ |
153 | - public function __construct( $date_query, $default_column = 'post_date' ) { |
|
154 | - if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) { |
|
153 | + public function __construct($date_query, $default_column = 'post_date') { |
|
154 | + if (isset($date_query['relation']) && 'OR' === strtoupper($date_query['relation'])) { |
|
155 | 155 | $this->relation = 'OR'; |
156 | 156 | } else { |
157 | 157 | $this->relation = 'AND'; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! is_array( $date_query ) ) { |
|
160 | + if ( ! is_array($date_query)) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | // Support for passing time-based keys in the top level of the $date_query array. |
165 | - if ( ! isset( $date_query[0] ) && ! empty( $date_query ) ) { |
|
166 | - $date_query = array( $date_query ); |
|
165 | + if ( ! isset($date_query[0]) && ! empty($date_query)) { |
|
166 | + $date_query = array($date_query); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( empty( $date_query ) ) { |
|
169 | + if (empty($date_query)) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | - if ( ! empty( $date_query['column'] ) ) { |
|
174 | - $date_query['column'] = esc_sql( $date_query['column'] ); |
|
173 | + if ( ! empty($date_query['column'])) { |
|
174 | + $date_query['column'] = esc_sql($date_query['column']); |
|
175 | 175 | } else { |
176 | - $date_query['column'] = esc_sql( $default_column ); |
|
176 | + $date_query['column'] = esc_sql($default_column); |
|
177 | 177 | } |
178 | 178 | |
179 | - $this->column = $this->validate_column( $this->column ); |
|
179 | + $this->column = $this->validate_column($this->column); |
|
180 | 180 | |
181 | - $this->compare = $this->get_compare( $date_query ); |
|
181 | + $this->compare = $this->get_compare($date_query); |
|
182 | 182 | |
183 | - $this->queries = $this->sanitize_query( $date_query ); |
|
183 | + $this->queries = $this->sanitize_query($date_query); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return array Sanitized queries. |
200 | 200 | */ |
201 | - public function sanitize_query( $queries, $parent_query = null ) { |
|
201 | + public function sanitize_query($queries, $parent_query = null) { |
|
202 | 202 | $cleaned_query = array(); |
203 | 203 | |
204 | 204 | $defaults = array( |
@@ -208,37 +208,37 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | // Numeric keys should always have array values. |
211 | - foreach ( $queries as $qkey => $qvalue ) { |
|
212 | - if ( is_numeric( $qkey ) && ! is_array( $qvalue ) ) { |
|
213 | - unset( $queries[ $qkey ] ); |
|
211 | + foreach ($queries as $qkey => $qvalue) { |
|
212 | + if (is_numeric($qkey) && ! is_array($qvalue)) { |
|
213 | + unset($queries[$qkey]); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | 217 | // Each query should have a value for each default key. Inherit from the parent when possible. |
218 | - foreach ( $defaults as $dkey => $dvalue ) { |
|
219 | - if ( isset( $queries[ $dkey ] ) ) { |
|
218 | + foreach ($defaults as $dkey => $dvalue) { |
|
219 | + if (isset($queries[$dkey])) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | - if ( isset( $parent_query[ $dkey ] ) ) { |
|
224 | - $queries[ $dkey ] = $parent_query[ $dkey ]; |
|
223 | + if (isset($parent_query[$dkey])) { |
|
224 | + $queries[$dkey] = $parent_query[$dkey]; |
|
225 | 225 | } else { |
226 | - $queries[ $dkey ] = $dvalue; |
|
226 | + $queries[$dkey] = $dvalue; |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Validate the dates passed in the query. |
231 | - if ( $this->is_first_order_clause( $queries ) ) { |
|
232 | - $this->validate_date_values( $queries ); |
|
231 | + if ($this->is_first_order_clause($queries)) { |
|
232 | + $this->validate_date_values($queries); |
|
233 | 233 | } |
234 | 234 | |
235 | - foreach ( $queries as $key => $q ) { |
|
236 | - if ( ! is_array( $q ) || in_array( $key, $this->time_keys, true ) ) { |
|
235 | + foreach ($queries as $key => $q) { |
|
236 | + if ( ! is_array($q) || in_array($key, $this->time_keys, true)) { |
|
237 | 237 | // This is a first-order query. Trust the values and sanitize when building SQL. |
238 | - $cleaned_query[ $key ] = $q; |
|
238 | + $cleaned_query[$key] = $q; |
|
239 | 239 | } else { |
240 | 240 | // Any array without a time key is another query, so we recurse. |
241 | - $cleaned_query[] = $this->sanitize_query( $q, $queries ); |
|
241 | + $cleaned_query[] = $this->sanitize_query($q, $queries); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | * @param array $query Query clause. |
258 | 258 | * @return bool True if this is a first-order clause. |
259 | 259 | */ |
260 | - protected function is_first_order_clause( $query ) { |
|
261 | - $time_keys = array_intersect( $this->time_keys, array_keys( $query ) ); |
|
262 | - return ! empty( $time_keys ); |
|
260 | + protected function is_first_order_clause($query) { |
|
261 | + $time_keys = array_intersect($this->time_keys, array_keys($query)); |
|
262 | + return ! empty($time_keys); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | * @param array $query A date query or a date subquery. |
272 | 272 | * @return string The comparison operator. |
273 | 273 | */ |
274 | - public function get_compare( $query ) { |
|
275 | - if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) |
|
276 | - return strtoupper( $query['compare'] ); |
|
274 | + public function get_compare($query) { |
|
275 | + if ( ! empty($query['compare']) && in_array($query['compare'], array('=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) |
|
276 | + return strtoupper($query['compare']); |
|
277 | 277 | |
278 | 278 | return $this->compare; |
279 | 279 | } |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param array $date_query The date_query array. |
292 | 292 | * @return bool True if all values in the query are valid, false if one or more fail. |
293 | 293 | */ |
294 | - public function validate_date_values( $date_query = array() ) { |
|
295 | - if ( empty( $date_query ) ) { |
|
294 | + public function validate_date_values($date_query = array()) { |
|
295 | + if (empty($date_query)) { |
|
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | |
@@ -303,30 +303,30 @@ discard block |
||
303 | 303 | * validation routine continue to be sure that all invalid |
304 | 304 | * values generate errors too. |
305 | 305 | */ |
306 | - if ( array_key_exists( 'before', $date_query ) && is_array( $date_query['before'] ) ){ |
|
307 | - $valid = $this->validate_date_values( $date_query['before'] ); |
|
306 | + if (array_key_exists('before', $date_query) && is_array($date_query['before'])) { |
|
307 | + $valid = $this->validate_date_values($date_query['before']); |
|
308 | 308 | } |
309 | 309 | |
310 | - if ( array_key_exists( 'after', $date_query ) && is_array( $date_query['after'] ) ){ |
|
311 | - $valid = $this->validate_date_values( $date_query['after'] ); |
|
310 | + if (array_key_exists('after', $date_query) && is_array($date_query['after'])) { |
|
311 | + $valid = $this->validate_date_values($date_query['after']); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | // Array containing all min-max checks. |
315 | 315 | $min_max_checks = array(); |
316 | 316 | |
317 | 317 | // Days per year. |
318 | - if ( array_key_exists( 'year', $date_query ) ) { |
|
318 | + if (array_key_exists('year', $date_query)) { |
|
319 | 319 | /* |
320 | 320 | * If a year exists in the date query, we can use it to get the days. |
321 | 321 | * If multiple years are provided (as in a BETWEEN), use the first one. |
322 | 322 | */ |
323 | - if ( is_array( $date_query['year'] ) ) { |
|
324 | - $_year = reset( $date_query['year'] ); |
|
323 | + if (is_array($date_query['year'])) { |
|
324 | + $_year = reset($date_query['year']); |
|
325 | 325 | } else { |
326 | 326 | $_year = $date_query['year']; |
327 | 327 | } |
328 | 328 | |
329 | - $max_days_of_year = date( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1; |
|
329 | + $max_days_of_year = date('z', mktime(0, 0, 0, 12, 31, $_year)) + 1; |
|
330 | 330 | } else { |
331 | 331 | // otherwise we use the max of 366 (leap-year) |
332 | 332 | $max_days_of_year = 366; |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | ); |
357 | 357 | |
358 | 358 | // Weeks per year. |
359 | - if ( isset( $_year ) ) { |
|
359 | + if (isset($_year)) { |
|
360 | 360 | /* |
361 | 361 | * If we have a specific year, use it to calculate number of weeks. |
362 | 362 | * Note: the number of weeks in a year is the date in which Dec 28 appears. |
363 | 363 | */ |
364 | - $week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) ); |
|
364 | + $week_count = date('W', mktime(0, 0, 0, 12, 28, $_year)); |
|
365 | 365 | |
366 | 366 | } else { |
367 | 367 | // Otherwise set the week-count to a maximum of 53. |
@@ -398,26 +398,26 @@ discard block |
||
398 | 398 | ); |
399 | 399 | |
400 | 400 | // Concatenate and throw a notice for each invalid value. |
401 | - foreach ( $min_max_checks as $key => $check ) { |
|
402 | - if ( ! array_key_exists( $key, $date_query ) ) { |
|
401 | + foreach ($min_max_checks as $key => $check) { |
|
402 | + if ( ! array_key_exists($key, $date_query)) { |
|
403 | 403 | continue; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // Throw a notice for each failing value. |
407 | - foreach ( (array) $date_query[ $key ] as $_value ) { |
|
407 | + foreach ((array) $date_query[$key] as $_value) { |
|
408 | 408 | $is_between = $_value >= $check['min'] && $_value <= $check['max']; |
409 | 409 | |
410 | - if ( ! is_numeric( $_value ) || ! $is_between ) { |
|
410 | + if ( ! is_numeric($_value) || ! $is_between) { |
|
411 | 411 | $error = sprintf( |
412 | 412 | /* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */ |
413 | - __( 'Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s.' ), |
|
414 | - '<code>' . esc_html( $_value ) . '</code>', |
|
415 | - '<code>' . esc_html( $key ) . '</code>', |
|
416 | - '<code>' . esc_html( $check['min'] ) . '</code>', |
|
417 | - '<code>' . esc_html( $check['max'] ) . '</code>' |
|
413 | + __('Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s.'), |
|
414 | + '<code>'.esc_html($_value).'</code>', |
|
415 | + '<code>'.esc_html($key).'</code>', |
|
416 | + '<code>'.esc_html($check['min']).'</code>', |
|
417 | + '<code>'.esc_html($check['max']).'</code>' |
|
418 | 418 | ); |
419 | 419 | |
420 | - _doing_it_wrong( __CLASS__, $error, '4.1.0' ); |
|
420 | + _doing_it_wrong(__CLASS__, $error, '4.1.0'); |
|
421 | 421 | |
422 | 422 | $valid = false; |
423 | 423 | } |
@@ -425,49 +425,49 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | // If we already have invalid date messages, don't bother running through checkdate(). |
428 | - if ( ! $valid ) { |
|
428 | + if ( ! $valid) { |
|
429 | 429 | return $valid; |
430 | 430 | } |
431 | 431 | |
432 | 432 | $day_month_year_error_msg = ''; |
433 | 433 | |
434 | - $day_exists = array_key_exists( 'day', $date_query ) && is_numeric( $date_query['day'] ); |
|
435 | - $month_exists = array_key_exists( 'month', $date_query ) && is_numeric( $date_query['month'] ); |
|
436 | - $year_exists = array_key_exists( 'year', $date_query ) && is_numeric( $date_query['year'] ); |
|
434 | + $day_exists = array_key_exists('day', $date_query) && is_numeric($date_query['day']); |
|
435 | + $month_exists = array_key_exists('month', $date_query) && is_numeric($date_query['month']); |
|
436 | + $year_exists = array_key_exists('year', $date_query) && is_numeric($date_query['year']); |
|
437 | 437 | |
438 | - if ( $day_exists && $month_exists && $year_exists ) { |
|
438 | + if ($day_exists && $month_exists && $year_exists) { |
|
439 | 439 | // 1. Checking day, month, year combination. |
440 | - if ( ! wp_checkdate( $date_query['month'], $date_query['day'], $date_query['year'], sprintf( '%s-%s-%s', $date_query['year'], $date_query['month'], $date_query['day'] ) ) ) { |
|
440 | + if ( ! wp_checkdate($date_query['month'], $date_query['day'], $date_query['year'], sprintf('%s-%s-%s', $date_query['year'], $date_query['month'], $date_query['day']))) { |
|
441 | 441 | /* translators: 1: year, 2: month, 3: day of month */ |
442 | 442 | $day_month_year_error_msg = sprintf( |
443 | - __( 'The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.' ), |
|
444 | - '<code>' . esc_html( $date_query['year'] ) . '</code>', |
|
445 | - '<code>' . esc_html( $date_query['month'] ) . '</code>', |
|
446 | - '<code>' . esc_html( $date_query['day'] ) . '</code>' |
|
443 | + __('The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.'), |
|
444 | + '<code>'.esc_html($date_query['year']).'</code>', |
|
445 | + '<code>'.esc_html($date_query['month']).'</code>', |
|
446 | + '<code>'.esc_html($date_query['day']).'</code>' |
|
447 | 447 | ); |
448 | 448 | |
449 | 449 | $valid = false; |
450 | 450 | } |
451 | 451 | |
452 | - } elseif ( $day_exists && $month_exists ) { |
|
452 | + } elseif ($day_exists && $month_exists) { |
|
453 | 453 | /* |
454 | 454 | * 2. checking day, month combination |
455 | 455 | * We use 2012 because, as a leap year, it's the most permissive. |
456 | 456 | */ |
457 | - if ( ! wp_checkdate( $date_query['month'], $date_query['day'], 2012, sprintf( '2012-%s-%s', $date_query['month'], $date_query['day'] ) ) ) { |
|
457 | + if ( ! wp_checkdate($date_query['month'], $date_query['day'], 2012, sprintf('2012-%s-%s', $date_query['month'], $date_query['day']))) { |
|
458 | 458 | /* translators: 1: month, 2: day of month */ |
459 | 459 | $day_month_year_error_msg = sprintf( |
460 | - __( 'The following values do not describe a valid date: month %1$s, day %2$s.' ), |
|
461 | - '<code>' . esc_html( $date_query['month'] ) . '</code>', |
|
462 | - '<code>' . esc_html( $date_query['day'] ) . '</code>' |
|
460 | + __('The following values do not describe a valid date: month %1$s, day %2$s.'), |
|
461 | + '<code>'.esc_html($date_query['month']).'</code>', |
|
462 | + '<code>'.esc_html($date_query['day']).'</code>' |
|
463 | 463 | ); |
464 | 464 | |
465 | 465 | $valid = false; |
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
469 | - if ( ! empty( $day_month_year_error_msg ) ) { |
|
470 | - _doing_it_wrong( __CLASS__, $day_month_year_error_msg, '4.1.0' ); |
|
469 | + if ( ! empty($day_month_year_error_msg)) { |
|
470 | + _doing_it_wrong(__CLASS__, $day_month_year_error_msg, '4.1.0'); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | return $valid; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @param string $column The user-supplied column name. |
488 | 488 | * @return string A validated column name value. |
489 | 489 | */ |
490 | - public function validate_column( $column ) { |
|
490 | + public function validate_column($column) { |
|
491 | 491 | global $wpdb; |
492 | 492 | |
493 | 493 | $valid_columns = array( |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | ); |
498 | 498 | |
499 | 499 | // Attempt to detect a table prefix. |
500 | - if ( false === strpos( $column, '.' ) ) { |
|
500 | + if (false === strpos($column, '.')) { |
|
501 | 501 | /** |
502 | 502 | * Filters the list of valid date query columns. |
503 | 503 | * |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | * 'post_modified_gmt', 'comment_date', 'comment_date_gmt', |
510 | 510 | * 'user_registered' |
511 | 511 | */ |
512 | - if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) { |
|
512 | + if ( ! in_array($column, apply_filters('date_query_valid_columns', $valid_columns))) { |
|
513 | 513 | $column = 'post_date'; |
514 | 514 | } |
515 | 515 | |
@@ -534,9 +534,9 @@ discard block |
||
534 | 534 | ); |
535 | 535 | |
536 | 536 | // If it's a known column name, add the appropriate table prefix. |
537 | - foreach ( $known_columns as $table_name => $table_columns ) { |
|
538 | - if ( in_array( $column, $table_columns ) ) { |
|
539 | - $column = $table_name . '.' . $column; |
|
537 | + foreach ($known_columns as $table_name => $table_columns) { |
|
538 | + if (in_array($column, $table_columns)) { |
|
539 | + $column = $table_name.'.'.$column; |
|
540 | 540 | break; |
541 | 541 | } |
542 | 542 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | // Remove unsafe characters. |
547 | - return preg_replace( '/[^a-zA-Z0-9_$\.]/', '', $column ); |
|
547 | + return preg_replace('/[^a-zA-Z0-9_$\.]/', '', $column); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param string $where WHERE clause of the date query. |
569 | 569 | * @param WP_Date_Query $this The WP_Date_Query instance. |
570 | 570 | */ |
571 | - return apply_filters( 'get_date_sql', $where, $this ); |
|
571 | + return apply_filters('get_date_sql', $where, $this); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -588,10 +588,10 @@ discard block |
||
588 | 588 | * } |
589 | 589 | */ |
590 | 590 | protected function get_sql_clauses() { |
591 | - $sql = $this->get_sql_for_query( $this->queries ); |
|
591 | + $sql = $this->get_sql_for_query($this->queries); |
|
592 | 592 | |
593 | - if ( ! empty( $sql['where'] ) ) { |
|
594 | - $sql['where'] = ' AND ' . $sql['where']; |
|
593 | + if ( ! empty($sql['where'])) { |
|
594 | + $sql['where'] = ' AND '.$sql['where']; |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | return $sql; |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @type string $where SQL fragment to append to the main WHERE clause. |
617 | 617 | * } |
618 | 618 | */ |
619 | - protected function get_sql_for_query( $query, $depth = 0 ) { |
|
619 | + protected function get_sql_for_query($query, $depth = 0) { |
|
620 | 620 | $sql_chunks = array( |
621 | 621 | 'join' => array(), |
622 | 622 | 'where' => array(), |
@@ -628,32 +628,32 @@ discard block |
||
628 | 628 | ); |
629 | 629 | |
630 | 630 | $indent = ''; |
631 | - for ( $i = 0; $i < $depth; $i++ ) { |
|
631 | + for ($i = 0; $i < $depth; $i++) { |
|
632 | 632 | $indent .= " "; |
633 | 633 | } |
634 | 634 | |
635 | - foreach ( $query as $key => $clause ) { |
|
636 | - if ( 'relation' === $key ) { |
|
635 | + foreach ($query as $key => $clause) { |
|
636 | + if ('relation' === $key) { |
|
637 | 637 | $relation = $query['relation']; |
638 | - } elseif ( is_array( $clause ) ) { |
|
638 | + } elseif (is_array($clause)) { |
|
639 | 639 | |
640 | 640 | // This is a first-order clause. |
641 | - if ( $this->is_first_order_clause( $clause ) ) { |
|
642 | - $clause_sql = $this->get_sql_for_clause( $clause, $query ); |
|
641 | + if ($this->is_first_order_clause($clause)) { |
|
642 | + $clause_sql = $this->get_sql_for_clause($clause, $query); |
|
643 | 643 | |
644 | - $where_count = count( $clause_sql['where'] ); |
|
645 | - if ( ! $where_count ) { |
|
644 | + $where_count = count($clause_sql['where']); |
|
645 | + if ( ! $where_count) { |
|
646 | 646 | $sql_chunks['where'][] = ''; |
647 | - } elseif ( 1 === $where_count ) { |
|
647 | + } elseif (1 === $where_count) { |
|
648 | 648 | $sql_chunks['where'][] = $clause_sql['where'][0]; |
649 | 649 | } else { |
650 | - $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )'; |
|
650 | + $sql_chunks['where'][] = '( '.implode(' AND ', $clause_sql['where']).' )'; |
|
651 | 651 | } |
652 | 652 | |
653 | - $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] ); |
|
653 | + $sql_chunks['join'] = array_merge($sql_chunks['join'], $clause_sql['join']); |
|
654 | 654 | // This is a subquery, so we recurse. |
655 | 655 | } else { |
656 | - $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 ); |
|
656 | + $clause_sql = $this->get_sql_for_query($clause, $depth + 1); |
|
657 | 657 | |
658 | 658 | $sql_chunks['where'][] = $clause_sql['where']; |
659 | 659 | $sql_chunks['join'][] = $clause_sql['join']; |
@@ -662,21 +662,21 @@ discard block |
||
662 | 662 | } |
663 | 663 | |
664 | 664 | // Filter to remove empties. |
665 | - $sql_chunks['join'] = array_filter( $sql_chunks['join'] ); |
|
666 | - $sql_chunks['where'] = array_filter( $sql_chunks['where'] ); |
|
665 | + $sql_chunks['join'] = array_filter($sql_chunks['join']); |
|
666 | + $sql_chunks['where'] = array_filter($sql_chunks['where']); |
|
667 | 667 | |
668 | - if ( empty( $relation ) ) { |
|
668 | + if (empty($relation)) { |
|
669 | 669 | $relation = 'AND'; |
670 | 670 | } |
671 | 671 | |
672 | 672 | // Filter duplicate JOIN clauses and combine into a single string. |
673 | - if ( ! empty( $sql_chunks['join'] ) ) { |
|
674 | - $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) ); |
|
673 | + if ( ! empty($sql_chunks['join'])) { |
|
674 | + $sql['join'] = implode(' ', array_unique($sql_chunks['join'])); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | // Generate a single WHERE clause with proper brackets and indentation. |
678 | - if ( ! empty( $sql_chunks['where'] ) ) { |
|
679 | - $sql['where'] = '( ' . "\n " . $indent . implode( ' ' . "\n " . $indent . $relation . ' ' . "\n " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')'; |
|
678 | + if ( ! empty($sql_chunks['where'])) { |
|
679 | + $sql['where'] = '( '."\n ".$indent.implode(' '."\n ".$indent.$relation.' '."\n ".$indent, $sql_chunks['where'])."\n".$indent.')'; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | return $sql; |
@@ -699,8 +699,8 @@ discard block |
||
699 | 699 | * @type string $where SQL fragment to append to the main WHERE clause. |
700 | 700 | * } |
701 | 701 | */ |
702 | - protected function get_sql_for_subquery( $query ) { |
|
703 | - return $this->get_sql_for_clause( $query, '' ); |
|
702 | + protected function get_sql_for_subquery($query) { |
|
703 | + return $this->get_sql_for_clause($query, ''); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | /** |
@@ -718,72 +718,72 @@ discard block |
||
718 | 718 | * @type string $where SQL fragment to append to the main WHERE clause. |
719 | 719 | * } |
720 | 720 | */ |
721 | - protected function get_sql_for_clause( $query, $parent_query ) { |
|
721 | + protected function get_sql_for_clause($query, $parent_query) { |
|
722 | 722 | global $wpdb; |
723 | 723 | |
724 | 724 | // The sub-parts of a $where part. |
725 | 725 | $where_parts = array(); |
726 | 726 | |
727 | - $column = ( ! empty( $query['column'] ) ) ? esc_sql( $query['column'] ) : $this->column; |
|
727 | + $column = ( ! empty($query['column'])) ? esc_sql($query['column']) : $this->column; |
|
728 | 728 | |
729 | - $column = $this->validate_column( $column ); |
|
729 | + $column = $this->validate_column($column); |
|
730 | 730 | |
731 | - $compare = $this->get_compare( $query ); |
|
731 | + $compare = $this->get_compare($query); |
|
732 | 732 | |
733 | - $inclusive = ! empty( $query['inclusive'] ); |
|
733 | + $inclusive = ! empty($query['inclusive']); |
|
734 | 734 | |
735 | 735 | // Assign greater- and less-than values. |
736 | 736 | $lt = '<'; |
737 | 737 | $gt = '>'; |
738 | 738 | |
739 | - if ( $inclusive ) { |
|
739 | + if ($inclusive) { |
|
740 | 740 | $lt .= '='; |
741 | 741 | $gt .= '='; |
742 | 742 | } |
743 | 743 | |
744 | 744 | // Range queries. |
745 | - if ( ! empty( $query['after'] ) ) { |
|
746 | - $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) ); |
|
745 | + if ( ! empty($query['after'])) { |
|
746 | + $where_parts[] = $wpdb->prepare("$column $gt %s", $this->build_mysql_datetime($query['after'], ! $inclusive)); |
|
747 | 747 | } |
748 | - if ( ! empty( $query['before'] ) ) { |
|
749 | - $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) ); |
|
748 | + if ( ! empty($query['before'])) { |
|
749 | + $where_parts[] = $wpdb->prepare("$column $lt %s", $this->build_mysql_datetime($query['before'], $inclusive)); |
|
750 | 750 | } |
751 | 751 | // Specific value queries. |
752 | 752 | |
753 | - if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) |
|
753 | + if (isset($query['year']) && $value = $this->build_value($compare, $query['year'])) |
|
754 | 754 | $where_parts[] = "YEAR( $column ) $compare $value"; |
755 | 755 | |
756 | - if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) { |
|
756 | + if (isset($query['month']) && $value = $this->build_value($compare, $query['month'])) { |
|
757 | 757 | $where_parts[] = "MONTH( $column ) $compare $value"; |
758 | - } elseif ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) { |
|
758 | + } elseif (isset($query['monthnum']) && $value = $this->build_value($compare, $query['monthnum'])) { |
|
759 | 759 | $where_parts[] = "MONTH( $column ) $compare $value"; |
760 | 760 | } |
761 | - if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) { |
|
762 | - $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
|
763 | - } elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) { |
|
764 | - $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
|
761 | + if (isset($query['week']) && false !== ($value = $this->build_value($compare, $query['week']))) { |
|
762 | + $where_parts[] = _wp_mysql_week($column)." $compare $value"; |
|
763 | + } elseif (isset($query['w']) && false !== ($value = $this->build_value($compare, $query['w']))) { |
|
764 | + $where_parts[] = _wp_mysql_week($column)." $compare $value"; |
|
765 | 765 | } |
766 | - if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) |
|
766 | + if (isset($query['dayofyear']) && $value = $this->build_value($compare, $query['dayofyear'])) |
|
767 | 767 | $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; |
768 | 768 | |
769 | - if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) |
|
769 | + if (isset($query['day']) && $value = $this->build_value($compare, $query['day'])) |
|
770 | 770 | $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; |
771 | 771 | |
772 | - if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) |
|
772 | + if (isset($query['dayofweek']) && $value = $this->build_value($compare, $query['dayofweek'])) |
|
773 | 773 | $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; |
774 | 774 | |
775 | - if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) |
|
775 | + if (isset($query['dayofweek_iso']) && $value = $this->build_value($compare, $query['dayofweek_iso'])) |
|
776 | 776 | $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; |
777 | 777 | |
778 | - if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) { |
|
778 | + if (isset($query['hour']) || isset($query['minute']) || isset($query['second'])) { |
|
779 | 779 | // Avoid notices. |
780 | - foreach ( array( 'hour', 'minute', 'second' ) as $unit ) { |
|
781 | - if ( ! isset( $query[ $unit ] ) ) { |
|
782 | - $query[ $unit ] = null; |
|
780 | + foreach (array('hour', 'minute', 'second') as $unit) { |
|
781 | + if ( ! isset($query[$unit])) { |
|
782 | + $query[$unit] = null; |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
786 | - if ( $time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] ) ) { |
|
786 | + if ($time_query = $this->build_time_query($column, $compare, $query['hour'], $query['minute'], $query['second'])) { |
|
787 | 787 | $where_parts[] = $time_query; |
788 | 788 | } |
789 | 789 | } |
@@ -808,45 +808,45 @@ discard block |
||
808 | 808 | * @param string|array $value The value |
809 | 809 | * @return string|false|int The value to be used in SQL or false on error. |
810 | 810 | */ |
811 | - public function build_value( $compare, $value ) { |
|
812 | - if ( ! isset( $value ) ) |
|
811 | + public function build_value($compare, $value) { |
|
812 | + if ( ! isset($value)) |
|
813 | 813 | return false; |
814 | 814 | |
815 | - switch ( $compare ) { |
|
815 | + switch ($compare) { |
|
816 | 816 | case 'IN': |
817 | 817 | case 'NOT IN': |
818 | 818 | $value = (array) $value; |
819 | 819 | |
820 | 820 | // Remove non-numeric values. |
821 | - $value = array_filter( $value, 'is_numeric' ); |
|
821 | + $value = array_filter($value, 'is_numeric'); |
|
822 | 822 | |
823 | - if ( empty( $value ) ) { |
|
823 | + if (empty($value)) { |
|
824 | 824 | return false; |
825 | 825 | } |
826 | 826 | |
827 | - return '(' . implode( ',', array_map( 'intval', $value ) ) . ')'; |
|
827 | + return '('.implode(',', array_map('intval', $value)).')'; |
|
828 | 828 | |
829 | 829 | case 'BETWEEN': |
830 | 830 | case 'NOT BETWEEN': |
831 | - if ( ! is_array( $value ) || 2 != count( $value ) ) { |
|
832 | - $value = array( $value, $value ); |
|
831 | + if ( ! is_array($value) || 2 != count($value)) { |
|
832 | + $value = array($value, $value); |
|
833 | 833 | } else { |
834 | - $value = array_values( $value ); |
|
834 | + $value = array_values($value); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | // If either value is non-numeric, bail. |
838 | - foreach ( $value as $v ) { |
|
839 | - if ( ! is_numeric( $v ) ) { |
|
838 | + foreach ($value as $v) { |
|
839 | + if ( ! is_numeric($v)) { |
|
840 | 840 | return false; |
841 | 841 | } |
842 | 842 | } |
843 | 843 | |
844 | - $value = array_map( 'intval', $value ); |
|
844 | + $value = array_map('intval', $value); |
|
845 | 845 | |
846 | - return $value[0] . ' AND ' . $value[1]; |
|
846 | + return $value[0].' AND '.$value[1]; |
|
847 | 847 | |
848 | 848 | default; |
849 | - if ( ! is_numeric( $value ) ) { |
|
849 | + if ( ! is_numeric($value)) { |
|
850 | 850 | return false; |
851 | 851 | } |
852 | 852 | |
@@ -871,75 +871,75 @@ discard block |
||
871 | 871 | * Default: false. |
872 | 872 | * @return string|false A MySQL format date/time or false on failure |
873 | 873 | */ |
874 | - public function build_mysql_datetime( $datetime, $default_to_max = false ) { |
|
875 | - $now = current_time( 'timestamp' ); |
|
874 | + public function build_mysql_datetime($datetime, $default_to_max = false) { |
|
875 | + $now = current_time('timestamp'); |
|
876 | 876 | |
877 | - if ( ! is_array( $datetime ) ) { |
|
877 | + if ( ! is_array($datetime)) { |
|
878 | 878 | |
879 | 879 | /* |
880 | 880 | * Try to parse some common date formats, so we can detect |
881 | 881 | * the level of precision and support the 'inclusive' parameter. |
882 | 882 | */ |
883 | - if ( preg_match( '/^(\d{4})$/', $datetime, $matches ) ) { |
|
883 | + if (preg_match('/^(\d{4})$/', $datetime, $matches)) { |
|
884 | 884 | // Y |
885 | 885 | $datetime = array( |
886 | - 'year' => intval( $matches[1] ), |
|
886 | + 'year' => intval($matches[1]), |
|
887 | 887 | ); |
888 | 888 | |
889 | - } elseif ( preg_match( '/^(\d{4})\-(\d{2})$/', $datetime, $matches ) ) { |
|
889 | + } elseif (preg_match('/^(\d{4})\-(\d{2})$/', $datetime, $matches)) { |
|
890 | 890 | // Y-m |
891 | 891 | $datetime = array( |
892 | - 'year' => intval( $matches[1] ), |
|
893 | - 'month' => intval( $matches[2] ), |
|
892 | + 'year' => intval($matches[1]), |
|
893 | + 'month' => intval($matches[2]), |
|
894 | 894 | ); |
895 | 895 | |
896 | - } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches ) ) { |
|
896 | + } elseif (preg_match('/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches)) { |
|
897 | 897 | // Y-m-d |
898 | 898 | $datetime = array( |
899 | - 'year' => intval( $matches[1] ), |
|
900 | - 'month' => intval( $matches[2] ), |
|
901 | - 'day' => intval( $matches[3] ), |
|
899 | + 'year' => intval($matches[1]), |
|
900 | + 'month' => intval($matches[2]), |
|
901 | + 'day' => intval($matches[3]), |
|
902 | 902 | ); |
903 | 903 | |
904 | - } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches ) ) { |
|
904 | + } elseif (preg_match('/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches)) { |
|
905 | 905 | // Y-m-d H:i |
906 | 906 | $datetime = array( |
907 | - 'year' => intval( $matches[1] ), |
|
908 | - 'month' => intval( $matches[2] ), |
|
909 | - 'day' => intval( $matches[3] ), |
|
910 | - 'hour' => intval( $matches[4] ), |
|
911 | - 'minute' => intval( $matches[5] ), |
|
907 | + 'year' => intval($matches[1]), |
|
908 | + 'month' => intval($matches[2]), |
|
909 | + 'day' => intval($matches[3]), |
|
910 | + 'hour' => intval($matches[4]), |
|
911 | + 'minute' => intval($matches[5]), |
|
912 | 912 | ); |
913 | 913 | } |
914 | 914 | |
915 | 915 | // If no match is found, we don't support default_to_max. |
916 | - if ( ! is_array( $datetime ) ) { |
|
916 | + if ( ! is_array($datetime)) { |
|
917 | 917 | // @todo Timezone issues here possibly |
918 | - return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) ); |
|
918 | + return gmdate('Y-m-d H:i:s', strtotime($datetime, $now)); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | |
922 | - $datetime = array_map( 'absint', $datetime ); |
|
922 | + $datetime = array_map('absint', $datetime); |
|
923 | 923 | |
924 | - if ( ! isset( $datetime['year'] ) ) |
|
925 | - $datetime['year'] = gmdate( 'Y', $now ); |
|
924 | + if ( ! isset($datetime['year'])) |
|
925 | + $datetime['year'] = gmdate('Y', $now); |
|
926 | 926 | |
927 | - if ( ! isset( $datetime['month'] ) ) |
|
928 | - $datetime['month'] = ( $default_to_max ) ? 12 : 1; |
|
927 | + if ( ! isset($datetime['month'])) |
|
928 | + $datetime['month'] = ($default_to_max) ? 12 : 1; |
|
929 | 929 | |
930 | - if ( ! isset( $datetime['day'] ) ) |
|
931 | - $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; |
|
930 | + if ( ! isset($datetime['day'])) |
|
931 | + $datetime['day'] = ($default_to_max) ? (int) date('t', mktime(0, 0, 0, $datetime['month'], 1, $datetime['year'])) : 1; |
|
932 | 932 | |
933 | - if ( ! isset( $datetime['hour'] ) ) |
|
934 | - $datetime['hour'] = ( $default_to_max ) ? 23 : 0; |
|
933 | + if ( ! isset($datetime['hour'])) |
|
934 | + $datetime['hour'] = ($default_to_max) ? 23 : 0; |
|
935 | 935 | |
936 | - if ( ! isset( $datetime['minute'] ) ) |
|
937 | - $datetime['minute'] = ( $default_to_max ) ? 59 : 0; |
|
936 | + if ( ! isset($datetime['minute'])) |
|
937 | + $datetime['minute'] = ($default_to_max) ? 59 : 0; |
|
938 | 938 | |
939 | - if ( ! isset( $datetime['second'] ) ) |
|
940 | - $datetime['second'] = ( $default_to_max ) ? 59 : 0; |
|
939 | + if ( ! isset($datetime['second'])) |
|
940 | + $datetime['second'] = ($default_to_max) ? 59 : 0; |
|
941 | 941 | |
942 | - return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] ); |
|
942 | + return sprintf('%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second']); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | /** |
@@ -959,48 +959,48 @@ discard block |
||
959 | 959 | * @param int|null $second Optional. A second value (0-59). |
960 | 960 | * @return string|false A query part or false on failure. |
961 | 961 | */ |
962 | - public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) { |
|
962 | + public function build_time_query($column, $compare, $hour = null, $minute = null, $second = null) { |
|
963 | 963 | global $wpdb; |
964 | 964 | |
965 | 965 | // Have to have at least one |
966 | - if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) |
|
966 | + if ( ! isset($hour) && ! isset($minute) && ! isset($second)) |
|
967 | 967 | return false; |
968 | 968 | |
969 | 969 | // Complex combined queries aren't supported for multi-value queries |
970 | - if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { |
|
970 | + if (in_array($compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) { |
|
971 | 971 | $return = array(); |
972 | 972 | |
973 | - if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) |
|
973 | + if (isset($hour) && false !== ($value = $this->build_value($compare, $hour))) |
|
974 | 974 | $return[] = "HOUR( $column ) $compare $value"; |
975 | 975 | |
976 | - if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) |
|
976 | + if (isset($minute) && false !== ($value = $this->build_value($compare, $minute))) |
|
977 | 977 | $return[] = "MINUTE( $column ) $compare $value"; |
978 | 978 | |
979 | - if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) |
|
979 | + if (isset($second) && false !== ($value = $this->build_value($compare, $second))) |
|
980 | 980 | $return[] = "SECOND( $column ) $compare $value"; |
981 | 981 | |
982 | - return implode( ' AND ', $return ); |
|
982 | + return implode(' AND ', $return); |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | // Cases where just one unit is set |
986 | - if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) { |
|
986 | + if (isset($hour) && ! isset($minute) && ! isset($second) && false !== ($value = $this->build_value($compare, $hour))) { |
|
987 | 987 | return "HOUR( $column ) $compare $value"; |
988 | - } elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) { |
|
988 | + } elseif ( ! isset($hour) && isset($minute) && ! isset($second) && false !== ($value = $this->build_value($compare, $minute))) { |
|
989 | 989 | return "MINUTE( $column ) $compare $value"; |
990 | - } elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) { |
|
990 | + } elseif ( ! isset($hour) && ! isset($minute) && isset($second) && false !== ($value = $this->build_value($compare, $second))) { |
|
991 | 991 | return "SECOND( $column ) $compare $value"; |
992 | 992 | } |
993 | 993 | |
994 | 994 | // Single units were already handled. Since hour & second isn't allowed, minute must to be set. |
995 | - if ( ! isset( $minute ) ) |
|
995 | + if ( ! isset($minute)) |
|
996 | 996 | return false; |
997 | 997 | |
998 | 998 | $format = $time = ''; |
999 | 999 | |
1000 | 1000 | // Hour |
1001 | - if ( null !== $hour ) { |
|
1001 | + if (null !== $hour) { |
|
1002 | 1002 | $format .= '%H.'; |
1003 | - $time .= sprintf( '%02d', $hour ) . '.'; |
|
1003 | + $time .= sprintf('%02d', $hour).'.'; |
|
1004 | 1004 | } else { |
1005 | 1005 | $format .= '0.'; |
1006 | 1006 | $time .= '0.'; |
@@ -1008,13 +1008,13 @@ discard block |
||
1008 | 1008 | |
1009 | 1009 | // Minute |
1010 | 1010 | $format .= '%i'; |
1011 | - $time .= sprintf( '%02d', $minute ); |
|
1011 | + $time .= sprintf('%02d', $minute); |
|
1012 | 1012 | |
1013 | - if ( isset( $second ) ) { |
|
1013 | + if (isset($second)) { |
|
1014 | 1014 | $format .= '%s'; |
1015 | - $time .= sprintf( '%02d', $second ); |
|
1015 | + $time .= sprintf('%02d', $second); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | - return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time ); |
|
1018 | + return $wpdb->prepare("DATE_FORMAT( $column, %s ) $compare %f", $format, $time); |
|
1019 | 1019 | } |
1020 | 1020 | } |
@@ -272,8 +272,9 @@ discard block |
||
272 | 272 | * @return string The comparison operator. |
273 | 273 | */ |
274 | 274 | public function get_compare( $query ) { |
275 | - if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) |
|
276 | - return strtoupper( $query['compare'] ); |
|
275 | + if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { |
|
276 | + return strtoupper( $query['compare'] ); |
|
277 | + } |
|
277 | 278 | |
278 | 279 | return $this->compare; |
279 | 280 | } |
@@ -750,8 +751,9 @@ discard block |
||
750 | 751 | } |
751 | 752 | // Specific value queries. |
752 | 753 | |
753 | - if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) |
|
754 | - $where_parts[] = "YEAR( $column ) $compare $value"; |
|
754 | + if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) { |
|
755 | + $where_parts[] = "YEAR( $column ) $compare $value"; |
|
756 | + } |
|
755 | 757 | |
756 | 758 | if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) { |
757 | 759 | $where_parts[] = "MONTH( $column ) $compare $value"; |
@@ -763,17 +765,21 @@ discard block |
||
763 | 765 | } elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) { |
764 | 766 | $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
765 | 767 | } |
766 | - if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) |
|
767 | - $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; |
|
768 | + if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) { |
|
769 | + $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; |
|
770 | + } |
|
768 | 771 | |
769 | - if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) |
|
770 | - $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; |
|
772 | + if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) { |
|
773 | + $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; |
|
774 | + } |
|
771 | 775 | |
772 | - if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) |
|
773 | - $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; |
|
776 | + if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) { |
|
777 | + $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; |
|
778 | + } |
|
774 | 779 | |
775 | - if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) |
|
776 | - $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; |
|
780 | + if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) { |
|
781 | + $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; |
|
782 | + } |
|
777 | 783 | |
778 | 784 | if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) { |
779 | 785 | // Avoid notices. |
@@ -809,8 +815,9 @@ discard block |
||
809 | 815 | * @return string|false|int The value to be used in SQL or false on error. |
810 | 816 | */ |
811 | 817 | public function build_value( $compare, $value ) { |
812 | - if ( ! isset( $value ) ) |
|
813 | - return false; |
|
818 | + if ( ! isset( $value ) ) { |
|
819 | + return false; |
|
820 | + } |
|
814 | 821 | |
815 | 822 | switch ( $compare ) { |
816 | 823 | case 'IN': |
@@ -921,23 +928,29 @@ discard block |
||
921 | 928 | |
922 | 929 | $datetime = array_map( 'absint', $datetime ); |
923 | 930 | |
924 | - if ( ! isset( $datetime['year'] ) ) |
|
925 | - $datetime['year'] = gmdate( 'Y', $now ); |
|
931 | + if ( ! isset( $datetime['year'] ) ) { |
|
932 | + $datetime['year'] = gmdate( 'Y', $now ); |
|
933 | + } |
|
926 | 934 | |
927 | - if ( ! isset( $datetime['month'] ) ) |
|
928 | - $datetime['month'] = ( $default_to_max ) ? 12 : 1; |
|
935 | + if ( ! isset( $datetime['month'] ) ) { |
|
936 | + $datetime['month'] = ( $default_to_max ) ? 12 : 1; |
|
937 | + } |
|
929 | 938 | |
930 | - if ( ! isset( $datetime['day'] ) ) |
|
931 | - $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; |
|
939 | + if ( ! isset( $datetime['day'] ) ) { |
|
940 | + $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; |
|
941 | + } |
|
932 | 942 | |
933 | - if ( ! isset( $datetime['hour'] ) ) |
|
934 | - $datetime['hour'] = ( $default_to_max ) ? 23 : 0; |
|
943 | + if ( ! isset( $datetime['hour'] ) ) { |
|
944 | + $datetime['hour'] = ( $default_to_max ) ? 23 : 0; |
|
945 | + } |
|
935 | 946 | |
936 | - if ( ! isset( $datetime['minute'] ) ) |
|
937 | - $datetime['minute'] = ( $default_to_max ) ? 59 : 0; |
|
947 | + if ( ! isset( $datetime['minute'] ) ) { |
|
948 | + $datetime['minute'] = ( $default_to_max ) ? 59 : 0; |
|
949 | + } |
|
938 | 950 | |
939 | - if ( ! isset( $datetime['second'] ) ) |
|
940 | - $datetime['second'] = ( $default_to_max ) ? 59 : 0; |
|
951 | + if ( ! isset( $datetime['second'] ) ) { |
|
952 | + $datetime['second'] = ( $default_to_max ) ? 59 : 0; |
|
953 | + } |
|
941 | 954 | |
942 | 955 | return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] ); |
943 | 956 | } |
@@ -963,21 +976,25 @@ discard block |
||
963 | 976 | global $wpdb; |
964 | 977 | |
965 | 978 | // Have to have at least one |
966 | - if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) |
|
967 | - return false; |
|
979 | + if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) { |
|
980 | + return false; |
|
981 | + } |
|
968 | 982 | |
969 | 983 | // Complex combined queries aren't supported for multi-value queries |
970 | 984 | if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { |
971 | 985 | $return = array(); |
972 | 986 | |
973 | - if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) |
|
974 | - $return[] = "HOUR( $column ) $compare $value"; |
|
987 | + if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) { |
|
988 | + $return[] = "HOUR( $column ) $compare $value"; |
|
989 | + } |
|
975 | 990 | |
976 | - if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) |
|
977 | - $return[] = "MINUTE( $column ) $compare $value"; |
|
991 | + if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) { |
|
992 | + $return[] = "MINUTE( $column ) $compare $value"; |
|
993 | + } |
|
978 | 994 | |
979 | - if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) |
|
980 | - $return[] = "SECOND( $column ) $compare $value"; |
|
995 | + if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) { |
|
996 | + $return[] = "SECOND( $column ) $compare $value"; |
|
997 | + } |
|
981 | 998 | |
982 | 999 | return implode( ' AND ', $return ); |
983 | 1000 | } |
@@ -992,8 +1009,9 @@ discard block |
||
992 | 1009 | } |
993 | 1010 | |
994 | 1011 | // Single units were already handled. Since hour & second isn't allowed, minute must to be set. |
995 | - if ( ! isset( $minute ) ) |
|
996 | - return false; |
|
1012 | + if ( ! isset( $minute ) ) { |
|
1013 | + return false; |
|
1014 | + } |
|
997 | 1015 | |
998 | 1016 | $format = $time = ''; |
999 | 1017 |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * @param string $feed_image |
611 | 611 | * @param string $exclude |
612 | 612 | * @param bool $hierarchical |
613 | - * @return false|null |
|
613 | + * @return false|string |
|
614 | 614 | */ |
615 | 615 | function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, |
616 | 616 | $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @see wp_list_categories() |
631 | 631 | * |
632 | 632 | * @param string|array $args |
633 | - * @return false|null|string |
|
633 | + * @return false|string |
|
634 | 634 | */ |
635 | 635 | function wp_list_cats($args = '') { |
636 | 636 | _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); |
@@ -2101,7 +2101,6 @@ discard block |
||
2101 | 2101 | * @param string|int $name Widget ID. |
2102 | 2102 | * @param callable $output_callback Run when widget is called. |
2103 | 2103 | * @param string $classname Optional. Classname widget option. Default empty. |
2104 | - * @param mixed $params ,... Widget parameters. |
|
2105 | 2104 | */ |
2106 | 2105 | function register_sidebar_widget($name, $output_callback, $classname = '') { |
2107 | 2106 | _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); |
@@ -2419,7 +2418,7 @@ discard block |
||
2419 | 2418 | * @see count_user_posts() |
2420 | 2419 | * |
2421 | 2420 | * @param int $userid User to count posts for. |
2422 | - * @return int Number of posts the given user has written. |
|
2421 | + * @return string Number of posts the given user has written. |
|
2423 | 2422 | */ |
2424 | 2423 | function get_usernumposts( $userid ) { |
2425 | 2424 | _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' ); |
@@ -3601,7 +3600,7 @@ discard block |
||
3601 | 3600 | * @deprecated 4.4.0 Use get_permalink() |
3602 | 3601 | * @see get_permalink() |
3603 | 3602 | * |
3604 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
3603 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
3605 | 3604 | * @return string|false |
3606 | 3605 | */ |
3607 | 3606 | function post_permalink( $post_id = 0 ) { |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | * @return array Post data. |
24 | 24 | */ |
25 | 25 | function get_postdata($postid) { |
26 | - _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); |
|
26 | + _deprecated_function(__FUNCTION__, '1.5.1', 'get_post()'); |
|
27 | 27 | |
28 | 28 | $post = get_post($postid); |
29 | 29 | |
30 | - $postdata = array ( |
|
30 | + $postdata = array( |
|
31 | 31 | 'ID' => $post->ID, |
32 | 32 | 'Author_ID' => $post->post_author, |
33 | 33 | 'Date' => $post->post_date, |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | function start_wp() { |
62 | 62 | global $wp_query; |
63 | 63 | |
64 | - _deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') ); |
|
64 | + _deprecated_function(__FUNCTION__, '1.5.0', __('new WordPress Loop')); |
|
65 | 65 | |
66 | 66 | // Since the old style loop is being used, advance the query iterator here. |
67 | 67 | $wp_query->next_post(); |
68 | 68 | |
69 | - setup_postdata( get_post() ); |
|
69 | + setup_postdata(get_post()); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | * @return int Category ID. |
81 | 81 | */ |
82 | 82 | function the_category_ID($echo = true) { |
83 | - _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); |
|
83 | + _deprecated_function(__FUNCTION__, '0.71', 'get_the_category()'); |
|
84 | 84 | |
85 | 85 | // Grab the first cat in the list. |
86 | 86 | $categories = get_the_category(); |
87 | 87 | $cat = $categories[0]->term_id; |
88 | 88 | |
89 | - if ( $echo ) |
|
89 | + if ($echo) |
|
90 | 90 | echo $cat; |
91 | 91 | |
92 | 92 | return $cat; |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | * @param string $before Optional. Text to display before the category. Default empty. |
103 | 103 | * @param string $after Optional. Text to display after the category. Default empty. |
104 | 104 | */ |
105 | -function the_category_head( $before = '', $after = '' ) { |
|
105 | +function the_category_head($before = '', $after = '') { |
|
106 | 106 | global $currentcat, $previouscat; |
107 | 107 | |
108 | - _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); |
|
108 | + _deprecated_function(__FUNCTION__, '0.71', 'get_the_category_by_ID()'); |
|
109 | 109 | |
110 | 110 | // Grab the first cat in the list. |
111 | 111 | $categories = get_the_category(); |
112 | 112 | $currentcat = $categories[0]->category_id; |
113 | - if ( $currentcat != $previouscat ) { |
|
113 | + if ($currentcat != $previouscat) { |
|
114 | 114 | echo $before; |
115 | 115 | echo get_the_category_by_ID($currentcat); |
116 | 116 | echo $after; |
@@ -132,22 +132,22 @@ discard block |
||
132 | 132 | * @param int $limitprev |
133 | 133 | * @param string $excluded_categories |
134 | 134 | */ |
135 | -function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { |
|
135 | +function previous_post($format = '%', $previous = 'previous post: ', $title = 'yes', $in_same_cat = 'no', $limitprev = 1, $excluded_categories = '') { |
|
136 | 136 | |
137 | - _deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' ); |
|
137 | + _deprecated_function(__FUNCTION__, '2.0.0', 'previous_post_link()'); |
|
138 | 138 | |
139 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
139 | + if (empty($in_same_cat) || 'no' == $in_same_cat) |
|
140 | 140 | $in_same_cat = false; |
141 | 141 | else |
142 | 142 | $in_same_cat = true; |
143 | 143 | |
144 | 144 | $post = get_previous_post($in_same_cat, $excluded_categories); |
145 | 145 | |
146 | - if ( !$post ) |
|
146 | + if ( ! $post) |
|
147 | 147 | return; |
148 | 148 | |
149 | 149 | $string = '<a href="'.get_permalink($post->ID).'">'.$previous; |
150 | - if ( 'yes' == $title ) |
|
150 | + if ('yes' == $title) |
|
151 | 151 | $string .= apply_filters('the_title', $post->post_title, $post->ID); |
152 | 152 | $string .= '</a>'; |
153 | 153 | $format = str_replace('%', $string, $format); |
@@ -168,21 +168,21 @@ discard block |
||
168 | 168 | * @param int $limitnext |
169 | 169 | * @param string $excluded_categories |
170 | 170 | */ |
171 | -function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { |
|
172 | - _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' ); |
|
171 | +function next_post($format = '%', $next = 'next post: ', $title = 'yes', $in_same_cat = 'no', $limitnext = 1, $excluded_categories = '') { |
|
172 | + _deprecated_function(__FUNCTION__, '2.0.0', 'next_post_link()'); |
|
173 | 173 | |
174 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
174 | + if (empty($in_same_cat) || 'no' == $in_same_cat) |
|
175 | 175 | $in_same_cat = false; |
176 | 176 | else |
177 | 177 | $in_same_cat = true; |
178 | 178 | |
179 | 179 | $post = get_next_post($in_same_cat, $excluded_categories); |
180 | 180 | |
181 | - if ( !$post ) |
|
181 | + if ( ! $post) |
|
182 | 182 | return; |
183 | 183 | |
184 | 184 | $string = '<a href="'.get_permalink($post->ID).'">'.$next; |
185 | - if ( 'yes' == $title ) |
|
185 | + if ('yes' == $title) |
|
186 | 186 | $string .= apply_filters('the_title', $post->post_title, $post->ID); |
187 | 187 | $string .= '</a>'; |
188 | 188 | $format = str_replace('%', $string, $format); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return bool |
203 | 203 | */ |
204 | 204 | function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { |
205 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
205 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
206 | 206 | |
207 | 207 | $author_data = get_userdata($user_id); |
208 | 208 | return ($author_data->user_level > 1); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return bool |
222 | 222 | */ |
223 | 223 | function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { |
224 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
224 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
225 | 225 | |
226 | 226 | $author_data = get_userdata($user_id); |
227 | 227 | return ($author_data->user_level >= 1); |
@@ -240,15 +240,15 @@ discard block |
||
240 | 240 | * @return bool |
241 | 241 | */ |
242 | 242 | function user_can_edit_post($user_id, $post_id, $blog_id = 1) { |
243 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
243 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
244 | 244 | |
245 | 245 | $author_data = get_userdata($user_id); |
246 | 246 | $post = get_post($post_id); |
247 | 247 | $post_author_data = get_userdata($post->post_author); |
248 | 248 | |
249 | - if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) |
|
249 | + if ((($user_id == $post_author_data->ID) && ! ($post->post_status == 'publish' && $author_data->user_level < 2)) |
|
250 | 250 | || ($author_data->user_level > $post_author_data->user_level) |
251 | - || ($author_data->user_level >= 10) ) { |
|
251 | + || ($author_data->user_level >= 10)) { |
|
252 | 252 | return true; |
253 | 253 | } else { |
254 | 254 | return false; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return bool |
269 | 269 | */ |
270 | 270 | function user_can_delete_post($user_id, $post_id, $blog_id = 1) { |
271 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
271 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
272 | 272 | |
273 | 273 | // right now if one can edit, one can delete |
274 | 274 | return user_can_edit_post($user_id, $post_id, $blog_id); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @return bool |
288 | 288 | */ |
289 | 289 | function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { |
290 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
290 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
291 | 291 | |
292 | 292 | $author_data = get_userdata($user_id); |
293 | 293 | return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @return bool returns true if $user_id can edit $post_id's date |
307 | 307 | */ |
308 | 308 | function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { |
309 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
309 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
310 | 310 | |
311 | 311 | $author_data = get_userdata($user_id); |
312 | 312 | return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * @return bool returns true if $user_id can edit $post_id's comments |
326 | 326 | */ |
327 | 327 | function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { |
328 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
328 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
329 | 329 | |
330 | 330 | // right now if one can edit a post, one can edit comments made on it |
331 | 331 | return user_can_edit_post($user_id, $post_id, $blog_id); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @return bool returns true if $user_id can delete $post_id's comments |
345 | 345 | */ |
346 | 346 | function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { |
347 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
347 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
348 | 348 | |
349 | 349 | // right now if one can edit comments, one can delete comments |
350 | 350 | return user_can_edit_post_comments($user_id, $post_id, $blog_id); |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | * @return bool |
363 | 363 | */ |
364 | 364 | function user_can_edit_user($user_id, $other_user) { |
365 | - _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
|
365 | + _deprecated_function(__FUNCTION__, '2.0.0', 'current_user_can()'); |
|
366 | 366 | |
367 | 367 | $user = get_userdata($user_id); |
368 | 368 | $other = get_userdata($other_user); |
369 | - if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) |
|
369 | + if ($user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID) |
|
370 | 370 | return true; |
371 | 371 | else |
372 | 372 | return false; |
@@ -395,11 +395,11 @@ discard block |
||
395 | 395 | function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id', |
396 | 396 | $show_description = true, $show_rating = false, |
397 | 397 | $limit = -1, $show_updated = 0) { |
398 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
|
398 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_bookmarks()'); |
|
399 | 399 | |
400 | 400 | $cat_id = -1; |
401 | 401 | $cat = get_term_by('name', $cat_name, 'link_category'); |
402 | - if ( $cat ) |
|
402 | + if ($cat) |
|
403 | 403 | $cat_id = $cat->term_id; |
404 | 404 | |
405 | 405 | get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | 'title_li' => '', |
431 | 431 | ); |
432 | 432 | |
433 | - $r = wp_parse_args( $args, $defaults ); |
|
433 | + $r = wp_parse_args($args, $defaults); |
|
434 | 434 | |
435 | 435 | return wp_list_bookmarks($r); |
436 | 436 | } |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | * @param int $limit Limit to X entries. If not specified, all entries are shown. |
455 | 455 | * @return array |
456 | 456 | */ |
457 | -function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { |
|
458 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
|
457 | +function get_linkobjectsbyname($cat_name = "noname", $orderby = 'name', $limit = -1) { |
|
458 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_bookmarks()'); |
|
459 | 459 | |
460 | 460 | $cat_id = -1; |
461 | 461 | $cat = get_term_by('name', $cat_name, 'link_category'); |
462 | - if ( $cat ) |
|
462 | + if ($cat) |
|
463 | 463 | $cat_id = $cat->term_id; |
464 | 464 | |
465 | 465 | return get_linkobjects($cat_id, $orderby, $limit); |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | * @return array |
507 | 507 | */ |
508 | 508 | function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { |
509 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
|
509 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_bookmarks()'); |
|
510 | 510 | |
511 | - $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; |
|
511 | + $links = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'limit' => $limit)); |
|
512 | 512 | |
513 | 513 | $links_array = array(); |
514 | 514 | foreach ($links as $link) |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ", |
541 | 541 | $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { |
542 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
|
542 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_bookmarks()'); |
|
543 | 543 | |
544 | 544 | get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); |
545 | 545 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | */ |
567 | 567 | function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true, |
568 | 568 | $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { |
569 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
|
569 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_bookmarks()'); |
|
570 | 570 | |
571 | 571 | get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); |
572 | 572 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return int Only returns 0. |
582 | 582 | */ |
583 | 583 | function get_autotoggle($id = 0) { |
584 | - _deprecated_function( __FUNCTION__, '2.1.0' ); |
|
584 | + _deprecated_function(__FUNCTION__, '2.1.0'); |
|
585 | 585 | return 0; |
586 | 586 | } |
587 | 587 | |
@@ -613,9 +613,9 @@ discard block |
||
613 | 613 | * @return false|null |
614 | 614 | */ |
615 | 615 | function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, |
616 | - $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, |
|
617 | - $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { |
|
618 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); |
|
616 | + $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children = false, $child_of = 0, $categories = 0, |
|
617 | + $recurse = 0, $feed = '', $feed_image = '', $exclude = '', $hierarchical = false) { |
|
618 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_categories()'); |
|
619 | 619 | |
620 | 620 | $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', |
621 | 621 | 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); |
@@ -633,22 +633,22 @@ discard block |
||
633 | 633 | * @return false|null|string |
634 | 634 | */ |
635 | 635 | function wp_list_cats($args = '') { |
636 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); |
|
636 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_categories()'); |
|
637 | 637 | |
638 | - $r = wp_parse_args( $args ); |
|
638 | + $r = wp_parse_args($args); |
|
639 | 639 | |
640 | 640 | // Map to new names. |
641 | - if ( isset($r['optionall']) && isset($r['all'])) |
|
641 | + if (isset($r['optionall']) && isset($r['all'])) |
|
642 | 642 | $r['show_option_all'] = $r['all']; |
643 | - if ( isset($r['sort_column']) ) |
|
643 | + if (isset($r['sort_column'])) |
|
644 | 644 | $r['orderby'] = $r['sort_column']; |
645 | - if ( isset($r['sort_order']) ) |
|
645 | + if (isset($r['sort_order'])) |
|
646 | 646 | $r['order'] = $r['sort_order']; |
647 | - if ( isset($r['optiondates']) ) |
|
647 | + if (isset($r['optiondates'])) |
|
648 | 648 | $r['show_last_update'] = $r['optiondates']; |
649 | - if ( isset($r['optioncount']) ) |
|
649 | + if (isset($r['optioncount'])) |
|
650 | 650 | $r['show_count'] = $r['optioncount']; |
651 | - if ( isset($r['list']) ) |
|
651 | + if (isset($r['list'])) |
|
652 | 652 | $r['style'] = $r['list'] ? 'list' : 'break'; |
653 | 653 | $r['title_li'] = ''; |
654 | 654 | |
@@ -677,14 +677,14 @@ discard block |
||
677 | 677 | function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', |
678 | 678 | $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, |
679 | 679 | $selected = 0, $exclude = 0) { |
680 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' ); |
|
680 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_dropdown_categories()'); |
|
681 | 681 | |
682 | 682 | $show_option_all = ''; |
683 | - if ( $optionall ) |
|
683 | + if ($optionall) |
|
684 | 684 | $show_option_all = $all; |
685 | 685 | |
686 | 686 | $show_option_none = ''; |
687 | - if ( $optionnone ) |
|
687 | + if ($optionnone) |
|
688 | 688 | $show_option_none = __('None'); |
689 | 689 | |
690 | 690 | $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * @return null|string |
710 | 710 | */ |
711 | 711 | function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { |
712 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_authors()' ); |
|
712 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_authors()'); |
|
713 | 713 | |
714 | 714 | $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); |
715 | 715 | return wp_list_authors($args); |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @return array |
728 | 728 | */ |
729 | 729 | function wp_get_post_cats($blogid = '1', $post_ID = 0) { |
730 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' ); |
|
730 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_get_post_categories()'); |
|
731 | 731 | return wp_get_post_categories($post_ID); |
732 | 732 | } |
733 | 733 | |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | * @return bool|mixed |
746 | 746 | */ |
747 | 747 | function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { |
748 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' ); |
|
748 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_set_post_categories()'); |
|
749 | 749 | return wp_set_post_categories($post_ID, $post_categories); |
750 | 750 | } |
751 | 751 | |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | * @param bool $show_post_count |
765 | 765 | * @return string|null |
766 | 766 | */ |
767 | -function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { |
|
768 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' ); |
|
767 | +function get_archives($type = '', $limit = '', $format = 'html', $before = '', $after = '', $show_post_count = false) { |
|
768 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_get_archives()'); |
|
769 | 769 | $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); |
770 | 770 | return wp_get_archives($args); |
771 | 771 | } |
@@ -783,11 +783,11 @@ discard block |
||
783 | 783 | * @return string|null |
784 | 784 | */ |
785 | 785 | function get_author_link($echo, $author_id, $author_nicename = '') { |
786 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' ); |
|
786 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_author_posts_url()'); |
|
787 | 787 | |
788 | 788 | $link = get_author_posts_url($author_id, $author_nicename); |
789 | 789 | |
790 | - if ( $echo ) |
|
790 | + if ($echo) |
|
791 | 791 | echo $link; |
792 | 792 | return $link; |
793 | 793 | } |
@@ -808,9 +808,9 @@ discard block |
||
808 | 808 | * @param string $more_file |
809 | 809 | * @return string |
810 | 810 | */ |
811 | -function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', |
|
812 | - $pagelink='%', $more_file='') { |
|
813 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_link_pages()' ); |
|
811 | +function link_pages($before = '<br />', $after = '<br />', $next_or_number = 'number', $nextpagelink = 'next page', $previouspagelink = 'previous page', |
|
812 | + $pagelink = '%', $more_file = '') { |
|
813 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_link_pages()'); |
|
814 | 814 | |
815 | 815 | $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); |
816 | 816 | return wp_link_pages($args); |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | * @return string |
828 | 828 | */ |
829 | 829 | function get_settings($option) { |
830 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_option()' ); |
|
830 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_option()'); |
|
831 | 831 | |
832 | 832 | return get_option($option); |
833 | 833 | } |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @see the_permalink() |
841 | 841 | */ |
842 | 842 | function permalink_link() { |
843 | - _deprecated_function( __FUNCTION__, '1.2.0', 'the_permalink()' ); |
|
843 | + _deprecated_function(__FUNCTION__, '1.2.0', 'the_permalink()'); |
|
844 | 844 | the_permalink(); |
845 | 845 | } |
846 | 846 | |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | * @param string $deprecated |
855 | 855 | */ |
856 | 856 | function permalink_single_rss($deprecated = '') { |
857 | - _deprecated_function( __FUNCTION__, '2.3.0', 'the_permalink_rss()' ); |
|
857 | + _deprecated_function(__FUNCTION__, '2.3.0', 'the_permalink_rss()'); |
|
858 | 858 | the_permalink_rss(); |
859 | 859 | } |
860 | 860 | |
@@ -869,11 +869,11 @@ discard block |
||
869 | 869 | * @return null|string |
870 | 870 | */ |
871 | 871 | function wp_get_links($args = '') { |
872 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); |
|
872 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()'); |
|
873 | 873 | |
874 | - if ( strpos( $args, '=' ) === false ) { |
|
874 | + if (strpos($args, '=') === false) { |
|
875 | 875 | $cat_id = $args; |
876 | - $args = add_query_arg( 'category', $cat_id, $args ); |
|
876 | + $args = add_query_arg('category', $cat_id, $args); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | $defaults = array( |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | 'title_li' => '', |
893 | 893 | ); |
894 | 894 | |
895 | - $r = wp_parse_args( $args, $defaults ); |
|
895 | + $r = wp_parse_args($args, $defaults); |
|
896 | 896 | |
897 | 897 | return wp_list_bookmarks($r); |
898 | 898 | } |
@@ -923,81 +923,81 @@ discard block |
||
923 | 923 | */ |
924 | 924 | function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name', |
925 | 925 | $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) { |
926 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
|
926 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_bookmarks()'); |
|
927 | 927 | |
928 | 928 | $order = 'ASC'; |
929 | - if ( substr($orderby, 0, 1) == '_' ) { |
|
929 | + if (substr($orderby, 0, 1) == '_') { |
|
930 | 930 | $order = 'DESC'; |
931 | 931 | $orderby = substr($orderby, 1); |
932 | 932 | } |
933 | 933 | |
934 | - if ( $category == -1 ) //get_bookmarks uses '' to signify all categories |
|
934 | + if ($category == -1) //get_bookmarks uses '' to signify all categories |
|
935 | 935 | $category = ''; |
936 | 936 | |
937 | 937 | $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); |
938 | 938 | |
939 | - if ( !$results ) |
|
939 | + if ( ! $results) |
|
940 | 940 | return; |
941 | 941 | |
942 | 942 | $output = ''; |
943 | 943 | |
944 | - foreach ( (array) $results as $row ) { |
|
945 | - if ( !isset($row->recently_updated) ) |
|
944 | + foreach ((array) $results as $row) { |
|
945 | + if ( ! isset($row->recently_updated)) |
|
946 | 946 | $row->recently_updated = false; |
947 | 947 | $output .= $before; |
948 | - if ( $show_updated && $row->recently_updated ) |
|
948 | + if ($show_updated && $row->recently_updated) |
|
949 | 949 | $output .= get_option('links_recently_updated_prepend'); |
950 | 950 | $the_link = '#'; |
951 | - if ( !empty($row->link_url) ) |
|
951 | + if ( ! empty($row->link_url)) |
|
952 | 952 | $the_link = esc_url($row->link_url); |
953 | 953 | $rel = $row->link_rel; |
954 | - if ( '' != $rel ) |
|
955 | - $rel = ' rel="' . $rel . '"'; |
|
954 | + if ('' != $rel) |
|
955 | + $rel = ' rel="'.$rel.'"'; |
|
956 | 956 | |
957 | 957 | $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); |
958 | 958 | $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); |
959 | 959 | $title = $desc; |
960 | 960 | |
961 | - if ( $show_updated ) |
|
961 | + if ($show_updated) |
|
962 | 962 | if (substr($row->link_updated_f, 0, 2) != '00') |
963 | - $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; |
|
963 | + $title .= ' ('.__('Last updated').' '.date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)).')'; |
|
964 | 964 | |
965 | - if ( '' != $title ) |
|
966 | - $title = ' title="' . $title . '"'; |
|
965 | + if ('' != $title) |
|
966 | + $title = ' title="'.$title.'"'; |
|
967 | 967 | |
968 | - $alt = ' alt="' . $name . '"'; |
|
968 | + $alt = ' alt="'.$name.'"'; |
|
969 | 969 | |
970 | 970 | $target = $row->link_target; |
971 | - if ( '' != $target ) |
|
972 | - $target = ' target="' . $target . '"'; |
|
971 | + if ('' != $target) |
|
972 | + $target = ' target="'.$target.'"'; |
|
973 | 973 | |
974 | - $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; |
|
974 | + $output .= '<a href="'.$the_link.'"'.$rel.$title.$target.'>'; |
|
975 | 975 | |
976 | - if ( $row->link_image != null && $show_images ) { |
|
977 | - if ( strpos($row->link_image, 'http') !== false ) |
|
976 | + if ($row->link_image != null && $show_images) { |
|
977 | + if (strpos($row->link_image, 'http') !== false) |
|
978 | 978 | $output .= "<img src=\"$row->link_image\" $alt $title />"; |
979 | 979 | else // If it's a relative path |
980 | - $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; |
|
980 | + $output .= "<img src=\"".get_option('siteurl')."$row->link_image\" $alt $title />"; |
|
981 | 981 | } else { |
982 | 982 | $output .= $name; |
983 | 983 | } |
984 | 984 | |
985 | 985 | $output .= '</a>'; |
986 | 986 | |
987 | - if ( $show_updated && $row->recently_updated ) |
|
987 | + if ($show_updated && $row->recently_updated) |
|
988 | 988 | $output .= get_option('links_recently_updated_append'); |
989 | 989 | |
990 | - if ( $show_description && '' != $desc ) |
|
991 | - $output .= $between . $desc; |
|
990 | + if ($show_description && '' != $desc) |
|
991 | + $output .= $between.$desc; |
|
992 | 992 | |
993 | 993 | if ($show_rating) { |
994 | - $output .= $between . get_linkrating($row); |
|
994 | + $output .= $between.get_linkrating($row); |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | $output .= "$after\n"; |
998 | 998 | } // end while |
999 | 999 | |
1000 | - if ( !$echo ) |
|
1000 | + if ( ! $echo) |
|
1001 | 1001 | return $output; |
1002 | 1002 | echo $output; |
1003 | 1003 | } |
@@ -1015,29 +1015,29 @@ discard block |
||
1015 | 1015 | * @param string $order Sort link categories by 'name' or 'id' |
1016 | 1016 | */ |
1017 | 1017 | function get_links_list($order = 'name') { |
1018 | - _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); |
|
1018 | + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()'); |
|
1019 | 1019 | |
1020 | 1020 | $order = strtolower($order); |
1021 | 1021 | |
1022 | 1022 | // Handle link category sorting |
1023 | 1023 | $direction = 'ASC'; |
1024 | - if ( '_' == substr($order,0,1) ) { |
|
1024 | + if ('_' == substr($order, 0, 1)) { |
|
1025 | 1025 | $direction = 'DESC'; |
1026 | - $order = substr($order,1); |
|
1026 | + $order = substr($order, 1); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | - if ( !isset($direction) ) |
|
1029 | + if ( ! isset($direction)) |
|
1030 | 1030 | $direction = ''; |
1031 | 1031 | |
1032 | 1032 | $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); |
1033 | 1033 | |
1034 | 1034 | // Display each category |
1035 | - if ( $cats ) { |
|
1036 | - foreach ( (array) $cats as $cat ) { |
|
1035 | + if ($cats) { |
|
1036 | + foreach ((array) $cats as $cat) { |
|
1037 | 1037 | // Handle each category. |
1038 | 1038 | |
1039 | 1039 | // Display the category name |
1040 | - echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; |
|
1040 | + echo ' <li id="linkcat-'.$cat->term_id.'" class="linkcat"><h2>'.apply_filters('link_category', $cat->name)."</h2>\n\t<ul>\n"; |
|
1041 | 1041 | // Call get_links() with all the appropriate params |
1042 | 1042 | get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); |
1043 | 1043 | |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | * @param string $file the page to open in the popup window |
1060 | 1060 | * @param bool $count the number of links in the db |
1061 | 1061 | */ |
1062 | -function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { |
|
1063 | - _deprecated_function( __FUNCTION__, '2.1.0' ); |
|
1062 | +function links_popup_script($text = 'Links', $width = 400, $height = 400, $file = 'links.all.php', $count = true) { |
|
1063 | + _deprecated_function(__FUNCTION__, '2.1.0'); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | /** |
@@ -1073,8 +1073,8 @@ discard block |
||
1073 | 1073 | * @param object $link Link object. |
1074 | 1074 | * @return mixed Value of the 'link_rating' field, false otherwise. |
1075 | 1075 | */ |
1076 | -function get_linkrating( $link ) { |
|
1077 | - _deprecated_function( __FUNCTION__, '2.1.0', 'sanitize_bookmark_field()' ); |
|
1076 | +function get_linkrating($link) { |
|
1077 | + _deprecated_function(__FUNCTION__, '2.1.0', 'sanitize_bookmark_field()'); |
|
1078 | 1078 | return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); |
1079 | 1079 | } |
1080 | 1080 | |
@@ -1089,16 +1089,16 @@ discard block |
||
1089 | 1089 | * @return string |
1090 | 1090 | */ |
1091 | 1091 | function get_linkcatname($id = 0) { |
1092 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' ); |
|
1092 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_category()'); |
|
1093 | 1093 | |
1094 | 1094 | $id = (int) $id; |
1095 | 1095 | |
1096 | - if ( empty($id) ) |
|
1096 | + if (empty($id)) |
|
1097 | 1097 | return ''; |
1098 | 1098 | |
1099 | 1099 | $cats = wp_get_link_cats($id); |
1100 | 1100 | |
1101 | - if ( empty($cats) || ! is_array($cats) ) |
|
1101 | + if (empty($cats) || ! is_array($cats)) |
|
1102 | 1102 | return ''; |
1103 | 1103 | |
1104 | 1104 | $cat_id = (int) $cats[0]; // Take the first cat. |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | * @param string $link_text |
1118 | 1118 | */ |
1119 | 1119 | function comments_rss_link($link_text = 'Comments RSS') { |
1120 | - _deprecated_function( __FUNCTION__, '2.5.0', 'post_comments_feed_link()' ); |
|
1120 | + _deprecated_function(__FUNCTION__, '2.5.0', 'post_comments_feed_link()'); |
|
1121 | 1121 | post_comments_feed_link($link_text); |
1122 | 1122 | } |
1123 | 1123 | |
@@ -1133,11 +1133,11 @@ discard block |
||
1133 | 1133 | * @return string |
1134 | 1134 | */ |
1135 | 1135 | function get_category_rss_link($echo = false, $cat_ID = 1) { |
1136 | - _deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' ); |
|
1136 | + _deprecated_function(__FUNCTION__, '2.5.0', 'get_category_feed_link()'); |
|
1137 | 1137 | |
1138 | 1138 | $link = get_category_feed_link($cat_ID, 'rss2'); |
1139 | 1139 | |
1140 | - if ( $echo ) |
|
1140 | + if ($echo) |
|
1141 | 1141 | echo $link; |
1142 | 1142 | return $link; |
1143 | 1143 | } |
@@ -1154,10 +1154,10 @@ discard block |
||
1154 | 1154 | * @return string |
1155 | 1155 | */ |
1156 | 1156 | function get_author_rss_link($echo = false, $author_id = 1) { |
1157 | - _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' ); |
|
1157 | + _deprecated_function(__FUNCTION__, '2.5.0', 'get_author_feed_link()'); |
|
1158 | 1158 | |
1159 | 1159 | $link = get_author_feed_link($author_id); |
1160 | - if ( $echo ) |
|
1160 | + if ($echo) |
|
1161 | 1161 | echo $link; |
1162 | 1162 | return $link; |
1163 | 1163 | } |
@@ -1172,8 +1172,8 @@ discard block |
||
1172 | 1172 | * @return string |
1173 | 1173 | */ |
1174 | 1174 | function comments_rss() { |
1175 | - _deprecated_function( __FUNCTION__, '2.2.0', 'get_post_comments_feed_link()' ); |
|
1176 | - return esc_url( get_post_comments_feed_link() ); |
|
1175 | + _deprecated_function(__FUNCTION__, '2.2.0', 'get_post_comments_feed_link()'); |
|
1176 | + return esc_url(get_post_comments_feed_link()); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | /** |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | * @return int The new user's ID. |
1190 | 1190 | */ |
1191 | 1191 | function create_user($username, $password, $email) { |
1192 | - _deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' ); |
|
1192 | + _deprecated_function(__FUNCTION__, '2.0.0', 'wp_create_user()'); |
|
1193 | 1193 | return wp_create_user($username, $password, $email); |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | * @deprecated 2.5.0 |
1200 | 1200 | */ |
1201 | 1201 | function gzip_compression() { |
1202 | - _deprecated_function( __FUNCTION__, '2.5.0' ); |
|
1202 | + _deprecated_function(__FUNCTION__, '2.5.0'); |
|
1203 | 1203 | return false; |
1204 | 1204 | } |
1205 | 1205 | |
@@ -1215,8 +1215,8 @@ discard block |
||
1215 | 1215 | * @param bool $include_unapproved Whether to include unapproved comments |
1216 | 1216 | * @return array The comment data |
1217 | 1217 | */ |
1218 | -function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { |
|
1219 | - _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' ); |
|
1218 | +function get_commentdata($comment_ID, $no_cache = 0, $include_unapproved = false) { |
|
1219 | + _deprecated_function(__FUNCTION__, '2.7.0', 'get_comment()'); |
|
1220 | 1220 | return get_comment($comment_ID, ARRAY_A); |
1221 | 1221 | } |
1222 | 1222 | |
@@ -1230,9 +1230,9 @@ discard block |
||
1230 | 1230 | * @param int $cat_ID Category ID |
1231 | 1231 | * @return string category name |
1232 | 1232 | */ |
1233 | -function get_catname( $cat_ID ) { |
|
1234 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_cat_name()' ); |
|
1235 | - return get_cat_name( $cat_ID ); |
|
1233 | +function get_catname($cat_ID) { |
|
1234 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_cat_name()'); |
|
1235 | + return get_cat_name($cat_ID); |
|
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | /** |
@@ -1248,25 +1248,25 @@ discard block |
||
1248 | 1248 | * @param array $visited Optional. Category Term IDs that have already been added. |
1249 | 1249 | * @return string |
1250 | 1250 | */ |
1251 | -function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { |
|
1252 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' ); |
|
1253 | - if ( 0 == $id ) |
|
1251 | +function get_category_children($id, $before = '/', $after = '', $visited = array()) { |
|
1252 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_term_children()'); |
|
1253 | + if (0 == $id) |
|
1254 | 1254 | return ''; |
1255 | 1255 | |
1256 | 1256 | $chain = ''; |
1257 | 1257 | /** TODO: consult hierarchy */ |
1258 | 1258 | $cat_ids = get_all_category_ids(); |
1259 | - foreach ( (array) $cat_ids as $cat_id ) { |
|
1260 | - if ( $cat_id == $id ) |
|
1259 | + foreach ((array) $cat_ids as $cat_id) { |
|
1260 | + if ($cat_id == $id) |
|
1261 | 1261 | continue; |
1262 | 1262 | |
1263 | - $category = get_category( $cat_id ); |
|
1264 | - if ( is_wp_error( $category ) ) |
|
1263 | + $category = get_category($cat_id); |
|
1264 | + if (is_wp_error($category)) |
|
1265 | 1265 | return $category; |
1266 | - if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { |
|
1266 | + if ($category->parent == $id && ! in_array($category->term_id, $visited)) { |
|
1267 | 1267 | $visited[] = $category->term_id; |
1268 | 1268 | $chain .= $before.$category->term_id.$after; |
1269 | - $chain .= get_category_children( $category->term_id, $before, $after ); |
|
1269 | + $chain .= get_category_children($category->term_id, $before, $after); |
|
1270 | 1270 | } |
1271 | 1271 | } |
1272 | 1272 | return $chain; |
@@ -1284,11 +1284,11 @@ discard block |
||
1284 | 1284 | * @return object List of all of the category IDs. |
1285 | 1285 | */ |
1286 | 1286 | function get_all_category_ids() { |
1287 | - _deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' ); |
|
1287 | + _deprecated_function(__FUNCTION__, '4.0.0', 'get_terms()'); |
|
1288 | 1288 | |
1289 | - if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) { |
|
1290 | - $cat_ids = get_terms( 'category', array('fields' => 'ids', 'get' => 'all') ); |
|
1291 | - wp_cache_add( 'all_category_ids', $cat_ids, 'category' ); |
|
1289 | + if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category')) { |
|
1290 | + $cat_ids = get_terms('category', array('fields' => 'ids', 'get' => 'all')); |
|
1291 | + wp_cache_add('all_category_ids', $cat_ids, 'category'); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | return $cat_ids; |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | * @return string The author's description. |
1305 | 1305 | */ |
1306 | 1306 | function get_the_author_description() { |
1307 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' ); |
|
1307 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')'); |
|
1308 | 1308 | return get_the_author_meta('description'); |
1309 | 1309 | } |
1310 | 1310 | |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | * @see the_author_meta() |
1317 | 1317 | */ |
1318 | 1318 | function the_author_description() { |
1319 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' ); |
|
1319 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'description\')'); |
|
1320 | 1320 | the_author_meta('description'); |
1321 | 1321 | } |
1322 | 1322 | |
@@ -1330,7 +1330,7 @@ discard block |
||
1330 | 1330 | * @return string The author's login name (username). |
1331 | 1331 | */ |
1332 | 1332 | function get_the_author_login() { |
1333 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' ); |
|
1333 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')'); |
|
1334 | 1334 | return get_the_author_meta('login'); |
1335 | 1335 | } |
1336 | 1336 | |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | * @see the_author_meta() |
1343 | 1343 | */ |
1344 | 1344 | function the_author_login() { |
1345 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' ); |
|
1345 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'login\')'); |
|
1346 | 1346 | the_author_meta('login'); |
1347 | 1347 | } |
1348 | 1348 | |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | * @return string The author's first name. |
1357 | 1357 | */ |
1358 | 1358 | function get_the_author_firstname() { |
1359 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' ); |
|
1359 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')'); |
|
1360 | 1360 | return get_the_author_meta('first_name'); |
1361 | 1361 | } |
1362 | 1362 | |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | * @see the_author_meta() |
1369 | 1369 | */ |
1370 | 1370 | function the_author_firstname() { |
1371 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' ); |
|
1371 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')'); |
|
1372 | 1372 | the_author_meta('first_name'); |
1373 | 1373 | } |
1374 | 1374 | |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | * @return string The author's last name. |
1383 | 1383 | */ |
1384 | 1384 | function get_the_author_lastname() { |
1385 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' ); |
|
1385 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')'); |
|
1386 | 1386 | return get_the_author_meta('last_name'); |
1387 | 1387 | } |
1388 | 1388 | |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | * @see the_author_meta() |
1395 | 1395 | */ |
1396 | 1396 | function the_author_lastname() { |
1397 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' ); |
|
1397 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')'); |
|
1398 | 1398 | the_author_meta('last_name'); |
1399 | 1399 | } |
1400 | 1400 | |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | * @return string The author's nickname. |
1409 | 1409 | */ |
1410 | 1410 | function get_the_author_nickname() { |
1411 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' ); |
|
1411 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')'); |
|
1412 | 1412 | return get_the_author_meta('nickname'); |
1413 | 1413 | } |
1414 | 1414 | |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | * @see the_author_meta() |
1421 | 1421 | */ |
1422 | 1422 | function the_author_nickname() { |
1423 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' ); |
|
1423 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')'); |
|
1424 | 1424 | the_author_meta('nickname'); |
1425 | 1425 | } |
1426 | 1426 | |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | * @return string The author's username. |
1435 | 1435 | */ |
1436 | 1436 | function get_the_author_email() { |
1437 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' ); |
|
1437 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')'); |
|
1438 | 1438 | return get_the_author_meta('email'); |
1439 | 1439 | } |
1440 | 1440 | |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | * @see the_author_meta() |
1447 | 1447 | */ |
1448 | 1448 | function the_author_email() { |
1449 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' ); |
|
1449 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'email\')'); |
|
1450 | 1450 | the_author_meta('email'); |
1451 | 1451 | } |
1452 | 1452 | |
@@ -1460,7 +1460,7 @@ discard block |
||
1460 | 1460 | * @return string The author's ICQ number. |
1461 | 1461 | */ |
1462 | 1462 | function get_the_author_icq() { |
1463 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' ); |
|
1463 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')'); |
|
1464 | 1464 | return get_the_author_meta('icq'); |
1465 | 1465 | } |
1466 | 1466 | |
@@ -1472,7 +1472,7 @@ discard block |
||
1472 | 1472 | * @see the_author_meta() |
1473 | 1473 | */ |
1474 | 1474 | function the_author_icq() { |
1475 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' ); |
|
1475 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')'); |
|
1476 | 1476 | the_author_meta('icq'); |
1477 | 1477 | } |
1478 | 1478 | |
@@ -1486,7 +1486,7 @@ discard block |
||
1486 | 1486 | * @return string The author's Yahoo! IM name. |
1487 | 1487 | */ |
1488 | 1488 | function get_the_author_yim() { |
1489 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' ); |
|
1489 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')'); |
|
1490 | 1490 | return get_the_author_meta('yim'); |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1498,7 +1498,7 @@ discard block |
||
1498 | 1498 | * @see the_author_meta() |
1499 | 1499 | */ |
1500 | 1500 | function the_author_yim() { |
1501 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' ); |
|
1501 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')'); |
|
1502 | 1502 | the_author_meta('yim'); |
1503 | 1503 | } |
1504 | 1504 | |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | * @return string The author's MSN address. |
1513 | 1513 | */ |
1514 | 1514 | function get_the_author_msn() { |
1515 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' ); |
|
1515 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')'); |
|
1516 | 1516 | return get_the_author_meta('msn'); |
1517 | 1517 | } |
1518 | 1518 | |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | * @see the_author_meta() |
1525 | 1525 | */ |
1526 | 1526 | function the_author_msn() { |
1527 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' ); |
|
1527 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')'); |
|
1528 | 1528 | the_author_meta('msn'); |
1529 | 1529 | } |
1530 | 1530 | |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | * @return string The author's AIM address. |
1539 | 1539 | */ |
1540 | 1540 | function get_the_author_aim() { |
1541 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' ); |
|
1541 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')'); |
|
1542 | 1542 | return get_the_author_meta('aim'); |
1543 | 1543 | } |
1544 | 1544 | |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | * @see the_author_meta() |
1551 | 1551 | */ |
1552 | 1552 | function the_author_aim() { |
1553 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' ); |
|
1553 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')'); |
|
1554 | 1554 | the_author_meta('aim'); |
1555 | 1555 | } |
1556 | 1556 | |
@@ -1564,8 +1564,8 @@ discard block |
||
1564 | 1564 | * @param int $auth_id The ID of the author. |
1565 | 1565 | * @return string The author's display name. |
1566 | 1566 | */ |
1567 | -function get_author_name( $auth_id = false ) { |
|
1568 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' ); |
|
1567 | +function get_author_name($auth_id = false) { |
|
1568 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')'); |
|
1569 | 1569 | return get_the_author_meta('display_name', $auth_id); |
1570 | 1570 | } |
1571 | 1571 | |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | * @return string The URL to the author's page. |
1580 | 1580 | */ |
1581 | 1581 | function get_the_author_url() { |
1582 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' ); |
|
1582 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')'); |
|
1583 | 1583 | return get_the_author_meta('url'); |
1584 | 1584 | } |
1585 | 1585 | |
@@ -1591,7 +1591,7 @@ discard block |
||
1591 | 1591 | * @see the_author_meta() |
1592 | 1592 | */ |
1593 | 1593 | function the_author_url() { |
1594 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' ); |
|
1594 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'url\')'); |
|
1595 | 1595 | the_author_meta('url'); |
1596 | 1596 | } |
1597 | 1597 | |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | * @return string|int The author's ID. |
1606 | 1606 | */ |
1607 | 1607 | function get_the_author_ID() { |
1608 | - _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' ); |
|
1608 | + _deprecated_function(__FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')'); |
|
1609 | 1609 | return get_the_author_meta('ID'); |
1610 | 1610 | } |
1611 | 1611 | |
@@ -1617,7 +1617,7 @@ discard block |
||
1617 | 1617 | * @see the_author_meta() |
1618 | 1618 | */ |
1619 | 1619 | function the_author_ID() { |
1620 | - _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' ); |
|
1620 | + _deprecated_function(__FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')'); |
|
1621 | 1621 | the_author_meta('ID'); |
1622 | 1622 | } |
1623 | 1623 | |
@@ -1649,23 +1649,23 @@ discard block |
||
1649 | 1649 | * @param int $cut Optional. Amount of words to keep for the content. |
1650 | 1650 | * @param int $encode_html Optional. How to encode the content. |
1651 | 1651 | */ |
1652 | -function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { |
|
1653 | - _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed' ); |
|
1652 | +function the_content_rss($more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $cut = 0, $encode_html = 0) { |
|
1653 | + _deprecated_function(__FUNCTION__, '2.9.0', 'the_content_feed'); |
|
1654 | 1654 | $content = get_the_content($more_link_text, $stripteaser); |
1655 | 1655 | $content = apply_filters('the_content_rss', $content); |
1656 | - if ( $cut && !$encode_html ) |
|
1656 | + if ($cut && ! $encode_html) |
|
1657 | 1657 | $encode_html = 2; |
1658 | - if ( 1== $encode_html ) { |
|
1658 | + if (1 == $encode_html) { |
|
1659 | 1659 | $content = esc_html($content); |
1660 | 1660 | $cut = 0; |
1661 | - } elseif ( 0 == $encode_html ) { |
|
1661 | + } elseif (0 == $encode_html) { |
|
1662 | 1662 | $content = make_url_footnote($content); |
1663 | - } elseif ( 2 == $encode_html ) { |
|
1663 | + } elseif (2 == $encode_html) { |
|
1664 | 1664 | $content = strip_tags($content); |
1665 | 1665 | } |
1666 | - if ( $cut ) { |
|
1666 | + if ($cut) { |
|
1667 | 1667 | $blah = explode(' ', $content); |
1668 | - if ( count($blah) > $cut ) { |
|
1668 | + if (count($blah) > $cut) { |
|
1669 | 1669 | $k = $cut; |
1670 | 1670 | $use_dotdotdot = 1; |
1671 | 1671 | } else { |
@@ -1674,7 +1674,7 @@ discard block |
||
1674 | 1674 | } |
1675 | 1675 | |
1676 | 1676 | /** @todo Check performance, might be faster to use array slice instead. */ |
1677 | - for ( $i=0; $i<$k; $i++ ) |
|
1677 | + for ($i = 0; $i < $k; $i++) |
|
1678 | 1678 | $excerpt .= $blah[$i].' '; |
1679 | 1679 | $excerpt .= ($use_dotdotdot) ? '...' : ''; |
1680 | 1680 | $content = $excerpt; |
@@ -1695,20 +1695,20 @@ discard block |
||
1695 | 1695 | * @param string $content Content to get links |
1696 | 1696 | * @return string HTML stripped out of content with links at the bottom. |
1697 | 1697 | */ |
1698 | -function make_url_footnote( $content ) { |
|
1699 | - _deprecated_function( __FUNCTION__, '2.9.0', '' ); |
|
1700 | - preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches ); |
|
1698 | +function make_url_footnote($content) { |
|
1699 | + _deprecated_function(__FUNCTION__, '2.9.0', ''); |
|
1700 | + preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches); |
|
1701 | 1701 | $links_summary = "\n"; |
1702 | - for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) { |
|
1702 | + for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { |
|
1703 | 1703 | $link_match = $matches[0][$i]; |
1704 | - $link_number = '['.($i+1).']'; |
|
1704 | + $link_number = '['.($i + 1).']'; |
|
1705 | 1705 | $link_url = $matches[2][$i]; |
1706 | 1706 | $link_text = $matches[4][$i]; |
1707 | - $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content ); |
|
1708 | - $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url; |
|
1709 | - $links_summary .= "\n" . $link_number . ' ' . $link_url; |
|
1707 | + $content = str_replace($link_match, $link_text.' '.$link_number, $content); |
|
1708 | + $link_url = ((strtolower(substr($link_url, 0, 7)) != 'http://') && (strtolower(substr($link_url, 0, 8)) != 'https://')) ? get_option('home').$link_url : $link_url; |
|
1709 | + $links_summary .= "\n".$link_number.' '.$link_url; |
|
1710 | 1710 | } |
1711 | - $content = strip_tags( $content ); |
|
1711 | + $content = strip_tags($content); |
|
1712 | 1712 | $content .= $links_summary; |
1713 | 1713 | return $content; |
1714 | 1714 | } |
@@ -1734,9 +1734,9 @@ discard block |
||
1734 | 1734 | * @param string $domain Optional. Domain to retrieve the translated text |
1735 | 1735 | * @return string Translated context string without pipe |
1736 | 1736 | */ |
1737 | -function _c( $text, $domain = 'default' ) { |
|
1738 | - _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); |
|
1739 | - return before_last_bar( translate( $text, $domain ) ); |
|
1737 | +function _c($text, $domain = 'default') { |
|
1738 | + _deprecated_function(__FUNCTION__, '2.9.0', '_x()'); |
|
1739 | + return before_last_bar(translate($text, $domain)); |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | /** |
@@ -1751,9 +1751,9 @@ discard block |
||
1751 | 1751 | * @param string $domain Domain to retrieve the translated text |
1752 | 1752 | * @return string Translated text |
1753 | 1753 | */ |
1754 | -function translate_with_context( $text, $domain = 'default' ) { |
|
1755 | - _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); |
|
1756 | - return before_last_bar( translate( $text, $domain ) ); |
|
1754 | +function translate_with_context($text, $domain = 'default') { |
|
1755 | + _deprecated_function(__FUNCTION__, '2.9.0', '_x()'); |
|
1756 | + return before_last_bar(translate($text, $domain)); |
|
1757 | 1757 | } |
1758 | 1758 | |
1759 | 1759 | /** |
@@ -1772,9 +1772,9 @@ discard block |
||
1772 | 1772 | * Default 'default'. |
1773 | 1773 | * @return string The translated singular or plural form. |
1774 | 1774 | */ |
1775 | -function _nc( $single, $plural, $number, $domain = 'default' ) { |
|
1776 | - _deprecated_function( __FUNCTION__, '2.9.0', '_nx()' ); |
|
1777 | - return before_last_bar( _n( $single, $plural, $number, $domain ) ); |
|
1775 | +function _nc($single, $plural, $number, $domain = 'default') { |
|
1776 | + _deprecated_function(__FUNCTION__, '2.9.0', '_nx()'); |
|
1777 | + return before_last_bar(_n($single, $plural, $number, $domain)); |
|
1778 | 1778 | } |
1779 | 1779 | |
1780 | 1780 | /** |
@@ -1785,7 +1785,7 @@ discard block |
||
1785 | 1785 | * @see _n() |
1786 | 1786 | */ |
1787 | 1787 | function __ngettext() { |
1788 | - _deprecated_function( __FUNCTION__, '2.8.0', '_n()' ); |
|
1788 | + _deprecated_function(__FUNCTION__, '2.8.0', '_n()'); |
|
1789 | 1789 | $args = func_get_args(); |
1790 | 1790 | return call_user_func_array('_n', $args); |
1791 | 1791 | } |
@@ -1798,7 +1798,7 @@ discard block |
||
1798 | 1798 | * @see _n_noop() |
1799 | 1799 | */ |
1800 | 1800 | function __ngettext_noop() { |
1801 | - _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' ); |
|
1801 | + _deprecated_function(__FUNCTION__, '2.8.0', '_n_noop()'); |
|
1802 | 1802 | $args = func_get_args(); |
1803 | 1803 | return call_user_func_array('_n_noop', $args); |
1804 | 1804 | |
@@ -1814,7 +1814,7 @@ discard block |
||
1814 | 1814 | * @return array List of all options. |
1815 | 1815 | */ |
1816 | 1816 | function get_alloptions() { |
1817 | - _deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' ); |
|
1817 | + _deprecated_function(__FUNCTION__, '3.0.0', 'wp_load_alloptions()'); |
|
1818 | 1818 | return wp_load_alloptions(); |
1819 | 1819 | } |
1820 | 1820 | |
@@ -1832,14 +1832,14 @@ discard block |
||
1832 | 1832 | * @return string |
1833 | 1833 | */ |
1834 | 1834 | function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { |
1835 | - _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' ); |
|
1835 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_get_attachment_link()'); |
|
1836 | 1836 | $id = (int) $id; |
1837 | 1837 | $_post = get_post($id); |
1838 | 1838 | |
1839 | - if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) |
|
1839 | + if (('attachment' != $_post->post_type) || ! $url = wp_get_attachment_url($_post->ID)) |
|
1840 | 1840 | return __('Missing Attachment'); |
1841 | 1841 | |
1842 | - if ( $permalink ) |
|
1842 | + if ($permalink) |
|
1843 | 1843 | $url = get_attachment_link($_post->ID); |
1844 | 1844 | |
1845 | 1845 | $post_title = esc_attr($_post->post_title); |
@@ -1859,31 +1859,31 @@ discard block |
||
1859 | 1859 | * @param bool $fullsize Optional, default to false. Whether to have full image. |
1860 | 1860 | * @return array Icon URL and full path to file, respectively. |
1861 | 1861 | */ |
1862 | -function get_attachment_icon_src( $id = 0, $fullsize = false ) { |
|
1863 | - _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' ); |
|
1862 | +function get_attachment_icon_src($id = 0, $fullsize = false) { |
|
1863 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()'); |
|
1864 | 1864 | $id = (int) $id; |
1865 | - if ( !$post = get_post($id) ) |
|
1865 | + if ( ! $post = get_post($id)) |
|
1866 | 1866 | return false; |
1867 | 1867 | |
1868 | - $file = get_attached_file( $post->ID ); |
|
1868 | + $file = get_attached_file($post->ID); |
|
1869 | 1869 | |
1870 | - if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { |
|
1870 | + if ( ! $fullsize && $src = wp_get_attachment_thumb_url($post->ID)) { |
|
1871 | 1871 | // We have a thumbnail desired, specified and existing |
1872 | 1872 | |
1873 | 1873 | $src_file = basename($src); |
1874 | - } elseif ( wp_attachment_is_image( $post->ID ) ) { |
|
1874 | + } elseif (wp_attachment_is_image($post->ID)) { |
|
1875 | 1875 | // We have an image without a thumbnail |
1876 | 1876 | |
1877 | - $src = wp_get_attachment_url( $post->ID ); |
|
1877 | + $src = wp_get_attachment_url($post->ID); |
|
1878 | 1878 | $src_file = & $file; |
1879 | - } elseif ( $src = wp_mime_type_icon( $post->ID ) ) { |
|
1879 | + } elseif ($src = wp_mime_type_icon($post->ID)) { |
|
1880 | 1880 | // No thumb, no image. We'll look for a mime-related icon instead. |
1881 | 1881 | |
1882 | - $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); |
|
1883 | - $src_file = $icon_dir . '/' . basename($src); |
|
1882 | + $icon_dir = apply_filters('icon_dir', get_template_directory().'/images'); |
|
1883 | + $src_file = $icon_dir.'/'.basename($src); |
|
1884 | 1884 | } |
1885 | 1885 | |
1886 | - if ( !isset($src) || !$src ) |
|
1886 | + if ( ! isset($src) || ! $src) |
|
1887 | 1887 | return false; |
1888 | 1888 | |
1889 | 1889 | return array($src, $src_file); |
@@ -1901,27 +1901,27 @@ discard block |
||
1901 | 1901 | * @param array $max_dims Optional. Dimensions of image. |
1902 | 1902 | * @return false|string HTML content. |
1903 | 1903 | */ |
1904 | -function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { |
|
1905 | - _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); |
|
1904 | +function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) { |
|
1905 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_get_attachment_image()'); |
|
1906 | 1906 | $id = (int) $id; |
1907 | - if ( !$post = get_post($id) ) |
|
1907 | + if ( ! $post = get_post($id)) |
|
1908 | 1908 | return false; |
1909 | 1909 | |
1910 | - if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) |
|
1910 | + if ( ! $src = get_attachment_icon_src($post->ID, $fullsize)) |
|
1911 | 1911 | return false; |
1912 | 1912 | |
1913 | 1913 | list($src, $src_file) = $src; |
1914 | 1914 | |
1915 | 1915 | // Do we need to constrain the image? |
1916 | - if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { |
|
1916 | + if (($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file)) { |
|
1917 | 1917 | |
1918 | 1918 | $imagesize = getimagesize($src_file); |
1919 | 1919 | |
1920 | - if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { |
|
1920 | + if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1]) { |
|
1921 | 1921 | $actual_aspect = $imagesize[0] / $imagesize[1]; |
1922 | 1922 | $desired_aspect = $max_dims[0] / $max_dims[1]; |
1923 | 1923 | |
1924 | - if ( $actual_aspect >= $desired_aspect ) { |
|
1924 | + if ($actual_aspect >= $desired_aspect) { |
|
1925 | 1925 | $height = $actual_aspect * $max_dims[0]; |
1926 | 1926 | $constraint = "width='{$max_dims[0]}' "; |
1927 | 1927 | $post->iconsize = array($max_dims[0], $height); |
@@ -1942,7 +1942,7 @@ discard block |
||
1942 | 1942 | |
1943 | 1943 | $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>"; |
1944 | 1944 | |
1945 | - return apply_filters( 'attachment_icon', $icon, $post->ID ); |
|
1945 | + return apply_filters('attachment_icon', $icon, $post->ID); |
|
1946 | 1946 | } |
1947 | 1947 | |
1948 | 1948 | /** |
@@ -1958,12 +1958,12 @@ discard block |
||
1958 | 1958 | * @return false|string |
1959 | 1959 | */ |
1960 | 1960 | function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { |
1961 | - _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); |
|
1961 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_get_attachment_image()'); |
|
1962 | 1962 | $id = (int) $id; |
1963 | - if ( !$post = get_post($id) ) |
|
1963 | + if ( ! $post = get_post($id)) |
|
1964 | 1964 | return false; |
1965 | 1965 | |
1966 | - if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) |
|
1966 | + if ($innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) |
|
1967 | 1967 | return $innerHTML; |
1968 | 1968 | |
1969 | 1969 | $innerHTML = esc_attr($post->post_title); |
@@ -1985,8 +1985,8 @@ discard block |
||
1985 | 1985 | * 'attribute', 'js', 'db', or 'display'. Default 'raw'. |
1986 | 1986 | * @return object|array Bookmark object or array, depending on the type specified by `$output`. |
1987 | 1987 | */ |
1988 | -function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) { |
|
1989 | - _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' ); |
|
1988 | +function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') { |
|
1989 | + _deprecated_function(__FUNCTION__, '2.1.0', 'get_bookmark()'); |
|
1990 | 1990 | return get_bookmark($bookmark_id, $output, $filter); |
1991 | 1991 | } |
1992 | 1992 | |
@@ -2001,9 +2001,9 @@ discard block |
||
2001 | 2001 | * @param array $protocols An array of acceptable protocols. |
2002 | 2002 | * @return string The cleaned URL. |
2003 | 2003 | */ |
2004 | -function sanitize_url( $url, $protocols = null ) { |
|
2005 | - _deprecated_function( __FUNCTION__, '2.8.0', 'esc_url_raw()' ); |
|
2006 | - return esc_url_raw( $url, $protocols ); |
|
2004 | +function sanitize_url($url, $protocols = null) { |
|
2005 | + _deprecated_function(__FUNCTION__, '2.8.0', 'esc_url_raw()'); |
|
2006 | + return esc_url_raw($url, $protocols); |
|
2007 | 2007 | } |
2008 | 2008 | |
2009 | 2009 | /** |
@@ -2022,12 +2022,12 @@ discard block |
||
2022 | 2022 | * @param string $context Optional. How the URL will be used. Default is 'display'. |
2023 | 2023 | * @return string The cleaned $url after the {@see 'clean_url'} filter is applied. |
2024 | 2024 | */ |
2025 | -function clean_url( $url, $protocols = null, $context = 'display' ) { |
|
2026 | - if ( $context == 'db' ) |
|
2027 | - _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()' ); |
|
2025 | +function clean_url($url, $protocols = null, $context = 'display') { |
|
2026 | + if ($context == 'db') |
|
2027 | + _deprecated_function('clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()'); |
|
2028 | 2028 | else |
2029 | - _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' ); |
|
2030 | - return esc_url( $url, $protocols, $context ); |
|
2029 | + _deprecated_function(__FUNCTION__, '3.0.0', 'esc_url()'); |
|
2030 | + return esc_url($url, $protocols, $context); |
|
2031 | 2031 | } |
2032 | 2032 | |
2033 | 2033 | /** |
@@ -2042,9 +2042,9 @@ discard block |
||
2042 | 2042 | * @param string $text The text to be escaped. |
2043 | 2043 | * @return string Escaped text. |
2044 | 2044 | */ |
2045 | -function js_escape( $text ) { |
|
2046 | - _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' ); |
|
2047 | - return esc_js( $text ); |
|
2045 | +function js_escape($text) { |
|
2046 | + _deprecated_function(__FUNCTION__, '2.8.0', 'esc_js()'); |
|
2047 | + return esc_js($text); |
|
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | /** |
@@ -2059,13 +2059,13 @@ discard block |
||
2059 | 2059 | * @param false $double_encode Whether to double encode. Unused. |
2060 | 2060 | * @return string Escaped `$string`. |
2061 | 2061 | */ |
2062 | -function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { |
|
2063 | - _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' ); |
|
2064 | - if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments. |
|
2062 | +function wp_specialchars($string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false) { |
|
2063 | + _deprecated_function(__FUNCTION__, '2.8.0', 'esc_html()'); |
|
2064 | + if (func_num_args() > 1) { // Maintain back-compat for people passing additional arguments. |
|
2065 | 2065 | $args = func_get_args(); |
2066 | - return call_user_func_array( '_wp_specialchars', $args ); |
|
2066 | + return call_user_func_array('_wp_specialchars', $args); |
|
2067 | 2067 | } else { |
2068 | - return esc_html( $string ); |
|
2068 | + return esc_html($string); |
|
2069 | 2069 | } |
2070 | 2070 | } |
2071 | 2071 | |
@@ -2079,9 +2079,9 @@ discard block |
||
2079 | 2079 | * @param string $text |
2080 | 2080 | * @return string |
2081 | 2081 | */ |
2082 | -function attribute_escape( $text ) { |
|
2083 | - _deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' ); |
|
2084 | - return esc_attr( $text ); |
|
2082 | +function attribute_escape($text) { |
|
2083 | + _deprecated_function(__FUNCTION__, '2.8.0', 'esc_attr()'); |
|
2084 | + return esc_attr($text); |
|
2085 | 2085 | } |
2086 | 2086 | |
2087 | 2087 | /** |
@@ -2104,10 +2104,10 @@ discard block |
||
2104 | 2104 | * @param mixed $params ,... Widget parameters. |
2105 | 2105 | */ |
2106 | 2106 | function register_sidebar_widget($name, $output_callback, $classname = '') { |
2107 | - _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); |
|
2107 | + _deprecated_function(__FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()'); |
|
2108 | 2108 | // Compat |
2109 | - if ( is_array($name) ) { |
|
2110 | - if ( count($name) == 3 ) |
|
2109 | + if (is_array($name)) { |
|
2110 | + if (count($name) == 3) |
|
2111 | 2111 | $name = sprintf($name[0], $name[2]); |
2112 | 2112 | else |
2113 | 2113 | $name = $name[0]; |
@@ -2115,11 +2115,11 @@ discard block |
||
2115 | 2115 | |
2116 | 2116 | $id = sanitize_title($name); |
2117 | 2117 | $options = array(); |
2118 | - if ( !empty($classname) && is_string($classname) ) |
|
2118 | + if ( ! empty($classname) && is_string($classname)) |
|
2119 | 2119 | $options['classname'] = $classname; |
2120 | 2120 | $params = array_slice(func_get_args(), 2); |
2121 | 2121 | $args = array($id, $name, $output_callback, $options); |
2122 | - if ( !empty($params) ) |
|
2122 | + if ( ! empty($params)) |
|
2123 | 2123 | $args = array_merge($args, $params); |
2124 | 2124 | |
2125 | 2125 | call_user_func_array('wp_register_sidebar_widget', $args); |
@@ -2135,7 +2135,7 @@ discard block |
||
2135 | 2135 | * @param int|string $id Widget ID. |
2136 | 2136 | */ |
2137 | 2137 | function unregister_sidebar_widget($id) { |
2138 | - _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' ); |
|
2138 | + _deprecated_function(__FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()'); |
|
2139 | 2139 | return wp_unregister_sidebar_widget($id); |
2140 | 2140 | } |
2141 | 2141 | |
@@ -2159,10 +2159,10 @@ discard block |
||
2159 | 2159 | * @param int $height Widget height. |
2160 | 2160 | */ |
2161 | 2161 | function register_widget_control($name, $control_callback, $width = '', $height = '') { |
2162 | - _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' ); |
|
2162 | + _deprecated_function(__FUNCTION__, '2.8.0', 'wp_register_widget_control()'); |
|
2163 | 2163 | // Compat |
2164 | - if ( is_array($name) ) { |
|
2165 | - if ( count($name) == 3 ) |
|
2164 | + if (is_array($name)) { |
|
2165 | + if (count($name) == 3) |
|
2166 | 2166 | $name = sprintf($name[0], $name[2]); |
2167 | 2167 | else |
2168 | 2168 | $name = $name[0]; |
@@ -2170,13 +2170,13 @@ discard block |
||
2170 | 2170 | |
2171 | 2171 | $id = sanitize_title($name); |
2172 | 2172 | $options = array(); |
2173 | - if ( !empty($width) ) |
|
2173 | + if ( ! empty($width)) |
|
2174 | 2174 | $options['width'] = $width; |
2175 | - if ( !empty($height) ) |
|
2175 | + if ( ! empty($height)) |
|
2176 | 2176 | $options['height'] = $height; |
2177 | 2177 | $params = array_slice(func_get_args(), 4); |
2178 | 2178 | $args = array($id, $name, $control_callback, $options); |
2179 | - if ( !empty($params) ) |
|
2179 | + if ( ! empty($params)) |
|
2180 | 2180 | $args = array_merge($args, $params); |
2181 | 2181 | |
2182 | 2182 | call_user_func_array('wp_register_widget_control', $args); |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | * @param int|string $id Widget ID. |
2193 | 2193 | */ |
2194 | 2194 | function unregister_widget_control($id) { |
2195 | - _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' ); |
|
2195 | + _deprecated_function(__FUNCTION__, '2.8.0', 'wp_unregister_widget_control()'); |
|
2196 | 2196 | return wp_unregister_widget_control($id); |
2197 | 2197 | } |
2198 | 2198 | |
@@ -2208,32 +2208,32 @@ discard block |
||
2208 | 2208 | * @param mixed $meta_value Metadata value. |
2209 | 2209 | * @return bool True deletion completed and false if user_id is not a number. |
2210 | 2210 | */ |
2211 | -function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { |
|
2212 | - _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' ); |
|
2211 | +function delete_usermeta($user_id, $meta_key, $meta_value = '') { |
|
2212 | + _deprecated_function(__FUNCTION__, '3.0.0', 'delete_user_meta()'); |
|
2213 | 2213 | global $wpdb; |
2214 | - if ( !is_numeric( $user_id ) ) |
|
2214 | + if ( ! is_numeric($user_id)) |
|
2215 | 2215 | return false; |
2216 | 2216 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
2217 | 2217 | |
2218 | - if ( is_array($meta_value) || is_object($meta_value) ) |
|
2218 | + if (is_array($meta_value) || is_object($meta_value)) |
|
2219 | 2219 | $meta_value = serialize($meta_value); |
2220 | - $meta_value = trim( $meta_value ); |
|
2220 | + $meta_value = trim($meta_value); |
|
2221 | 2221 | |
2222 | - $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2222 | + $cur = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
2223 | 2223 | |
2224 | - if ( $cur && $cur->umeta_id ) |
|
2225 | - do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2224 | + if ($cur && $cur->umeta_id) |
|
2225 | + do_action('delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
2226 | 2226 | |
2227 | - if ( ! empty($meta_value) ) |
|
2228 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); |
|
2227 | + if ( ! empty($meta_value)) |
|
2228 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value)); |
|
2229 | 2229 | else |
2230 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2230 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
2231 | 2231 | |
2232 | - clean_user_cache( $user_id ); |
|
2233 | - wp_cache_delete( $user_id, 'user_meta' ); |
|
2232 | + clean_user_cache($user_id); |
|
2233 | + wp_cache_delete($user_id, 'user_meta'); |
|
2234 | 2234 | |
2235 | - if ( $cur && $cur->umeta_id ) |
|
2236 | - do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2235 | + if ($cur && $cur->umeta_id) |
|
2236 | + do_action('deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
2237 | 2237 | |
2238 | 2238 | return true; |
2239 | 2239 | } |
@@ -2254,28 +2254,28 @@ discard block |
||
2254 | 2254 | * @param string $meta_key Optional. Metadata key. |
2255 | 2255 | * @return mixed |
2256 | 2256 | */ |
2257 | -function get_usermeta( $user_id, $meta_key = '' ) { |
|
2258 | - _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' ); |
|
2257 | +function get_usermeta($user_id, $meta_key = '') { |
|
2258 | + _deprecated_function(__FUNCTION__, '3.0.0', 'get_user_meta()'); |
|
2259 | 2259 | global $wpdb; |
2260 | 2260 | $user_id = (int) $user_id; |
2261 | 2261 | |
2262 | - if ( !$user_id ) |
|
2262 | + if ( ! $user_id) |
|
2263 | 2263 | return false; |
2264 | 2264 | |
2265 | - if ( !empty($meta_key) ) { |
|
2265 | + if ( ! empty($meta_key)) { |
|
2266 | 2266 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
2267 | 2267 | $user = wp_cache_get($user_id, 'users'); |
2268 | 2268 | // Check the cached user object |
2269 | - if ( false !== $user && isset($user->$meta_key) ) |
|
2269 | + if (false !== $user && isset($user->$meta_key)) |
|
2270 | 2270 | $metas = array($user->$meta_key); |
2271 | 2271 | else |
2272 | - $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2272 | + $metas = $wpdb->get_col($wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
2273 | 2273 | } else { |
2274 | - $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); |
|
2274 | + $metas = $wpdb->get_col($wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id)); |
|
2275 | 2275 | } |
2276 | 2276 | |
2277 | - if ( empty($metas) ) { |
|
2278 | - if ( empty($meta_key) ) |
|
2277 | + if (empty($metas)) { |
|
2278 | + if (empty($meta_key)) |
|
2279 | 2279 | return array(); |
2280 | 2280 | else |
2281 | 2281 | return ''; |
@@ -2283,7 +2283,7 @@ discard block |
||
2283 | 2283 | |
2284 | 2284 | $metas = array_map('maybe_unserialize', $metas); |
2285 | 2285 | |
2286 | - if ( count($metas) == 1 ) |
|
2286 | + if (count($metas) == 1) |
|
2287 | 2287 | return $metas[0]; |
2288 | 2288 | else |
2289 | 2289 | return $metas; |
@@ -2307,15 +2307,15 @@ discard block |
||
2307 | 2307 | * @param mixed $meta_value Metadata value. |
2308 | 2308 | * @return bool True on successful update, false on failure. |
2309 | 2309 | */ |
2310 | -function update_usermeta( $user_id, $meta_key, $meta_value ) { |
|
2311 | - _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' ); |
|
2310 | +function update_usermeta($user_id, $meta_key, $meta_value) { |
|
2311 | + _deprecated_function(__FUNCTION__, '3.0.0', 'update_user_meta()'); |
|
2312 | 2312 | global $wpdb; |
2313 | - if ( !is_numeric( $user_id ) ) |
|
2313 | + if ( ! is_numeric($user_id)) |
|
2314 | 2314 | return false; |
2315 | 2315 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
2316 | 2316 | |
2317 | 2317 | /** @todo Might need fix because usermeta data is assumed to be already escaped */ |
2318 | - if ( is_string($meta_value) ) |
|
2318 | + if (is_string($meta_value)) |
|
2319 | 2319 | $meta_value = stripslashes($meta_value); |
2320 | 2320 | $meta_value = maybe_serialize($meta_value); |
2321 | 2321 | |
@@ -2323,25 +2323,25 @@ discard block |
||
2323 | 2323 | return delete_usermeta($user_id, $meta_key); |
2324 | 2324 | } |
2325 | 2325 | |
2326 | - $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2326 | + $cur = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
2327 | 2327 | |
2328 | - if ( $cur ) |
|
2329 | - do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2328 | + if ($cur) |
|
2329 | + do_action('update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
2330 | 2330 | |
2331 | - if ( !$cur ) |
|
2332 | - $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); |
|
2333 | - elseif ( $cur->meta_value != $meta_value ) |
|
2334 | - $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); |
|
2331 | + if ( ! $cur) |
|
2332 | + $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value')); |
|
2333 | + elseif ($cur->meta_value != $meta_value) |
|
2334 | + $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key')); |
|
2335 | 2335 | else |
2336 | 2336 | return false; |
2337 | 2337 | |
2338 | - clean_user_cache( $user_id ); |
|
2339 | - wp_cache_delete( $user_id, 'user_meta' ); |
|
2338 | + clean_user_cache($user_id); |
|
2339 | + wp_cache_delete($user_id, 'user_meta'); |
|
2340 | 2340 | |
2341 | - if ( !$cur ) |
|
2342 | - do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); |
|
2341 | + if ( ! $cur) |
|
2342 | + do_action('added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value); |
|
2343 | 2343 | else |
2344 | - do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2344 | + do_action('updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
2345 | 2345 | |
2346 | 2346 | return true; |
2347 | 2347 | } |
@@ -2361,15 +2361,15 @@ discard block |
||
2361 | 2361 | * @param int $id Site ID. |
2362 | 2362 | * @return array List of users that are part of that site ID |
2363 | 2363 | */ |
2364 | -function get_users_of_blog( $id = '' ) { |
|
2365 | - _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); |
|
2364 | +function get_users_of_blog($id = '') { |
|
2365 | + _deprecated_function(__FUNCTION__, '3.1.0', 'get_users()'); |
|
2366 | 2366 | |
2367 | 2367 | global $wpdb; |
2368 | - if ( empty( $id ) ) { |
|
2368 | + if (empty($id)) { |
|
2369 | 2369 | $id = get_current_blog_id(); |
2370 | 2370 | } |
2371 | 2371 | $blog_prefix = $wpdb->get_blog_prefix($id); |
2372 | - $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); |
|
2372 | + $users = $wpdb->get_results("SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id"); |
|
2373 | 2373 | return $users; |
2374 | 2374 | } |
2375 | 2375 | |
@@ -2382,13 +2382,13 @@ discard block |
||
2382 | 2382 | * |
2383 | 2383 | * @param bool $add Optional, default is true. Add or remove links. Defaults to true. |
2384 | 2384 | */ |
2385 | -function automatic_feed_links( $add = true ) { |
|
2386 | - _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" ); |
|
2385 | +function automatic_feed_links($add = true) { |
|
2386 | + _deprecated_function(__FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )"); |
|
2387 | 2387 | |
2388 | - if ( $add ) |
|
2389 | - add_theme_support( 'automatic-feed-links' ); |
|
2388 | + if ($add) |
|
2389 | + add_theme_support('automatic-feed-links'); |
|
2390 | 2390 | else |
2391 | - remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+ |
|
2391 | + remove_action('wp_head', 'feed_links_extra', 3); // Just do this yourself in 3.0+ |
|
2392 | 2392 | } |
2393 | 2393 | |
2394 | 2394 | /** |
@@ -2402,13 +2402,13 @@ discard block |
||
2402 | 2402 | * @param false|int $user Optional. User ID to retrieve the field for. Default false (current user). |
2403 | 2403 | * @return string The author's field from the current author's DB object. |
2404 | 2404 | */ |
2405 | -function get_profile( $field, $user = false ) { |
|
2406 | - _deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' ); |
|
2407 | - if ( $user ) { |
|
2408 | - $user = get_user_by( 'login', $user ); |
|
2405 | +function get_profile($field, $user = false) { |
|
2406 | + _deprecated_function(__FUNCTION__, '3.0.0', 'get_the_author_meta()'); |
|
2407 | + if ($user) { |
|
2408 | + $user = get_user_by('login', $user); |
|
2409 | 2409 | $user = $user->ID; |
2410 | 2410 | } |
2411 | - return get_the_author_meta( $field, $user ); |
|
2411 | + return get_the_author_meta($field, $user); |
|
2412 | 2412 | } |
2413 | 2413 | |
2414 | 2414 | /** |
@@ -2421,9 +2421,9 @@ discard block |
||
2421 | 2421 | * @param int $userid User to count posts for. |
2422 | 2422 | * @return int Number of posts the given user has written. |
2423 | 2423 | */ |
2424 | -function get_usernumposts( $userid ) { |
|
2425 | - _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' ); |
|
2426 | - return count_user_posts( $userid ); |
|
2424 | +function get_usernumposts($userid) { |
|
2425 | + _deprecated_function(__FUNCTION__, '3.0.0', 'count_user_posts()'); |
|
2426 | + return count_user_posts($userid); |
|
2427 | 2427 | } |
2428 | 2428 | |
2429 | 2429 | /** |
@@ -2437,7 +2437,7 @@ discard block |
||
2437 | 2437 | * @return string An HTML entity |
2438 | 2438 | */ |
2439 | 2439 | function funky_javascript_callback($matches) { |
2440 | - return "&#".base_convert($matches[1],16,10).";"; |
|
2440 | + return "&#".base_convert($matches[1], 16, 10).";"; |
|
2441 | 2441 | } |
2442 | 2442 | |
2443 | 2443 | /** |
@@ -2455,12 +2455,12 @@ discard block |
||
2455 | 2455 | * @return string Fixed text. |
2456 | 2456 | */ |
2457 | 2457 | function funky_javascript_fix($text) { |
2458 | - _deprecated_function( __FUNCTION__, '3.0.0' ); |
|
2458 | + _deprecated_function(__FUNCTION__, '3.0.0'); |
|
2459 | 2459 | // Fixes for browsers' JavaScript bugs. |
2460 | 2460 | global $is_macIE, $is_winIE; |
2461 | 2461 | |
2462 | - if ( $is_winIE || $is_macIE ) |
|
2463 | - $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
2462 | + if ($is_winIE || $is_macIE) |
|
2463 | + $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
2464 | 2464 | "funky_javascript_callback", |
2465 | 2465 | $text); |
2466 | 2466 | |
@@ -2477,9 +2477,9 @@ discard block |
||
2477 | 2477 | * @param string $taxonomy Name of taxonomy object |
2478 | 2478 | * @return bool Whether the taxonomy exists. |
2479 | 2479 | */ |
2480 | -function is_taxonomy( $taxonomy ) { |
|
2481 | - _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' ); |
|
2482 | - return taxonomy_exists( $taxonomy ); |
|
2480 | +function is_taxonomy($taxonomy) { |
|
2481 | + _deprecated_function(__FUNCTION__, '3.0.0', 'taxonomy_exists()'); |
|
2482 | + return taxonomy_exists($taxonomy); |
|
2483 | 2483 | } |
2484 | 2484 | |
2485 | 2485 | /** |
@@ -2494,9 +2494,9 @@ discard block |
||
2494 | 2494 | * @param int $parent ID of parent term under which to confine the exists search. |
2495 | 2495 | * @return mixed Get the term id or Term Object, if exists. |
2496 | 2496 | */ |
2497 | -function is_term( $term, $taxonomy = '', $parent = 0 ) { |
|
2498 | - _deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' ); |
|
2499 | - return term_exists( $term, $taxonomy, $parent ); |
|
2497 | +function is_term($term, $taxonomy = '', $parent = 0) { |
|
2498 | + _deprecated_function(__FUNCTION__, '3.0.0', 'term_exists()'); |
|
2499 | + return term_exists($term, $taxonomy, $parent); |
|
2500 | 2500 | } |
2501 | 2501 | |
2502 | 2502 | /** |
@@ -2512,11 +2512,11 @@ discard block |
||
2512 | 2512 | * @return bool |
2513 | 2513 | */ |
2514 | 2514 | function is_plugin_page() { |
2515 | - _deprecated_function( __FUNCTION__, '3.1.0' ); |
|
2515 | + _deprecated_function(__FUNCTION__, '3.1.0'); |
|
2516 | 2516 | |
2517 | 2517 | global $plugin_page; |
2518 | 2518 | |
2519 | - if ( isset($plugin_page) ) |
|
2519 | + if (isset($plugin_page)) |
|
2520 | 2520 | return true; |
2521 | 2521 | |
2522 | 2522 | return false; |
@@ -2535,7 +2535,7 @@ discard block |
||
2535 | 2535 | * @return bool Always return True |
2536 | 2536 | */ |
2537 | 2537 | function update_category_cache() { |
2538 | - _deprecated_function( __FUNCTION__, '3.1.0' ); |
|
2538 | + _deprecated_function(__FUNCTION__, '3.1.0'); |
|
2539 | 2539 | |
2540 | 2540 | return true; |
2541 | 2541 | } |
@@ -2549,7 +2549,7 @@ discard block |
||
2549 | 2549 | * @return bool |
2550 | 2550 | */ |
2551 | 2551 | function wp_timezone_supported() { |
2552 | - _deprecated_function( __FUNCTION__, '3.2.0' ); |
|
2552 | + _deprecated_function(__FUNCTION__, '3.2.0'); |
|
2553 | 2553 | |
2554 | 2554 | return true; |
2555 | 2555 | } |
@@ -2569,9 +2569,9 @@ discard block |
||
2569 | 2569 | * @param bool $extended Optional. Unused. |
2570 | 2570 | */ |
2571 | 2571 | function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { |
2572 | - _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); |
|
2572 | + _deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()'); |
|
2573 | 2573 | |
2574 | - wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) ); |
|
2574 | + wp_editor($content, $id, array('media_buttons' => $media_buttons)); |
|
2575 | 2575 | } |
2576 | 2576 | |
2577 | 2577 | /** |
@@ -2584,20 +2584,20 @@ discard block |
||
2584 | 2584 | * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays. |
2585 | 2585 | */ |
2586 | 2586 | function get_user_metavalues($ids) { |
2587 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2587 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2588 | 2588 | |
2589 | 2589 | $objects = array(); |
2590 | 2590 | |
2591 | 2591 | $ids = array_map('intval', $ids); |
2592 | - foreach ( $ids as $id ) |
|
2592 | + foreach ($ids as $id) |
|
2593 | 2593 | $objects[$id] = array(); |
2594 | 2594 | |
2595 | 2595 | $metas = update_meta_cache('user', $ids); |
2596 | 2596 | |
2597 | - foreach ( $metas as $id => $meta ) { |
|
2598 | - foreach ( $meta as $key => $metavalues ) { |
|
2599 | - foreach ( $metavalues as $value ) { |
|
2600 | - $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); |
|
2597 | + foreach ($metas as $id => $meta) { |
|
2598 | + foreach ($meta as $key => $metavalues) { |
|
2599 | + foreach ($metavalues as $value) { |
|
2600 | + $objects[$id][] = (object) array('user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); |
|
2601 | 2601 | } |
2602 | 2602 | } |
2603 | 2603 | } |
@@ -2618,23 +2618,23 @@ discard block |
||
2618 | 2618 | * @return object|array The now sanitized User Object or Array (will be the same type as $user) |
2619 | 2619 | */ |
2620 | 2620 | function sanitize_user_object($user, $context = 'display') { |
2621 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2621 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2622 | 2622 | |
2623 | - if ( is_object($user) ) { |
|
2624 | - if ( !isset($user->ID) ) |
|
2623 | + if (is_object($user)) { |
|
2624 | + if ( ! isset($user->ID)) |
|
2625 | 2625 | $user->ID = 0; |
2626 | - if ( ! ( $user instanceof WP_User ) ) { |
|
2626 | + if ( ! ($user instanceof WP_User)) { |
|
2627 | 2627 | $vars = get_object_vars($user); |
2628 | - foreach ( array_keys($vars) as $field ) { |
|
2629 | - if ( is_string($user->$field) || is_numeric($user->$field) ) |
|
2628 | + foreach (array_keys($vars) as $field) { |
|
2629 | + if (is_string($user->$field) || is_numeric($user->$field)) |
|
2630 | 2630 | $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); |
2631 | 2631 | } |
2632 | 2632 | } |
2633 | 2633 | $user->filter = $context; |
2634 | 2634 | } else { |
2635 | - if ( !isset($user['ID']) ) |
|
2635 | + if ( ! isset($user['ID'])) |
|
2636 | 2636 | $user['ID'] = 0; |
2637 | - foreach ( array_keys($user) as $field ) |
|
2637 | + foreach (array_keys($user) as $field) |
|
2638 | 2638 | $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); |
2639 | 2639 | $user['filter'] = $context; |
2640 | 2640 | } |
@@ -2657,17 +2657,17 @@ discard block |
||
2657 | 2657 | * @return string |
2658 | 2658 | */ |
2659 | 2659 | function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { |
2660 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2660 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2661 | 2661 | |
2662 | 2662 | $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); |
2663 | 2663 | // If there is no post stop. |
2664 | - if ( empty($posts) ) |
|
2664 | + if (empty($posts)) |
|
2665 | 2665 | return; |
2666 | 2666 | |
2667 | 2667 | // Even though we limited get_posts to return only 1 item it still returns an array of objects. |
2668 | 2668 | $post = $posts[0]; |
2669 | 2669 | |
2670 | - if ( empty($post->post_title) ) |
|
2670 | + if (empty($post->post_title)) |
|
2671 | 2671 | $post->post_title = $start ? __('First Post') : __('Last Post'); |
2672 | 2672 | |
2673 | 2673 | $date = mysql2date(get_option('date_format'), $post->post_date); |
@@ -2678,10 +2678,10 @@ discard block |
||
2678 | 2678 | |
2679 | 2679 | $link = $start ? "<link rel='start' title='" : "<link rel='end' title='"; |
2680 | 2680 | $link .= esc_attr($title); |
2681 | - $link .= "' href='" . get_permalink($post) . "' />\n"; |
|
2681 | + $link .= "' href='".get_permalink($post)."' />\n"; |
|
2682 | 2682 | |
2683 | 2683 | $boundary = $start ? 'start' : 'end'; |
2684 | - return apply_filters( "{$boundary}_post_rel_link", $link ); |
|
2684 | + return apply_filters("{$boundary}_post_rel_link", $link); |
|
2685 | 2685 | } |
2686 | 2686 | |
2687 | 2687 | /** |
@@ -2695,7 +2695,7 @@ discard block |
||
2695 | 2695 | * @param string $excluded_categories Optional. Excluded categories IDs. |
2696 | 2696 | */ |
2697 | 2697 | function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { |
2698 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2698 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2699 | 2699 | |
2700 | 2700 | echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); |
2701 | 2701 | } |
@@ -2709,10 +2709,10 @@ discard block |
||
2709 | 2709 | * @return string |
2710 | 2710 | */ |
2711 | 2711 | function get_index_rel_link() { |
2712 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2712 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2713 | 2713 | |
2714 | - $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n"; |
|
2715 | - return apply_filters( "index_rel_link", $link ); |
|
2714 | + $link = "<link rel='index' title='".esc_attr(get_bloginfo('name', 'display'))."' href='".esc_url(user_trailingslashit(get_bloginfo('url', 'display')))."' />\n"; |
|
2715 | + return apply_filters("index_rel_link", $link); |
|
2716 | 2716 | } |
2717 | 2717 | |
2718 | 2718 | /** |
@@ -2722,7 +2722,7 @@ discard block |
||
2722 | 2722 | * @deprecated 3.3.0 |
2723 | 2723 | */ |
2724 | 2724 | function index_rel_link() { |
2725 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2725 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2726 | 2726 | |
2727 | 2727 | echo get_index_rel_link(); |
2728 | 2728 | } |
@@ -2736,13 +2736,13 @@ discard block |
||
2736 | 2736 | * @param string $title Optional. Link title format. Default '%title'. |
2737 | 2737 | * @return string |
2738 | 2738 | */ |
2739 | -function get_parent_post_rel_link( $title = '%title' ) { |
|
2740 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2739 | +function get_parent_post_rel_link($title = '%title') { |
|
2740 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2741 | 2741 | |
2742 | - if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) |
|
2742 | + if ( ! empty($GLOBALS['post']) && ! empty($GLOBALS['post']->post_parent)) |
|
2743 | 2743 | $post = get_post($GLOBALS['post']->post_parent); |
2744 | 2744 | |
2745 | - if ( empty($post) ) |
|
2745 | + if (empty($post)) |
|
2746 | 2746 | return; |
2747 | 2747 | |
2748 | 2748 | $date = mysql2date(get_option('date_format'), $post->post_date); |
@@ -2752,10 +2752,10 @@ discard block |
||
2752 | 2752 | $title = apply_filters('the_title', $title, $post->ID); |
2753 | 2753 | |
2754 | 2754 | $link = "<link rel='up' title='"; |
2755 | - $link .= esc_attr( $title ); |
|
2756 | - $link .= "' href='" . get_permalink($post) . "' />\n"; |
|
2755 | + $link .= esc_attr($title); |
|
2756 | + $link .= "' href='".get_permalink($post)."' />\n"; |
|
2757 | 2757 | |
2758 | - return apply_filters( "parent_post_rel_link", $link ); |
|
2758 | + return apply_filters("parent_post_rel_link", $link); |
|
2759 | 2759 | } |
2760 | 2760 | |
2761 | 2761 | /** |
@@ -2766,8 +2766,8 @@ discard block |
||
2766 | 2766 | * |
2767 | 2767 | * @param string $title Optional. Link title format. Default '%title'. |
2768 | 2768 | */ |
2769 | -function parent_post_rel_link( $title = '%title' ) { |
|
2770 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2769 | +function parent_post_rel_link($title = '%title') { |
|
2770 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2771 | 2771 | |
2772 | 2772 | echo get_parent_post_rel_link($title); |
2773 | 2773 | } |
@@ -2780,18 +2780,18 @@ discard block |
||
2780 | 2780 | * |
2781 | 2781 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. |
2782 | 2782 | */ |
2783 | -function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { |
|
2784 | - _deprecated_function( __FUNCTION__, '3.3.0' ); |
|
2783 | +function wp_admin_bar_dashboard_view_site_menu($wp_admin_bar) { |
|
2784 | + _deprecated_function(__FUNCTION__, '3.3.0'); |
|
2785 | 2785 | |
2786 | 2786 | $user_id = get_current_user_id(); |
2787 | 2787 | |
2788 | - if ( 0 != $user_id ) { |
|
2789 | - if ( is_admin() ) |
|
2790 | - $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); |
|
2791 | - elseif ( is_multisite() ) |
|
2792 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); |
|
2788 | + if (0 != $user_id) { |
|
2789 | + if (is_admin()) |
|
2790 | + $wp_admin_bar->add_menu(array('id' => 'view-site', 'title' => __('Visit Site'), 'href' => home_url())); |
|
2791 | + elseif (is_multisite()) |
|
2792 | + $wp_admin_bar->add_menu(array('id' => 'dashboard', 'title' => __('Dashboard'), 'href' => get_dashboard_url($user_id))); |
|
2793 | 2793 | else |
2794 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); |
|
2794 | + $wp_admin_bar->add_menu(array('id' => 'dashboard', 'title' => __('Dashboard'), 'href' => admin_url())); |
|
2795 | 2795 | } |
2796 | 2796 | } |
2797 | 2797 | |
@@ -2805,10 +2805,10 @@ discard block |
||
2805 | 2805 | * @param int $blog_id Site ID |
2806 | 2806 | * @return bool True if the current users belong to $blog_id, false if not. |
2807 | 2807 | */ |
2808 | -function is_blog_user( $blog_id = 0 ) { |
|
2809 | - _deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' ); |
|
2808 | +function is_blog_user($blog_id = 0) { |
|
2809 | + _deprecated_function(__FUNCTION__, '3.3.0', 'is_user_member_of_blog()'); |
|
2810 | 2810 | |
2811 | - return is_user_member_of_blog( get_current_user_id(), $blog_id ); |
|
2811 | + return is_user_member_of_blog(get_current_user_id(), $blog_id); |
|
2812 | 2812 | } |
2813 | 2813 | |
2814 | 2814 | /** |
@@ -2824,8 +2824,8 @@ discard block |
||
2824 | 2824 | * @param string $mode Type of access you required to the stream. |
2825 | 2825 | * @return false Always false. |
2826 | 2826 | */ |
2827 | -function debug_fopen( $filename, $mode ) { |
|
2828 | - _deprecated_function( __FUNCTION__, 'error_log()' ); |
|
2827 | +function debug_fopen($filename, $mode) { |
|
2828 | + _deprecated_function(__FUNCTION__, 'error_log()'); |
|
2829 | 2829 | return false; |
2830 | 2830 | } |
2831 | 2831 | |
@@ -2841,10 +2841,10 @@ discard block |
||
2841 | 2841 | * @param mixed $fp Unused. |
2842 | 2842 | * @param string $string Message to log. |
2843 | 2843 | */ |
2844 | -function debug_fwrite( $fp, $string ) { |
|
2845 | - _deprecated_function( __FUNCTION__, 'error_log()' ); |
|
2846 | - if ( ! empty( $GLOBALS['debug'] ) ) |
|
2847 | - error_log( $string ); |
|
2844 | +function debug_fwrite($fp, $string) { |
|
2845 | + _deprecated_function(__FUNCTION__, 'error_log()'); |
|
2846 | + if ( ! empty($GLOBALS['debug'])) |
|
2847 | + error_log($string); |
|
2848 | 2848 | } |
2849 | 2849 | |
2850 | 2850 | /** |
@@ -2858,8 +2858,8 @@ discard block |
||
2858 | 2858 | * |
2859 | 2859 | * @param mixed $fp Unused. |
2860 | 2860 | */ |
2861 | -function debug_fclose( $fp ) { |
|
2862 | - _deprecated_function( __FUNCTION__, 'error_log()' ); |
|
2861 | +function debug_fclose($fp) { |
|
2862 | + _deprecated_function(__FUNCTION__, 'error_log()'); |
|
2863 | 2863 | } |
2864 | 2864 | |
2865 | 2865 | /** |
@@ -2876,21 +2876,21 @@ discard block |
||
2876 | 2876 | * @return array Theme list with theme data. |
2877 | 2877 | */ |
2878 | 2878 | function get_themes() { |
2879 | - _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' ); |
|
2879 | + _deprecated_function(__FUNCTION__, '3.4.0', 'wp_get_themes()'); |
|
2880 | 2880 | |
2881 | 2881 | global $wp_themes; |
2882 | - if ( isset( $wp_themes ) ) |
|
2882 | + if (isset($wp_themes)) |
|
2883 | 2883 | return $wp_themes; |
2884 | 2884 | |
2885 | 2885 | $themes = wp_get_themes(); |
2886 | 2886 | $wp_themes = array(); |
2887 | 2887 | |
2888 | - foreach ( $themes as $theme ) { |
|
2888 | + foreach ($themes as $theme) { |
|
2889 | 2889 | $name = $theme->get('Name'); |
2890 | - if ( isset( $wp_themes[ $name ] ) ) |
|
2891 | - $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; |
|
2890 | + if (isset($wp_themes[$name])) |
|
2891 | + $wp_themes[$name.'/'.$theme->get_stylesheet()] = $theme; |
|
2892 | 2892 | else |
2893 | - $wp_themes[ $name ] = $theme; |
|
2893 | + $wp_themes[$name] = $theme; |
|
2894 | 2894 | } |
2895 | 2895 | |
2896 | 2896 | return $wp_themes; |
@@ -2906,12 +2906,12 @@ discard block |
||
2906 | 2906 | * @param string $theme Theme name. |
2907 | 2907 | * @return array|null Null, if theme name does not exist. Theme data, if exists. |
2908 | 2908 | */ |
2909 | -function get_theme( $theme ) { |
|
2910 | - _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' ); |
|
2909 | +function get_theme($theme) { |
|
2910 | + _deprecated_function(__FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )'); |
|
2911 | 2911 | |
2912 | 2912 | $themes = get_themes(); |
2913 | - if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) |
|
2914 | - return $themes[ $theme ]; |
|
2913 | + if (is_array($themes) && array_key_exists($theme, $themes)) |
|
2914 | + return $themes[$theme]; |
|
2915 | 2915 | return null; |
2916 | 2916 | } |
2917 | 2917 | |
@@ -2925,9 +2925,9 @@ discard block |
||
2925 | 2925 | * @return string |
2926 | 2926 | */ |
2927 | 2927 | function get_current_theme() { |
2928 | - _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); |
|
2928 | + _deprecated_function(__FUNCTION__, '3.4.0', 'wp_get_theme()'); |
|
2929 | 2929 | |
2930 | - if ( $theme = get_option( 'current_theme' ) ) |
|
2930 | + if ($theme = get_option('current_theme')) |
|
2931 | 2931 | return $theme; |
2932 | 2932 | |
2933 | 2933 | return wp_get_theme()->get('Name'); |
@@ -2946,10 +2946,10 @@ discard block |
||
2946 | 2946 | * @return string The pre block without paragraph/line-break conversion. |
2947 | 2947 | */ |
2948 | 2948 | function clean_pre($matches) { |
2949 | - _deprecated_function( __FUNCTION__, '3.4.0' ); |
|
2949 | + _deprecated_function(__FUNCTION__, '3.4.0'); |
|
2950 | 2950 | |
2951 | - if ( is_array($matches) ) |
|
2952 | - $text = $matches[1] . $matches[2] . "</pre>"; |
|
2951 | + if (is_array($matches)) |
|
2952 | + $text = $matches[1].$matches[2]."</pre>"; |
|
2953 | 2953 | else |
2954 | 2954 | $text = $matches; |
2955 | 2955 | |
@@ -2972,15 +2972,15 @@ discard block |
||
2972 | 2972 | * @param callable $admin_head_callback Call on custom header administration screen. |
2973 | 2973 | * @param callable $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional. |
2974 | 2974 | */ |
2975 | -function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) { |
|
2976 | - _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' ); |
|
2975 | +function add_custom_image_header($wp_head_callback, $admin_head_callback, $admin_preview_callback = '') { |
|
2976 | + _deprecated_function(__FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )'); |
|
2977 | 2977 | $args = array( |
2978 | 2978 | 'wp-head-callback' => $wp_head_callback, |
2979 | 2979 | 'admin-head-callback' => $admin_head_callback, |
2980 | 2980 | ); |
2981 | - if ( $admin_preview_callback ) |
|
2981 | + if ($admin_preview_callback) |
|
2982 | 2982 | $args['admin-preview-callback'] = $admin_preview_callback; |
2983 | - return add_theme_support( 'custom-header', $args ); |
|
2983 | + return add_theme_support('custom-header', $args); |
|
2984 | 2984 | } |
2985 | 2985 | |
2986 | 2986 | /** |
@@ -2993,8 +2993,8 @@ discard block |
||
2993 | 2993 | * @return null|bool Whether support was removed. |
2994 | 2994 | */ |
2995 | 2995 | function remove_custom_image_header() { |
2996 | - _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' ); |
|
2997 | - return remove_theme_support( 'custom-header' ); |
|
2996 | + _deprecated_function(__FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )'); |
|
2997 | + return remove_theme_support('custom-header'); |
|
2998 | 2998 | } |
2999 | 2999 | |
3000 | 3000 | /** |
@@ -3008,16 +3008,16 @@ discard block |
||
3008 | 3008 | * @param callable $admin_head_callback Call on custom background administration screen. |
3009 | 3009 | * @param callable $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional. |
3010 | 3010 | */ |
3011 | -function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { |
|
3012 | - _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' ); |
|
3011 | +function add_custom_background($wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '') { |
|
3012 | + _deprecated_function(__FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )'); |
|
3013 | 3013 | $args = array(); |
3014 | - if ( $wp_head_callback ) |
|
3014 | + if ($wp_head_callback) |
|
3015 | 3015 | $args['wp-head-callback'] = $wp_head_callback; |
3016 | - if ( $admin_head_callback ) |
|
3016 | + if ($admin_head_callback) |
|
3017 | 3017 | $args['admin-head-callback'] = $admin_head_callback; |
3018 | - if ( $admin_preview_callback ) |
|
3018 | + if ($admin_preview_callback) |
|
3019 | 3019 | $args['admin-preview-callback'] = $admin_preview_callback; |
3020 | - return add_theme_support( 'custom-background', $args ); |
|
3020 | + return add_theme_support('custom-background', $args); |
|
3021 | 3021 | } |
3022 | 3022 | |
3023 | 3023 | /** |
@@ -3030,8 +3030,8 @@ discard block |
||
3030 | 3030 | * @return null|bool Whether support was removed. |
3031 | 3031 | */ |
3032 | 3032 | function remove_custom_background() { |
3033 | - _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' ); |
|
3034 | - return remove_theme_support( 'custom-background' ); |
|
3033 | + _deprecated_function(__FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )'); |
|
3034 | + return remove_theme_support('custom-background'); |
|
3035 | 3035 | } |
3036 | 3036 | |
3037 | 3037 | /** |
@@ -3044,9 +3044,9 @@ discard block |
||
3044 | 3044 | * @param string $theme_file Theme file path. |
3045 | 3045 | * @return array Theme data. |
3046 | 3046 | */ |
3047 | -function get_theme_data( $theme_file ) { |
|
3048 | - _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); |
|
3049 | - $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); |
|
3047 | +function get_theme_data($theme_file) { |
|
3048 | + _deprecated_function(__FUNCTION__, '3.4.0', 'wp_get_theme()'); |
|
3049 | + $theme = new WP_Theme(basename(dirname($theme_file)), dirname(dirname($theme_file))); |
|
3050 | 3050 | |
3051 | 3051 | $theme_data = array( |
3052 | 3052 | 'Name' => $theme->get('Name'), |
@@ -3062,9 +3062,9 @@ discard block |
||
3062 | 3062 | 'AuthorName' => $theme->get('Author'), |
3063 | 3063 | ); |
3064 | 3064 | |
3065 | - foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { |
|
3066 | - if ( ! isset( $theme_data[ $extra_header ] ) ) |
|
3067 | - $theme_data[ $extra_header ] = $theme->get( $extra_header ); |
|
3065 | + foreach (apply_filters('extra_theme_headers', array()) as $extra_header) { |
|
3066 | + if ( ! isset($theme_data[$extra_header])) |
|
3067 | + $theme_data[$extra_header] = $theme->get($extra_header); |
|
3068 | 3068 | } |
3069 | 3069 | |
3070 | 3070 | return $theme_data; |
@@ -3081,10 +3081,10 @@ discard block |
||
3081 | 3081 | * |
3082 | 3082 | * @param array $pages list of page objects |
3083 | 3083 | */ |
3084 | -function update_page_cache( &$pages ) { |
|
3085 | - _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' ); |
|
3084 | +function update_page_cache(&$pages) { |
|
3085 | + _deprecated_function(__FUNCTION__, '3.4.0', 'update_post_cache()'); |
|
3086 | 3086 | |
3087 | - update_post_cache( $pages ); |
|
3087 | + update_post_cache($pages); |
|
3088 | 3088 | } |
3089 | 3089 | |
3090 | 3090 | /** |
@@ -3099,10 +3099,10 @@ discard block |
||
3099 | 3099 | * |
3100 | 3100 | * @param int $id Page ID to clean |
3101 | 3101 | */ |
3102 | -function clean_page_cache( $id ) { |
|
3103 | - _deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' ); |
|
3102 | +function clean_page_cache($id) { |
|
3103 | + _deprecated_function(__FUNCTION__, '3.4.0', 'clean_post_cache()'); |
|
3104 | 3104 | |
3105 | - clean_post_cache( $id ); |
|
3105 | + clean_post_cache($id); |
|
3106 | 3106 | } |
3107 | 3107 | |
3108 | 3108 | /** |
@@ -3117,9 +3117,9 @@ discard block |
||
3117 | 3117 | * @param string $action Nonce action. |
3118 | 3118 | * @return string Are you sure message. |
3119 | 3119 | */ |
3120 | -function wp_explain_nonce( $action ) { |
|
3121 | - _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' ); |
|
3122 | - return __( 'Are you sure you want to do this?' ); |
|
3120 | +function wp_explain_nonce($action) { |
|
3121 | + _deprecated_function(__FUNCTION__, '3.4.1', 'wp_nonce_ays()'); |
|
3122 | + return __('Are you sure you want to do this?'); |
|
3123 | 3123 | } |
3124 | 3124 | |
3125 | 3125 | /** |
@@ -3131,9 +3131,9 @@ discard block |
||
3131 | 3131 | * |
3132 | 3132 | * @param int $post_id An optional post ID. |
3133 | 3133 | */ |
3134 | -function sticky_class( $post_id = null ) { |
|
3135 | - _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' ); |
|
3136 | - if ( is_sticky( $post_id ) ) |
|
3134 | +function sticky_class($post_id = null) { |
|
3135 | + _deprecated_function(__FUNCTION__, '3.5.0', 'post_class()'); |
|
3136 | + if (is_sticky($post_id)) |
|
3137 | 3137 | echo ' sticky'; |
3138 | 3138 | } |
3139 | 3139 | |
@@ -3149,8 +3149,8 @@ discard block |
||
3149 | 3149 | * |
3150 | 3150 | * @param WP_Post &$post Post object, passed by reference (unused). |
3151 | 3151 | */ |
3152 | -function _get_post_ancestors( &$post ) { |
|
3153 | - _deprecated_function( __FUNCTION__, '3.5.0' ); |
|
3152 | +function _get_post_ancestors(&$post) { |
|
3153 | + _deprecated_function(__FUNCTION__, '3.5.0'); |
|
3154 | 3154 | } |
3155 | 3155 | |
3156 | 3156 | /** |
@@ -3163,28 +3163,28 @@ discard block |
||
3163 | 3163 | * @param string $file Filename of the image to load. |
3164 | 3164 | * @return resource The resulting image resource on success, Error string on failure. |
3165 | 3165 | */ |
3166 | -function wp_load_image( $file ) { |
|
3167 | - _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); |
|
3166 | +function wp_load_image($file) { |
|
3167 | + _deprecated_function(__FUNCTION__, '3.5.0', 'wp_get_image_editor()'); |
|
3168 | 3168 | |
3169 | - if ( is_numeric( $file ) ) |
|
3170 | - $file = get_attached_file( $file ); |
|
3169 | + if (is_numeric($file)) |
|
3170 | + $file = get_attached_file($file); |
|
3171 | 3171 | |
3172 | - if ( ! is_file( $file ) ) { |
|
3172 | + if ( ! is_file($file)) { |
|
3173 | 3173 | /* translators: %s: file name */ |
3174 | - return sprintf( __( 'File “%s” doesn’t exist?' ), $file ); |
|
3174 | + return sprintf(__('File “%s” doesn’t exist?'), $file); |
|
3175 | 3175 | } |
3176 | 3176 | |
3177 | - if ( ! function_exists('imagecreatefromstring') ) |
|
3177 | + if ( ! function_exists('imagecreatefromstring')) |
|
3178 | 3178 | return __('The GD image library is not installed.'); |
3179 | 3179 | |
3180 | 3180 | // Set artificially high because GD uses uncompressed images in memory. |
3181 | - wp_raise_memory_limit( 'image' ); |
|
3181 | + wp_raise_memory_limit('image'); |
|
3182 | 3182 | |
3183 | - $image = imagecreatefromstring( file_get_contents( $file ) ); |
|
3183 | + $image = imagecreatefromstring(file_get_contents($file)); |
|
3184 | 3184 | |
3185 | - if ( ! is_resource( $image ) ) { |
|
3185 | + if ( ! is_resource($image)) { |
|
3186 | 3186 | /* translators: %s: file name */ |
3187 | - return sprintf( __( 'File “%s” is not an image.' ), $file ); |
|
3187 | + return sprintf(__('File “%s” is not an image.'), $file); |
|
3188 | 3188 | } |
3189 | 3189 | |
3190 | 3190 | return $image; |
@@ -3214,22 +3214,22 @@ discard block |
||
3214 | 3214 | * @param int $jpeg_quality Optional, default is 90. Image quality percentage. |
3215 | 3215 | * @return mixed WP_Error on failure. String with new destination path. |
3216 | 3216 | */ |
3217 | -function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { |
|
3218 | - _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); |
|
3217 | +function image_resize($file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90) { |
|
3218 | + _deprecated_function(__FUNCTION__, '3.5.0', 'wp_get_image_editor()'); |
|
3219 | 3219 | |
3220 | - $editor = wp_get_image_editor( $file ); |
|
3221 | - if ( is_wp_error( $editor ) ) |
|
3220 | + $editor = wp_get_image_editor($file); |
|
3221 | + if (is_wp_error($editor)) |
|
3222 | 3222 | return $editor; |
3223 | - $editor->set_quality( $jpeg_quality ); |
|
3223 | + $editor->set_quality($jpeg_quality); |
|
3224 | 3224 | |
3225 | - $resized = $editor->resize( $max_w, $max_h, $crop ); |
|
3226 | - if ( is_wp_error( $resized ) ) |
|
3225 | + $resized = $editor->resize($max_w, $max_h, $crop); |
|
3226 | + if (is_wp_error($resized)) |
|
3227 | 3227 | return $resized; |
3228 | 3228 | |
3229 | - $dest_file = $editor->generate_filename( $suffix, $dest_path ); |
|
3230 | - $saved = $editor->save( $dest_file ); |
|
3229 | + $dest_file = $editor->generate_filename($suffix, $dest_path); |
|
3230 | + $saved = $editor->save($dest_file); |
|
3231 | 3231 | |
3232 | - if ( is_wp_error( $saved ) ) |
|
3232 | + if (is_wp_error($saved)) |
|
3233 | 3233 | return $saved; |
3234 | 3234 | |
3235 | 3235 | return $dest_file; |
@@ -3249,9 +3249,9 @@ discard block |
||
3249 | 3249 | * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A. |
3250 | 3250 | * @return WP_Post|null Post object or array holding post contents and information |
3251 | 3251 | */ |
3252 | -function wp_get_single_post( $postid = 0, $mode = OBJECT ) { |
|
3253 | - _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' ); |
|
3254 | - return get_post( $postid, $mode ); |
|
3252 | +function wp_get_single_post($postid = 0, $mode = OBJECT) { |
|
3253 | + _deprecated_function(__FUNCTION__, '3.5.0', 'get_post()'); |
|
3254 | + return get_post($postid, $mode); |
|
3255 | 3255 | } |
3256 | 3256 | |
3257 | 3257 | /** |
@@ -3266,9 +3266,9 @@ discard block |
||
3266 | 3266 | * @return bool False if does not authenticate, true if username and password authenticates. |
3267 | 3267 | */ |
3268 | 3268 | function user_pass_ok($user_login, $user_pass) { |
3269 | - _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' ); |
|
3270 | - $user = wp_authenticate( $user_login, $user_pass ); |
|
3271 | - if ( is_wp_error( $user ) ) |
|
3269 | + _deprecated_function(__FUNCTION__, '3.5.0', 'wp_authenticate()'); |
|
3270 | + $user = wp_authenticate($user_login, $user_pass); |
|
3271 | + if (is_wp_error($user)) |
|
3272 | 3272 | return false; |
3273 | 3273 | |
3274 | 3274 | return true; |
@@ -3293,10 +3293,10 @@ discard block |
||
3293 | 3293 | * @return bool |
3294 | 3294 | */ |
3295 | 3295 | function gd_edit_image_support($mime_type) { |
3296 | - _deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' ); |
|
3296 | + _deprecated_function(__FUNCTION__, '3.5.0', 'wp_image_editor_supports()'); |
|
3297 | 3297 | |
3298 | - if ( function_exists('imagetypes') ) { |
|
3299 | - switch( $mime_type ) { |
|
3298 | + if (function_exists('imagetypes')) { |
|
3299 | + switch ($mime_type) { |
|
3300 | 3300 | case 'image/jpeg': |
3301 | 3301 | return (imagetypes() & IMG_JPG) != 0; |
3302 | 3302 | case 'image/png': |
@@ -3305,7 +3305,7 @@ discard block |
||
3305 | 3305 | return (imagetypes() & IMG_GIF) != 0; |
3306 | 3306 | } |
3307 | 3307 | } else { |
3308 | - switch( $mime_type ) { |
|
3308 | + switch ($mime_type) { |
|
3309 | 3309 | case 'image/jpeg': |
3310 | 3310 | return function_exists('imagecreatefromjpeg'); |
3311 | 3311 | case 'image/png': |
@@ -3327,22 +3327,22 @@ discard block |
||
3327 | 3327 | * @param int $bytes An integer byte value. |
3328 | 3328 | * @return string A shorthand byte value. |
3329 | 3329 | */ |
3330 | -function wp_convert_bytes_to_hr( $bytes ) { |
|
3331 | - _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' ); |
|
3330 | +function wp_convert_bytes_to_hr($bytes) { |
|
3331 | + _deprecated_function(__FUNCTION__, '3.6.0', 'size_format()'); |
|
3332 | 3332 | |
3333 | - $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); |
|
3334 | - $log = log( $bytes, KB_IN_BYTES ); |
|
3333 | + $units = array(0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB'); |
|
3334 | + $log = log($bytes, KB_IN_BYTES); |
|
3335 | 3335 | $power = (int) $log; |
3336 | - $size = pow( KB_IN_BYTES, $log - $power ); |
|
3336 | + $size = pow(KB_IN_BYTES, $log - $power); |
|
3337 | 3337 | |
3338 | - if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { |
|
3339 | - $unit = $units[ $power ]; |
|
3338 | + if ( ! is_nan($size) && array_key_exists($power, $units)) { |
|
3339 | + $unit = $units[$power]; |
|
3340 | 3340 | } else { |
3341 | 3341 | $size = $bytes; |
3342 | 3342 | $unit = $units[0]; |
3343 | 3343 | } |
3344 | 3344 | |
3345 | - return $size . $unit; |
|
3345 | + return $size.$unit; |
|
3346 | 3346 | } |
3347 | 3347 | |
3348 | 3348 | /** |
@@ -3355,9 +3355,9 @@ discard block |
||
3355 | 3355 | * @param string $t Search terms to "tidy", e.g. trim. |
3356 | 3356 | * @return string Trimmed search terms. |
3357 | 3357 | */ |
3358 | -function _search_terms_tidy( $t ) { |
|
3359 | - _deprecated_function( __FUNCTION__, '3.7.0' ); |
|
3360 | - return trim( $t, "\"'\n\r " ); |
|
3358 | +function _search_terms_tidy($t) { |
|
3359 | + _deprecated_function(__FUNCTION__, '3.7.0'); |
|
3360 | + return trim($t, "\"'\n\r "); |
|
3361 | 3361 | } |
3362 | 3362 | |
3363 | 3363 | /** |
@@ -3373,10 +3373,10 @@ discard block |
||
3373 | 3373 | */ |
3374 | 3374 | function rich_edit_exists() { |
3375 | 3375 | global $wp_rich_edit_exists; |
3376 | - _deprecated_function( __FUNCTION__, '3.9.0' ); |
|
3376 | + _deprecated_function(__FUNCTION__, '3.9.0'); |
|
3377 | 3377 | |
3378 | - if ( ! isset( $wp_rich_edit_exists ) ) |
|
3379 | - $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); |
|
3378 | + if ( ! isset($wp_rich_edit_exists)) |
|
3379 | + $wp_rich_edit_exists = file_exists(ABSPATH.WPINC.'/js/tinymce/tinymce.js'); |
|
3380 | 3380 | |
3381 | 3381 | return $wp_rich_edit_exists; |
3382 | 3382 | } |
@@ -3391,7 +3391,7 @@ discard block |
||
3391 | 3391 | * @param int $count Number of topics. |
3392 | 3392 | * @return int Number of topics. |
3393 | 3393 | */ |
3394 | -function default_topic_count_text( $count ) { |
|
3394 | +function default_topic_count_text($count) { |
|
3395 | 3395 | return $count; |
3396 | 3396 | } |
3397 | 3397 | |
@@ -3406,8 +3406,8 @@ discard block |
||
3406 | 3406 | * @param string $content The text to format. |
3407 | 3407 | * @return string The very same text. |
3408 | 3408 | */ |
3409 | -function format_to_post( $content ) { |
|
3410 | - _deprecated_function( __FUNCTION__, '3.9.0' ); |
|
3409 | +function format_to_post($content) { |
|
3410 | + _deprecated_function(__FUNCTION__, '3.9.0'); |
|
3411 | 3411 | return $content; |
3412 | 3412 | } |
3413 | 3413 | |
@@ -3422,8 +3422,8 @@ discard block |
||
3422 | 3422 | * @return string text, safe for inclusion in LIKE query. |
3423 | 3423 | */ |
3424 | 3424 | function like_escape($text) { |
3425 | - _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' ); |
|
3426 | - return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text ); |
|
3425 | + _deprecated_function(__FUNCTION__, '4.0.0', 'wpdb::esc_like()'); |
|
3426 | + return str_replace(array("%", "_"), array("\\%", "\\_"), $text); |
|
3427 | 3427 | } |
3428 | 3428 | |
3429 | 3429 | /** |
@@ -3438,14 +3438,14 @@ discard block |
||
3438 | 3438 | * @param string $url The URL to test. |
3439 | 3439 | * @return bool Whether SSL access is available. |
3440 | 3440 | */ |
3441 | -function url_is_accessable_via_ssl( $url ) { |
|
3442 | - _deprecated_function( __FUNCTION__, '4.0.0' ); |
|
3441 | +function url_is_accessable_via_ssl($url) { |
|
3442 | + _deprecated_function(__FUNCTION__, '4.0.0'); |
|
3443 | 3443 | |
3444 | - $response = wp_remote_get( set_url_scheme( $url, 'https' ) ); |
|
3444 | + $response = wp_remote_get(set_url_scheme($url, 'https')); |
|
3445 | 3445 | |
3446 | - if ( !is_wp_error( $response ) ) { |
|
3447 | - $status = wp_remote_retrieve_response_code( $response ); |
|
3448 | - if ( 200 == $status || 401 == $status ) { |
|
3446 | + if ( ! is_wp_error($response)) { |
|
3447 | + $status = wp_remote_retrieve_response_code($response); |
|
3448 | + if (200 == $status || 401 == $status) { |
|
3449 | 3449 | return true; |
3450 | 3450 | } |
3451 | 3451 | } |
@@ -3463,7 +3463,7 @@ discard block |
||
3463 | 3463 | * @deprecated 4.3.0 |
3464 | 3464 | */ |
3465 | 3465 | function preview_theme() { |
3466 | - _deprecated_function( __FUNCTION__, '4.3.0' ); |
|
3466 | + _deprecated_function(__FUNCTION__, '4.3.0'); |
|
3467 | 3467 | } |
3468 | 3468 | |
3469 | 3469 | /** |
@@ -3476,7 +3476,7 @@ discard block |
||
3476 | 3476 | * @return string |
3477 | 3477 | */ |
3478 | 3478 | function _preview_theme_template_filter() { |
3479 | - _deprecated_function( __FUNCTION__, '4.3.0' ); |
|
3479 | + _deprecated_function(__FUNCTION__, '4.3.0'); |
|
3480 | 3480 | return ''; |
3481 | 3481 | } |
3482 | 3482 | |
@@ -3490,7 +3490,7 @@ discard block |
||
3490 | 3490 | * @return string |
3491 | 3491 | */ |
3492 | 3492 | function _preview_theme_stylesheet_filter() { |
3493 | - _deprecated_function( __FUNCTION__, '4.3.0' ); |
|
3493 | + _deprecated_function(__FUNCTION__, '4.3.0'); |
|
3494 | 3494 | return ''; |
3495 | 3495 | } |
3496 | 3496 | |
@@ -3504,8 +3504,8 @@ discard block |
||
3504 | 3504 | * @param string $content |
3505 | 3505 | * @return string |
3506 | 3506 | */ |
3507 | -function preview_theme_ob_filter( $content ) { |
|
3508 | - _deprecated_function( __FUNCTION__, '4.3.0' ); |
|
3507 | +function preview_theme_ob_filter($content) { |
|
3508 | + _deprecated_function(__FUNCTION__, '4.3.0'); |
|
3509 | 3509 | return $content; |
3510 | 3510 | } |
3511 | 3511 | |
@@ -3521,8 +3521,8 @@ discard block |
||
3521 | 3521 | * @param array $matches |
3522 | 3522 | * @return string |
3523 | 3523 | */ |
3524 | -function preview_theme_ob_filter_callback( $matches ) { |
|
3525 | - _deprecated_function( __FUNCTION__, '4.3.0' ); |
|
3524 | +function preview_theme_ob_filter_callback($matches) { |
|
3525 | + _deprecated_function(__FUNCTION__, '4.3.0'); |
|
3526 | 3526 | return ''; |
3527 | 3527 | } |
3528 | 3528 | |
@@ -3539,9 +3539,9 @@ discard block |
||
3539 | 3539 | * @return string The formatted text after filter is applied. |
3540 | 3540 | */ |
3541 | 3541 | function wp_richedit_pre($text) { |
3542 | - _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); |
|
3542 | + _deprecated_function(__FUNCTION__, '4.3.0', 'format_for_editor()'); |
|
3543 | 3543 | |
3544 | - if ( empty( $text ) ) { |
|
3544 | + if (empty($text)) { |
|
3545 | 3545 | /** |
3546 | 3546 | * Filters text returned for the rich text editor. |
3547 | 3547 | * |
@@ -3557,15 +3557,15 @@ discard block |
||
3557 | 3557 | * |
3558 | 3558 | * @param string $output Text for the rich text editor. |
3559 | 3559 | */ |
3560 | - return apply_filters( 'richedit_pre', '' ); |
|
3560 | + return apply_filters('richedit_pre', ''); |
|
3561 | 3561 | } |
3562 | 3562 | |
3563 | 3563 | $output = convert_chars($text); |
3564 | 3564 | $output = wpautop($output); |
3565 | - $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
|
3565 | + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option('blog_charset')); |
|
3566 | 3566 | |
3567 | 3567 | /** This filter is documented in wp-includes/deprecated.php */ |
3568 | - return apply_filters( 'richedit_pre', $output ); |
|
3568 | + return apply_filters('richedit_pre', $output); |
|
3569 | 3569 | } |
3570 | 3570 | |
3571 | 3571 | /** |
@@ -3582,10 +3582,10 @@ discard block |
||
3582 | 3582 | * @return string Formatted text after filter applied. |
3583 | 3583 | */ |
3584 | 3584 | function wp_htmledit_pre($output) { |
3585 | - _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); |
|
3585 | + _deprecated_function(__FUNCTION__, '4.3.0', 'format_for_editor()'); |
|
3586 | 3586 | |
3587 | - if ( !empty($output) ) |
|
3588 | - $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > & |
|
3587 | + if ( ! empty($output)) |
|
3588 | + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option('blog_charset')); // convert only < > & |
|
3589 | 3589 | |
3590 | 3590 | /** |
3591 | 3591 | * Filters the text before it is formatted for the HTML editor. |
@@ -3595,7 +3595,7 @@ discard block |
||
3595 | 3595 | * |
3596 | 3596 | * @param string $output The HTML-formatted text. |
3597 | 3597 | */ |
3598 | - return apply_filters( 'htmledit_pre', $output ); |
|
3598 | + return apply_filters('htmledit_pre', $output); |
|
3599 | 3599 | } |
3600 | 3600 | |
3601 | 3601 | /** |
@@ -3608,10 +3608,10 @@ discard block |
||
3608 | 3608 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
3609 | 3609 | * @return string|false |
3610 | 3610 | */ |
3611 | -function post_permalink( $post_id = 0 ) { |
|
3612 | - _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' ); |
|
3611 | +function post_permalink($post_id = 0) { |
|
3612 | + _deprecated_function(__FUNCTION__, '4.4.0', 'get_permalink()'); |
|
3613 | 3613 | |
3614 | - return get_permalink( $post_id ); |
|
3614 | + return get_permalink($post_id); |
|
3615 | 3615 | } |
3616 | 3616 | |
3617 | 3617 | /** |
@@ -3630,44 +3630,44 @@ discard block |
||
3630 | 3630 | * returns false. Default 1. |
3631 | 3631 | * @return bool|string False on failure and string of headers if HEAD request. |
3632 | 3632 | */ |
3633 | -function wp_get_http( $url, $file_path = false, $red = 1 ) { |
|
3634 | - _deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' ); |
|
3633 | +function wp_get_http($url, $file_path = false, $red = 1) { |
|
3634 | + _deprecated_function(__FUNCTION__, '4.4.0', 'WP_Http'); |
|
3635 | 3635 | |
3636 | - @set_time_limit( 60 ); |
|
3636 | + @set_time_limit(60); |
|
3637 | 3637 | |
3638 | - if ( $red > 5 ) |
|
3638 | + if ($red > 5) |
|
3639 | 3639 | return false; |
3640 | 3640 | |
3641 | 3641 | $options = array(); |
3642 | 3642 | $options['redirection'] = 5; |
3643 | 3643 | |
3644 | - if ( false == $file_path ) |
|
3644 | + if (false == $file_path) |
|
3645 | 3645 | $options['method'] = 'HEAD'; |
3646 | 3646 | else |
3647 | 3647 | $options['method'] = 'GET'; |
3648 | 3648 | |
3649 | - $response = wp_safe_remote_request( $url, $options ); |
|
3649 | + $response = wp_safe_remote_request($url, $options); |
|
3650 | 3650 | |
3651 | - if ( is_wp_error( $response ) ) |
|
3651 | + if (is_wp_error($response)) |
|
3652 | 3652 | return false; |
3653 | 3653 | |
3654 | - $headers = wp_remote_retrieve_headers( $response ); |
|
3655 | - $headers['response'] = wp_remote_retrieve_response_code( $response ); |
|
3654 | + $headers = wp_remote_retrieve_headers($response); |
|
3655 | + $headers['response'] = wp_remote_retrieve_response_code($response); |
|
3656 | 3656 | |
3657 | 3657 | // WP_HTTP no longer follows redirects for HEAD requests. |
3658 | - if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { |
|
3659 | - return wp_get_http( $headers['location'], $file_path, ++$red ); |
|
3658 | + if ('HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset($headers['location'])) { |
|
3659 | + return wp_get_http($headers['location'], $file_path, ++$red); |
|
3660 | 3660 | } |
3661 | 3661 | |
3662 | - if ( false == $file_path ) |
|
3662 | + if (false == $file_path) |
|
3663 | 3663 | return $headers; |
3664 | 3664 | |
3665 | 3665 | // GET request - write it to the supplied filename |
3666 | 3666 | $out_fp = fopen($file_path, 'w'); |
3667 | - if ( !$out_fp ) |
|
3667 | + if ( ! $out_fp) |
|
3668 | 3668 | return $headers; |
3669 | 3669 | |
3670 | - fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); |
|
3670 | + fwrite($out_fp, wp_remote_retrieve_body($response)); |
|
3671 | 3671 | fclose($out_fp); |
3672 | 3672 | clearstatcache(); |
3673 | 3673 | |
@@ -3684,9 +3684,9 @@ discard block |
||
3684 | 3684 | * @param string|bool $force Optional Whether to force SSL login. Default null. |
3685 | 3685 | * @return bool True if forced, false if not forced. |
3686 | 3686 | */ |
3687 | -function force_ssl_login( $force = null ) { |
|
3688 | - _deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' ); |
|
3689 | - return force_ssl_admin( $force ); |
|
3687 | +function force_ssl_login($force = null) { |
|
3688 | + _deprecated_function(__FUNCTION__, '4.4.0', 'force_ssl_admin()'); |
|
3689 | + return force_ssl_admin($force); |
|
3690 | 3690 | } |
3691 | 3691 | |
3692 | 3692 | /** |
@@ -3698,7 +3698,7 @@ discard block |
||
3698 | 3698 | * @return string Full path to comments popup template file. |
3699 | 3699 | */ |
3700 | 3700 | function get_comments_popup_template() { |
3701 | - _deprecated_function( __FUNCTION__, '4.5.0' ); |
|
3701 | + _deprecated_function(__FUNCTION__, '4.5.0'); |
|
3702 | 3702 | |
3703 | 3703 | return ''; |
3704 | 3704 | } |
@@ -3712,7 +3712,7 @@ discard block |
||
3712 | 3712 | * @return bool |
3713 | 3713 | */ |
3714 | 3714 | function is_comments_popup() { |
3715 | - _deprecated_function( __FUNCTION__, '4.5.0' ); |
|
3715 | + _deprecated_function(__FUNCTION__, '4.5.0'); |
|
3716 | 3716 | |
3717 | 3717 | return false; |
3718 | 3718 | } |
@@ -3724,7 +3724,7 @@ discard block |
||
3724 | 3724 | * @deprecated 4.5.0 |
3725 | 3725 | */ |
3726 | 3726 | function comments_popup_script() { |
3727 | - _deprecated_function( __FUNCTION__, '4.5.0' ); |
|
3727 | + _deprecated_function(__FUNCTION__, '4.5.0'); |
|
3728 | 3728 | } |
3729 | 3729 | |
3730 | 3730 | /** |
@@ -3736,8 +3736,8 @@ discard block |
||
3736 | 3736 | * @param string $text Content to replace links to open in a new window. |
3737 | 3737 | * @return string Content that has filtered links. |
3738 | 3738 | */ |
3739 | -function popuplinks( $text ) { |
|
3740 | - _deprecated_function( __FUNCTION__, '4.5.0' ); |
|
3739 | +function popuplinks($text) { |
|
3740 | + _deprecated_function(__FUNCTION__, '4.5.0'); |
|
3741 | 3741 | $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text); |
3742 | 3742 | return $text; |
3743 | 3743 | } |
@@ -3753,8 +3753,8 @@ discard block |
||
3753 | 3753 | * |
3754 | 3754 | * @return string An empty string. |
3755 | 3755 | */ |
3756 | -function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { |
|
3757 | - _deprecated_function( __FUNCTION__, '4.6.0' ); |
|
3756 | +function wp_embed_handler_googlevideo($matches, $attr, $url, $rawattr) { |
|
3757 | + _deprecated_function(__FUNCTION__, '4.6.0'); |
|
3758 | 3758 | |
3759 | 3759 | return ''; |
3760 | 3760 | } |
@@ -3768,9 +3768,9 @@ discard block |
||
3768 | 3768 | * @return string Full path to paged template file. |
3769 | 3769 | */ |
3770 | 3770 | function get_paged_template() { |
3771 | - _deprecated_function( __FUNCTION__, '4.7.0' ); |
|
3771 | + _deprecated_function(__FUNCTION__, '4.7.0'); |
|
3772 | 3772 | |
3773 | - return get_query_template( 'paged' ); |
|
3773 | + return get_query_template('paged'); |
|
3774 | 3774 | } |
3775 | 3775 | |
3776 | 3776 | /** |
@@ -3793,10 +3793,10 @@ discard block |
||
3793 | 3793 | * @param string $string |
3794 | 3794 | * @return string |
3795 | 3795 | */ |
3796 | -function wp_kses_js_entities( $string ) { |
|
3797 | - _deprecated_function( __FUNCTION__, '4.7.0' ); |
|
3796 | +function wp_kses_js_entities($string) { |
|
3797 | + _deprecated_function(__FUNCTION__, '4.7.0'); |
|
3798 | 3798 | |
3799 | - return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $string ); |
|
3799 | + return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string); |
|
3800 | 3800 | } |
3801 | 3801 | |
3802 | 3802 | /** |
@@ -3813,12 +3813,12 @@ discard block |
||
3813 | 3813 | * @param object $b |
3814 | 3814 | * @return int |
3815 | 3815 | */ |
3816 | -function _usort_terms_by_ID( $a, $b ) { |
|
3817 | - _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' ); |
|
3816 | +function _usort_terms_by_ID($a, $b) { |
|
3817 | + _deprecated_function(__FUNCTION__, '4.7.0', 'wp_list_sort'); |
|
3818 | 3818 | |
3819 | - if ( $a->term_id > $b->term_id ) |
|
3819 | + if ($a->term_id > $b->term_id) |
|
3820 | 3820 | return 1; |
3821 | - elseif ( $a->term_id < $b->term_id ) |
|
3821 | + elseif ($a->term_id < $b->term_id) |
|
3822 | 3822 | return -1; |
3823 | 3823 | else |
3824 | 3824 | return 0; |
@@ -3838,10 +3838,10 @@ discard block |
||
3838 | 3838 | * @param object $b |
3839 | 3839 | * @return int |
3840 | 3840 | */ |
3841 | -function _usort_terms_by_name( $a, $b ) { |
|
3842 | - _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' ); |
|
3841 | +function _usort_terms_by_name($a, $b) { |
|
3842 | + _deprecated_function(__FUNCTION__, '4.7.0', 'wp_list_sort'); |
|
3843 | 3843 | |
3844 | - return strcmp( $a->name, $b->name ); |
|
3844 | + return strcmp($a->name, $b->name); |
|
3845 | 3845 | } |
3846 | 3846 | |
3847 | 3847 | /** |
@@ -3857,24 +3857,24 @@ discard block |
||
3857 | 3857 | * @param object $b The second object to compare |
3858 | 3858 | * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b. |
3859 | 3859 | */ |
3860 | -function _sort_nav_menu_items( $a, $b ) { |
|
3860 | +function _sort_nav_menu_items($a, $b) { |
|
3861 | 3861 | global $_menu_item_sort_prop; |
3862 | 3862 | |
3863 | - _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' ); |
|
3863 | + _deprecated_function(__FUNCTION__, '4.7.0', 'wp_list_sort'); |
|
3864 | 3864 | |
3865 | - if ( empty( $_menu_item_sort_prop ) ) |
|
3865 | + if (empty($_menu_item_sort_prop)) |
|
3866 | 3866 | return 0; |
3867 | 3867 | |
3868 | - if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) |
|
3868 | + if ( ! isset($a->$_menu_item_sort_prop) || ! isset($b->$_menu_item_sort_prop)) |
|
3869 | 3869 | return 0; |
3870 | 3870 | |
3871 | 3871 | $_a = (int) $a->$_menu_item_sort_prop; |
3872 | 3872 | $_b = (int) $b->$_menu_item_sort_prop; |
3873 | 3873 | |
3874 | - if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) |
|
3874 | + if ($a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop) |
|
3875 | 3875 | return 0; |
3876 | - elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) |
|
3876 | + elseif ($_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop) |
|
3877 | 3877 | return $_a < $_b ? -1 : 1; |
3878 | 3878 | else |
3879 | - return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); |
|
3879 | + return strcmp($a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop); |
|
3880 | 3880 | } |
@@ -86,8 +86,9 @@ discard block |
||
86 | 86 | $categories = get_the_category(); |
87 | 87 | $cat = $categories[0]->term_id; |
88 | 88 | |
89 | - if ( $echo ) |
|
90 | - echo $cat; |
|
89 | + if ( $echo ) { |
|
90 | + echo $cat; |
|
91 | + } |
|
91 | 92 | |
92 | 93 | return $cat; |
93 | 94 | } |
@@ -136,19 +137,22 @@ discard block |
||
136 | 137 | |
137 | 138 | _deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' ); |
138 | 139 | |
139 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
140 | - $in_same_cat = false; |
|
141 | - else |
|
142 | - $in_same_cat = true; |
|
140 | + if ( empty($in_same_cat) || 'no' == $in_same_cat ) { |
|
141 | + $in_same_cat = false; |
|
142 | + } else { |
|
143 | + $in_same_cat = true; |
|
144 | + } |
|
143 | 145 | |
144 | 146 | $post = get_previous_post($in_same_cat, $excluded_categories); |
145 | 147 | |
146 | - if ( !$post ) |
|
147 | - return; |
|
148 | + if ( !$post ) { |
|
149 | + return; |
|
150 | + } |
|
148 | 151 | |
149 | 152 | $string = '<a href="'.get_permalink($post->ID).'">'.$previous; |
150 | - if ( 'yes' == $title ) |
|
151 | - $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
153 | + if ( 'yes' == $title ) { |
|
154 | + $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
155 | + } |
|
152 | 156 | $string .= '</a>'; |
153 | 157 | $format = str_replace('%', $string, $format); |
154 | 158 | echo $format; |
@@ -171,19 +175,22 @@ discard block |
||
171 | 175 | function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { |
172 | 176 | _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' ); |
173 | 177 | |
174 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
175 | - $in_same_cat = false; |
|
176 | - else |
|
177 | - $in_same_cat = true; |
|
178 | + if ( empty($in_same_cat) || 'no' == $in_same_cat ) { |
|
179 | + $in_same_cat = false; |
|
180 | + } else { |
|
181 | + $in_same_cat = true; |
|
182 | + } |
|
178 | 183 | |
179 | 184 | $post = get_next_post($in_same_cat, $excluded_categories); |
180 | 185 | |
181 | - if ( !$post ) |
|
182 | - return; |
|
186 | + if ( !$post ) { |
|
187 | + return; |
|
188 | + } |
|
183 | 189 | |
184 | 190 | $string = '<a href="'.get_permalink($post->ID).'">'.$next; |
185 | - if ( 'yes' == $title ) |
|
186 | - $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
191 | + if ( 'yes' == $title ) { |
|
192 | + $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
193 | + } |
|
187 | 194 | $string .= '</a>'; |
188 | 195 | $format = str_replace('%', $string, $format); |
189 | 196 | echo $format; |
@@ -366,11 +373,12 @@ discard block |
||
366 | 373 | |
367 | 374 | $user = get_userdata($user_id); |
368 | 375 | $other = get_userdata($other_user); |
369 | - if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) |
|
370 | - return true; |
|
371 | - else |
|
372 | - return false; |
|
373 | -} |
|
376 | + if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) { |
|
377 | + return true; |
|
378 | + } else { |
|
379 | + return false; |
|
380 | + } |
|
381 | + } |
|
374 | 382 | |
375 | 383 | /** |
376 | 384 | * Gets the links associated with category $cat_name. |
@@ -399,8 +407,9 @@ discard block |
||
399 | 407 | |
400 | 408 | $cat_id = -1; |
401 | 409 | $cat = get_term_by('name', $cat_name, 'link_category'); |
402 | - if ( $cat ) |
|
403 | - $cat_id = $cat->term_id; |
|
410 | + if ( $cat ) { |
|
411 | + $cat_id = $cat->term_id; |
|
412 | + } |
|
404 | 413 | |
405 | 414 | get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); |
406 | 415 | } |
@@ -459,8 +468,9 @@ discard block |
||
459 | 468 | |
460 | 469 | $cat_id = -1; |
461 | 470 | $cat = get_term_by('name', $cat_name, 'link_category'); |
462 | - if ( $cat ) |
|
463 | - $cat_id = $cat->term_id; |
|
471 | + if ( $cat ) { |
|
472 | + $cat_id = $cat->term_id; |
|
473 | + } |
|
464 | 474 | |
465 | 475 | return get_linkobjects($cat_id, $orderby, $limit); |
466 | 476 | } |
@@ -511,8 +521,9 @@ discard block |
||
511 | 521 | $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; |
512 | 522 | |
513 | 523 | $links_array = array(); |
514 | - foreach ($links as $link) |
|
515 | - $links_array[] = $link; |
|
524 | + foreach ($links as $link) { |
|
525 | + $links_array[] = $link; |
|
526 | + } |
|
516 | 527 | |
517 | 528 | return $links_array; |
518 | 529 | } |
@@ -638,18 +649,24 @@ discard block |
||
638 | 649 | $r = wp_parse_args( $args ); |
639 | 650 | |
640 | 651 | // Map to new names. |
641 | - if ( isset($r['optionall']) && isset($r['all'])) |
|
642 | - $r['show_option_all'] = $r['all']; |
|
643 | - if ( isset($r['sort_column']) ) |
|
644 | - $r['orderby'] = $r['sort_column']; |
|
645 | - if ( isset($r['sort_order']) ) |
|
646 | - $r['order'] = $r['sort_order']; |
|
647 | - if ( isset($r['optiondates']) ) |
|
648 | - $r['show_last_update'] = $r['optiondates']; |
|
649 | - if ( isset($r['optioncount']) ) |
|
650 | - $r['show_count'] = $r['optioncount']; |
|
651 | - if ( isset($r['list']) ) |
|
652 | - $r['style'] = $r['list'] ? 'list' : 'break'; |
|
652 | + if ( isset($r['optionall']) && isset($r['all'])) { |
|
653 | + $r['show_option_all'] = $r['all']; |
|
654 | + } |
|
655 | + if ( isset($r['sort_column']) ) { |
|
656 | + $r['orderby'] = $r['sort_column']; |
|
657 | + } |
|
658 | + if ( isset($r['sort_order']) ) { |
|
659 | + $r['order'] = $r['sort_order']; |
|
660 | + } |
|
661 | + if ( isset($r['optiondates']) ) { |
|
662 | + $r['show_last_update'] = $r['optiondates']; |
|
663 | + } |
|
664 | + if ( isset($r['optioncount']) ) { |
|
665 | + $r['show_count'] = $r['optioncount']; |
|
666 | + } |
|
667 | + if ( isset($r['list']) ) { |
|
668 | + $r['style'] = $r['list'] ? 'list' : 'break'; |
|
669 | + } |
|
653 | 670 | $r['title_li'] = ''; |
654 | 671 | |
655 | 672 | return wp_list_categories($r); |
@@ -680,12 +697,14 @@ discard block |
||
680 | 697 | _deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' ); |
681 | 698 | |
682 | 699 | $show_option_all = ''; |
683 | - if ( $optionall ) |
|
684 | - $show_option_all = $all; |
|
700 | + if ( $optionall ) { |
|
701 | + $show_option_all = $all; |
|
702 | + } |
|
685 | 703 | |
686 | 704 | $show_option_none = ''; |
687 | - if ( $optionnone ) |
|
688 | - $show_option_none = __('None'); |
|
705 | + if ( $optionnone ) { |
|
706 | + $show_option_none = __('None'); |
|
707 | + } |
|
689 | 708 | |
690 | 709 | $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', |
691 | 710 | 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); |
@@ -787,8 +806,9 @@ discard block |
||
787 | 806 | |
788 | 807 | $link = get_author_posts_url($author_id, $author_nicename); |
789 | 808 | |
790 | - if ( $echo ) |
|
791 | - echo $link; |
|
809 | + if ( $echo ) { |
|
810 | + echo $link; |
|
811 | + } |
|
792 | 812 | return $link; |
793 | 813 | } |
794 | 814 | |
@@ -931,64 +951,78 @@ discard block |
||
931 | 951 | $orderby = substr($orderby, 1); |
932 | 952 | } |
933 | 953 | |
934 | - if ( $category == -1 ) //get_bookmarks uses '' to signify all categories |
|
954 | + if ( $category == -1 ) { |
|
955 | + //get_bookmarks uses '' to signify all categories |
|
935 | 956 | $category = ''; |
957 | + } |
|
936 | 958 | |
937 | 959 | $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); |
938 | 960 | |
939 | - if ( !$results ) |
|
940 | - return; |
|
961 | + if ( !$results ) { |
|
962 | + return; |
|
963 | + } |
|
941 | 964 | |
942 | 965 | $output = ''; |
943 | 966 | |
944 | 967 | foreach ( (array) $results as $row ) { |
945 | - if ( !isset($row->recently_updated) ) |
|
946 | - $row->recently_updated = false; |
|
968 | + if ( !isset($row->recently_updated) ) { |
|
969 | + $row->recently_updated = false; |
|
970 | + } |
|
947 | 971 | $output .= $before; |
948 | - if ( $show_updated && $row->recently_updated ) |
|
949 | - $output .= get_option('links_recently_updated_prepend'); |
|
972 | + if ( $show_updated && $row->recently_updated ) { |
|
973 | + $output .= get_option('links_recently_updated_prepend'); |
|
974 | + } |
|
950 | 975 | $the_link = '#'; |
951 | - if ( !empty($row->link_url) ) |
|
952 | - $the_link = esc_url($row->link_url); |
|
976 | + if ( !empty($row->link_url) ) { |
|
977 | + $the_link = esc_url($row->link_url); |
|
978 | + } |
|
953 | 979 | $rel = $row->link_rel; |
954 | - if ( '' != $rel ) |
|
955 | - $rel = ' rel="' . $rel . '"'; |
|
980 | + if ( '' != $rel ) { |
|
981 | + $rel = ' rel="' . $rel . '"'; |
|
982 | + } |
|
956 | 983 | |
957 | 984 | $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); |
958 | 985 | $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); |
959 | 986 | $title = $desc; |
960 | 987 | |
961 | - if ( $show_updated ) |
|
962 | - if (substr($row->link_updated_f, 0, 2) != '00') |
|
988 | + if ( $show_updated ) { |
|
989 | + if (substr($row->link_updated_f, 0, 2) != '00') |
|
963 | 990 | $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; |
991 | + } |
|
964 | 992 | |
965 | - if ( '' != $title ) |
|
966 | - $title = ' title="' . $title . '"'; |
|
993 | + if ( '' != $title ) { |
|
994 | + $title = ' title="' . $title . '"'; |
|
995 | + } |
|
967 | 996 | |
968 | 997 | $alt = ' alt="' . $name . '"'; |
969 | 998 | |
970 | 999 | $target = $row->link_target; |
971 | - if ( '' != $target ) |
|
972 | - $target = ' target="' . $target . '"'; |
|
1000 | + if ( '' != $target ) { |
|
1001 | + $target = ' target="' . $target . '"'; |
|
1002 | + } |
|
973 | 1003 | |
974 | 1004 | $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; |
975 | 1005 | |
976 | 1006 | if ( $row->link_image != null && $show_images ) { |
977 | - if ( strpos($row->link_image, 'http') !== false ) |
|
978 | - $output .= "<img src=\"$row->link_image\" $alt $title />"; |
|
979 | - else // If it's a relative path |
|
1007 | + if ( strpos($row->link_image, 'http') !== false ) { |
|
1008 | + $output .= "<img src=\"$row->link_image\" $alt $title />"; |
|
1009 | + } else { |
|
1010 | + // If it's a relative path |
|
980 | 1011 | $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; |
1012 | + } |
|
981 | 1013 | } else { |
982 | 1014 | $output .= $name; |
983 | 1015 | } |
984 | 1016 | |
985 | 1017 | $output .= '</a>'; |
986 | 1018 | |
987 | - if ( $show_updated && $row->recently_updated ) |
|
988 | - $output .= get_option('links_recently_updated_append'); |
|
1019 | + if ( $show_updated && $row->recently_updated ) { |
|
1020 | + $output .= get_option('links_recently_updated_append'); |
|
1021 | + } |
|
989 | 1022 | |
990 | - if ( $show_description && '' != $desc ) |
|
991 | - $output .= $between . $desc; |
|
1023 | + if ( $show_description && '' != $desc ) { |
|
1024 | + $output .= $between . $desc; |
|
1025 | + } |
|
992 | 1026 | |
993 | 1027 | if ($show_rating) { |
994 | 1028 | $output .= $between . get_linkrating($row); |
@@ -997,8 +1031,9 @@ discard block |
||
997 | 1031 | $output .= "$after\n"; |
998 | 1032 | } // end while |
999 | 1033 | |
1000 | - if ( !$echo ) |
|
1001 | - return $output; |
|
1034 | + if ( !$echo ) { |
|
1035 | + return $output; |
|
1036 | + } |
|
1002 | 1037 | echo $output; |
1003 | 1038 | } |
1004 | 1039 | |
@@ -1026,8 +1061,9 @@ discard block |
||
1026 | 1061 | $order = substr($order,1); |
1027 | 1062 | } |
1028 | 1063 | |
1029 | - if ( !isset($direction) ) |
|
1030 | - $direction = ''; |
|
1064 | + if ( !isset($direction) ) { |
|
1065 | + $direction = ''; |
|
1066 | + } |
|
1031 | 1067 | |
1032 | 1068 | $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); |
1033 | 1069 | |
@@ -1093,13 +1129,15 @@ discard block |
||
1093 | 1129 | |
1094 | 1130 | $id = (int) $id; |
1095 | 1131 | |
1096 | - if ( empty($id) ) |
|
1097 | - return ''; |
|
1132 | + if ( empty($id) ) { |
|
1133 | + return ''; |
|
1134 | + } |
|
1098 | 1135 | |
1099 | 1136 | $cats = wp_get_link_cats($id); |
1100 | 1137 | |
1101 | - if ( empty($cats) || ! is_array($cats) ) |
|
1102 | - return ''; |
|
1138 | + if ( empty($cats) || ! is_array($cats) ) { |
|
1139 | + return ''; |
|
1140 | + } |
|
1103 | 1141 | |
1104 | 1142 | $cat_id = (int) $cats[0]; // Take the first cat. |
1105 | 1143 | |
@@ -1137,8 +1175,9 @@ discard block |
||
1137 | 1175 | |
1138 | 1176 | $link = get_category_feed_link($cat_ID, 'rss2'); |
1139 | 1177 | |
1140 | - if ( $echo ) |
|
1141 | - echo $link; |
|
1178 | + if ( $echo ) { |
|
1179 | + echo $link; |
|
1180 | + } |
|
1142 | 1181 | return $link; |
1143 | 1182 | } |
1144 | 1183 | |
@@ -1157,8 +1196,9 @@ discard block |
||
1157 | 1196 | _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' ); |
1158 | 1197 | |
1159 | 1198 | $link = get_author_feed_link($author_id); |
1160 | - if ( $echo ) |
|
1161 | - echo $link; |
|
1199 | + if ( $echo ) { |
|
1200 | + echo $link; |
|
1201 | + } |
|
1162 | 1202 | return $link; |
1163 | 1203 | } |
1164 | 1204 | |
@@ -1250,19 +1290,22 @@ discard block |
||
1250 | 1290 | */ |
1251 | 1291 | function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { |
1252 | 1292 | _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' ); |
1253 | - if ( 0 == $id ) |
|
1254 | - return ''; |
|
1293 | + if ( 0 == $id ) { |
|
1294 | + return ''; |
|
1295 | + } |
|
1255 | 1296 | |
1256 | 1297 | $chain = ''; |
1257 | 1298 | /** TODO: consult hierarchy */ |
1258 | 1299 | $cat_ids = get_all_category_ids(); |
1259 | 1300 | foreach ( (array) $cat_ids as $cat_id ) { |
1260 | - if ( $cat_id == $id ) |
|
1261 | - continue; |
|
1301 | + if ( $cat_id == $id ) { |
|
1302 | + continue; |
|
1303 | + } |
|
1262 | 1304 | |
1263 | 1305 | $category = get_category( $cat_id ); |
1264 | - if ( is_wp_error( $category ) ) |
|
1265 | - return $category; |
|
1306 | + if ( is_wp_error( $category ) ) { |
|
1307 | + return $category; |
|
1308 | + } |
|
1266 | 1309 | if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { |
1267 | 1310 | $visited[] = $category->term_id; |
1268 | 1311 | $chain .= $before.$category->term_id.$after; |
@@ -1653,8 +1696,9 @@ discard block |
||
1653 | 1696 | _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed' ); |
1654 | 1697 | $content = get_the_content($more_link_text, $stripteaser); |
1655 | 1698 | $content = apply_filters('the_content_rss', $content); |
1656 | - if ( $cut && !$encode_html ) |
|
1657 | - $encode_html = 2; |
|
1699 | + if ( $cut && !$encode_html ) { |
|
1700 | + $encode_html = 2; |
|
1701 | + } |
|
1658 | 1702 | if ( 1== $encode_html ) { |
1659 | 1703 | $content = esc_html($content); |
1660 | 1704 | $cut = 0; |
@@ -1674,8 +1718,9 @@ discard block |
||
1674 | 1718 | } |
1675 | 1719 | |
1676 | 1720 | /** @todo Check performance, might be faster to use array slice instead. */ |
1677 | - for ( $i=0; $i<$k; $i++ ) |
|
1678 | - $excerpt .= $blah[$i].' '; |
|
1721 | + for ( $i=0; $i<$k; $i++ ) { |
|
1722 | + $excerpt .= $blah[$i].' '; |
|
1723 | + } |
|
1679 | 1724 | $excerpt .= ($use_dotdotdot) ? '...' : ''; |
1680 | 1725 | $content = $excerpt; |
1681 | 1726 | } |
@@ -1836,11 +1881,13 @@ discard block |
||
1836 | 1881 | $id = (int) $id; |
1837 | 1882 | $_post = get_post($id); |
1838 | 1883 | |
1839 | - if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) |
|
1840 | - return __('Missing Attachment'); |
|
1884 | + if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) { |
|
1885 | + return __('Missing Attachment'); |
|
1886 | + } |
|
1841 | 1887 | |
1842 | - if ( $permalink ) |
|
1843 | - $url = get_attachment_link($_post->ID); |
|
1888 | + if ( $permalink ) { |
|
1889 | + $url = get_attachment_link($_post->ID); |
|
1890 | + } |
|
1844 | 1891 | |
1845 | 1892 | $post_title = esc_attr($_post->post_title); |
1846 | 1893 | |
@@ -1862,8 +1909,9 @@ discard block |
||
1862 | 1909 | function get_attachment_icon_src( $id = 0, $fullsize = false ) { |
1863 | 1910 | _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' ); |
1864 | 1911 | $id = (int) $id; |
1865 | - if ( !$post = get_post($id) ) |
|
1866 | - return false; |
|
1912 | + if ( !$post = get_post($id) ) { |
|
1913 | + return false; |
|
1914 | + } |
|
1867 | 1915 | |
1868 | 1916 | $file = get_attached_file( $post->ID ); |
1869 | 1917 | |
@@ -1883,8 +1931,9 @@ discard block |
||
1883 | 1931 | $src_file = $icon_dir . '/' . basename($src); |
1884 | 1932 | } |
1885 | 1933 | |
1886 | - if ( !isset($src) || !$src ) |
|
1887 | - return false; |
|
1934 | + if ( !isset($src) || !$src ) { |
|
1935 | + return false; |
|
1936 | + } |
|
1888 | 1937 | |
1889 | 1938 | return array($src, $src_file); |
1890 | 1939 | } |
@@ -1904,11 +1953,13 @@ discard block |
||
1904 | 1953 | function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { |
1905 | 1954 | _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); |
1906 | 1955 | $id = (int) $id; |
1907 | - if ( !$post = get_post($id) ) |
|
1908 | - return false; |
|
1956 | + if ( !$post = get_post($id) ) { |
|
1957 | + return false; |
|
1958 | + } |
|
1909 | 1959 | |
1910 | - if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) |
|
1911 | - return false; |
|
1960 | + if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) { |
|
1961 | + return false; |
|
1962 | + } |
|
1912 | 1963 | |
1913 | 1964 | list($src, $src_file) = $src; |
1914 | 1965 | |
@@ -1960,11 +2011,13 @@ discard block |
||
1960 | 2011 | function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { |
1961 | 2012 | _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); |
1962 | 2013 | $id = (int) $id; |
1963 | - if ( !$post = get_post($id) ) |
|
1964 | - return false; |
|
2014 | + if ( !$post = get_post($id) ) { |
|
2015 | + return false; |
|
2016 | + } |
|
1965 | 2017 | |
1966 | - if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) |
|
1967 | - return $innerHTML; |
|
2018 | + if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) { |
|
2019 | + return $innerHTML; |
|
2020 | + } |
|
1968 | 2021 | |
1969 | 2022 | $innerHTML = esc_attr($post->post_title); |
1970 | 2023 | |
@@ -2023,10 +2076,11 @@ discard block |
||
2023 | 2076 | * @return string The cleaned $url after the {@see 'clean_url'} filter is applied. |
2024 | 2077 | */ |
2025 | 2078 | function clean_url( $url, $protocols = null, $context = 'display' ) { |
2026 | - if ( $context == 'db' ) |
|
2027 | - _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()' ); |
|
2028 | - else |
|
2029 | - _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' ); |
|
2079 | + if ( $context == 'db' ) { |
|
2080 | + _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()' ); |
|
2081 | + } else { |
|
2082 | + _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' ); |
|
2083 | + } |
|
2030 | 2084 | return esc_url( $url, $protocols, $context ); |
2031 | 2085 | } |
2032 | 2086 | |
@@ -2107,20 +2161,23 @@ discard block |
||
2107 | 2161 | _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); |
2108 | 2162 | // Compat |
2109 | 2163 | if ( is_array($name) ) { |
2110 | - if ( count($name) == 3 ) |
|
2111 | - $name = sprintf($name[0], $name[2]); |
|
2112 | - else |
|
2113 | - $name = $name[0]; |
|
2164 | + if ( count($name) == 3 ) { |
|
2165 | + $name = sprintf($name[0], $name[2]); |
|
2166 | + } else { |
|
2167 | + $name = $name[0]; |
|
2168 | + } |
|
2114 | 2169 | } |
2115 | 2170 | |
2116 | 2171 | $id = sanitize_title($name); |
2117 | 2172 | $options = array(); |
2118 | - if ( !empty($classname) && is_string($classname) ) |
|
2119 | - $options['classname'] = $classname; |
|
2173 | + if ( !empty($classname) && is_string($classname) ) { |
|
2174 | + $options['classname'] = $classname; |
|
2175 | + } |
|
2120 | 2176 | $params = array_slice(func_get_args(), 2); |
2121 | 2177 | $args = array($id, $name, $output_callback, $options); |
2122 | - if ( !empty($params) ) |
|
2123 | - $args = array_merge($args, $params); |
|
2178 | + if ( !empty($params) ) { |
|
2179 | + $args = array_merge($args, $params); |
|
2180 | + } |
|
2124 | 2181 | |
2125 | 2182 | call_user_func_array('wp_register_sidebar_widget', $args); |
2126 | 2183 | } |
@@ -2162,22 +2219,26 @@ discard block |
||
2162 | 2219 | _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' ); |
2163 | 2220 | // Compat |
2164 | 2221 | if ( is_array($name) ) { |
2165 | - if ( count($name) == 3 ) |
|
2166 | - $name = sprintf($name[0], $name[2]); |
|
2167 | - else |
|
2168 | - $name = $name[0]; |
|
2222 | + if ( count($name) == 3 ) { |
|
2223 | + $name = sprintf($name[0], $name[2]); |
|
2224 | + } else { |
|
2225 | + $name = $name[0]; |
|
2226 | + } |
|
2169 | 2227 | } |
2170 | 2228 | |
2171 | 2229 | $id = sanitize_title($name); |
2172 | 2230 | $options = array(); |
2173 | - if ( !empty($width) ) |
|
2174 | - $options['width'] = $width; |
|
2175 | - if ( !empty($height) ) |
|
2176 | - $options['height'] = $height; |
|
2231 | + if ( !empty($width) ) { |
|
2232 | + $options['width'] = $width; |
|
2233 | + } |
|
2234 | + if ( !empty($height) ) { |
|
2235 | + $options['height'] = $height; |
|
2236 | + } |
|
2177 | 2237 | $params = array_slice(func_get_args(), 4); |
2178 | 2238 | $args = array($id, $name, $control_callback, $options); |
2179 | - if ( !empty($params) ) |
|
2180 | - $args = array_merge($args, $params); |
|
2239 | + if ( !empty($params) ) { |
|
2240 | + $args = array_merge($args, $params); |
|
2241 | + } |
|
2181 | 2242 | |
2182 | 2243 | call_user_func_array('wp_register_widget_control', $args); |
2183 | 2244 | } |
@@ -2211,29 +2272,34 @@ discard block |
||
2211 | 2272 | function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { |
2212 | 2273 | _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' ); |
2213 | 2274 | global $wpdb; |
2214 | - if ( !is_numeric( $user_id ) ) |
|
2215 | - return false; |
|
2275 | + if ( !is_numeric( $user_id ) ) { |
|
2276 | + return false; |
|
2277 | + } |
|
2216 | 2278 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
2217 | 2279 | |
2218 | - if ( is_array($meta_value) || is_object($meta_value) ) |
|
2219 | - $meta_value = serialize($meta_value); |
|
2280 | + if ( is_array($meta_value) || is_object($meta_value) ) { |
|
2281 | + $meta_value = serialize($meta_value); |
|
2282 | + } |
|
2220 | 2283 | $meta_value = trim( $meta_value ); |
2221 | 2284 | |
2222 | 2285 | $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
2223 | 2286 | |
2224 | - if ( $cur && $cur->umeta_id ) |
|
2225 | - do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2287 | + if ( $cur && $cur->umeta_id ) { |
|
2288 | + do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2289 | + } |
|
2226 | 2290 | |
2227 | - if ( ! empty($meta_value) ) |
|
2228 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); |
|
2229 | - else |
|
2230 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2291 | + if ( ! empty($meta_value) ) { |
|
2292 | + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); |
|
2293 | + } else { |
|
2294 | + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2295 | + } |
|
2231 | 2296 | |
2232 | 2297 | clean_user_cache( $user_id ); |
2233 | 2298 | wp_cache_delete( $user_id, 'user_meta' ); |
2234 | 2299 | |
2235 | - if ( $cur && $cur->umeta_id ) |
|
2236 | - do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2300 | + if ( $cur && $cur->umeta_id ) { |
|
2301 | + do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2302 | + } |
|
2237 | 2303 | |
2238 | 2304 | return true; |
2239 | 2305 | } |
@@ -2259,35 +2325,39 @@ discard block |
||
2259 | 2325 | global $wpdb; |
2260 | 2326 | $user_id = (int) $user_id; |
2261 | 2327 | |
2262 | - if ( !$user_id ) |
|
2263 | - return false; |
|
2328 | + if ( !$user_id ) { |
|
2329 | + return false; |
|
2330 | + } |
|
2264 | 2331 | |
2265 | 2332 | if ( !empty($meta_key) ) { |
2266 | 2333 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
2267 | 2334 | $user = wp_cache_get($user_id, 'users'); |
2268 | 2335 | // Check the cached user object |
2269 | - if ( false !== $user && isset($user->$meta_key) ) |
|
2270 | - $metas = array($user->$meta_key); |
|
2271 | - else |
|
2272 | - $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2336 | + if ( false !== $user && isset($user->$meta_key) ) { |
|
2337 | + $metas = array($user->$meta_key); |
|
2338 | + } else { |
|
2339 | + $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2340 | + } |
|
2273 | 2341 | } else { |
2274 | 2342 | $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); |
2275 | 2343 | } |
2276 | 2344 | |
2277 | 2345 | if ( empty($metas) ) { |
2278 | - if ( empty($meta_key) ) |
|
2279 | - return array(); |
|
2280 | - else |
|
2281 | - return ''; |
|
2346 | + if ( empty($meta_key) ) { |
|
2347 | + return array(); |
|
2348 | + } else { |
|
2349 | + return ''; |
|
2350 | + } |
|
2282 | 2351 | } |
2283 | 2352 | |
2284 | 2353 | $metas = array_map('maybe_unserialize', $metas); |
2285 | 2354 | |
2286 | - if ( count($metas) == 1 ) |
|
2287 | - return $metas[0]; |
|
2288 | - else |
|
2289 | - return $metas; |
|
2290 | -} |
|
2355 | + if ( count($metas) == 1 ) { |
|
2356 | + return $metas[0]; |
|
2357 | + } else { |
|
2358 | + return $metas; |
|
2359 | + } |
|
2360 | + } |
|
2291 | 2361 | |
2292 | 2362 | /** |
2293 | 2363 | * Update metadata of user. |
@@ -2310,13 +2380,15 @@ discard block |
||
2310 | 2380 | function update_usermeta( $user_id, $meta_key, $meta_value ) { |
2311 | 2381 | _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' ); |
2312 | 2382 | global $wpdb; |
2313 | - if ( !is_numeric( $user_id ) ) |
|
2314 | - return false; |
|
2383 | + if ( !is_numeric( $user_id ) ) { |
|
2384 | + return false; |
|
2385 | + } |
|
2315 | 2386 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
2316 | 2387 | |
2317 | 2388 | /** @todo Might need fix because usermeta data is assumed to be already escaped */ |
2318 | - if ( is_string($meta_value) ) |
|
2319 | - $meta_value = stripslashes($meta_value); |
|
2389 | + if ( is_string($meta_value) ) { |
|
2390 | + $meta_value = stripslashes($meta_value); |
|
2391 | + } |
|
2320 | 2392 | $meta_value = maybe_serialize($meta_value); |
2321 | 2393 | |
2322 | 2394 | if (empty($meta_value)) { |
@@ -2325,23 +2397,26 @@ discard block |
||
2325 | 2397 | |
2326 | 2398 | $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
2327 | 2399 | |
2328 | - if ( $cur ) |
|
2329 | - do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2400 | + if ( $cur ) { |
|
2401 | + do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2402 | + } |
|
2330 | 2403 | |
2331 | - if ( !$cur ) |
|
2332 | - $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); |
|
2333 | - elseif ( $cur->meta_value != $meta_value ) |
|
2334 | - $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); |
|
2335 | - else |
|
2336 | - return false; |
|
2404 | + if ( !$cur ) { |
|
2405 | + $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); |
|
2406 | + } elseif ( $cur->meta_value != $meta_value ) { |
|
2407 | + $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); |
|
2408 | + } else { |
|
2409 | + return false; |
|
2410 | + } |
|
2337 | 2411 | |
2338 | 2412 | clean_user_cache( $user_id ); |
2339 | 2413 | wp_cache_delete( $user_id, 'user_meta' ); |
2340 | 2414 | |
2341 | - if ( !$cur ) |
|
2342 | - do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); |
|
2343 | - else |
|
2344 | - do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2415 | + if ( !$cur ) { |
|
2416 | + do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); |
|
2417 | + } else { |
|
2418 | + do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2419 | + } |
|
2345 | 2420 | |
2346 | 2421 | return true; |
2347 | 2422 | } |
@@ -2385,10 +2460,12 @@ discard block |
||
2385 | 2460 | function automatic_feed_links( $add = true ) { |
2386 | 2461 | _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" ); |
2387 | 2462 | |
2388 | - if ( $add ) |
|
2389 | - add_theme_support( 'automatic-feed-links' ); |
|
2390 | - else |
|
2391 | - remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+ |
|
2463 | + if ( $add ) { |
|
2464 | + add_theme_support( 'automatic-feed-links' ); |
|
2465 | + } else { |
|
2466 | + remove_action( 'wp_head', 'feed_links_extra', 3 ); |
|
2467 | + } |
|
2468 | + // Just do this yourself in 3.0+ |
|
2392 | 2469 | } |
2393 | 2470 | |
2394 | 2471 | /** |
@@ -2459,10 +2536,11 @@ discard block |
||
2459 | 2536 | // Fixes for browsers' JavaScript bugs. |
2460 | 2537 | global $is_macIE, $is_winIE; |
2461 | 2538 | |
2462 | - if ( $is_winIE || $is_macIE ) |
|
2463 | - $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
2539 | + if ( $is_winIE || $is_macIE ) { |
|
2540 | + $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
2464 | 2541 | "funky_javascript_callback", |
2465 | 2542 | $text); |
2543 | + } |
|
2466 | 2544 | |
2467 | 2545 | return $text; |
2468 | 2546 | } |
@@ -2516,8 +2594,9 @@ discard block |
||
2516 | 2594 | |
2517 | 2595 | global $plugin_page; |
2518 | 2596 | |
2519 | - if ( isset($plugin_page) ) |
|
2520 | - return true; |
|
2597 | + if ( isset($plugin_page) ) { |
|
2598 | + return true; |
|
2599 | + } |
|
2521 | 2600 | |
2522 | 2601 | return false; |
2523 | 2602 | } |
@@ -2589,8 +2668,9 @@ discard block |
||
2589 | 2668 | $objects = array(); |
2590 | 2669 | |
2591 | 2670 | $ids = array_map('intval', $ids); |
2592 | - foreach ( $ids as $id ) |
|
2593 | - $objects[$id] = array(); |
|
2671 | + foreach ( $ids as $id ) { |
|
2672 | + $objects[$id] = array(); |
|
2673 | + } |
|
2594 | 2674 | |
2595 | 2675 | $metas = update_meta_cache('user', $ids); |
2596 | 2676 | |
@@ -2621,21 +2701,25 @@ discard block |
||
2621 | 2701 | _deprecated_function( __FUNCTION__, '3.3.0' ); |
2622 | 2702 | |
2623 | 2703 | if ( is_object($user) ) { |
2624 | - if ( !isset($user->ID) ) |
|
2625 | - $user->ID = 0; |
|
2704 | + if ( !isset($user->ID) ) { |
|
2705 | + $user->ID = 0; |
|
2706 | + } |
|
2626 | 2707 | if ( ! ( $user instanceof WP_User ) ) { |
2627 | 2708 | $vars = get_object_vars($user); |
2628 | 2709 | foreach ( array_keys($vars) as $field ) { |
2629 | - if ( is_string($user->$field) || is_numeric($user->$field) ) |
|
2630 | - $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); |
|
2710 | + if ( is_string($user->$field) || is_numeric($user->$field) ) { |
|
2711 | + $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); |
|
2712 | + } |
|
2631 | 2713 | } |
2632 | 2714 | } |
2633 | 2715 | $user->filter = $context; |
2634 | 2716 | } else { |
2635 | - if ( !isset($user['ID']) ) |
|
2636 | - $user['ID'] = 0; |
|
2637 | - foreach ( array_keys($user) as $field ) |
|
2638 | - $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); |
|
2717 | + if ( !isset($user['ID']) ) { |
|
2718 | + $user['ID'] = 0; |
|
2719 | + } |
|
2720 | + foreach ( array_keys($user) as $field ) { |
|
2721 | + $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); |
|
2722 | + } |
|
2639 | 2723 | $user['filter'] = $context; |
2640 | 2724 | } |
2641 | 2725 | |
@@ -2661,14 +2745,16 @@ discard block |
||
2661 | 2745 | |
2662 | 2746 | $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); |
2663 | 2747 | // If there is no post stop. |
2664 | - if ( empty($posts) ) |
|
2665 | - return; |
|
2748 | + if ( empty($posts) ) { |
|
2749 | + return; |
|
2750 | + } |
|
2666 | 2751 | |
2667 | 2752 | // Even though we limited get_posts to return only 1 item it still returns an array of objects. |
2668 | 2753 | $post = $posts[0]; |
2669 | 2754 | |
2670 | - if ( empty($post->post_title) ) |
|
2671 | - $post->post_title = $start ? __('First Post') : __('Last Post'); |
|
2755 | + if ( empty($post->post_title) ) { |
|
2756 | + $post->post_title = $start ? __('First Post') : __('Last Post'); |
|
2757 | + } |
|
2672 | 2758 | |
2673 | 2759 | $date = mysql2date(get_option('date_format'), $post->post_date); |
2674 | 2760 | |
@@ -2739,11 +2825,13 @@ discard block |
||
2739 | 2825 | function get_parent_post_rel_link( $title = '%title' ) { |
2740 | 2826 | _deprecated_function( __FUNCTION__, '3.3.0' ); |
2741 | 2827 | |
2742 | - if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) |
|
2743 | - $post = get_post($GLOBALS['post']->post_parent); |
|
2828 | + if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) { |
|
2829 | + $post = get_post($GLOBALS['post']->post_parent); |
|
2830 | + } |
|
2744 | 2831 | |
2745 | - if ( empty($post) ) |
|
2746 | - return; |
|
2832 | + if ( empty($post) ) { |
|
2833 | + return; |
|
2834 | + } |
|
2747 | 2835 | |
2748 | 2836 | $date = mysql2date(get_option('date_format'), $post->post_date); |
2749 | 2837 | |
@@ -2786,12 +2874,13 @@ discard block |
||
2786 | 2874 | $user_id = get_current_user_id(); |
2787 | 2875 | |
2788 | 2876 | if ( 0 != $user_id ) { |
2789 | - if ( is_admin() ) |
|
2790 | - $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); |
|
2791 | - elseif ( is_multisite() ) |
|
2792 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); |
|
2793 | - else |
|
2794 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); |
|
2877 | + if ( is_admin() ) { |
|
2878 | + $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); |
|
2879 | + } elseif ( is_multisite() ) { |
|
2880 | + $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); |
|
2881 | + } else { |
|
2882 | + $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); |
|
2883 | + } |
|
2795 | 2884 | } |
2796 | 2885 | } |
2797 | 2886 | |
@@ -2843,9 +2932,10 @@ discard block |
||
2843 | 2932 | */ |
2844 | 2933 | function debug_fwrite( $fp, $string ) { |
2845 | 2934 | _deprecated_function( __FUNCTION__, 'error_log()' ); |
2846 | - if ( ! empty( $GLOBALS['debug'] ) ) |
|
2847 | - error_log( $string ); |
|
2848 | -} |
|
2935 | + if ( ! empty( $GLOBALS['debug'] ) ) { |
|
2936 | + error_log( $string ); |
|
2937 | + } |
|
2938 | + } |
|
2849 | 2939 | |
2850 | 2940 | /** |
2851 | 2941 | * Close the debugging file handle. |
@@ -2879,18 +2969,20 @@ discard block |
||
2879 | 2969 | _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' ); |
2880 | 2970 | |
2881 | 2971 | global $wp_themes; |
2882 | - if ( isset( $wp_themes ) ) |
|
2883 | - return $wp_themes; |
|
2972 | + if ( isset( $wp_themes ) ) { |
|
2973 | + return $wp_themes; |
|
2974 | + } |
|
2884 | 2975 | |
2885 | 2976 | $themes = wp_get_themes(); |
2886 | 2977 | $wp_themes = array(); |
2887 | 2978 | |
2888 | 2979 | foreach ( $themes as $theme ) { |
2889 | 2980 | $name = $theme->get('Name'); |
2890 | - if ( isset( $wp_themes[ $name ] ) ) |
|
2891 | - $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; |
|
2892 | - else |
|
2893 | - $wp_themes[ $name ] = $theme; |
|
2981 | + if ( isset( $wp_themes[ $name ] ) ) { |
|
2982 | + $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; |
|
2983 | + } else { |
|
2984 | + $wp_themes[ $name ] = $theme; |
|
2985 | + } |
|
2894 | 2986 | } |
2895 | 2987 | |
2896 | 2988 | return $wp_themes; |
@@ -2910,8 +3002,9 @@ discard block |
||
2910 | 3002 | _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' ); |
2911 | 3003 | |
2912 | 3004 | $themes = get_themes(); |
2913 | - if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) |
|
2914 | - return $themes[ $theme ]; |
|
3005 | + if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) { |
|
3006 | + return $themes[ $theme ]; |
|
3007 | + } |
|
2915 | 3008 | return null; |
2916 | 3009 | } |
2917 | 3010 | |
@@ -2927,8 +3020,9 @@ discard block |
||
2927 | 3020 | function get_current_theme() { |
2928 | 3021 | _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); |
2929 | 3022 | |
2930 | - if ( $theme = get_option( 'current_theme' ) ) |
|
2931 | - return $theme; |
|
3023 | + if ( $theme = get_option( 'current_theme' ) ) { |
|
3024 | + return $theme; |
|
3025 | + } |
|
2932 | 3026 | |
2933 | 3027 | return wp_get_theme()->get('Name'); |
2934 | 3028 | } |
@@ -2948,10 +3042,11 @@ discard block |
||
2948 | 3042 | function clean_pre($matches) { |
2949 | 3043 | _deprecated_function( __FUNCTION__, '3.4.0' ); |
2950 | 3044 | |
2951 | - if ( is_array($matches) ) |
|
2952 | - $text = $matches[1] . $matches[2] . "</pre>"; |
|
2953 | - else |
|
2954 | - $text = $matches; |
|
3045 | + if ( is_array($matches) ) { |
|
3046 | + $text = $matches[1] . $matches[2] . "</pre>"; |
|
3047 | + } else { |
|
3048 | + $text = $matches; |
|
3049 | + } |
|
2955 | 3050 | |
2956 | 3051 | $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text); |
2957 | 3052 | $text = str_replace('<p>', "\n", $text); |
@@ -2978,8 +3073,9 @@ discard block |
||
2978 | 3073 | 'wp-head-callback' => $wp_head_callback, |
2979 | 3074 | 'admin-head-callback' => $admin_head_callback, |
2980 | 3075 | ); |
2981 | - if ( $admin_preview_callback ) |
|
2982 | - $args['admin-preview-callback'] = $admin_preview_callback; |
|
3076 | + if ( $admin_preview_callback ) { |
|
3077 | + $args['admin-preview-callback'] = $admin_preview_callback; |
|
3078 | + } |
|
2983 | 3079 | return add_theme_support( 'custom-header', $args ); |
2984 | 3080 | } |
2985 | 3081 | |
@@ -3011,12 +3107,15 @@ discard block |
||
3011 | 3107 | function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { |
3012 | 3108 | _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' ); |
3013 | 3109 | $args = array(); |
3014 | - if ( $wp_head_callback ) |
|
3015 | - $args['wp-head-callback'] = $wp_head_callback; |
|
3016 | - if ( $admin_head_callback ) |
|
3017 | - $args['admin-head-callback'] = $admin_head_callback; |
|
3018 | - if ( $admin_preview_callback ) |
|
3019 | - $args['admin-preview-callback'] = $admin_preview_callback; |
|
3110 | + if ( $wp_head_callback ) { |
|
3111 | + $args['wp-head-callback'] = $wp_head_callback; |
|
3112 | + } |
|
3113 | + if ( $admin_head_callback ) { |
|
3114 | + $args['admin-head-callback'] = $admin_head_callback; |
|
3115 | + } |
|
3116 | + if ( $admin_preview_callback ) { |
|
3117 | + $args['admin-preview-callback'] = $admin_preview_callback; |
|
3118 | + } |
|
3020 | 3119 | return add_theme_support( 'custom-background', $args ); |
3021 | 3120 | } |
3022 | 3121 | |
@@ -3063,8 +3162,9 @@ discard block |
||
3063 | 3162 | ); |
3064 | 3163 | |
3065 | 3164 | foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { |
3066 | - if ( ! isset( $theme_data[ $extra_header ] ) ) |
|
3067 | - $theme_data[ $extra_header ] = $theme->get( $extra_header ); |
|
3165 | + if ( ! isset( $theme_data[ $extra_header ] ) ) { |
|
3166 | + $theme_data[ $extra_header ] = $theme->get( $extra_header ); |
|
3167 | + } |
|
3068 | 3168 | } |
3069 | 3169 | |
3070 | 3170 | return $theme_data; |
@@ -3133,9 +3233,10 @@ discard block |
||
3133 | 3233 | */ |
3134 | 3234 | function sticky_class( $post_id = null ) { |
3135 | 3235 | _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' ); |
3136 | - if ( is_sticky( $post_id ) ) |
|
3137 | - echo ' sticky'; |
|
3138 | -} |
|
3236 | + if ( is_sticky( $post_id ) ) { |
|
3237 | + echo ' sticky'; |
|
3238 | + } |
|
3239 | + } |
|
3139 | 3240 | |
3140 | 3241 | /** |
3141 | 3242 | * Retrieve post ancestors. |
@@ -3166,16 +3267,18 @@ discard block |
||
3166 | 3267 | function wp_load_image( $file ) { |
3167 | 3268 | _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); |
3168 | 3269 | |
3169 | - if ( is_numeric( $file ) ) |
|
3170 | - $file = get_attached_file( $file ); |
|
3270 | + if ( is_numeric( $file ) ) { |
|
3271 | + $file = get_attached_file( $file ); |
|
3272 | + } |
|
3171 | 3273 | |
3172 | 3274 | if ( ! is_file( $file ) ) { |
3173 | 3275 | /* translators: %s: file name */ |
3174 | 3276 | return sprintf( __( 'File “%s” doesn’t exist?' ), $file ); |
3175 | 3277 | } |
3176 | 3278 | |
3177 | - if ( ! function_exists('imagecreatefromstring') ) |
|
3178 | - return __('The GD image library is not installed.'); |
|
3279 | + if ( ! function_exists('imagecreatefromstring') ) { |
|
3280 | + return __('The GD image library is not installed.'); |
|
3281 | + } |
|
3179 | 3282 | |
3180 | 3283 | // Set artificially high because GD uses uncompressed images in memory. |
3181 | 3284 | wp_raise_memory_limit( 'image' ); |
@@ -3218,19 +3321,22 @@ discard block |
||
3218 | 3321 | _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); |
3219 | 3322 | |
3220 | 3323 | $editor = wp_get_image_editor( $file ); |
3221 | - if ( is_wp_error( $editor ) ) |
|
3222 | - return $editor; |
|
3324 | + if ( is_wp_error( $editor ) ) { |
|
3325 | + return $editor; |
|
3326 | + } |
|
3223 | 3327 | $editor->set_quality( $jpeg_quality ); |
3224 | 3328 | |
3225 | 3329 | $resized = $editor->resize( $max_w, $max_h, $crop ); |
3226 | - if ( is_wp_error( $resized ) ) |
|
3227 | - return $resized; |
|
3330 | + if ( is_wp_error( $resized ) ) { |
|
3331 | + return $resized; |
|
3332 | + } |
|
3228 | 3333 | |
3229 | 3334 | $dest_file = $editor->generate_filename( $suffix, $dest_path ); |
3230 | 3335 | $saved = $editor->save( $dest_file ); |
3231 | 3336 | |
3232 | - if ( is_wp_error( $saved ) ) |
|
3233 | - return $saved; |
|
3337 | + if ( is_wp_error( $saved ) ) { |
|
3338 | + return $saved; |
|
3339 | + } |
|
3234 | 3340 | |
3235 | 3341 | return $dest_file; |
3236 | 3342 | } |
@@ -3268,8 +3374,9 @@ discard block |
||
3268 | 3374 | function user_pass_ok($user_login, $user_pass) { |
3269 | 3375 | _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' ); |
3270 | 3376 | $user = wp_authenticate( $user_login, $user_pass ); |
3271 | - if ( is_wp_error( $user ) ) |
|
3272 | - return false; |
|
3377 | + if ( is_wp_error( $user ) ) { |
|
3378 | + return false; |
|
3379 | + } |
|
3273 | 3380 | |
3274 | 3381 | return true; |
3275 | 3382 | } |
@@ -3375,8 +3482,9 @@ discard block |
||
3375 | 3482 | global $wp_rich_edit_exists; |
3376 | 3483 | _deprecated_function( __FUNCTION__, '3.9.0' ); |
3377 | 3484 | |
3378 | - if ( ! isset( $wp_rich_edit_exists ) ) |
|
3379 | - $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); |
|
3485 | + if ( ! isset( $wp_rich_edit_exists ) ) { |
|
3486 | + $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); |
|
3487 | + } |
|
3380 | 3488 | |
3381 | 3489 | return $wp_rich_edit_exists; |
3382 | 3490 | } |
@@ -3584,8 +3692,10 @@ discard block |
||
3584 | 3692 | function wp_htmledit_pre($output) { |
3585 | 3693 | _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); |
3586 | 3694 | |
3587 | - if ( !empty($output) ) |
|
3588 | - $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > & |
|
3695 | + if ( !empty($output) ) { |
|
3696 | + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
|
3697 | + } |
|
3698 | + // convert only < > & |
|
3589 | 3699 | |
3590 | 3700 | /** |
3591 | 3701 | * Filters the text before it is formatted for the HTML editor. |
@@ -3635,21 +3745,24 @@ discard block |
||
3635 | 3745 | |
3636 | 3746 | @set_time_limit( 60 ); |
3637 | 3747 | |
3638 | - if ( $red > 5 ) |
|
3639 | - return false; |
|
3748 | + if ( $red > 5 ) { |
|
3749 | + return false; |
|
3750 | + } |
|
3640 | 3751 | |
3641 | 3752 | $options = array(); |
3642 | 3753 | $options['redirection'] = 5; |
3643 | 3754 | |
3644 | - if ( false == $file_path ) |
|
3645 | - $options['method'] = 'HEAD'; |
|
3646 | - else |
|
3647 | - $options['method'] = 'GET'; |
|
3755 | + if ( false == $file_path ) { |
|
3756 | + $options['method'] = 'HEAD'; |
|
3757 | + } else { |
|
3758 | + $options['method'] = 'GET'; |
|
3759 | + } |
|
3648 | 3760 | |
3649 | 3761 | $response = wp_safe_remote_request( $url, $options ); |
3650 | 3762 | |
3651 | - if ( is_wp_error( $response ) ) |
|
3652 | - return false; |
|
3763 | + if ( is_wp_error( $response ) ) { |
|
3764 | + return false; |
|
3765 | + } |
|
3653 | 3766 | |
3654 | 3767 | $headers = wp_remote_retrieve_headers( $response ); |
3655 | 3768 | $headers['response'] = wp_remote_retrieve_response_code( $response ); |
@@ -3659,13 +3772,15 @@ discard block |
||
3659 | 3772 | return wp_get_http( $headers['location'], $file_path, ++$red ); |
3660 | 3773 | } |
3661 | 3774 | |
3662 | - if ( false == $file_path ) |
|
3663 | - return $headers; |
|
3775 | + if ( false == $file_path ) { |
|
3776 | + return $headers; |
|
3777 | + } |
|
3664 | 3778 | |
3665 | 3779 | // GET request - write it to the supplied filename |
3666 | 3780 | $out_fp = fopen($file_path, 'w'); |
3667 | - if ( !$out_fp ) |
|
3668 | - return $headers; |
|
3781 | + if ( !$out_fp ) { |
|
3782 | + return $headers; |
|
3783 | + } |
|
3669 | 3784 | |
3670 | 3785 | fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); |
3671 | 3786 | fclose($out_fp); |
@@ -3816,13 +3931,14 @@ discard block |
||
3816 | 3931 | function _usort_terms_by_ID( $a, $b ) { |
3817 | 3932 | _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' ); |
3818 | 3933 | |
3819 | - if ( $a->term_id > $b->term_id ) |
|
3820 | - return 1; |
|
3821 | - elseif ( $a->term_id < $b->term_id ) |
|
3822 | - return -1; |
|
3823 | - else |
|
3824 | - return 0; |
|
3825 | -} |
|
3934 | + if ( $a->term_id > $b->term_id ) { |
|
3935 | + return 1; |
|
3936 | + } elseif ( $a->term_id < $b->term_id ) { |
|
3937 | + return -1; |
|
3938 | + } else { |
|
3939 | + return 0; |
|
3940 | + } |
|
3941 | + } |
|
3826 | 3942 | |
3827 | 3943 | /** |
3828 | 3944 | * Sort categories by name. |
@@ -3862,19 +3978,22 @@ discard block |
||
3862 | 3978 | |
3863 | 3979 | _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' ); |
3864 | 3980 | |
3865 | - if ( empty( $_menu_item_sort_prop ) ) |
|
3866 | - return 0; |
|
3981 | + if ( empty( $_menu_item_sort_prop ) ) { |
|
3982 | + return 0; |
|
3983 | + } |
|
3867 | 3984 | |
3868 | - if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) |
|
3869 | - return 0; |
|
3985 | + if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) { |
|
3986 | + return 0; |
|
3987 | + } |
|
3870 | 3988 | |
3871 | 3989 | $_a = (int) $a->$_menu_item_sort_prop; |
3872 | 3990 | $_b = (int) $b->$_menu_item_sort_prop; |
3873 | 3991 | |
3874 | - if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) |
|
3875 | - return 0; |
|
3876 | - elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) |
|
3877 | - return $_a < $_b ? -1 : 1; |
|
3878 | - else |
|
3879 | - return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); |
|
3880 | -} |
|
3992 | + if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) { |
|
3993 | + return 0; |
|
3994 | + } elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) { |
|
3995 | + return $_a < $_b ? -1 : 1; |
|
3996 | + } else { |
|
3997 | + return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); |
|
3998 | + } |
|
3999 | + } |
@@ -432,7 +432,7 @@ |
||
432 | 432 | * |
433 | 433 | * @see get_children() |
434 | 434 | * |
435 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global `$post`. |
|
435 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global `$post`. |
|
436 | 436 | * @param array|null $args Optional. Arguments for retrieving post revisions. Default null. |
437 | 437 | * @return array An array of revisions, or an empty array if none. |
438 | 438 | */ |
@@ -110,20 +110,25 @@ discard block |
||
110 | 110 | * @return int|WP_Error|void Void or 0 if error, new revision ID, if success. |
111 | 111 | */ |
112 | 112 | function wp_save_post_revision( $post_id ) { |
113 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
114 | - return; |
|
113 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
114 | + return; |
|
115 | + } |
|
115 | 116 | |
116 | - if ( ! $post = get_post( $post_id ) ) |
|
117 | - return; |
|
117 | + if ( ! $post = get_post( $post_id ) ) { |
|
118 | + return; |
|
119 | + } |
|
118 | 120 | |
119 | - if ( ! post_type_supports( $post->post_type, 'revisions' ) ) |
|
120 | - return; |
|
121 | + if ( ! post_type_supports( $post->post_type, 'revisions' ) ) { |
|
122 | + return; |
|
123 | + } |
|
121 | 124 | |
122 | - if ( 'auto-draft' == $post->post_status ) |
|
123 | - return; |
|
125 | + if ( 'auto-draft' == $post->post_status ) { |
|
126 | + return; |
|
127 | + } |
|
124 | 128 | |
125 | - if ( ! wp_revisions_enabled( $post ) ) |
|
126 | - return; |
|
129 | + if ( ! wp_revisions_enabled( $post ) ) { |
|
130 | + return; |
|
131 | + } |
|
127 | 132 | |
128 | 133 | // Compare the proposed update with the last stored revision verifying that |
129 | 134 | // they are different, unless a plugin tells us to always save regardless. |
@@ -189,21 +194,24 @@ discard block |
||
189 | 194 | // delete the oldest ones. |
190 | 195 | $revisions_to_keep = wp_revisions_to_keep( $post ); |
191 | 196 | |
192 | - if ( $revisions_to_keep < 0 ) |
|
193 | - return $return; |
|
197 | + if ( $revisions_to_keep < 0 ) { |
|
198 | + return $return; |
|
199 | + } |
|
194 | 200 | |
195 | 201 | $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); |
196 | 202 | |
197 | 203 | $delete = count($revisions) - $revisions_to_keep; |
198 | 204 | |
199 | - if ( $delete < 1 ) |
|
200 | - return $return; |
|
205 | + if ( $delete < 1 ) { |
|
206 | + return $return; |
|
207 | + } |
|
201 | 208 | |
202 | 209 | $revisions = array_slice( $revisions, 0, $delete ); |
203 | 210 | |
204 | 211 | for ( $i = 0; isset( $revisions[$i] ); $i++ ) { |
205 | - if ( false !== strpos( $revisions[ $i ]->post_name, 'autosave' ) ) |
|
206 | - continue; |
|
212 | + if ( false !== strpos( $revisions[ $i ]->post_name, 'autosave' ) ) { |
|
213 | + continue; |
|
214 | + } |
|
207 | 215 | |
208 | 216 | wp_delete_post_revision( $revisions[ $i ]->ID ); |
209 | 217 | } |
@@ -229,8 +237,9 @@ discard block |
||
229 | 237 | |
230 | 238 | foreach ( $revisions as $revision ) { |
231 | 239 | if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) { |
232 | - if ( $user_id && $user_id != $revision->post_author ) |
|
233 | - continue; |
|
240 | + if ( $user_id && $user_id != $revision->post_author ) { |
|
241 | + continue; |
|
242 | + } |
|
234 | 243 | |
235 | 244 | return $revision; |
236 | 245 | } |
@@ -248,8 +257,9 @@ discard block |
||
248 | 257 | * @return false|int False if not a revision, ID of revision's parent otherwise. |
249 | 258 | */ |
250 | 259 | function wp_is_post_revision( $post ) { |
251 | - if ( !$post = wp_get_post_revision( $post ) ) |
|
252 | - return false; |
|
260 | + if ( !$post = wp_get_post_revision( $post ) ) { |
|
261 | + return false; |
|
262 | + } |
|
253 | 263 | |
254 | 264 | return (int) $post->post_parent; |
255 | 265 | } |
@@ -263,11 +273,13 @@ discard block |
||
263 | 273 | * @return false|int False if not a revision, ID of autosave's parent otherwise |
264 | 274 | */ |
265 | 275 | function wp_is_post_autosave( $post ) { |
266 | - if ( !$post = wp_get_post_revision( $post ) ) |
|
267 | - return false; |
|
276 | + if ( !$post = wp_get_post_revision( $post ) ) { |
|
277 | + return false; |
|
278 | + } |
|
268 | 279 | |
269 | - if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) |
|
270 | - return (int) $post->post_parent; |
|
280 | + if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) { |
|
281 | + return (int) $post->post_parent; |
|
282 | + } |
|
271 | 283 | |
272 | 284 | return false; |
273 | 285 | } |
@@ -283,23 +295,27 @@ discard block |
||
283 | 295 | * @return int|WP_Error WP_Error or 0 if error, new revision ID if success. |
284 | 296 | */ |
285 | 297 | function _wp_put_post_revision( $post = null, $autosave = false ) { |
286 | - if ( is_object($post) ) |
|
287 | - $post = get_object_vars( $post ); |
|
288 | - elseif ( !is_array($post) ) |
|
289 | - $post = get_post($post, ARRAY_A); |
|
298 | + if ( is_object($post) ) { |
|
299 | + $post = get_object_vars( $post ); |
|
300 | + } elseif ( !is_array($post) ) { |
|
301 | + $post = get_post($post, ARRAY_A); |
|
302 | + } |
|
290 | 303 | |
291 | - if ( ! $post || empty($post['ID']) ) |
|
292 | - return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) ); |
|
304 | + if ( ! $post || empty($post['ID']) ) { |
|
305 | + return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) ); |
|
306 | + } |
|
293 | 307 | |
294 | - if ( isset($post['post_type']) && 'revision' == $post['post_type'] ) |
|
295 | - return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); |
|
308 | + if ( isset($post['post_type']) && 'revision' == $post['post_type'] ) { |
|
309 | + return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); |
|
310 | + } |
|
296 | 311 | |
297 | 312 | $post = _wp_post_revision_data( $post, $autosave ); |
298 | 313 | $post = wp_slash($post); //since data is from db |
299 | 314 | |
300 | 315 | $revision_id = wp_insert_post( $post ); |
301 | - if ( is_wp_error($revision_id) ) |
|
302 | - return $revision_id; |
|
316 | + if ( is_wp_error($revision_id) ) { |
|
317 | + return $revision_id; |
|
318 | + } |
|
303 | 319 | |
304 | 320 | if ( $revision_id ) { |
305 | 321 | /** |
@@ -326,10 +342,12 @@ discard block |
||
326 | 342 | * @return WP_Post|array|null Null if error or post object if success. |
327 | 343 | */ |
328 | 344 | function wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') { |
329 | - if ( !$revision = get_post( $post, OBJECT, $filter ) ) |
|
330 | - return $revision; |
|
331 | - if ( 'revision' !== $revision->post_type ) |
|
332 | - return null; |
|
345 | + if ( !$revision = get_post( $post, OBJECT, $filter ) ) { |
|
346 | + return $revision; |
|
347 | + } |
|
348 | + if ( 'revision' !== $revision->post_type ) { |
|
349 | + return null; |
|
350 | + } |
|
333 | 351 | |
334 | 352 | if ( $output == OBJECT ) { |
335 | 353 | return $revision; |
@@ -356,27 +374,31 @@ discard block |
||
356 | 374 | * @return int|false|null Null if error, false if no fields to restore, (int) post ID if success. |
357 | 375 | */ |
358 | 376 | function wp_restore_post_revision( $revision_id, $fields = null ) { |
359 | - if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) ) |
|
360 | - return $revision; |
|
377 | + if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) ) { |
|
378 | + return $revision; |
|
379 | + } |
|
361 | 380 | |
362 | - if ( !is_array( $fields ) ) |
|
363 | - $fields = array_keys( _wp_post_revision_fields( $revision ) ); |
|
381 | + if ( !is_array( $fields ) ) { |
|
382 | + $fields = array_keys( _wp_post_revision_fields( $revision ) ); |
|
383 | + } |
|
364 | 384 | |
365 | 385 | $update = array(); |
366 | 386 | foreach ( array_intersect( array_keys( $revision ), $fields ) as $field ) { |
367 | 387 | $update[$field] = $revision[$field]; |
368 | 388 | } |
369 | 389 | |
370 | - if ( !$update ) |
|
371 | - return false; |
|
390 | + if ( !$update ) { |
|
391 | + return false; |
|
392 | + } |
|
372 | 393 | |
373 | 394 | $update['ID'] = $revision['post_parent']; |
374 | 395 | |
375 | 396 | $update = wp_slash( $update ); //since data is from db |
376 | 397 | |
377 | 398 | $post_id = wp_update_post( $update ); |
378 | - if ( ! $post_id || is_wp_error( $post_id ) ) |
|
379 | - return $post_id; |
|
399 | + if ( ! $post_id || is_wp_error( $post_id ) ) { |
|
400 | + return $post_id; |
|
401 | + } |
|
380 | 402 | |
381 | 403 | // Update last edit user |
382 | 404 | update_post_meta( $post_id, '_edit_last', get_current_user_id() ); |
@@ -438,19 +460,22 @@ discard block |
||
438 | 460 | */ |
439 | 461 | function wp_get_post_revisions( $post_id = 0, $args = null ) { |
440 | 462 | $post = get_post( $post_id ); |
441 | - if ( ! $post || empty( $post->ID ) ) |
|
442 | - return array(); |
|
463 | + if ( ! $post || empty( $post->ID ) ) { |
|
464 | + return array(); |
|
465 | + } |
|
443 | 466 | |
444 | 467 | $defaults = array( 'order' => 'DESC', 'orderby' => 'date ID', 'check_enabled' => true ); |
445 | 468 | $args = wp_parse_args( $args, $defaults ); |
446 | 469 | |
447 | - if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) |
|
448 | - return array(); |
|
470 | + if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) { |
|
471 | + return array(); |
|
472 | + } |
|
449 | 473 | |
450 | 474 | $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ); |
451 | 475 | |
452 | - if ( ! $revisions = get_children( $args ) ) |
|
453 | - return array(); |
|
476 | + if ( ! $revisions = get_children( $args ) ) { |
|
477 | + return array(); |
|
478 | + } |
|
454 | 479 | |
455 | 480 | return $revisions; |
456 | 481 | } |
@@ -483,13 +508,15 @@ discard block |
||
483 | 508 | function wp_revisions_to_keep( $post ) { |
484 | 509 | $num = WP_POST_REVISIONS; |
485 | 510 | |
486 | - if ( true === $num ) |
|
487 | - $num = -1; |
|
488 | - else |
|
489 | - $num = intval( $num ); |
|
511 | + if ( true === $num ) { |
|
512 | + $num = -1; |
|
513 | + } else { |
|
514 | + $num = intval( $num ); |
|
515 | + } |
|
490 | 516 | |
491 | - if ( ! post_type_supports( $post->post_type, 'revisions' ) ) |
|
492 | - $num = 0; |
|
517 | + if ( ! post_type_supports( $post->post_type, 'revisions' ) ) { |
|
518 | + $num = 0; |
|
519 | + } |
|
493 | 520 | |
494 | 521 | /** |
495 | 522 | * Filters the number of revisions to save for the given post. |
@@ -545,8 +572,9 @@ discard block |
||
545 | 572 | if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) { |
546 | 573 | $id = (int) $_GET['preview_id']; |
547 | 574 | |
548 | - if ( false === wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) |
|
549 | - wp_die( __('Sorry, you are not allowed to preview drafts.') ); |
|
575 | + if ( false === wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) { |
|
576 | + wp_die( __('Sorry, you are not allowed to preview drafts.') ); |
|
577 | + } |
|
550 | 578 | |
551 | 579 | add_filter('the_preview', '_set_preview'); |
552 | 580 | } |
@@ -564,16 +592,20 @@ discard block |
||
564 | 592 | * @return array |
565 | 593 | */ |
566 | 594 | function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { |
567 | - if ( ! $post = get_post() ) |
|
568 | - return $terms; |
|
595 | + if ( ! $post = get_post() ) { |
|
596 | + return $terms; |
|
597 | + } |
|
569 | 598 | |
570 | - if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) |
|
571 | - return $terms; |
|
599 | + if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) { |
|
600 | + return $terms; |
|
601 | + } |
|
572 | 602 | |
573 | - if ( 'standard' == $_REQUEST['post_format'] ) |
|
574 | - $terms = array(); |
|
575 | - elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) ) |
|
576 | - $terms = array( $term ); // Can only have one post format |
|
603 | + if ( 'standard' == $_REQUEST['post_format'] ) { |
|
604 | + $terms = array(); |
|
605 | + } elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) ) { |
|
606 | + $terms = array( $term ); |
|
607 | + } |
|
608 | + // Can only have one post format |
|
577 | 609 | |
578 | 610 | return $terms; |
579 | 611 | } |
@@ -616,13 +648,15 @@ discard block |
||
616 | 648 | * @return int|false |
617 | 649 | */ |
618 | 650 | function _wp_get_post_revision_version( $revision ) { |
619 | - if ( is_object( $revision ) ) |
|
620 | - $revision = get_object_vars( $revision ); |
|
621 | - elseif ( !is_array( $revision ) ) |
|
622 | - return false; |
|
651 | + if ( is_object( $revision ) ) { |
|
652 | + $revision = get_object_vars( $revision ); |
|
653 | + } elseif ( !is_array( $revision ) ) { |
|
654 | + return false; |
|
655 | + } |
|
623 | 656 | |
624 | - if ( preg_match( '/^\d+-(?:autosave|revision)-v(\d+)$/', $revision['post_name'], $matches ) ) |
|
625 | - return (int) $matches[1]; |
|
657 | + if ( preg_match( '/^\d+-(?:autosave|revision)-v(\d+)$/', $revision['post_name'], $matches ) ) { |
|
658 | + return (int) $matches[1]; |
|
659 | + } |
|
626 | 660 | |
627 | 661 | return 0; |
628 | 662 | } |
@@ -676,8 +710,9 @@ discard block |
||
676 | 710 | $this_revision_version = _wp_get_post_revision_version( $this_revision ); |
677 | 711 | |
678 | 712 | // Something terrible happened |
679 | - if ( false === $this_revision_version ) |
|
680 | - continue; |
|
713 | + if ( false === $this_revision_version ) { |
|
714 | + continue; |
|
715 | + } |
|
681 | 716 | |
682 | 717 | // 1 is the latest revision version, so we're already up to date. |
683 | 718 | // No need to add a copy of the post as latest revision. |
@@ -698,23 +733,26 @@ discard block |
||
698 | 733 | $prev_revision_version = _wp_get_post_revision_version( $prev_revision ); |
699 | 734 | |
700 | 735 | // If the previous revision is already up to date, it no longer has the information we need :( |
701 | - if ( $prev_revision_version < 1 ) |
|
702 | - $update['post_author'] = $prev_revision->post_author; |
|
736 | + if ( $prev_revision_version < 1 ) { |
|
737 | + $update['post_author'] = $prev_revision->post_author; |
|
738 | + } |
|
703 | 739 | } |
704 | 740 | |
705 | 741 | // Upgrade this revision |
706 | 742 | $result = $wpdb->update( $wpdb->posts, $update, array( 'ID' => $this_revision->ID ) ); |
707 | 743 | |
708 | - if ( $result ) |
|
709 | - wp_cache_delete( $this_revision->ID, 'posts' ); |
|
744 | + if ( $result ) { |
|
745 | + wp_cache_delete( $this_revision->ID, 'posts' ); |
|
746 | + } |
|
710 | 747 | |
711 | 748 | } while ( $prev_revision ); |
712 | 749 | |
713 | 750 | delete_option( $lock ); |
714 | 751 | |
715 | 752 | // Add a copy of the post as latest revision. |
716 | - if ( $add_last ) |
|
717 | - wp_save_post_revision( $post->ID ); |
|
753 | + if ( $add_last ) { |
|
754 | + wp_save_post_revision( $post->ID ); |
|
755 | + } |
|
718 | 756 | |
719 | 757 | return true; |
720 | 758 | } |
@@ -596,11 +596,11 @@ |
||
596 | 596 | } |
597 | 597 | |
598 | 598 | if ( empty( $_REQUEST['_thumbnail_id'] ) || |
599 | - empty( $_REQUEST['preview_id'] ) || |
|
600 | - $post->ID != $post_id || |
|
601 | - '_thumbnail_id' != $meta_key || |
|
602 | - 'revision' == $post->post_type || |
|
603 | - $post_id != $_REQUEST['preview_id'] |
|
599 | + empty( $_REQUEST['preview_id'] ) || |
|
600 | + $post->ID != $post_id || |
|
601 | + '_thumbnail_id' != $meta_key || |
|
602 | + 'revision' == $post->post_type || |
|
603 | + $post_id != $_REQUEST['preview_id'] |
|
604 | 604 | ) { |
605 | 605 | return $value; |
606 | 606 | } |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | * @param bool $deprecated Not used. |
22 | 22 | * @return array Array of fields that can be versioned. |
23 | 23 | */ |
24 | -function _wp_post_revision_fields( $post = array(), $deprecated = false ) { |
|
24 | +function _wp_post_revision_fields($post = array(), $deprecated = false) { |
|
25 | 25 | static $fields = null; |
26 | 26 | |
27 | - if ( ! is_array( $post ) ) { |
|
28 | - $post = get_post( $post, ARRAY_A ); |
|
27 | + if ( ! is_array($post)) { |
|
28 | + $post = get_post($post, ARRAY_A); |
|
29 | 29 | } |
30 | 30 | |
31 | - if ( is_null( $fields ) ) { |
|
31 | + if (is_null($fields)) { |
|
32 | 32 | // Allow these to be versioned |
33 | 33 | $fields = array( |
34 | - 'post_title' => __( 'Title' ), |
|
35 | - 'post_content' => __( 'Content' ), |
|
36 | - 'post_excerpt' => __( 'Excerpt' ), |
|
34 | + 'post_title' => __('Title'), |
|
35 | + 'post_content' => __('Content'), |
|
36 | + 'post_excerpt' => __('Excerpt'), |
|
37 | 37 | ); |
38 | 38 | } |
39 | 39 | |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | * 'post_content', and 'post_excerpt' by default. |
54 | 54 | * @param array $post A post array being processed for insertion as a post revision. |
55 | 55 | */ |
56 | - $fields = apply_filters( '_wp_post_revision_fields', $fields, $post ); |
|
56 | + $fields = apply_filters('_wp_post_revision_fields', $fields, $post); |
|
57 | 57 | |
58 | 58 | // WP uses these internally either in versioning or elsewhere - they cannot be versioned |
59 | - foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect ) { |
|
60 | - unset( $fields[ $protect ] ); |
|
59 | + foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) { |
|
60 | + unset($fields[$protect]); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -75,25 +75,25 @@ discard block |
||
75 | 75 | * @param bool $autosave Optional. Is the revision an autosave? Default false. |
76 | 76 | * @return array Post array ready to be inserted as a post revision. |
77 | 77 | */ |
78 | -function _wp_post_revision_data( $post = array(), $autosave = false ) { |
|
79 | - if ( ! is_array( $post ) ) { |
|
80 | - $post = get_post( $post, ARRAY_A ); |
|
78 | +function _wp_post_revision_data($post = array(), $autosave = false) { |
|
79 | + if ( ! is_array($post)) { |
|
80 | + $post = get_post($post, ARRAY_A); |
|
81 | 81 | } |
82 | 82 | |
83 | - $fields = _wp_post_revision_fields( $post ); |
|
83 | + $fields = _wp_post_revision_fields($post); |
|
84 | 84 | |
85 | 85 | $revision_data = array(); |
86 | 86 | |
87 | - foreach ( array_intersect( array_keys( $post ), array_keys( $fields ) ) as $field ) { |
|
88 | - $revision_data[ $field ] = $post[ $field ]; |
|
87 | + foreach (array_intersect(array_keys($post), array_keys($fields)) as $field) { |
|
88 | + $revision_data[$field] = $post[$field]; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $revision_data['post_parent'] = $post['ID']; |
92 | 92 | $revision_data['post_status'] = 'inherit'; |
93 | 93 | $revision_data['post_type'] = 'revision'; |
94 | 94 | $revision_data['post_name'] = $autosave ? "$post[ID]-autosave-v1" : "$post[ID]-revision-v1"; // "1" is the revisioning system version |
95 | - $revision_data['post_date'] = isset( $post['post_modified'] ) ? $post['post_modified'] : ''; |
|
96 | - $revision_data['post_date_gmt'] = isset( $post['post_modified_gmt'] ) ? $post['post_modified_gmt'] : ''; |
|
95 | + $revision_data['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : ''; |
|
96 | + $revision_data['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : ''; |
|
97 | 97 | |
98 | 98 | return $revision_data; |
99 | 99 | } |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | * @param int $post_id The ID of the post to save as a revision. |
110 | 110 | * @return int|WP_Error|void Void or 0 if error, new revision ID, if success. |
111 | 111 | */ |
112 | -function wp_save_post_revision( $post_id ) { |
|
113 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
112 | +function wp_save_post_revision($post_id) { |
|
113 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
114 | 114 | return; |
115 | 115 | |
116 | - if ( ! $post = get_post( $post_id ) ) |
|
116 | + if ( ! $post = get_post($post_id)) |
|
117 | 117 | return; |
118 | 118 | |
119 | - if ( ! post_type_supports( $post->post_type, 'revisions' ) ) |
|
119 | + if ( ! post_type_supports($post->post_type, 'revisions')) |
|
120 | 120 | return; |
121 | 121 | |
122 | - if ( 'auto-draft' == $post->post_status ) |
|
122 | + if ('auto-draft' == $post->post_status) |
|
123 | 123 | return; |
124 | 124 | |
125 | - if ( ! wp_revisions_enabled( $post ) ) |
|
125 | + if ( ! wp_revisions_enabled($post)) |
|
126 | 126 | return; |
127 | 127 | |
128 | 128 | // Compare the proposed update with the last stored revision verifying that |
129 | 129 | // they are different, unless a plugin tells us to always save regardless. |
130 | 130 | // If no previous revisions, save one |
131 | - if ( $revisions = wp_get_post_revisions( $post_id ) ) { |
|
131 | + if ($revisions = wp_get_post_revisions($post_id)) { |
|
132 | 132 | // grab the last revision, but not an autosave |
133 | - foreach ( $revisions as $revision ) { |
|
134 | - if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) { |
|
133 | + foreach ($revisions as $revision) { |
|
134 | + if (false !== strpos($revision->post_name, "{$revision->post_parent}-revision")) { |
|
135 | 135 | $last_revision = $revision; |
136 | 136 | break; |
137 | 137 | } |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | * @param WP_Post $post The post object. |
152 | 152 | * |
153 | 153 | */ |
154 | - if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) { |
|
154 | + if (isset($last_revision) && apply_filters('wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post)) { |
|
155 | 155 | $post_has_changed = false; |
156 | 156 | |
157 | - foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) { |
|
158 | - if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) { |
|
157 | + foreach (array_keys(_wp_post_revision_fields($post)) as $field) { |
|
158 | + if (normalize_whitespace($post->$field) != normalize_whitespace($last_revision->$field)) { |
|
159 | 159 | $post_has_changed = true; |
160 | 160 | break; |
161 | 161 | } |
@@ -174,38 +174,38 @@ discard block |
||
174 | 174 | * @param WP_Post $post The post object. |
175 | 175 | * |
176 | 176 | */ |
177 | - $post_has_changed = (bool) apply_filters( 'wp_save_post_revision_post_has_changed', $post_has_changed, $last_revision, $post ); |
|
177 | + $post_has_changed = (bool) apply_filters('wp_save_post_revision_post_has_changed', $post_has_changed, $last_revision, $post); |
|
178 | 178 | |
179 | 179 | //don't save revision if post unchanged |
180 | - if ( ! $post_has_changed ) { |
|
180 | + if ( ! $post_has_changed) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $return = _wp_put_post_revision( $post ); |
|
186 | + $return = _wp_put_post_revision($post); |
|
187 | 187 | |
188 | 188 | // If a limit for the number of revisions to keep has been set, |
189 | 189 | // delete the oldest ones. |
190 | - $revisions_to_keep = wp_revisions_to_keep( $post ); |
|
190 | + $revisions_to_keep = wp_revisions_to_keep($post); |
|
191 | 191 | |
192 | - if ( $revisions_to_keep < 0 ) |
|
192 | + if ($revisions_to_keep < 0) |
|
193 | 193 | return $return; |
194 | 194 | |
195 | - $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); |
|
195 | + $revisions = wp_get_post_revisions($post_id, array('order' => 'ASC')); |
|
196 | 196 | |
197 | 197 | $delete = count($revisions) - $revisions_to_keep; |
198 | 198 | |
199 | - if ( $delete < 1 ) |
|
199 | + if ($delete < 1) |
|
200 | 200 | return $return; |
201 | 201 | |
202 | - $revisions = array_slice( $revisions, 0, $delete ); |
|
202 | + $revisions = array_slice($revisions, 0, $delete); |
|
203 | 203 | |
204 | - for ( $i = 0; isset( $revisions[$i] ); $i++ ) { |
|
205 | - if ( false !== strpos( $revisions[ $i ]->post_name, 'autosave' ) ) |
|
204 | + for ($i = 0; isset($revisions[$i]); $i++) { |
|
205 | + if (false !== strpos($revisions[$i]->post_name, 'autosave')) |
|
206 | 206 | continue; |
207 | 207 | |
208 | - wp_delete_post_revision( $revisions[ $i ]->ID ); |
|
208 | + wp_delete_post_revision($revisions[$i]->ID); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | return $return; |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * @param int $user_id Optional The post author ID. |
225 | 225 | * @return WP_Post|false The autosaved data or false on failure or when no autosave exists. |
226 | 226 | */ |
227 | -function wp_get_post_autosave( $post_id, $user_id = 0 ) { |
|
228 | - $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) ); |
|
227 | +function wp_get_post_autosave($post_id, $user_id = 0) { |
|
228 | + $revisions = wp_get_post_revisions($post_id, array('check_enabled' => false)); |
|
229 | 229 | |
230 | - foreach ( $revisions as $revision ) { |
|
231 | - if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) { |
|
232 | - if ( $user_id && $user_id != $revision->post_author ) |
|
230 | + foreach ($revisions as $revision) { |
|
231 | + if (false !== strpos($revision->post_name, "{$post_id}-autosave")) { |
|
232 | + if ($user_id && $user_id != $revision->post_author) |
|
233 | 233 | continue; |
234 | 234 | |
235 | 235 | return $revision; |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @param int|WP_Post $post Post ID or post object. |
248 | 248 | * @return false|int False if not a revision, ID of revision's parent otherwise. |
249 | 249 | */ |
250 | -function wp_is_post_revision( $post ) { |
|
251 | - if ( !$post = wp_get_post_revision( $post ) ) |
|
250 | +function wp_is_post_revision($post) { |
|
251 | + if ( ! $post = wp_get_post_revision($post)) |
|
252 | 252 | return false; |
253 | 253 | |
254 | 254 | return (int) $post->post_parent; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | * @param int|WP_Post $post Post ID or post object. |
263 | 263 | * @return false|int False if not a revision, ID of autosave's parent otherwise |
264 | 264 | */ |
265 | -function wp_is_post_autosave( $post ) { |
|
266 | - if ( !$post = wp_get_post_revision( $post ) ) |
|
265 | +function wp_is_post_autosave($post) { |
|
266 | + if ( ! $post = wp_get_post_revision($post)) |
|
267 | 267 | return false; |
268 | 268 | |
269 | - if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) |
|
269 | + if (false !== strpos($post->post_name, "{$post->post_parent}-autosave")) |
|
270 | 270 | return (int) $post->post_parent; |
271 | 271 | |
272 | 272 | return false; |
@@ -282,26 +282,26 @@ discard block |
||
282 | 282 | * @param bool $autosave Optional. Is the revision an autosave? |
283 | 283 | * @return int|WP_Error WP_Error or 0 if error, new revision ID if success. |
284 | 284 | */ |
285 | -function _wp_put_post_revision( $post = null, $autosave = false ) { |
|
286 | - if ( is_object($post) ) |
|
287 | - $post = get_object_vars( $post ); |
|
288 | - elseif ( !is_array($post) ) |
|
285 | +function _wp_put_post_revision($post = null, $autosave = false) { |
|
286 | + if (is_object($post)) |
|
287 | + $post = get_object_vars($post); |
|
288 | + elseif ( ! is_array($post)) |
|
289 | 289 | $post = get_post($post, ARRAY_A); |
290 | 290 | |
291 | - if ( ! $post || empty($post['ID']) ) |
|
292 | - return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) ); |
|
291 | + if ( ! $post || empty($post['ID'])) |
|
292 | + return new WP_Error('invalid_post', __('Invalid post ID.')); |
|
293 | 293 | |
294 | - if ( isset($post['post_type']) && 'revision' == $post['post_type'] ) |
|
295 | - return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); |
|
294 | + if (isset($post['post_type']) && 'revision' == $post['post_type']) |
|
295 | + return new WP_Error('post_type', __('Cannot create a revision of a revision')); |
|
296 | 296 | |
297 | - $post = _wp_post_revision_data( $post, $autosave ); |
|
297 | + $post = _wp_post_revision_data($post, $autosave); |
|
298 | 298 | $post = wp_slash($post); //since data is from db |
299 | 299 | |
300 | - $revision_id = wp_insert_post( $post ); |
|
301 | - if ( is_wp_error($revision_id) ) |
|
300 | + $revision_id = wp_insert_post($post); |
|
301 | + if (is_wp_error($revision_id)) |
|
302 | 302 | return $revision_id; |
303 | 303 | |
304 | - if ( $revision_id ) { |
|
304 | + if ($revision_id) { |
|
305 | 305 | /** |
306 | 306 | * Fires once a revision has been saved. |
307 | 307 | * |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @param int $revision_id Post revision ID. |
311 | 311 | */ |
312 | - do_action( '_wp_put_post_revision', $revision_id ); |
|
312 | + do_action('_wp_put_post_revision', $revision_id); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | return $revision_id; |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | * @return WP_Post|array|null WP_Post (or array) on success, or null on failure. |
328 | 328 | */ |
329 | 329 | function wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') { |
330 | - if ( !$revision = get_post( $post, OBJECT, $filter ) ) |
|
330 | + if ( ! $revision = get_post($post, OBJECT, $filter)) |
|
331 | 331 | return $revision; |
332 | - if ( 'revision' !== $revision->post_type ) |
|
332 | + if ('revision' !== $revision->post_type) |
|
333 | 333 | return null; |
334 | 334 | |
335 | - if ( $output == OBJECT ) { |
|
335 | + if ($output == OBJECT) { |
|
336 | 336 | return $revision; |
337 | - } elseif ( $output == ARRAY_A ) { |
|
337 | + } elseif ($output == ARRAY_A) { |
|
338 | 338 | $_revision = get_object_vars($revision); |
339 | 339 | return $_revision; |
340 | - } elseif ( $output == ARRAY_N ) { |
|
340 | + } elseif ($output == ARRAY_N) { |
|
341 | 341 | $_revision = array_values(get_object_vars($revision)); |
342 | 342 | return $_revision; |
343 | 343 | } |
@@ -356,31 +356,31 @@ discard block |
||
356 | 356 | * @param array $fields Optional. What fields to restore from. Defaults to all. |
357 | 357 | * @return int|false|null Null if error, false if no fields to restore, (int) post ID if success. |
358 | 358 | */ |
359 | -function wp_restore_post_revision( $revision_id, $fields = null ) { |
|
360 | - if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) ) |
|
359 | +function wp_restore_post_revision($revision_id, $fields = null) { |
|
360 | + if ( ! $revision = wp_get_post_revision($revision_id, ARRAY_A)) |
|
361 | 361 | return $revision; |
362 | 362 | |
363 | - if ( !is_array( $fields ) ) |
|
364 | - $fields = array_keys( _wp_post_revision_fields( $revision ) ); |
|
363 | + if ( ! is_array($fields)) |
|
364 | + $fields = array_keys(_wp_post_revision_fields($revision)); |
|
365 | 365 | |
366 | 366 | $update = array(); |
367 | - foreach ( array_intersect( array_keys( $revision ), $fields ) as $field ) { |
|
367 | + foreach (array_intersect(array_keys($revision), $fields) as $field) { |
|
368 | 368 | $update[$field] = $revision[$field]; |
369 | 369 | } |
370 | 370 | |
371 | - if ( !$update ) |
|
371 | + if ( ! $update) |
|
372 | 372 | return false; |
373 | 373 | |
374 | 374 | $update['ID'] = $revision['post_parent']; |
375 | 375 | |
376 | - $update = wp_slash( $update ); //since data is from db |
|
376 | + $update = wp_slash($update); //since data is from db |
|
377 | 377 | |
378 | - $post_id = wp_update_post( $update ); |
|
379 | - if ( ! $post_id || is_wp_error( $post_id ) ) |
|
378 | + $post_id = wp_update_post($update); |
|
379 | + if ( ! $post_id || is_wp_error($post_id)) |
|
380 | 380 | return $post_id; |
381 | 381 | |
382 | 382 | // Update last edit user |
383 | - update_post_meta( $post_id, '_edit_last', get_current_user_id() ); |
|
383 | + update_post_meta($post_id, '_edit_last', get_current_user_id()); |
|
384 | 384 | |
385 | 385 | /** |
386 | 386 | * Fires after a post revision has been restored. |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @param int $post_id Post ID. |
391 | 391 | * @param int $revision_id Post revision ID. |
392 | 392 | */ |
393 | - do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] ); |
|
393 | + do_action('wp_restore_post_revision', $post_id, $revision['ID']); |
|
394 | 394 | |
395 | 395 | return $post_id; |
396 | 396 | } |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * @param int|WP_Post $revision_id Revision ID or revision object. |
406 | 406 | * @return array|false|WP_Post|WP_Error|null Null or WP_Error if error, deleted post if success. |
407 | 407 | */ |
408 | -function wp_delete_post_revision( $revision_id ) { |
|
409 | - if ( ! $revision = wp_get_post_revision( $revision_id ) ) { |
|
408 | +function wp_delete_post_revision($revision_id) { |
|
409 | + if ( ! $revision = wp_get_post_revision($revision_id)) { |
|
410 | 410 | return $revision; |
411 | 411 | } |
412 | 412 | |
413 | - $delete = wp_delete_post( $revision->ID ); |
|
414 | - if ( $delete ) { |
|
413 | + $delete = wp_delete_post($revision->ID); |
|
414 | + if ($delete) { |
|
415 | 415 | /** |
416 | 416 | * Fires once a post revision has been deleted. |
417 | 417 | * |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @param int $revision_id Post revision ID. |
421 | 421 | * @param object|array $revision Post revision object or array. |
422 | 422 | */ |
423 | - do_action( 'wp_delete_post_revision', $revision->ID, $revision ); |
|
423 | + do_action('wp_delete_post_revision', $revision->ID, $revision); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | return $delete; |
@@ -437,20 +437,20 @@ discard block |
||
437 | 437 | * @param array|null $args Optional. Arguments for retrieving post revisions. Default null. |
438 | 438 | * @return array An array of revisions, or an empty array if none. |
439 | 439 | */ |
440 | -function wp_get_post_revisions( $post_id = 0, $args = null ) { |
|
441 | - $post = get_post( $post_id ); |
|
442 | - if ( ! $post || empty( $post->ID ) ) |
|
440 | +function wp_get_post_revisions($post_id = 0, $args = null) { |
|
441 | + $post = get_post($post_id); |
|
442 | + if ( ! $post || empty($post->ID)) |
|
443 | 443 | return array(); |
444 | 444 | |
445 | - $defaults = array( 'order' => 'DESC', 'orderby' => 'date ID', 'check_enabled' => true ); |
|
446 | - $args = wp_parse_args( $args, $defaults ); |
|
445 | + $defaults = array('order' => 'DESC', 'orderby' => 'date ID', 'check_enabled' => true); |
|
446 | + $args = wp_parse_args($args, $defaults); |
|
447 | 447 | |
448 | - if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) |
|
448 | + if ($args['check_enabled'] && ! wp_revisions_enabled($post)) |
|
449 | 449 | return array(); |
450 | 450 | |
451 | - $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ); |
|
451 | + $args = array_merge($args, array('post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit')); |
|
452 | 452 | |
453 | - if ( ! $revisions = get_children( $args ) ) |
|
453 | + if ( ! $revisions = get_children($args)) |
|
454 | 454 | return array(); |
455 | 455 | |
456 | 456 | return $revisions; |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | * @param WP_Post $post The post object. |
465 | 465 | * @return bool True if number of revisions to keep isn't zero, false otherwise. |
466 | 466 | */ |
467 | -function wp_revisions_enabled( $post ) { |
|
468 | - return wp_revisions_to_keep( $post ) !== 0; |
|
467 | +function wp_revisions_enabled($post) { |
|
468 | + return wp_revisions_to_keep($post) !== 0; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -481,15 +481,15 @@ discard block |
||
481 | 481 | * @param WP_Post $post The post object. |
482 | 482 | * @return int The number of revisions to keep. |
483 | 483 | */ |
484 | -function wp_revisions_to_keep( $post ) { |
|
484 | +function wp_revisions_to_keep($post) { |
|
485 | 485 | $num = WP_POST_REVISIONS; |
486 | 486 | |
487 | - if ( true === $num ) |
|
487 | + if (true === $num) |
|
488 | 488 | $num = -1; |
489 | 489 | else |
490 | - $num = intval( $num ); |
|
490 | + $num = intval($num); |
|
491 | 491 | |
492 | - if ( ! post_type_supports( $post->post_type, 'revisions' ) ) |
|
492 | + if ( ! post_type_supports($post->post_type, 'revisions')) |
|
493 | 493 | $num = 0; |
494 | 494 | |
495 | 495 | /** |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param int $num Number of revisions to store. |
503 | 503 | * @param WP_Post $post Post object. |
504 | 504 | */ |
505 | - return (int) apply_filters( 'wp_revisions_to_keep', $num, $post ); |
|
505 | + return (int) apply_filters('wp_revisions_to_keep', $num, $post); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -514,24 +514,24 @@ discard block |
||
514 | 514 | * @param WP_Post $post |
515 | 515 | * @return WP_Post|false |
516 | 516 | */ |
517 | -function _set_preview( $post ) { |
|
518 | - if ( ! is_object( $post ) ) { |
|
517 | +function _set_preview($post) { |
|
518 | + if ( ! is_object($post)) { |
|
519 | 519 | return $post; |
520 | 520 | } |
521 | 521 | |
522 | - $preview = wp_get_post_autosave( $post->ID ); |
|
523 | - if ( ! is_object( $preview ) ) { |
|
522 | + $preview = wp_get_post_autosave($post->ID); |
|
523 | + if ( ! is_object($preview)) { |
|
524 | 524 | return $post; |
525 | 525 | } |
526 | 526 | |
527 | - $preview = sanitize_post( $preview ); |
|
527 | + $preview = sanitize_post($preview); |
|
528 | 528 | |
529 | 529 | $post->post_content = $preview->post_content; |
530 | 530 | $post->post_title = $preview->post_title; |
531 | 531 | $post->post_excerpt = $preview->post_excerpt; |
532 | 532 | |
533 | - add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 ); |
|
534 | - add_filter( 'get_post_metadata', '_wp_preview_post_thumbnail_filter', 10, 3 ); |
|
533 | + add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3); |
|
534 | + add_filter('get_post_metadata', '_wp_preview_post_thumbnail_filter', 10, 3); |
|
535 | 535 | |
536 | 536 | return $post; |
537 | 537 | } |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | * @access private |
544 | 544 | */ |
545 | 545 | function _show_post_preview() { |
546 | - if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) { |
|
546 | + if (isset($_GET['preview_id']) && isset($_GET['preview_nonce'])) { |
|
547 | 547 | $id = (int) $_GET['preview_id']; |
548 | 548 | |
549 | - if ( false === wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) |
|
550 | - wp_die( __('Sorry, you are not allowed to preview drafts.') ); |
|
549 | + if (false === wp_verify_nonce($_GET['preview_nonce'], 'post_preview_'.$id)) |
|
550 | + wp_die(__('Sorry, you are not allowed to preview drafts.')); |
|
551 | 551 | |
552 | 552 | add_filter('the_preview', '_set_preview'); |
553 | 553 | } |
@@ -564,17 +564,17 @@ discard block |
||
564 | 564 | * @param string $taxonomy |
565 | 565 | * @return array |
566 | 566 | */ |
567 | -function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { |
|
568 | - if ( ! $post = get_post() ) |
|
567 | +function _wp_preview_terms_filter($terms, $post_id, $taxonomy) { |
|
568 | + if ( ! $post = get_post()) |
|
569 | 569 | return $terms; |
570 | 570 | |
571 | - if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) |
|
571 | + if (empty($_REQUEST['post_format']) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type) |
|
572 | 572 | return $terms; |
573 | 573 | |
574 | - if ( 'standard' == $_REQUEST['post_format'] ) |
|
574 | + if ('standard' == $_REQUEST['post_format']) |
|
575 | 575 | $terms = array(); |
576 | - elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) ) |
|
577 | - $terms = array( $term ); // Can only have one post format |
|
576 | + elseif ($term = get_term_by('slug', 'post-format-'.sanitize_key($_REQUEST['post_format']), 'post_format')) |
|
577 | + $terms = array($term); // Can only have one post format |
|
578 | 578 | |
579 | 579 | return $terms; |
580 | 580 | } |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | * @param string $meta_key Meta key. |
591 | 591 | * @return null|array The default return value or the post thumbnail meta array. |
592 | 592 | */ |
593 | -function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) { |
|
594 | - if ( ! $post = get_post() ) { |
|
593 | +function _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key) { |
|
594 | + if ( ! $post = get_post()) { |
|
595 | 595 | return $value; |
596 | 596 | } |
597 | 597 | |
598 | - if ( empty( $_REQUEST['_thumbnail_id'] ) || |
|
599 | - empty( $_REQUEST['preview_id'] ) || |
|
598 | + if (empty($_REQUEST['_thumbnail_id']) || |
|
599 | + empty($_REQUEST['preview_id']) || |
|
600 | 600 | $post->ID != $post_id || |
601 | 601 | '_thumbnail_id' != $meta_key || |
602 | 602 | 'revision' == $post->post_type || |
@@ -605,12 +605,12 @@ discard block |
||
605 | 605 | return $value; |
606 | 606 | } |
607 | 607 | |
608 | - $thumbnail_id = intval( $_REQUEST['_thumbnail_id'] ); |
|
609 | - if ( $thumbnail_id <= 0 ) { |
|
608 | + $thumbnail_id = intval($_REQUEST['_thumbnail_id']); |
|
609 | + if ($thumbnail_id <= 0) { |
|
610 | 610 | return ''; |
611 | 611 | } |
612 | 612 | |
613 | - return strval( $thumbnail_id ); |
|
613 | + return strval($thumbnail_id); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | * @param WP_Post $revision |
623 | 623 | * @return int|false |
624 | 624 | */ |
625 | -function _wp_get_post_revision_version( $revision ) { |
|
626 | - if ( is_object( $revision ) ) |
|
627 | - $revision = get_object_vars( $revision ); |
|
628 | - elseif ( !is_array( $revision ) ) |
|
625 | +function _wp_get_post_revision_version($revision) { |
|
626 | + if (is_object($revision)) |
|
627 | + $revision = get_object_vars($revision); |
|
628 | + elseif ( ! is_array($revision)) |
|
629 | 629 | return false; |
630 | 630 | |
631 | - if ( preg_match( '/^\d+-(?:autosave|revision)-v(\d+)$/', $revision['post_name'], $matches ) ) |
|
631 | + if (preg_match('/^\d+-(?:autosave|revision)-v(\d+)$/', $revision['post_name'], $matches)) |
|
632 | 632 | return (int) $matches[1]; |
633 | 633 | |
634 | 634 | return 0; |
@@ -646,23 +646,23 @@ discard block |
||
646 | 646 | * @param array $revisions Current revisions of the post |
647 | 647 | * @return bool true if the revisions were upgraded, false if problems |
648 | 648 | */ |
649 | -function _wp_upgrade_revisions_of_post( $post, $revisions ) { |
|
649 | +function _wp_upgrade_revisions_of_post($post, $revisions) { |
|
650 | 650 | global $wpdb; |
651 | 651 | |
652 | 652 | // Add post option exclusively |
653 | 653 | $lock = "revision-upgrade-{$post->ID}"; |
654 | 654 | $now = time(); |
655 | - $result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */", $lock, $now ) ); |
|
656 | - if ( ! $result ) { |
|
655 | + $result = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */", $lock, $now)); |
|
656 | + if ( ! $result) { |
|
657 | 657 | // If we couldn't get a lock, see how old the previous lock is |
658 | - $locked = get_option( $lock ); |
|
659 | - if ( ! $locked ) { |
|
658 | + $locked = get_option($lock); |
|
659 | + if ( ! $locked) { |
|
660 | 660 | // Can't write to the lock, and can't read the lock. |
661 | 661 | // Something broken has happened |
662 | 662 | return false; |
663 | 663 | } |
664 | 664 | |
665 | - if ( $locked > $now - 3600 ) { |
|
665 | + if ($locked > $now - 3600) { |
|
666 | 666 | // Lock is not too old: some other process may be upgrading this post. Bail. |
667 | 667 | return false; |
668 | 668 | } |
@@ -671,57 +671,57 @@ discard block |
||
671 | 671 | } |
672 | 672 | |
673 | 673 | // If we could get a lock, re-"add" the option to fire all the correct filters. |
674 | - update_option( $lock, $now ); |
|
674 | + update_option($lock, $now); |
|
675 | 675 | |
676 | - reset( $revisions ); |
|
676 | + reset($revisions); |
|
677 | 677 | $add_last = true; |
678 | 678 | |
679 | 679 | do { |
680 | - $this_revision = current( $revisions ); |
|
681 | - $prev_revision = next( $revisions ); |
|
680 | + $this_revision = current($revisions); |
|
681 | + $prev_revision = next($revisions); |
|
682 | 682 | |
683 | - $this_revision_version = _wp_get_post_revision_version( $this_revision ); |
|
683 | + $this_revision_version = _wp_get_post_revision_version($this_revision); |
|
684 | 684 | |
685 | 685 | // Something terrible happened |
686 | - if ( false === $this_revision_version ) |
|
686 | + if (false === $this_revision_version) |
|
687 | 687 | continue; |
688 | 688 | |
689 | 689 | // 1 is the latest revision version, so we're already up to date. |
690 | 690 | // No need to add a copy of the post as latest revision. |
691 | - if ( 0 < $this_revision_version ) { |
|
691 | + if (0 < $this_revision_version) { |
|
692 | 692 | $add_last = false; |
693 | 693 | continue; |
694 | 694 | } |
695 | 695 | |
696 | 696 | // Always update the revision version |
697 | 697 | $update = array( |
698 | - 'post_name' => preg_replace( '/^(\d+-(?:autosave|revision))[\d-]*$/', '$1-v1', $this_revision->post_name ), |
|
698 | + 'post_name' => preg_replace('/^(\d+-(?:autosave|revision))[\d-]*$/', '$1-v1', $this_revision->post_name), |
|
699 | 699 | ); |
700 | 700 | |
701 | 701 | // If this revision is the oldest revision of the post, i.e. no $prev_revision, |
702 | 702 | // the correct post_author is probably $post->post_author, but that's only a good guess. |
703 | 703 | // Update the revision version only and Leave the author as-is. |
704 | - if ( $prev_revision ) { |
|
705 | - $prev_revision_version = _wp_get_post_revision_version( $prev_revision ); |
|
704 | + if ($prev_revision) { |
|
705 | + $prev_revision_version = _wp_get_post_revision_version($prev_revision); |
|
706 | 706 | |
707 | 707 | // If the previous revision is already up to date, it no longer has the information we need :( |
708 | - if ( $prev_revision_version < 1 ) |
|
708 | + if ($prev_revision_version < 1) |
|
709 | 709 | $update['post_author'] = $prev_revision->post_author; |
710 | 710 | } |
711 | 711 | |
712 | 712 | // Upgrade this revision |
713 | - $result = $wpdb->update( $wpdb->posts, $update, array( 'ID' => $this_revision->ID ) ); |
|
713 | + $result = $wpdb->update($wpdb->posts, $update, array('ID' => $this_revision->ID)); |
|
714 | 714 | |
715 | - if ( $result ) |
|
716 | - wp_cache_delete( $this_revision->ID, 'posts' ); |
|
715 | + if ($result) |
|
716 | + wp_cache_delete($this_revision->ID, 'posts'); |
|
717 | 717 | |
718 | - } while ( $prev_revision ); |
|
718 | + } while ($prev_revision); |
|
719 | 719 | |
720 | - delete_option( $lock ); |
|
720 | + delete_option($lock); |
|
721 | 721 | |
722 | 722 | // Add a copy of the post as latest revision. |
723 | - if ( $add_last ) |
|
724 | - wp_save_post_revision( $post->ID ); |
|
723 | + if ($add_last) |
|
724 | + wp_save_post_revision($post->ID); |
|
725 | 725 | |
726 | 726 | return true; |
727 | 727 | } |