@@ -33,21 +33,28 @@ discard block |
||
33 | 33 | * @since 2.0.0 |
34 | 34 | */ |
35 | 35 | function edit_comment() { |
36 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
37 | - wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); |
|
38 | - |
|
39 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
40 | - $_POST['comment_author'] = $_POST['newcomment_author']; |
|
41 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
42 | - $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
43 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
44 | - $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
45 | - if ( isset( $_POST['comment_status'] ) ) |
|
46 | - $_POST['comment_approved'] = $_POST['comment_status']; |
|
47 | - if ( isset( $_POST['content'] ) ) |
|
48 | - $_POST['comment_content'] = $_POST['content']; |
|
49 | - if ( isset( $_POST['comment_ID'] ) ) |
|
50 | - $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
36 | + if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) { |
|
37 | + wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); |
|
38 | + } |
|
39 | + |
|
40 | + if ( isset( $_POST['newcomment_author'] ) ) { |
|
41 | + $_POST['comment_author'] = $_POST['newcomment_author']; |
|
42 | + } |
|
43 | + if ( isset( $_POST['newcomment_author_email'] ) ) { |
|
44 | + $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
45 | + } |
|
46 | + if ( isset( $_POST['newcomment_author_url'] ) ) { |
|
47 | + $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
48 | + } |
|
49 | + if ( isset( $_POST['comment_status'] ) ) { |
|
50 | + $_POST['comment_approved'] = $_POST['comment_status']; |
|
51 | + } |
|
52 | + if ( isset( $_POST['content'] ) ) { |
|
53 | + $_POST['comment_content'] = $_POST['content']; |
|
54 | + } |
|
55 | + if ( isset( $_POST['comment_ID'] ) ) { |
|
56 | + $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
57 | + } |
|
51 | 58 | |
52 | 59 | foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
53 | 60 | if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
@@ -82,8 +89,9 @@ discard block |
||
82 | 89 | * @return object|false Comment if found. False on failure. |
83 | 90 | */ |
84 | 91 | function get_comment_to_edit( $id ) { |
85 | - if ( !$comment = get_comment($id) ) |
|
86 | - return false; |
|
92 | + if ( !$comment = get_comment($id) ) { |
|
93 | + return false; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | $comment->comment_ID = (int) $comment->comment_ID; |
89 | 97 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
@@ -132,21 +140,24 @@ discard block |
||
132 | 140 | $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
133 | 141 | |
134 | 142 | if ( $single ) { |
135 | - if ( empty($pending) ) |
|
136 | - return 0; |
|
137 | - else |
|
138 | - return absint($pending[0]['num_comments']); |
|
143 | + if ( empty($pending) ) { |
|
144 | + return 0; |
|
145 | + } else { |
|
146 | + return absint($pending[0]['num_comments']); |
|
147 | + } |
|
139 | 148 | } |
140 | 149 | |
141 | 150 | $pending_keyed = array(); |
142 | 151 | |
143 | 152 | // Default to zero pending for all posts in request |
144 | - foreach ( $post_id_array as $id ) |
|
145 | - $pending_keyed[$id] = 0; |
|
153 | + foreach ( $post_id_array as $id ) { |
|
154 | + $pending_keyed[$id] = 0; |
|
155 | + } |
|
146 | 156 | |
147 | - if ( !empty($pending) ) |
|
148 | - foreach ( $pending as $pend ) |
|
157 | + if ( !empty($pending) ) { |
|
158 | + foreach ( $pending as $pend ) |
|
149 | 159 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
160 | + } |
|
150 | 161 | |
151 | 162 | return $pending_keyed; |
152 | 163 | } |
@@ -171,6 +182,7 @@ discard block |
||
171 | 182 | * @since 2.7.0 |
172 | 183 | */ |
173 | 184 | function enqueue_comment_hotkeys_js() { |
174 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
175 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
176 | -} |
|
185 | + if ( 'true' == get_user_option( 'comment_shortcuts' ) ) { |
|
186 | + wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
187 | + } |
|
188 | + } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Comment Administration API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - * @since 2.3.0 |
|
8 | - */ |
|
3 | + * WordPress Comment Administration API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + * @since 2.3.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Determine if a comment exists based on author and date. |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return mixed Comment post ID on success. |
26 | 26 | */ |
27 | -function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) { |
|
27 | +function comment_exists($comment_author, $comment_date, $timezone = 'blog') { |
|
28 | 28 | global $wpdb; |
29 | 29 | |
30 | 30 | $date_field = 'comment_date'; |
31 | - if ( 'gmt' === $timezone ) { |
|
31 | + if ('gmt' === $timezone) { |
|
32 | 32 | $date_field = 'comment_date_gmt'; |
33 | 33 | } |
34 | 34 | |
35 | - return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
35 | + return $wpdb->get_var($wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
36 | 36 | WHERE comment_author = %s AND $date_field = %s", |
37 | - stripslashes( $comment_author ), |
|
38 | - stripslashes( $comment_date ) |
|
39 | - ) ); |
|
37 | + stripslashes($comment_author), |
|
38 | + stripslashes($comment_date) |
|
39 | + )); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,44 +45,44 @@ discard block |
||
45 | 45 | * @since 2.0.0 |
46 | 46 | */ |
47 | 47 | function edit_comment() { |
48 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
49 | - wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); |
|
48 | + if ( ! current_user_can('edit_comment', (int) $_POST['comment_ID'])) |
|
49 | + wp_die(__('You are not allowed to edit comments on this post.')); |
|
50 | 50 | |
51 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
51 | + if (isset($_POST['newcomment_author'])) |
|
52 | 52 | $_POST['comment_author'] = $_POST['newcomment_author']; |
53 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
53 | + if (isset($_POST['newcomment_author_email'])) |
|
54 | 54 | $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
55 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
55 | + if (isset($_POST['newcomment_author_url'])) |
|
56 | 56 | $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
57 | - if ( isset( $_POST['comment_status'] ) ) |
|
57 | + if (isset($_POST['comment_status'])) |
|
58 | 58 | $_POST['comment_approved'] = $_POST['comment_status']; |
59 | - if ( isset( $_POST['content'] ) ) |
|
59 | + if (isset($_POST['content'])) |
|
60 | 60 | $_POST['comment_content'] = $_POST['content']; |
61 | - if ( isset( $_POST['comment_ID'] ) ) |
|
61 | + if (isset($_POST['comment_ID'])) |
|
62 | 62 | $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
63 | 63 | |
64 | - foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
|
65 | - if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
|
64 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
65 | + if ( ! empty($_POST['hidden_'.$timeunit]) && $_POST['hidden_'.$timeunit] != $_POST[$timeunit]) { |
|
66 | 66 | $_POST['edit_date'] = '1'; |
67 | 67 | break; |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - if ( !empty ( $_POST['edit_date'] ) ) { |
|
71 | + if ( ! empty ($_POST['edit_date'])) { |
|
72 | 72 | $aa = $_POST['aa']; |
73 | 73 | $mm = $_POST['mm']; |
74 | 74 | $jj = $_POST['jj']; |
75 | 75 | $hh = $_POST['hh']; |
76 | 76 | $mn = $_POST['mn']; |
77 | 77 | $ss = $_POST['ss']; |
78 | - $jj = ($jj > 31 ) ? 31 : $jj; |
|
79 | - $hh = ($hh > 23 ) ? $hh -24 : $hh; |
|
80 | - $mn = ($mn > 59 ) ? $mn -60 : $mn; |
|
81 | - $ss = ($ss > 59 ) ? $ss -60 : $ss; |
|
78 | + $jj = ($jj > 31) ? 31 : $jj; |
|
79 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
80 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
81 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
82 | 82 | $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; |
83 | 83 | } |
84 | 84 | |
85 | - wp_update_comment( $_POST ); |
|
85 | + wp_update_comment($_POST); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | * @param int $id ID of comment to retrieve. |
94 | 94 | * @return WP_Comment|false Comment if found. False on failure. |
95 | 95 | */ |
96 | -function get_comment_to_edit( $id ) { |
|
97 | - if ( !$comment = get_comment($id) ) |
|
96 | +function get_comment_to_edit($id) { |
|
97 | + if ( ! $comment = get_comment($id)) |
|
98 | 98 | return false; |
99 | 99 | |
100 | 100 | $comment->comment_ID = (int) $comment->comment_ID; |
101 | 101 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
102 | 102 | |
103 | - $comment->comment_content = format_to_edit( $comment->comment_content ); |
|
103 | + $comment->comment_content = format_to_edit($comment->comment_content); |
|
104 | 104 | /** |
105 | 105 | * Filter the comment content before editing. |
106 | 106 | * |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $comment->comment_content Comment content. |
110 | 110 | */ |
111 | - $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); |
|
111 | + $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content); |
|
112 | 112 | |
113 | - $comment->comment_author = format_to_edit( $comment->comment_author ); |
|
114 | - $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); |
|
115 | - $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); |
|
113 | + $comment->comment_author = format_to_edit($comment->comment_author); |
|
114 | + $comment->comment_author_email = format_to_edit($comment->comment_author_email); |
|
115 | + $comment->comment_author_url = format_to_edit($comment->comment_author_url); |
|
116 | 116 | $comment->comment_author_url = esc_url($comment->comment_author_url); |
117 | 117 | |
118 | 118 | return $comment; |
@@ -128,23 +128,23 @@ discard block |
||
128 | 128 | * @param int|array $post_id Either a single Post ID or an array of Post IDs |
129 | 129 | * @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs |
130 | 130 | */ |
131 | -function get_pending_comments_num( $post_id ) { |
|
131 | +function get_pending_comments_num($post_id) { |
|
132 | 132 | global $wpdb; |
133 | 133 | |
134 | 134 | $single = false; |
135 | - if ( !is_array($post_id) ) { |
|
135 | + if ( ! is_array($post_id)) { |
|
136 | 136 | $post_id_array = (array) $post_id; |
137 | 137 | $single = true; |
138 | 138 | } else { |
139 | 139 | $post_id_array = $post_id; |
140 | 140 | } |
141 | 141 | $post_id_array = array_map('intval', $post_id_array); |
142 | - $post_id_in = "'" . implode("', '", $post_id_array) . "'"; |
|
142 | + $post_id_in = "'".implode("', '", $post_id_array)."'"; |
|
143 | 143 | |
144 | - $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
|
144 | + $pending = $wpdb->get_results("SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A); |
|
145 | 145 | |
146 | - if ( $single ) { |
|
147 | - if ( empty($pending) ) |
|
146 | + if ($single) { |
|
147 | + if (empty($pending)) |
|
148 | 148 | return 0; |
149 | 149 | else |
150 | 150 | return absint($pending[0]['num_comments']); |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | $pending_keyed = array(); |
154 | 154 | |
155 | 155 | // Default to zero pending for all posts in request |
156 | - foreach ( $post_id_array as $id ) |
|
156 | + foreach ($post_id_array as $id) |
|
157 | 157 | $pending_keyed[$id] = 0; |
158 | 158 | |
159 | - if ( !empty($pending) ) |
|
160 | - foreach ( $pending as $pend ) |
|
159 | + if ( ! empty($pending)) |
|
160 | + foreach ($pending as $pend) |
|
161 | 161 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
162 | 162 | |
163 | 163 | return $pending_keyed; |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param string $name User name. |
172 | 172 | * @return string Avatar with Admin name. |
173 | 173 | */ |
174 | -function floated_admin_avatar( $name ) { |
|
175 | - $avatar = get_avatar( get_comment(), 32, 'mystery' ); |
|
174 | +function floated_admin_avatar($name) { |
|
175 | + $avatar = get_avatar(get_comment(), 32, 'mystery'); |
|
176 | 176 | return "$avatar $name"; |
177 | 177 | } |
178 | 178 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | * @since 2.7.0 |
181 | 181 | */ |
182 | 182 | function enqueue_comment_hotkeys_js() { |
183 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
184 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
183 | + if ('true' == get_user_option('comment_shortcuts')) |
|
184 | + wp_enqueue_script('jquery-table-hotkeys'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param string $msg Error Message. Assumed to contain HTML and be sanitized. |
191 | 191 | */ |
192 | -function comment_footer_die( $msg ) { |
|
192 | +function comment_footer_die($msg) { |
|
193 | 193 | echo "<div class='wrap'><p>$msg</p></div>"; |
194 | - include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
194 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
195 | 195 | die; |
196 | 196 | } |
197 | 197 | \ No newline at end of file |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Theme Install Administration API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Theme Install Administration API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | $themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), |
10 | 10 | 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), |
@@ -31,15 +31,18 @@ discard block |
||
31 | 31 | function install_themes_feature_list() { |
32 | 32 | _deprecated_function( __FUNCTION__, '3.1', 'get_theme_feature_list()' ); |
33 | 33 | |
34 | - if ( !$cache = get_transient( 'wporg_theme_feature_list' ) ) |
|
35 | - set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
34 | + if ( !$cache = get_transient( 'wporg_theme_feature_list' ) ) { |
|
35 | + set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
36 | + } |
|
36 | 37 | |
37 | - if ( $cache ) |
|
38 | - return $cache; |
|
38 | + if ( $cache ) { |
|
39 | + return $cache; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $feature_list = themes_api( 'feature_list', array() ); |
41 | - if ( is_wp_error( $feature_list ) ) |
|
42 | - return array(); |
|
43 | + if ( is_wp_error( $feature_list ) ) { |
|
44 | + return array(); |
|
45 | + } |
|
43 | 46 | |
44 | 47 | set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); |
45 | 48 | |
@@ -56,8 +59,9 @@ discard block |
||
56 | 59 | function install_theme_search_form( $type_selector = true ) { |
57 | 60 | $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
58 | 61 | $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
59 | - if ( ! $type_selector ) |
|
60 | - echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>'; |
|
62 | + if ( ! $type_selector ) { |
|
63 | + echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>'; |
|
64 | + } |
|
61 | 65 | ?> |
62 | 66 | <form id="search-themes" method="get"> |
63 | 67 | <input type="hidden" name="tab" value="search" /> |
@@ -81,8 +85,11 @@ discard block |
||
81 | 85 | break; |
82 | 86 | } |
83 | 87 | ?></label> |
84 | - <?php else : ?> |
|
85 | - <label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label> |
|
88 | + <?php else { |
|
89 | + : ?> |
|
90 | + <label class="screen-reader-text" for="s"><?php _e('Search by keyword'); |
|
91 | +} |
|
92 | +?></label> |
|
86 | 93 | <?php endif; ?> |
87 | 94 | <input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" /> |
88 | 95 | <?php submit_button( __( 'Search' ), 'button', 'search', false ); ?> |
@@ -198,8 +205,9 @@ discard block |
||
198 | 205 | |
199 | 206 | $theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) ); |
200 | 207 | |
201 | - if ( is_wp_error( $theme ) ) |
|
202 | - wp_die( $theme ); |
|
208 | + if ( is_wp_error( $theme ) ) { |
|
209 | + wp_die( $theme ); |
|
210 | + } |
|
203 | 211 | |
204 | 212 | iframe_header( __('Theme Install') ); |
205 | 213 | if ( ! isset( $wp_list_table ) ) { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | 'img' => array('src' => array(), 'class' => array(), 'alt' => array()) |
15 | 15 | ); |
16 | 16 | |
17 | -$theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true, |
|
17 | +$theme_field_defaults = array('description' => true, 'sections' => false, 'tested' => true, 'requires' => true, |
|
18 | 18 | 'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true, |
19 | 19 | 'tags' => true, 'num_ratings' => true |
20 | 20 | ); |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | * @return array |
30 | 30 | */ |
31 | 31 | function install_themes_feature_list() { |
32 | - _deprecated_function( __FUNCTION__, '3.1', 'get_theme_feature_list()' ); |
|
32 | + _deprecated_function(__FUNCTION__, '3.1', 'get_theme_feature_list()'); |
|
33 | 33 | |
34 | - if ( !$cache = get_transient( 'wporg_theme_feature_list' ) ) |
|
35 | - set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
34 | + if ( ! $cache = get_transient('wporg_theme_feature_list')) |
|
35 | + set_transient('wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS); |
|
36 | 36 | |
37 | - if ( $cache ) |
|
37 | + if ($cache) |
|
38 | 38 | return $cache; |
39 | 39 | |
40 | - $feature_list = themes_api( 'feature_list', array() ); |
|
41 | - if ( is_wp_error( $feature_list ) ) |
|
40 | + $feature_list = themes_api('feature_list', array()); |
|
41 | + if (is_wp_error($feature_list)) |
|
42 | 42 | return array(); |
43 | 43 | |
44 | - set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); |
|
44 | + set_transient('wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS); |
|
45 | 45 | |
46 | 46 | return $feature_list; |
47 | 47 | } |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param bool $type_selector |
55 | 55 | */ |
56 | -function install_theme_search_form( $type_selector = true ) { |
|
57 | - $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
|
58 | - $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
|
59 | - if ( ! $type_selector ) |
|
60 | - echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>'; |
|
56 | +function install_theme_search_form($type_selector = true) { |
|
57 | + $type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term'; |
|
58 | + $term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : ''; |
|
59 | + if ( ! $type_selector) |
|
60 | + echo '<p class="install-help">'.__('Search for themes by keyword.').'</p>'; |
|
61 | 61 | ?> |
62 | 62 | <form id="search-themes" method="get"> |
63 | 63 | <input type="hidden" name="tab" value="search" /> |
64 | - <?php if ( $type_selector ) : ?> |
|
64 | + <?php if ($type_selector) : ?> |
|
65 | 65 | <label class="screen-reader-text" for="typeselector"><?php _e('Type of search'); ?></label> |
66 | 66 | <select name="type" id="typeselector"> |
67 | 67 | <option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option> |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | <option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option> |
70 | 70 | </select> |
71 | 71 | <label class="screen-reader-text" for="s"><?php |
72 | - switch ( $type ) { |
|
72 | + switch ($type) { |
|
73 | 73 | case 'term': |
74 | - _e( 'Search by keyword' ); |
|
74 | + _e('Search by keyword'); |
|
75 | 75 | break; |
76 | 76 | case 'author': |
77 | - _e( 'Search by author' ); |
|
77 | + _e('Search by author'); |
|
78 | 78 | break; |
79 | 79 | case 'tag': |
80 | - _e( 'Search by tag' ); |
|
80 | + _e('Search by tag'); |
|
81 | 81 | break; |
82 | 82 | } |
83 | 83 | ?></label> |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | <label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label> |
86 | 86 | <?php endif; ?> |
87 | 87 | <input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" /> |
88 | - <?php submit_button( __( 'Search' ), 'button', 'search', false ); ?> |
|
88 | + <?php submit_button(__('Search'), 'button', 'search', false); ?> |
|
89 | 89 | </form> |
90 | 90 | <?php |
91 | 91 | } |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @since 2.8.0 |
97 | 97 | */ |
98 | 98 | function install_themes_dashboard() { |
99 | - install_theme_search_form( false ); |
|
99 | + install_theme_search_form(false); |
|
100 | 100 | ?> |
101 | 101 | <h4><?php _e('Feature Filter') ?></h4> |
102 | -<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p> |
|
102 | +<p class="install-help"><?php _e('Find a theme based on specific features.'); ?></p> |
|
103 | 103 | |
104 | 104 | <form method="get"> |
105 | 105 | <input type="hidden" name="tab" value="search" /> |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $feature_list = get_theme_feature_list(); |
108 | 108 | echo '<div class="feature-filter">'; |
109 | 109 | |
110 | - foreach ( (array) $feature_list as $feature_name => $features ) { |
|
111 | - $feature_name = esc_html( $feature_name ); |
|
112 | - echo '<div class="feature-name">' . $feature_name . '</div>'; |
|
110 | + foreach ((array) $feature_list as $feature_name => $features) { |
|
111 | + $feature_name = esc_html($feature_name); |
|
112 | + echo '<div class="feature-name">'.$feature_name.'</div>'; |
|
113 | 113 | |
114 | 114 | echo '<ol class="feature-group">'; |
115 | - foreach ( $features as $feature => $feature_name ) { |
|
116 | - $feature_name = esc_html( $feature_name ); |
|
115 | + foreach ($features as $feature => $feature_name) { |
|
116 | + $feature_name = esc_html($feature_name); |
|
117 | 117 | $feature = esc_attr($feature); |
118 | 118 | ?> |
119 | 119 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | </div> |
132 | 132 | <br class="clear" /> |
133 | -<?php submit_button( __( 'Find Themes' ), 'button', 'search' ); ?> |
|
133 | +<?php submit_button(__('Find Themes'), 'button', 'search'); ?> |
|
134 | 134 | </form> |
135 | 135 | <?php |
136 | 136 | } |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | ?> |
143 | 143 | <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.'); ?></p> |
144 | 144 | <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>"> |
145 | - <?php wp_nonce_field( 'theme-upload' ); ?> |
|
146 | - <label class="screen-reader-text" for="themezip"><?php _e( 'Theme zip file' ); ?></label> |
|
145 | + <?php wp_nonce_field('theme-upload'); ?> |
|
146 | + <label class="screen-reader-text" for="themezip"><?php _e('Theme zip file'); ?></label> |
|
147 | 147 | <input type="file" id="themezip" name="themezip" /> |
148 | - <?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?> |
|
148 | + <?php submit_button(__('Install Now'), 'button', 'install-theme-submit', false); ?> |
|
149 | 149 | </form> |
150 | 150 | <?php |
151 | 151 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @param object $theme |
161 | 161 | */ |
162 | -function display_theme( $theme ) { |
|
163 | - _deprecated_function( __FUNCTION__, '3.4' ); |
|
162 | +function display_theme($theme) { |
|
163 | + _deprecated_function(__FUNCTION__, '3.4'); |
|
164 | 164 | global $wp_list_table; |
165 | - if ( ! isset( $wp_list_table ) ) { |
|
165 | + if ( ! isset($wp_list_table)) { |
|
166 | 166 | $wp_list_table = _get_list_table('WP_Theme_Install_List_Table'); |
167 | 167 | } |
168 | 168 | $wp_list_table->prepare_items(); |
169 | - $wp_list_table->single_row( $theme ); |
|
169 | + $wp_list_table->single_row($theme); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | function display_themes() { |
180 | 180 | global $wp_list_table; |
181 | 181 | |
182 | - if ( ! isset( $wp_list_table ) ) { |
|
182 | + if ( ! isset($wp_list_table)) { |
|
183 | 183 | $wp_list_table = _get_list_table('WP_Theme_Install_List_Table'); |
184 | 184 | } |
185 | 185 | $wp_list_table->prepare_items(); |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | function install_theme_information() { |
198 | 198 | global $wp_list_table; |
199 | 199 | |
200 | - $theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) ); |
|
200 | + $theme = themes_api('theme_information', array('slug' => wp_unslash($_REQUEST['theme']))); |
|
201 | 201 | |
202 | - if ( is_wp_error( $theme ) ) |
|
203 | - wp_die( $theme ); |
|
202 | + if (is_wp_error($theme)) |
|
203 | + wp_die($theme); |
|
204 | 204 | |
205 | - iframe_header( __('Theme Install') ); |
|
206 | - if ( ! isset( $wp_list_table ) ) { |
|
205 | + iframe_header(__('Theme Install')); |
|
206 | + if ( ! isset($wp_list_table)) { |
|
207 | 207 | $wp_list_table = _get_list_table('WP_Theme_Install_List_Table'); |
208 | 208 | } |
209 | - $wp_list_table->theme_installer_single( $theme ); |
|
209 | + $wp_list_table->theme_installer_single($theme); |
|
210 | 210 | iframe_footer(); |
211 | 211 | exit; |
212 | 212 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Post Administration API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Post Administration API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Rename $_POST data from form names to DB post columns. |
@@ -1372,7 +1372,7 @@ |
||
1372 | 1372 | * @global array $_wp_additional_image_sizes |
1373 | 1373 | * |
1374 | 1374 | * @param int $thumbnail_id ID of the attachment used for thumbnail |
1375 | - * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. |
|
1375 | + * @param integer $post The post ID or object associated with the thumbnail, defaults to global $post. |
|
1376 | 1376 | * @return string html |
1377 | 1377 | */ |
1378 | 1378 | function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { |
@@ -18,151 +18,151 @@ discard block |
||
18 | 18 | * @param array $post_data Array of post data. Defaults to the contents of $_POST. |
19 | 19 | * @return object|bool WP_Error on failure, true on success. |
20 | 20 | */ |
21 | -function _wp_translate_postdata( $update = false, $post_data = null ) { |
|
21 | +function _wp_translate_postdata($update = false, $post_data = null) { |
|
22 | 22 | |
23 | - if ( empty($post_data) ) |
|
23 | + if (empty($post_data)) |
|
24 | 24 | $post_data = &$_POST; |
25 | 25 | |
26 | - if ( $update ) |
|
26 | + if ($update) |
|
27 | 27 | $post_data['ID'] = (int) $post_data['post_ID']; |
28 | 28 | |
29 | - $ptype = get_post_type_object( $post_data['post_type'] ); |
|
29 | + $ptype = get_post_type_object($post_data['post_type']); |
|
30 | 30 | |
31 | - if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { |
|
32 | - if ( 'page' == $post_data['post_type'] ) |
|
33 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
31 | + if ($update && ! current_user_can('edit_post', $post_data['ID'])) { |
|
32 | + if ('page' == $post_data['post_type']) |
|
33 | + return new WP_Error('edit_others_pages', __('You are not allowed to edit pages as this user.')); |
|
34 | 34 | else |
35 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
36 | - } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
|
37 | - if ( 'page' == $post_data['post_type'] ) |
|
38 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
35 | + return new WP_Error('edit_others_posts', __('You are not allowed to edit posts as this user.')); |
|
36 | + } elseif ( ! $update && ! current_user_can($ptype->cap->create_posts)) { |
|
37 | + if ('page' == $post_data['post_type']) |
|
38 | + return new WP_Error('edit_others_pages', __('You are not allowed to create pages as this user.')); |
|
39 | 39 | else |
40 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
40 | + return new WP_Error('edit_others_posts', __('You are not allowed to create posts as this user.')); |
|
41 | 41 | } |
42 | 42 | |
43 | - if ( isset( $post_data['content'] ) ) |
|
43 | + if (isset($post_data['content'])) |
|
44 | 44 | $post_data['post_content'] = $post_data['content']; |
45 | 45 | |
46 | - if ( isset( $post_data['excerpt'] ) ) |
|
46 | + if (isset($post_data['excerpt'])) |
|
47 | 47 | $post_data['post_excerpt'] = $post_data['excerpt']; |
48 | 48 | |
49 | - if ( isset( $post_data['parent_id'] ) ) |
|
49 | + if (isset($post_data['parent_id'])) |
|
50 | 50 | $post_data['post_parent'] = (int) $post_data['parent_id']; |
51 | 51 | |
52 | - if ( isset($post_data['trackback_url']) ) |
|
52 | + if (isset($post_data['trackback_url'])) |
|
53 | 53 | $post_data['to_ping'] = $post_data['trackback_url']; |
54 | 54 | |
55 | 55 | $post_data['user_ID'] = get_current_user_id(); |
56 | 56 | |
57 | - if (!empty ( $post_data['post_author_override'] ) ) { |
|
57 | + if ( ! empty ($post_data['post_author_override'])) { |
|
58 | 58 | $post_data['post_author'] = (int) $post_data['post_author_override']; |
59 | 59 | } else { |
60 | - if (!empty ( $post_data['post_author'] ) ) { |
|
60 | + if ( ! empty ($post_data['post_author'])) { |
|
61 | 61 | $post_data['post_author'] = (int) $post_data['post_author']; |
62 | 62 | } else { |
63 | 63 | $post_data['post_author'] = (int) $post_data['user_ID']; |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
|
68 | - && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
69 | - if ( $update ) { |
|
70 | - if ( 'page' == $post_data['post_type'] ) |
|
71 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
67 | + if (isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) |
|
68 | + && ! current_user_can($ptype->cap->edit_others_posts)) { |
|
69 | + if ($update) { |
|
70 | + if ('page' == $post_data['post_type']) |
|
71 | + return new WP_Error('edit_others_pages', __('You are not allowed to edit pages as this user.')); |
|
72 | 72 | else |
73 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
73 | + return new WP_Error('edit_others_posts', __('You are not allowed to edit posts as this user.')); |
|
74 | 74 | } else { |
75 | - if ( 'page' == $post_data['post_type'] ) |
|
76 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
75 | + if ('page' == $post_data['post_type']) |
|
76 | + return new WP_Error('edit_others_pages', __('You are not allowed to create pages as this user.')); |
|
77 | 77 | else |
78 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
78 | + return new WP_Error('edit_others_posts', __('You are not allowed to create posts as this user.')); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
83 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
82 | + if ( ! empty($post_data['post_status'])) { |
|
83 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
84 | 84 | |
85 | 85 | // No longer an auto-draft |
86 | - if ( 'auto-draft' === $post_data['post_status'] ) { |
|
86 | + if ('auto-draft' === $post_data['post_status']) { |
|
87 | 87 | $post_data['post_status'] = 'draft'; |
88 | 88 | } |
89 | 89 | |
90 | - if ( ! get_post_status_object( $post_data['post_status'] ) ) { |
|
91 | - unset( $post_data['post_status'] ); |
|
90 | + if ( ! get_post_status_object($post_data['post_status'])) { |
|
91 | + unset($post_data['post_status']); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | 95 | // What to do based on which button they pressed |
96 | - if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
|
96 | + if (isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft']) |
|
97 | 97 | $post_data['post_status'] = 'draft'; |
98 | - if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) |
|
98 | + if (isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate']) |
|
99 | 99 | $post_data['post_status'] = 'private'; |
100 | - if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) |
|
100 | + if (isset($post_data['publish']) && ('' != $post_data['publish']) && ( ! isset($post_data['post_status']) || $post_data['post_status'] != 'private')) |
|
101 | 101 | $post_data['post_status'] = 'publish'; |
102 | - if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) |
|
102 | + if (isset($post_data['advanced']) && '' != $post_data['advanced']) |
|
103 | 103 | $post_data['post_status'] = 'draft'; |
104 | - if ( isset($post_data['pending']) && '' != $post_data['pending'] ) |
|
104 | + if (isset($post_data['pending']) && '' != $post_data['pending']) |
|
105 | 105 | $post_data['post_status'] = 'pending'; |
106 | 106 | |
107 | - if ( isset( $post_data['ID'] ) ) |
|
107 | + if (isset($post_data['ID'])) |
|
108 | 108 | $post_id = $post_data['ID']; |
109 | 109 | else |
110 | 110 | $post_id = false; |
111 | - $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; |
|
111 | + $previous_status = $post_id ? get_post_field('post_status', $post_id) : false; |
|
112 | 112 | |
113 | - if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
113 | + if (isset($post_data['post_status']) && 'private' == $post_data['post_status'] && ! current_user_can($ptype->cap->publish_posts)) { |
|
114 | 114 | $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; |
115 | 115 | } |
116 | 116 | |
117 | - $published_statuses = array( 'publish', 'future' ); |
|
117 | + $published_statuses = array('publish', 'future'); |
|
118 | 118 | |
119 | 119 | // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. |
120 | 120 | // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. |
121 | - if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) |
|
122 | - if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
121 | + if (isset($post_data['post_status']) && (in_array($post_data['post_status'], $published_statuses) && ! current_user_can($ptype->cap->publish_posts))) |
|
122 | + if ( ! in_array($previous_status, $published_statuses) || ! current_user_can('edit_post', $post_id)) |
|
123 | 123 | $post_data['post_status'] = 'pending'; |
124 | 124 | |
125 | - if ( ! isset( $post_data['post_status'] ) ) { |
|
125 | + if ( ! isset($post_data['post_status'])) { |
|
126 | 126 | $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; |
127 | 127 | } |
128 | 128 | |
129 | - if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
130 | - unset( $post_data['post_password'] ); |
|
129 | + if (isset($post_data['post_password']) && ! current_user_can($ptype->cap->publish_posts)) { |
|
130 | + unset($post_data['post_password']); |
|
131 | 131 | } |
132 | 132 | |
133 | - if (!isset( $post_data['comment_status'] )) |
|
133 | + if ( ! isset($post_data['comment_status'])) |
|
134 | 134 | $post_data['comment_status'] = 'closed'; |
135 | 135 | |
136 | - if (!isset( $post_data['ping_status'] )) |
|
136 | + if ( ! isset($post_data['ping_status'])) |
|
137 | 137 | $post_data['ping_status'] = 'closed'; |
138 | 138 | |
139 | - foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
|
140 | - if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { |
|
139 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
140 | + if ( ! empty($post_data['hidden_'.$timeunit]) && $post_data['hidden_'.$timeunit] != $post_data[$timeunit]) { |
|
141 | 141 | $post_data['edit_date'] = '1'; |
142 | 142 | break; |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | - if ( !empty( $post_data['edit_date'] ) ) { |
|
146 | + if ( ! empty($post_data['edit_date'])) { |
|
147 | 147 | $aa = $post_data['aa']; |
148 | 148 | $mm = $post_data['mm']; |
149 | 149 | $jj = $post_data['jj']; |
150 | 150 | $hh = $post_data['hh']; |
151 | 151 | $mn = $post_data['mn']; |
152 | 152 | $ss = $post_data['ss']; |
153 | - $aa = ($aa <= 0 ) ? date('Y') : $aa; |
|
154 | - $mm = ($mm <= 0 ) ? date('n') : $mm; |
|
155 | - $jj = ($jj > 31 ) ? 31 : $jj; |
|
156 | - $jj = ($jj <= 0 ) ? date('j') : $jj; |
|
157 | - $hh = ($hh > 23 ) ? $hh -24 : $hh; |
|
158 | - $mn = ($mn > 59 ) ? $mn -60 : $mn; |
|
159 | - $ss = ($ss > 59 ) ? $ss -60 : $ss; |
|
160 | - $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); |
|
161 | - $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); |
|
162 | - if ( !$valid_date ) { |
|
163 | - return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) ); |
|
153 | + $aa = ($aa <= 0) ? date('Y') : $aa; |
|
154 | + $mm = ($mm <= 0) ? date('n') : $mm; |
|
155 | + $jj = ($jj > 31) ? 31 : $jj; |
|
156 | + $jj = ($jj <= 0) ? date('j') : $jj; |
|
157 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
158 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
159 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
160 | + $post_data['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss); |
|
161 | + $valid_date = wp_checkdate($mm, $jj, $aa, $post_data['post_date']); |
|
162 | + if ( ! $valid_date) { |
|
163 | + return new WP_Error('invalid_date', __('Whoops, the provided date is invalid.')); |
|
164 | 164 | } |
165 | - $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); |
|
165 | + $post_data['post_date_gmt'] = get_gmt_from_date($post_data['post_date']); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return $post_data; |
@@ -178,149 +178,149 @@ discard block |
||
178 | 178 | * @param array $post_data Optional. |
179 | 179 | * @return int Post ID. |
180 | 180 | */ |
181 | -function edit_post( $post_data = null ) { |
|
181 | +function edit_post($post_data = null) { |
|
182 | 182 | global $wpdb; |
183 | 183 | |
184 | - if ( empty($post_data) ) |
|
184 | + if (empty($post_data)) |
|
185 | 185 | $post_data = &$_POST; |
186 | 186 | |
187 | 187 | // Clear out any data in internal vars. |
188 | - unset( $post_data['filter'] ); |
|
188 | + unset($post_data['filter']); |
|
189 | 189 | |
190 | 190 | $post_ID = (int) $post_data['post_ID']; |
191 | - $post = get_post( $post_ID ); |
|
191 | + $post = get_post($post_ID); |
|
192 | 192 | $post_data['post_type'] = $post->post_type; |
193 | 193 | $post_data['post_mime_type'] = $post->post_mime_type; |
194 | 194 | |
195 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
196 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
195 | + if ( ! empty($post_data['post_status'])) { |
|
196 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
197 | 197 | |
198 | - if ( 'inherit' == $post_data['post_status'] ) { |
|
199 | - unset( $post_data['post_status'] ); |
|
198 | + if ('inherit' == $post_data['post_status']) { |
|
199 | + unset($post_data['post_status']); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | $ptype = get_post_type_object($post_data['post_type']); |
204 | - if ( !current_user_can( 'edit_post', $post_ID ) ) { |
|
205 | - if ( 'page' == $post_data['post_type'] ) |
|
206 | - wp_die( __('You are not allowed to edit this page.' )); |
|
204 | + if ( ! current_user_can('edit_post', $post_ID)) { |
|
205 | + if ('page' == $post_data['post_type']) |
|
206 | + wp_die(__('You are not allowed to edit this page.')); |
|
207 | 207 | else |
208 | - wp_die( __('You are not allowed to edit this post.' )); |
|
208 | + wp_die(__('You are not allowed to edit this post.')); |
|
209 | 209 | } |
210 | 210 | |
211 | - if ( post_type_supports( $ptype->name, 'revisions' ) ) { |
|
212 | - $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) ); |
|
213 | - $revision = current( $revisions ); |
|
211 | + if (post_type_supports($ptype->name, 'revisions')) { |
|
212 | + $revisions = wp_get_post_revisions($post_ID, array('order' => 'ASC', 'posts_per_page' => 1)); |
|
213 | + $revision = current($revisions); |
|
214 | 214 | |
215 | 215 | // Check if the revisions have been upgraded |
216 | - if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) |
|
217 | - _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
216 | + if ($revisions && _wp_get_post_revision_version($revision) < 1) |
|
217 | + _wp_upgrade_revisions_of_post($post, wp_get_post_revisions($post_ID)); |
|
218 | 218 | } |
219 | 219 | |
220 | - if ( isset($post_data['visibility']) ) { |
|
221 | - switch ( $post_data['visibility'] ) { |
|
220 | + if (isset($post_data['visibility'])) { |
|
221 | + switch ($post_data['visibility']) { |
|
222 | 222 | case 'public' : |
223 | 223 | $post_data['post_password'] = ''; |
224 | 224 | break; |
225 | 225 | case 'password' : |
226 | - unset( $post_data['sticky'] ); |
|
226 | + unset($post_data['sticky']); |
|
227 | 227 | break; |
228 | 228 | case 'private' : |
229 | 229 | $post_data['post_status'] = 'private'; |
230 | 230 | $post_data['post_password'] = ''; |
231 | - unset( $post_data['sticky'] ); |
|
231 | + unset($post_data['sticky']); |
|
232 | 232 | break; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
237 | - if ( is_wp_error($post_data) ) |
|
238 | - wp_die( $post_data->get_error_message() ); |
|
236 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
237 | + if (is_wp_error($post_data)) |
|
238 | + wp_die($post_data->get_error_message()); |
|
239 | 239 | |
240 | 240 | // Post Formats |
241 | - if ( isset( $post_data['post_format'] ) ) |
|
242 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
241 | + if (isset($post_data['post_format'])) |
|
242 | + set_post_format($post_ID, $post_data['post_format']); |
|
243 | 243 | |
244 | - $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); |
|
245 | - foreach ( $format_meta_urls as $format_meta_url ) { |
|
246 | - $keyed = '_format_' . $format_meta_url; |
|
247 | - if ( isset( $post_data[ $keyed ] ) ) |
|
248 | - update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
244 | + $format_meta_urls = array('url', 'link_url', 'quote_source_url'); |
|
245 | + foreach ($format_meta_urls as $format_meta_url) { |
|
246 | + $keyed = '_format_'.$format_meta_url; |
|
247 | + if (isset($post_data[$keyed])) |
|
248 | + update_post_meta($post_ID, $keyed, wp_slash(esc_url_raw(wp_unslash($post_data[$keyed])))); |
|
249 | 249 | } |
250 | 250 | |
251 | - $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); |
|
251 | + $format_keys = array('quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed'); |
|
252 | 252 | |
253 | - foreach ( $format_keys as $key ) { |
|
254 | - $keyed = '_format_' . $key; |
|
255 | - if ( isset( $post_data[ $keyed ] ) ) { |
|
256 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
257 | - update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
253 | + foreach ($format_keys as $key) { |
|
254 | + $keyed = '_format_'.$key; |
|
255 | + if (isset($post_data[$keyed])) { |
|
256 | + if (current_user_can('unfiltered_html')) |
|
257 | + update_post_meta($post_ID, $keyed, $post_data[$keyed]); |
|
258 | 258 | else |
259 | - update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
259 | + update_post_meta($post_ID, $keyed, wp_filter_post_kses($post_data[$keyed])); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) { |
|
264 | - $id3data = wp_get_attachment_metadata( $post_ID ); |
|
265 | - if ( ! is_array( $id3data ) ) { |
|
263 | + if ('attachment' === $post_data['post_type'] && preg_match('#^(audio|video)/#', $post_data['post_mime_type'])) { |
|
264 | + $id3data = wp_get_attachment_metadata($post_ID); |
|
265 | + if ( ! is_array($id3data)) { |
|
266 | 266 | $id3data = array(); |
267 | 267 | } |
268 | 268 | |
269 | - foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) { |
|
270 | - if ( isset( $post_data[ 'id3_' . $key ] ) ) { |
|
271 | - $id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) ); |
|
269 | + foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) { |
|
270 | + if (isset($post_data['id3_'.$key])) { |
|
271 | + $id3data[$key] = sanitize_text_field(wp_unslash($post_data['id3_'.$key])); |
|
272 | 272 | } |
273 | 273 | } |
274 | - wp_update_attachment_metadata( $post_ID, $id3data ); |
|
274 | + wp_update_attachment_metadata($post_ID, $id3data); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | // Meta Stuff |
278 | - if ( isset($post_data['meta']) && $post_data['meta'] ) { |
|
279 | - foreach ( $post_data['meta'] as $key => $value ) { |
|
280 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
278 | + if (isset($post_data['meta']) && $post_data['meta']) { |
|
279 | + foreach ($post_data['meta'] as $key => $value) { |
|
280 | + if ( ! $meta = get_post_meta_by_id($key)) |
|
281 | 281 | continue; |
282 | - if ( $meta->post_id != $post_ID ) |
|
282 | + if ($meta->post_id != $post_ID) |
|
283 | 283 | continue; |
284 | - if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) |
|
284 | + if (is_protected_meta($value['key'], 'post') || ! current_user_can('edit_post_meta', $post_ID, $value['key'])) |
|
285 | 285 | continue; |
286 | - update_meta( $key, $value['key'], $value['value'] ); |
|
286 | + update_meta($key, $value['key'], $value['value']); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | - if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { |
|
291 | - foreach ( $post_data['deletemeta'] as $key => $value ) { |
|
292 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
290 | + if (isset($post_data['deletemeta']) && $post_data['deletemeta']) { |
|
291 | + foreach ($post_data['deletemeta'] as $key => $value) { |
|
292 | + if ( ! $meta = get_post_meta_by_id($key)) |
|
293 | 293 | continue; |
294 | - if ( $meta->post_id != $post_ID ) |
|
294 | + if ($meta->post_id != $post_ID) |
|
295 | 295 | continue; |
296 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) |
|
296 | + if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $post_ID, $meta->meta_key)) |
|
297 | 297 | continue; |
298 | - delete_meta( $key ); |
|
298 | + delete_meta($key); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Attachment stuff |
303 | - if ( 'attachment' == $post_data['post_type'] ) { |
|
304 | - if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) { |
|
305 | - $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); |
|
306 | - if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) { |
|
307 | - $image_alt = wp_strip_all_tags( $image_alt, true ); |
|
303 | + if ('attachment' == $post_data['post_type']) { |
|
304 | + if (isset($post_data['_wp_attachment_image_alt'])) { |
|
305 | + $image_alt = wp_unslash($post_data['_wp_attachment_image_alt']); |
|
306 | + if ($image_alt != get_post_meta($post_ID, '_wp_attachment_image_alt', true)) { |
|
307 | + $image_alt = wp_strip_all_tags($image_alt, true); |
|
308 | 308 | // update_meta expects slashed. |
309 | - update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); |
|
309 | + update_post_meta($post_ID, '_wp_attachment_image_alt', wp_slash($image_alt)); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); |
|
313 | + $attachment_data = isset($post_data['attachments'][$post_ID]) ? $post_data['attachments'][$post_ID] : array(); |
|
314 | 314 | |
315 | 315 | /** This filter is documented in wp-admin/includes/media.php */ |
316 | - $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data ); |
|
316 | + $post_data = apply_filters('attachment_fields_to_save', $post_data, $attachment_data); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | // Convert taxonomy input to term IDs, to avoid ambiguity. |
320 | - if ( isset( $post_data['tax_input'] ) ) { |
|
321 | - foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { |
|
320 | + if (isset($post_data['tax_input'])) { |
|
321 | + foreach ((array) $post_data['tax_input'] as $taxonomy => $terms) { |
|
322 | 322 | // Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary. |
323 | - if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
323 | + if (is_taxonomy_hierarchical($taxonomy)) { |
|
324 | 324 | continue; |
325 | 325 | } |
326 | 326 | |
@@ -329,67 +329,67 @@ discard block |
||
329 | 329 | * Some languages may use a character other than a comma as a delimiter, so we standardize on |
330 | 330 | * commas before parsing the list. |
331 | 331 | */ |
332 | - if ( ! is_array( $terms ) ) { |
|
333 | - $comma = _x( ',', 'tag delimiter' ); |
|
334 | - if ( ',' !== $comma ) { |
|
335 | - $terms = str_replace( $comma, ',', $terms ); |
|
332 | + if ( ! is_array($terms)) { |
|
333 | + $comma = _x(',', 'tag delimiter'); |
|
334 | + if (',' !== $comma) { |
|
335 | + $terms = str_replace($comma, ',', $terms); |
|
336 | 336 | } |
337 | - $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
337 | + $terms = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | $clean_terms = array(); |
341 | - foreach ( $terms as $term ) { |
|
341 | + foreach ($terms as $term) { |
|
342 | 342 | // Empty terms are invalid input. |
343 | - if ( empty( $term ) ) { |
|
343 | + if (empty($term)) { |
|
344 | 344 | continue; |
345 | 345 | } |
346 | 346 | |
347 | - $_term = get_terms( $taxonomy, array( |
|
347 | + $_term = get_terms($taxonomy, array( |
|
348 | 348 | 'name' => $term, |
349 | 349 | 'fields' => 'ids', |
350 | 350 | 'hide_empty' => false, |
351 | - ) ); |
|
351 | + )); |
|
352 | 352 | |
353 | - if ( ! empty( $_term ) ) { |
|
354 | - $clean_terms[] = intval( $_term[0] ); |
|
353 | + if ( ! empty($_term)) { |
|
354 | + $clean_terms[] = intval($_term[0]); |
|
355 | 355 | } else { |
356 | 356 | // No existing term was found, so pass the string. A new term will be created. |
357 | 357 | $clean_terms[] = $term; |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | - $post_data['tax_input'][ $taxonomy ] = $clean_terms; |
|
361 | + $post_data['tax_input'][$taxonomy] = $clean_terms; |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | - add_meta( $post_ID ); |
|
365 | + add_meta($post_ID); |
|
366 | 366 | |
367 | - update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); |
|
367 | + update_post_meta($post_ID, '_edit_last', get_current_user_id()); |
|
368 | 368 | |
369 | - $success = wp_update_post( $post_data ); |
|
369 | + $success = wp_update_post($post_data); |
|
370 | 370 | // If the save failed, see if we can sanity check the main fields and try again |
371 | - if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { |
|
372 | - $fields = array( 'post_title', 'post_content', 'post_excerpt' ); |
|
371 | + if ( ! $success && is_callable(array($wpdb, 'strip_invalid_text_for_column'))) { |
|
372 | + $fields = array('post_title', 'post_content', 'post_excerpt'); |
|
373 | 373 | |
374 | - foreach ( $fields as $field ) { |
|
375 | - if ( isset( $post_data[ $field ] ) ) { |
|
376 | - $post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] ); |
|
374 | + foreach ($fields as $field) { |
|
375 | + if (isset($post_data[$field])) { |
|
376 | + $post_data[$field] = $wpdb->strip_invalid_text_for_column($wpdb->posts, $field, $post_data[$field]); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | - wp_update_post( $post_data ); |
|
380 | + wp_update_post($post_data); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // Now that we have an ID we can fix any attachment anchor hrefs |
384 | - _fix_attachment_links( $post_ID ); |
|
384 | + _fix_attachment_links($post_ID); |
|
385 | 385 | |
386 | - wp_set_post_lock( $post_ID ); |
|
386 | + wp_set_post_lock($post_ID); |
|
387 | 387 | |
388 | - if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { |
|
389 | - if ( ! empty( $post_data['sticky'] ) ) |
|
390 | - stick_post( $post_ID ); |
|
388 | + if (current_user_can($ptype->cap->edit_others_posts) && current_user_can($ptype->cap->publish_posts)) { |
|
389 | + if ( ! empty($post_data['sticky'])) |
|
390 | + stick_post($post_ID); |
|
391 | 391 | else |
392 | - unstick_post( $post_ID ); |
|
392 | + unstick_post($post_ID); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | return $post_ID; |
@@ -408,22 +408,22 @@ discard block |
||
408 | 408 | * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal. |
409 | 409 | * @return array |
410 | 410 | */ |
411 | -function bulk_edit_posts( $post_data = null ) { |
|
411 | +function bulk_edit_posts($post_data = null) { |
|
412 | 412 | global $wpdb; |
413 | 413 | |
414 | - if ( empty($post_data) ) |
|
414 | + if (empty($post_data)) |
|
415 | 415 | $post_data = &$_POST; |
416 | 416 | |
417 | - if ( isset($post_data['post_type']) ) |
|
417 | + if (isset($post_data['post_type'])) |
|
418 | 418 | $ptype = get_post_type_object($post_data['post_type']); |
419 | 419 | else |
420 | 420 | $ptype = get_post_type_object('post'); |
421 | 421 | |
422 | - if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
|
423 | - if ( 'page' == $ptype->name ) |
|
424 | - wp_die( __('You are not allowed to edit pages.')); |
|
422 | + if ( ! current_user_can($ptype->cap->edit_posts)) { |
|
423 | + if ('page' == $ptype->name) |
|
424 | + wp_die(__('You are not allowed to edit pages.')); |
|
425 | 425 | else |
426 | - wp_die( __('You are not allowed to edit posts.')); |
|
426 | + wp_die(__('You are not allowed to edit posts.')); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | if ( -1 == $post_data['_status'] ) { |
@@ -434,15 +434,15 @@ discard block |
||
434 | 434 | } |
435 | 435 | unset($post_data['_status']); |
436 | 436 | |
437 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
438 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
437 | + if ( ! empty($post_data['post_status'])) { |
|
438 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
439 | 439 | |
440 | - if ( 'inherit' == $post_data['post_status'] ) { |
|
441 | - unset( $post_data['post_status'] ); |
|
440 | + if ('inherit' == $post_data['post_status']) { |
|
441 | + unset($post_data['post_status']); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | - $post_IDs = array_map( 'intval', (array) $post_data['post'] ); |
|
445 | + $post_IDs = array_map('intval', (array) $post_data['post']); |
|
446 | 446 | |
447 | 447 | $reset = array( |
448 | 448 | 'post_author', 'post_status', 'post_password', |
@@ -451,43 +451,43 @@ discard block |
||
451 | 451 | 'post_category', 'sticky', 'post_format', |
452 | 452 | ); |
453 | 453 | |
454 | - foreach ( $reset as $field ) { |
|
455 | - if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) |
|
454 | + foreach ($reset as $field) { |
|
455 | + if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field])) |
|
456 | 456 | unset($post_data[$field]); |
457 | 457 | } |
458 | 458 | |
459 | - if ( isset($post_data['post_category']) ) { |
|
460 | - if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) |
|
461 | - $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
459 | + if (isset($post_data['post_category'])) { |
|
460 | + if (is_array($post_data['post_category']) && ! empty($post_data['post_category'])) |
|
461 | + $new_cats = array_map('absint', $post_data['post_category']); |
|
462 | 462 | else |
463 | 463 | unset($post_data['post_category']); |
464 | 464 | } |
465 | 465 | |
466 | 466 | $tax_input = array(); |
467 | - if ( isset($post_data['tax_input'])) { |
|
468 | - foreach ( $post_data['tax_input'] as $tax_name => $terms ) { |
|
469 | - if ( empty($terms) ) |
|
467 | + if (isset($post_data['tax_input'])) { |
|
468 | + foreach ($post_data['tax_input'] as $tax_name => $terms) { |
|
469 | + if (empty($terms)) |
|
470 | 470 | continue; |
471 | - if ( is_taxonomy_hierarchical( $tax_name ) ) { |
|
472 | - $tax_input[ $tax_name ] = array_map( 'absint', $terms ); |
|
471 | + if (is_taxonomy_hierarchical($tax_name)) { |
|
472 | + $tax_input[$tax_name] = array_map('absint', $terms); |
|
473 | 473 | } else { |
474 | - $comma = _x( ',', 'tag delimiter' ); |
|
475 | - if ( ',' !== $comma ) |
|
476 | - $terms = str_replace( $comma, ',', $terms ); |
|
477 | - $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
474 | + $comma = _x(',', 'tag delimiter'); |
|
475 | + if (',' !== $comma) |
|
476 | + $terms = str_replace($comma, ',', $terms); |
|
477 | + $tax_input[$tax_name] = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
478 | 478 | } |
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | - if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) { |
|
482 | + if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) { |
|
483 | 483 | $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'"); |
484 | 484 | $children = array(); |
485 | 485 | |
486 | - for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { |
|
486 | + for ($i = 0; $i < 50 && $parent > 0; $i++) { |
|
487 | 487 | $children[] = $parent; |
488 | 488 | |
489 | - foreach ( $pages as $page ) { |
|
490 | - if ( $page->ID == $parent ) { |
|
489 | + foreach ($pages as $page) { |
|
490 | + if ($page->ID == $parent) { |
|
491 | 491 | $parent = $page->post_parent; |
492 | 492 | break; |
493 | 493 | } |
@@ -498,78 +498,78 @@ discard block |
||
498 | 498 | $updated = $skipped = $locked = array(); |
499 | 499 | $shared_post_data = $post_data; |
500 | 500 | |
501 | - foreach ( $post_IDs as $post_ID ) { |
|
501 | + foreach ($post_IDs as $post_ID) { |
|
502 | 502 | // Start with fresh post data with each iteration. |
503 | 503 | $post_data = $shared_post_data; |
504 | 504 | |
505 | - $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); |
|
505 | + $post_type_object = get_post_type_object(get_post_type($post_ID)); |
|
506 | 506 | |
507 | - if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) { |
|
507 | + if ( ! isset($post_type_object) || (isset($children) && in_array($post_ID, $children)) || ! current_user_can('edit_post', $post_ID)) { |
|
508 | 508 | $skipped[] = $post_ID; |
509 | 509 | continue; |
510 | 510 | } |
511 | 511 | |
512 | - if ( wp_check_post_lock( $post_ID ) ) { |
|
512 | + if (wp_check_post_lock($post_ID)) { |
|
513 | 513 | $locked[] = $post_ID; |
514 | 514 | continue; |
515 | 515 | } |
516 | 516 | |
517 | - $post = get_post( $post_ID ); |
|
518 | - $tax_names = get_object_taxonomies( $post ); |
|
519 | - foreach ( $tax_names as $tax_name ) { |
|
517 | + $post = get_post($post_ID); |
|
518 | + $tax_names = get_object_taxonomies($post); |
|
519 | + foreach ($tax_names as $tax_name) { |
|
520 | 520 | $taxonomy_obj = get_taxonomy($tax_name); |
521 | - if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) |
|
521 | + if (isset($tax_input[$tax_name]) && current_user_can($taxonomy_obj->cap->assign_terms)) |
|
522 | 522 | $new_terms = $tax_input[$tax_name]; |
523 | 523 | else |
524 | 524 | $new_terms = array(); |
525 | 525 | |
526 | - if ( $taxonomy_obj->hierarchical ) |
|
527 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
526 | + if ($taxonomy_obj->hierarchical) |
|
527 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'ids')); |
|
528 | 528 | else |
529 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
529 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'names')); |
|
530 | 530 | |
531 | - $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms ); |
|
531 | + $post_data['tax_input'][$tax_name] = array_merge($current_terms, $new_terms); |
|
532 | 532 | } |
533 | 533 | |
534 | - if ( isset($new_cats) && in_array( 'category', $tax_names ) ) { |
|
534 | + if (isset($new_cats) && in_array('category', $tax_names)) { |
|
535 | 535 | $cats = (array) wp_get_post_categories($post_ID); |
536 | - $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) ); |
|
537 | - unset( $post_data['tax_input']['category'] ); |
|
536 | + $post_data['post_category'] = array_unique(array_merge($cats, $new_cats)); |
|
537 | + unset($post_data['tax_input']['category']); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | $post_data['post_type'] = $post->post_type; |
541 | 541 | $post_data['post_mime_type'] = $post->post_mime_type; |
542 | 542 | $post_data['guid'] = $post->guid; |
543 | 543 | |
544 | - foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) { |
|
545 | - if ( ! isset( $post_data[ $field ] ) ) { |
|
546 | - $post_data[ $field ] = $post->$field; |
|
544 | + foreach (array('comment_status', 'ping_status', 'post_author') as $field) { |
|
545 | + if ( ! isset($post_data[$field])) { |
|
546 | + $post_data[$field] = $post->$field; |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
550 | 550 | $post_data['ID'] = $post_ID; |
551 | 551 | $post_data['post_ID'] = $post_ID; |
552 | 552 | |
553 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
554 | - if ( is_wp_error( $post_data ) ) { |
|
553 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
554 | + if (is_wp_error($post_data)) { |
|
555 | 555 | $skipped[] = $post_ID; |
556 | 556 | continue; |
557 | 557 | } |
558 | 558 | |
559 | - $updated[] = wp_update_post( $post_data ); |
|
559 | + $updated[] = wp_update_post($post_data); |
|
560 | 560 | |
561 | - if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
562 | - if ( 'sticky' == $post_data['sticky'] ) |
|
563 | - stick_post( $post_ID ); |
|
561 | + if (isset($post_data['sticky']) && current_user_can($ptype->cap->edit_others_posts)) { |
|
562 | + if ('sticky' == $post_data['sticky']) |
|
563 | + stick_post($post_ID); |
|
564 | 564 | else |
565 | - unstick_post( $post_ID ); |
|
565 | + unstick_post($post_ID); |
|
566 | 566 | } |
567 | 567 | |
568 | - if ( isset( $post_data['post_format'] ) ) |
|
569 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
568 | + if (isset($post_data['post_format'])) |
|
569 | + set_post_format($post_ID, $post_data['post_format']); |
|
570 | 570 | } |
571 | 571 | |
572 | - return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); |
|
572 | + return array('updated' => $updated, 'skipped' => $skipped, 'locked' => $locked); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -581,24 +581,24 @@ discard block |
||
581 | 581 | * @param bool $create_in_db Optional. Whether to insert the post into database. Default false. |
582 | 582 | * @return WP_Post Post object containing all the default post data as attributes |
583 | 583 | */ |
584 | -function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { |
|
584 | +function get_default_post_to_edit($post_type = 'post', $create_in_db = false) { |
|
585 | 585 | $post_title = ''; |
586 | - if ( !empty( $_REQUEST['post_title'] ) ) |
|
587 | - $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
586 | + if ( ! empty($_REQUEST['post_title'])) |
|
587 | + $post_title = esc_html(wp_unslash($_REQUEST['post_title'])); |
|
588 | 588 | |
589 | 589 | $post_content = ''; |
590 | - if ( !empty( $_REQUEST['content'] ) ) |
|
591 | - $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
590 | + if ( ! empty($_REQUEST['content'])) |
|
591 | + $post_content = esc_html(wp_unslash($_REQUEST['content'])); |
|
592 | 592 | |
593 | 593 | $post_excerpt = ''; |
594 | - if ( !empty( $_REQUEST['excerpt'] ) ) |
|
595 | - $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
596 | - |
|
597 | - if ( $create_in_db ) { |
|
598 | - $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
|
599 | - $post = get_post( $post_id ); |
|
600 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) |
|
601 | - set_post_format( $post, get_option( 'default_post_format' ) ); |
|
594 | + if ( ! empty($_REQUEST['excerpt'])) |
|
595 | + $post_excerpt = esc_html(wp_unslash($_REQUEST['excerpt'])); |
|
596 | + |
|
597 | + if ($create_in_db) { |
|
598 | + $post_id = wp_insert_post(array('post_title' => __('Auto Draft'), 'post_type' => $post_type, 'post_status' => 'auto-draft')); |
|
599 | + $post = get_post($post_id); |
|
600 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats') && get_option('default_post_format')) |
|
601 | + set_post_format($post, get_option('default_post_format')); |
|
602 | 602 | } else { |
603 | 603 | $post = new stdClass; |
604 | 604 | $post->ID = 0; |
@@ -611,14 +611,14 @@ discard block |
||
611 | 611 | $post->post_status = 'draft'; |
612 | 612 | $post->to_ping = ''; |
613 | 613 | $post->pinged = ''; |
614 | - $post->comment_status = get_default_comment_status( $post_type ); |
|
615 | - $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); |
|
616 | - $post->post_pingback = get_option( 'default_pingback_flag' ); |
|
617 | - $post->post_category = get_option( 'default_category' ); |
|
614 | + $post->comment_status = get_default_comment_status($post_type); |
|
615 | + $post->ping_status = get_default_comment_status($post_type, 'pingback'); |
|
616 | + $post->post_pingback = get_option('default_pingback_flag'); |
|
617 | + $post->post_category = get_option('default_category'); |
|
618 | 618 | $post->page_template = 'default'; |
619 | 619 | $post->post_parent = 0; |
620 | 620 | $post->menu_order = 0; |
621 | - $post = new WP_Post( $post ); |
|
621 | + $post = new WP_Post($post); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @param string $post_content Default post content. |
630 | 630 | * @param WP_Post $post Post object. |
631 | 631 | */ |
632 | - $post->post_content = apply_filters( 'default_content', $post_content, $post ); |
|
632 | + $post->post_content = apply_filters('default_content', $post_content, $post); |
|
633 | 633 | |
634 | 634 | /** |
635 | 635 | * Filter the default post title initially used in the "Write Post" form. |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | * @param string $post_title Default post title. |
640 | 640 | * @param WP_Post $post Post object. |
641 | 641 | */ |
642 | - $post->post_title = apply_filters( 'default_title', $post_title, $post ); |
|
642 | + $post->post_title = apply_filters('default_title', $post_title, $post); |
|
643 | 643 | |
644 | 644 | /** |
645 | 645 | * Filter the default post excerpt initially used in the "Write Post" form. |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | * @param string $post_excerpt Default post excerpt. |
650 | 650 | * @param WP_Post $post Post object. |
651 | 651 | */ |
652 | - $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); |
|
652 | + $post->post_excerpt = apply_filters('default_excerpt', $post_excerpt, $post); |
|
653 | 653 | |
654 | 654 | return $post; |
655 | 655 | } |
@@ -669,30 +669,30 @@ discard block |
||
669 | 669 | function post_exists($title, $content = '', $date = '') { |
670 | 670 | global $wpdb; |
671 | 671 | |
672 | - $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); |
|
673 | - $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); |
|
674 | - $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); |
|
672 | + $post_title = wp_unslash(sanitize_post_field('post_title', $title, 0, 'db')); |
|
673 | + $post_content = wp_unslash(sanitize_post_field('post_content', $content, 0, 'db')); |
|
674 | + $post_date = wp_unslash(sanitize_post_field('post_date', $date, 0, 'db')); |
|
675 | 675 | |
676 | 676 | $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; |
677 | 677 | $args = array(); |
678 | 678 | |
679 | - if ( !empty ( $date ) ) { |
|
679 | + if ( ! empty ($date)) { |
|
680 | 680 | $query .= ' AND post_date = %s'; |
681 | 681 | $args[] = $post_date; |
682 | 682 | } |
683 | 683 | |
684 | - if ( !empty ( $title ) ) { |
|
684 | + if ( ! empty ($title)) { |
|
685 | 685 | $query .= ' AND post_title = %s'; |
686 | 686 | $args[] = $post_title; |
687 | 687 | } |
688 | 688 | |
689 | - if ( !empty ( $content ) ) { |
|
689 | + if ( ! empty ($content)) { |
|
690 | 690 | $query .= ' AND post_content = %s'; |
691 | 691 | $args[] = $post_content; |
692 | 692 | } |
693 | 693 | |
694 | - if ( !empty ( $args ) ) |
|
695 | - return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
694 | + if ( ! empty ($args)) |
|
695 | + return (int) $wpdb->get_var($wpdb->prepare($query, $args)); |
|
696 | 696 | |
697 | 697 | return 0; |
698 | 698 | } |
@@ -707,63 +707,63 @@ discard block |
||
707 | 707 | * @return int|WP_Error |
708 | 708 | */ |
709 | 709 | function wp_write_post() { |
710 | - if ( isset($_POST['post_type']) ) |
|
710 | + if (isset($_POST['post_type'])) |
|
711 | 711 | $ptype = get_post_type_object($_POST['post_type']); |
712 | 712 | else |
713 | 713 | $ptype = get_post_type_object('post'); |
714 | 714 | |
715 | - if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
|
716 | - if ( 'page' == $ptype->name ) |
|
717 | - return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) ); |
|
715 | + if ( ! current_user_can($ptype->cap->edit_posts)) { |
|
716 | + if ('page' == $ptype->name) |
|
717 | + return new WP_Error('edit_pages', __('You are not allowed to create pages on this site.')); |
|
718 | 718 | else |
719 | - return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) ); |
|
719 | + return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this site.')); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | $_POST['post_mime_type'] = ''; |
723 | 723 | |
724 | 724 | // Clear out any data in internal vars. |
725 | - unset( $_POST['filter'] ); |
|
725 | + unset($_POST['filter']); |
|
726 | 726 | |
727 | 727 | // Edit don't write if we have a post id. |
728 | - if ( isset( $_POST['post_ID'] ) ) |
|
728 | + if (isset($_POST['post_ID'])) |
|
729 | 729 | return edit_post(); |
730 | 730 | |
731 | - if ( isset($_POST['visibility']) ) { |
|
732 | - switch ( $_POST['visibility'] ) { |
|
731 | + if (isset($_POST['visibility'])) { |
|
732 | + switch ($_POST['visibility']) { |
|
733 | 733 | case 'public' : |
734 | 734 | $_POST['post_password'] = ''; |
735 | 735 | break; |
736 | 736 | case 'password' : |
737 | - unset( $_POST['sticky'] ); |
|
737 | + unset($_POST['sticky']); |
|
738 | 738 | break; |
739 | 739 | case 'private' : |
740 | 740 | $_POST['post_status'] = 'private'; |
741 | 741 | $_POST['post_password'] = ''; |
742 | - unset( $_POST['sticky'] ); |
|
742 | + unset($_POST['sticky']); |
|
743 | 743 | break; |
744 | 744 | } |
745 | 745 | } |
746 | 746 | |
747 | - $translated = _wp_translate_postdata( false ); |
|
748 | - if ( is_wp_error($translated) ) |
|
747 | + $translated = _wp_translate_postdata(false); |
|
748 | + if (is_wp_error($translated)) |
|
749 | 749 | return $translated; |
750 | 750 | |
751 | 751 | // Create the post. |
752 | - $post_ID = wp_insert_post( $_POST ); |
|
753 | - if ( is_wp_error( $post_ID ) ) |
|
752 | + $post_ID = wp_insert_post($_POST); |
|
753 | + if (is_wp_error($post_ID)) |
|
754 | 754 | return $post_ID; |
755 | 755 | |
756 | - if ( empty($post_ID) ) |
|
756 | + if (empty($post_ID)) |
|
757 | 757 | return 0; |
758 | 758 | |
759 | - add_meta( $post_ID ); |
|
759 | + add_meta($post_ID); |
|
760 | 760 | |
761 | - add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); |
|
761 | + add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID); |
|
762 | 762 | |
763 | 763 | // Now that we have an ID we can fix any attachment anchor hrefs |
764 | - _fix_attachment_links( $post_ID ); |
|
764 | + _fix_attachment_links($post_ID); |
|
765 | 765 | |
766 | - wp_set_post_lock( $post_ID ); |
|
766 | + wp_set_post_lock($post_ID); |
|
767 | 767 | |
768 | 768 | return $post_ID; |
769 | 769 | } |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | */ |
778 | 778 | function write_post() { |
779 | 779 | $result = wp_write_post(); |
780 | - if ( is_wp_error( $result ) ) |
|
781 | - wp_die( $result->get_error_message() ); |
|
780 | + if (is_wp_error($result)) |
|
781 | + wp_die($result->get_error_message()); |
|
782 | 782 | else |
783 | 783 | return $result; |
784 | 784 | } |
@@ -795,32 +795,32 @@ discard block |
||
795 | 795 | * @param int $post_ID |
796 | 796 | * @return int|bool |
797 | 797 | */ |
798 | -function add_meta( $post_ID ) { |
|
798 | +function add_meta($post_ID) { |
|
799 | 799 | $post_ID = (int) $post_ID; |
800 | 800 | |
801 | - $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; |
|
802 | - $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; |
|
801 | + $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash(trim($_POST['metakeyselect'])) : ''; |
|
802 | + $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash(trim($_POST['metakeyinput'])) : ''; |
|
803 | 803 | $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; |
804 | - if ( is_string( $metavalue ) ) |
|
805 | - $metavalue = trim( $metavalue ); |
|
804 | + if (is_string($metavalue)) |
|
805 | + $metavalue = trim($metavalue); |
|
806 | 806 | |
807 | - if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) { |
|
807 | + if (('0' === $metavalue || ! empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && ! empty ($metakeyselect)) || ! empty ($metakeyinput))) { |
|
808 | 808 | /* |
809 | 809 | * We have a key/value pair. If both the select and the input |
810 | 810 | * for the key have data, the input takes precedence. |
811 | 811 | */ |
812 | - if ( '#NONE#' != $metakeyselect ) |
|
812 | + if ('#NONE#' != $metakeyselect) |
|
813 | 813 | $metakey = $metakeyselect; |
814 | 814 | |
815 | - if ( $metakeyinput ) |
|
815 | + if ($metakeyinput) |
|
816 | 816 | $metakey = $metakeyinput; // default |
817 | 817 | |
818 | - if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) |
|
818 | + if (is_protected_meta($metakey, 'post') || ! current_user_can('add_post_meta', $post_ID, $metakey)) |
|
819 | 819 | return false; |
820 | 820 | |
821 | - $metakey = wp_slash( $metakey ); |
|
821 | + $metakey = wp_slash($metakey); |
|
822 | 822 | |
823 | - return add_post_meta( $post_ID, $metakey, $metavalue ); |
|
823 | + return add_post_meta($post_ID, $metakey, $metavalue); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | return false; |
@@ -834,8 +834,8 @@ discard block |
||
834 | 834 | * @param int $mid |
835 | 835 | * @return bool |
836 | 836 | */ |
837 | -function delete_meta( $mid ) { |
|
838 | - return delete_metadata_by_mid( 'post' , $mid ); |
|
837 | +function delete_meta($mid) { |
|
838 | + return delete_metadata_by_mid('post', $mid); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | /** |
@@ -850,11 +850,11 @@ discard block |
||
850 | 850 | function get_meta_keys() { |
851 | 851 | global $wpdb; |
852 | 852 | |
853 | - $keys = $wpdb->get_col( " |
|
853 | + $keys = $wpdb->get_col(" |
|
854 | 854 | SELECT meta_key |
855 | 855 | FROM $wpdb->postmeta |
856 | 856 | GROUP BY meta_key |
857 | - ORDER BY meta_key" ); |
|
857 | + ORDER BY meta_key"); |
|
858 | 858 | |
859 | 859 | return $keys; |
860 | 860 | } |
@@ -867,8 +867,8 @@ discard block |
||
867 | 867 | * @param int $mid |
868 | 868 | * @return object|bool |
869 | 869 | */ |
870 | -function get_post_meta_by_id( $mid ) { |
|
871 | - return get_metadata_by_mid( 'post', $mid ); |
|
870 | +function get_post_meta_by_id($mid) { |
|
871 | + return get_metadata_by_mid('post', $mid); |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | /** |
@@ -881,12 +881,12 @@ discard block |
||
881 | 881 | * @param int $postid |
882 | 882 | * @return mixed |
883 | 883 | */ |
884 | -function has_meta( $postid ) { |
|
884 | +function has_meta($postid) { |
|
885 | 885 | global $wpdb; |
886 | 886 | |
887 | - return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id |
|
887 | + return $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id |
|
888 | 888 | FROM $wpdb->postmeta WHERE post_id = %d |
889 | - ORDER BY meta_key,meta_id", $postid), ARRAY_A ); |
|
889 | + ORDER BY meta_key,meta_id", $postid), ARRAY_A); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | /** |
@@ -899,11 +899,11 @@ discard block |
||
899 | 899 | * @param string $meta_value Expect Slashed |
900 | 900 | * @return bool |
901 | 901 | */ |
902 | -function update_meta( $meta_id, $meta_key, $meta_value ) { |
|
903 | - $meta_key = wp_unslash( $meta_key ); |
|
904 | - $meta_value = wp_unslash( $meta_value ); |
|
902 | +function update_meta($meta_id, $meta_key, $meta_value) { |
|
903 | + $meta_key = wp_unslash($meta_key); |
|
904 | + $meta_value = wp_unslash($meta_value); |
|
905 | 905 | |
906 | - return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key ); |
|
906 | + return update_metadata_by_mid('post', $meta_id, $meta_value, $meta_key); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | // |
@@ -919,42 +919,42 @@ discard block |
||
919 | 919 | * @param int|object $post Post ID or post object. |
920 | 920 | * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success. |
921 | 921 | */ |
922 | -function _fix_attachment_links( $post ) { |
|
923 | - $post = get_post( $post, ARRAY_A ); |
|
922 | +function _fix_attachment_links($post) { |
|
923 | + $post = get_post($post, ARRAY_A); |
|
924 | 924 | $content = $post['post_content']; |
925 | 925 | |
926 | 926 | // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. |
927 | - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) |
|
927 | + if ( ! get_option('permalink_structure') || ! in_array($post['post_status'], array('publish', 'future', 'private'))) |
|
928 | 928 | return; |
929 | 929 | |
930 | 930 | // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) |
931 | - if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) |
|
931 | + if ( ! strpos($content, '?attachment_id=') || ! preg_match_all('/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches)) |
|
932 | 932 | return; |
933 | 933 | |
934 | 934 | $site_url = get_bloginfo('url'); |
935 | - $site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s) |
|
935 | + $site_url = substr($site_url, (int) strpos($site_url, '://')); // remove the http(s) |
|
936 | 936 | $replace = ''; |
937 | 937 | |
938 | - foreach ( $link_matches[1] as $key => $value ) { |
|
939 | - if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') |
|
940 | - || !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) |
|
941 | - || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) |
|
938 | + foreach ($link_matches[1] as $key => $value) { |
|
939 | + if ( ! strpos($value, '?attachment_id=') || ! strpos($value, 'wp-att-') |
|
940 | + || ! preg_match('/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match) |
|
941 | + || ! preg_match('/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match)) |
|
942 | 942 | continue; |
943 | 943 | |
944 | 944 | $quote = $url_match[1]; // the quote (single or double) |
945 | 945 | $url_id = (int) $url_match[2]; |
946 | 946 | $rel_id = (int) $rel_match[1]; |
947 | 947 | |
948 | - if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) |
|
948 | + if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false) |
|
949 | 949 | continue; |
950 | 950 | |
951 | 951 | $link = $link_matches[0][$key]; |
952 | - $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); |
|
952 | + $replace = str_replace($url_match[0], 'href='.$quote.get_attachment_link($url_id).$quote, $link); |
|
953 | 953 | |
954 | - $content = str_replace( $link, $replace, $content ); |
|
954 | + $content = str_replace($link, $replace, $content); |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( $replace ) { |
|
957 | + if ($replace) { |
|
958 | 958 | $post['post_content'] = $content; |
959 | 959 | // Escape data pulled from DB. |
960 | 960 | $post = add_magic_quotes($post); |
@@ -985,40 +985,40 @@ discard block |
||
985 | 985 | * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal. |
986 | 986 | * @return array |
987 | 987 | */ |
988 | -function wp_edit_posts_query( $q = false ) { |
|
989 | - if ( false === $q ) |
|
988 | +function wp_edit_posts_query($q = false) { |
|
989 | + if (false === $q) |
|
990 | 990 | $q = $_GET; |
991 | 991 | $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
992 | 992 | $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
993 | - $post_stati = get_post_stati(); |
|
993 | + $post_stati = get_post_stati(); |
|
994 | 994 | |
995 | - if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) |
|
995 | + if (isset($q['post_type']) && in_array($q['post_type'], get_post_types())) |
|
996 | 996 | $post_type = $q['post_type']; |
997 | 997 | else |
998 | 998 | $post_type = 'post'; |
999 | 999 | |
1000 | 1000 | $avail_post_stati = get_available_post_statuses($post_type); |
1001 | 1001 | |
1002 | - if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) { |
|
1002 | + if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) { |
|
1003 | 1003 | $post_status = $q['post_status']; |
1004 | 1004 | $perm = 'readable'; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | - if ( isset( $q['orderby'] ) ) { |
|
1007 | + if (isset($q['orderby'])) { |
|
1008 | 1008 | $orderby = $q['orderby']; |
1009 | - } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) { |
|
1009 | + } elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'))) { |
|
1010 | 1010 | $orderby = 'modified'; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - if ( isset( $q['order'] ) ) { |
|
1013 | + if (isset($q['order'])) { |
|
1014 | 1014 | $order = $q['order']; |
1015 | - } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) { |
|
1015 | + } elseif (isset($q['post_status']) && 'pending' == $q['post_status']) { |
|
1016 | 1016 | $order = 'ASC'; |
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | $per_page = "edit_{$post_type}_per_page"; |
1020 | - $posts_per_page = (int) get_user_option( $per_page ); |
|
1021 | - if ( empty( $posts_per_page ) || $posts_per_page < 1 ) |
|
1020 | + $posts_per_page = (int) get_user_option($per_page); |
|
1021 | + if (empty($posts_per_page) || $posts_per_page < 1) |
|
1022 | 1022 | $posts_per_page = 20; |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | * @param int $posts_per_page Number of posts to display per page for the given post |
1035 | 1035 | * type. Default 20. |
1036 | 1036 | */ |
1037 | - $posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page ); |
|
1037 | + $posts_per_page = apply_filters("edit_{$post_type}_per_page", $posts_per_page); |
|
1038 | 1038 | |
1039 | 1039 | /** |
1040 | 1040 | * Filter the number of posts displayed per page when specifically listing "posts". |
@@ -1044,12 +1044,12 @@ discard block |
||
1044 | 1044 | * @param int $posts_per_page Number of posts to be displayed. Default 20. |
1045 | 1045 | * @param string $post_type The post type. |
1046 | 1046 | */ |
1047 | - $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type ); |
|
1047 | + $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type); |
|
1048 | 1048 | |
1049 | 1049 | $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page'); |
1050 | 1050 | |
1051 | 1051 | // Hierarchical types require special args. |
1052 | - if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) { |
|
1052 | + if (is_post_type_hierarchical($post_type) && ! isset($orderby)) { |
|
1053 | 1053 | $query['orderby'] = 'menu_order title'; |
1054 | 1054 | $query['order'] = 'asc'; |
1055 | 1055 | $query['posts_per_page'] = -1; |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | $query['fields'] = 'id=>parent'; |
1058 | 1058 | } |
1059 | 1059 | |
1060 | - if ( ! empty( $q['show_sticky'] ) ) |
|
1061 | - $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
1060 | + if ( ! empty($q['show_sticky'])) |
|
1061 | + $query['post__in'] = (array) get_option('sticky_posts'); |
|
1062 | 1062 | |
1063 | - wp( $query ); |
|
1063 | + wp($query); |
|
1064 | 1064 | |
1065 | 1065 | return $avail_post_stati; |
1066 | 1066 | } |
@@ -1091,24 +1091,24 @@ discard block |
||
1091 | 1091 | * to use $_GET superglobal. Default false. |
1092 | 1092 | * @return array The parsed query vars. |
1093 | 1093 | */ |
1094 | -function wp_edit_attachments_query_vars( $q = false ) { |
|
1095 | - if ( false === $q ) { |
|
1094 | +function wp_edit_attachments_query_vars($q = false) { |
|
1095 | + if (false === $q) { |
|
1096 | 1096 | $q = $_GET; |
1097 | 1097 | } |
1098 | - $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; |
|
1099 | - $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; |
|
1098 | + $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
|
1099 | + $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
|
1100 | 1100 | $q['post_type'] = 'attachment'; |
1101 | - $post_type = get_post_type_object( 'attachment' ); |
|
1101 | + $post_type = get_post_type_object('attachment'); |
|
1102 | 1102 | $states = 'inherit'; |
1103 | - if ( current_user_can( $post_type->cap->read_private_posts ) ) { |
|
1103 | + if (current_user_can($post_type->cap->read_private_posts)) { |
|
1104 | 1104 | $states .= ',private'; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states; |
|
1108 | - $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; |
|
1107 | + $q['post_status'] = isset($q['status']) && 'trash' == $q['status'] ? 'trash' : $states; |
|
1108 | + $q['post_status'] = isset($q['attachment-filter']) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; |
|
1109 | 1109 | |
1110 | - $media_per_page = (int) get_user_option( 'upload_per_page' ); |
|
1111 | - if ( empty( $media_per_page ) || $media_per_page < 1 ) { |
|
1110 | + $media_per_page = (int) get_user_option('upload_per_page'); |
|
1111 | + if (empty($media_per_page) || $media_per_page < 1) { |
|
1112 | 1112 | $media_per_page = 20; |
1113 | 1113 | } |
1114 | 1114 | |
@@ -1119,21 +1119,21 @@ discard block |
||
1119 | 1119 | * |
1120 | 1120 | * @param int $media_per_page Number of media to list. Default 20. |
1121 | 1121 | */ |
1122 | - $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page ); |
|
1122 | + $q['posts_per_page'] = apply_filters('upload_per_page', $media_per_page); |
|
1123 | 1123 | |
1124 | 1124 | $post_mime_types = get_post_mime_types(); |
1125 | - if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) { |
|
1125 | + if (isset($q['post_mime_type']) && ! array_intersect((array) $q['post_mime_type'], array_keys($post_mime_types))) { |
|
1126 | 1126 | unset($q['post_mime_type']); |
1127 | 1127 | } |
1128 | 1128 | |
1129 | - foreach ( array_keys( $post_mime_types ) as $type ) { |
|
1130 | - if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) { |
|
1129 | + foreach (array_keys($post_mime_types) as $type) { |
|
1130 | + if (isset($q['attachment-filter']) && "post_mime_type:$type" == $q['attachment-filter']) { |
|
1131 | 1131 | $q['post_mime_type'] = $type; |
1132 | 1132 | break; |
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | |
1136 | - if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) { |
|
1136 | + if (isset($q['detached']) || (isset($q['attachment-filter']) && 'detached' == $q['attachment-filter'])) { |
|
1137 | 1137 | $q['post_parent'] = 0; |
1138 | 1138 | } |
1139 | 1139 | |
@@ -1149,13 +1149,13 @@ discard block |
||
1149 | 1149 | * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal. |
1150 | 1150 | * @return array |
1151 | 1151 | */ |
1152 | -function wp_edit_attachments_query( $q = false ) { |
|
1153 | - wp( wp_edit_attachments_query_vars( $q ) ); |
|
1152 | +function wp_edit_attachments_query($q = false) { |
|
1153 | + wp(wp_edit_attachments_query_vars($q)); |
|
1154 | 1154 | |
1155 | 1155 | $post_mime_types = get_post_mime_types(); |
1156 | - $avail_post_mime_types = get_available_post_mime_types( 'attachment' ); |
|
1156 | + $avail_post_mime_types = get_available_post_mime_types('attachment'); |
|
1157 | 1157 | |
1158 | - return array( $post_mime_types, $avail_post_mime_types ); |
|
1158 | + return array($post_mime_types, $avail_post_mime_types); |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | /** |
@@ -1167,17 +1167,17 @@ discard block |
||
1167 | 1167 | * @param string $page |
1168 | 1168 | * @return string |
1169 | 1169 | */ |
1170 | -function postbox_classes( $id, $page ) { |
|
1171 | - if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) { |
|
1172 | - $classes = array( '' ); |
|
1173 | - } elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) { |
|
1174 | - if ( !is_array( $closed ) ) { |
|
1175 | - $classes = array( '' ); |
|
1170 | +function postbox_classes($id, $page) { |
|
1171 | + if (isset($_GET['edit']) && $_GET['edit'] == $id) { |
|
1172 | + $classes = array(''); |
|
1173 | + } elseif ($closed = get_user_option('closedpostboxes_'.$page)) { |
|
1174 | + if ( ! is_array($closed)) { |
|
1175 | + $classes = array(''); |
|
1176 | 1176 | } else { |
1177 | - $classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' ); |
|
1177 | + $classes = in_array($id, $closed) ? array('closed') : array(''); |
|
1178 | 1178 | } |
1179 | 1179 | } else { |
1180 | - $classes = array( '' ); |
|
1180 | + $classes = array(''); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | /** |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | * |
1191 | 1191 | * @param array $classes An array of postbox classes. |
1192 | 1192 | */ |
1193 | - $classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes ); |
|
1194 | - return implode( ' ', $classes ); |
|
1193 | + $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes); |
|
1194 | + return implode(' ', $classes); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | /** |
@@ -1205,9 +1205,9 @@ discard block |
||
1205 | 1205 | * @return array Array with two entries of type string. |
1206 | 1206 | */ |
1207 | 1207 | function get_sample_permalink($id, $title = null, $name = null) { |
1208 | - $post = get_post( $id ); |
|
1209 | - if ( ! $post ) |
|
1210 | - return array( '', '' ); |
|
1208 | + $post = get_post($id); |
|
1209 | + if ( ! $post) |
|
1210 | + return array('', ''); |
|
1211 | 1211 | |
1212 | 1212 | $ptype = get_post_type_object($post->post_type); |
1213 | 1213 | |
@@ -1216,14 +1216,14 @@ discard block |
||
1216 | 1216 | $original_name = $post->post_name; |
1217 | 1217 | |
1218 | 1218 | // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published. |
1219 | - if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) { |
|
1219 | + if (in_array($post->post_status, array('draft', 'pending', 'future'))) { |
|
1220 | 1220 | $post->post_status = 'publish'; |
1221 | 1221 | $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); |
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | // If the user wants to set a new name -- override the current one |
1225 | 1225 | // Note: if empty name is supplied -- use the title instead, see #6072 |
1226 | - if ( !is_null($name) ) |
|
1226 | + if ( ! is_null($name)) |
|
1227 | 1227 | $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
1228 | 1228 | |
1229 | 1229 | $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); |
@@ -1236,23 +1236,23 @@ discard block |
||
1236 | 1236 | $permalink = str_replace("%$post->post_type%", '%pagename%', $permalink); |
1237 | 1237 | |
1238 | 1238 | // Handle page hierarchy |
1239 | - if ( $ptype->hierarchical ) { |
|
1239 | + if ($ptype->hierarchical) { |
|
1240 | 1240 | $uri = get_page_uri($post); |
1241 | - if ( $uri ) { |
|
1241 | + if ($uri) { |
|
1242 | 1242 | $uri = untrailingslashit($uri); |
1243 | - $uri = strrev( stristr( strrev( $uri ), '/' ) ); |
|
1243 | + $uri = strrev(stristr(strrev($uri), '/')); |
|
1244 | 1244 | $uri = untrailingslashit($uri); |
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
1248 | - $uri = apply_filters( 'editable_slug', $uri, $post ); |
|
1249 | - if ( !empty($uri) ) |
|
1248 | + $uri = apply_filters('editable_slug', $uri, $post); |
|
1249 | + if ( ! empty($uri)) |
|
1250 | 1250 | $uri .= '/'; |
1251 | 1251 | $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); |
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
1255 | - $permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) ); |
|
1255 | + $permalink = array($permalink, apply_filters('editable_slug', $post->post_name, $post)); |
|
1256 | 1256 | $post->post_status = $original_status; |
1257 | 1257 | $post->post_date = $original_date; |
1258 | 1258 | $post->post_name = $original_name; |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | * @param string $name Post name (slug). |
1270 | 1270 | * @param WP_Post $post Post object. |
1271 | 1271 | */ |
1272 | - return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post ); |
|
1272 | + return apply_filters('get_sample_permalink', $permalink, $post->ID, $title, $name, $post); |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | /** |
@@ -1282,9 +1282,9 @@ discard block |
||
1282 | 1282 | * @param string $new_slug Optional. New slug. Default null. |
1283 | 1283 | * @return string The HTML of the sample permalink slug editor. |
1284 | 1284 | */ |
1285 | -function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
|
1286 | - $post = get_post( $id ); |
|
1287 | - if ( ! $post ) |
|
1285 | +function get_sample_permalink_html($id, $new_title = null, $new_slug = null) { |
|
1286 | + $post = get_post($id); |
|
1287 | + if ( ! $post) |
|
1288 | 1288 | return ''; |
1289 | 1289 | |
1290 | 1290 | list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
@@ -1292,58 +1292,58 @@ discard block |
||
1292 | 1292 | $view_link = false; |
1293 | 1293 | $preview_target = ''; |
1294 | 1294 | |
1295 | - if ( current_user_can( 'read_post', $post->ID ) ) { |
|
1296 | - if ( 'draft' === $post->post_status ) { |
|
1297 | - $view_link = get_preview_post_link( $post ); |
|
1295 | + if (current_user_can('read_post', $post->ID)) { |
|
1296 | + if ('draft' === $post->post_status) { |
|
1297 | + $view_link = get_preview_post_link($post); |
|
1298 | 1298 | $preview_target = " target='wp-preview-{$post->ID}'"; |
1299 | 1299 | } else { |
1300 | - if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) { |
|
1301 | - $view_link = get_permalink( $post ); |
|
1300 | + if ('publish' === $post->post_status || 'attachment' === $post->post_type) { |
|
1301 | + $view_link = get_permalink($post); |
|
1302 | 1302 | } else { |
1303 | 1303 | // Allow non-published (private, future) to be viewed at a pretty permalink. |
1304 | - $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink ); |
|
1304 | + $view_link = str_replace(array('%pagename%', '%postname%'), $post->post_name, $permalink); |
|
1305 | 1305 | } |
1306 | 1306 | } |
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | // Permalinks without a post/page name placeholder don't have anything to edit |
1310 | - if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { |
|
1311 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
1310 | + if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { |
|
1311 | + $return = '<strong>'.__('Permalink:')."</strong>\n"; |
|
1312 | 1312 | |
1313 | - if ( false !== $view_link ) { |
|
1314 | - $display_link = urldecode( $view_link ); |
|
1315 | - $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a>\n"; |
|
1313 | + if (false !== $view_link) { |
|
1314 | + $display_link = urldecode($view_link); |
|
1315 | + $return .= '<a id="sample-permalink" href="'.esc_url($view_link).'"'.$preview_target.'>'.$display_link."</a>\n"; |
|
1316 | 1316 | } else { |
1317 | - $return .= '<span id="sample-permalink">' . $permalink . "</span>\n"; |
|
1317 | + $return .= '<span id="sample-permalink">'.$permalink."</span>\n"; |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | // Encourage a pretty permalink setting |
1321 | - if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { |
|
1322 | - $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; |
|
1321 | + if ('' == get_option('permalink_structure') && current_user_can('manage_options') && ! ('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) { |
|
1322 | + $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">'.__('Change Permalinks')."</a></span>\n"; |
|
1323 | 1323 | } |
1324 | 1324 | } else { |
1325 | - if ( function_exists( 'mb_strlen' ) ) { |
|
1326 | - if ( mb_strlen( $post_name ) > 34 ) { |
|
1327 | - $post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 ); |
|
1325 | + if (function_exists('mb_strlen')) { |
|
1326 | + if (mb_strlen($post_name) > 34) { |
|
1327 | + $post_name_abridged = mb_substr($post_name, 0, 16).'…'.mb_substr($post_name, -16); |
|
1328 | 1328 | } else { |
1329 | 1329 | $post_name_abridged = $post_name; |
1330 | 1330 | } |
1331 | 1331 | } else { |
1332 | - if ( strlen( $post_name ) > 34 ) { |
|
1333 | - $post_name_abridged = substr( $post_name, 0, 16 ) . '…' . substr( $post_name, -16 ); |
|
1332 | + if (strlen($post_name) > 34) { |
|
1333 | + $post_name_abridged = substr($post_name, 0, 16).'…'.substr($post_name, -16); |
|
1334 | 1334 | } else { |
1335 | 1335 | $post_name_abridged = $post_name; |
1336 | 1336 | } |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - $post_name_html = '<span id="editable-post-name">' . $post_name_abridged . '</span>'; |
|
1340 | - $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) ); |
|
1339 | + $post_name_html = '<span id="editable-post-name">'.$post_name_abridged.'</span>'; |
|
1340 | + $display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, urldecode($permalink)); |
|
1341 | 1341 | |
1342 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
1343 | - $return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n"; |
|
1342 | + $return = '<strong>'.__('Permalink:')."</strong>\n"; |
|
1343 | + $return .= '<span id="sample-permalink"><a href="'.esc_url($view_link).'"'.$preview_target.'>'.$display_link."</a></span>\n"; |
|
1344 | 1344 | $return .= '‎'; // Fix bi-directional text display defect in RTL languages. |
1345 | - $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __( 'Edit permalink' ) . '">' . __( 'Edit' ) . "</button></span>\n"; |
|
1346 | - $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; |
|
1345 | + $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="'.__('Edit permalink').'">'.__('Edit')."</button></span>\n"; |
|
1346 | + $return .= '<span id="editable-post-name-full">'.$post_name."</span>\n"; |
|
1347 | 1347 | } |
1348 | 1348 | |
1349 | 1349 | /** |
@@ -1358,7 +1358,7 @@ discard block |
||
1358 | 1358 | * @param string $new_slug New sample permalink slug. |
1359 | 1359 | * @param WP_Post $post Post object. |
1360 | 1360 | */ |
1361 | - $return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post ); |
|
1361 | + $return = apply_filters('get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post); |
|
1362 | 1362 | |
1363 | 1363 | return $return; |
1364 | 1364 | } |
@@ -1375,22 +1375,22 @@ discard block |
||
1375 | 1375 | * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. |
1376 | 1376 | * @return string html |
1377 | 1377 | */ |
1378 | -function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { |
|
1378 | +function _wp_post_thumbnail_html($thumbnail_id = null, $post = null) { |
|
1379 | 1379 | global $content_width, $_wp_additional_image_sizes; |
1380 | 1380 | |
1381 | - $post = get_post( $post ); |
|
1382 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
1381 | + $post = get_post($post); |
|
1382 | + $post_type_object = get_post_type_object($post->post_type); |
|
1383 | 1383 | $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>'; |
1384 | - $upload_iframe_src = get_upload_iframe_src( 'image', $post->ID ); |
|
1384 | + $upload_iframe_src = get_upload_iframe_src('image', $post->ID); |
|
1385 | 1385 | |
1386 | - $content = sprintf( $set_thumbnail_link, |
|
1387 | - esc_url( $upload_iframe_src ), |
|
1386 | + $content = sprintf($set_thumbnail_link, |
|
1387 | + esc_url($upload_iframe_src), |
|
1388 | 1388 | '', // Empty when there's no featured image set, `aria-describedby` attribute otherwise. |
1389 | - esc_html( $post_type_object->labels->set_featured_image ) |
|
1389 | + esc_html($post_type_object->labels->set_featured_image) |
|
1390 | 1390 | ); |
1391 | 1391 | |
1392 | - if ( $thumbnail_id && get_post( $thumbnail_id ) ) { |
|
1393 | - $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 ); |
|
1392 | + if ($thumbnail_id && get_post($thumbnail_id)) { |
|
1393 | + $size = isset($_wp_additional_image_sizes['post-thumbnail']) ? 'post-thumbnail' : array(266, 266); |
|
1394 | 1394 | |
1395 | 1395 | /** |
1396 | 1396 | * Filter the size used to display the post thumbnail image in the 'Featured Image' meta box. |
@@ -1409,19 +1409,19 @@ discard block |
||
1409 | 1409 | * @param int $thumbnail_id Post thumbnail attachment ID. |
1410 | 1410 | * @param WP_Post $post The post object associated with the thumbnail. |
1411 | 1411 | */ |
1412 | - $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post ); |
|
1412 | + $size = apply_filters('admin_post_thumbnail_size', $size, $thumbnail_id, $post); |
|
1413 | 1413 | |
1414 | - $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size ); |
|
1414 | + $thumbnail_html = wp_get_attachment_image($thumbnail_id, $size); |
|
1415 | 1415 | |
1416 | - if ( !empty( $thumbnail_html ) ) { |
|
1417 | - $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); |
|
1418 | - $content = sprintf( $set_thumbnail_link, |
|
1419 | - esc_url( $upload_iframe_src ), |
|
1416 | + if ( ! empty($thumbnail_html)) { |
|
1417 | + $ajax_nonce = wp_create_nonce('set_post_thumbnail-'.$post->ID); |
|
1418 | + $content = sprintf($set_thumbnail_link, |
|
1419 | + esc_url($upload_iframe_src), |
|
1420 | 1420 | ' aria-describedby="set-post-thumbnail-desc"', |
1421 | 1421 | $thumbnail_html |
1422 | 1422 | ); |
1423 | - $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>'; |
|
1424 | - $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>'; |
|
1423 | + $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">'.__('Click the image to edit or update').'</p>'; |
|
1424 | + $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\''.$ajax_nonce.'\');return false;">'.esc_html($post_type_object->labels->remove_featured_image).'</a></p>'; |
|
1425 | 1425 | } |
1426 | 1426 | } |
1427 | 1427 | |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | * @param string $content Admin post thumbnail HTML markup. |
1434 | 1434 | * @param int $post_id Post ID. |
1435 | 1435 | */ |
1436 | - return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID ); |
|
1436 | + return apply_filters('admin_post_thumbnail_html', $content, $post->ID); |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | /** |
@@ -1444,21 +1444,21 @@ discard block |
||
1444 | 1444 | * @param int $post_id ID of the post to check for editing |
1445 | 1445 | * @return integer False: not locked or locked by current user. Int: user ID of user with lock. |
1446 | 1446 | */ |
1447 | -function wp_check_post_lock( $post_id ) { |
|
1448 | - if ( !$post = get_post( $post_id ) ) |
|
1447 | +function wp_check_post_lock($post_id) { |
|
1448 | + if ( ! $post = get_post($post_id)) |
|
1449 | 1449 | return false; |
1450 | 1450 | |
1451 | - if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) |
|
1451 | + if ( ! $lock = get_post_meta($post->ID, '_edit_lock', true)) |
|
1452 | 1452 | return false; |
1453 | 1453 | |
1454 | - $lock = explode( ':', $lock ); |
|
1454 | + $lock = explode(':', $lock); |
|
1455 | 1455 | $time = $lock[0]; |
1456 | - $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); |
|
1456 | + $user = isset($lock[1]) ? $lock[1] : get_post_meta($post->ID, '_edit_last', true); |
|
1457 | 1457 | |
1458 | 1458 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
1459 | - $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); |
|
1459 | + $time_window = apply_filters('wp_check_post_lock_window', 150); |
|
1460 | 1460 | |
1461 | - if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) |
|
1461 | + if ($time && $time > time() - $time_window && $user != get_current_user_id()) |
|
1462 | 1462 | return $user; |
1463 | 1463 | return false; |
1464 | 1464 | } |
@@ -1472,17 +1472,17 @@ discard block |
||
1472 | 1472 | * @return bool|array Returns false if the post doesn't exist of there is no current user, or |
1473 | 1473 | * an array of the lock time and the user ID. |
1474 | 1474 | */ |
1475 | -function wp_set_post_lock( $post_id ) { |
|
1476 | - if ( !$post = get_post( $post_id ) ) |
|
1475 | +function wp_set_post_lock($post_id) { |
|
1476 | + if ( ! $post = get_post($post_id)) |
|
1477 | 1477 | return false; |
1478 | - if ( 0 == ($user_id = get_current_user_id()) ) |
|
1478 | + if (0 == ($user_id = get_current_user_id())) |
|
1479 | 1479 | return false; |
1480 | 1480 | |
1481 | 1481 | $now = time(); |
1482 | 1482 | $lock = "$now:$user_id"; |
1483 | 1483 | |
1484 | - update_post_meta( $post->ID, '_edit_lock', $lock ); |
|
1485 | - return array( $now, $user_id ); |
|
1484 | + update_post_meta($post->ID, '_edit_lock', $lock); |
|
1485 | + return array($now, $user_id); |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | /** |
@@ -1492,14 +1492,14 @@ discard block |
||
1492 | 1492 | * @return none |
1493 | 1493 | */ |
1494 | 1494 | function _admin_notice_post_locked() { |
1495 | - if ( ! $post = get_post() ) |
|
1495 | + if ( ! $post = get_post()) |
|
1496 | 1496 | return; |
1497 | 1497 | |
1498 | 1498 | $user = null; |
1499 | - if ( $user_id = wp_check_post_lock( $post->ID ) ) |
|
1500 | - $user = get_userdata( $user_id ); |
|
1499 | + if ($user_id = wp_check_post_lock($post->ID)) |
|
1500 | + $user = get_userdata($user_id); |
|
1501 | 1501 | |
1502 | - if ( $user ) { |
|
1502 | + if ($user) { |
|
1503 | 1503 | |
1504 | 1504 | /** |
1505 | 1505 | * Filter whether to show the post locked dialog. |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | * @param bool $display Whether to display the dialog. Default true. |
1512 | 1512 | * @param WP_User|bool $user WP_User object on success, false otherwise. |
1513 | 1513 | */ |
1514 | - if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) |
|
1514 | + if ( ! apply_filters('show_post_locked_dialog', true, $post, $user)) |
|
1515 | 1515 | return; |
1516 | 1516 | |
1517 | 1517 | $locked = true; |
@@ -1519,17 +1519,17 @@ discard block |
||
1519 | 1519 | $locked = false; |
1520 | 1520 | } |
1521 | 1521 | |
1522 | - if ( $locked && ( $sendback = wp_get_referer() ) && |
|
1523 | - false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) { |
|
1522 | + if ($locked && ($sendback = wp_get_referer()) && |
|
1523 | + false === strpos($sendback, 'post.php') && false === strpos($sendback, 'post-new.php')) { |
|
1524 | 1524 | |
1525 | 1525 | $sendback_text = __('Go back'); |
1526 | 1526 | } else { |
1527 | - $sendback = admin_url( 'edit.php' ); |
|
1527 | + $sendback = admin_url('edit.php'); |
|
1528 | 1528 | |
1529 | - if ( 'post' != $post->post_type ) |
|
1530 | - $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
1529 | + if ('post' != $post->post_type) |
|
1530 | + $sendback = add_query_arg('post_type', $post->post_type, $sendback); |
|
1531 | 1531 | |
1532 | - $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; |
|
1532 | + $sendback_text = get_post_type_object($post->post_type)->labels->all_items; |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | 1535 | $hidden = $locked ? '' : ' hidden'; |
@@ -1540,18 +1540,18 @@ discard block |
||
1540 | 1540 | <div class="notification-dialog"> |
1541 | 1541 | <?php |
1542 | 1542 | |
1543 | - if ( $locked ) { |
|
1543 | + if ($locked) { |
|
1544 | 1544 | $query_args = array(); |
1545 | - if ( get_post_type_object( $post->post_type )->public ) { |
|
1546 | - if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) { |
|
1545 | + if (get_post_type_object($post->post_type)->public) { |
|
1546 | + if ('publish' == $post->post_status || $user->ID != $post->post_author) { |
|
1547 | 1547 | // Latest content is in autosave |
1548 | - $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
1548 | + $nonce = wp_create_nonce('post_preview_'.$post->ID); |
|
1549 | 1549 | $query_args['preview_id'] = $post->ID; |
1550 | 1550 | $query_args['preview_nonce'] = $nonce; |
1551 | 1551 | } |
1552 | 1552 | } |
1553 | 1553 | |
1554 | - $preview_link = get_preview_post_link( $post->ID, $query_args ); |
|
1554 | + $preview_link = get_preview_post_link($post->ID, $query_args); |
|
1555 | 1555 | |
1556 | 1556 | /** |
1557 | 1557 | * Filter whether to allow the post lock to be overridden. |
@@ -1565,17 +1565,17 @@ discard block |
||
1565 | 1565 | * @param WP_Post $post Post object. |
1566 | 1566 | * @param WP_User $user User object. |
1567 | 1567 | */ |
1568 | - $override = apply_filters( 'override_post_lock', true, $post, $user ); |
|
1568 | + $override = apply_filters('override_post_lock', true, $post, $user); |
|
1569 | 1569 | $tab_last = $override ? '' : ' wp-tab-last'; |
1570 | 1570 | |
1571 | 1571 | ?> |
1572 | 1572 | <div class="post-locked-message"> |
1573 | - <div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div> |
|
1573 | + <div class="post-locked-avatar"><?php echo get_avatar($user->ID, 64); ?></div> |
|
1574 | 1574 | <p class="currently-editing wp-tab-first" tabindex="0"> |
1575 | 1575 | <?php |
1576 | - _e( 'This content is currently locked.' ); |
|
1577 | - if ( $override ) |
|
1578 | - printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
1576 | + _e('This content is currently locked.'); |
|
1577 | + if ($override) |
|
1578 | + printf(' '.__('If you take over, %s will be blocked from continuing to edit.'), esc_html($user->display_name)); |
|
1579 | 1579 | ?> |
1580 | 1580 | </p> |
1581 | 1581 | <?php |
@@ -1586,19 +1586,19 @@ discard block |
||
1586 | 1586 | * |
1587 | 1587 | * @param WP_Post $post Post object. |
1588 | 1588 | */ |
1589 | - do_action( 'post_locked_dialog', $post ); |
|
1589 | + do_action('post_locked_dialog', $post); |
|
1590 | 1590 | ?> |
1591 | 1591 | <p> |
1592 | - <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a> |
|
1593 | - <?php if ( $preview_link ) { ?> |
|
1594 | - <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a> |
|
1592 | + <a class="button" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a> |
|
1593 | + <?php if ($preview_link) { ?> |
|
1594 | + <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url($preview_link); ?>"><?php _e('Preview'); ?></a> |
|
1595 | 1595 | <?php |
1596 | 1596 | } |
1597 | 1597 | |
1598 | 1598 | // Allow plugins to prevent some users overriding the post lock |
1599 | - if ( $override ) { |
|
1599 | + if ($override) { |
|
1600 | 1600 | ?> |
1601 | - <a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e('Take over'); ?></a> |
|
1601 | + <a class="button button-primary wp-tab-last" href="<?php echo esc_url(add_query_arg('get-post-lock', '1', wp_nonce_url(get_edit_post_link($post->ID, 'url'), 'lock-post_'.$post->ID))); ?>"><?php _e('Take over'); ?></a> |
|
1602 | 1602 | <?php |
1603 | 1603 | } |
1604 | 1604 | |
@@ -1612,7 +1612,7 @@ discard block |
||
1612 | 1612 | <div class="post-locked-avatar"></div> |
1613 | 1613 | <p class="wp-tab-first" tabindex="0"> |
1614 | 1614 | <span class="currently-editing"></span><br /> |
1615 | - <span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" alt="" /> <?php _e( 'Saving revision…' ); ?></span> |
|
1615 | + <span class="locked-saving hidden"><img src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" width="16" height="16" alt="" /> <?php _e('Saving revision…'); ?></span> |
|
1616 | 1616 | <span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span> |
1617 | 1617 | </p> |
1618 | 1618 | <?php |
@@ -1623,9 +1623,9 @@ discard block |
||
1623 | 1623 | * |
1624 | 1624 | * @param WP_Post $post Post object. |
1625 | 1625 | */ |
1626 | - do_action( 'post_lock_lost_dialog', $post ); |
|
1626 | + do_action('post_lock_lost_dialog', $post); |
|
1627 | 1627 | ?> |
1628 | - <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p> |
|
1628 | + <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a></p> |
|
1629 | 1629 | </div> |
1630 | 1630 | <?php |
1631 | 1631 | } |
@@ -1646,38 +1646,38 @@ discard block |
||
1646 | 1646 | * @param mixed $post_data Associative array containing the post data or int post ID. |
1647 | 1647 | * @return mixed The autosave revision ID. WP_Error or 0 on error. |
1648 | 1648 | */ |
1649 | -function wp_create_post_autosave( $post_data ) { |
|
1650 | - if ( is_numeric( $post_data ) ) { |
|
1649 | +function wp_create_post_autosave($post_data) { |
|
1650 | + if (is_numeric($post_data)) { |
|
1651 | 1651 | $post_id = $post_data; |
1652 | 1652 | $post_data = $_POST; |
1653 | 1653 | } else { |
1654 | 1654 | $post_id = (int) $post_data['post_ID']; |
1655 | 1655 | } |
1656 | 1656 | |
1657 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
1658 | - if ( is_wp_error( $post_data ) ) |
|
1657 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
1658 | + if (is_wp_error($post_data)) |
|
1659 | 1659 | return $post_data; |
1660 | 1660 | |
1661 | 1661 | $post_author = get_current_user_id(); |
1662 | 1662 | |
1663 | 1663 | // Store one autosave per author. If there is already an autosave, overwrite it. |
1664 | - if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) { |
|
1665 | - $new_autosave = _wp_post_revision_data( $post_data, true ); |
|
1664 | + if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) { |
|
1665 | + $new_autosave = _wp_post_revision_data($post_data, true); |
|
1666 | 1666 | $new_autosave['ID'] = $old_autosave->ID; |
1667 | 1667 | $new_autosave['post_author'] = $post_author; |
1668 | 1668 | |
1669 | 1669 | // If the new autosave has the same content as the post, delete the autosave. |
1670 | - $post = get_post( $post_id ); |
|
1670 | + $post = get_post($post_id); |
|
1671 | 1671 | $autosave_is_different = false; |
1672 | - foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { |
|
1673 | - if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { |
|
1672 | + foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields($post))) as $field) { |
|
1673 | + if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->$field)) { |
|
1674 | 1674 | $autosave_is_different = true; |
1675 | 1675 | break; |
1676 | 1676 | } |
1677 | 1677 | } |
1678 | 1678 | |
1679 | - if ( ! $autosave_is_different ) { |
|
1680 | - wp_delete_post_revision( $old_autosave->ID ); |
|
1679 | + if ( ! $autosave_is_different) { |
|
1680 | + wp_delete_post_revision($old_autosave->ID); |
|
1681 | 1681 | return 0; |
1682 | 1682 | } |
1683 | 1683 | |
@@ -1688,16 +1688,16 @@ discard block |
||
1688 | 1688 | * |
1689 | 1689 | * @param array $new_autosave Post array - the autosave that is about to be saved. |
1690 | 1690 | */ |
1691 | - do_action( 'wp_creating_autosave', $new_autosave ); |
|
1691 | + do_action('wp_creating_autosave', $new_autosave); |
|
1692 | 1692 | |
1693 | - return wp_update_post( $new_autosave ); |
|
1693 | + return wp_update_post($new_autosave); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | // _wp_put_post_revision() expects unescaped. |
1697 | - $post_data = wp_unslash( $post_data ); |
|
1697 | + $post_data = wp_unslash($post_data); |
|
1698 | 1698 | |
1699 | 1699 | // Otherwise create the new autosave as a special post revision |
1700 | - return _wp_put_post_revision( $post_data, true ); |
|
1700 | + return _wp_put_post_revision($post_data, true); |
|
1701 | 1701 | } |
1702 | 1702 | |
1703 | 1703 | /** |
@@ -1713,41 +1713,41 @@ discard block |
||
1713 | 1713 | $post_ID = (int) $_POST['post_ID']; |
1714 | 1714 | $_POST['ID'] = $post_ID; |
1715 | 1715 | |
1716 | - if ( ! $post = get_post( $post_ID ) ) { |
|
1717 | - wp_die( __( 'You are not allowed to edit this post.' ) ); |
|
1716 | + if ( ! $post = get_post($post_ID)) { |
|
1717 | + wp_die(__('You are not allowed to edit this post.')); |
|
1718 | 1718 | } |
1719 | 1719 | |
1720 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
1721 | - wp_die( __( 'You are not allowed to edit this post.' ) ); |
|
1720 | + if ( ! current_user_can('edit_post', $post->ID)) { |
|
1721 | + wp_die(__('You are not allowed to edit this post.')); |
|
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | $is_autosave = false; |
1725 | 1725 | |
1726 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) { |
|
1726 | + if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('draft' == $post->post_status || 'auto-draft' == $post->post_status)) { |
|
1727 | 1727 | $saved_post_id = edit_post(); |
1728 | 1728 | } else { |
1729 | 1729 | $is_autosave = true; |
1730 | 1730 | |
1731 | - if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) |
|
1731 | + if (isset($_POST['post_status']) && 'auto-draft' == $_POST['post_status']) |
|
1732 | 1732 | $_POST['post_status'] = 'draft'; |
1733 | 1733 | |
1734 | - $saved_post_id = wp_create_post_autosave( $post->ID ); |
|
1734 | + $saved_post_id = wp_create_post_autosave($post->ID); |
|
1735 | 1735 | } |
1736 | 1736 | |
1737 | - if ( is_wp_error( $saved_post_id ) ) |
|
1738 | - wp_die( $saved_post_id->get_error_message() ); |
|
1737 | + if (is_wp_error($saved_post_id)) |
|
1738 | + wp_die($saved_post_id->get_error_message()); |
|
1739 | 1739 | |
1740 | 1740 | $query_args = array(); |
1741 | 1741 | |
1742 | - if ( $is_autosave && $saved_post_id ) { |
|
1742 | + if ($is_autosave && $saved_post_id) { |
|
1743 | 1743 | $query_args['preview_id'] = $post->ID; |
1744 | - $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
1744 | + $query_args['preview_nonce'] = wp_create_nonce('post_preview_'.$post->ID); |
|
1745 | 1745 | |
1746 | - if ( isset( $_POST['post_format'] ) ) |
|
1747 | - $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
1746 | + if (isset($_POST['post_format'])) |
|
1747 | + $query_args['post_format'] = empty($_POST['post_format']) ? 'standard' : sanitize_key($_POST['post_format']); |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | - return get_preview_post_link( $post, $query_args ); |
|
1750 | + return get_preview_post_link($post, $query_args); |
|
1751 | 1751 | } |
1752 | 1752 | |
1753 | 1753 | /** |
@@ -1761,36 +1761,36 @@ discard block |
||
1761 | 1761 | * @return mixed The value 0 or WP_Error on failure. The saved post ID on success. |
1762 | 1762 | * The ID can be the draft post_id or the autosave revision post_id. |
1763 | 1763 | */ |
1764 | -function wp_autosave( $post_data ) { |
|
1764 | +function wp_autosave($post_data) { |
|
1765 | 1765 | // Back-compat |
1766 | - if ( ! defined( 'DOING_AUTOSAVE' ) ) |
|
1767 | - define( 'DOING_AUTOSAVE', true ); |
|
1766 | + if ( ! defined('DOING_AUTOSAVE')) |
|
1767 | + define('DOING_AUTOSAVE', true); |
|
1768 | 1768 | |
1769 | 1769 | $post_id = (int) $post_data['post_id']; |
1770 | 1770 | $post_data['ID'] = $post_data['post_ID'] = $post_id; |
1771 | 1771 | |
1772 | - if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) { |
|
1773 | - return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) ); |
|
1772 | + if (false === wp_verify_nonce($post_data['_wpnonce'], 'update-post_'.$post_id)) { |
|
1773 | + return new WP_Error('invalid_nonce', __('Error while saving.')); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | - $post = get_post( $post_id ); |
|
1776 | + $post = get_post($post_id); |
|
1777 | 1777 | |
1778 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
1779 | - return new WP_Error( 'edit_posts', __( 'You are not allowed to edit this item.' ) ); |
|
1778 | + if ( ! current_user_can('edit_post', $post->ID)) { |
|
1779 | + return new WP_Error('edit_posts', __('You are not allowed to edit this item.')); |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | - if ( 'auto-draft' == $post->post_status ) |
|
1782 | + if ('auto-draft' == $post->post_status) |
|
1783 | 1783 | $post_data['post_status'] = 'draft'; |
1784 | 1784 | |
1785 | - if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) |
|
1786 | - $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
1785 | + if ($post_data['post_type'] != 'page' && ! empty($post_data['catslist'])) |
|
1786 | + $post_data['post_category'] = explode(',', $post_data['catslist']); |
|
1787 | 1787 | |
1788 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { |
|
1788 | + if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) { |
|
1789 | 1789 | // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked |
1790 | - return edit_post( wp_slash( $post_data ) ); |
|
1790 | + return edit_post(wp_slash($post_data)); |
|
1791 | 1791 | } else { |
1792 | 1792 | // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user. |
1793 | - return wp_create_post_autosave( wp_slash( $post_data ) ); |
|
1793 | + return wp_create_post_autosave(wp_slash($post_data)); |
|
1794 | 1794 | } |
1795 | 1795 | } |
1796 | 1796 | |
@@ -1800,11 +1800,11 @@ discard block |
||
1800 | 1800 | * @param int $post_id Optional. Post ID. |
1801 | 1801 | */ |
1802 | 1802 | function redirect_post($post_id = '') { |
1803 | - if ( isset($_POST['save']) || isset($_POST['publish']) ) { |
|
1804 | - $status = get_post_status( $post_id ); |
|
1803 | + if (isset($_POST['save']) || isset($_POST['publish'])) { |
|
1804 | + $status = get_post_status($post_id); |
|
1805 | 1805 | |
1806 | - if ( isset( $_POST['publish'] ) ) { |
|
1807 | - switch ( $status ) { |
|
1806 | + if (isset($_POST['publish'])) { |
|
1807 | + switch ($status) { |
|
1808 | 1808 | case 'pending': |
1809 | 1809 | $message = 8; |
1810 | 1810 | break; |
@@ -1818,17 +1818,17 @@ discard block |
||
1818 | 1818 | $message = 'draft' == $status ? 10 : 1; |
1819 | 1819 | } |
1820 | 1820 | |
1821 | - $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); |
|
1822 | - } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) { |
|
1823 | - $location = add_query_arg( 'message', 2, wp_get_referer() ); |
|
1821 | + $location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url')); |
|
1822 | + } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { |
|
1823 | + $location = add_query_arg('message', 2, wp_get_referer()); |
|
1824 | 1824 | $location = explode('#', $location); |
1825 | - $location = $location[0] . '#postcustom'; |
|
1826 | - } elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { |
|
1827 | - $location = add_query_arg( 'message', 3, wp_get_referer() ); |
|
1825 | + $location = $location[0].'#postcustom'; |
|
1826 | + } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { |
|
1827 | + $location = add_query_arg('message', 3, wp_get_referer()); |
|
1828 | 1828 | $location = explode('#', $location); |
1829 | - $location = $location[0] . '#postcustom'; |
|
1829 | + $location = $location[0].'#postcustom'; |
|
1830 | 1830 | } else { |
1831 | - $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); |
|
1831 | + $location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url')); |
|
1832 | 1832 | } |
1833 | 1833 | |
1834 | 1834 | /** |
@@ -1839,6 +1839,6 @@ discard block |
||
1839 | 1839 | * @param string $location The destination URL. |
1840 | 1840 | * @param int $post_id The post ID. |
1841 | 1841 | */ |
1842 | - wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); |
|
1842 | + wp_redirect(apply_filters('redirect_post_location', $location, $post_id)); |
|
1843 | 1843 | exit; |
1844 | 1844 | } |
@@ -20,37 +20,45 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function _wp_translate_postdata( $update = false, $post_data = null ) { |
22 | 22 | |
23 | - if ( empty($post_data) ) |
|
24 | - $post_data = &$_POST; |
|
23 | + if ( empty($post_data) ) { |
|
24 | + $post_data = &$_POST; |
|
25 | + } |
|
25 | 26 | |
26 | - if ( $update ) |
|
27 | - $post_data['ID'] = (int) $post_data['post_ID']; |
|
27 | + if ( $update ) { |
|
28 | + $post_data['ID'] = (int) $post_data['post_ID']; |
|
29 | + } |
|
28 | 30 | |
29 | 31 | $ptype = get_post_type_object( $post_data['post_type'] ); |
30 | 32 | |
31 | 33 | if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { |
32 | - if ( 'page' == $post_data['post_type'] ) |
|
33 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
34 | - else |
|
35 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
34 | + if ( 'page' == $post_data['post_type'] ) { |
|
35 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
36 | + } else { |
|
37 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
38 | + } |
|
36 | 39 | } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
37 | - if ( 'page' == $post_data['post_type'] ) |
|
38 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
39 | - else |
|
40 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
40 | + if ( 'page' == $post_data['post_type'] ) { |
|
41 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
42 | + } else { |
|
43 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
44 | + } |
|
41 | 45 | } |
42 | 46 | |
43 | - if ( isset( $post_data['content'] ) ) |
|
44 | - $post_data['post_content'] = $post_data['content']; |
|
47 | + if ( isset( $post_data['content'] ) ) { |
|
48 | + $post_data['post_content'] = $post_data['content']; |
|
49 | + } |
|
45 | 50 | |
46 | - if ( isset( $post_data['excerpt'] ) ) |
|
47 | - $post_data['post_excerpt'] = $post_data['excerpt']; |
|
51 | + if ( isset( $post_data['excerpt'] ) ) { |
|
52 | + $post_data['post_excerpt'] = $post_data['excerpt']; |
|
53 | + } |
|
48 | 54 | |
49 | - if ( isset( $post_data['parent_id'] ) ) |
|
50 | - $post_data['post_parent'] = (int) $post_data['parent_id']; |
|
55 | + if ( isset( $post_data['parent_id'] ) ) { |
|
56 | + $post_data['post_parent'] = (int) $post_data['parent_id']; |
|
57 | + } |
|
51 | 58 | |
52 | - if ( isset($post_data['trackback_url']) ) |
|
53 | - $post_data['to_ping'] = $post_data['trackback_url']; |
|
59 | + if ( isset($post_data['trackback_url']) ) { |
|
60 | + $post_data['to_ping'] = $post_data['trackback_url']; |
|
61 | + } |
|
54 | 62 | |
55 | 63 | $post_data['user_ID'] = get_current_user_id(); |
56 | 64 | |
@@ -67,15 +75,17 @@ discard block |
||
67 | 75 | if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
68 | 76 | && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
69 | 77 | if ( $update ) { |
70 | - if ( 'page' == $post_data['post_type'] ) |
|
71 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
72 | - else |
|
73 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
78 | + if ( 'page' == $post_data['post_type'] ) { |
|
79 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
80 | + } else { |
|
81 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
82 | + } |
|
74 | 83 | } else { |
75 | - if ( 'page' == $post_data['post_type'] ) |
|
76 | - return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
77 | - else |
|
78 | - return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
84 | + if ( 'page' == $post_data['post_type'] ) { |
|
85 | + return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
86 | + } else { |
|
87 | + return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
88 | + } |
|
79 | 89 | } |
80 | 90 | } |
81 | 91 | |
@@ -93,21 +103,27 @@ discard block |
||
93 | 103 | } |
94 | 104 | |
95 | 105 | // What to do based on which button they pressed |
96 | - if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
|
97 | - $post_data['post_status'] = 'draft'; |
|
98 | - if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) |
|
99 | - $post_data['post_status'] = 'private'; |
|
100 | - if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) |
|
101 | - $post_data['post_status'] = 'publish'; |
|
102 | - if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) |
|
103 | - $post_data['post_status'] = 'draft'; |
|
104 | - if ( isset($post_data['pending']) && '' != $post_data['pending'] ) |
|
105 | - $post_data['post_status'] = 'pending'; |
|
106 | - |
|
107 | - if ( isset( $post_data['ID'] ) ) |
|
108 | - $post_id = $post_data['ID']; |
|
109 | - else |
|
110 | - $post_id = false; |
|
106 | + if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) { |
|
107 | + $post_data['post_status'] = 'draft'; |
|
108 | + } |
|
109 | + if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) { |
|
110 | + $post_data['post_status'] = 'private'; |
|
111 | + } |
|
112 | + if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) { |
|
113 | + $post_data['post_status'] = 'publish'; |
|
114 | + } |
|
115 | + if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) { |
|
116 | + $post_data['post_status'] = 'draft'; |
|
117 | + } |
|
118 | + if ( isset($post_data['pending']) && '' != $post_data['pending'] ) { |
|
119 | + $post_data['post_status'] = 'pending'; |
|
120 | + } |
|
121 | + |
|
122 | + if ( isset( $post_data['ID'] ) ) { |
|
123 | + $post_id = $post_data['ID']; |
|
124 | + } else { |
|
125 | + $post_id = false; |
|
126 | + } |
|
111 | 127 | $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; |
112 | 128 | |
113 | 129 | if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { |
@@ -118,9 +134,10 @@ discard block |
||
118 | 134 | |
119 | 135 | // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. |
120 | 136 | // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. |
121 | - if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) |
|
122 | - if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
137 | + if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) { |
|
138 | + if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
123 | 139 | $post_data['post_status'] = 'pending'; |
140 | + } |
|
124 | 141 | |
125 | 142 | if ( ! isset( $post_data['post_status'] ) ) { |
126 | 143 | $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; |
@@ -130,11 +147,13 @@ discard block |
||
130 | 147 | unset( $post_data['post_password'] ); |
131 | 148 | } |
132 | 149 | |
133 | - if (!isset( $post_data['comment_status'] )) |
|
134 | - $post_data['comment_status'] = 'closed'; |
|
150 | + if (!isset( $post_data['comment_status'] )) { |
|
151 | + $post_data['comment_status'] = 'closed'; |
|
152 | + } |
|
135 | 153 | |
136 | - if (!isset( $post_data['ping_status'] )) |
|
137 | - $post_data['ping_status'] = 'closed'; |
|
154 | + if (!isset( $post_data['ping_status'] )) { |
|
155 | + $post_data['ping_status'] = 'closed'; |
|
156 | + } |
|
138 | 157 | |
139 | 158 | foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
140 | 159 | if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { |
@@ -181,8 +200,9 @@ discard block |
||
181 | 200 | function edit_post( $post_data = null ) { |
182 | 201 | global $wpdb; |
183 | 202 | |
184 | - if ( empty($post_data) ) |
|
185 | - $post_data = &$_POST; |
|
203 | + if ( empty($post_data) ) { |
|
204 | + $post_data = &$_POST; |
|
205 | + } |
|
186 | 206 | |
187 | 207 | // Clear out any data in internal vars. |
188 | 208 | unset( $post_data['filter'] ); |
@@ -202,10 +222,11 @@ discard block |
||
202 | 222 | |
203 | 223 | $ptype = get_post_type_object($post_data['post_type']); |
204 | 224 | if ( !current_user_can( 'edit_post', $post_ID ) ) { |
205 | - if ( 'page' == $post_data['post_type'] ) |
|
206 | - wp_die( __('You are not allowed to edit this page.' )); |
|
207 | - else |
|
208 | - wp_die( __('You are not allowed to edit this post.' )); |
|
225 | + if ( 'page' == $post_data['post_type'] ) { |
|
226 | + wp_die( __('You are not allowed to edit this page.' )); |
|
227 | + } else { |
|
228 | + wp_die( __('You are not allowed to edit this post.' )); |
|
229 | + } |
|
209 | 230 | } |
210 | 231 | |
211 | 232 | if ( post_type_supports( $ptype->name, 'revisions' ) ) { |
@@ -213,8 +234,9 @@ discard block |
||
213 | 234 | $revision = current( $revisions ); |
214 | 235 | |
215 | 236 | // Check if the revisions have been upgraded |
216 | - if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) |
|
217 | - _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
237 | + if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) { |
|
238 | + _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
239 | + } |
|
218 | 240 | } |
219 | 241 | |
220 | 242 | if ( isset($post_data['visibility']) ) { |
@@ -234,18 +256,21 @@ discard block |
||
234 | 256 | } |
235 | 257 | |
236 | 258 | $post_data = _wp_translate_postdata( true, $post_data ); |
237 | - if ( is_wp_error($post_data) ) |
|
238 | - wp_die( $post_data->get_error_message() ); |
|
259 | + if ( is_wp_error($post_data) ) { |
|
260 | + wp_die( $post_data->get_error_message() ); |
|
261 | + } |
|
239 | 262 | |
240 | 263 | // Post Formats |
241 | - if ( isset( $post_data['post_format'] ) ) |
|
242 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
264 | + if ( isset( $post_data['post_format'] ) ) { |
|
265 | + set_post_format( $post_ID, $post_data['post_format'] ); |
|
266 | + } |
|
243 | 267 | |
244 | 268 | $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); |
245 | 269 | foreach ( $format_meta_urls as $format_meta_url ) { |
246 | 270 | $keyed = '_format_' . $format_meta_url; |
247 | - if ( isset( $post_data[ $keyed ] ) ) |
|
248 | - update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
271 | + if ( isset( $post_data[ $keyed ] ) ) { |
|
272 | + update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
273 | + } |
|
249 | 274 | } |
250 | 275 | |
251 | 276 | $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); |
@@ -253,10 +278,11 @@ discard block |
||
253 | 278 | foreach ( $format_keys as $key ) { |
254 | 279 | $keyed = '_format_' . $key; |
255 | 280 | if ( isset( $post_data[ $keyed ] ) ) { |
256 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
257 | - update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
258 | - else |
|
259 | - update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
281 | + if ( current_user_can( 'unfiltered_html' ) ) { |
|
282 | + update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
283 | + } else { |
|
284 | + update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
285 | + } |
|
260 | 286 | } |
261 | 287 | } |
262 | 288 | |
@@ -277,24 +303,30 @@ discard block |
||
277 | 303 | // Meta Stuff |
278 | 304 | if ( isset($post_data['meta']) && $post_data['meta'] ) { |
279 | 305 | foreach ( $post_data['meta'] as $key => $value ) { |
280 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
281 | - continue; |
|
282 | - if ( $meta->post_id != $post_ID ) |
|
283 | - continue; |
|
284 | - if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) |
|
285 | - continue; |
|
306 | + if ( !$meta = get_post_meta_by_id( $key ) ) { |
|
307 | + continue; |
|
308 | + } |
|
309 | + if ( $meta->post_id != $post_ID ) { |
|
310 | + continue; |
|
311 | + } |
|
312 | + if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) { |
|
313 | + continue; |
|
314 | + } |
|
286 | 315 | update_meta( $key, $value['key'], $value['value'] ); |
287 | 316 | } |
288 | 317 | } |
289 | 318 | |
290 | 319 | if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { |
291 | 320 | foreach ( $post_data['deletemeta'] as $key => $value ) { |
292 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
293 | - continue; |
|
294 | - if ( $meta->post_id != $post_ID ) |
|
295 | - continue; |
|
296 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) |
|
297 | - continue; |
|
321 | + if ( !$meta = get_post_meta_by_id( $key ) ) { |
|
322 | + continue; |
|
323 | + } |
|
324 | + if ( $meta->post_id != $post_ID ) { |
|
325 | + continue; |
|
326 | + } |
|
327 | + if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) { |
|
328 | + continue; |
|
329 | + } |
|
298 | 330 | delete_meta( $key ); |
299 | 331 | } |
300 | 332 | } |
@@ -386,10 +418,11 @@ discard block |
||
386 | 418 | wp_set_post_lock( $post_ID ); |
387 | 419 | |
388 | 420 | if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { |
389 | - if ( ! empty( $post_data['sticky'] ) ) |
|
390 | - stick_post( $post_ID ); |
|
391 | - else |
|
392 | - unstick_post( $post_ID ); |
|
421 | + if ( ! empty( $post_data['sticky'] ) ) { |
|
422 | + stick_post( $post_ID ); |
|
423 | + } else { |
|
424 | + unstick_post( $post_ID ); |
|
425 | + } |
|
393 | 426 | } |
394 | 427 | |
395 | 428 | return $post_ID; |
@@ -411,19 +444,22 @@ discard block |
||
411 | 444 | function bulk_edit_posts( $post_data = null ) { |
412 | 445 | global $wpdb; |
413 | 446 | |
414 | - if ( empty($post_data) ) |
|
415 | - $post_data = &$_POST; |
|
447 | + if ( empty($post_data) ) { |
|
448 | + $post_data = &$_POST; |
|
449 | + } |
|
416 | 450 | |
417 | - if ( isset($post_data['post_type']) ) |
|
418 | - $ptype = get_post_type_object($post_data['post_type']); |
|
419 | - else |
|
420 | - $ptype = get_post_type_object('post'); |
|
451 | + if ( isset($post_data['post_type']) ) { |
|
452 | + $ptype = get_post_type_object($post_data['post_type']); |
|
453 | + } else { |
|
454 | + $ptype = get_post_type_object('post'); |
|
455 | + } |
|
421 | 456 | |
422 | 457 | if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
423 | - if ( 'page' == $ptype->name ) |
|
424 | - wp_die( __('You are not allowed to edit pages.')); |
|
425 | - else |
|
426 | - wp_die( __('You are not allowed to edit posts.')); |
|
458 | + if ( 'page' == $ptype->name ) { |
|
459 | + wp_die( __('You are not allowed to edit pages.')); |
|
460 | + } else { |
|
461 | + wp_die( __('You are not allowed to edit posts.')); |
|
462 | + } |
|
427 | 463 | } |
428 | 464 | |
429 | 465 | if ( -1 == $post_data['_status'] ) { |
@@ -452,28 +488,32 @@ discard block |
||
452 | 488 | ); |
453 | 489 | |
454 | 490 | foreach ( $reset as $field ) { |
455 | - if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) |
|
456 | - unset($post_data[$field]); |
|
491 | + if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) { |
|
492 | + unset($post_data[$field]); |
|
493 | + } |
|
457 | 494 | } |
458 | 495 | |
459 | 496 | if ( isset($post_data['post_category']) ) { |
460 | - if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) |
|
461 | - $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
462 | - else |
|
463 | - unset($post_data['post_category']); |
|
497 | + if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) { |
|
498 | + $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
499 | + } else { |
|
500 | + unset($post_data['post_category']); |
|
501 | + } |
|
464 | 502 | } |
465 | 503 | |
466 | 504 | $tax_input = array(); |
467 | 505 | if ( isset($post_data['tax_input'])) { |
468 | 506 | foreach ( $post_data['tax_input'] as $tax_name => $terms ) { |
469 | - if ( empty($terms) ) |
|
470 | - continue; |
|
507 | + if ( empty($terms) ) { |
|
508 | + continue; |
|
509 | + } |
|
471 | 510 | if ( is_taxonomy_hierarchical( $tax_name ) ) { |
472 | 511 | $tax_input[ $tax_name ] = array_map( 'absint', $terms ); |
473 | 512 | } else { |
474 | 513 | $comma = _x( ',', 'tag delimiter' ); |
475 | - if ( ',' !== $comma ) |
|
476 | - $terms = str_replace( $comma, ',', $terms ); |
|
514 | + if ( ',' !== $comma ) { |
|
515 | + $terms = str_replace( $comma, ',', $terms ); |
|
516 | + } |
|
477 | 517 | $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
478 | 518 | } |
479 | 519 | } |
@@ -518,15 +558,17 @@ discard block |
||
518 | 558 | $tax_names = get_object_taxonomies( $post ); |
519 | 559 | foreach ( $tax_names as $tax_name ) { |
520 | 560 | $taxonomy_obj = get_taxonomy($tax_name); |
521 | - if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) |
|
522 | - $new_terms = $tax_input[$tax_name]; |
|
523 | - else |
|
524 | - $new_terms = array(); |
|
561 | + if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) { |
|
562 | + $new_terms = $tax_input[$tax_name]; |
|
563 | + } else { |
|
564 | + $new_terms = array(); |
|
565 | + } |
|
525 | 566 | |
526 | - if ( $taxonomy_obj->hierarchical ) |
|
527 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
528 | - else |
|
529 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
567 | + if ( $taxonomy_obj->hierarchical ) { |
|
568 | + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
569 | + } else { |
|
570 | + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
571 | + } |
|
530 | 572 | |
531 | 573 | $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms ); |
532 | 574 | } |
@@ -559,14 +601,16 @@ discard block |
||
559 | 601 | $updated[] = wp_update_post( $post_data ); |
560 | 602 | |
561 | 603 | if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { |
562 | - if ( 'sticky' == $post_data['sticky'] ) |
|
563 | - stick_post( $post_ID ); |
|
564 | - else |
|
565 | - unstick_post( $post_ID ); |
|
604 | + if ( 'sticky' == $post_data['sticky'] ) { |
|
605 | + stick_post( $post_ID ); |
|
606 | + } else { |
|
607 | + unstick_post( $post_ID ); |
|
608 | + } |
|
566 | 609 | } |
567 | 610 | |
568 | - if ( isset( $post_data['post_format'] ) ) |
|
569 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
611 | + if ( isset( $post_data['post_format'] ) ) { |
|
612 | + set_post_format( $post_ID, $post_data['post_format'] ); |
|
613 | + } |
|
570 | 614 | } |
571 | 615 | |
572 | 616 | return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); |
@@ -583,22 +627,26 @@ discard block |
||
583 | 627 | */ |
584 | 628 | function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { |
585 | 629 | $post_title = ''; |
586 | - if ( !empty( $_REQUEST['post_title'] ) ) |
|
587 | - $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
630 | + if ( !empty( $_REQUEST['post_title'] ) ) { |
|
631 | + $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
632 | + } |
|
588 | 633 | |
589 | 634 | $post_content = ''; |
590 | - if ( !empty( $_REQUEST['content'] ) ) |
|
591 | - $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
635 | + if ( !empty( $_REQUEST['content'] ) ) { |
|
636 | + $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
637 | + } |
|
592 | 638 | |
593 | 639 | $post_excerpt = ''; |
594 | - if ( !empty( $_REQUEST['excerpt'] ) ) |
|
595 | - $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
640 | + if ( !empty( $_REQUEST['excerpt'] ) ) { |
|
641 | + $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
642 | + } |
|
596 | 643 | |
597 | 644 | if ( $create_in_db ) { |
598 | 645 | $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
599 | 646 | $post = get_post( $post_id ); |
600 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) |
|
601 | - set_post_format( $post, get_option( 'default_post_format' ) ); |
|
647 | + if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) { |
|
648 | + set_post_format( $post, get_option( 'default_post_format' ) ); |
|
649 | + } |
|
602 | 650 | } else { |
603 | 651 | $post = new stdClass; |
604 | 652 | $post->ID = 0; |
@@ -691,8 +739,9 @@ discard block |
||
691 | 739 | $args[] = $post_content; |
692 | 740 | } |
693 | 741 | |
694 | - if ( !empty ( $args ) ) |
|
695 | - return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
742 | + if ( !empty ( $args ) ) { |
|
743 | + return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
744 | + } |
|
696 | 745 | |
697 | 746 | return 0; |
698 | 747 | } |
@@ -707,16 +756,18 @@ discard block |
||
707 | 756 | * @return int|WP_Error |
708 | 757 | */ |
709 | 758 | function wp_write_post() { |
710 | - if ( isset($_POST['post_type']) ) |
|
711 | - $ptype = get_post_type_object($_POST['post_type']); |
|
712 | - else |
|
713 | - $ptype = get_post_type_object('post'); |
|
759 | + if ( isset($_POST['post_type']) ) { |
|
760 | + $ptype = get_post_type_object($_POST['post_type']); |
|
761 | + } else { |
|
762 | + $ptype = get_post_type_object('post'); |
|
763 | + } |
|
714 | 764 | |
715 | 765 | if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
716 | - if ( 'page' == $ptype->name ) |
|
717 | - return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) ); |
|
718 | - else |
|
719 | - return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) ); |
|
766 | + if ( 'page' == $ptype->name ) { |
|
767 | + return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) ); |
|
768 | + } else { |
|
769 | + return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) ); |
|
770 | + } |
|
720 | 771 | } |
721 | 772 | |
722 | 773 | $_POST['post_mime_type'] = ''; |
@@ -725,8 +776,9 @@ discard block |
||
725 | 776 | unset( $_POST['filter'] ); |
726 | 777 | |
727 | 778 | // Edit don't write if we have a post id. |
728 | - if ( isset( $_POST['post_ID'] ) ) |
|
729 | - return edit_post(); |
|
779 | + if ( isset( $_POST['post_ID'] ) ) { |
|
780 | + return edit_post(); |
|
781 | + } |
|
730 | 782 | |
731 | 783 | if ( isset($_POST['visibility']) ) { |
732 | 784 | switch ( $_POST['visibility'] ) { |
@@ -745,16 +797,19 @@ discard block |
||
745 | 797 | } |
746 | 798 | |
747 | 799 | $translated = _wp_translate_postdata( false ); |
748 | - if ( is_wp_error($translated) ) |
|
749 | - return $translated; |
|
800 | + if ( is_wp_error($translated) ) { |
|
801 | + return $translated; |
|
802 | + } |
|
750 | 803 | |
751 | 804 | // Create the post. |
752 | 805 | $post_ID = wp_insert_post( $_POST ); |
753 | - if ( is_wp_error( $post_ID ) ) |
|
754 | - return $post_ID; |
|
806 | + if ( is_wp_error( $post_ID ) ) { |
|
807 | + return $post_ID; |
|
808 | + } |
|
755 | 809 | |
756 | - if ( empty($post_ID) ) |
|
757 | - return 0; |
|
810 | + if ( empty($post_ID) ) { |
|
811 | + return 0; |
|
812 | + } |
|
758 | 813 | |
759 | 814 | add_meta( $post_ID ); |
760 | 815 | |
@@ -777,11 +832,12 @@ discard block |
||
777 | 832 | */ |
778 | 833 | function write_post() { |
779 | 834 | $result = wp_write_post(); |
780 | - if ( is_wp_error( $result ) ) |
|
781 | - wp_die( $result->get_error_message() ); |
|
782 | - else |
|
783 | - return $result; |
|
784 | -} |
|
835 | + if ( is_wp_error( $result ) ) { |
|
836 | + wp_die( $result->get_error_message() ); |
|
837 | + } else { |
|
838 | + return $result; |
|
839 | + } |
|
840 | + } |
|
785 | 841 | |
786 | 842 | // |
787 | 843 | // Post Meta |
@@ -801,22 +857,27 @@ discard block |
||
801 | 857 | $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; |
802 | 858 | $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; |
803 | 859 | $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; |
804 | - if ( is_string( $metavalue ) ) |
|
805 | - $metavalue = trim( $metavalue ); |
|
860 | + if ( is_string( $metavalue ) ) { |
|
861 | + $metavalue = trim( $metavalue ); |
|
862 | + } |
|
806 | 863 | |
807 | 864 | if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) { |
808 | 865 | /* |
809 | 866 | * We have a key/value pair. If both the select and the input |
810 | 867 | * for the key have data, the input takes precedence. |
811 | 868 | */ |
812 | - if ( '#NONE#' != $metakeyselect ) |
|
813 | - $metakey = $metakeyselect; |
|
869 | + if ( '#NONE#' != $metakeyselect ) { |
|
870 | + $metakey = $metakeyselect; |
|
871 | + } |
|
814 | 872 | |
815 | - if ( $metakeyinput ) |
|
816 | - $metakey = $metakeyinput; // default |
|
873 | + if ( $metakeyinput ) { |
|
874 | + $metakey = $metakeyinput; |
|
875 | + } |
|
876 | + // default |
|
817 | 877 | |
818 | - if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) |
|
819 | - return false; |
|
878 | + if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { |
|
879 | + return false; |
|
880 | + } |
|
820 | 881 | |
821 | 882 | $metakey = wp_slash( $metakey ); |
822 | 883 | |
@@ -924,12 +985,14 @@ discard block |
||
924 | 985 | $content = $post['post_content']; |
925 | 986 | |
926 | 987 | // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. |
927 | - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) |
|
928 | - return; |
|
988 | + if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) { |
|
989 | + return; |
|
990 | + } |
|
929 | 991 | |
930 | 992 | // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) |
931 | - if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) |
|
932 | - return; |
|
993 | + if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) { |
|
994 | + return; |
|
995 | + } |
|
933 | 996 | |
934 | 997 | $site_url = get_bloginfo('url'); |
935 | 998 | $site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s) |
@@ -938,15 +1001,17 @@ discard block |
||
938 | 1001 | foreach ( $link_matches[1] as $key => $value ) { |
939 | 1002 | if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') |
940 | 1003 | || !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) |
941 | - || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) |
|
942 | - continue; |
|
1004 | + || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) { |
|
1005 | + continue; |
|
1006 | + } |
|
943 | 1007 | |
944 | 1008 | $quote = $url_match[1]; // the quote (single or double) |
945 | 1009 | $url_id = (int) $url_match[2]; |
946 | 1010 | $rel_id = (int) $rel_match[1]; |
947 | 1011 | |
948 | - if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) |
|
949 | - continue; |
|
1012 | + if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) { |
|
1013 | + continue; |
|
1014 | + } |
|
950 | 1015 | |
951 | 1016 | $link = $link_matches[0][$key]; |
952 | 1017 | $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); |
@@ -986,16 +1051,18 @@ discard block |
||
986 | 1051 | * @return array |
987 | 1052 | */ |
988 | 1053 | function wp_edit_posts_query( $q = false ) { |
989 | - if ( false === $q ) |
|
990 | - $q = $_GET; |
|
1054 | + if ( false === $q ) { |
|
1055 | + $q = $_GET; |
|
1056 | + } |
|
991 | 1057 | $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
992 | 1058 | $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
993 | 1059 | $post_stati = get_post_stati(); |
994 | 1060 | |
995 | - if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) |
|
996 | - $post_type = $q['post_type']; |
|
997 | - else |
|
998 | - $post_type = 'post'; |
|
1061 | + if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) { |
|
1062 | + $post_type = $q['post_type']; |
|
1063 | + } else { |
|
1064 | + $post_type = 'post'; |
|
1065 | + } |
|
999 | 1066 | |
1000 | 1067 | $avail_post_stati = get_available_post_statuses($post_type); |
1001 | 1068 | |
@@ -1018,8 +1085,9 @@ discard block |
||
1018 | 1085 | |
1019 | 1086 | $per_page = "edit_{$post_type}_per_page"; |
1020 | 1087 | $posts_per_page = (int) get_user_option( $per_page ); |
1021 | - if ( empty( $posts_per_page ) || $posts_per_page < 1 ) |
|
1022 | - $posts_per_page = 20; |
|
1088 | + if ( empty( $posts_per_page ) || $posts_per_page < 1 ) { |
|
1089 | + $posts_per_page = 20; |
|
1090 | + } |
|
1023 | 1091 | |
1024 | 1092 | /** |
1025 | 1093 | * Filter the number of items per page to show for a specific 'per_page' type. |
@@ -1057,8 +1125,9 @@ discard block |
||
1057 | 1125 | $query['fields'] = 'id=>parent'; |
1058 | 1126 | } |
1059 | 1127 | |
1060 | - if ( ! empty( $q['show_sticky'] ) ) |
|
1061 | - $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
1128 | + if ( ! empty( $q['show_sticky'] ) ) { |
|
1129 | + $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
1130 | + } |
|
1062 | 1131 | |
1063 | 1132 | wp( $query ); |
1064 | 1133 | |
@@ -1206,8 +1275,9 @@ discard block |
||
1206 | 1275 | */ |
1207 | 1276 | function get_sample_permalink($id, $title = null, $name = null) { |
1208 | 1277 | $post = get_post( $id ); |
1209 | - if ( ! $post ) |
|
1210 | - return array( '', '' ); |
|
1278 | + if ( ! $post ) { |
|
1279 | + return array( '', '' ); |
|
1280 | + } |
|
1211 | 1281 | |
1212 | 1282 | $ptype = get_post_type_object($post->post_type); |
1213 | 1283 | |
@@ -1223,8 +1293,9 @@ discard block |
||
1223 | 1293 | |
1224 | 1294 | // If the user wants to set a new name -- override the current one |
1225 | 1295 | // Note: if empty name is supplied -- use the title instead, see #6072 |
1226 | - if ( !is_null($name) ) |
|
1227 | - $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
|
1296 | + if ( !is_null($name) ) { |
|
1297 | + $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
|
1298 | + } |
|
1228 | 1299 | |
1229 | 1300 | $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); |
1230 | 1301 | |
@@ -1246,8 +1317,9 @@ discard block |
||
1246 | 1317 | |
1247 | 1318 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
1248 | 1319 | $uri = apply_filters( 'editable_slug', $uri, $post ); |
1249 | - if ( !empty($uri) ) |
|
1250 | - $uri .= '/'; |
|
1320 | + if ( !empty($uri) ) { |
|
1321 | + $uri .= '/'; |
|
1322 | + } |
|
1251 | 1323 | $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); |
1252 | 1324 | } |
1253 | 1325 | |
@@ -1284,8 +1356,9 @@ discard block |
||
1284 | 1356 | */ |
1285 | 1357 | function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
1286 | 1358 | $post = get_post( $id ); |
1287 | - if ( ! $post ) |
|
1288 | - return ''; |
|
1359 | + if ( ! $post ) { |
|
1360 | + return ''; |
|
1361 | + } |
|
1289 | 1362 | |
1290 | 1363 | list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
1291 | 1364 | |
@@ -1445,11 +1518,13 @@ discard block |
||
1445 | 1518 | * @return integer False: not locked or locked by current user. Int: user ID of user with lock. |
1446 | 1519 | */ |
1447 | 1520 | function wp_check_post_lock( $post_id ) { |
1448 | - if ( !$post = get_post( $post_id ) ) |
|
1449 | - return false; |
|
1521 | + if ( !$post = get_post( $post_id ) ) { |
|
1522 | + return false; |
|
1523 | + } |
|
1450 | 1524 | |
1451 | - if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) |
|
1452 | - return false; |
|
1525 | + if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) { |
|
1526 | + return false; |
|
1527 | + } |
|
1453 | 1528 | |
1454 | 1529 | $lock = explode( ':', $lock ); |
1455 | 1530 | $time = $lock[0]; |
@@ -1458,8 +1533,9 @@ discard block |
||
1458 | 1533 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
1459 | 1534 | $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); |
1460 | 1535 | |
1461 | - if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) |
|
1462 | - return $user; |
|
1536 | + if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) { |
|
1537 | + return $user; |
|
1538 | + } |
|
1463 | 1539 | return false; |
1464 | 1540 | } |
1465 | 1541 | |
@@ -1473,10 +1549,12 @@ discard block |
||
1473 | 1549 | * an array of the lock time and the user ID. |
1474 | 1550 | */ |
1475 | 1551 | function wp_set_post_lock( $post_id ) { |
1476 | - if ( !$post = get_post( $post_id ) ) |
|
1477 | - return false; |
|
1478 | - if ( 0 == ($user_id = get_current_user_id()) ) |
|
1479 | - return false; |
|
1552 | + if ( !$post = get_post( $post_id ) ) { |
|
1553 | + return false; |
|
1554 | + } |
|
1555 | + if ( 0 == ($user_id = get_current_user_id()) ) { |
|
1556 | + return false; |
|
1557 | + } |
|
1480 | 1558 | |
1481 | 1559 | $now = time(); |
1482 | 1560 | $lock = "$now:$user_id"; |
@@ -1492,12 +1570,14 @@ discard block |
||
1492 | 1570 | * @return none |
1493 | 1571 | */ |
1494 | 1572 | function _admin_notice_post_locked() { |
1495 | - if ( ! $post = get_post() ) |
|
1496 | - return; |
|
1573 | + if ( ! $post = get_post() ) { |
|
1574 | + return; |
|
1575 | + } |
|
1497 | 1576 | |
1498 | 1577 | $user = null; |
1499 | - if ( $user_id = wp_check_post_lock( $post->ID ) ) |
|
1500 | - $user = get_userdata( $user_id ); |
|
1578 | + if ( $user_id = wp_check_post_lock( $post->ID ) ) { |
|
1579 | + $user = get_userdata( $user_id ); |
|
1580 | + } |
|
1501 | 1581 | |
1502 | 1582 | if ( $user ) { |
1503 | 1583 | |
@@ -1511,8 +1591,9 @@ discard block |
||
1511 | 1591 | * @param bool $display Whether to display the dialog. Default true. |
1512 | 1592 | * @param WP_User|bool $user WP_User object on success, false otherwise. |
1513 | 1593 | */ |
1514 | - if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) |
|
1515 | - return; |
|
1594 | + if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) { |
|
1595 | + return; |
|
1596 | + } |
|
1516 | 1597 | |
1517 | 1598 | $locked = true; |
1518 | 1599 | } else { |
@@ -1526,8 +1607,9 @@ discard block |
||
1526 | 1607 | } else { |
1527 | 1608 | $sendback = admin_url( 'edit.php' ); |
1528 | 1609 | |
1529 | - if ( 'post' != $post->post_type ) |
|
1530 | - $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
1610 | + if ( 'post' != $post->post_type ) { |
|
1611 | + $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
1612 | + } |
|
1531 | 1613 | |
1532 | 1614 | $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; |
1533 | 1615 | } |
@@ -1574,8 +1656,9 @@ discard block |
||
1574 | 1656 | <p class="currently-editing wp-tab-first" tabindex="0"> |
1575 | 1657 | <?php |
1576 | 1658 | _e( 'This content is currently locked.' ); |
1577 | - if ( $override ) |
|
1578 | - printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
1659 | + if ( $override ) { |
|
1660 | + printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
1661 | + } |
|
1579 | 1662 | ?> |
1580 | 1663 | </p> |
1581 | 1664 | <?php |
@@ -1655,8 +1738,9 @@ discard block |
||
1655 | 1738 | } |
1656 | 1739 | |
1657 | 1740 | $post_data = _wp_translate_postdata( true, $post_data ); |
1658 | - if ( is_wp_error( $post_data ) ) |
|
1659 | - return $post_data; |
|
1741 | + if ( is_wp_error( $post_data ) ) { |
|
1742 | + return $post_data; |
|
1743 | + } |
|
1660 | 1744 | |
1661 | 1745 | $post_author = get_current_user_id(); |
1662 | 1746 | |
@@ -1728,14 +1812,16 @@ discard block |
||
1728 | 1812 | } else { |
1729 | 1813 | $is_autosave = true; |
1730 | 1814 | |
1731 | - if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) |
|
1732 | - $_POST['post_status'] = 'draft'; |
|
1815 | + if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) { |
|
1816 | + $_POST['post_status'] = 'draft'; |
|
1817 | + } |
|
1733 | 1818 | |
1734 | 1819 | $saved_post_id = wp_create_post_autosave( $post->ID ); |
1735 | 1820 | } |
1736 | 1821 | |
1737 | - if ( is_wp_error( $saved_post_id ) ) |
|
1738 | - wp_die( $saved_post_id->get_error_message() ); |
|
1822 | + if ( is_wp_error( $saved_post_id ) ) { |
|
1823 | + wp_die( $saved_post_id->get_error_message() ); |
|
1824 | + } |
|
1739 | 1825 | |
1740 | 1826 | $query_args = array(); |
1741 | 1827 | |
@@ -1743,8 +1829,9 @@ discard block |
||
1743 | 1829 | $query_args['preview_id'] = $post->ID; |
1744 | 1830 | $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); |
1745 | 1831 | |
1746 | - if ( isset( $_POST['post_format'] ) ) |
|
1747 | - $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
1832 | + if ( isset( $_POST['post_format'] ) ) { |
|
1833 | + $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
1834 | + } |
|
1748 | 1835 | } |
1749 | 1836 | |
1750 | 1837 | return get_preview_post_link( $post, $query_args ); |
@@ -1763,8 +1850,9 @@ discard block |
||
1763 | 1850 | */ |
1764 | 1851 | function wp_autosave( $post_data ) { |
1765 | 1852 | // Back-compat |
1766 | - if ( ! defined( 'DOING_AUTOSAVE' ) ) |
|
1767 | - define( 'DOING_AUTOSAVE', true ); |
|
1853 | + if ( ! defined( 'DOING_AUTOSAVE' ) ) { |
|
1854 | + define( 'DOING_AUTOSAVE', true ); |
|
1855 | + } |
|
1768 | 1856 | |
1769 | 1857 | $post_id = (int) $post_data['post_id']; |
1770 | 1858 | $post_data['ID'] = $post_data['post_ID'] = $post_id; |
@@ -1779,11 +1867,13 @@ discard block |
||
1779 | 1867 | return new WP_Error( 'edit_posts', __( 'You are not allowed to edit this item.' ) ); |
1780 | 1868 | } |
1781 | 1869 | |
1782 | - if ( 'auto-draft' == $post->post_status ) |
|
1783 | - $post_data['post_status'] = 'draft'; |
|
1870 | + if ( 'auto-draft' == $post->post_status ) { |
|
1871 | + $post_data['post_status'] = 'draft'; |
|
1872 | + } |
|
1784 | 1873 | |
1785 | - if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) |
|
1786 | - $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
1874 | + if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) { |
|
1875 | + $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
1876 | + } |
|
1787 | 1877 | |
1788 | 1878 | if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { |
1789 | 1879 | // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Direct Filesystem. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Filesystem |
|
7 | - */ |
|
3 | + * WordPress Direct Filesystem. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Filesystem |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * WordPress Filesystem Class for direct PHP file and folder manipulation. |
@@ -55,25 +55,25 @@ discard block |
||
55 | 55 | * Default false. |
56 | 56 | * @return bool False upon failure, true otherwise. |
57 | 57 | */ |
58 | - public function put_contents( $file, $contents, $mode = false ) { |
|
59 | - $fp = @fopen( $file, 'wb' ); |
|
60 | - if ( ! $fp ) |
|
58 | + public function put_contents($file, $contents, $mode = false) { |
|
59 | + $fp = @fopen($file, 'wb'); |
|
60 | + if ( ! $fp) |
|
61 | 61 | return false; |
62 | 62 | |
63 | 63 | mbstring_binary_safe_encoding(); |
64 | 64 | |
65 | - $data_length = strlen( $contents ); |
|
65 | + $data_length = strlen($contents); |
|
66 | 66 | |
67 | - $bytes_written = fwrite( $fp, $contents ); |
|
67 | + $bytes_written = fwrite($fp, $contents); |
|
68 | 68 | |
69 | 69 | reset_mbstring_encoding(); |
70 | 70 | |
71 | - fclose( $fp ); |
|
71 | + fclose($fp); |
|
72 | 72 | |
73 | - if ( $data_length !== $bytes_written ) |
|
73 | + if ($data_length !== $bytes_written) |
|
74 | 74 | return false; |
75 | 75 | |
76 | - $this->chmod( $file, $mode ); |
|
76 | + $this->chmod($file, $mode); |
|
77 | 77 | |
78 | 78 | return true; |
79 | 79 | } |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | * @return bool Returns true on success or false on failure. |
107 | 107 | */ |
108 | 108 | public function chgrp($file, $group, $recursive = false) { |
109 | - if ( ! $this->exists($file) ) |
|
109 | + if ( ! $this->exists($file)) |
|
110 | 110 | return false; |
111 | - if ( ! $recursive ) |
|
111 | + if ( ! $recursive) |
|
112 | 112 | return @chgrp($file, $group); |
113 | - if ( ! $this->is_dir($file) ) |
|
113 | + if ( ! $this->is_dir($file)) |
|
114 | 114 | return @chgrp($file, $group); |
115 | 115 | // Is a directory, and we want recursive |
116 | 116 | $file = trailingslashit($file); |
117 | 117 | $filelist = $this->dirlist($file); |
118 | 118 | foreach ($filelist as $filename) |
119 | - $this->chgrp($file . $filename, $group, $recursive); |
|
119 | + $this->chgrp($file.$filename, $group, $recursive); |
|
120 | 120 | |
121 | 121 | return true; |
122 | 122 | } |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | * @return bool Returns true on success or false on failure. |
132 | 132 | */ |
133 | 133 | public function chmod($file, $mode = false, $recursive = false) { |
134 | - if ( ! $mode ) { |
|
135 | - if ( $this->is_file($file) ) |
|
134 | + if ( ! $mode) { |
|
135 | + if ($this->is_file($file)) |
|
136 | 136 | $mode = FS_CHMOD_FILE; |
137 | - elseif ( $this->is_dir($file) ) |
|
137 | + elseif ($this->is_dir($file)) |
|
138 | 138 | $mode = FS_CHMOD_DIR; |
139 | 139 | else |
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | - if ( ! $recursive || ! $this->is_dir($file) ) |
|
143 | + if ( ! $recursive || ! $this->is_dir($file)) |
|
144 | 144 | return @chmod($file, $mode); |
145 | 145 | // Is a directory, and we want recursive |
146 | 146 | $file = trailingslashit($file); |
147 | 147 | $filelist = $this->dirlist($file); |
148 | - foreach ( (array)$filelist as $filename => $filemeta) |
|
149 | - $this->chmod($file . $filename, $mode, $recursive); |
|
148 | + foreach ((array) $filelist as $filename => $filemeta) |
|
149 | + $this->chmod($file.$filename, $mode, $recursive); |
|
150 | 150 | |
151 | 151 | return true; |
152 | 152 | } |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | * @return bool Returns true on success or false on failure. |
162 | 162 | */ |
163 | 163 | public function chown($file, $owner, $recursive = false) { |
164 | - if ( ! $this->exists($file) ) |
|
164 | + if ( ! $this->exists($file)) |
|
165 | 165 | return false; |
166 | - if ( ! $recursive ) |
|
166 | + if ( ! $recursive) |
|
167 | 167 | return @chown($file, $owner); |
168 | - if ( ! $this->is_dir($file) ) |
|
168 | + if ( ! $this->is_dir($file)) |
|
169 | 169 | return @chown($file, $owner); |
170 | 170 | // Is a directory, and we want recursive |
171 | 171 | $filelist = $this->dirlist($file); |
172 | 172 | foreach ($filelist as $filename) { |
173 | - $this->chown($file . '/' . $filename, $owner, $recursive); |
|
173 | + $this->chown($file.'/'.$filename, $owner, $recursive); |
|
174 | 174 | } |
175 | 175 | return true; |
176 | 176 | } |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function owner($file) { |
185 | 185 | $owneruid = @fileowner($file); |
186 | - if ( ! $owneruid ) |
|
186 | + if ( ! $owneruid) |
|
187 | 187 | return false; |
188 | - if ( ! function_exists('posix_getpwuid') ) |
|
188 | + if ( ! function_exists('posix_getpwuid')) |
|
189 | 189 | return $owneruid; |
190 | 190 | $ownerarray = posix_getpwuid($owneruid); |
191 | 191 | return $ownerarray['name']; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return string Mode of the file (last 3 digits). |
201 | 201 | */ |
202 | 202 | public function getchmod($file) { |
203 | - return substr( decoct( @fileperms( $file ) ), -3 ); |
|
203 | + return substr(decoct(@fileperms($file)), -3); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function group($file) { |
211 | 211 | $gid = @filegroup($file); |
212 | - if ( ! $gid ) |
|
212 | + if ( ! $gid) |
|
213 | 213 | return false; |
214 | - if ( ! function_exists('posix_getgrgid') ) |
|
214 | + if ( ! function_exists('posix_getgrgid')) |
|
215 | 215 | return $gid; |
216 | 216 | $grouparray = posix_getgrgid($gid); |
217 | 217 | return $grouparray['name']; |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @return bool |
226 | 226 | */ |
227 | 227 | public function copy($source, $destination, $overwrite = false, $mode = false) { |
228 | - if ( ! $overwrite && $this->exists($destination) ) |
|
228 | + if ( ! $overwrite && $this->exists($destination)) |
|
229 | 229 | return false; |
230 | 230 | |
231 | 231 | $rtval = copy($source, $destination); |
232 | - if ( $mode ) |
|
232 | + if ($mode) |
|
233 | 233 | $this->chmod($destination, $mode); |
234 | 234 | return $rtval; |
235 | 235 | } |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | * @return bool |
242 | 242 | */ |
243 | 243 | public function move($source, $destination, $overwrite = false) { |
244 | - if ( ! $overwrite && $this->exists($destination) ) |
|
244 | + if ( ! $overwrite && $this->exists($destination)) |
|
245 | 245 | return false; |
246 | 246 | |
247 | 247 | // Try using rename first. if that fails (for example, source is read only) try copy. |
248 | - if ( @rename($source, $destination) ) |
|
248 | + if (@rename($source, $destination)) |
|
249 | 249 | return true; |
250 | 250 | |
251 | - if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) { |
|
251 | + if ($this->copy($source, $destination, $overwrite) && $this->exists($destination)) { |
|
252 | 252 | $this->delete($source); |
253 | 253 | return true; |
254 | 254 | } else { |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | * @return bool |
264 | 264 | */ |
265 | 265 | public function delete($file, $recursive = false, $type = false) { |
266 | - if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. |
|
266 | + if (empty($file)) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. |
|
267 | 267 | return false; |
268 | - $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise |
|
268 | + $file = str_replace('\\', '/', $file); // for win32, occasional problems deleting files otherwise |
|
269 | 269 | |
270 | - if ( 'f' == $type || $this->is_file($file) ) |
|
270 | + if ('f' == $type || $this->is_file($file)) |
|
271 | 271 | return @unlink($file); |
272 | - if ( ! $recursive && $this->is_dir($file) ) |
|
272 | + if ( ! $recursive && $this->is_dir($file)) |
|
273 | 273 | return @rmdir($file); |
274 | 274 | |
275 | 275 | // At this point it's a folder, and we're in recursive mode |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | $filelist = $this->dirlist($file, true); |
278 | 278 | |
279 | 279 | $retval = true; |
280 | - if ( is_array( $filelist ) ) { |
|
281 | - foreach ( $filelist as $filename => $fileinfo ) { |
|
282 | - if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) |
|
280 | + if (is_array($filelist)) { |
|
281 | + foreach ($filelist as $filename => $fileinfo) { |
|
282 | + if ( ! $this->delete($file.$filename, $recursive, $fileinfo['type'])) |
|
283 | 283 | $retval = false; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - if ( file_exists($file) && ! @rmdir($file) ) |
|
287 | + if (file_exists($file) && ! @rmdir($file)) |
|
288 | 288 | $retval = false; |
289 | 289 | |
290 | 290 | return $retval; |
@@ -375,18 +375,18 @@ discard block |
||
375 | 375 | public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { |
376 | 376 | // Safe mode fails with a trailing slash under certain PHP versions. |
377 | 377 | $path = untrailingslashit($path); |
378 | - if ( empty($path) ) |
|
378 | + if (empty($path)) |
|
379 | 379 | return false; |
380 | 380 | |
381 | - if ( ! $chmod ) |
|
381 | + if ( ! $chmod) |
|
382 | 382 | $chmod = FS_CHMOD_DIR; |
383 | 383 | |
384 | - if ( ! @mkdir($path) ) |
|
384 | + if ( ! @mkdir($path)) |
|
385 | 385 | return false; |
386 | 386 | $this->chmod($path, $chmod); |
387 | - if ( $chown ) |
|
387 | + if ($chown) |
|
388 | 388 | $this->chown($path, $chown); |
389 | - if ( $chgrp ) |
|
389 | + if ($chgrp) |
|
390 | 390 | $this->chgrp($path, $chgrp); |
391 | 391 | return true; |
392 | 392 | } |
@@ -407,54 +407,54 @@ discard block |
||
407 | 407 | * @return bool|array |
408 | 408 | */ |
409 | 409 | public function dirlist($path, $include_hidden = true, $recursive = false) { |
410 | - if ( $this->is_file($path) ) { |
|
410 | + if ($this->is_file($path)) { |
|
411 | 411 | $limit_file = basename($path); |
412 | 412 | $path = dirname($path); |
413 | 413 | } else { |
414 | 414 | $limit_file = false; |
415 | 415 | } |
416 | 416 | |
417 | - if ( ! $this->is_dir($path) ) |
|
417 | + if ( ! $this->is_dir($path)) |
|
418 | 418 | return false; |
419 | 419 | |
420 | 420 | $dir = @dir($path); |
421 | - if ( ! $dir ) |
|
421 | + if ( ! $dir) |
|
422 | 422 | return false; |
423 | 423 | |
424 | 424 | $ret = array(); |
425 | 425 | |
426 | - while (false !== ($entry = $dir->read()) ) { |
|
426 | + while (false !== ($entry = $dir->read())) { |
|
427 | 427 | $struc = array(); |
428 | 428 | $struc['name'] = $entry; |
429 | 429 | |
430 | - if ( '.' == $struc['name'] || '..' == $struc['name'] ) |
|
430 | + if ('.' == $struc['name'] || '..' == $struc['name']) |
|
431 | 431 | continue; |
432 | 432 | |
433 | - if ( ! $include_hidden && '.' == $struc['name'][0] ) |
|
433 | + if ( ! $include_hidden && '.' == $struc['name'][0]) |
|
434 | 434 | continue; |
435 | 435 | |
436 | - if ( $limit_file && $struc['name'] != $limit_file) |
|
436 | + if ($limit_file && $struc['name'] != $limit_file) |
|
437 | 437 | continue; |
438 | 438 | |
439 | 439 | $struc['perms'] = $this->gethchmod($path.'/'.$entry); |
440 | 440 | $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); |
441 | - $struc['number'] = false; |
|
441 | + $struc['number'] = false; |
|
442 | 442 | $struc['owner'] = $this->owner($path.'/'.$entry); |
443 | 443 | $struc['group'] = $this->group($path.'/'.$entry); |
444 | 444 | $struc['size'] = $this->size($path.'/'.$entry); |
445 | - $struc['lastmodunix']= $this->mtime($path.'/'.$entry); |
|
446 | - $struc['lastmod'] = date('M j',$struc['lastmodunix']); |
|
447 | - $struc['time'] = date('h:i:s',$struc['lastmodunix']); |
|
448 | - $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; |
|
449 | - |
|
450 | - if ( 'd' == $struc['type'] ) { |
|
451 | - if ( $recursive ) |
|
452 | - $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
445 | + $struc['lastmodunix'] = $this->mtime($path.'/'.$entry); |
|
446 | + $struc['lastmod'] = date('M j', $struc['lastmodunix']); |
|
447 | + $struc['time'] = date('h:i:s', $struc['lastmodunix']); |
|
448 | + $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; |
|
449 | + |
|
450 | + if ('d' == $struc['type']) { |
|
451 | + if ($recursive) |
|
452 | + $struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive); |
|
453 | 453 | else |
454 | 454 | $struc['files'] = array(); |
455 | 455 | } |
456 | 456 | |
457 | - $ret[ $struc['name'] ] = $struc; |
|
457 | + $ret[$struc['name']] = $struc; |
|
458 | 458 | } |
459 | 459 | $dir->close(); |
460 | 460 | unset($dir); |
@@ -57,8 +57,9 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function put_contents( $file, $contents, $mode = false ) { |
59 | 59 | $fp = @fopen( $file, 'wb' ); |
60 | - if ( ! $fp ) |
|
61 | - return false; |
|
60 | + if ( ! $fp ) { |
|
61 | + return false; |
|
62 | + } |
|
62 | 63 | |
63 | 64 | mbstring_binary_safe_encoding(); |
64 | 65 | |
@@ -70,8 +71,9 @@ discard block |
||
70 | 71 | |
71 | 72 | fclose( $fp ); |
72 | 73 | |
73 | - if ( $data_length !== $bytes_written ) |
|
74 | - return false; |
|
74 | + if ( $data_length !== $bytes_written ) { |
|
75 | + return false; |
|
76 | + } |
|
75 | 77 | |
76 | 78 | $this->chmod( $file, $mode ); |
77 | 79 | |
@@ -106,17 +108,21 @@ discard block |
||
106 | 108 | * @return bool Returns true on success or false on failure. |
107 | 109 | */ |
108 | 110 | public function chgrp($file, $group, $recursive = false) { |
109 | - if ( ! $this->exists($file) ) |
|
110 | - return false; |
|
111 | - if ( ! $recursive ) |
|
112 | - return @chgrp($file, $group); |
|
113 | - if ( ! $this->is_dir($file) ) |
|
114 | - return @chgrp($file, $group); |
|
111 | + if ( ! $this->exists($file) ) { |
|
112 | + return false; |
|
113 | + } |
|
114 | + if ( ! $recursive ) { |
|
115 | + return @chgrp($file, $group); |
|
116 | + } |
|
117 | + if ( ! $this->is_dir($file) ) { |
|
118 | + return @chgrp($file, $group); |
|
119 | + } |
|
115 | 120 | // Is a directory, and we want recursive |
116 | 121 | $file = trailingslashit($file); |
117 | 122 | $filelist = $this->dirlist($file); |
118 | - foreach ($filelist as $filename) |
|
119 | - $this->chgrp($file . $filename, $group, $recursive); |
|
123 | + foreach ($filelist as $filename) { |
|
124 | + $this->chgrp($file . $filename, $group, $recursive); |
|
125 | + } |
|
120 | 126 | |
121 | 127 | return true; |
122 | 128 | } |
@@ -132,21 +138,24 @@ discard block |
||
132 | 138 | */ |
133 | 139 | public function chmod($file, $mode = false, $recursive = false) { |
134 | 140 | if ( ! $mode ) { |
135 | - if ( $this->is_file($file) ) |
|
136 | - $mode = FS_CHMOD_FILE; |
|
137 | - elseif ( $this->is_dir($file) ) |
|
138 | - $mode = FS_CHMOD_DIR; |
|
139 | - else |
|
140 | - return false; |
|
141 | + if ( $this->is_file($file) ) { |
|
142 | + $mode = FS_CHMOD_FILE; |
|
143 | + } elseif ( $this->is_dir($file) ) { |
|
144 | + $mode = FS_CHMOD_DIR; |
|
145 | + } else { |
|
146 | + return false; |
|
147 | + } |
|
141 | 148 | } |
142 | 149 | |
143 | - if ( ! $recursive || ! $this->is_dir($file) ) |
|
144 | - return @chmod($file, $mode); |
|
150 | + if ( ! $recursive || ! $this->is_dir($file) ) { |
|
151 | + return @chmod($file, $mode); |
|
152 | + } |
|
145 | 153 | // Is a directory, and we want recursive |
146 | 154 | $file = trailingslashit($file); |
147 | 155 | $filelist = $this->dirlist($file); |
148 | - foreach ( (array)$filelist as $filename => $filemeta) |
|
149 | - $this->chmod($file . $filename, $mode, $recursive); |
|
156 | + foreach ( (array)$filelist as $filename => $filemeta) { |
|
157 | + $this->chmod($file . $filename, $mode, $recursive); |
|
158 | + } |
|
150 | 159 | |
151 | 160 | return true; |
152 | 161 | } |
@@ -161,12 +170,15 @@ discard block |
||
161 | 170 | * @return bool Returns true on success or false on failure. |
162 | 171 | */ |
163 | 172 | public function chown($file, $owner, $recursive = false) { |
164 | - if ( ! $this->exists($file) ) |
|
165 | - return false; |
|
166 | - if ( ! $recursive ) |
|
167 | - return @chown($file, $owner); |
|
168 | - if ( ! $this->is_dir($file) ) |
|
169 | - return @chown($file, $owner); |
|
173 | + if ( ! $this->exists($file) ) { |
|
174 | + return false; |
|
175 | + } |
|
176 | + if ( ! $recursive ) { |
|
177 | + return @chown($file, $owner); |
|
178 | + } |
|
179 | + if ( ! $this->is_dir($file) ) { |
|
180 | + return @chown($file, $owner); |
|
181 | + } |
|
170 | 182 | // Is a directory, and we want recursive |
171 | 183 | $filelist = $this->dirlist($file); |
172 | 184 | foreach ($filelist as $filename) { |
@@ -183,10 +195,12 @@ discard block |
||
183 | 195 | */ |
184 | 196 | public function owner($file) { |
185 | 197 | $owneruid = @fileowner($file); |
186 | - if ( ! $owneruid ) |
|
187 | - return false; |
|
188 | - if ( ! function_exists('posix_getpwuid') ) |
|
189 | - return $owneruid; |
|
198 | + if ( ! $owneruid ) { |
|
199 | + return false; |
|
200 | + } |
|
201 | + if ( ! function_exists('posix_getpwuid') ) { |
|
202 | + return $owneruid; |
|
203 | + } |
|
190 | 204 | $ownerarray = posix_getpwuid($owneruid); |
191 | 205 | return $ownerarray['name']; |
192 | 206 | } |
@@ -209,10 +223,12 @@ discard block |
||
209 | 223 | */ |
210 | 224 | public function group($file) { |
211 | 225 | $gid = @filegroup($file); |
212 | - if ( ! $gid ) |
|
213 | - return false; |
|
214 | - if ( ! function_exists('posix_getgrgid') ) |
|
215 | - return $gid; |
|
226 | + if ( ! $gid ) { |
|
227 | + return false; |
|
228 | + } |
|
229 | + if ( ! function_exists('posix_getgrgid') ) { |
|
230 | + return $gid; |
|
231 | + } |
|
216 | 232 | $grouparray = posix_getgrgid($gid); |
217 | 233 | return $grouparray['name']; |
218 | 234 | } |
@@ -225,12 +241,14 @@ discard block |
||
225 | 241 | * @return bool |
226 | 242 | */ |
227 | 243 | public function copy($source, $destination, $overwrite = false, $mode = false) { |
228 | - if ( ! $overwrite && $this->exists($destination) ) |
|
229 | - return false; |
|
244 | + if ( ! $overwrite && $this->exists($destination) ) { |
|
245 | + return false; |
|
246 | + } |
|
230 | 247 | |
231 | 248 | $rtval = copy($source, $destination); |
232 | - if ( $mode ) |
|
233 | - $this->chmod($destination, $mode); |
|
249 | + if ( $mode ) { |
|
250 | + $this->chmod($destination, $mode); |
|
251 | + } |
|
234 | 252 | return $rtval; |
235 | 253 | } |
236 | 254 | |
@@ -241,12 +259,14 @@ discard block |
||
241 | 259 | * @return bool |
242 | 260 | */ |
243 | 261 | public function move($source, $destination, $overwrite = false) { |
244 | - if ( ! $overwrite && $this->exists($destination) ) |
|
245 | - return false; |
|
262 | + if ( ! $overwrite && $this->exists($destination) ) { |
|
263 | + return false; |
|
264 | + } |
|
246 | 265 | |
247 | 266 | // Try using rename first. if that fails (for example, source is read only) try copy. |
248 | - if ( @rename($source, $destination) ) |
|
249 | - return true; |
|
267 | + if ( @rename($source, $destination) ) { |
|
268 | + return true; |
|
269 | + } |
|
250 | 270 | |
251 | 271 | if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) { |
252 | 272 | $this->delete($source); |
@@ -263,14 +283,18 @@ discard block |
||
263 | 283 | * @return bool |
264 | 284 | */ |
265 | 285 | public function delete($file, $recursive = false, $type = false) { |
266 | - if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. |
|
286 | + if ( empty( $file ) ) { |
|
287 | + // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. |
|
267 | 288 | return false; |
289 | + } |
|
268 | 290 | $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise |
269 | 291 | |
270 | - if ( 'f' == $type || $this->is_file($file) ) |
|
271 | - return @unlink($file); |
|
272 | - if ( ! $recursive && $this->is_dir($file) ) |
|
273 | - return @rmdir($file); |
|
292 | + if ( 'f' == $type || $this->is_file($file) ) { |
|
293 | + return @unlink($file); |
|
294 | + } |
|
295 | + if ( ! $recursive && $this->is_dir($file) ) { |
|
296 | + return @rmdir($file); |
|
297 | + } |
|
274 | 298 | |
275 | 299 | // At this point it's a folder, and we're in recursive mode |
276 | 300 | $file = trailingslashit($file); |
@@ -279,13 +303,15 @@ discard block |
||
279 | 303 | $retval = true; |
280 | 304 | if ( is_array( $filelist ) ) { |
281 | 305 | foreach ( $filelist as $filename => $fileinfo ) { |
282 | - if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) |
|
283 | - $retval = false; |
|
306 | + if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) { |
|
307 | + $retval = false; |
|
308 | + } |
|
284 | 309 | } |
285 | 310 | } |
286 | 311 | |
287 | - if ( file_exists($file) && ! @rmdir($file) ) |
|
288 | - $retval = false; |
|
312 | + if ( file_exists($file) && ! @rmdir($file) ) { |
|
313 | + $retval = false; |
|
314 | + } |
|
289 | 315 | |
290 | 316 | return $retval; |
291 | 317 | } |
@@ -358,10 +384,12 @@ discard block |
||
358 | 384 | * @return bool |
359 | 385 | */ |
360 | 386 | public function touch($file, $time = 0, $atime = 0) { |
361 | - if ($time == 0) |
|
362 | - $time = time(); |
|
363 | - if ($atime == 0) |
|
364 | - $atime = time(); |
|
387 | + if ($time == 0) { |
|
388 | + $time = time(); |
|
389 | + } |
|
390 | + if ($atime == 0) { |
|
391 | + $atime = time(); |
|
392 | + } |
|
365 | 393 | return @touch($file, $time, $atime); |
366 | 394 | } |
367 | 395 | |
@@ -375,19 +403,24 @@ discard block |
||
375 | 403 | public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { |
376 | 404 | // Safe mode fails with a trailing slash under certain PHP versions. |
377 | 405 | $path = untrailingslashit($path); |
378 | - if ( empty($path) ) |
|
379 | - return false; |
|
406 | + if ( empty($path) ) { |
|
407 | + return false; |
|
408 | + } |
|
380 | 409 | |
381 | - if ( ! $chmod ) |
|
382 | - $chmod = FS_CHMOD_DIR; |
|
410 | + if ( ! $chmod ) { |
|
411 | + $chmod = FS_CHMOD_DIR; |
|
412 | + } |
|
383 | 413 | |
384 | - if ( ! @mkdir($path) ) |
|
385 | - return false; |
|
414 | + if ( ! @mkdir($path) ) { |
|
415 | + return false; |
|
416 | + } |
|
386 | 417 | $this->chmod($path, $chmod); |
387 | - if ( $chown ) |
|
388 | - $this->chown($path, $chown); |
|
389 | - if ( $chgrp ) |
|
390 | - $this->chgrp($path, $chgrp); |
|
418 | + if ( $chown ) { |
|
419 | + $this->chown($path, $chown); |
|
420 | + } |
|
421 | + if ( $chgrp ) { |
|
422 | + $this->chgrp($path, $chgrp); |
|
423 | + } |
|
391 | 424 | return true; |
392 | 425 | } |
393 | 426 | |
@@ -414,12 +447,14 @@ discard block |
||
414 | 447 | $limit_file = false; |
415 | 448 | } |
416 | 449 | |
417 | - if ( ! $this->is_dir($path) ) |
|
418 | - return false; |
|
450 | + if ( ! $this->is_dir($path) ) { |
|
451 | + return false; |
|
452 | + } |
|
419 | 453 | |
420 | 454 | $dir = @dir($path); |
421 | - if ( ! $dir ) |
|
422 | - return false; |
|
455 | + if ( ! $dir ) { |
|
456 | + return false; |
|
457 | + } |
|
423 | 458 | |
424 | 459 | $ret = array(); |
425 | 460 | |
@@ -427,14 +462,17 @@ discard block |
||
427 | 462 | $struc = array(); |
428 | 463 | $struc['name'] = $entry; |
429 | 464 | |
430 | - if ( '.' == $struc['name'] || '..' == $struc['name'] ) |
|
431 | - continue; |
|
465 | + if ( '.' == $struc['name'] || '..' == $struc['name'] ) { |
|
466 | + continue; |
|
467 | + } |
|
432 | 468 | |
433 | - if ( ! $include_hidden && '.' == $struc['name'][0] ) |
|
434 | - continue; |
|
469 | + if ( ! $include_hidden && '.' == $struc['name'][0] ) { |
|
470 | + continue; |
|
471 | + } |
|
435 | 472 | |
436 | - if ( $limit_file && $struc['name'] != $limit_file) |
|
437 | - continue; |
|
473 | + if ( $limit_file && $struc['name'] != $limit_file) { |
|
474 | + continue; |
|
475 | + } |
|
438 | 476 | |
439 | 477 | $struc['perms'] = $this->gethchmod($path.'/'.$entry); |
440 | 478 | $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); |
@@ -448,10 +486,11 @@ discard block |
||
448 | 486 | $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; |
449 | 487 | |
450 | 488 | if ( 'd' == $struc['type'] ) { |
451 | - if ( $recursive ) |
|
452 | - $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
453 | - else |
|
454 | - $struc['files'] = array(); |
|
489 | + if ( $recursive ) { |
|
490 | + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
491 | + } else { |
|
492 | + $struc['files'] = array(); |
|
493 | + } |
|
455 | 494 | } |
456 | 495 | |
457 | 496 | $ret[ $struc['name'] ] = $struc; |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Build Administration Menu. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * Build Administration Menu. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | if ( is_network_admin() ) { |
10 | 10 |
@@ -49,20 +49,22 @@ discard block |
||
49 | 49 | $hook_args = substr($menu_page[2], $pos + 1); |
50 | 50 | wp_parse_str($hook_args, $hook_args); |
51 | 51 | // Set the hook name to be the post type. |
52 | - if ( isset($hook_args['post_type']) ) |
|
53 | - $hook_name = $hook_args['post_type']; |
|
54 | - else |
|
55 | - $hook_name = basename($hook_name, '.php'); |
|
52 | + if ( isset($hook_args['post_type']) ) { |
|
53 | + $hook_name = $hook_args['post_type']; |
|
54 | + } else { |
|
55 | + $hook_name = basename($hook_name, '.php'); |
|
56 | + } |
|
56 | 57 | unset($hook_args); |
57 | 58 | } else { |
58 | 59 | $hook_name = basename($menu_page[2], '.php'); |
59 | 60 | } |
60 | 61 | $hook_name = sanitize_title($hook_name); |
61 | 62 | |
62 | - if ( isset($compat[$hook_name]) ) |
|
63 | - $hook_name = $compat[$hook_name]; |
|
64 | - elseif ( !$hook_name ) |
|
65 | - continue; |
|
63 | + if ( isset($compat[$hook_name]) ) { |
|
64 | + $hook_name = $compat[$hook_name]; |
|
65 | + } elseif ( !$hook_name ) { |
|
66 | + continue; |
|
67 | + } |
|
66 | 68 | |
67 | 69 | $admin_page_hooks[$menu_page[2]] = $hook_name; |
68 | 70 | } |
@@ -80,9 +82,10 @@ discard block |
||
80 | 82 | } |
81 | 83 | unset($index, $data); |
82 | 84 | |
83 | - if ( empty($submenu[$parent]) ) |
|
84 | - unset($submenu[$parent]); |
|
85 | -} |
|
85 | + if ( empty($submenu[$parent]) ) { |
|
86 | + unset($submenu[$parent]); |
|
87 | + } |
|
88 | + } |
|
86 | 89 | unset($sub, $parent); |
87 | 90 | |
88 | 91 | /* |
@@ -91,8 +94,9 @@ discard block |
||
91 | 94 | * will have the next submenu in line be assigned as the new menu parent. |
92 | 95 | */ |
93 | 96 | foreach ( $menu as $id => $data ) { |
94 | - if ( empty($submenu[$data[2]]) ) |
|
95 | - continue; |
|
97 | + if ( empty($submenu[$data[2]]) ) { |
|
98 | + continue; |
|
99 | + } |
|
96 | 100 | $subs = $submenu[$data[2]]; |
97 | 101 | $first_sub = reset( $subs ); |
98 | 102 | $old_parent = $data[2]; |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | } |
112 | 116 | unset($submenu[$old_parent], $index); |
113 | 117 | |
114 | - if ( isset($_wp_submenu_nopriv[$old_parent]) ) |
|
115 | - $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent]; |
|
118 | + if ( isset($_wp_submenu_nopriv[$old_parent]) ) { |
|
119 | + $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent]; |
|
120 | + } |
|
116 | 121 | } |
117 | 122 | } |
118 | 123 | unset($id, $data, $subs, $first_sub, $old_parent, $new_parent); |
@@ -154,8 +159,9 @@ discard block |
||
154 | 159 | * that the user does not have. Run re-parent loop again. |
155 | 160 | */ |
156 | 161 | foreach ( $menu as $id => $data ) { |
157 | - if ( ! current_user_can($data[1]) ) |
|
158 | - $_wp_menu_nopriv[$data[2]] = true; |
|
162 | + if ( ! current_user_can($data[1]) ) { |
|
163 | + $_wp_menu_nopriv[$data[2]] = true; |
|
164 | + } |
|
159 | 165 | |
160 | 166 | /* |
161 | 167 | * If there is only one submenu and it is has same destination as the parent, |
@@ -164,8 +170,9 @@ discard block |
||
164 | 170 | if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) { |
165 | 171 | $subs = $submenu[$data[2]]; |
166 | 172 | $first_sub = reset( $subs ); |
167 | - if ( $data[2] == $first_sub[2] ) |
|
168 | - unset( $submenu[$data[2]] ); |
|
173 | + if ( $data[2] == $first_sub[2] ) { |
|
174 | + unset( $submenu[$data[2]] ); |
|
175 | + } |
|
169 | 176 | } |
170 | 177 | |
171 | 178 | // If submenu is empty... |
@@ -307,8 +314,9 @@ discard block |
||
307 | 314 | } elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) { |
308 | 315 | return 1; |
309 | 316 | } elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) { |
310 | - if ( $menu_order[$a] == $menu_order[$b] ) |
|
311 | - return 0; |
|
317 | + if ( $menu_order[$a] == $menu_order[$b] ) { |
|
318 | + return 0; |
|
319 | + } |
|
312 | 320 | return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1; |
313 | 321 | } else { |
314 | 322 | return ($default_menu_order[$a] <= $default_menu_order[$b]) ? -1 : 1; |
@@ -322,8 +330,9 @@ discard block |
||
322 | 330 | // Remove the last menu item if it is a separator. |
323 | 331 | $last_menu_key = array_keys( $menu ); |
324 | 332 | $last_menu_key = array_pop( $last_menu_key ); |
325 | -if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] ) |
|
333 | +if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] ) { |
|
326 | 334 | unset( $menu[ $last_menu_key ] ); |
335 | +} |
|
327 | 336 | unset( $last_menu_key ); |
328 | 337 | |
329 | 338 | if ( !user_can_access_admin_page() ) { |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @subpackage Administration |
7 | 7 | */ |
8 | 8 | |
9 | -if ( is_network_admin() ) { |
|
9 | +if (is_network_admin()) { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Fires before the administration menu loads in the Network Admin. |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | * @private |
17 | 17 | * @since 3.1.0 |
18 | 18 | */ |
19 | - do_action( '_network_admin_menu' ); |
|
20 | -} elseif ( is_user_admin() ) { |
|
19 | + do_action('_network_admin_menu'); |
|
20 | +} elseif (is_user_admin()) { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Fires before the administration menu loads in the User Admin. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @private |
28 | 28 | * @since 3.1.0 |
29 | 29 | */ |
30 | - do_action( '_user_admin_menu' ); |
|
30 | + do_action('_user_admin_menu'); |
|
31 | 31 | } else { |
32 | 32 | |
33 | 33 | /** |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | * @private |
39 | 39 | * @since 2.2.0 |
40 | 40 | */ |
41 | - do_action( '_admin_menu' ); |
|
41 | + do_action('_admin_menu'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Create list of page plugin hook names. |
45 | 45 | foreach ($menu as $menu_page) { |
46 | - if ( false !== $pos = strpos($menu_page[2], '?') ) { |
|
46 | + if (false !== $pos = strpos($menu_page[2], '?')) { |
|
47 | 47 | // Handle post_type=post|page|foo pages. |
48 | 48 | $hook_name = substr($menu_page[2], 0, $pos); |
49 | 49 | $hook_args = substr($menu_page[2], $pos + 1); |
50 | 50 | wp_parse_str($hook_args, $hook_args); |
51 | 51 | // Set the hook name to be the post type. |
52 | - if ( isset($hook_args['post_type']) ) |
|
52 | + if (isset($hook_args['post_type'])) |
|
53 | 53 | $hook_name = $hook_args['post_type']; |
54 | 54 | else |
55 | 55 | $hook_name = basename($hook_name, '.php'); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | } |
60 | 60 | $hook_name = sanitize_title($hook_name); |
61 | 61 | |
62 | - if ( isset($compat[$hook_name]) ) |
|
62 | + if (isset($compat[$hook_name])) |
|
63 | 63 | $hook_name = $compat[$hook_name]; |
64 | - elseif ( !$hook_name ) |
|
64 | + elseif ( ! $hook_name) |
|
65 | 65 | continue; |
66 | 66 | |
67 | 67 | $admin_page_hooks[$menu_page[2]] = $hook_name; |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | // Loop over submenus and remove pages for which the user does not have privs. |
74 | 74 | foreach ($submenu as $parent => $sub) { |
75 | 75 | foreach ($sub as $index => $data) { |
76 | - if ( ! current_user_can($data[1]) ) { |
|
76 | + if ( ! current_user_can($data[1])) { |
|
77 | 77 | unset($submenu[$parent][$index]); |
78 | 78 | $_wp_submenu_nopriv[$parent][$data[2]] = true; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | unset($index, $data); |
82 | 82 | |
83 | - if ( empty($submenu[$parent]) ) |
|
83 | + if (empty($submenu[$parent])) |
|
84 | 84 | unset($submenu[$parent]); |
85 | 85 | } |
86 | 86 | unset($sub, $parent); |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * Menus for which the original parent is not accessible due to lack of privileges |
91 | 91 | * will have the next submenu in line be assigned as the new menu parent. |
92 | 92 | */ |
93 | -foreach ( $menu as $id => $data ) { |
|
94 | - if ( empty($submenu[$data[2]]) ) |
|
93 | +foreach ($menu as $id => $data) { |
|
94 | + if (empty($submenu[$data[2]])) |
|
95 | 95 | continue; |
96 | 96 | $subs = $submenu[$data[2]]; |
97 | - $first_sub = reset( $subs ); |
|
97 | + $first_sub = reset($subs); |
|
98 | 98 | $old_parent = $data[2]; |
99 | 99 | $new_parent = $first_sub[2]; |
100 | 100 | /* |
101 | 101 | * If the first submenu is not the same as the assigned parent, |
102 | 102 | * make the first submenu the new parent. |
103 | 103 | */ |
104 | - if ( $new_parent != $old_parent ) { |
|
104 | + if ($new_parent != $old_parent) { |
|
105 | 105 | $_wp_real_parent_file[$old_parent] = $new_parent; |
106 | 106 | $menu[$id][2] = $new_parent; |
107 | 107 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | } |
112 | 112 | unset($submenu[$old_parent], $index); |
113 | 113 | |
114 | - if ( isset($_wp_submenu_nopriv[$old_parent]) ) |
|
114 | + if (isset($_wp_submenu_nopriv[$old_parent])) |
|
115 | 115 | $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent]; |
116 | 116 | } |
117 | 117 | } |
118 | 118 | unset($id, $data, $subs, $first_sub, $old_parent, $new_parent); |
119 | 119 | |
120 | -if ( is_network_admin() ) { |
|
120 | +if (is_network_admin()) { |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Fires before the administration menu loads in the Network Admin. |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @param string $context Empty context. |
128 | 128 | */ |
129 | - do_action( 'network_admin_menu', '' ); |
|
130 | -} elseif ( is_user_admin() ) { |
|
129 | + do_action('network_admin_menu', ''); |
|
130 | +} elseif (is_user_admin()) { |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Fires before the administration menu loads in the User Admin. |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @param string $context Empty context. |
138 | 138 | */ |
139 | - do_action( 'user_admin_menu', '' ); |
|
139 | + do_action('user_admin_menu', ''); |
|
140 | 140 | } else { |
141 | 141 | |
142 | 142 | /** |
@@ -146,32 +146,32 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param string $context Empty context. |
148 | 148 | */ |
149 | - do_action( 'admin_menu', '' ); |
|
149 | + do_action('admin_menu', ''); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /* |
153 | 153 | * Remove menus that have no accessible submenus and require privileges |
154 | 154 | * that the user does not have. Run re-parent loop again. |
155 | 155 | */ |
156 | -foreach ( $menu as $id => $data ) { |
|
157 | - if ( ! current_user_can($data[1]) ) |
|
156 | +foreach ($menu as $id => $data) { |
|
157 | + if ( ! current_user_can($data[1])) |
|
158 | 158 | $_wp_menu_nopriv[$data[2]] = true; |
159 | 159 | |
160 | 160 | /* |
161 | 161 | * If there is only one submenu and it is has same destination as the parent, |
162 | 162 | * remove the submenu. |
163 | 163 | */ |
164 | - if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) { |
|
164 | + if ( ! empty($submenu[$data[2]]) && 1 == count($submenu[$data[2]])) { |
|
165 | 165 | $subs = $submenu[$data[2]]; |
166 | - $first_sub = reset( $subs ); |
|
167 | - if ( $data[2] == $first_sub[2] ) |
|
168 | - unset( $submenu[$data[2]] ); |
|
166 | + $first_sub = reset($subs); |
|
167 | + if ($data[2] == $first_sub[2]) |
|
168 | + unset($submenu[$data[2]]); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // If submenu is empty... |
172 | - if ( empty($submenu[$data[2]]) ) { |
|
172 | + if (empty($submenu[$data[2]])) { |
|
173 | 173 | // And user doesn't have privs, remove menu. |
174 | - if ( isset( $_wp_menu_nopriv[$data[2]] ) ) { |
|
174 | + if (isset($_wp_menu_nopriv[$data[2]])) { |
|
175 | 175 | unset($menu[$id]); |
176 | 176 | } |
177 | 177 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return string |
186 | 186 | */ |
187 | 187 | function add_cssclass($add, $class) { |
188 | - $class = empty($class) ? $add : $class .= ' ' . $add; |
|
188 | + $class = empty($class) ? $add : $class .= ' '.$add; |
|
189 | 189 | return $class; |
190 | 190 | } |
191 | 191 | |
@@ -198,29 +198,29 @@ discard block |
||
198 | 198 | $first = $lastorder = false; |
199 | 199 | $i = 0; |
200 | 200 | $mc = count($menu); |
201 | - foreach ( $menu as $order => $top ) { |
|
201 | + foreach ($menu as $order => $top) { |
|
202 | 202 | $i++; |
203 | 203 | |
204 | - if ( 0 == $order ) { // dashboard is always shown/single |
|
204 | + if (0 == $order) { // dashboard is always shown/single |
|
205 | 205 | $menu[0][4] = add_cssclass('menu-top-first', $top[4]); |
206 | 206 | $lastorder = 0; |
207 | 207 | continue; |
208 | 208 | } |
209 | 209 | |
210 | - if ( 0 === strpos($top[2], 'separator') && false !== $lastorder ) { // if separator |
|
210 | + if (0 === strpos($top[2], 'separator') && false !== $lastorder) { // if separator |
|
211 | 211 | $first = true; |
212 | 212 | $c = $menu[$lastorder][4]; |
213 | 213 | $menu[$lastorder][4] = add_cssclass('menu-top-last', $c); |
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | - if ( $first ) { |
|
217 | + if ($first) { |
|
218 | 218 | $c = $menu[$order][4]; |
219 | 219 | $menu[$order][4] = add_cssclass('menu-top-first', $c); |
220 | 220 | $first = false; |
221 | 221 | } |
222 | 222 | |
223 | - if ( $mc == $i ) { // last item |
|
223 | + if ($mc == $i) { // last item |
|
224 | 224 | $c = $menu[$order][4]; |
225 | 225 | $menu[$order][4] = add_cssclass('menu-top-last', $c); |
226 | 226 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param array $menu Associative array of administration menu items. |
237 | 237 | */ |
238 | - return apply_filters( 'add_menu_classes', $menu ); |
|
238 | + return apply_filters('add_menu_classes', $menu); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | uksort($menu, "strnatcasecmp"); // make it all pretty |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param bool $custom Whether custom ordering is enabled. Default false. |
251 | 251 | */ |
252 | -if ( apply_filters( 'custom_menu_order', false ) ) { |
|
252 | +if (apply_filters('custom_menu_order', false)) { |
|
253 | 253 | $menu_order = array(); |
254 | - foreach ( $menu as $menu_item ) { |
|
254 | + foreach ($menu as $menu_item) { |
|
255 | 255 | $menu_order[] = $menu_item[2]; |
256 | 256 | } |
257 | 257 | unset($menu_item); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @param array $menu_order An ordered array of menu items. |
271 | 271 | */ |
272 | - $menu_order = apply_filters( 'menu_order', $menu_order ); |
|
272 | + $menu_order = apply_filters('menu_order', $menu_order); |
|
273 | 273 | $menu_order = array_flip($menu_order); |
274 | 274 | $default_menu_order = array_flip($default_menu_order); |
275 | 275 | |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | global $menu_order, $default_menu_order; |
287 | 287 | $a = $a[2]; |
288 | 288 | $b = $b[2]; |
289 | - if ( isset($menu_order[$a]) && !isset($menu_order[$b]) ) { |
|
289 | + if (isset($menu_order[$a]) && ! isset($menu_order[$b])) { |
|
290 | 290 | return -1; |
291 | - } elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) { |
|
291 | + } elseif ( ! isset($menu_order[$a]) && isset($menu_order[$b])) { |
|
292 | 292 | return 1; |
293 | - } elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) { |
|
294 | - if ( $menu_order[$a] == $menu_order[$b] ) |
|
293 | + } elseif (isset($menu_order[$a]) && isset($menu_order[$b])) { |
|
294 | + if ($menu_order[$a] == $menu_order[$b]) |
|
295 | 295 | return 0; |
296 | 296 | return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1; |
297 | 297 | } else { |
@@ -305,41 +305,41 @@ discard block |
||
305 | 305 | |
306 | 306 | // Prevent adjacent separators |
307 | 307 | $prev_menu_was_separator = false; |
308 | -foreach ( $menu as $id => $data ) { |
|
309 | - if ( false === stristr( $data[4], 'wp-menu-separator' ) ) { |
|
308 | +foreach ($menu as $id => $data) { |
|
309 | + if (false === stristr($data[4], 'wp-menu-separator')) { |
|
310 | 310 | |
311 | 311 | // This item is not a separator, so falsey the toggler and do nothing |
312 | 312 | $prev_menu_was_separator = false; |
313 | 313 | } else { |
314 | 314 | |
315 | 315 | // The previous item was a separator, so unset this one |
316 | - if ( true === $prev_menu_was_separator ) { |
|
317 | - unset( $menu[ $id ] ); |
|
316 | + if (true === $prev_menu_was_separator) { |
|
317 | + unset($menu[$id]); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // This item is a separator, so truthy the toggler and move on |
321 | 321 | $prev_menu_was_separator = true; |
322 | 322 | } |
323 | 323 | } |
324 | -unset( $id, $data, $prev_menu_was_separator ); |
|
324 | +unset($id, $data, $prev_menu_was_separator); |
|
325 | 325 | |
326 | 326 | // Remove the last menu item if it is a separator. |
327 | -$last_menu_key = array_keys( $menu ); |
|
328 | -$last_menu_key = array_pop( $last_menu_key ); |
|
329 | -if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] ) |
|
330 | - unset( $menu[ $last_menu_key ] ); |
|
331 | -unset( $last_menu_key ); |
|
327 | +$last_menu_key = array_keys($menu); |
|
328 | +$last_menu_key = array_pop($last_menu_key); |
|
329 | +if ( ! empty($menu) && 'wp-menu-separator' == $menu[$last_menu_key][4]) |
|
330 | + unset($menu[$last_menu_key]); |
|
331 | +unset($last_menu_key); |
|
332 | 332 | |
333 | -if ( !user_can_access_admin_page() ) { |
|
333 | +if ( ! user_can_access_admin_page()) { |
|
334 | 334 | |
335 | 335 | /** |
336 | 336 | * Fires when access to an admin page is denied. |
337 | 337 | * |
338 | 338 | * @since 2.5.0 |
339 | 339 | */ |
340 | - do_action( 'admin_page_access_denied' ); |
|
340 | + do_action('admin_page_access_denied'); |
|
341 | 341 | |
342 | - wp_die( __( 'You do not have sufficient permissions to access this page.' ), 403 ); |
|
342 | + wp_die(__('You do not have sufficient permissions to access this page.'), 403); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $menu = add_menu_classes($menu); |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Administration Update API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Administration Update API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Selects the first update version from the update_core option. |
@@ -354,16 +354,16 @@ discard block |
||
354 | 354 | * @type string $title The human-readable title of the plugin. |
355 | 355 | * @type string $author_name Plugin author's name. |
356 | 356 | * @type bool $update Whether there's an available update. Default null. |
357 | - * } |
|
358 | - * @param array $r { |
|
359 | - * An array of metadata about the available plugin update. |
|
360 | - * |
|
361 | - * @type int $id Plugin ID. |
|
362 | - * @type string $slug Plugin slug. |
|
363 | - * @type string $new_version New plugin version. |
|
364 | - * @type string $url Plugin URL. |
|
365 | - * @type string $package Plugin update package URL. |
|
366 | - * } |
|
357 | + * } |
|
358 | + * @param array $r { |
|
359 | + * An array of metadata about the available plugin update. |
|
360 | + * |
|
361 | + * @type int $id Plugin ID. |
|
362 | + * @type string $slug Plugin slug. |
|
363 | + * @type string $new_version New plugin version. |
|
364 | + * @type string $url Plugin URL. |
|
365 | + * @type string $package Plugin update package URL. |
|
366 | + * } |
|
367 | 367 | */ |
368 | 368 | do_action( "in_plugin_update_message-{$file}", $plugin_data, $r ); |
369 | 369 |
@@ -13,10 +13,12 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function get_preferred_from_update_core() { |
15 | 15 | $updates = get_core_updates(); |
16 | - if ( ! is_array( $updates ) ) |
|
17 | - return false; |
|
18 | - if ( empty( $updates ) ) |
|
19 | - return (object) array( 'response' => 'latest' ); |
|
16 | + if ( ! is_array( $updates ) ) { |
|
17 | + return false; |
|
18 | + } |
|
19 | + if ( empty( $updates ) ) { |
|
20 | + return (object) array( 'response' => 'latest' ); |
|
21 | + } |
|
20 | 22 | return $updates[0]; |
21 | 23 | } |
22 | 24 | |
@@ -31,19 +33,22 @@ discard block |
||
31 | 33 | $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
32 | 34 | $dismissed = get_site_option( 'dismissed_update_core' ); |
33 | 35 | |
34 | - if ( ! is_array( $dismissed ) ) |
|
35 | - $dismissed = array(); |
|
36 | + if ( ! is_array( $dismissed ) ) { |
|
37 | + $dismissed = array(); |
|
38 | + } |
|
36 | 39 | |
37 | 40 | $from_api = get_site_transient( 'update_core' ); |
38 | 41 | |
39 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
40 | - return false; |
|
42 | + if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
|
43 | + return false; |
|
44 | + } |
|
41 | 45 | |
42 | 46 | $updates = $from_api->updates; |
43 | 47 | $result = array(); |
44 | 48 | foreach ( $updates as $update ) { |
45 | - if ( $update->response == 'autoupdate' ) |
|
46 | - continue; |
|
49 | + if ( $update->response == 'autoupdate' ) { |
|
50 | + continue; |
|
51 | + } |
|
47 | 52 | |
48 | 53 | if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
49 | 54 | if ( $options['dismissed'] ) { |
@@ -71,22 +76,26 @@ discard block |
||
71 | 76 | */ |
72 | 77 | function find_core_auto_update() { |
73 | 78 | $updates = get_site_transient( 'update_core' ); |
74 | - if ( ! $updates || empty( $updates->updates ) ) |
|
75 | - return false; |
|
79 | + if ( ! $updates || empty( $updates->updates ) ) { |
|
80 | + return false; |
|
81 | + } |
|
76 | 82 | |
77 | 83 | include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
78 | 84 | |
79 | 85 | $auto_update = false; |
80 | 86 | $upgrader = new WP_Automatic_Updater; |
81 | 87 | foreach ( $updates->updates as $update ) { |
82 | - if ( 'autoupdate' != $update->response ) |
|
83 | - continue; |
|
88 | + if ( 'autoupdate' != $update->response ) { |
|
89 | + continue; |
|
90 | + } |
|
84 | 91 | |
85 | - if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) |
|
86 | - continue; |
|
92 | + if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) { |
|
93 | + continue; |
|
94 | + } |
|
87 | 95 | |
88 | - if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) |
|
89 | - $auto_update = $update; |
|
96 | + if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) { |
|
97 | + $auto_update = $update; |
|
98 | + } |
|
90 | 99 | } |
91 | 100 | return $auto_update; |
92 | 101 | } |
@@ -103,8 +112,9 @@ discard block |
||
103 | 112 | function get_core_checksums( $version, $locale ) { |
104 | 113 | $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); |
105 | 114 | |
106 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
107 | - $url = set_url_scheme( $url, 'https' ); |
|
115 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
116 | + $url = set_url_scheme( $url, 'https' ); |
|
117 | + } |
|
108 | 118 | |
109 | 119 | $options = array( |
110 | 120 | 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
@@ -116,14 +126,16 @@ discard block |
||
116 | 126 | $response = wp_remote_get( $http_url, $options ); |
117 | 127 | } |
118 | 128 | |
119 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
120 | - return false; |
|
129 | + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
130 | + return false; |
|
131 | + } |
|
121 | 132 | |
122 | 133 | $body = trim( wp_remote_retrieve_body( $response ) ); |
123 | 134 | $body = json_decode( $body, true ); |
124 | 135 | |
125 | - if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) |
|
126 | - return false; |
|
136 | + if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) { |
|
137 | + return false; |
|
138 | + } |
|
127 | 139 | |
128 | 140 | return $body['checksums']; |
129 | 141 | } |
@@ -149,8 +161,9 @@ discard block |
||
149 | 161 | $dismissed = get_site_option( 'dismissed_update_core' ); |
150 | 162 | $key = $version . '|' . $locale; |
151 | 163 | |
152 | - if ( ! isset( $dismissed[$key] ) ) |
|
153 | - return false; |
|
164 | + if ( ! isset( $dismissed[$key] ) ) { |
|
165 | + return false; |
|
166 | + } |
|
154 | 167 | |
155 | 168 | unset( $dismissed[$key] ); |
156 | 169 | return update_site_option( 'dismissed_update_core', $dismissed ); |
@@ -165,13 +178,15 @@ discard block |
||
165 | 178 | function find_core_update( $version, $locale ) { |
166 | 179 | $from_api = get_site_transient( 'update_core' ); |
167 | 180 | |
168 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
169 | - return false; |
|
181 | + if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
|
182 | + return false; |
|
183 | + } |
|
170 | 184 | |
171 | 185 | $updates = $from_api->updates; |
172 | 186 | foreach ( $updates as $update ) { |
173 | - if ( $update->current == $version && $update->locale == $locale ) |
|
174 | - return $update; |
|
187 | + if ( $update->current == $version && $update->locale == $locale ) { |
|
188 | + return $update; |
|
189 | + } |
|
175 | 190 | } |
176 | 191 | return false; |
177 | 192 | } |
@@ -182,21 +197,26 @@ discard block |
||
182 | 197 | * @return string |
183 | 198 | */ |
184 | 199 | function core_update_footer( $msg = '' ) { |
185 | - if ( !current_user_can('update_core') ) |
|
186 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
200 | + if ( !current_user_can('update_core') ) { |
|
201 | + return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
202 | + } |
|
187 | 203 | |
188 | 204 | $cur = get_preferred_from_update_core(); |
189 | - if ( ! is_object( $cur ) ) |
|
190 | - $cur = new stdClass; |
|
205 | + if ( ! is_object( $cur ) ) { |
|
206 | + $cur = new stdClass; |
|
207 | + } |
|
191 | 208 | |
192 | - if ( ! isset( $cur->current ) ) |
|
193 | - $cur->current = ''; |
|
209 | + if ( ! isset( $cur->current ) ) { |
|
210 | + $cur->current = ''; |
|
211 | + } |
|
194 | 212 | |
195 | - if ( ! isset( $cur->url ) ) |
|
196 | - $cur->url = ''; |
|
213 | + if ( ! isset( $cur->url ) ) { |
|
214 | + $cur->url = ''; |
|
215 | + } |
|
197 | 216 | |
198 | - if ( ! isset( $cur->response ) ) |
|
199 | - $cur->response = ''; |
|
217 | + if ( ! isset( $cur->response ) ) { |
|
218 | + $cur->response = ''; |
|
219 | + } |
|
200 | 220 | |
201 | 221 | switch ( $cur->response ) { |
202 | 222 | case 'development' : |
@@ -217,18 +237,21 @@ discard block |
||
217 | 237 | * @return false|void |
218 | 238 | */ |
219 | 239 | function update_nag() { |
220 | - if ( is_multisite() && !current_user_can('update_core') ) |
|
221 | - return false; |
|
240 | + if ( is_multisite() && !current_user_can('update_core') ) { |
|
241 | + return false; |
|
242 | + } |
|
222 | 243 | |
223 | 244 | global $pagenow; |
224 | 245 | |
225 | - if ( 'update-core.php' == $pagenow ) |
|
226 | - return; |
|
246 | + if ( 'update-core.php' == $pagenow ) { |
|
247 | + return; |
|
248 | + } |
|
227 | 249 | |
228 | 250 | $cur = get_preferred_from_update_core(); |
229 | 251 | |
230 | - if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
|
231 | - return false; |
|
252 | + if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) { |
|
253 | + return false; |
|
254 | + } |
|
232 | 255 | |
233 | 256 | if ( current_user_can('update_core') ) { |
234 | 257 | $msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) ); |
@@ -250,8 +273,9 @@ discard block |
||
250 | 273 | if ( current_user_can('update_core') ) { |
251 | 274 | $cur = get_preferred_from_update_core(); |
252 | 275 | |
253 | - if ( isset( $cur->response ) && $cur->response == 'upgrade' ) |
|
254 | - $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
|
276 | + if ( isset( $cur->response ) && $cur->response == 'upgrade' ) { |
|
277 | + $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
|
278 | + } |
|
255 | 279 | } |
256 | 280 | |
257 | 281 | $msg .= sprintf( '<span id="wp-version">' . __( 'WordPress %1$s running %2$s theme.' ) . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); |
@@ -282,8 +306,9 @@ discard block |
||
282 | 306 | * @since 2.9.0 |
283 | 307 | */ |
284 | 308 | function wp_plugin_update_rows() { |
285 | - if ( !current_user_can('update_plugins' ) ) |
|
286 | - return; |
|
309 | + if ( !current_user_can('update_plugins' ) ) { |
|
310 | + return; |
|
311 | + } |
|
287 | 312 | |
288 | 313 | $plugins = get_site_transient( 'update_plugins' ); |
289 | 314 | if ( isset($plugins->response) && is_array($plugins->response) ) { |
@@ -302,8 +327,9 @@ discard block |
||
302 | 327 | */ |
303 | 328 | function wp_plugin_update_row( $file, $plugin_data ) { |
304 | 329 | $current = get_site_transient( 'update_plugins' ); |
305 | - if ( !isset( $current->response[ $file ] ) ) |
|
306 | - return false; |
|
330 | + if ( !isset( $current->response[ $file ] ) ) { |
|
331 | + return false; |
|
332 | + } |
|
307 | 333 | |
308 | 334 | $r = $current->response[ $file ]; |
309 | 335 | |
@@ -378,8 +404,9 @@ discard block |
||
378 | 404 | function get_theme_updates() { |
379 | 405 | $current = get_site_transient('update_themes'); |
380 | 406 | |
381 | - if ( ! isset( $current->response ) ) |
|
382 | - return array(); |
|
407 | + if ( ! isset( $current->response ) ) { |
|
408 | + return array(); |
|
409 | + } |
|
383 | 410 | |
384 | 411 | $update_themes = array(); |
385 | 412 | foreach ( $current->response as $stylesheet => $data ) { |
@@ -394,8 +421,9 @@ discard block |
||
394 | 421 | * @since 3.1.0 |
395 | 422 | */ |
396 | 423 | function wp_theme_update_rows() { |
397 | - if ( !current_user_can('update_themes' ) ) |
|
398 | - return; |
|
424 | + if ( !current_user_can('update_themes' ) ) { |
|
425 | + return; |
|
426 | + } |
|
399 | 427 | |
400 | 428 | $themes = get_site_transient( 'update_themes' ); |
401 | 429 | if ( isset($themes->response) && is_array($themes->response) ) { |
@@ -415,8 +443,9 @@ discard block |
||
415 | 443 | */ |
416 | 444 | function wp_theme_update_row( $theme_key, $theme ) { |
417 | 445 | $current = get_site_transient( 'update_themes' ); |
418 | - if ( !isset( $current->response[ $theme_key ] ) ) |
|
419 | - return false; |
|
446 | + if ( !isset( $current->response[ $theme_key ] ) ) { |
|
447 | + return false; |
|
448 | + } |
|
420 | 449 | $r = $current->response[ $theme_key ]; |
421 | 450 | |
422 | 451 | $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] ); |
@@ -476,17 +505,20 @@ discard block |
||
476 | 505 | * This flag is cleared whenever a successful update occurs using Core_Upgrader. |
477 | 506 | */ |
478 | 507 | $comparison = ! empty( $failed['critical'] ) ? '>=' : '>'; |
479 | - if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) |
|
480 | - $nag = true; |
|
508 | + if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) { |
|
509 | + $nag = true; |
|
510 | + } |
|
481 | 511 | } |
482 | 512 | |
483 | - if ( ! $nag ) |
|
484 | - return false; |
|
513 | + if ( ! $nag ) { |
|
514 | + return false; |
|
515 | + } |
|
485 | 516 | |
486 | - if ( current_user_can('update_core') ) |
|
487 | - $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' ); |
|
488 | - else |
|
489 | - $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); |
|
517 | + if ( current_user_can('update_core') ) { |
|
518 | + $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' ); |
|
519 | + } else { |
|
520 | + $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); |
|
521 | + } |
|
490 | 522 | |
491 | 523 | echo "<div class='update-nag'>$msg</div>"; |
492 | 524 | } |
@@ -199,15 +199,15 @@ |
||
199 | 199 | $cur->response = ''; |
200 | 200 | |
201 | 201 | switch ( $cur->response ) { |
202 | - case 'development' : |
|
203 | - return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
202 | + case 'development' : |
|
203 | + return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
204 | 204 | |
205 | - case 'upgrade' : |
|
206 | - return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
205 | + case 'upgrade' : |
|
206 | + return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
207 | 207 | |
208 | - case 'latest' : |
|
209 | - default : |
|
210 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
208 | + case 'latest' : |
|
209 | + default : |
|
210 | + return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function get_preferred_from_update_core() { |
15 | 15 | $updates = get_core_updates(); |
16 | - if ( ! is_array( $updates ) ) |
|
16 | + if ( ! is_array($updates)) |
|
17 | 17 | return false; |
18 | - if ( empty( $updates ) ) |
|
19 | - return (object) array( 'response' => 'latest' ); |
|
18 | + if (empty($updates)) |
|
19 | + return (object) array('response' => 'latest'); |
|
20 | 20 | return $updates[0]; |
21 | 21 | } |
22 | 22 | |
@@ -27,31 +27,31 @@ discard block |
||
27 | 27 | * set $options['available'] to false to skip not-dismissed updates. |
28 | 28 | * @return array|false Array of the update objects on success, false on failure. |
29 | 29 | */ |
30 | -function get_core_updates( $options = array() ) { |
|
31 | - $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
|
32 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
30 | +function get_core_updates($options = array()) { |
|
31 | + $options = array_merge(array('available' => true, 'dismissed' => false), $options); |
|
32 | + $dismissed = get_site_option('dismissed_update_core'); |
|
33 | 33 | |
34 | - if ( ! is_array( $dismissed ) ) |
|
34 | + if ( ! is_array($dismissed)) |
|
35 | 35 | $dismissed = array(); |
36 | 36 | |
37 | - $from_api = get_site_transient( 'update_core' ); |
|
37 | + $from_api = get_site_transient('update_core'); |
|
38 | 38 | |
39 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
39 | + if ( ! isset($from_api->updates) || ! is_array($from_api->updates)) |
|
40 | 40 | return false; |
41 | 41 | |
42 | 42 | $updates = $from_api->updates; |
43 | 43 | $result = array(); |
44 | - foreach ( $updates as $update ) { |
|
45 | - if ( $update->response == 'autoupdate' ) |
|
44 | + foreach ($updates as $update) { |
|
45 | + if ($update->response == 'autoupdate') |
|
46 | 46 | continue; |
47 | 47 | |
48 | - if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
|
49 | - if ( $options['dismissed'] ) { |
|
48 | + if (array_key_exists($update->current.'|'.$update->locale, $dismissed)) { |
|
49 | + if ($options['dismissed']) { |
|
50 | 50 | $update->dismissed = true; |
51 | 51 | $result[] = $update; |
52 | 52 | } |
53 | 53 | } else { |
54 | - if ( $options['available'] ) { |
|
54 | + if ($options['available']) { |
|
55 | 55 | $update->dismissed = false; |
56 | 56 | $result[] = $update; |
57 | 57 | } |
@@ -70,22 +70,22 @@ discard block |
||
70 | 70 | * @return array|false False on failure, otherwise the core update offering. |
71 | 71 | */ |
72 | 72 | function find_core_auto_update() { |
73 | - $updates = get_site_transient( 'update_core' ); |
|
74 | - if ( ! $updates || empty( $updates->updates ) ) |
|
73 | + $updates = get_site_transient('update_core'); |
|
74 | + if ( ! $updates || empty($updates->updates)) |
|
75 | 75 | return false; |
76 | 76 | |
77 | - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
77 | + include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); |
|
78 | 78 | |
79 | 79 | $auto_update = false; |
80 | 80 | $upgrader = new WP_Automatic_Updater; |
81 | - foreach ( $updates->updates as $update ) { |
|
82 | - if ( 'autoupdate' != $update->response ) |
|
81 | + foreach ($updates->updates as $update) { |
|
82 | + if ('autoupdate' != $update->response) |
|
83 | 83 | continue; |
84 | 84 | |
85 | - if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) |
|
85 | + if ( ! $upgrader->should_update('core', $update, ABSPATH)) |
|
86 | 86 | continue; |
87 | 87 | |
88 | - if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) |
|
88 | + if ( ! $auto_update || version_compare($update->current, $auto_update->current, '>')) |
|
89 | 89 | $auto_update = $update; |
90 | 90 | } |
91 | 91 | return $auto_update; |
@@ -100,29 +100,29 @@ discard block |
||
100 | 100 | * @param string $locale Locale to query. |
101 | 101 | * @return bool|array False on failure. An array of checksums on success. |
102 | 102 | */ |
103 | -function get_core_checksums( $version, $locale ) { |
|
104 | - $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); |
|
103 | +function get_core_checksums($version, $locale) { |
|
104 | + $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?'.http_build_query(compact('version', 'locale'), null, '&'); |
|
105 | 105 | |
106 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
107 | - $url = set_url_scheme( $url, 'https' ); |
|
106 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
107 | + $url = set_url_scheme($url, 'https'); |
|
108 | 108 | |
109 | 109 | $options = array( |
110 | - 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
|
110 | + 'timeout' => ((defined('DOING_CRON') && DOING_CRON) ? 30 : 3), |
|
111 | 111 | ); |
112 | 112 | |
113 | - $response = wp_remote_get( $url, $options ); |
|
114 | - if ( $ssl && is_wp_error( $response ) ) { |
|
115 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
116 | - $response = wp_remote_get( $http_url, $options ); |
|
113 | + $response = wp_remote_get($url, $options); |
|
114 | + if ($ssl && is_wp_error($response)) { |
|
115 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
116 | + $response = wp_remote_get($http_url, $options); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
119 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) |
|
120 | 120 | return false; |
121 | 121 | |
122 | - $body = trim( wp_remote_retrieve_body( $response ) ); |
|
123 | - $body = json_decode( $body, true ); |
|
122 | + $body = trim(wp_remote_retrieve_body($response)); |
|
123 | + $body = json_decode($body, true); |
|
124 | 124 | |
125 | - if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) |
|
125 | + if ( ! is_array($body) || ! isset($body['checksums']) || ! is_array($body['checksums'])) |
|
126 | 126 | return false; |
127 | 127 | |
128 | 128 | return $body['checksums']; |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | * @param object $update |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | -function dismiss_core_update( $update ) { |
|
137 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
138 | - $dismissed[ $update->current . '|' . $update->locale ] = true; |
|
139 | - return update_site_option( 'dismissed_update_core', $dismissed ); |
|
136 | +function dismiss_core_update($update) { |
|
137 | + $dismissed = get_site_option('dismissed_update_core'); |
|
138 | + $dismissed[$update->current.'|'.$update->locale] = true; |
|
139 | + return update_site_option('dismissed_update_core', $dismissed); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @param string $locale |
146 | 146 | * @return bool |
147 | 147 | */ |
148 | -function undismiss_core_update( $version, $locale ) { |
|
149 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
150 | - $key = $version . '|' . $locale; |
|
148 | +function undismiss_core_update($version, $locale) { |
|
149 | + $dismissed = get_site_option('dismissed_update_core'); |
|
150 | + $key = $version.'|'.$locale; |
|
151 | 151 | |
152 | - if ( ! isset( $dismissed[$key] ) ) |
|
152 | + if ( ! isset($dismissed[$key])) |
|
153 | 153 | return false; |
154 | 154 | |
155 | - unset( $dismissed[$key] ); |
|
156 | - return update_site_option( 'dismissed_update_core', $dismissed ); |
|
155 | + unset($dismissed[$key]); |
|
156 | + return update_site_option('dismissed_update_core', $dismissed); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | * @param string $locale |
163 | 163 | * @return object|false |
164 | 164 | */ |
165 | -function find_core_update( $version, $locale ) { |
|
166 | - $from_api = get_site_transient( 'update_core' ); |
|
165 | +function find_core_update($version, $locale) { |
|
166 | + $from_api = get_site_transient('update_core'); |
|
167 | 167 | |
168 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
168 | + if ( ! isset($from_api->updates) || ! is_array($from_api->updates)) |
|
169 | 169 | return false; |
170 | 170 | |
171 | 171 | $updates = $from_api->updates; |
172 | - foreach ( $updates as $update ) { |
|
173 | - if ( $update->current == $version && $update->locale == $locale ) |
|
172 | + foreach ($updates as $update) { |
|
173 | + if ($update->current == $version && $update->locale == $locale) |
|
174 | 174 | return $update; |
175 | 175 | } |
176 | 176 | return false; |
@@ -181,33 +181,33 @@ discard block |
||
181 | 181 | * @param string $msg |
182 | 182 | * @return string |
183 | 183 | */ |
184 | -function core_update_footer( $msg = '' ) { |
|
185 | - if ( !current_user_can('update_core') ) |
|
186 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
184 | +function core_update_footer($msg = '') { |
|
185 | + if ( ! current_user_can('update_core')) |
|
186 | + return sprintf(__('Version %s'), get_bloginfo('version', 'display')); |
|
187 | 187 | |
188 | 188 | $cur = get_preferred_from_update_core(); |
189 | - if ( ! is_object( $cur ) ) |
|
189 | + if ( ! is_object($cur)) |
|
190 | 190 | $cur = new stdClass; |
191 | 191 | |
192 | - if ( ! isset( $cur->current ) ) |
|
192 | + if ( ! isset($cur->current)) |
|
193 | 193 | $cur->current = ''; |
194 | 194 | |
195 | - if ( ! isset( $cur->url ) ) |
|
195 | + if ( ! isset($cur->url)) |
|
196 | 196 | $cur->url = ''; |
197 | 197 | |
198 | - if ( ! isset( $cur->response ) ) |
|
198 | + if ( ! isset($cur->response)) |
|
199 | 199 | $cur->response = ''; |
200 | 200 | |
201 | - switch ( $cur->response ) { |
|
201 | + switch ($cur->response) { |
|
202 | 202 | case 'development' : |
203 | - return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
203 | + return sprintf(__('You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.'), get_bloginfo('version', 'display'), network_admin_url('update-core.php')); |
|
204 | 204 | |
205 | 205 | case 'upgrade' : |
206 | - return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
206 | + return '<strong><a href="'.network_admin_url('update-core.php').'">'.sprintf(__('Get Version %s'), $cur->current).'</a></strong>'; |
|
207 | 207 | |
208 | 208 | case 'latest' : |
209 | 209 | default : |
210 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
210 | + return sprintf(__('Version %s'), get_bloginfo('version', 'display')); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
@@ -217,23 +217,23 @@ discard block |
||
217 | 217 | * @return false|void |
218 | 218 | */ |
219 | 219 | function update_nag() { |
220 | - if ( is_multisite() && !current_user_can('update_core') ) |
|
220 | + if (is_multisite() && ! current_user_can('update_core')) |
|
221 | 221 | return false; |
222 | 222 | |
223 | 223 | global $pagenow; |
224 | 224 | |
225 | - if ( 'update-core.php' == $pagenow ) |
|
225 | + if ('update-core.php' == $pagenow) |
|
226 | 226 | return; |
227 | 227 | |
228 | 228 | $cur = get_preferred_from_update_core(); |
229 | 229 | |
230 | - if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
|
230 | + if ( ! isset($cur->response) || $cur->response != 'upgrade') |
|
231 | 231 | return false; |
232 | 232 | |
233 | - if ( current_user_can('update_core') ) { |
|
234 | - $msg = sprintf( __( '<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s" aria-label="Please update WordPress now">Please update now</a>.' ), $cur->current, network_admin_url( 'update-core.php' ) ); |
|
233 | + if (current_user_can('update_core')) { |
|
234 | + $msg = sprintf(__('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s" aria-label="Please update WordPress now">Please update now</a>.'), $cur->current, network_admin_url('update-core.php')); |
|
235 | 235 | } else { |
236 | - $msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current ); |
|
236 | + $msg = sprintf(__('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current); |
|
237 | 237 | } |
238 | 238 | echo "<div class='update-nag'>$msg</div>"; |
239 | 239 | } |
@@ -241,21 +241,21 @@ discard block |
||
241 | 241 | // Called directly from dashboard |
242 | 242 | function update_right_now_message() { |
243 | 243 | $theme_name = wp_get_theme(); |
244 | - if ( current_user_can( 'switch_themes' ) ) { |
|
245 | - $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); |
|
244 | + if (current_user_can('switch_themes')) { |
|
245 | + $theme_name = sprintf('<a href="themes.php">%1$s</a>', $theme_name); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | $msg = ''; |
249 | 249 | |
250 | - if ( current_user_can('update_core') ) { |
|
250 | + if (current_user_can('update_core')) { |
|
251 | 251 | $cur = get_preferred_from_update_core(); |
252 | 252 | |
253 | - if ( isset( $cur->response ) && $cur->response == 'upgrade' ) |
|
254 | - $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
|
253 | + if (isset($cur->response) && $cur->response == 'upgrade') |
|
254 | + $msg .= '<a href="'.network_admin_url('update-core.php').'" class="button" aria-describedby="wp-version">'.sprintf(__('Update to %s'), $cur->current ? $cur->current : __('Latest')).'</a> '; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /* translators: 1: version number, 2: theme name */ |
258 | - $content = __( 'WordPress %1$s running %2$s theme.' ); |
|
258 | + $content = __('WordPress %1$s running %2$s theme.'); |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Filter the text displayed in the 'At a Glance' dashboard widget. |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @param string $content Default text. |
268 | 268 | */ |
269 | - $content = apply_filters( 'update_right_now_text', $content ); |
|
269 | + $content = apply_filters('update_right_now_text', $content); |
|
270 | 270 | |
271 | - $msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); |
|
271 | + $msg .= sprintf('<span id="wp-version">'.$content.'</span>', get_bloginfo('version', 'display'), $theme_name); |
|
272 | 272 | |
273 | 273 | echo "<p id='wp-version-message'>$msg</p>"; |
274 | 274 | } |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | function get_plugin_updates() { |
282 | 282 | $all_plugins = get_plugins(); |
283 | 283 | $upgrade_plugins = array(); |
284 | - $current = get_site_transient( 'update_plugins' ); |
|
285 | - foreach ( (array)$all_plugins as $plugin_file => $plugin_data) { |
|
286 | - if ( isset( $current->response[ $plugin_file ] ) ) { |
|
287 | - $upgrade_plugins[ $plugin_file ] = (object) $plugin_data; |
|
288 | - $upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ]; |
|
284 | + $current = get_site_transient('update_plugins'); |
|
285 | + foreach ((array) $all_plugins as $plugin_file => $plugin_data) { |
|
286 | + if (isset($current->response[$plugin_file])) { |
|
287 | + $upgrade_plugins[$plugin_file] = (object) $plugin_data; |
|
288 | + $upgrade_plugins[$plugin_file]->update = $current->response[$plugin_file]; |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | * @since 2.9.0 |
297 | 297 | */ |
298 | 298 | function wp_plugin_update_rows() { |
299 | - if ( !current_user_can('update_plugins' ) ) |
|
299 | + if ( ! current_user_can('update_plugins')) |
|
300 | 300 | return; |
301 | 301 | |
302 | - $plugins = get_site_transient( 'update_plugins' ); |
|
303 | - if ( isset($plugins->response) && is_array($plugins->response) ) { |
|
304 | - $plugins = array_keys( $plugins->response ); |
|
305 | - foreach ( $plugins as $plugin_file ) { |
|
306 | - add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 ); |
|
302 | + $plugins = get_site_transient('update_plugins'); |
|
303 | + if (isset($plugins->response) && is_array($plugins->response)) { |
|
304 | + $plugins = array_keys($plugins->response); |
|
305 | + foreach ($plugins as $plugin_file) { |
|
306 | + add_action("after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | } |
@@ -314,58 +314,58 @@ discard block |
||
314 | 314 | * @param array $plugin_data |
315 | 315 | * @return false|void |
316 | 316 | */ |
317 | -function wp_plugin_update_row( $file, $plugin_data ) { |
|
318 | - $current = get_site_transient( 'update_plugins' ); |
|
319 | - if ( !isset( $current->response[ $file ] ) ) |
|
317 | +function wp_plugin_update_row($file, $plugin_data) { |
|
318 | + $current = get_site_transient('update_plugins'); |
|
319 | + if ( ! isset($current->response[$file])) |
|
320 | 320 | return false; |
321 | 321 | |
322 | - $r = $current->response[ $file ]; |
|
322 | + $r = $current->response[$file]; |
|
323 | 323 | |
324 | - $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); |
|
325 | - $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); |
|
324 | + $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array()); |
|
325 | + $plugin_name = wp_kses($plugin_data['Name'], $plugins_allowedtags); |
|
326 | 326 | |
327 | - $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '§ion=changelog&TB_iframe=true&width=600&height=800'); |
|
327 | + $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin='.$r->slug.'§ion=changelog&TB_iframe=true&width=600&height=800'); |
|
328 | 328 | |
329 | 329 | $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
330 | 330 | |
331 | - if ( is_network_admin() || !is_multisite() ) { |
|
332 | - if ( is_network_admin() ) { |
|
333 | - $active_class = is_plugin_active_for_network( $file ) ? ' active': ''; |
|
331 | + if (is_network_admin() || ! is_multisite()) { |
|
332 | + if (is_network_admin()) { |
|
333 | + $active_class = is_plugin_active_for_network($file) ? ' active' : ''; |
|
334 | 334 | } else { |
335 | - $active_class = is_plugin_active( $file ) ? ' active' : ''; |
|
335 | + $active_class = is_plugin_active($file) ? ' active' : ''; |
|
336 | 336 | } |
337 | 337 | |
338 | - echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $r->slug . '-update' ) . '" data-slug="' . esc_attr( $r->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
338 | + echo '<tr class="plugin-update-tr'.$active_class.'" id="'.esc_attr($r->slug.'-update').'" data-slug="'.esc_attr($r->slug).'" data-plugin="'.esc_attr($file).'"><td colspan="'.esc_attr($wp_list_table->get_column_count()).'" class="plugin-update colspanchange"><div class="update-message">'; |
|
339 | 339 | |
340 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
340 | + if ( ! current_user_can('update_plugins')) { |
|
341 | 341 | /* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number */ |
342 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.' ), |
|
342 | + printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'), |
|
343 | 343 | $plugin_name, |
344 | - esc_url( $details_url ), |
|
344 | + esc_url($details_url), |
|
345 | 345 | /* translators: 1: plugin name, 2: version number */ |
346 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ), |
|
346 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $r->new_version)), |
|
347 | 347 | $r->new_version |
348 | 348 | ); |
349 | - } elseif ( empty( $r->package ) ) { |
|
349 | + } elseif (empty($r->package)) { |
|
350 | 350 | /* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number */ |
351 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ), |
|
351 | + printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), |
|
352 | 352 | $plugin_name, |
353 | - esc_url( $details_url ), |
|
353 | + esc_url($details_url), |
|
354 | 354 | /* translators: 1: plugin name, 2: version number */ |
355 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ), |
|
355 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $r->new_version)), |
|
356 | 356 | $r->new_version |
357 | 357 | ); |
358 | 358 | } else { |
359 | 359 | /* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */ |
360 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.' ), |
|
360 | + printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.'), |
|
361 | 361 | $plugin_name, |
362 | - esc_url( $details_url ), |
|
362 | + esc_url($details_url), |
|
363 | 363 | /* translators: 1: plugin name, 2: version number */ |
364 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ), |
|
364 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $r->new_version)), |
|
365 | 365 | $r->new_version, |
366 | - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), |
|
366 | + wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$file, 'upgrade-plugin_'.$file), |
|
367 | 367 | /* translators: %s: plugin name */ |
368 | - esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) |
|
368 | + esc_attr(sprintf(__('Update %s now'), $plugin_name)) |
|
369 | 369 | ); |
370 | 370 | } |
371 | 371 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @type string $package Plugin update package URL. |
404 | 404 | * } |
405 | 405 | */ |
406 | - do_action( "in_plugin_update_message-{$file}", $plugin_data, $r ); |
|
406 | + do_action("in_plugin_update_message-{$file}", $plugin_data, $r); |
|
407 | 407 | |
408 | 408 | echo '</div></td></tr>'; |
409 | 409 | } |
@@ -416,13 +416,13 @@ discard block |
||
416 | 416 | function get_theme_updates() { |
417 | 417 | $current = get_site_transient('update_themes'); |
418 | 418 | |
419 | - if ( ! isset( $current->response ) ) |
|
419 | + if ( ! isset($current->response)) |
|
420 | 420 | return array(); |
421 | 421 | |
422 | 422 | $update_themes = array(); |
423 | - foreach ( $current->response as $stylesheet => $data ) { |
|
424 | - $update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); |
|
425 | - $update_themes[ $stylesheet ]->update = $data; |
|
423 | + foreach ($current->response as $stylesheet => $data) { |
|
424 | + $update_themes[$stylesheet] = wp_get_theme($stylesheet); |
|
425 | + $update_themes[$stylesheet]->update = $data; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | return $update_themes; |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | * @since 3.1.0 |
433 | 433 | */ |
434 | 434 | function wp_theme_update_rows() { |
435 | - if ( !current_user_can('update_themes' ) ) |
|
435 | + if ( ! current_user_can('update_themes')) |
|
436 | 436 | return; |
437 | 437 | |
438 | - $themes = get_site_transient( 'update_themes' ); |
|
439 | - if ( isset($themes->response) && is_array($themes->response) ) { |
|
440 | - $themes = array_keys( $themes->response ); |
|
438 | + $themes = get_site_transient('update_themes'); |
|
439 | + if (isset($themes->response) && is_array($themes->response)) { |
|
440 | + $themes = array_keys($themes->response); |
|
441 | 441 | |
442 | - foreach ( $themes as $theme ) { |
|
443 | - add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 ); |
|
442 | + foreach ($themes as $theme) { |
|
443 | + add_action("after_theme_row_$theme", 'wp_theme_update_row', 10, 2); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
@@ -451,51 +451,51 @@ discard block |
||
451 | 451 | * @param WP_Theme $theme |
452 | 452 | * @return false|void |
453 | 453 | */ |
454 | -function wp_theme_update_row( $theme_key, $theme ) { |
|
455 | - $current = get_site_transient( 'update_themes' ); |
|
456 | - if ( !isset( $current->response[ $theme_key ] ) ) |
|
454 | +function wp_theme_update_row($theme_key, $theme) { |
|
455 | + $current = get_site_transient('update_themes'); |
|
456 | + if ( ! isset($current->response[$theme_key])) |
|
457 | 457 | return false; |
458 | 458 | |
459 | - $r = $current->response[ $theme_key ]; |
|
459 | + $r = $current->response[$theme_key]; |
|
460 | 460 | |
461 | 461 | $theme_name = $theme['Name']; |
462 | 462 | |
463 | - $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] ); |
|
463 | + $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $current->response[$theme_key]['url']); |
|
464 | 464 | |
465 | 465 | $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); |
466 | 466 | |
467 | - $active = $theme->is_allowed( 'network' ) ? ' active': ''; |
|
467 | + $active = $theme->is_allowed('network') ? ' active' : ''; |
|
468 | 468 | |
469 | - echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
470 | - if ( ! current_user_can('update_themes') ) { |
|
469 | + echo '<tr class="plugin-update-tr'.$active.'" id="'.esc_attr($theme->get_stylesheet().'-update').'" data-slug="'.esc_attr($theme->get_stylesheet()).'"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">'; |
|
470 | + if ( ! current_user_can('update_themes')) { |
|
471 | 471 | /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */ |
472 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'), |
|
472 | + printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'), |
|
473 | 473 | $theme_name, |
474 | - esc_url( $details_url ), |
|
474 | + esc_url($details_url), |
|
475 | 475 | /* translators: 1: theme name, 2: version number */ |
476 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ), |
|
476 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])), |
|
477 | 477 | $r['new_version'] |
478 | 478 | ); |
479 | - } elseif ( empty( $r['package'] ) ) { |
|
479 | + } elseif (empty($r['package'])) { |
|
480 | 480 | /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */ |
481 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ), |
|
481 | + printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), |
|
482 | 482 | $theme_name, |
483 | - esc_url( $details_url ), |
|
483 | + esc_url($details_url), |
|
484 | 484 | /* translators: 1: theme name, 2: version number */ |
485 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ), |
|
485 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])), |
|
486 | 486 | $r['new_version'] |
487 | 487 | ); |
488 | 488 | } else { |
489 | 489 | /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */ |
490 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.' ), |
|
490 | + printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.'), |
|
491 | 491 | $theme_name, |
492 | - esc_url( $details_url ), |
|
492 | + esc_url($details_url), |
|
493 | 493 | /* translators: 1: theme name, 2: version number */ |
494 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ), |
|
494 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])), |
|
495 | 495 | $r['new_version'], |
496 | - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), |
|
496 | + wp_nonce_url(self_admin_url('update.php?action=upgrade-theme&theme=').$theme_key, 'upgrade-theme_'.$theme_key), |
|
497 | 497 | /* translators: %s: theme name */ |
498 | - esc_attr( sprintf( __( 'Update %s now' ), $theme_name ) ) |
|
498 | + esc_attr(sprintf(__('Update %s now'), $theme_name)) |
|
499 | 499 | ); |
500 | 500 | } |
501 | 501 | /** |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @type string $package Theme update package URL. |
517 | 517 | * } |
518 | 518 | */ |
519 | - do_action( "in_theme_update_message-{$theme_key}", $theme, $r ); |
|
519 | + do_action("in_theme_update_message-{$theme_key}", $theme, $r); |
|
520 | 520 | |
521 | 521 | echo '</div></td></tr>'; |
522 | 522 | } |
@@ -527,11 +527,11 @@ discard block |
||
527 | 527 | * @return false|void |
528 | 528 | */ |
529 | 529 | function maintenance_nag() { |
530 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
530 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
531 | 531 | global $upgrading; |
532 | - $nag = isset( $upgrading ); |
|
533 | - if ( ! $nag ) { |
|
534 | - $failed = get_site_option( 'auto_core_update_failed' ); |
|
532 | + $nag = isset($upgrading); |
|
533 | + if ( ! $nag) { |
|
534 | + $failed = get_site_option('auto_core_update_failed'); |
|
535 | 535 | /* |
536 | 536 | * If an update failed critically, we may have copied over version.php but not other files. |
537 | 537 | * In that case, if the install claims we're running the version we attempted, nag. |
@@ -542,16 +542,16 @@ discard block |
||
542 | 542 | * |
543 | 543 | * This flag is cleared whenever a successful update occurs using Core_Upgrader. |
544 | 544 | */ |
545 | - $comparison = ! empty( $failed['critical'] ) ? '>=' : '>'; |
|
546 | - if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) |
|
545 | + $comparison = ! empty($failed['critical']) ? '>=' : '>'; |
|
546 | + if (version_compare($failed['attempted'], $wp_version, $comparison)) |
|
547 | 547 | $nag = true; |
548 | 548 | } |
549 | 549 | |
550 | - if ( ! $nag ) |
|
550 | + if ( ! $nag) |
|
551 | 551 | return false; |
552 | 552 | |
553 | - if ( current_user_can('update_core') ) |
|
554 | - $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' ); |
|
553 | + if (current_user_can('update_core')) |
|
554 | + $msg = sprintf(__('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php'); |
|
555 | 555 | else |
556 | 556 | $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); |
557 | 557 |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param array $args An associative array of arguments. |
24 | 24 | */ |
25 | - public function __construct( $args = array() ) { |
|
26 | - parent::__construct( array( |
|
25 | + public function __construct($args = array()) { |
|
26 | + parent::__construct(array( |
|
27 | 27 | 'ajax' => true, |
28 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
29 | - ) ); |
|
28 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
29 | + )); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -35,85 +35,85 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function ajax_user_can() { |
37 | 37 | // Do not check edit_theme_options here. AJAX calls for available themes require switch_themes. |
38 | - return current_user_can( 'switch_themes' ); |
|
38 | + return current_user_can('switch_themes'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @access public |
43 | 43 | */ |
44 | 44 | public function prepare_items() { |
45 | - $themes = wp_get_themes( array( 'allowed' => true ) ); |
|
45 | + $themes = wp_get_themes(array('allowed' => true)); |
|
46 | 46 | |
47 | - if ( ! empty( $_REQUEST['s'] ) ) |
|
48 | - $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); |
|
47 | + if ( ! empty($_REQUEST['s'])) |
|
48 | + $this->search_terms = array_unique(array_filter(array_map('trim', explode(',', strtolower(wp_unslash($_REQUEST['s'])))))); |
|
49 | 49 | |
50 | - if ( ! empty( $_REQUEST['features'] ) ) |
|
50 | + if ( ! empty($_REQUEST['features'])) |
|
51 | 51 | $this->features = $_REQUEST['features']; |
52 | 52 | |
53 | - if ( $this->search_terms || $this->features ) { |
|
54 | - foreach ( $themes as $key => $theme ) { |
|
55 | - if ( ! $this->search_theme( $theme ) ) |
|
56 | - unset( $themes[ $key ] ); |
|
53 | + if ($this->search_terms || $this->features) { |
|
54 | + foreach ($themes as $key => $theme) { |
|
55 | + if ( ! $this->search_theme($theme)) |
|
56 | + unset($themes[$key]); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - unset( $themes[ get_option( 'stylesheet' ) ] ); |
|
61 | - WP_Theme::sort_by_name( $themes ); |
|
60 | + unset($themes[get_option('stylesheet')]); |
|
61 | + WP_Theme::sort_by_name($themes); |
|
62 | 62 | |
63 | 63 | $per_page = 36; |
64 | 64 | $page = $this->get_pagenum(); |
65 | 65 | |
66 | - $start = ( $page - 1 ) * $per_page; |
|
66 | + $start = ($page - 1) * $per_page; |
|
67 | 67 | |
68 | - $this->items = array_slice( $themes, $start, $per_page, true ); |
|
68 | + $this->items = array_slice($themes, $start, $per_page, true); |
|
69 | 69 | |
70 | - $this->set_pagination_args( array( |
|
71 | - 'total_items' => count( $themes ), |
|
70 | + $this->set_pagination_args(array( |
|
71 | + 'total_items' => count($themes), |
|
72 | 72 | 'per_page' => $per_page, |
73 | 73 | 'infinite_scroll' => true, |
74 | - ) ); |
|
74 | + )); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @access public |
79 | 79 | */ |
80 | 80 | public function no_items() { |
81 | - if ( $this->search_terms || $this->features ) { |
|
82 | - _e( 'No items found.' ); |
|
81 | + if ($this->search_terms || $this->features) { |
|
82 | + _e('No items found.'); |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | - if ( is_multisite() ) { |
|
87 | - if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { |
|
88 | - printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ), network_admin_url( 'theme-install.php' ) ); |
|
86 | + if (is_multisite()) { |
|
87 | + if (current_user_can('install_themes') && current_user_can('manage_network_themes')) { |
|
88 | + printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.'), network_admin_url('site-themes.php?id='.$GLOBALS['blog_id']), network_admin_url('theme-install.php')); |
|
89 | 89 | |
90 | 90 | return; |
91 | - } elseif ( current_user_can( 'manage_network_themes' ) ) { |
|
92 | - printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ) ); |
|
91 | + } elseif (current_user_can('manage_network_themes')) { |
|
92 | + printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.'), network_admin_url('site-themes.php?id='.$GLOBALS['blog_id'])); |
|
93 | 93 | |
94 | 94 | return; |
95 | 95 | } |
96 | 96 | // Else, fallthrough. install_themes doesn't help if you can't enable it. |
97 | 97 | } else { |
98 | - if ( current_user_can( 'install_themes' ) ) { |
|
99 | - printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), admin_url( 'theme-install.php' ) ); |
|
98 | + if (current_user_can('install_themes')) { |
|
99 | + printf(__('You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.'), admin_url('theme-install.php')); |
|
100 | 100 | |
101 | 101 | return; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | // Fallthrough. |
105 | - printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) ); |
|
105 | + printf(__('Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.'), get_site_option('site_name')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * @param string $which |
110 | 110 | */ |
111 | - public function tablenav( $which = 'top' ) { |
|
112 | - if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) |
|
111 | + public function tablenav($which = 'top') { |
|
112 | + if ($this->get_pagination_arg('total_pages') <= 1) |
|
113 | 113 | return; |
114 | 114 | ?> |
115 | 115 | <div class="tablenav themes <?php echo $which; ?>"> |
116 | - <?php $this->pagination( $which ); ?> |
|
116 | + <?php $this->pagination($which); ?> |
|
117 | 117 | <span class="spinner"></span> |
118 | 118 | <br class="clear" /> |
119 | 119 | </div> |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | * @access public |
125 | 125 | */ |
126 | 126 | public function display() { |
127 | - wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); |
|
127 | + wp_nonce_field("fetch-list-".get_class($this), '_ajax_fetch_list_nonce'); |
|
128 | 128 | ?> |
129 | - <?php $this->tablenav( 'top' ); ?> |
|
129 | + <?php $this->tablenav('top'); ?> |
|
130 | 130 | |
131 | 131 | <div id="availablethemes"> |
132 | 132 | <?php $this->display_rows_or_placeholder(); ?> |
133 | 133 | </div> |
134 | 134 | |
135 | - <?php $this->tablenav( 'bottom' ); ?> |
|
135 | + <?php $this->tablenav('bottom'); ?> |
|
136 | 136 | <?php |
137 | 137 | } |
138 | 138 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @access public |
149 | 149 | */ |
150 | 150 | public function display_rows_or_placeholder() { |
151 | - if ( $this->has_items() ) { |
|
151 | + if ($this->has_items()) { |
|
152 | 152 | $this->display_rows(); |
153 | 153 | } else { |
154 | 154 | echo '<div class="no-items">'; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | public function display_rows() { |
164 | 164 | $themes = $this->items; |
165 | 165 | |
166 | - foreach ( $themes as $theme ): |
|
166 | + foreach ($themes as $theme): |
|
167 | 167 | ?><div class="available-theme"><?php |
168 | 168 | |
169 | 169 | $template = $theme->get_template(); |
@@ -172,64 +172,64 @@ discard block |
||
172 | 172 | $version = $theme->display('Version'); |
173 | 173 | $author = $theme->display('Author'); |
174 | 174 | |
175 | - $activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); |
|
175 | + $activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_'.$stylesheet); |
|
176 | 176 | |
177 | 177 | $actions = array(); |
178 | - $actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="' |
|
179 | - . esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>'; |
|
178 | + $actions['activate'] = '<a href="'.$activate_link.'" class="activatelink" title="' |
|
179 | + . esc_attr(sprintf(__('Activate “%s”'), $title)).'">'.__('Activate').'</a>'; |
|
180 | 180 | |
181 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
182 | - $actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="load-customize hide-if-no-customize">' |
|
183 | - . __( 'Live Preview' ) . '</a>'; |
|
181 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
182 | + $actions['preview'] .= '<a href="'.wp_customize_url($stylesheet).'" class="load-customize hide-if-no-customize">' |
|
183 | + . __('Live Preview').'</a>'; |
|
184 | 184 | } |
185 | 185 | |
186 | - if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) |
|
187 | - $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) |
|
188 | - . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ) |
|
189 | - . "' );" . '">' . __( 'Delete' ) . '</a>'; |
|
186 | + if ( ! is_multisite() && current_user_can('delete_themes')) |
|
187 | + $actions['delete'] = '<a class="submitdelete deletion" href="'.wp_nonce_url('themes.php?action=delete&stylesheet='.urlencode($stylesheet), 'delete-theme_'.$stylesheet) |
|
188 | + . '" onclick="'."return confirm( '".esc_js(sprintf(__("You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete."), $title)) |
|
189 | + . "' );".'">'.__('Delete').'</a>'; |
|
190 | 190 | |
191 | 191 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
192 | - $actions = apply_filters( 'theme_action_links', $actions, $theme ); |
|
192 | + $actions = apply_filters('theme_action_links', $actions, $theme); |
|
193 | 193 | |
194 | 194 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
195 | - $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme ); |
|
196 | - $delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : ''; |
|
197 | - unset( $actions['delete'] ); |
|
195 | + $actions = apply_filters("theme_action_links_$stylesheet", $actions, $theme); |
|
196 | + $delete_action = isset($actions['delete']) ? '<div class="delete-theme">'.$actions['delete'].'</div>' : ''; |
|
197 | + unset($actions['delete']); |
|
198 | 198 | |
199 | 199 | ?> |
200 | 200 | |
201 | 201 | <span class="screenshot hide-if-customize"> |
202 | - <?php if ( $screenshot = $theme->get_screenshot() ) : ?> |
|
203 | - <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
|
202 | + <?php if ($screenshot = $theme->get_screenshot()) : ?> |
|
203 | + <img src="<?php echo esc_url($screenshot); ?>" alt="" /> |
|
204 | 204 | <?php endif; ?> |
205 | 205 | </span> |
206 | - <a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize"> |
|
207 | - <?php if ( $screenshot = $theme->get_screenshot() ) : ?> |
|
208 | - <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
|
206 | + <a href="<?php echo wp_customize_url($stylesheet); ?>" class="screenshot load-customize hide-if-no-customize"> |
|
207 | + <?php if ($screenshot = $theme->get_screenshot()) : ?> |
|
208 | + <img src="<?php echo esc_url($screenshot); ?>" alt="" /> |
|
209 | 209 | <?php endif; ?> |
210 | 210 | </a> |
211 | 211 | |
212 | 212 | <h3><?php echo $title; ?></h3> |
213 | - <div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div> |
|
213 | + <div class="theme-author"><?php printf(__('By %s'), $author); ?></div> |
|
214 | 214 | <div class="action-links"> |
215 | 215 | <ul> |
216 | - <?php foreach ( $actions as $action ): ?> |
|
216 | + <?php foreach ($actions as $action): ?> |
|
217 | 217 | <li><?php echo $action; ?></li> |
218 | 218 | <?php endforeach; ?> |
219 | 219 | <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details') ?></a></li> |
220 | 220 | </ul> |
221 | 221 | <?php echo $delete_action; ?> |
222 | 222 | |
223 | - <?php theme_update_available( $theme ); ?> |
|
223 | + <?php theme_update_available($theme); ?> |
|
224 | 224 | </div> |
225 | 225 | |
226 | 226 | <div class="themedetaildiv hide-if-js"> |
227 | 227 | <p><strong><?php _e('Version:'); ?></strong> <?php echo $version; ?></p> |
228 | 228 | <p><?php echo $theme->display('Description'); ?></p> |
229 | - <?php if ( $theme->parent() ) { |
|
230 | - printf( ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>', |
|
231 | - __( 'https://codex.wordpress.org/Child_Themes' ), |
|
232 | - $theme->parent()->display( 'Name' ) ); |
|
229 | + <?php if ($theme->parent()) { |
|
230 | + printf(' <p class="howto">'.__('This <a href="%1$s">child theme</a> requires its parent theme, %2$s.').'</p>', |
|
231 | + __('https://codex.wordpress.org/Child_Themes'), |
|
232 | + $theme->parent()->display('Name')); |
|
233 | 233 | } ?> |
234 | 234 | </div> |
235 | 235 | |
@@ -242,29 +242,29 @@ discard block |
||
242 | 242 | * @param WP_Theme $theme |
243 | 243 | * @return bool |
244 | 244 | */ |
245 | - public function search_theme( $theme ) { |
|
245 | + public function search_theme($theme) { |
|
246 | 246 | // Search the features |
247 | - foreach ( $this->features as $word ) { |
|
248 | - if ( ! in_array( $word, $theme->get('Tags') ) ) |
|
247 | + foreach ($this->features as $word) { |
|
248 | + if ( ! in_array($word, $theme->get('Tags'))) |
|
249 | 249 | return false; |
250 | 250 | } |
251 | 251 | |
252 | 252 | // Match all phrases |
253 | - foreach ( $this->search_terms as $word ) { |
|
254 | - if ( in_array( $word, $theme->get('Tags') ) ) |
|
253 | + foreach ($this->search_terms as $word) { |
|
254 | + if (in_array($word, $theme->get('Tags'))) |
|
255 | 255 | continue; |
256 | 256 | |
257 | - foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { |
|
257 | + foreach (array('Name', 'Description', 'Author', 'AuthorURI') as $header) { |
|
258 | 258 | // Don't mark up; Do translate. |
259 | - if ( false !== stripos( strip_tags( $theme->display( $header, false, true ) ), $word ) ) { |
|
259 | + if (false !== stripos(strip_tags($theme->display($header, false, true)), $word)) { |
|
260 | 260 | continue 2; |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( false !== stripos( $theme->get_stylesheet(), $word ) ) |
|
264 | + if (false !== stripos($theme->get_stylesheet(), $word)) |
|
265 | 265 | continue; |
266 | 266 | |
267 | - if ( false !== stripos( $theme->get_template(), $word ) ) |
|
267 | + if (false !== stripos($theme->get_template(), $word)) |
|
268 | 268 | continue; |
269 | 269 | |
270 | 270 | return false; |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @param array $extra_args |
283 | 283 | */ |
284 | - public function _js_vars( $extra_args = array() ) { |
|
285 | - $search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
284 | + public function _js_vars($extra_args = array()) { |
|
285 | + $search_string = isset($_REQUEST['s']) ? esc_attr(wp_unslash($_REQUEST['s'])) : ''; |
|
286 | 286 | |
287 | 287 | $args = array( |
288 | 288 | 'search' => $search_string, |
289 | 289 | 'features' => $this->features, |
290 | 290 | 'paged' => $this->get_pagenum(), |
291 | - 'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1, |
|
291 | + 'total_pages' => ! empty($this->_pagination_args['total_pages']) ? $this->_pagination_args['total_pages'] : 1, |
|
292 | 292 | ); |
293 | 293 | |
294 | - if ( is_array( $extra_args ) ) |
|
295 | - $args = array_merge( $args, $extra_args ); |
|
294 | + if (is_array($extra_args)) |
|
295 | + $args = array_merge($args, $extra_args); |
|
296 | 296 | |
297 | - printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) ); |
|
297 | + printf("<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode($args)); |
|
298 | 298 | parent::_js_vars(); |
299 | 299 | } |
300 | 300 | } |
@@ -44,16 +44,19 @@ discard block |
||
44 | 44 | public function prepare_items() { |
45 | 45 | $themes = wp_get_themes( array( 'allowed' => true ) ); |
46 | 46 | |
47 | - if ( ! empty( $_REQUEST['s'] ) ) |
|
48 | - $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); |
|
47 | + if ( ! empty( $_REQUEST['s'] ) ) { |
|
48 | + $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); |
|
49 | + } |
|
49 | 50 | |
50 | - if ( ! empty( $_REQUEST['features'] ) ) |
|
51 | - $this->features = $_REQUEST['features']; |
|
51 | + if ( ! empty( $_REQUEST['features'] ) ) { |
|
52 | + $this->features = $_REQUEST['features']; |
|
53 | + } |
|
52 | 54 | |
53 | 55 | if ( $this->search_terms || $this->features ) { |
54 | 56 | foreach ( $themes as $key => $theme ) { |
55 | - if ( ! $this->search_theme( $theme ) ) |
|
56 | - unset( $themes[ $key ] ); |
|
57 | + if ( ! $this->search_theme( $theme ) ) { |
|
58 | + unset( $themes[ $key ] ); |
|
59 | + } |
|
57 | 60 | } |
58 | 61 | } |
59 | 62 | |
@@ -109,8 +112,9 @@ discard block |
||
109 | 112 | * @param string $which |
110 | 113 | */ |
111 | 114 | public function tablenav( $which = 'top' ) { |
112 | - if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) |
|
113 | - return; |
|
115 | + if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) { |
|
116 | + return; |
|
117 | + } |
|
114 | 118 | ?> |
115 | 119 | <div class="tablenav themes <?php echo $which; ?>"> |
116 | 120 | <?php $this->pagination( $which ); ?> |
@@ -183,10 +187,11 @@ discard block |
||
183 | 187 | . __( 'Live Preview' ) . '</a>'; |
184 | 188 | } |
185 | 189 | |
186 | - if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) |
|
187 | - $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) |
|
190 | + if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) { |
|
191 | + $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) |
|
188 | 192 | . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ) |
189 | 193 | . "' );" . '">' . __( 'Delete' ) . '</a>'; |
194 | + } |
|
190 | 195 | |
191 | 196 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
192 | 197 | $actions = apply_filters( 'theme_action_links', $actions, $theme ); |
@@ -245,14 +250,16 @@ discard block |
||
245 | 250 | public function search_theme( $theme ) { |
246 | 251 | // Search the features |
247 | 252 | foreach ( $this->features as $word ) { |
248 | - if ( ! in_array( $word, $theme->get('Tags') ) ) |
|
249 | - return false; |
|
253 | + if ( ! in_array( $word, $theme->get('Tags') ) ) { |
|
254 | + return false; |
|
255 | + } |
|
250 | 256 | } |
251 | 257 | |
252 | 258 | // Match all phrases |
253 | 259 | foreach ( $this->search_terms as $word ) { |
254 | - if ( in_array( $word, $theme->get('Tags') ) ) |
|
255 | - continue; |
|
260 | + if ( in_array( $word, $theme->get('Tags') ) ) { |
|
261 | + continue; |
|
262 | + } |
|
256 | 263 | |
257 | 264 | foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { |
258 | 265 | // Don't mark up; Do translate. |
@@ -261,11 +268,13 @@ discard block |
||
261 | 268 | } |
262 | 269 | } |
263 | 270 | |
264 | - if ( false !== stripos( $theme->get_stylesheet(), $word ) ) |
|
265 | - continue; |
|
271 | + if ( false !== stripos( $theme->get_stylesheet(), $word ) ) { |
|
272 | + continue; |
|
273 | + } |
|
266 | 274 | |
267 | - if ( false !== stripos( $theme->get_template(), $word ) ) |
|
268 | - continue; |
|
275 | + if ( false !== stripos( $theme->get_template(), $word ) ) { |
|
276 | + continue; |
|
277 | + } |
|
269 | 278 | |
270 | 279 | return false; |
271 | 280 | } |
@@ -291,8 +300,9 @@ discard block |
||
291 | 300 | 'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1, |
292 | 301 | ); |
293 | 302 | |
294 | - if ( is_array( $extra_args ) ) |
|
295 | - $args = array_merge( $args, $extra_args ); |
|
303 | + if ( is_array( $extra_args ) ) { |
|
304 | + $args = array_merge( $args, $extra_args ); |
|
305 | + } |
|
296 | 306 | |
297 | 307 | printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) ); |
298 | 308 | parent::_js_vars(); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * List Table API: WP_Themes_List_Table class |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - * @since 3.1.0 |
|
8 | - */ |
|
3 | + * List Table API: WP_Themes_List_Table class |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + * @since 3.1.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Core class used to implement displaying installed themes in a list table. |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Administration Importer API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Administration Importer API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Retrieve list of importers. |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function get_importers() { |
18 | 18 | global $wp_importers; |
19 | - if ( is_array( $wp_importers ) ) { |
|
20 | - uasort( $wp_importers, '_usort_by_first_member' ); |
|
19 | + if (is_array($wp_importers)) { |
|
20 | + uasort($wp_importers, '_usort_by_first_member'); |
|
21 | 21 | } |
22 | 22 | return $wp_importers; |
23 | 23 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param array $b |
35 | 35 | * @return int |
36 | 36 | */ |
37 | -function _usort_by_first_member( $a, $b ) { |
|
38 | - return strnatcasecmp( $a[0], $b[0] ); |
|
37 | +function _usort_by_first_member($a, $b) { |
|
38 | + return strnatcasecmp($a[0], $b[0]); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * @param callback $callback Callback to run. |
52 | 52 | * @return WP_Error Returns WP_Error when $callback is WP_Error. |
53 | 53 | */ |
54 | -function register_importer( $id, $name, $description, $callback ) { |
|
54 | +function register_importer($id, $name, $description, $callback) { |
|
55 | 55 | global $wp_importers; |
56 | - if ( is_wp_error( $callback ) ) |
|
56 | + if (is_wp_error($callback)) |
|
57 | 57 | return $callback; |
58 | - $wp_importers[$id] = array ( $name, $description, $callback ); |
|
58 | + $wp_importers[$id] = array($name, $description, $callback); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param string $id Importer ID. |
69 | 69 | */ |
70 | -function wp_import_cleanup( $id ) { |
|
71 | - wp_delete_attachment( $id ); |
|
70 | +function wp_import_cleanup($id) { |
|
71 | + wp_delete_attachment($id); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -79,23 +79,23 @@ discard block |
||
79 | 79 | * @return array Uploaded file's details on success, error message on failure |
80 | 80 | */ |
81 | 81 | function wp_import_handle_upload() { |
82 | - if ( ! isset( $_FILES['import'] ) ) { |
|
82 | + if ( ! isset($_FILES['import'])) { |
|
83 | 83 | return array( |
84 | - 'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ) |
|
84 | + 'error' => __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.') |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
88 | - $overrides = array( 'test_form' => false, 'test_type' => false ); |
|
88 | + $overrides = array('test_form' => false, 'test_type' => false); |
|
89 | 89 | $_FILES['import']['name'] .= '.txt'; |
90 | - $upload = wp_handle_upload( $_FILES['import'], $overrides ); |
|
90 | + $upload = wp_handle_upload($_FILES['import'], $overrides); |
|
91 | 91 | |
92 | - if ( isset( $upload['error'] ) ) { |
|
92 | + if (isset($upload['error'])) { |
|
93 | 93 | return $upload; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Construct the object array |
97 | 97 | $object = array( |
98 | - 'post_title' => basename( $upload['file'] ), |
|
98 | + 'post_title' => basename($upload['file']), |
|
99 | 99 | 'post_content' => $upload['url'], |
100 | 100 | 'post_mime_type' => $upload['type'], |
101 | 101 | 'guid' => $upload['url'], |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | ); |
105 | 105 | |
106 | 106 | // Save the data |
107 | - $id = wp_insert_attachment( $object, $upload['file'] ); |
|
107 | + $id = wp_insert_attachment($object, $upload['file']); |
|
108 | 108 | |
109 | 109 | /* |
110 | 110 | * Schedule a cleanup for one day from now in case of failed |
111 | 111 | * import or missing wp_import_cleanup() call. |
112 | 112 | */ |
113 | - wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) ); |
|
113 | + wp_schedule_single_event(time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array($id)); |
|
114 | 114 | |
115 | - return array( 'file' => $upload['file'], 'id' => $id ); |
|
115 | + return array('file' => $upload['file'], 'id' => $id); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -123,32 +123,32 @@ discard block |
||
123 | 123 | * @return array Importers with metadata for each. |
124 | 124 | */ |
125 | 125 | function wp_get_popular_importers() { |
126 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
126 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
127 | 127 | |
128 | 128 | $locale = get_locale(); |
129 | - $popular_importers = get_site_transient( 'popular_importers_' . $locale ); |
|
129 | + $popular_importers = get_site_transient('popular_importers_'.$locale); |
|
130 | 130 | |
131 | - if ( ! $popular_importers ) { |
|
132 | - $url = add_query_arg( 'locale', get_locale(), 'http://api.wordpress.org/core/importers/1.1/' ); |
|
133 | - $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() ); |
|
134 | - $response = wp_remote_get( $url, $options ); |
|
135 | - $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
131 | + if ( ! $popular_importers) { |
|
132 | + $url = add_query_arg('locale', get_locale(), 'http://api.wordpress.org/core/importers/1.1/'); |
|
133 | + $options = array('user-agent' => 'WordPress/'.$wp_version.'; '.home_url()); |
|
134 | + $response = wp_remote_get($url, $options); |
|
135 | + $popular_importers = json_decode(wp_remote_retrieve_body($response), true); |
|
136 | 136 | |
137 | - if ( is_array( $popular_importers ) ) |
|
138 | - set_site_transient( 'popular_importers_' . $locale, $popular_importers, 2 * DAY_IN_SECONDS ); |
|
137 | + if (is_array($popular_importers)) |
|
138 | + set_site_transient('popular_importers_'.$locale, $popular_importers, 2 * DAY_IN_SECONDS); |
|
139 | 139 | else |
140 | 140 | $popular_importers = false; |
141 | 141 | } |
142 | 142 | |
143 | - if ( is_array( $popular_importers ) ) { |
|
143 | + if (is_array($popular_importers)) { |
|
144 | 144 | // If the data was received as translated, return it as-is. |
145 | - if ( $popular_importers['translated'] ) |
|
145 | + if ($popular_importers['translated']) |
|
146 | 146 | return $popular_importers['importers']; |
147 | 147 | |
148 | - foreach ( $popular_importers['importers'] as &$importer ) { |
|
149 | - $importer['description'] = translate( $importer['description'] ); |
|
150 | - if ( $importer['name'] != 'WordPress' ) |
|
151 | - $importer['name'] = translate( $importer['name'] ); |
|
148 | + foreach ($popular_importers['importers'] as &$importer) { |
|
149 | + $importer['description'] = translate($importer['description']); |
|
150 | + if ($importer['name'] != 'WordPress') |
|
151 | + $importer['name'] = translate($importer['name']); |
|
152 | 152 | } |
153 | 153 | return $popular_importers['importers']; |
154 | 154 | } |
@@ -156,50 +156,50 @@ discard block |
||
156 | 156 | return array( |
157 | 157 | // slug => name, description, plugin slug, and register_importer() slug |
158 | 158 | 'blogger' => array( |
159 | - 'name' => __( 'Blogger' ), |
|
160 | - 'description' => __( 'Install the Blogger importer to import posts, comments, and users from a Blogger blog.' ), |
|
159 | + 'name' => __('Blogger'), |
|
160 | + 'description' => __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), |
|
161 | 161 | 'plugin-slug' => 'blogger-importer', |
162 | 162 | 'importer-id' => 'blogger', |
163 | 163 | ), |
164 | 164 | 'wpcat2tag' => array( |
165 | - 'name' => __( 'Categories and Tags Converter' ), |
|
166 | - 'description' => __( 'Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.' ), |
|
165 | + 'name' => __('Categories and Tags Converter'), |
|
166 | + 'description' => __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'), |
|
167 | 167 | 'plugin-slug' => 'wpcat2tag-importer', |
168 | 168 | 'importer-id' => 'wp-cat2tag', |
169 | 169 | ), |
170 | 170 | 'livejournal' => array( |
171 | - 'name' => __( 'LiveJournal' ), |
|
172 | - 'description' => __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), |
|
171 | + 'name' => __('LiveJournal'), |
|
172 | + 'description' => __('Install the LiveJournal importer to import posts from LiveJournal using their API.'), |
|
173 | 173 | 'plugin-slug' => 'livejournal-importer', |
174 | 174 | 'importer-id' => 'livejournal', |
175 | 175 | ), |
176 | 176 | 'movabletype' => array( |
177 | - 'name' => __( 'Movable Type and TypePad' ), |
|
178 | - 'description' => __( 'Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.' ), |
|
177 | + 'name' => __('Movable Type and TypePad'), |
|
178 | + 'description' => __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), |
|
179 | 179 | 'plugin-slug' => 'movabletype-importer', |
180 | 180 | 'importer-id' => 'mt', |
181 | 181 | ), |
182 | 182 | 'opml' => array( |
183 | - 'name' => __( 'Blogroll' ), |
|
184 | - 'description' => __( 'Install the blogroll importer to import links in OPML format.' ), |
|
183 | + 'name' => __('Blogroll'), |
|
184 | + 'description' => __('Install the blogroll importer to import links in OPML format.'), |
|
185 | 185 | 'plugin-slug' => 'opml-importer', |
186 | 186 | 'importer-id' => 'opml', |
187 | 187 | ), |
188 | 188 | 'rss' => array( |
189 | - 'name' => __( 'RSS' ), |
|
190 | - 'description' => __( 'Install the RSS importer to import posts from an RSS feed.' ), |
|
189 | + 'name' => __('RSS'), |
|
190 | + 'description' => __('Install the RSS importer to import posts from an RSS feed.'), |
|
191 | 191 | 'plugin-slug' => 'rss-importer', |
192 | 192 | 'importer-id' => 'rss', |
193 | 193 | ), |
194 | 194 | 'tumblr' => array( |
195 | - 'name' => __( 'Tumblr' ), |
|
196 | - 'description' => __( 'Install the Tumblr importer to import posts & media from Tumblr using their API.' ), |
|
195 | + 'name' => __('Tumblr'), |
|
196 | + 'description' => __('Install the Tumblr importer to import posts & media from Tumblr using their API.'), |
|
197 | 197 | 'plugin-slug' => 'tumblr-importer', |
198 | 198 | 'importer-id' => 'tumblr', |
199 | 199 | ), |
200 | 200 | 'wordpress' => array( |
201 | 201 | 'name' => 'WordPress', |
202 | - 'description' => __( 'Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), |
|
202 | + 'description' => __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), |
|
203 | 203 | 'plugin-slug' => 'wordpress-importer', |
204 | 204 | 'importer-id' => 'wordpress', |
205 | 205 | ), |
@@ -53,8 +53,9 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function register_importer( $id, $name, $description, $callback ) { |
55 | 55 | global $wp_importers; |
56 | - if ( is_wp_error( $callback ) ) |
|
57 | - return $callback; |
|
56 | + if ( is_wp_error( $callback ) ) { |
|
57 | + return $callback; |
|
58 | + } |
|
58 | 59 | $wp_importers[$id] = array ( $name, $description, $callback ); |
59 | 60 | } |
60 | 61 | |
@@ -134,21 +135,24 @@ discard block |
||
134 | 135 | $response = wp_remote_get( $url, $options ); |
135 | 136 | $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); |
136 | 137 | |
137 | - if ( is_array( $popular_importers ) ) |
|
138 | - set_site_transient( 'popular_importers_' . $locale, $popular_importers, 2 * DAY_IN_SECONDS ); |
|
139 | - else |
|
140 | - $popular_importers = false; |
|
138 | + if ( is_array( $popular_importers ) ) { |
|
139 | + set_site_transient( 'popular_importers_' . $locale, $popular_importers, 2 * DAY_IN_SECONDS ); |
|
140 | + } else { |
|
141 | + $popular_importers = false; |
|
142 | + } |
|
141 | 143 | } |
142 | 144 | |
143 | 145 | if ( is_array( $popular_importers ) ) { |
144 | 146 | // If the data was received as translated, return it as-is. |
145 | - if ( $popular_importers['translated'] ) |
|
146 | - return $popular_importers['importers']; |
|
147 | + if ( $popular_importers['translated'] ) { |
|
148 | + return $popular_importers['importers']; |
|
149 | + } |
|
147 | 150 | |
148 | 151 | foreach ( $popular_importers['importers'] as &$importer ) { |
149 | 152 | $importer['description'] = translate( $importer['description'] ); |
150 | - if ( $importer['name'] != 'WordPress' ) |
|
151 | - $importer['name'] = translate( $importer['name'] ); |
|
153 | + if ( $importer['name'] != 'WordPress' ) { |
|
154 | + $importer['name'] = translate( $importer['name'] ); |
|
155 | + } |
|
152 | 156 | } |
153 | 157 | return $popular_importers['importers']; |
154 | 158 | } |
@@ -449,8 +449,9 @@ |
||
449 | 449 | private function _limit_embed( $src ) { |
450 | 450 | $src = $this->_limit_url( $src ); |
451 | 451 | |
452 | - if ( empty( $src ) ) |
|
453 | - return ''; |
|
452 | + if ( empty( $src ) ) { |
|
453 | + return ''; |
|
454 | + } |
|
454 | 455 | |
455 | 456 | if ( preg_match( '/\/\/(m|www)\.youtube\.com\/(embed|v)\/([^\?]+)\?.+$/', $src, $src_matches ) ) { |
456 | 457 | // Embedded Youtube videos (www or mobile) |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Press This class and display functionality |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Press_This |
|
7 | - * @since 4.2.0 |
|
8 | - */ |
|
3 | + * Press This class and display functionality |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Press_This |
|
7 | + * @since 4.2.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Press This class. |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | * @since 4.2.0 |
1050 | 1050 | * @access public |
1051 | 1051 | * |
1052 | - * @param array $data The site's data. |
|
1052 | + * @param array $data The site's data. |
|
1053 | 1053 | * @return string Discovered canonical URL, or empty |
1054 | 1054 | */ |
1055 | 1055 | public function get_canonical_link( $data ) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @param bool $redirect Whether to redirect in parent window or not. Default false. |
50 | 50 | */ |
51 | - 'redirInParent' => apply_filters( 'press_this_redirect_in_parent', false ), |
|
51 | + 'redirInParent' => apply_filters('press_this_redirect_in_parent', false), |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
@@ -62,37 +62,37 @@ discard block |
||
62 | 62 | * @param string $content Optional. Current expected markup for Press This. Expects slashed. Default empty. |
63 | 63 | * @return string New markup with old image URLs replaced with the local attachment ones if swapped. |
64 | 64 | */ |
65 | - public function side_load_images( $post_id, $content = '' ) { |
|
66 | - $content = wp_unslash( $content ); |
|
65 | + public function side_load_images($post_id, $content = '') { |
|
66 | + $content = wp_unslash($content); |
|
67 | 67 | |
68 | - if ( preg_match_all( '/<img [^>]+>/', $content, $matches ) && current_user_can( 'upload_files' ) ) { |
|
69 | - foreach ( (array) $matches[0] as $image ) { |
|
68 | + if (preg_match_all('/<img [^>]+>/', $content, $matches) && current_user_can('upload_files')) { |
|
69 | + foreach ((array) $matches[0] as $image) { |
|
70 | 70 | // This is inserted from our JS so HTML attributes should always be in double quotes. |
71 | - if ( ! preg_match( '/src="([^"]+)"/', $image, $url_matches ) ) { |
|
71 | + if ( ! preg_match('/src="([^"]+)"/', $image, $url_matches)) { |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $image_src = $url_matches[1]; |
76 | 76 | |
77 | 77 | // Don't try to sideload a file without a file extension, leads to WP upload error. |
78 | - if ( ! preg_match( '/[^\?]+\.(?:jpe?g|jpe|gif|png)(?:\?|$)/i', $image_src ) ) { |
|
78 | + if ( ! preg_match('/[^\?]+\.(?:jpe?g|jpe|gif|png)(?:\?|$)/i', $image_src)) { |
|
79 | 79 | continue; |
80 | 80 | } |
81 | 81 | |
82 | 82 | // Sideload image, which gives us a new image src. |
83 | - $new_src = media_sideload_image( $image_src, $post_id, null, 'src' ); |
|
83 | + $new_src = media_sideload_image($image_src, $post_id, null, 'src'); |
|
84 | 84 | |
85 | - if ( ! is_wp_error( $new_src ) ) { |
|
85 | + if ( ! is_wp_error($new_src)) { |
|
86 | 86 | // Replace the POSTED content <img> with correct uploaded ones. |
87 | 87 | // Need to do it in two steps so we don't replace links to the original image if any. |
88 | - $new_image = str_replace( $image_src, $new_src, $image ); |
|
89 | - $content = str_replace( $image, $new_image, $content ); |
|
88 | + $new_image = str_replace($image_src, $new_src, $image); |
|
89 | + $content = str_replace($image, $new_image, $content); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Expected slashed |
95 | - return wp_slash( $content ); |
|
95 | + return wp_slash($content); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,36 +102,36 @@ discard block |
||
102 | 102 | * @access public |
103 | 103 | */ |
104 | 104 | public function save_post() { |
105 | - if ( empty( $_POST['post_ID'] ) || ! $post_id = (int) $_POST['post_ID'] ) { |
|
106 | - wp_send_json_error( array( 'errorMessage' => __( 'Missing post ID.' ) ) ); |
|
105 | + if (empty($_POST['post_ID']) || ! $post_id = (int) $_POST['post_ID']) { |
|
106 | + wp_send_json_error(array('errorMessage' => __('Missing post ID.'))); |
|
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-post_' . $post_id ) || |
|
110 | - ! current_user_can( 'edit_post', $post_id ) ) { |
|
109 | + if (empty($_POST['_wpnonce']) || ! wp_verify_nonce($_POST['_wpnonce'], 'update-post_'.$post_id) || |
|
110 | + ! current_user_can('edit_post', $post_id)) { |
|
111 | 111 | |
112 | - wp_send_json_error( array( 'errorMessage' => __( 'Invalid post.' ) ) ); |
|
112 | + wp_send_json_error(array('errorMessage' => __('Invalid post.'))); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $post_data = array( |
116 | 116 | 'ID' => $post_id, |
117 | - 'post_title' => ( ! empty( $_POST['post_title'] ) ) ? sanitize_text_field( trim( $_POST['post_title'] ) ) : '', |
|
118 | - 'post_content' => ( ! empty( $_POST['post_content'] ) ) ? trim( $_POST['post_content'] ) : '', |
|
117 | + 'post_title' => ( ! empty($_POST['post_title'])) ? sanitize_text_field(trim($_POST['post_title'])) : '', |
|
118 | + 'post_content' => ( ! empty($_POST['post_content'])) ? trim($_POST['post_content']) : '', |
|
119 | 119 | 'post_type' => 'post', |
120 | 120 | 'post_status' => 'draft', |
121 | - 'post_format' => ( ! empty( $_POST['post_format'] ) ) ? sanitize_text_field( $_POST['post_format'] ) : '', |
|
122 | - 'tax_input' => ( ! empty( $_POST['tax_input'] ) ) ? $_POST['tax_input'] : array(), |
|
123 | - 'post_category' => ( ! empty( $_POST['post_category'] ) ) ? $_POST['post_category'] : array(), |
|
121 | + 'post_format' => ( ! empty($_POST['post_format'])) ? sanitize_text_field($_POST['post_format']) : '', |
|
122 | + 'tax_input' => ( ! empty($_POST['tax_input'])) ? $_POST['tax_input'] : array(), |
|
123 | + 'post_category' => ( ! empty($_POST['post_category'])) ? $_POST['post_category'] : array(), |
|
124 | 124 | ); |
125 | 125 | |
126 | - if ( ! empty( $_POST['post_status'] ) && 'publish' === $_POST['post_status'] ) { |
|
127 | - if ( current_user_can( 'publish_posts' ) ) { |
|
126 | + if ( ! empty($_POST['post_status']) && 'publish' === $_POST['post_status']) { |
|
127 | + if (current_user_can('publish_posts')) { |
|
128 | 128 | $post_data['post_status'] = 'publish'; |
129 | 129 | } else { |
130 | 130 | $post_data['post_status'] = 'pending'; |
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - $post_data['post_content'] = $this->side_load_images( $post_id, $post_data['post_content'] ); |
|
134 | + $post_data['post_content'] = $this->side_load_images($post_id, $post_data['post_content']); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Filter the post data of a Press This post before saving/updating, after |
@@ -141,28 +141,28 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param array $post_data The post data. |
143 | 143 | */ |
144 | - $post_data = apply_filters( 'press_this_save_post', $post_data ); |
|
144 | + $post_data = apply_filters('press_this_save_post', $post_data); |
|
145 | 145 | |
146 | - $updated = wp_update_post( $post_data, true ); |
|
146 | + $updated = wp_update_post($post_data, true); |
|
147 | 147 | |
148 | - if ( is_wp_error( $updated ) ) { |
|
149 | - wp_send_json_error( array( 'errorMessage' => $updated->get_error_message() ) ); |
|
148 | + if (is_wp_error($updated)) { |
|
149 | + wp_send_json_error(array('errorMessage' => $updated->get_error_message())); |
|
150 | 150 | } else { |
151 | - if ( isset( $post_data['post_format'] ) ) { |
|
152 | - if ( current_theme_supports( 'post-formats', $post_data['post_format'] ) ) { |
|
153 | - set_post_format( $post_id, $post_data['post_format'] ); |
|
154 | - } elseif ( $post_data['post_format'] ) { |
|
155 | - set_post_format( $post_id, false ); |
|
151 | + if (isset($post_data['post_format'])) { |
|
152 | + if (current_theme_supports('post-formats', $post_data['post_format'])) { |
|
153 | + set_post_format($post_id, $post_data['post_format']); |
|
154 | + } elseif ($post_data['post_format']) { |
|
155 | + set_post_format($post_id, false); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | 159 | $forceRedirect = false; |
160 | 160 | |
161 | - if ( 'publish' === get_post_status( $post_id ) ) { |
|
162 | - $redirect = get_post_permalink( $post_id ); |
|
163 | - } elseif ( isset( $_POST['pt-force-redirect'] ) && $_POST['pt-force-redirect'] === 'true' ) { |
|
161 | + if ('publish' === get_post_status($post_id)) { |
|
162 | + $redirect = get_post_permalink($post_id); |
|
163 | + } elseif (isset($_POST['pt-force-redirect']) && $_POST['pt-force-redirect'] === 'true') { |
|
164 | 164 | $forceRedirect = true; |
165 | - $redirect = get_edit_post_link( $post_id, 'js' ); |
|
165 | + $redirect = get_edit_post_link($post_id, 'js'); |
|
166 | 166 | } else { |
167 | 167 | $redirect = false; |
168 | 168 | } |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | * @param int $post_id Post ID. |
178 | 178 | * @param string $status Post status. |
179 | 179 | */ |
180 | - $redirect = apply_filters( 'press_this_save_redirect', $redirect, $post_id, $post_data['post_status'] ); |
|
180 | + $redirect = apply_filters('press_this_save_redirect', $redirect, $post_id, $post_data['post_status']); |
|
181 | 181 | |
182 | - if ( $redirect ) { |
|
183 | - wp_send_json_success( array( 'redirect' => $redirect, 'force' => $forceRedirect ) ); |
|
182 | + if ($redirect) { |
|
183 | + wp_send_json_success(array('redirect' => $redirect, 'force' => $forceRedirect)); |
|
184 | 184 | } else { |
185 | - wp_send_json_success( array( 'postSaved' => true ) ); |
|
185 | + wp_send_json_success(array('postSaved' => true)); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | } |
@@ -194,57 +194,57 @@ discard block |
||
194 | 194 | * @access public |
195 | 195 | */ |
196 | 196 | public function add_category() { |
197 | - if ( false === wp_verify_nonce( $_POST['new_cat_nonce'], 'add-category' ) ) { |
|
197 | + if (false === wp_verify_nonce($_POST['new_cat_nonce'], 'add-category')) { |
|
198 | 198 | wp_send_json_error(); |
199 | 199 | } |
200 | 200 | |
201 | - $taxonomy = get_taxonomy( 'category' ); |
|
201 | + $taxonomy = get_taxonomy('category'); |
|
202 | 202 | |
203 | - if ( ! current_user_can( $taxonomy->cap->edit_terms ) || empty( $_POST['name'] ) ) { |
|
203 | + if ( ! current_user_can($taxonomy->cap->edit_terms) || empty($_POST['name'])) { |
|
204 | 204 | wp_send_json_error(); |
205 | 205 | } |
206 | 206 | |
207 | - $parent = isset( $_POST['parent'] ) && (int) $_POST['parent'] > 0 ? (int) $_POST['parent'] : 0; |
|
208 | - $names = explode( ',', $_POST['name'] ); |
|
207 | + $parent = isset($_POST['parent']) && (int) $_POST['parent'] > 0 ? (int) $_POST['parent'] : 0; |
|
208 | + $names = explode(',', $_POST['name']); |
|
209 | 209 | $added = $data = array(); |
210 | 210 | |
211 | - foreach ( $names as $cat_name ) { |
|
212 | - $cat_name = trim( $cat_name ); |
|
213 | - $cat_nicename = sanitize_title( $cat_name ); |
|
211 | + foreach ($names as $cat_name) { |
|
212 | + $cat_name = trim($cat_name); |
|
213 | + $cat_nicename = sanitize_title($cat_name); |
|
214 | 214 | |
215 | - if ( empty( $cat_nicename ) ) { |
|
215 | + if (empty($cat_nicename)) { |
|
216 | 216 | continue; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // @todo Find a more performant way to check existence, maybe get_term() with a separate parent check. |
220 | - if ( term_exists( $cat_name, $taxonomy->name, $parent ) ) { |
|
221 | - if ( count( $names ) === 1 ) { |
|
222 | - wp_send_json_error( array( 'errorMessage' => __( 'This category already exists.' ) ) ); |
|
220 | + if (term_exists($cat_name, $taxonomy->name, $parent)) { |
|
221 | + if (count($names) === 1) { |
|
222 | + wp_send_json_error(array('errorMessage' => __('This category already exists.'))); |
|
223 | 223 | } else { |
224 | 224 | continue; |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); |
|
228 | + $cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent)); |
|
229 | 229 | |
230 | - if ( is_wp_error( $cat_id ) ) { |
|
230 | + if (is_wp_error($cat_id)) { |
|
231 | 231 | continue; |
232 | - } elseif ( is_array( $cat_id ) ) { |
|
232 | + } elseif (is_array($cat_id)) { |
|
233 | 233 | $cat_id = $cat_id['term_id']; |
234 | 234 | } |
235 | 235 | |
236 | 236 | $added[] = $cat_id; |
237 | 237 | } |
238 | 238 | |
239 | - if ( empty( $added ) ) { |
|
240 | - wp_send_json_error( array( 'errorMessage' => __( 'This category cannot be added. Please change the name and try again.' ) ) ); |
|
239 | + if (empty($added)) { |
|
240 | + wp_send_json_error(array('errorMessage' => __('This category cannot be added. Please change the name and try again.'))); |
|
241 | 241 | } |
242 | 242 | |
243 | - foreach ( $added as $new_cat_id ) { |
|
244 | - $new_cat = get_category( $new_cat_id ); |
|
243 | + foreach ($added as $new_cat_id) { |
|
244 | + $new_cat = get_category($new_cat_id); |
|
245 | 245 | |
246 | - if ( is_wp_error( $new_cat ) ) { |
|
247 | - wp_send_json_error( array( 'errorMessage' => __( 'Error while adding the category. Please try again later.' ) ) ); |
|
246 | + if (is_wp_error($new_cat)) { |
|
247 | + wp_send_json_error(array('errorMessage' => __('Error while adding the category. Please try again later.'))); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | $data[] = array( |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | 'parent' => $new_cat->parent, |
254 | 254 | ); |
255 | 255 | } |
256 | - wp_send_json_success( $data ); |
|
256 | + wp_send_json_success($data); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -265,20 +265,20 @@ discard block |
||
265 | 265 | * @param string $url URL to scan. |
266 | 266 | * @return string Source's HTML sanitized markup |
267 | 267 | */ |
268 | - public function fetch_source_html( $url ) { |
|
268 | + public function fetch_source_html($url) { |
|
269 | 269 | global $wp_version; |
270 | 270 | |
271 | - if ( empty( $url ) ) { |
|
272 | - return new WP_Error( 'invalid-url', __( 'A valid URL was not provided.' ) ); |
|
271 | + if (empty($url)) { |
|
272 | + return new WP_Error('invalid-url', __('A valid URL was not provided.')); |
|
273 | 273 | } |
274 | 274 | |
275 | - $remote_url = wp_safe_remote_get( $url, array( |
|
275 | + $remote_url = wp_safe_remote_get($url, array( |
|
276 | 276 | 'timeout' => 30, |
277 | 277 | // Use an explicit user-agent for Press This |
278 | - 'user-agent' => 'Press This (WordPress/' . $wp_version . '); ' . get_bloginfo( 'url' ) |
|
279 | - ) ); |
|
278 | + 'user-agent' => 'Press This (WordPress/'.$wp_version.'); '.get_bloginfo('url') |
|
279 | + )); |
|
280 | 280 | |
281 | - if ( is_wp_error( $remote_url ) ) { |
|
281 | + if (is_wp_error($remote_url)) { |
|
282 | 282 | return $remote_url; |
283 | 283 | } |
284 | 284 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | |
306 | - $source_content = wp_remote_retrieve_body( $remote_url ); |
|
307 | - $source_content = wp_kses( $source_content, $allowed_elements ); |
|
306 | + $source_content = wp_remote_retrieve_body($remote_url); |
|
307 | + $source_content = wp_kses($source_content, $allowed_elements); |
|
308 | 308 | |
309 | 309 | return $source_content; |
310 | 310 | } |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | * @param array $value Array to limit. |
319 | 319 | * @return array Original array if fewer than 50 values, limited array, empty array otherwise. |
320 | 320 | */ |
321 | - private function _limit_array( $value ) { |
|
322 | - if ( is_array( $value ) ) { |
|
323 | - if ( count( $value ) > 50 ) { |
|
324 | - return array_slice( $value, 0, 50 ); |
|
321 | + private function _limit_array($value) { |
|
322 | + if (is_array($value)) { |
|
323 | + if (count($value) > 50) { |
|
324 | + return array_slice($value, 0, 50); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | return $value; |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | * if fewer than 5,000 characters, a truncated version, otherwise an |
342 | 342 | * empty string. |
343 | 343 | */ |
344 | - private function _limit_string( $value ) { |
|
344 | + private function _limit_string($value) { |
|
345 | 345 | $return = ''; |
346 | 346 | |
347 | - if ( is_numeric( $value ) || is_bool( $value ) ) { |
|
347 | + if (is_numeric($value) || is_bool($value)) { |
|
348 | 348 | $return = $value; |
349 | - } else if ( is_string( $value ) ) { |
|
350 | - if ( mb_strlen( $value ) > 5000 ) { |
|
351 | - $return = mb_substr( $value, 0, 5000 ); |
|
349 | + } else if (is_string($value)) { |
|
350 | + if (mb_strlen($value) > 5000) { |
|
351 | + $return = mb_substr($value, 0, 5000); |
|
352 | 352 | } else { |
353 | 353 | $return = $value; |
354 | 354 | } |
355 | 355 | |
356 | - $return = html_entity_decode( $return, ENT_QUOTES, 'UTF-8' ); |
|
357 | - $return = sanitize_text_field( trim( $return ) ); |
|
356 | + $return = html_entity_decode($return, ENT_QUOTES, 'UTF-8'); |
|
357 | + $return = sanitize_text_field(trim($return)); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $return; |
@@ -369,32 +369,32 @@ discard block |
||
369 | 369 | * @param string $url URL to check for length and validity. |
370 | 370 | * @return string Escaped URL if of valid length (< 2048) and makeup. Empty string otherwise. |
371 | 371 | */ |
372 | - private function _limit_url( $url ) { |
|
373 | - if ( ! is_string( $url ) ) { |
|
372 | + private function _limit_url($url) { |
|
373 | + if ( ! is_string($url)) { |
|
374 | 374 | return ''; |
375 | 375 | } |
376 | 376 | |
377 | 377 | // HTTP 1.1 allows 8000 chars but the "de-facto" standard supported in all current browsers is 2048. |
378 | - if ( strlen( $url ) > 2048 ) { |
|
378 | + if (strlen($url) > 2048) { |
|
379 | 379 | return ''; // Return empty rather than a truncated/invalid URL |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Does not look like a URL. |
383 | - if ( ! preg_match( '/^([!#$&-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/', $url ) ) { |
|
383 | + if ( ! preg_match('/^([!#$&-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/', $url)) { |
|
384 | 384 | return ''; |
385 | 385 | } |
386 | 386 | |
387 | 387 | // If the URL is root-relative, prepend the protocol and domain name |
388 | - if ( $url && $this->domain && preg_match( '%^/[^/]+%', $url ) ) { |
|
389 | - $url = $this->domain . $url; |
|
388 | + if ($url && $this->domain && preg_match('%^/[^/]+%', $url)) { |
|
389 | + $url = $this->domain.$url; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | // Not absolute or protocol-relative URL. |
393 | - if ( ! preg_match( '%^(?:https?:)?//[^/]+%', $url ) ) { |
|
393 | + if ( ! preg_match('%^(?:https?:)?//[^/]+%', $url)) { |
|
394 | 394 | return ''; |
395 | 395 | } |
396 | 396 | |
397 | - return esc_url_raw( $url, array( 'http', 'https' ) ); |
|
397 | + return esc_url_raw($url, array('http', 'https')); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -409,34 +409,34 @@ discard block |
||
409 | 409 | * @param string $src Image source URL. |
410 | 410 | * @return string If not matched an excluded URL type, the original URL, empty string otherwise. |
411 | 411 | */ |
412 | - private function _limit_img( $src ) { |
|
413 | - $src = $this->_limit_url( $src ); |
|
412 | + private function _limit_img($src) { |
|
413 | + $src = $this->_limit_url($src); |
|
414 | 414 | |
415 | - if ( preg_match( '!/ad[sx]?/!i', $src ) ) { |
|
415 | + if (preg_match('!/ad[sx]?/!i', $src)) { |
|
416 | 416 | // Ads |
417 | 417 | return ''; |
418 | - } else if ( preg_match( '!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src ) ) { |
|
418 | + } else if (preg_match('!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src)) { |
|
419 | 419 | // Share-this type button |
420 | 420 | return ''; |
421 | - } else if ( preg_match( '!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src ) ) { |
|
421 | + } else if (preg_match('!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src)) { |
|
422 | 422 | // Loaders, spinners, spacers |
423 | 423 | return ''; |
424 | - } else if ( preg_match( '!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src ) ) { |
|
424 | + } else if (preg_match('!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src)) { |
|
425 | 425 | // Fancy loaders, spinners, spacers |
426 | 426 | return ''; |
427 | - } else if ( preg_match( '!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src ) ) { |
|
427 | + } else if (preg_match('!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src)) { |
|
428 | 428 | // Thumbnails, too small, usually irrelevant to context |
429 | 429 | return ''; |
430 | - } else if ( false !== stripos( $src, '/wp-includes/' ) ) { |
|
430 | + } else if (false !== stripos($src, '/wp-includes/')) { |
|
431 | 431 | // Classic WordPress interface images |
432 | 432 | return ''; |
433 | - } else if ( preg_match( '![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src ) ) { |
|
433 | + } else if (preg_match('![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src)) { |
|
434 | 434 | // Most often tiny buttons/thumbs (< 100px wide) |
435 | 435 | return ''; |
436 | - } else if ( preg_match( '!/pixel\.(mathtag|quantserve)\.com!i', $src ) ) { |
|
436 | + } else if (preg_match('!/pixel\.(mathtag|quantserve)\.com!i', $src)) { |
|
437 | 437 | // See mathtag.com and https://www.quantcast.com/how-we-do-it/iab-standard-measurement/how-we-collect-data/ |
438 | 438 | return ''; |
439 | - } else if ( preg_match( '!/[gb]\.gif(\?.+)?$!i', $src ) ) { |
|
439 | + } else if (preg_match('!/[gb]\.gif(\?.+)?$!i', $src)) { |
|
440 | 440 | // WordPress.com stats gif |
441 | 441 | return ''; |
442 | 442 | } |
@@ -456,32 +456,32 @@ discard block |
||
456 | 456 | * @param string $src Embed source URL. |
457 | 457 | * @return string If not from a supported provider, an empty string. Otherwise, a reformattd embed URL. |
458 | 458 | */ |
459 | - private function _limit_embed( $src ) { |
|
460 | - $src = $this->_limit_url( $src ); |
|
459 | + private function _limit_embed($src) { |
|
460 | + $src = $this->_limit_url($src); |
|
461 | 461 | |
462 | - if ( empty( $src ) ) |
|
462 | + if (empty($src)) |
|
463 | 463 | return ''; |
464 | 464 | |
465 | - if ( preg_match( '!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches ) ) { |
|
465 | + if (preg_match('!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches)) { |
|
466 | 466 | // Embedded Youtube videos (www or mobile) |
467 | - $src = 'https://www.youtube.com/watch?v=' . $src_matches[3]; |
|
468 | - } else if ( preg_match( '!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches ) ) { |
|
467 | + $src = 'https://www.youtube.com/watch?v='.$src_matches[3]; |
|
468 | + } else if (preg_match('!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches)) { |
|
469 | 469 | // Embedded Vimeo iframe videos |
470 | - $src = 'https://vimeo.com/' . (int) $src_matches[1]; |
|
471 | - } else if ( preg_match( '!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches ) ) { |
|
470 | + $src = 'https://vimeo.com/'.(int) $src_matches[1]; |
|
471 | + } else if (preg_match('!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches)) { |
|
472 | 472 | // Embedded Vimeo Flash videos |
473 | - $src = 'https://vimeo.com/' . (int) $src_matches[1]; |
|
474 | - } else if ( preg_match( '!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches ) ) { |
|
473 | + $src = 'https://vimeo.com/'.(int) $src_matches[1]; |
|
474 | + } else if (preg_match('!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches)) { |
|
475 | 475 | // Embedded Vine videos |
476 | - $src = 'https://vine.co/v/' . $src_matches[1]; |
|
477 | - } else if ( preg_match( '!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches ) ) { |
|
476 | + $src = 'https://vine.co/v/'.$src_matches[1]; |
|
477 | + } else if (preg_match('!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches)) { |
|
478 | 478 | // Embedded Daily Motion videos |
479 | - $src = 'https://www.dailymotion.com/video/' . $src_matches[2]; |
|
479 | + $src = 'https://www.dailymotion.com/video/'.$src_matches[2]; |
|
480 | 480 | } else { |
481 | - require_once( ABSPATH . WPINC . '/class-oembed.php' ); |
|
481 | + require_once(ABSPATH.WPINC.'/class-oembed.php'); |
|
482 | 482 | $oembed = _wp_oembed_get_object(); |
483 | 483 | |
484 | - if ( ! $oembed->get_provider( $src, array( 'discover' => false ) ) ) { |
|
484 | + if ( ! $oembed->get_provider($src, array('discover' => false))) { |
|
485 | 485 | $src = ''; |
486 | 486 | } |
487 | 487 | } |
@@ -500,21 +500,21 @@ discard block |
||
500 | 500 | * @param array $data Associative array of source data. |
501 | 501 | * @return array Processed data array. |
502 | 502 | */ |
503 | - private function _process_meta_entry( $meta_name, $meta_value, $data ) { |
|
504 | - if ( preg_match( '/:?(title|description|keywords|site_name)$/', $meta_name ) ) { |
|
505 | - $data['_meta'][ $meta_name ] = $meta_value; |
|
503 | + private function _process_meta_entry($meta_name, $meta_value, $data) { |
|
504 | + if (preg_match('/:?(title|description|keywords|site_name)$/', $meta_name)) { |
|
505 | + $data['_meta'][$meta_name] = $meta_value; |
|
506 | 506 | } else { |
507 | - switch ( $meta_name ) { |
|
507 | + switch ($meta_name) { |
|
508 | 508 | case 'og:url': |
509 | 509 | case 'og:video': |
510 | 510 | case 'og:video:secure_url': |
511 | - $meta_value = $this->_limit_embed( $meta_value ); |
|
511 | + $meta_value = $this->_limit_embed($meta_value); |
|
512 | 512 | |
513 | - if ( ! isset( $data['_embeds'] ) ) { |
|
513 | + if ( ! isset($data['_embeds'])) { |
|
514 | 514 | $data['_embeds'] = array(); |
515 | 515 | } |
516 | 516 | |
517 | - if ( ! empty( $meta_value ) && ! in_array( $meta_value, $data['_embeds'] ) ) { |
|
517 | + if ( ! empty($meta_value) && ! in_array($meta_value, $data['_embeds'])) { |
|
518 | 518 | $data['_embeds'][] = $meta_value; |
519 | 519 | } |
520 | 520 | |
@@ -525,13 +525,13 @@ discard block |
||
525 | 525 | case 'twitter:image0': |
526 | 526 | case 'twitter:image:src': |
527 | 527 | case 'twitter:image': |
528 | - $meta_value = $this->_limit_img( $meta_value ); |
|
528 | + $meta_value = $this->_limit_img($meta_value); |
|
529 | 529 | |
530 | - if ( ! isset( $data['_images'] ) ) { |
|
530 | + if ( ! isset($data['_images'])) { |
|
531 | 531 | $data['_images'] = array(); |
532 | 532 | } |
533 | 533 | |
534 | - if ( ! empty( $meta_value ) && ! in_array( $meta_value, $data['_images'] ) ) { |
|
534 | + if ( ! empty($meta_value) && ! in_array($meta_value, $data['_images'])) { |
|
535 | 535 | $data['_images'][] = $meta_value; |
536 | 536 | } |
537 | 537 | |
@@ -552,58 +552,58 @@ discard block |
||
552 | 552 | * @param array $data Optional. Existing data array if you have one. Default empty array. |
553 | 553 | * @return array New data array. |
554 | 554 | */ |
555 | - public function source_data_fetch_fallback( $url, $data = array() ) { |
|
556 | - if ( empty( $url ) ) { |
|
555 | + public function source_data_fetch_fallback($url, $data = array()) { |
|
556 | + if (empty($url)) { |
|
557 | 557 | return array(); |
558 | 558 | } |
559 | 559 | |
560 | 560 | // Download source page to tmp file. |
561 | - $source_content = $this->fetch_source_html( $url ); |
|
562 | - if ( is_wp_error( $source_content ) ) { |
|
563 | - return array( 'errors' => $source_content->get_error_messages() ); |
|
561 | + $source_content = $this->fetch_source_html($url); |
|
562 | + if (is_wp_error($source_content)) { |
|
563 | + return array('errors' => $source_content->get_error_messages()); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | // Fetch and gather <meta> data first, so discovered media is offered 1st to user. |
567 | - if ( empty( $data['_meta'] ) ) { |
|
567 | + if (empty($data['_meta'])) { |
|
568 | 568 | $data['_meta'] = array(); |
569 | 569 | } |
570 | 570 | |
571 | - if ( preg_match_all( '/<meta [^>]+>/', $source_content, $matches ) ) { |
|
572 | - $items = $this->_limit_array( $matches[0] ); |
|
571 | + if (preg_match_all('/<meta [^>]+>/', $source_content, $matches)) { |
|
572 | + $items = $this->_limit_array($matches[0]); |
|
573 | 573 | |
574 | - foreach ( $items as $value ) { |
|
575 | - if ( preg_match( '/(property|name)="([^"]+)"[^>]+content="([^"]+)"/', $value, $new_matches ) ) { |
|
576 | - $meta_name = $this->_limit_string( $new_matches[2] ); |
|
577 | - $meta_value = $this->_limit_string( $new_matches[3] ); |
|
574 | + foreach ($items as $value) { |
|
575 | + if (preg_match('/(property|name)="([^"]+)"[^>]+content="([^"]+)"/', $value, $new_matches)) { |
|
576 | + $meta_name = $this->_limit_string($new_matches[2]); |
|
577 | + $meta_value = $this->_limit_string($new_matches[3]); |
|
578 | 578 | |
579 | 579 | // Sanity check. $key is usually things like 'title', 'description', 'keywords', etc. |
580 | - if ( strlen( $meta_name ) > 100 ) { |
|
580 | + if (strlen($meta_name) > 100) { |
|
581 | 581 | continue; |
582 | 582 | } |
583 | 583 | |
584 | - $data = $this->_process_meta_entry( $meta_name, $meta_value, $data ); |
|
584 | + $data = $this->_process_meta_entry($meta_name, $meta_value, $data); |
|
585 | 585 | } |
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | 589 | // Fetch and gather <img> data. |
590 | - if ( empty( $data['_images'] ) ) { |
|
590 | + if (empty($data['_images'])) { |
|
591 | 591 | $data['_images'] = array(); |
592 | 592 | } |
593 | 593 | |
594 | - if ( preg_match_all( '/<img [^>]+>/', $source_content, $matches ) ) { |
|
595 | - $items = $this->_limit_array( $matches[0] ); |
|
594 | + if (preg_match_all('/<img [^>]+>/', $source_content, $matches)) { |
|
595 | + $items = $this->_limit_array($matches[0]); |
|
596 | 596 | |
597 | - foreach ( $items as $value ) { |
|
598 | - if ( ( preg_match( '/width=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 256 ) || |
|
599 | - ( preg_match( '/height=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 128 ) ) { |
|
597 | + foreach ($items as $value) { |
|
598 | + if ((preg_match('/width=(\'|")(\d+)\\1/i', $value, $new_matches) && $new_matches[2] < 256) || |
|
599 | + (preg_match('/height=(\'|")(\d+)\\1/i', $value, $new_matches) && $new_matches[2] < 128)) { |
|
600 | 600 | |
601 | 601 | continue; |
602 | 602 | } |
603 | 603 | |
604 | - if ( preg_match( '/src=(\'|")([^\'"]+)\\1/i', $value, $new_matches ) ) { |
|
605 | - $src = $this->_limit_img( $new_matches[2] ); |
|
606 | - if ( ! empty( $src ) && ! in_array( $src, $data['_images'] ) ) { |
|
604 | + if (preg_match('/src=(\'|")([^\'"]+)\\1/i', $value, $new_matches)) { |
|
605 | + $src = $this->_limit_img($new_matches[2]); |
|
606 | + if ( ! empty($src) && ! in_array($src, $data['_images'])) { |
|
607 | 607 | $data['_images'][] = $src; |
608 | 608 | } |
609 | 609 | } |
@@ -611,18 +611,18 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | // Fetch and gather <iframe> data. |
614 | - if ( empty( $data['_embeds'] ) ) { |
|
614 | + if (empty($data['_embeds'])) { |
|
615 | 615 | $data['_embeds'] = array(); |
616 | 616 | } |
617 | 617 | |
618 | - if ( preg_match_all( '/<iframe [^>]+>/', $source_content, $matches ) ) { |
|
619 | - $items = $this->_limit_array( $matches[0] ); |
|
618 | + if (preg_match_all('/<iframe [^>]+>/', $source_content, $matches)) { |
|
619 | + $items = $this->_limit_array($matches[0]); |
|
620 | 620 | |
621 | - foreach ( $items as $value ) { |
|
622 | - if ( preg_match( '/src=(\'|")([^\'"]+)\\1/', $value, $new_matches ) ) { |
|
623 | - $src = $this->_limit_embed( $new_matches[2] ); |
|
621 | + foreach ($items as $value) { |
|
622 | + if (preg_match('/src=(\'|")([^\'"]+)\\1/', $value, $new_matches)) { |
|
623 | + $src = $this->_limit_embed($new_matches[2]); |
|
624 | 624 | |
625 | - if ( ! empty( $src ) && ! in_array( $src, $data['_embeds'] ) ) { |
|
625 | + if ( ! empty($src) && ! in_array($src, $data['_embeds'])) { |
|
626 | 626 | $data['_embeds'][] = $src; |
627 | 627 | } |
628 | 628 | } |
@@ -630,20 +630,20 @@ discard block |
||
630 | 630 | } |
631 | 631 | |
632 | 632 | // Fetch and gather <link> data. |
633 | - if ( empty( $data['_links'] ) ) { |
|
633 | + if (empty($data['_links'])) { |
|
634 | 634 | $data['_links'] = array(); |
635 | 635 | } |
636 | 636 | |
637 | - if ( preg_match_all( '/<link [^>]+>/', $source_content, $matches ) ) { |
|
638 | - $items = $this->_limit_array( $matches[0] ); |
|
637 | + if (preg_match_all('/<link [^>]+>/', $source_content, $matches)) { |
|
638 | + $items = $this->_limit_array($matches[0]); |
|
639 | 639 | |
640 | - foreach ( $items as $value ) { |
|
641 | - if ( preg_match( '/rel=["\'](canonical|shortlink|icon)["\']/i', $value, $matches_rel ) && preg_match( '/href=[\'"]([^\'" ]+)[\'"]/i', $value, $matches_url ) ) { |
|
640 | + foreach ($items as $value) { |
|
641 | + if (preg_match('/rel=["\'](canonical|shortlink|icon)["\']/i', $value, $matches_rel) && preg_match('/href=[\'"]([^\'" ]+)[\'"]/i', $value, $matches_url)) { |
|
642 | 642 | $rel = $matches_rel[1]; |
643 | - $url = $this->_limit_url( $matches_url[1] ); |
|
643 | + $url = $this->_limit_url($matches_url[1]); |
|
644 | 644 | |
645 | - if ( ! empty( $url ) && empty( $data['_links'][ $rel ] ) ) { |
|
646 | - $data['_links'][ $rel ] = $url; |
|
645 | + if ( ! empty($url) && empty($data['_links'][$rel])) { |
|
646 | + $data['_links'][$rel] = $url; |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
@@ -665,27 +665,27 @@ discard block |
||
665 | 665 | $data = array(); |
666 | 666 | |
667 | 667 | // Only instantiate the keys we want. Sanity check and sanitize each one. |
668 | - foreach ( array( 'u', 's', 't', 'v' ) as $key ) { |
|
669 | - if ( ! empty( $_POST[ $key ] ) ) { |
|
670 | - $value = wp_unslash( $_POST[ $key ] ); |
|
671 | - } else if ( ! empty( $_GET[ $key ] ) ) { |
|
672 | - $value = wp_unslash( $_GET[ $key ] ); |
|
668 | + foreach (array('u', 's', 't', 'v') as $key) { |
|
669 | + if ( ! empty($_POST[$key])) { |
|
670 | + $value = wp_unslash($_POST[$key]); |
|
671 | + } else if ( ! empty($_GET[$key])) { |
|
672 | + $value = wp_unslash($_GET[$key]); |
|
673 | 673 | } else { |
674 | 674 | continue; |
675 | 675 | } |
676 | 676 | |
677 | - if ( 'u' === $key ) { |
|
678 | - $value = $this->_limit_url( $value ); |
|
677 | + if ('u' === $key) { |
|
678 | + $value = $this->_limit_url($value); |
|
679 | 679 | |
680 | - if ( preg_match( '%^(?:https?:)?//[^/]+%i', $value, $domain_match ) ) { |
|
680 | + if (preg_match('%^(?:https?:)?//[^/]+%i', $value, $domain_match)) { |
|
681 | 681 | $this->domain = $domain_match[0]; |
682 | 682 | } |
683 | 683 | } else { |
684 | - $value = $this->_limit_string( $value ); |
|
684 | + $value = $this->_limit_string($value); |
|
685 | 685 | } |
686 | 686 | |
687 | - if ( ! empty( $value ) ) { |
|
688 | - $data[ $key ] = $value; |
|
687 | + if ( ! empty($value)) { |
|
688 | + $data[$key] = $value; |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
@@ -696,58 +696,58 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @param bool $enable Whether to enable media discovery. |
698 | 698 | */ |
699 | - if ( apply_filters( 'enable_press_this_media_discovery', true ) ) { |
|
699 | + if (apply_filters('enable_press_this_media_discovery', true)) { |
|
700 | 700 | /* |
701 | 701 | * If no title, _images, _embed, and _meta was passed via $_POST, fetch data from source as fallback, |
702 | 702 | * making PT fully backward compatible with the older bookmarklet. |
703 | 703 | */ |
704 | - if ( empty( $_POST ) && ! empty( $data['u'] ) ) { |
|
705 | - $data = $this->source_data_fetch_fallback( $data['u'], $data ); |
|
704 | + if (empty($_POST) && ! empty($data['u'])) { |
|
705 | + $data = $this->source_data_fetch_fallback($data['u'], $data); |
|
706 | 706 | } else { |
707 | - foreach ( array( '_images', '_embeds' ) as $type ) { |
|
708 | - if ( empty( $_POST[ $type ] ) ) { |
|
707 | + foreach (array('_images', '_embeds') as $type) { |
|
708 | + if (empty($_POST[$type])) { |
|
709 | 709 | continue; |
710 | 710 | } |
711 | 711 | |
712 | - $data[ $type ] = array(); |
|
713 | - $items = $this->_limit_array( $_POST[ $type ] ); |
|
712 | + $data[$type] = array(); |
|
713 | + $items = $this->_limit_array($_POST[$type]); |
|
714 | 714 | |
715 | - foreach ( $items as $key => $value ) { |
|
716 | - if ( $type === '_images' ) { |
|
717 | - $value = $this->_limit_img( wp_unslash( $value ) ); |
|
715 | + foreach ($items as $key => $value) { |
|
716 | + if ($type === '_images') { |
|
717 | + $value = $this->_limit_img(wp_unslash($value)); |
|
718 | 718 | } else { |
719 | - $value = $this->_limit_embed( wp_unslash( $value ) ); |
|
719 | + $value = $this->_limit_embed(wp_unslash($value)); |
|
720 | 720 | } |
721 | 721 | |
722 | - if ( ! empty( $value ) ) { |
|
723 | - $data[ $type ][] = $value; |
|
722 | + if ( ! empty($value)) { |
|
723 | + $data[$type][] = $value; |
|
724 | 724 | } |
725 | 725 | } |
726 | 726 | } |
727 | 727 | |
728 | - foreach ( array( '_meta', '_links' ) as $type ) { |
|
729 | - if ( empty( $_POST[ $type ] ) ) { |
|
728 | + foreach (array('_meta', '_links') as $type) { |
|
729 | + if (empty($_POST[$type])) { |
|
730 | 730 | continue; |
731 | 731 | } |
732 | 732 | |
733 | - $data[ $type ] = array(); |
|
734 | - $items = $this->_limit_array( $_POST[ $type ] ); |
|
733 | + $data[$type] = array(); |
|
734 | + $items = $this->_limit_array($_POST[$type]); |
|
735 | 735 | |
736 | - foreach ( $items as $key => $value ) { |
|
736 | + foreach ($items as $key => $value) { |
|
737 | 737 | // Sanity check. These are associative arrays, $key is usually things like 'title', 'description', 'keywords', etc. |
738 | - if ( empty( $key ) || strlen( $key ) > 100 ) { |
|
738 | + if (empty($key) || strlen($key) > 100) { |
|
739 | 739 | continue; |
740 | 740 | } |
741 | 741 | |
742 | - if ( $type === '_meta' ) { |
|
743 | - $value = $this->_limit_string( wp_unslash( $value ) ); |
|
742 | + if ($type === '_meta') { |
|
743 | + $value = $this->_limit_string(wp_unslash($value)); |
|
744 | 744 | |
745 | - if ( ! empty( $value ) ) { |
|
746 | - $data = $this->_process_meta_entry( $key, $value, $data ); |
|
745 | + if ( ! empty($value)) { |
|
746 | + $data = $this->_process_meta_entry($key, $value, $data); |
|
747 | 747 | } |
748 | 748 | } else { |
749 | - if ( in_array( $key, array( 'canonical', 'shortlink', 'icon' ), true ) ) { |
|
750 | - $data[ $type ][ $key ] = $this->_limit_url( wp_unslash( $value ) ); |
|
749 | + if (in_array($key, array('canonical', 'shortlink', 'icon'), true)) { |
|
750 | + $data[$type][$key] = $this->_limit_url(wp_unslash($value)); |
|
751 | 751 | } |
752 | 752 | } |
753 | 753 | } |
@@ -755,11 +755,11 @@ discard block |
||
755 | 755 | } |
756 | 756 | |
757 | 757 | // Support passing a single image src as `i` |
758 | - if ( ! empty( $_REQUEST['i'] ) && ( $img_src = $this->_limit_img( wp_unslash( $_REQUEST['i'] ) ) ) ) { |
|
759 | - if ( empty( $data['_images'] ) ) { |
|
760 | - $data['_images'] = array( $img_src ); |
|
761 | - } elseif ( ! in_array( $img_src, $data['_images'], true ) ) { |
|
762 | - array_unshift( $data['_images'], $img_src ); |
|
758 | + if ( ! empty($_REQUEST['i']) && ($img_src = $this->_limit_img(wp_unslash($_REQUEST['i'])))) { |
|
759 | + if (empty($data['_images'])) { |
|
760 | + $data['_images'] = array($img_src); |
|
761 | + } elseif ( ! in_array($img_src, $data['_images'], true)) { |
|
762 | + array_unshift($data['_images'], $img_src); |
|
763 | 763 | } |
764 | 764 | } |
765 | 765 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @param array $data Press This Data array. |
773 | 773 | */ |
774 | - return apply_filters( 'press_this_data', $data ); |
|
774 | + return apply_filters('press_this_data', $data); |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | /** |
@@ -783,14 +783,14 @@ discard block |
||
783 | 783 | * @param string $styles URL to editor stylesheet. |
784 | 784 | * @return string Possibly modified stylesheets list. |
785 | 785 | */ |
786 | - public function add_editor_style( $styles ) { |
|
787 | - if ( ! empty( $styles ) ) { |
|
786 | + public function add_editor_style($styles) { |
|
787 | + if ( ! empty($styles)) { |
|
788 | 788 | $styles .= ','; |
789 | 789 | } |
790 | 790 | |
791 | - $press_this = admin_url( 'css/press-this-editor.css' ); |
|
792 | - if ( is_rtl() ) { |
|
793 | - $press_this = str_replace( '.css', '-rtl.css', $press_this ); |
|
791 | + $press_this = admin_url('css/press-this-editor.css'); |
|
792 | + if (is_rtl()) { |
|
793 | + $press_this = str_replace('.css', '-rtl.css', $press_this); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | $open_sans_font_url = ''; |
@@ -798,31 +798,31 @@ discard block |
||
798 | 798 | /* translators: If there are characters in your language that are not supported |
799 | 799 | * by Open Sans, translate this to 'off'. Do not translate into your own language. |
800 | 800 | */ |
801 | - if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) { |
|
801 | + if ('off' !== _x('on', 'Open Sans font: on or off')) { |
|
802 | 802 | $subsets = 'latin,latin-ext'; |
803 | 803 | |
804 | 804 | /* translators: To add an additional Open Sans character subset specific to your language, |
805 | 805 | * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. |
806 | 806 | */ |
807 | - $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' ); |
|
807 | + $subset = _x('no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)'); |
|
808 | 808 | |
809 | - if ( 'cyrillic' == $subset ) { |
|
809 | + if ('cyrillic' == $subset) { |
|
810 | 810 | $subsets .= ',cyrillic,cyrillic-ext'; |
811 | - } elseif ( 'greek' == $subset ) { |
|
811 | + } elseif ('greek' == $subset) { |
|
812 | 812 | $subsets .= ',greek,greek-ext'; |
813 | - } elseif ( 'vietnamese' == $subset ) { |
|
813 | + } elseif ('vietnamese' == $subset) { |
|
814 | 814 | $subsets .= ',vietnamese'; |
815 | 815 | } |
816 | 816 | |
817 | 817 | $query_args = array( |
818 | - 'family' => urlencode( 'Open Sans:400italic,700italic,400,600,700' ), |
|
819 | - 'subset' => urlencode( $subsets ), |
|
818 | + 'family' => urlencode('Open Sans:400italic,700italic,400,600,700'), |
|
819 | + 'subset' => urlencode($subsets), |
|
820 | 820 | ); |
821 | 821 | |
822 | - $open_sans_font_url = ',' . add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); |
|
822 | + $open_sans_font_url = ','.add_query_arg($query_args, 'https://fonts.googleapis.com/css'); |
|
823 | 823 | } |
824 | 824 | |
825 | - return $styles . $press_this . $open_sans_font_url; |
|
825 | + return $styles.$press_this.$open_sans_font_url; |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -833,35 +833,35 @@ discard block |
||
833 | 833 | * |
834 | 834 | * @param WP_Post $post Post object. |
835 | 835 | */ |
836 | - public function post_formats_html( $post ) { |
|
837 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
838 | - $post_formats = get_theme_support( 'post-formats' ); |
|
836 | + public function post_formats_html($post) { |
|
837 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) { |
|
838 | + $post_formats = get_theme_support('post-formats'); |
|
839 | 839 | |
840 | - if ( is_array( $post_formats[0] ) ) { |
|
841 | - $post_format = get_post_format( $post->ID ); |
|
840 | + if (is_array($post_formats[0])) { |
|
841 | + $post_format = get_post_format($post->ID); |
|
842 | 842 | |
843 | - if ( ! $post_format ) { |
|
843 | + if ( ! $post_format) { |
|
844 | 844 | $post_format = '0'; |
845 | 845 | } |
846 | 846 | |
847 | 847 | // Add in the current one if it isn't there yet, in case the current theme doesn't support it. |
848 | - if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) { |
|
848 | + if ($post_format && ! in_array($post_format, $post_formats[0])) { |
|
849 | 849 | $post_formats[0][] = $post_format; |
850 | 850 | } |
851 | 851 | |
852 | 852 | ?> |
853 | 853 | <div id="post-formats-select"> |
854 | - <fieldset><legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend> |
|
855 | - <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> |
|
856 | - <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label> |
|
854 | + <fieldset><legend class="screen-reader-text"><?php _e('Post Formats'); ?></legend> |
|
855 | + <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked($post_format, '0'); ?> /> |
|
856 | + <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string('standard'); ?></label> |
|
857 | 857 | <?php |
858 | 858 | |
859 | - foreach ( $post_formats[0] as $format ) { |
|
860 | - $attr_format = esc_attr( $format ); |
|
859 | + foreach ($post_formats[0] as $format) { |
|
860 | + $attr_format = esc_attr($format); |
|
861 | 861 | ?> |
862 | 862 | <br /> |
863 | - <input type="radio" name="post_format" class="post-format" id="post-format-<?php echo $attr_format; ?>" value="<?php echo $attr_format; ?>" <?php checked( $post_format, $format ); ?> /> |
|
864 | - <label for="post-format-<?php echo $attr_format ?>" class="post-format-icon post-format-<?php echo $attr_format; ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label> |
|
863 | + <input type="radio" name="post_format" class="post-format" id="post-format-<?php echo $attr_format; ?>" value="<?php echo $attr_format; ?>" <?php checked($post_format, $format); ?> /> |
|
864 | + <label for="post-format-<?php echo $attr_format ?>" class="post-format-icon post-format-<?php echo $attr_format; ?>"><?php echo esc_html(get_post_format_string($format)); ?></label> |
|
865 | 865 | <?php |
866 | 866 | } |
867 | 867 | |
@@ -881,45 +881,45 @@ discard block |
||
881 | 881 | * |
882 | 882 | * @param WP_Post $post Post object. |
883 | 883 | */ |
884 | - public function categories_html( $post ) { |
|
885 | - $taxonomy = get_taxonomy( 'category' ); |
|
884 | + public function categories_html($post) { |
|
885 | + $taxonomy = get_taxonomy('category'); |
|
886 | 886 | |
887 | - if ( current_user_can( $taxonomy->cap->edit_terms ) ) { |
|
887 | + if (current_user_can($taxonomy->cap->edit_terms)) { |
|
888 | 888 | ?> |
889 | 889 | <button type="button" class="add-cat-toggle button-link" aria-expanded="false"> |
890 | - <span class="dashicons dashicons-plus"></span><span class="screen-reader-text"><?php _e( 'Toggle add category' ); ?></span> |
|
890 | + <span class="dashicons dashicons-plus"></span><span class="screen-reader-text"><?php _e('Toggle add category'); ?></span> |
|
891 | 891 | </button> |
892 | 892 | <div class="add-category is-hidden"> |
893 | 893 | <label class="screen-reader-text" for="new-category"><?php echo $taxonomy->labels->add_new_item; ?></label> |
894 | - <input type="text" id="new-category" class="add-category-name" placeholder="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" value="" aria-required="true"> |
|
894 | + <input type="text" id="new-category" class="add-category-name" placeholder="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" value="" aria-required="true"> |
|
895 | 895 | <label class="screen-reader-text" for="new-category-parent"><?php echo $taxonomy->labels->parent_item_colon; ?></label> |
896 | 896 | <div class="postform-wrapper"> |
897 | 897 | <?php |
898 | - wp_dropdown_categories( array( |
|
898 | + wp_dropdown_categories(array( |
|
899 | 899 | 'taxonomy' => 'category', |
900 | 900 | 'hide_empty' => 0, |
901 | 901 | 'name' => 'new-category-parent', |
902 | 902 | 'orderby' => 'name', |
903 | 903 | 'hierarchical' => 1, |
904 | - 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —' |
|
905 | - ) ); |
|
904 | + 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —' |
|
905 | + )); |
|
906 | 906 | ?> |
907 | 907 | </div> |
908 | - <button type="button" class="add-cat-submit"><?php _e( 'Add' ); ?></button> |
|
908 | + <button type="button" class="add-cat-submit"><?php _e('Add'); ?></button> |
|
909 | 909 | </div> |
910 | 910 | <?php |
911 | 911 | |
912 | 912 | } |
913 | 913 | ?> |
914 | 914 | <div class="categories-search-wrapper"> |
915 | - <input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e( 'Search categories by name' ) ?>"> |
|
915 | + <input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e('Search categories by name') ?>"> |
|
916 | 916 | <label for="categories-search"> |
917 | - <span class="dashicons dashicons-search"></span><span class="screen-reader-text"><?php _e( 'Search categories' ); ?></span> |
|
917 | + <span class="dashicons dashicons-search"></span><span class="screen-reader-text"><?php _e('Search categories'); ?></span> |
|
918 | 918 | </label> |
919 | 919 | </div> |
920 | - <div aria-label="<?php esc_attr_e( 'Categories' ); ?>"> |
|
920 | + <div aria-label="<?php esc_attr_e('Categories'); ?>"> |
|
921 | 921 | <ul class="categories-select"> |
922 | - <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'category', 'list_only' => true ) ); ?> |
|
922 | + <?php wp_terms_checklist($post->ID, array('taxonomy' => 'category', 'list_only' => true)); ?> |
|
923 | 923 | </ul> |
924 | 924 | </div> |
925 | 925 | <?php |
@@ -933,12 +933,12 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @param WP_Post $post Post object. |
935 | 935 | */ |
936 | - public function tags_html( $post ) { |
|
937 | - $taxonomy = get_taxonomy( 'post_tag' ); |
|
938 | - $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); |
|
939 | - $esc_tags = get_terms_to_edit( $post->ID, 'post_tag' ); |
|
936 | + public function tags_html($post) { |
|
937 | + $taxonomy = get_taxonomy('post_tag'); |
|
938 | + $user_can_assign_terms = current_user_can($taxonomy->cap->assign_terms); |
|
939 | + $esc_tags = get_terms_to_edit($post->ID, 'post_tag'); |
|
940 | 940 | |
941 | - if ( ! $esc_tags || is_wp_error( $esc_tags ) ) { |
|
941 | + if ( ! $esc_tags || is_wp_error($esc_tags)) { |
|
942 | 942 | $esc_tags = ''; |
943 | 943 | } |
944 | 944 | |
@@ -948,13 +948,13 @@ discard block |
||
948 | 948 | <input type="hidden" name="tax_input[post_tag]" class="the-tags" value="<?php echo $esc_tags; // escaped in get_terms_to_edit() ?>"> |
949 | 949 | <?php |
950 | 950 | |
951 | - if ( $user_can_assign_terms ) { |
|
951 | + if ($user_can_assign_terms) { |
|
952 | 952 | ?> |
953 | 953 | <div class="ajaxtag hide-if-no-js"> |
954 | - <label class="screen-reader-text" for="new-tag-post_tag"><?php _e( 'Tags' ); ?></label> |
|
954 | + <label class="screen-reader-text" for="new-tag-post_tag"><?php _e('Tags'); ?></label> |
|
955 | 955 | <p> |
956 | 956 | <input type="text" id="new-tag-post_tag" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" aria-describedby="new-tag-desc" /> |
957 | - <button type="button" class="tagadd"><?php _e( 'Add' ); ?></button> |
|
957 | + <button type="button" class="tagadd"><?php _e('Add'); ?></button> |
|
958 | 958 | </p> |
959 | 959 | </div> |
960 | 960 | <p class="howto" id="new-tag-desc"> |
@@ -969,7 +969,7 @@ discard block |
||
969 | 969 | </div> |
970 | 970 | <?php |
971 | 971 | |
972 | - if ( $user_can_assign_terms ) { |
|
972 | + if ($user_can_assign_terms) { |
|
973 | 973 | ?> |
974 | 974 | <button type="button" class="button-link tagcloud-link" id="link-post_tag"><?php echo $taxonomy->labels->choose_from_most_used; ?></button> |
975 | 975 | <?php |
@@ -985,19 +985,19 @@ discard block |
||
985 | 985 | * @param array $data The site's data. |
986 | 986 | * @return array Embeds selected to be available. |
987 | 987 | */ |
988 | - public function get_embeds( $data ) { |
|
988 | + public function get_embeds($data) { |
|
989 | 989 | $selected_embeds = array(); |
990 | 990 | |
991 | 991 | // Make sure to add the Pressed page if it's a valid oembed itself |
992 | - if ( ! empty ( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) { |
|
992 | + if ( ! empty ($data['u']) && $this->_limit_embed($data['u'])) { |
|
993 | 993 | $data['_embeds'][] = $data['u']; |
994 | 994 | } |
995 | 995 | |
996 | - if ( ! empty( $data['_embeds'] ) ) { |
|
997 | - foreach ( $data['_embeds'] as $src ) { |
|
998 | - $prot_relative_src = preg_replace( '/^https?:/', '', $src ); |
|
996 | + if ( ! empty($data['_embeds'])) { |
|
997 | + foreach ($data['_embeds'] as $src) { |
|
998 | + $prot_relative_src = preg_replace('/^https?:/', '', $src); |
|
999 | 999 | |
1000 | - if ( in_array( $prot_relative_src, $this->embeds ) ) { |
|
1000 | + if (in_array($prot_relative_src, $this->embeds)) { |
|
1001 | 1001 | continue; |
1002 | 1002 | } |
1003 | 1003 | |
@@ -1018,19 +1018,19 @@ discard block |
||
1018 | 1018 | * @param array $data The site's data. |
1019 | 1019 | * @return array |
1020 | 1020 | */ |
1021 | - public function get_images( $data ) { |
|
1021 | + public function get_images($data) { |
|
1022 | 1022 | $selected_images = array(); |
1023 | 1023 | |
1024 | - if ( ! empty( $data['_images'] ) ) { |
|
1025 | - foreach ( $data['_images'] as $src ) { |
|
1026 | - if ( false !== strpos( $src, 'gravatar.com' ) ) { |
|
1027 | - $src = preg_replace( '%http://[\d]+\.gravatar\.com/%', 'https://secure.gravatar.com/', $src ); |
|
1024 | + if ( ! empty($data['_images'])) { |
|
1025 | + foreach ($data['_images'] as $src) { |
|
1026 | + if (false !== strpos($src, 'gravatar.com')) { |
|
1027 | + $src = preg_replace('%http://[\d]+\.gravatar\.com/%', 'https://secure.gravatar.com/', $src); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | - $prot_relative_src = preg_replace( '/^https?:/', '', $src ); |
|
1030 | + $prot_relative_src = preg_replace('/^https?:/', '', $src); |
|
1031 | 1031 | |
1032 | - if ( in_array( $prot_relative_src, $this->images ) || |
|
1033 | - ( false !== strpos( $src, 'avatar' ) && count( $this->images ) > 15 ) ) { |
|
1032 | + if (in_array($prot_relative_src, $this->images) || |
|
1033 | + (false !== strpos($src, 'avatar') && count($this->images) > 15)) { |
|
1034 | 1034 | // Skip: already selected or some type of avatar and we've already gathered more than 15 images. |
1035 | 1035 | continue; |
1036 | 1036 | } |
@@ -1052,22 +1052,22 @@ discard block |
||
1052 | 1052 | * @param array $data The site's data. |
1053 | 1053 | * @return string Discovered canonical URL, or empty |
1054 | 1054 | */ |
1055 | - public function get_canonical_link( $data ) { |
|
1055 | + public function get_canonical_link($data) { |
|
1056 | 1056 | $link = ''; |
1057 | 1057 | |
1058 | - if ( ! empty( $data['_links']['canonical'] ) ) { |
|
1058 | + if ( ! empty($data['_links']['canonical'])) { |
|
1059 | 1059 | $link = $data['_links']['canonical']; |
1060 | - } elseif ( ! empty( $data['u'] ) ) { |
|
1060 | + } elseif ( ! empty($data['u'])) { |
|
1061 | 1061 | $link = $data['u']; |
1062 | - } elseif ( ! empty( $data['_meta'] ) ) { |
|
1063 | - if ( ! empty( $data['_meta']['twitter:url'] ) ) { |
|
1062 | + } elseif ( ! empty($data['_meta'])) { |
|
1063 | + if ( ! empty($data['_meta']['twitter:url'])) { |
|
1064 | 1064 | $link = $data['_meta']['twitter:url']; |
1065 | - } else if ( ! empty( $data['_meta']['og:url'] ) ) { |
|
1065 | + } else if ( ! empty($data['_meta']['og:url'])) { |
|
1066 | 1066 | $link = $data['_meta']['og:url']; |
1067 | 1067 | } |
1068 | 1068 | } |
1069 | 1069 | |
1070 | - if ( empty( $link ) && ! empty( $data['_links']['shortlink'] ) ) { |
|
1070 | + if (empty($link) && ! empty($data['_links']['shortlink'])) { |
|
1071 | 1071 | $link = $data['_links']['shortlink']; |
1072 | 1072 | } |
1073 | 1073 | |
@@ -1083,13 +1083,13 @@ discard block |
||
1083 | 1083 | * @param array $data The site's data. |
1084 | 1084 | * @return string Discovered site name, or empty |
1085 | 1085 | */ |
1086 | - public function get_source_site_name( $data ) { |
|
1086 | + public function get_source_site_name($data) { |
|
1087 | 1087 | $name = ''; |
1088 | 1088 | |
1089 | - if ( ! empty( $data['_meta'] ) ) { |
|
1090 | - if ( ! empty( $data['_meta']['og:site_name'] ) ) { |
|
1089 | + if ( ! empty($data['_meta'])) { |
|
1090 | + if ( ! empty($data['_meta']['og:site_name'])) { |
|
1091 | 1091 | $name = $data['_meta']['og:site_name']; |
1092 | - } else if ( ! empty( $data['_meta']['application-name'] ) ) { |
|
1092 | + } else if ( ! empty($data['_meta']['application-name'])) { |
|
1093 | 1093 | $name = $data['_meta']['application-name']; |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1106,17 +1106,17 @@ discard block |
||
1106 | 1106 | * @param array $data The site's data. |
1107 | 1107 | * @return string Discovered page title, or empty |
1108 | 1108 | */ |
1109 | - public function get_suggested_title( $data ) { |
|
1109 | + public function get_suggested_title($data) { |
|
1110 | 1110 | $title = ''; |
1111 | 1111 | |
1112 | - if ( ! empty( $data['t'] ) ) { |
|
1112 | + if ( ! empty($data['t'])) { |
|
1113 | 1113 | $title = $data['t']; |
1114 | - } elseif ( ! empty( $data['_meta'] ) ) { |
|
1115 | - if ( ! empty( $data['_meta']['twitter:title'] ) ) { |
|
1114 | + } elseif ( ! empty($data['_meta'])) { |
|
1115 | + if ( ! empty($data['_meta']['twitter:title'])) { |
|
1116 | 1116 | $title = $data['_meta']['twitter:title']; |
1117 | - } else if ( ! empty( $data['_meta']['og:title'] ) ) { |
|
1117 | + } else if ( ! empty($data['_meta']['og:title'])) { |
|
1118 | 1118 | $title = $data['_meta']['og:title']; |
1119 | - } else if ( ! empty( $data['_meta']['title'] ) ) { |
|
1119 | + } else if ( ! empty($data['_meta']['title'])) { |
|
1120 | 1120 | $title = $data['_meta']['title']; |
1121 | 1121 | } |
1122 | 1122 | } |
@@ -1135,38 +1135,38 @@ discard block |
||
1135 | 1135 | * @param array $data The site's data. |
1136 | 1136 | * @return string Discovered content, or empty |
1137 | 1137 | */ |
1138 | - public function get_suggested_content( $data ) { |
|
1138 | + public function get_suggested_content($data) { |
|
1139 | 1139 | $content = $text = ''; |
1140 | 1140 | |
1141 | - if ( ! empty( $data['s'] ) ) { |
|
1141 | + if ( ! empty($data['s'])) { |
|
1142 | 1142 | $text = $data['s']; |
1143 | - } else if ( ! empty( $data['_meta'] ) ) { |
|
1144 | - if ( ! empty( $data['_meta']['twitter:description'] ) ) { |
|
1143 | + } else if ( ! empty($data['_meta'])) { |
|
1144 | + if ( ! empty($data['_meta']['twitter:description'])) { |
|
1145 | 1145 | $text = $data['_meta']['twitter:description']; |
1146 | - } else if ( ! empty( $data['_meta']['og:description'] ) ) { |
|
1146 | + } else if ( ! empty($data['_meta']['og:description'])) { |
|
1147 | 1147 | $text = $data['_meta']['og:description']; |
1148 | - } else if ( ! empty( $data['_meta']['description'] ) ) { |
|
1148 | + } else if ( ! empty($data['_meta']['description'])) { |
|
1149 | 1149 | $text = $data['_meta']['description']; |
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | // If there is an ellipsis at the end, the description is very likely auto-generated. Better to ignore it. |
1153 | - if ( $text && substr( $text, -3 ) === '...' ) { |
|
1153 | + if ($text && substr($text, -3) === '...') { |
|
1154 | 1154 | $text = ''; |
1155 | 1155 | } |
1156 | 1156 | } |
1157 | 1157 | |
1158 | - $default_html = array( 'quote' => '', 'link' => '', 'embed' => '' ); |
|
1158 | + $default_html = array('quote' => '', 'link' => '', 'embed' => ''); |
|
1159 | 1159 | |
1160 | - if ( ! empty( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) { |
|
1161 | - $default_html['embed'] = '<p>[embed]' . $data['u'] . '[/embed]</p>'; |
|
1160 | + if ( ! empty($data['u']) && $this->_limit_embed($data['u'])) { |
|
1161 | + $default_html['embed'] = '<p>[embed]'.$data['u'].'[/embed]</p>'; |
|
1162 | 1162 | |
1163 | - if ( ! empty( $data['s'] ) ) { |
|
1163 | + if ( ! empty($data['s'])) { |
|
1164 | 1164 | // If the user has selected some text, do quote it. |
1165 | 1165 | $default_html['quote'] = '<blockquote>%1$s</blockquote>'; |
1166 | 1166 | } |
1167 | 1167 | } else { |
1168 | 1168 | $default_html['quote'] = '<blockquote>%1$s</blockquote>'; |
1169 | - $default_html['link'] = '<p>' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) . |
|
1169 | + $default_html['link'] = '<p>'._x('Source:', 'Used in Press This to indicate where the content comes from.'). |
|
1170 | 1170 | ' <em><a href="%1$s">%2$s</a></em></p>'; |
1171 | 1171 | } |
1172 | 1172 | |
@@ -1183,28 +1183,28 @@ discard block |
||
1183 | 1183 | * - 'embed' which contains an [embed] shortcode when the source page offers embeddable content. |
1184 | 1184 | * @param array $data Associative array containing the data from the source page. |
1185 | 1185 | */ |
1186 | - $default_html = apply_filters( 'press_this_suggested_html', $default_html, $data ); |
|
1186 | + $default_html = apply_filters('press_this_suggested_html', $default_html, $data); |
|
1187 | 1187 | |
1188 | - if ( ! empty( $default_html['embed'] ) ) { |
|
1188 | + if ( ! empty($default_html['embed'])) { |
|
1189 | 1189 | $content .= $default_html['embed']; |
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | // Wrap suggested content in the specified HTML. |
1193 | - if ( ! empty( $default_html['quote'] ) && $text ) { |
|
1194 | - $content .= sprintf( $default_html['quote'], $text ); |
|
1193 | + if ( ! empty($default_html['quote']) && $text) { |
|
1194 | + $content .= sprintf($default_html['quote'], $text); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | // Add source attribution if there is one available. |
1198 | - if ( ! empty( $default_html['link'] ) ) { |
|
1199 | - $title = $this->get_suggested_title( $data ); |
|
1200 | - $url = $this->get_canonical_link( $data ); |
|
1198 | + if ( ! empty($default_html['link'])) { |
|
1199 | + $title = $this->get_suggested_title($data); |
|
1200 | + $url = $this->get_canonical_link($data); |
|
1201 | 1201 | |
1202 | - if ( ! $title ) { |
|
1203 | - $title = $this->get_source_site_name( $data ); |
|
1202 | + if ( ! $title) { |
|
1203 | + $title = $this->get_source_site_name($data); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | - if ( $url && $title ) { |
|
1207 | - $content .= sprintf( $default_html['link'], $url, $title ); |
|
1206 | + if ($url && $title) { |
|
1207 | + $content .= sprintf($default_html['link'], $url, $title); |
|
1208 | 1208 | } |
1209 | 1209 | } |
1210 | 1210 | |
@@ -1227,41 +1227,41 @@ discard block |
||
1227 | 1227 | // Get data, new (POST) and old (GET). |
1228 | 1228 | $data = $this->merge_or_fetch_data(); |
1229 | 1229 | |
1230 | - $post_title = $this->get_suggested_title( $data ); |
|
1230 | + $post_title = $this->get_suggested_title($data); |
|
1231 | 1231 | |
1232 | - $post_content = $this->get_suggested_content( $data ); |
|
1232 | + $post_content = $this->get_suggested_content($data); |
|
1233 | 1233 | |
1234 | 1234 | // Get site settings array/data. |
1235 | 1235 | $site_settings = $this->site_settings(); |
1236 | 1236 | |
1237 | 1237 | // Pass the images and embeds |
1238 | - $images = $this->get_images( $data ); |
|
1239 | - $embeds = $this->get_embeds( $data ); |
|
1238 | + $images = $this->get_images($data); |
|
1239 | + $embeds = $this->get_embeds($data); |
|
1240 | 1240 | |
1241 | 1241 | $site_data = array( |
1242 | - 'v' => ! empty( $data['v'] ) ? $data['v'] : '', |
|
1243 | - 'u' => ! empty( $data['u'] ) ? $data['u'] : '', |
|
1244 | - 'hasData' => ! empty( $data ), |
|
1242 | + 'v' => ! empty($data['v']) ? $data['v'] : '', |
|
1243 | + 'u' => ! empty($data['u']) ? $data['u'] : '', |
|
1244 | + 'hasData' => ! empty($data), |
|
1245 | 1245 | ); |
1246 | 1246 | |
1247 | - if ( ! empty( $images ) ) { |
|
1247 | + if ( ! empty($images)) { |
|
1248 | 1248 | $site_data['_images'] = $images; |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - if ( ! empty( $embeds ) ) { |
|
1251 | + if ( ! empty($embeds)) { |
|
1252 | 1252 | $site_data['_embeds'] = $embeds; |
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | // Add press-this-editor.css and remove theme's editor-style.css, if any. |
1256 | 1256 | remove_editor_styles(); |
1257 | 1257 | |
1258 | - add_filter( 'mce_css', array( $this, 'add_editor_style' ) ); |
|
1258 | + add_filter('mce_css', array($this, 'add_editor_style')); |
|
1259 | 1259 | |
1260 | - if ( ! empty( $GLOBALS['is_IE'] ) ) { |
|
1261 | - @header( 'X-UA-Compatible: IE=edge' ); |
|
1260 | + if ( ! empty($GLOBALS['is_IE'])) { |
|
1261 | + @header('X-UA-Compatible: IE=edge'); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | - @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
|
1264 | + @header('Content-Type: '.get_option('html_type').'; charset='.get_option('blog_charset')); |
|
1265 | 1265 | |
1266 | 1266 | ?> |
1267 | 1267 | <!DOCTYPE html> |
@@ -1269,22 +1269,22 @@ discard block |
||
1269 | 1269 | <!--[if IE 8]> <html class="lt-ie9" <?php language_attributes(); ?>> <![endif]--> |
1270 | 1270 | <!--[if gt IE 8]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> |
1271 | 1271 | <head> |
1272 | - <meta http-equiv="Content-Type" content="<?php echo esc_attr( get_bloginfo( 'html_type' ) ); ?>; charset=<?php echo esc_attr( get_option( 'blog_charset' ) ); ?>" /> |
|
1272 | + <meta http-equiv="Content-Type" content="<?php echo esc_attr(get_bloginfo('html_type')); ?>; charset=<?php echo esc_attr(get_option('blog_charset')); ?>" /> |
|
1273 | 1273 | <meta name="viewport" content="width=device-width"> |
1274 | - <title><?php esc_html_e( 'Press This!' ) ?></title> |
|
1274 | + <title><?php esc_html_e('Press This!') ?></title> |
|
1275 | 1275 | |
1276 | 1276 | <script> |
1277 | - window.wpPressThisData = <?php echo wp_json_encode( $site_data ); ?>; |
|
1278 | - window.wpPressThisConfig = <?php echo wp_json_encode( $site_settings ); ?>; |
|
1277 | + window.wpPressThisData = <?php echo wp_json_encode($site_data); ?>; |
|
1278 | + window.wpPressThisConfig = <?php echo wp_json_encode($site_settings); ?>; |
|
1279 | 1279 | </script> |
1280 | 1280 | |
1281 | 1281 | <script type="text/javascript"> |
1282 | - var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>', |
|
1282 | + var ajaxurl = '<?php echo esc_js(admin_url('admin-ajax.php', 'relative')); ?>', |
|
1283 | 1283 | pagenow = 'press-this', |
1284 | 1284 | typenow = 'post', |
1285 | 1285 | adminpage = 'press-this-php', |
1286 | - thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', |
|
1287 | - decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', |
|
1286 | + thousandsSeparator = '<?php echo addslashes($wp_locale->number_format['thousands_sep']); ?>', |
|
1287 | + decimalPoint = '<?php echo addslashes($wp_locale->number_format['decimal_point']); ?>', |
|
1288 | 1288 | isRtl = <?php echo (int) is_rtl(); ?>; |
1289 | 1289 | </script> |
1290 | 1290 | |
@@ -1293,82 +1293,82 @@ discard block |
||
1293 | 1293 | * $post->ID is needed for the embed shortcode so we can show oEmbed previews in the editor. |
1294 | 1294 | * Maybe find a way without it. |
1295 | 1295 | */ |
1296 | - $post = get_default_post_to_edit( 'post', true ); |
|
1296 | + $post = get_default_post_to_edit('post', true); |
|
1297 | 1297 | $post_ID = (int) $post->ID; |
1298 | 1298 | |
1299 | - wp_enqueue_media( array( 'post' => $post_ID ) ); |
|
1300 | - wp_enqueue_style( 'press-this' ); |
|
1301 | - wp_enqueue_script( 'press-this' ); |
|
1302 | - wp_enqueue_script( 'json2' ); |
|
1303 | - wp_enqueue_script( 'editor' ); |
|
1299 | + wp_enqueue_media(array('post' => $post_ID)); |
|
1300 | + wp_enqueue_style('press-this'); |
|
1301 | + wp_enqueue_script('press-this'); |
|
1302 | + wp_enqueue_script('json2'); |
|
1303 | + wp_enqueue_script('editor'); |
|
1304 | 1304 | |
1305 | 1305 | $supports_formats = false; |
1306 | 1306 | $post_format = 0; |
1307 | 1307 | |
1308 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
1308 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) { |
|
1309 | 1309 | $supports_formats = true; |
1310 | 1310 | |
1311 | - if ( ! ( $post_format = get_post_format( $post_ID ) ) ) { |
|
1311 | + if ( ! ($post_format = get_post_format($post_ID))) { |
|
1312 | 1312 | $post_format = 0; |
1313 | 1313 | } |
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | /** This action is documented in wp-admin/admin-header.php */ |
1317 | - do_action( 'admin_enqueue_scripts', 'press-this.php' ); |
|
1317 | + do_action('admin_enqueue_scripts', 'press-this.php'); |
|
1318 | 1318 | |
1319 | 1319 | /** This action is documented in wp-admin/admin-header.php */ |
1320 | - do_action( 'admin_print_styles-press-this.php' ); |
|
1320 | + do_action('admin_print_styles-press-this.php'); |
|
1321 | 1321 | |
1322 | 1322 | /** This action is documented in wp-admin/admin-header.php */ |
1323 | - do_action( 'admin_print_styles' ); |
|
1323 | + do_action('admin_print_styles'); |
|
1324 | 1324 | |
1325 | 1325 | /** This action is documented in wp-admin/admin-header.php */ |
1326 | - do_action( 'admin_print_scripts-press-this.php' ); |
|
1326 | + do_action('admin_print_scripts-press-this.php'); |
|
1327 | 1327 | |
1328 | 1328 | /** This action is documented in wp-admin/admin-header.php */ |
1329 | - do_action( 'admin_print_scripts' ); |
|
1329 | + do_action('admin_print_scripts'); |
|
1330 | 1330 | |
1331 | 1331 | /** This action is documented in wp-admin/admin-header.php */ |
1332 | - do_action( 'admin_head-press-this.php' ); |
|
1332 | + do_action('admin_head-press-this.php'); |
|
1333 | 1333 | |
1334 | 1334 | /** This action is documented in wp-admin/admin-header.php */ |
1335 | - do_action( 'admin_head' ); |
|
1335 | + do_action('admin_head'); |
|
1336 | 1336 | ?> |
1337 | 1337 | </head> |
1338 | 1338 | <?php |
1339 | 1339 | |
1340 | 1340 | $admin_body_class = 'press-this'; |
1341 | - $admin_body_class .= ( is_rtl() ) ? ' rtl' : ''; |
|
1342 | - $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) ); |
|
1343 | - $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) ); |
|
1344 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
1345 | - $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
|
1341 | + $admin_body_class .= (is_rtl()) ? ' rtl' : ''; |
|
1342 | + $admin_body_class .= ' branch-'.str_replace(array('.', ','), '-', floatval($wp_version)); |
|
1343 | + $admin_body_class .= ' version-'.str_replace('.', '-', preg_replace('/^([.0-9]+).*/', '$1', $wp_version)); |
|
1344 | + $admin_body_class .= ' admin-color-'.sanitize_html_class(get_user_option('admin_color'), 'fresh'); |
|
1345 | + $admin_body_class .= ' locale-'.sanitize_html_class(strtolower(str_replace('_', '-', get_locale()))); |
|
1346 | 1346 | |
1347 | 1347 | /** This filter is documented in wp-admin/admin-header.php */ |
1348 | - $admin_body_classes = apply_filters( 'admin_body_class', '' ); |
|
1348 | + $admin_body_classes = apply_filters('admin_body_class', ''); |
|
1349 | 1349 | |
1350 | 1350 | ?> |
1351 | -<body class="wp-admin wp-core-ui <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>"> |
|
1351 | +<body class="wp-admin wp-core-ui <?php echo $admin_body_classes.' '.$admin_body_class; ?>"> |
|
1352 | 1352 | <div id="adminbar" class="adminbar"> |
1353 | 1353 | <h1 id="current-site" class="current-site"> |
1354 | - <a class="current-site-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank" rel="home"> |
|
1354 | + <a class="current-site-link" href="<?php echo esc_url(home_url('/')); ?>" target="_blank" rel="home"> |
|
1355 | 1355 | <span class="dashicons dashicons-wordpress"></span> |
1356 | - <span class="current-site-name"><?php bloginfo( 'name' ); ?></span> |
|
1356 | + <span class="current-site-name"><?php bloginfo('name'); ?></span> |
|
1357 | 1357 | </a> |
1358 | 1358 | </h1> |
1359 | 1359 | <button type="button" class="options button-link closed"> |
1360 | 1360 | <span class="dashicons dashicons-tag on-closed"></span> |
1361 | - <span class="screen-reader-text on-closed"><?php _e( 'Show post options' ); ?></span> |
|
1362 | - <span aria-hidden="true" class="on-open"><?php _e( 'Done' ); ?></span> |
|
1363 | - <span class="screen-reader-text on-open"><?php _e( 'Hide post options' ); ?></span> |
|
1361 | + <span class="screen-reader-text on-closed"><?php _e('Show post options'); ?></span> |
|
1362 | + <span aria-hidden="true" class="on-open"><?php _e('Done'); ?></span> |
|
1363 | + <span class="screen-reader-text on-open"><?php _e('Hide post options'); ?></span> |
|
1364 | 1364 | </button> |
1365 | 1365 | </div> |
1366 | 1366 | |
1367 | 1367 | <div id="scanbar" class="scan"> |
1368 | 1368 | <form method="GET"> |
1369 | - <label for="url-scan" class="screen-reader-text"><?php _e( 'Scan site for content' ); ?></label> |
|
1370 | - <input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php esc_attr_e( 'Enter a URL to scan' ) ?>" /> |
|
1371 | - <input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php esc_attr_e( 'Scan' ) ?>" /> |
|
1369 | + <label for="url-scan" class="screen-reader-text"><?php _e('Scan site for content'); ?></label> |
|
1370 | + <input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php esc_attr_e('Enter a URL to scan') ?>" /> |
|
1371 | + <input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php esc_attr_e('Scan') ?>" /> |
|
1372 | 1372 | </form> |
1373 | 1373 | </div> |
1374 | 1374 | |
@@ -1381,8 +1381,8 @@ discard block |
||
1381 | 1381 | <input type="hidden" name="pt-force-redirect" id="pt-force-redirect" value="" /> |
1382 | 1382 | <?php |
1383 | 1383 | |
1384 | - wp_nonce_field( 'update-post_' . $post_ID, '_wpnonce', false ); |
|
1385 | - wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); |
|
1384 | + wp_nonce_field('update-post_'.$post_ID, '_wpnonce', false); |
|
1385 | + wp_nonce_field('add-category', '_ajax_nonce-add-category', false); |
|
1386 | 1386 | |
1387 | 1387 | ?> |
1388 | 1388 | |
@@ -1391,10 +1391,10 @@ discard block |
||
1391 | 1391 | <div class="alerts" role="alert" aria-live="assertive" aria-relevant="all" aria-atomic="true"> |
1392 | 1392 | <?php |
1393 | 1393 | |
1394 | - if ( isset( $data['v'] ) && $this->version > $data['v'] ) { |
|
1394 | + if (isset($data['v']) && $this->version > $data['v']) { |
|
1395 | 1395 | ?> |
1396 | 1396 | <p class="alert is-notice"> |
1397 | - <?php printf( __( 'You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!' ), admin_url( 'tools.php' ) ); ?> |
|
1397 | + <?php printf(__('You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!'), admin_url('tools.php')); ?> |
|
1398 | 1398 | </p> |
1399 | 1399 | <?php |
1400 | 1400 | } |
@@ -1403,18 +1403,18 @@ discard block |
||
1403 | 1403 | </div> |
1404 | 1404 | |
1405 | 1405 | <div id="app-container" class="editor"> |
1406 | - <span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e( 'Post title' ); ?></span> |
|
1407 | - <h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php esc_attr_e( 'Post title' ); ?>" tabindex="0"><?php echo esc_html( $post_title ); ?></h2> |
|
1406 | + <span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e('Post title'); ?></span> |
|
1407 | + <h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php esc_attr_e('Post title'); ?>" tabindex="0"><?php echo esc_html($post_title); ?></h2> |
|
1408 | 1408 | |
1409 | 1409 | <div class="media-list-container"> |
1410 | 1410 | <div class="media-list-inner-container"> |
1411 | - <h2 class="screen-reader-text"><?php _e( 'Suggested media' ); ?></h2> |
|
1411 | + <h2 class="screen-reader-text"><?php _e('Suggested media'); ?></h2> |
|
1412 | 1412 | <ul class="media-list"></ul> |
1413 | 1413 | </div> |
1414 | 1414 | </div> |
1415 | 1415 | |
1416 | 1416 | <?php |
1417 | - wp_editor( $post_content, 'pressthis', array( |
|
1417 | + wp_editor($post_content, 'pressthis', array( |
|
1418 | 1418 | 'drag_drop_upload' => true, |
1419 | 1419 | 'editor_height' => 600, |
1420 | 1420 | 'media_buttons' => false, |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | 'quicktags' => array( |
1435 | 1435 | 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,more', |
1436 | 1436 | ), |
1437 | - ) ); |
|
1437 | + )); |
|
1438 | 1438 | |
1439 | 1439 | ?> |
1440 | 1440 | </div> |
@@ -1444,55 +1444,55 @@ discard block |
||
1444 | 1444 | <div class="options-panel is-off-screen is-hidden" tabindex="-1"> |
1445 | 1445 | <div class="post-options"> |
1446 | 1446 | |
1447 | - <?php if ( $supports_formats ) : ?> |
|
1447 | + <?php if ($supports_formats) : ?> |
|
1448 | 1448 | <button type="button" class="button-link post-option"> |
1449 | 1449 | <span class="dashicons dashicons-admin-post"></span> |
1450 | - <span class="post-option-title"><?php _ex( 'Format', 'post format' ); ?></span> |
|
1451 | - <span class="post-option-contents" id="post-option-post-format"><?php echo esc_html( get_post_format_string( $post_format ) ); ?></span> |
|
1450 | + <span class="post-option-title"><?php _ex('Format', 'post format'); ?></span> |
|
1451 | + <span class="post-option-contents" id="post-option-post-format"><?php echo esc_html(get_post_format_string($post_format)); ?></span> |
|
1452 | 1452 | <span class="dashicons post-option-forward"></span> |
1453 | 1453 | </button> |
1454 | 1454 | <?php endif; ?> |
1455 | 1455 | |
1456 | 1456 | <button type="button" class="button-link post-option"> |
1457 | 1457 | <span class="dashicons dashicons-category"></span> |
1458 | - <span class="post-option-title"><?php _e( 'Categories' ); ?></span> |
|
1458 | + <span class="post-option-title"><?php _e('Categories'); ?></span> |
|
1459 | 1459 | <span class="dashicons post-option-forward"></span> |
1460 | 1460 | </button> |
1461 | 1461 | |
1462 | 1462 | <button type="button" class="button-link post-option"> |
1463 | 1463 | <span class="dashicons dashicons-tag"></span> |
1464 | - <span class="post-option-title"><?php _e( 'Tags' ); ?></span> |
|
1464 | + <span class="post-option-title"><?php _e('Tags'); ?></span> |
|
1465 | 1465 | <span class="dashicons post-option-forward"></span> |
1466 | 1466 | </button> |
1467 | 1467 | </div> |
1468 | 1468 | |
1469 | - <?php if ( $supports_formats ) : ?> |
|
1469 | + <?php if ($supports_formats) : ?> |
|
1470 | 1470 | <div class="setting-modal is-off-screen is-hidden"> |
1471 | 1471 | <button type="button" class="button-link modal-close"> |
1472 | 1472 | <span class="dashicons post-option-back"></span> |
1473 | - <span class="setting-title" aria-hidden="true"><?php _ex( 'Format', 'post format' ); ?></span> |
|
1474 | - <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> |
|
1473 | + <span class="setting-title" aria-hidden="true"><?php _ex('Format', 'post format'); ?></span> |
|
1474 | + <span class="screen-reader-text"><?php _e('Back to post options') ?></span> |
|
1475 | 1475 | </button> |
1476 | - <?php $this->post_formats_html( $post ); ?> |
|
1476 | + <?php $this->post_formats_html($post); ?> |
|
1477 | 1477 | </div> |
1478 | 1478 | <?php endif; ?> |
1479 | 1479 | |
1480 | 1480 | <div class="setting-modal is-off-screen is-hidden"> |
1481 | 1481 | <button type="button" class="button-link modal-close"> |
1482 | 1482 | <span class="dashicons post-option-back"></span> |
1483 | - <span class="setting-title" aria-hidden="true"><?php _e( 'Categories' ); ?></span> |
|
1484 | - <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> |
|
1483 | + <span class="setting-title" aria-hidden="true"><?php _e('Categories'); ?></span> |
|
1484 | + <span class="screen-reader-text"><?php _e('Back to post options') ?></span> |
|
1485 | 1485 | </button> |
1486 | - <?php $this->categories_html( $post ); ?> |
|
1486 | + <?php $this->categories_html($post); ?> |
|
1487 | 1487 | </div> |
1488 | 1488 | |
1489 | 1489 | <div class="setting-modal tags is-off-screen is-hidden"> |
1490 | 1490 | <button type="button" class="button-link modal-close"> |
1491 | 1491 | <span class="dashicons post-option-back"></span> |
1492 | - <span class="setting-title" aria-hidden="true"><?php _e( 'Tags' ); ?></span> |
|
1493 | - <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> |
|
1492 | + <span class="setting-title" aria-hidden="true"><?php _e('Tags'); ?></span> |
|
1493 | + <span class="screen-reader-text"><?php _e('Back to post options') ?></span> |
|
1494 | 1494 | </button> |
1495 | - <?php $this->tags_html( $post ); ?> |
|
1495 | + <?php $this->tags_html($post); ?> |
|
1496 | 1496 | </div> |
1497 | 1497 | </div><!-- .options-panel --> |
1498 | 1498 | </div><!-- .wrapper --> |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | <div class="pressthis-media-buttons"> |
1502 | 1502 | <button type="button" class="insert-media button-link" data-editor="pressthis"> |
1503 | 1503 | <span class="dashicons dashicons-admin-media"></span> |
1504 | - <span class="screen-reader-text"><?php _e( 'Add Media' ); ?></span> |
|
1504 | + <span class="screen-reader-text"><?php _e('Add Media'); ?></span> |
|
1505 | 1505 | </button> |
1506 | 1506 | </div> |
1507 | 1507 | <div class="post-actions"> |
@@ -1509,17 +1509,17 @@ discard block |
||
1509 | 1509 | <div class="split-button"> |
1510 | 1510 | <div class="split-button-head"> |
1511 | 1511 | <button type="button" class="publish-button split-button-primary" aria-live="polite"> |
1512 | - <span class="publish"><?php echo ( current_user_can( 'publish_posts' ) ) ? __( 'Publish' ) : __( 'Submit for Review' ); ?></span> |
|
1513 | - <span class="saving-draft"><?php _e( 'Saving…' ); ?></span> |
|
1512 | + <span class="publish"><?php echo (current_user_can('publish_posts')) ? __('Publish') : __('Submit for Review'); ?></span> |
|
1513 | + <span class="saving-draft"><?php _e('Saving…'); ?></span> |
|
1514 | 1514 | </button><button type="button" class="split-button-toggle" aria-haspopup="true" aria-expanded="false"> |
1515 | 1515 | <i class="dashicons dashicons-arrow-down-alt2"></i> |
1516 | 1516 | <span class="screen-reader-text"><?php _e('More actions'); ?></span> |
1517 | 1517 | </button> |
1518 | 1518 | </div> |
1519 | 1519 | <ul class="split-button-body"> |
1520 | - <li><button type="button" class="button-link draft-button split-button-option"><?php _e( 'Save Draft' ); ?></button></li> |
|
1521 | - <li><button type="button" class="button-link standard-editor-button split-button-option"><?php _e( 'Standard Editor' ); ?></button></li> |
|
1522 | - <li><button type="button" class="button-link preview-button split-button-option"><?php _e( 'Preview' ); ?></button></li> |
|
1520 | + <li><button type="button" class="button-link draft-button split-button-option"><?php _e('Save Draft'); ?></button></li> |
|
1521 | + <li><button type="button" class="button-link standard-editor-button split-button-option"><?php _e('Standard Editor'); ?></button></li> |
|
1522 | + <li><button type="button" class="button-link preview-button split-button-option"><?php _e('Preview'); ?></button></li> |
|
1523 | 1523 | </ul> |
1524 | 1524 | </div> |
1525 | 1525 | </div> |
@@ -1528,13 +1528,13 @@ discard block |
||
1528 | 1528 | |
1529 | 1529 | <?php |
1530 | 1530 | /** This action is documented in wp-admin/admin-footer.php */ |
1531 | - do_action( 'admin_footer' ); |
|
1531 | + do_action('admin_footer'); |
|
1532 | 1532 | |
1533 | 1533 | /** This action is documented in wp-admin/admin-footer.php */ |
1534 | - do_action( 'admin_print_footer_scripts' ); |
|
1534 | + do_action('admin_print_footer_scripts'); |
|
1535 | 1535 | |
1536 | 1536 | /** This action is documented in wp-admin/admin-footer.php */ |
1537 | - do_action( 'admin_footer-press-this.php' ); |
|
1537 | + do_action('admin_footer-press-this.php'); |
|
1538 | 1538 | ?> |
1539 | 1539 | </body> |
1540 | 1540 | </html> |