@@ -13,468 +13,468 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // Strip, trim, kses, special chars for string saves |
| 16 | -foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) { |
|
| 17 | - add_filter( $filter, 'sanitize_text_field' ); |
|
| 18 | - add_filter( $filter, 'wp_filter_kses' ); |
|
| 19 | - add_filter( $filter, '_wp_specialchars', 30 ); |
|
| 16 | +foreach (array('pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname') as $filter) { |
|
| 17 | + add_filter($filter, 'sanitize_text_field'); |
|
| 18 | + add_filter($filter, 'wp_filter_kses'); |
|
| 19 | + add_filter($filter, '_wp_specialchars', 30); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Strip, kses, special chars for string display |
| 23 | -foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) { |
|
| 24 | - if ( is_admin() ) { |
|
| 23 | +foreach (array('term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname') as $filter) { |
|
| 24 | + if (is_admin()) { |
|
| 25 | 25 | // These are expensive. Run only on admin pages for defense in depth. |
| 26 | - add_filter( $filter, 'sanitize_text_field' ); |
|
| 27 | - add_filter( $filter, 'wp_kses_data' ); |
|
| 26 | + add_filter($filter, 'sanitize_text_field'); |
|
| 27 | + add_filter($filter, 'wp_kses_data'); |
|
| 28 | 28 | } |
| 29 | - add_filter( $filter, '_wp_specialchars', 30 ); |
|
| 29 | + add_filter($filter, '_wp_specialchars', 30); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | // Kses only for textarea saves |
| 33 | -foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) { |
|
| 34 | - add_filter( $filter, 'wp_filter_kses' ); |
|
| 33 | +foreach (array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description') as $filter) { |
|
| 34 | + add_filter($filter, 'wp_filter_kses'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // Kses only for textarea admin displays |
| 38 | -if ( is_admin() ) { |
|
| 39 | - foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) { |
|
| 40 | - add_filter( $filter, 'wp_kses_data' ); |
|
| 38 | +if (is_admin()) { |
|
| 39 | + foreach (array('term_description', 'link_description', 'link_notes', 'user_description') as $filter) { |
|
| 40 | + add_filter($filter, 'wp_kses_data'); |
|
| 41 | 41 | } |
| 42 | - add_filter( 'comment_text', 'wp_kses_post' ); |
|
| 42 | + add_filter('comment_text', 'wp_kses_post'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Email saves |
| 46 | -foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) { |
|
| 47 | - add_filter( $filter, 'trim' ); |
|
| 48 | - add_filter( $filter, 'sanitize_email' ); |
|
| 49 | - add_filter( $filter, 'wp_filter_kses' ); |
|
| 46 | +foreach (array('pre_comment_author_email', 'pre_user_email') as $filter) { |
|
| 47 | + add_filter($filter, 'trim'); |
|
| 48 | + add_filter($filter, 'sanitize_email'); |
|
| 49 | + add_filter($filter, 'wp_filter_kses'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Email admin display |
| 53 | -foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) { |
|
| 54 | - add_filter( $filter, 'sanitize_email' ); |
|
| 55 | - if ( is_admin() ) |
|
| 56 | - add_filter( $filter, 'wp_kses_data' ); |
|
| 53 | +foreach (array('comment_author_email', 'user_email') as $filter) { |
|
| 54 | + add_filter($filter, 'sanitize_email'); |
|
| 55 | + if (is_admin()) |
|
| 56 | + add_filter($filter, 'wp_kses_data'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Save URL |
| 60 | -foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', |
|
| 61 | - 'pre_link_rss', 'pre_post_guid' ) as $filter ) { |
|
| 62 | - add_filter( $filter, 'wp_strip_all_tags' ); |
|
| 63 | - add_filter( $filter, 'esc_url_raw' ); |
|
| 64 | - add_filter( $filter, 'wp_filter_kses' ); |
|
| 60 | +foreach (array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', |
|
| 61 | + 'pre_link_rss', 'pre_post_guid') as $filter) { |
|
| 62 | + add_filter($filter, 'wp_strip_all_tags'); |
|
| 63 | + add_filter($filter, 'esc_url_raw'); |
|
| 64 | + add_filter($filter, 'wp_filter_kses'); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Display URL |
| 68 | -foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid' ) as $filter ) { |
|
| 69 | - if ( is_admin() ) |
|
| 70 | - add_filter( $filter, 'wp_strip_all_tags' ); |
|
| 71 | - add_filter( $filter, 'esc_url' ); |
|
| 72 | - if ( is_admin() ) |
|
| 73 | - add_filter( $filter, 'wp_kses_data' ); |
|
| 68 | +foreach (array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid') as $filter) { |
|
| 69 | + if (is_admin()) |
|
| 70 | + add_filter($filter, 'wp_strip_all_tags'); |
|
| 71 | + add_filter($filter, 'esc_url'); |
|
| 72 | + if (is_admin()) |
|
| 73 | + add_filter($filter, 'wp_kses_data'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // Slugs |
| 77 | -add_filter( 'pre_term_slug', 'sanitize_title' ); |
|
| 77 | +add_filter('pre_term_slug', 'sanitize_title'); |
|
| 78 | 78 | |
| 79 | 79 | // Keys |
| 80 | -foreach ( array( 'pre_post_type', 'pre_post_status', 'pre_post_comment_status', 'pre_post_ping_status' ) as $filter ) { |
|
| 81 | - add_filter( $filter, 'sanitize_key' ); |
|
| 80 | +foreach (array('pre_post_type', 'pre_post_status', 'pre_post_comment_status', 'pre_post_ping_status') as $filter) { |
|
| 81 | + add_filter($filter, 'sanitize_key'); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Mime types |
| 85 | -add_filter( 'pre_post_mime_type', 'sanitize_mime_type' ); |
|
| 86 | -add_filter( 'post_mime_type', 'sanitize_mime_type' ); |
|
| 85 | +add_filter('pre_post_mime_type', 'sanitize_mime_type'); |
|
| 86 | +add_filter('post_mime_type', 'sanitize_mime_type'); |
|
| 87 | 87 | |
| 88 | 88 | // Places to balance tags on input |
| 89 | -foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { |
|
| 90 | - add_filter( $filter, 'convert_invalid_entities' ); |
|
| 91 | - add_filter( $filter, 'balanceTags', 50 ); |
|
| 89 | +foreach (array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content') as $filter) { |
|
| 90 | + add_filter($filter, 'convert_invalid_entities'); |
|
| 91 | + add_filter($filter, 'balanceTags', 50); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // Format strings for display. |
| 95 | -foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) { |
|
| 96 | - add_filter( $filter, 'wptexturize' ); |
|
| 97 | - add_filter( $filter, 'convert_chars' ); |
|
| 98 | - add_filter( $filter, 'esc_html' ); |
|
| 95 | +foreach (array('comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title') as $filter) { |
|
| 96 | + add_filter($filter, 'wptexturize'); |
|
| 97 | + add_filter($filter, 'convert_chars'); |
|
| 98 | + add_filter($filter, 'esc_html'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Format WordPress |
| 102 | -foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter ) |
|
| 103 | - add_filter( $filter, 'capital_P_dangit', 11 ); |
|
| 104 | -add_filter( 'comment_text', 'capital_P_dangit', 31 ); |
|
| 102 | +foreach (array('the_content', 'the_title', 'wp_title') as $filter) |
|
| 103 | + add_filter($filter, 'capital_P_dangit', 11); |
|
| 104 | +add_filter('comment_text', 'capital_P_dangit', 31); |
|
| 105 | 105 | |
| 106 | 106 | // Format titles |
| 107 | -foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) { |
|
| 108 | - add_filter( $filter, 'wptexturize' ); |
|
| 109 | - add_filter( $filter, 'strip_tags' ); |
|
| 107 | +foreach (array('single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description') as $filter) { |
|
| 108 | + add_filter($filter, 'wptexturize'); |
|
| 109 | + add_filter($filter, 'strip_tags'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Format text area for display. |
| 113 | -foreach ( array( 'term_description' ) as $filter ) { |
|
| 114 | - add_filter( $filter, 'wptexturize' ); |
|
| 115 | - add_filter( $filter, 'convert_chars' ); |
|
| 116 | - add_filter( $filter, 'wpautop' ); |
|
| 117 | - add_filter( $filter, 'shortcode_unautop'); |
|
| 113 | +foreach (array('term_description') as $filter) { |
|
| 114 | + add_filter($filter, 'wptexturize'); |
|
| 115 | + add_filter($filter, 'convert_chars'); |
|
| 116 | + add_filter($filter, 'wpautop'); |
|
| 117 | + add_filter($filter, 'shortcode_unautop'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Format for RSS |
| 121 | -add_filter( 'term_name_rss', 'convert_chars' ); |
|
| 121 | +add_filter('term_name_rss', 'convert_chars'); |
|
| 122 | 122 | |
| 123 | 123 | // Pre save hierarchy |
| 124 | -add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); |
|
| 125 | -add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); |
|
| 124 | +add_filter('wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2); |
|
| 125 | +add_filter('wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3); |
|
| 126 | 126 | |
| 127 | 127 | // Display filters |
| 128 | -add_filter( 'the_title', 'wptexturize' ); |
|
| 129 | -add_filter( 'the_title', 'convert_chars' ); |
|
| 130 | -add_filter( 'the_title', 'trim' ); |
|
| 128 | +add_filter('the_title', 'wptexturize'); |
|
| 129 | +add_filter('the_title', 'convert_chars'); |
|
| 130 | +add_filter('the_title', 'trim'); |
|
| 131 | 131 | |
| 132 | -add_filter( 'the_content', 'wptexturize' ); |
|
| 133 | -add_filter( 'the_content', 'convert_smilies' ); |
|
| 134 | -add_filter( 'the_content', 'wpautop' ); |
|
| 135 | -add_filter( 'the_content', 'shortcode_unautop' ); |
|
| 136 | -add_filter( 'the_content', 'prepend_attachment' ); |
|
| 137 | -add_filter( 'the_content', 'wp_make_content_images_responsive' ); |
|
| 132 | +add_filter('the_content', 'wptexturize'); |
|
| 133 | +add_filter('the_content', 'convert_smilies'); |
|
| 134 | +add_filter('the_content', 'wpautop'); |
|
| 135 | +add_filter('the_content', 'shortcode_unautop'); |
|
| 136 | +add_filter('the_content', 'prepend_attachment'); |
|
| 137 | +add_filter('the_content', 'wp_make_content_images_responsive'); |
|
| 138 | 138 | |
| 139 | -add_filter( 'the_excerpt', 'wptexturize' ); |
|
| 140 | -add_filter( 'the_excerpt', 'convert_smilies' ); |
|
| 141 | -add_filter( 'the_excerpt', 'convert_chars' ); |
|
| 142 | -add_filter( 'the_excerpt', 'wpautop' ); |
|
| 143 | -add_filter( 'the_excerpt', 'shortcode_unautop'); |
|
| 144 | -add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); |
|
| 139 | +add_filter('the_excerpt', 'wptexturize'); |
|
| 140 | +add_filter('the_excerpt', 'convert_smilies'); |
|
| 141 | +add_filter('the_excerpt', 'convert_chars'); |
|
| 142 | +add_filter('the_excerpt', 'wpautop'); |
|
| 143 | +add_filter('the_excerpt', 'shortcode_unautop'); |
|
| 144 | +add_filter('get_the_excerpt', 'wp_trim_excerpt'); |
|
| 145 | 145 | |
| 146 | -add_filter( 'comment_text', 'wptexturize' ); |
|
| 147 | -add_filter( 'comment_text', 'convert_chars' ); |
|
| 148 | -add_filter( 'comment_text', 'make_clickable', 9 ); |
|
| 149 | -add_filter( 'comment_text', 'force_balance_tags', 25 ); |
|
| 150 | -add_filter( 'comment_text', 'convert_smilies', 20 ); |
|
| 151 | -add_filter( 'comment_text', 'wpautop', 30 ); |
|
| 146 | +add_filter('comment_text', 'wptexturize'); |
|
| 147 | +add_filter('comment_text', 'convert_chars'); |
|
| 148 | +add_filter('comment_text', 'make_clickable', 9); |
|
| 149 | +add_filter('comment_text', 'force_balance_tags', 25); |
|
| 150 | +add_filter('comment_text', 'convert_smilies', 20); |
|
| 151 | +add_filter('comment_text', 'wpautop', 30); |
|
| 152 | 152 | |
| 153 | -add_filter( 'comment_excerpt', 'convert_chars' ); |
|
| 153 | +add_filter('comment_excerpt', 'convert_chars'); |
|
| 154 | 154 | |
| 155 | -add_filter( 'list_cats', 'wptexturize' ); |
|
| 155 | +add_filter('list_cats', 'wptexturize'); |
|
| 156 | 156 | |
| 157 | -add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 ); |
|
| 157 | +add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2); |
|
| 158 | 158 | |
| 159 | -add_filter( 'widget_text', 'balanceTags' ); |
|
| 159 | +add_filter('widget_text', 'balanceTags'); |
|
| 160 | 160 | |
| 161 | -add_filter( 'date_i18n', 'wp_maybe_decline_date' ); |
|
| 161 | +add_filter('date_i18n', 'wp_maybe_decline_date'); |
|
| 162 | 162 | |
| 163 | 163 | // RSS filters |
| 164 | -add_filter( 'the_title_rss', 'strip_tags' ); |
|
| 165 | -add_filter( 'the_title_rss', 'ent2ncr', 8 ); |
|
| 166 | -add_filter( 'the_title_rss', 'esc_html' ); |
|
| 167 | -add_filter( 'the_content_rss', 'ent2ncr', 8 ); |
|
| 168 | -add_filter( 'the_content_feed', 'wp_staticize_emoji' ); |
|
| 169 | -add_filter( 'the_content_feed', '_oembed_filter_feed_content' ); |
|
| 170 | -add_filter( 'the_excerpt_rss', 'convert_chars' ); |
|
| 171 | -add_filter( 'the_excerpt_rss', 'ent2ncr', 8 ); |
|
| 172 | -add_filter( 'comment_author_rss', 'ent2ncr', 8 ); |
|
| 173 | -add_filter( 'comment_text_rss', 'ent2ncr', 8 ); |
|
| 174 | -add_filter( 'comment_text_rss', 'esc_html' ); |
|
| 175 | -add_filter( 'comment_text_rss', 'wp_staticize_emoji' ); |
|
| 176 | -add_filter( 'bloginfo_rss', 'ent2ncr', 8 ); |
|
| 177 | -add_filter( 'the_author', 'ent2ncr', 8 ); |
|
| 178 | -add_filter( 'the_guid', 'esc_url' ); |
|
| 164 | +add_filter('the_title_rss', 'strip_tags'); |
|
| 165 | +add_filter('the_title_rss', 'ent2ncr', 8); |
|
| 166 | +add_filter('the_title_rss', 'esc_html'); |
|
| 167 | +add_filter('the_content_rss', 'ent2ncr', 8); |
|
| 168 | +add_filter('the_content_feed', 'wp_staticize_emoji'); |
|
| 169 | +add_filter('the_content_feed', '_oembed_filter_feed_content'); |
|
| 170 | +add_filter('the_excerpt_rss', 'convert_chars'); |
|
| 171 | +add_filter('the_excerpt_rss', 'ent2ncr', 8); |
|
| 172 | +add_filter('comment_author_rss', 'ent2ncr', 8); |
|
| 173 | +add_filter('comment_text_rss', 'ent2ncr', 8); |
|
| 174 | +add_filter('comment_text_rss', 'esc_html'); |
|
| 175 | +add_filter('comment_text_rss', 'wp_staticize_emoji'); |
|
| 176 | +add_filter('bloginfo_rss', 'ent2ncr', 8); |
|
| 177 | +add_filter('the_author', 'ent2ncr', 8); |
|
| 178 | +add_filter('the_guid', 'esc_url'); |
|
| 179 | 179 | |
| 180 | 180 | // Email filters |
| 181 | -add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); |
|
| 181 | +add_filter('wp_mail', 'wp_staticize_emoji_for_email'); |
|
| 182 | 182 | |
| 183 | 183 | // Misc filters |
| 184 | -add_filter( 'option_ping_sites', 'privacy_ping_filter' ); |
|
| 185 | -add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop |
|
| 186 | -add_filter( 'option_blog_charset', '_canonical_charset' ); |
|
| 187 | -add_filter( 'option_home', '_config_wp_home' ); |
|
| 188 | -add_filter( 'option_siteurl', '_config_wp_siteurl' ); |
|
| 189 | -add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); |
|
| 190 | -add_filter( 'teeny_mce_before_init', '_mce_set_direction' ); |
|
| 191 | -add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); |
|
| 192 | -add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); |
|
| 193 | -add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); |
|
| 194 | -add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); |
|
| 195 | -add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); |
|
| 196 | -add_filter( 'comment_email', 'antispambot' ); |
|
| 197 | -add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); |
|
| 198 | -add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); |
|
| 199 | -add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2); |
|
| 200 | -add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); |
|
| 201 | -add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); |
|
| 202 | -add_filter( 'editable_slug', 'urldecode' ); |
|
| 203 | -add_filter( 'editable_slug', 'esc_textarea' ); |
|
| 204 | -add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); |
|
| 205 | -add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri' ); |
|
| 206 | -add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' ); |
|
| 207 | -add_filter( 'title_save_pre', 'trim' ); |
|
| 208 | - |
|
| 209 | -add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); |
|
| 184 | +add_filter('option_ping_sites', 'privacy_ping_filter'); |
|
| 185 | +add_filter('option_blog_charset', '_wp_specialchars'); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop |
|
| 186 | +add_filter('option_blog_charset', '_canonical_charset'); |
|
| 187 | +add_filter('option_home', '_config_wp_home'); |
|
| 188 | +add_filter('option_siteurl', '_config_wp_siteurl'); |
|
| 189 | +add_filter('tiny_mce_before_init', '_mce_set_direction'); |
|
| 190 | +add_filter('teeny_mce_before_init', '_mce_set_direction'); |
|
| 191 | +add_filter('pre_kses', 'wp_pre_kses_less_than'); |
|
| 192 | +add_filter('sanitize_title', 'sanitize_title_with_dashes', 10, 3); |
|
| 193 | +add_action('check_comment_flood', 'check_comment_flood_db', 10, 3); |
|
| 194 | +add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3); |
|
| 195 | +add_filter('pre_comment_content', 'wp_rel_nofollow', 15); |
|
| 196 | +add_filter('comment_email', 'antispambot'); |
|
| 197 | +add_filter('option_tag_base', '_wp_filter_taxonomy_base'); |
|
| 198 | +add_filter('option_category_base', '_wp_filter_taxonomy_base'); |
|
| 199 | +add_filter('the_posts', '_close_comments_for_old_posts', 10, 2); |
|
| 200 | +add_filter('comments_open', '_close_comments_for_old_post', 10, 2); |
|
| 201 | +add_filter('pings_open', '_close_comments_for_old_post', 10, 2); |
|
| 202 | +add_filter('editable_slug', 'urldecode'); |
|
| 203 | +add_filter('editable_slug', 'esc_textarea'); |
|
| 204 | +add_filter('nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'); |
|
| 205 | +add_filter('pingback_ping_source_uri', 'pingback_ping_source_uri'); |
|
| 206 | +add_filter('xmlrpc_pingback_error', 'xmlrpc_pingback_error'); |
|
| 207 | +add_filter('title_save_pre', 'trim'); |
|
| 208 | + |
|
| 209 | +add_filter('http_request_host_is_external', 'allowed_http_request_hosts', 10, 2); |
|
| 210 | 210 | |
| 211 | 211 | // REST API filters. |
| 212 | -add_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); |
|
| 213 | -add_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); |
|
| 214 | -add_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); |
|
| 215 | -add_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); |
|
| 216 | -add_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); |
|
| 217 | -add_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); |
|
| 218 | -add_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); |
|
| 219 | -add_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); |
|
| 220 | -add_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); |
|
| 212 | +add_action('xmlrpc_rsd_apis', 'rest_output_rsd'); |
|
| 213 | +add_action('wp_head', 'rest_output_link_wp_head', 10, 0); |
|
| 214 | +add_action('template_redirect', 'rest_output_link_header', 11, 0); |
|
| 215 | +add_action('auth_cookie_malformed', 'rest_cookie_collect_status'); |
|
| 216 | +add_action('auth_cookie_expired', 'rest_cookie_collect_status'); |
|
| 217 | +add_action('auth_cookie_bad_username', 'rest_cookie_collect_status'); |
|
| 218 | +add_action('auth_cookie_bad_hash', 'rest_cookie_collect_status'); |
|
| 219 | +add_action('auth_cookie_valid', 'rest_cookie_collect_status'); |
|
| 220 | +add_filter('rest_authentication_errors', 'rest_cookie_check_errors', 100); |
|
| 221 | 221 | |
| 222 | 222 | // Actions |
| 223 | -add_action( 'wp_head', '_wp_render_title_tag', 1 ); |
|
| 224 | -add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); |
|
| 225 | -add_action( 'wp_head', 'feed_links', 2 ); |
|
| 226 | -add_action( 'wp_head', 'feed_links_extra', 3 ); |
|
| 227 | -add_action( 'wp_head', 'rsd_link' ); |
|
| 228 | -add_action( 'wp_head', 'wlwmanifest_link' ); |
|
| 229 | -add_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); |
|
| 230 | -add_action( 'wp_head', 'locale_stylesheet' ); |
|
| 231 | -add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); |
|
| 232 | -add_action( 'wp_head', 'noindex', 1 ); |
|
| 233 | -add_action( 'wp_head', 'print_emoji_detection_script', 7 ); |
|
| 234 | -add_action( 'wp_head', 'wp_print_styles', 8 ); |
|
| 235 | -add_action( 'wp_head', 'wp_print_head_scripts', 9 ); |
|
| 236 | -add_action( 'wp_head', 'wp_generator' ); |
|
| 237 | -add_action( 'wp_head', 'rel_canonical' ); |
|
| 238 | -add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); |
|
| 239 | -add_action( 'wp_head', 'wp_site_icon', 99 ); |
|
| 240 | -add_action( 'wp_footer', 'wp_print_footer_scripts', 20 ); |
|
| 241 | -add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 ); |
|
| 242 | -add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); |
|
| 243 | -add_action( 'init', 'check_theme_switched', 99 ); |
|
| 244 | -add_action( 'after_switch_theme', '_wp_sidebars_changed' ); |
|
| 245 | -add_action( 'wp_print_styles', 'print_emoji_styles' ); |
|
| 246 | - |
|
| 247 | -if ( isset( $_GET['replytocom'] ) ) |
|
| 248 | - add_action( 'wp_head', 'wp_no_robots' ); |
|
| 223 | +add_action('wp_head', '_wp_render_title_tag', 1); |
|
| 224 | +add_action('wp_head', 'wp_enqueue_scripts', 1); |
|
| 225 | +add_action('wp_head', 'feed_links', 2); |
|
| 226 | +add_action('wp_head', 'feed_links_extra', 3); |
|
| 227 | +add_action('wp_head', 'rsd_link'); |
|
| 228 | +add_action('wp_head', 'wlwmanifest_link'); |
|
| 229 | +add_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); |
|
| 230 | +add_action('wp_head', 'locale_stylesheet'); |
|
| 231 | +add_action('publish_future_post', 'check_and_publish_future_post', 10, 1); |
|
| 232 | +add_action('wp_head', 'noindex', 1); |
|
| 233 | +add_action('wp_head', 'print_emoji_detection_script', 7); |
|
| 234 | +add_action('wp_head', 'wp_print_styles', 8); |
|
| 235 | +add_action('wp_head', 'wp_print_head_scripts', 9); |
|
| 236 | +add_action('wp_head', 'wp_generator'); |
|
| 237 | +add_action('wp_head', 'rel_canonical'); |
|
| 238 | +add_action('wp_head', 'wp_shortlink_wp_head', 10, 0); |
|
| 239 | +add_action('wp_head', 'wp_site_icon', 99); |
|
| 240 | +add_action('wp_footer', 'wp_print_footer_scripts', 20); |
|
| 241 | +add_action('template_redirect', 'wp_shortlink_header', 11, 0); |
|
| 242 | +add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
| 243 | +add_action('init', 'check_theme_switched', 99); |
|
| 244 | +add_action('after_switch_theme', '_wp_sidebars_changed'); |
|
| 245 | +add_action('wp_print_styles', 'print_emoji_styles'); |
|
| 246 | + |
|
| 247 | +if (isset($_GET['replytocom'])) |
|
| 248 | + add_action('wp_head', 'wp_no_robots'); |
|
| 249 | 249 | |
| 250 | 250 | // Login actions |
| 251 | -add_action( 'login_head', 'wp_print_head_scripts', 9 ); |
|
| 252 | -add_action( 'login_head', 'print_admin_styles', 9 ); |
|
| 253 | -add_action( 'login_head', 'wp_site_icon', 99 ); |
|
| 254 | -add_action( 'login_footer', 'wp_print_footer_scripts', 20 ); |
|
| 255 | -add_action( 'login_init', 'send_frame_options_header', 10, 0 ); |
|
| 251 | +add_action('login_head', 'wp_print_head_scripts', 9); |
|
| 252 | +add_action('login_head', 'print_admin_styles', 9); |
|
| 253 | +add_action('login_head', 'wp_site_icon', 99); |
|
| 254 | +add_action('login_footer', 'wp_print_footer_scripts', 20); |
|
| 255 | +add_action('login_init', 'send_frame_options_header', 10, 0); |
|
| 256 | 256 | |
| 257 | 257 | // Feed Generator Tags |
| 258 | -foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) { |
|
| 259 | - add_action( $action, 'the_generator' ); |
|
| 258 | +foreach (array('rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head') as $action) { |
|
| 259 | + add_action($action, 'the_generator'); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // Feed Site Icon |
| 263 | -add_action( 'atom_head', 'atom_site_icon' ); |
|
| 264 | -add_action( 'rss2_head', 'rss2_site_icon' ); |
|
| 263 | +add_action('atom_head', 'atom_site_icon'); |
|
| 264 | +add_action('rss2_head', 'rss2_site_icon'); |
|
| 265 | 265 | |
| 266 | 266 | |
| 267 | 267 | // WP Cron |
| 268 | -if ( !defined( 'DOING_CRON' ) ) |
|
| 269 | - add_action( 'init', 'wp_cron' ); |
|
| 268 | +if ( ! defined('DOING_CRON')) |
|
| 269 | + add_action('init', 'wp_cron'); |
|
| 270 | 270 | |
| 271 | 271 | // 2 Actions 2 Furious |
| 272 | -add_action( 'do_feed_rdf', 'do_feed_rdf', 10, 1 ); |
|
| 273 | -add_action( 'do_feed_rss', 'do_feed_rss', 10, 1 ); |
|
| 274 | -add_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 ); |
|
| 275 | -add_action( 'do_feed_atom', 'do_feed_atom', 10, 1 ); |
|
| 276 | -add_action( 'do_pings', 'do_all_pings', 10, 1 ); |
|
| 277 | -add_action( 'do_robots', 'do_robots' ); |
|
| 278 | -add_action( 'set_comment_cookies', 'wp_set_comment_cookies', 10, 2 ); |
|
| 279 | -add_action( 'sanitize_comment_cookies', 'sanitize_comment_cookies' ); |
|
| 280 | -add_action( 'admin_print_scripts', 'print_emoji_detection_script' ); |
|
| 281 | -add_action( 'admin_print_scripts', 'print_head_scripts', 20 ); |
|
| 282 | -add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' ); |
|
| 283 | -add_action( 'admin_print_styles', 'print_emoji_styles' ); |
|
| 284 | -add_action( 'admin_print_styles', 'print_admin_styles', 20 ); |
|
| 285 | -add_action( 'init', 'smilies_init', 5 ); |
|
| 286 | -add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); |
|
| 287 | -add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); |
|
| 288 | -add_action( 'shutdown', 'wp_ob_end_flush_all', 1 ); |
|
| 272 | +add_action('do_feed_rdf', 'do_feed_rdf', 10, 1); |
|
| 273 | +add_action('do_feed_rss', 'do_feed_rss', 10, 1); |
|
| 274 | +add_action('do_feed_rss2', 'do_feed_rss2', 10, 1); |
|
| 275 | +add_action('do_feed_atom', 'do_feed_atom', 10, 1); |
|
| 276 | +add_action('do_pings', 'do_all_pings', 10, 1); |
|
| 277 | +add_action('do_robots', 'do_robots'); |
|
| 278 | +add_action('set_comment_cookies', 'wp_set_comment_cookies', 10, 2); |
|
| 279 | +add_action('sanitize_comment_cookies', 'sanitize_comment_cookies'); |
|
| 280 | +add_action('admin_print_scripts', 'print_emoji_detection_script'); |
|
| 281 | +add_action('admin_print_scripts', 'print_head_scripts', 20); |
|
| 282 | +add_action('admin_print_footer_scripts', '_wp_footer_scripts'); |
|
| 283 | +add_action('admin_print_styles', 'print_emoji_styles'); |
|
| 284 | +add_action('admin_print_styles', 'print_admin_styles', 20); |
|
| 285 | +add_action('init', 'smilies_init', 5); |
|
| 286 | +add_action('plugins_loaded', 'wp_maybe_load_widgets', 0); |
|
| 287 | +add_action('plugins_loaded', 'wp_maybe_load_embeds', 0); |
|
| 288 | +add_action('shutdown', 'wp_ob_end_flush_all', 1); |
|
| 289 | 289 | // Create a revision whenever a post is updated. |
| 290 | -add_action( 'post_updated', 'wp_save_post_revision', 10, 1 ); |
|
| 291 | -add_action( 'publish_post', '_publish_post_hook', 5, 1 ); |
|
| 292 | -add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); |
|
| 293 | -add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 ); |
|
| 294 | -add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); |
|
| 295 | -add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' ); |
|
| 296 | -add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' ); |
|
| 297 | -add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); |
|
| 298 | -add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' ); |
|
| 299 | -add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' ); |
|
| 300 | -add_action( 'welcome_panel', 'wp_welcome_panel' ); |
|
| 290 | +add_action('post_updated', 'wp_save_post_revision', 10, 1); |
|
| 291 | +add_action('publish_post', '_publish_post_hook', 5, 1); |
|
| 292 | +add_action('transition_post_status', '_transition_post_status', 5, 3); |
|
| 293 | +add_action('transition_post_status', '_update_term_count_on_transition_post_status', 10, 3); |
|
| 294 | +add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce'); |
|
| 295 | +add_action('wp_scheduled_delete', 'wp_scheduled_delete'); |
|
| 296 | +add_action('wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts'); |
|
| 297 | +add_action('admin_init', 'send_frame_options_header', 10, 0); |
|
| 298 | +add_action('importer_scheduled_cleanup', 'wp_delete_attachment'); |
|
| 299 | +add_action('upgrader_scheduled_cleanup', 'wp_delete_attachment'); |
|
| 300 | +add_action('welcome_panel', 'wp_welcome_panel'); |
|
| 301 | 301 | |
| 302 | 302 | // Navigation menu actions |
| 303 | -add_action( 'delete_post', '_wp_delete_post_menu_item' ); |
|
| 304 | -add_action( 'delete_term', '_wp_delete_tax_menu_item', 10, 3 ); |
|
| 305 | -add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 ); |
|
| 303 | +add_action('delete_post', '_wp_delete_post_menu_item'); |
|
| 304 | +add_action('delete_term', '_wp_delete_tax_menu_item', 10, 3); |
|
| 305 | +add_action('transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3); |
|
| 306 | 306 | |
| 307 | 307 | // Post Thumbnail CSS class filtering |
| 308 | -add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' ); |
|
| 309 | -add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove' ); |
|
| 308 | +add_action('begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'); |
|
| 309 | +add_action('end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove'); |
|
| 310 | 310 | |
| 311 | 311 | // Redirect Old Slugs |
| 312 | -add_action( 'template_redirect', 'wp_old_slug_redirect' ); |
|
| 313 | -add_action( 'post_updated', 'wp_check_for_changed_slugs', 12, 3 ); |
|
| 314 | -add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 ); |
|
| 312 | +add_action('template_redirect', 'wp_old_slug_redirect'); |
|
| 313 | +add_action('post_updated', 'wp_check_for_changed_slugs', 12, 3); |
|
| 314 | +add_action('attachment_updated', 'wp_check_for_changed_slugs', 12, 3); |
|
| 315 | 315 | |
| 316 | 316 | // Nonce check for Post Previews |
| 317 | -add_action( 'init', '_show_post_preview' ); |
|
| 317 | +add_action('init', '_show_post_preview'); |
|
| 318 | 318 | |
| 319 | 319 | // Output JS to reset window.name for previews |
| 320 | -add_action( 'wp_head', 'wp_post_preview_js', 1 ); |
|
| 320 | +add_action('wp_head', 'wp_post_preview_js', 1); |
|
| 321 | 321 | |
| 322 | 322 | // Timezone |
| 323 | -add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' ); |
|
| 323 | +add_filter('pre_option_gmt_offset', 'wp_timezone_override_offset'); |
|
| 324 | 324 | |
| 325 | 325 | // Admin Color Schemes |
| 326 | -add_action( 'admin_init', 'register_admin_color_schemes', 1); |
|
| 327 | -add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); |
|
| 326 | +add_action('admin_init', 'register_admin_color_schemes', 1); |
|
| 327 | +add_action('admin_color_scheme_picker', 'admin_color_scheme_picker'); |
|
| 328 | 328 | |
| 329 | 329 | // If the upgrade hasn't run yet, assume link manager is used. |
| 330 | -add_filter( 'default_option_link_manager_enabled', '__return_true' ); |
|
| 330 | +add_filter('default_option_link_manager_enabled', '__return_true'); |
|
| 331 | 331 | |
| 332 | 332 | // This option no longer exists; tell plugins we always support auto-embedding. |
| 333 | -add_filter( 'default_option_embed_autourls', '__return_true' ); |
|
| 333 | +add_filter('default_option_embed_autourls', '__return_true'); |
|
| 334 | 334 | |
| 335 | 335 | // Default settings for heartbeat |
| 336 | -add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' ); |
|
| 336 | +add_filter('heartbeat_settings', 'wp_heartbeat_settings'); |
|
| 337 | 337 | |
| 338 | 338 | // Check if the user is logged out |
| 339 | -add_action( 'admin_enqueue_scripts', 'wp_auth_check_load' ); |
|
| 340 | -add_filter( 'heartbeat_send', 'wp_auth_check' ); |
|
| 341 | -add_filter( 'heartbeat_nopriv_send', 'wp_auth_check' ); |
|
| 339 | +add_action('admin_enqueue_scripts', 'wp_auth_check_load'); |
|
| 340 | +add_filter('heartbeat_send', 'wp_auth_check'); |
|
| 341 | +add_filter('heartbeat_nopriv_send', 'wp_auth_check'); |
|
| 342 | 342 | |
| 343 | 343 | // Default authentication filters |
| 344 | -add_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); |
|
| 345 | -add_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 ); |
|
| 346 | -add_filter( 'authenticate', 'wp_authenticate_spam_check', 99 ); |
|
| 347 | -add_filter( 'determine_current_user', 'wp_validate_auth_cookie' ); |
|
| 348 | -add_filter( 'determine_current_user', 'wp_validate_logged_in_cookie', 20 ); |
|
| 344 | +add_filter('authenticate', 'wp_authenticate_username_password', 20, 3); |
|
| 345 | +add_filter('authenticate', 'wp_authenticate_email_password', 20, 3); |
|
| 346 | +add_filter('authenticate', 'wp_authenticate_spam_check', 99); |
|
| 347 | +add_filter('determine_current_user', 'wp_validate_auth_cookie'); |
|
| 348 | +add_filter('determine_current_user', 'wp_validate_logged_in_cookie', 20); |
|
| 349 | 349 | |
| 350 | 350 | // Split term updates. |
| 351 | -add_action( 'admin_init', '_wp_check_for_scheduled_split_terms' ); |
|
| 352 | -add_action( 'split_shared_term', '_wp_check_split_default_terms', 10, 4 ); |
|
| 353 | -add_action( 'split_shared_term', '_wp_check_split_terms_in_menus', 10, 4 ); |
|
| 354 | -add_action( 'split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4 ); |
|
| 355 | -add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' ); |
|
| 351 | +add_action('admin_init', '_wp_check_for_scheduled_split_terms'); |
|
| 352 | +add_action('split_shared_term', '_wp_check_split_default_terms', 10, 4); |
|
| 353 | +add_action('split_shared_term', '_wp_check_split_terms_in_menus', 10, 4); |
|
| 354 | +add_action('split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4); |
|
| 355 | +add_action('wp_split_shared_term_batch', '_wp_batch_split_terms'); |
|
| 356 | 356 | |
| 357 | 357 | // Email notifications. |
| 358 | -add_action( 'comment_post', 'wp_new_comment_notify_moderator' ); |
|
| 359 | -add_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); |
|
| 360 | -add_action( 'after_password_reset', 'wp_password_change_notification' ); |
|
| 361 | -add_action( 'register_new_user', 'wp_send_new_user_notifications' ); |
|
| 362 | -add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); |
|
| 358 | +add_action('comment_post', 'wp_new_comment_notify_moderator'); |
|
| 359 | +add_action('comment_post', 'wp_new_comment_notify_postauthor'); |
|
| 360 | +add_action('after_password_reset', 'wp_password_change_notification'); |
|
| 361 | +add_action('register_new_user', 'wp_send_new_user_notifications'); |
|
| 362 | +add_action('edit_user_created_user', 'wp_send_new_user_notifications', 10, 2); |
|
| 363 | 363 | |
| 364 | 364 | // REST API actions. |
| 365 | -add_action( 'init', 'rest_api_init' ); |
|
| 366 | -add_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); |
|
| 367 | -add_action( 'parse_request', 'rest_api_loaded' ); |
|
| 365 | +add_action('init', 'rest_api_init'); |
|
| 366 | +add_action('rest_api_init', 'rest_api_default_filters', 10, 1); |
|
| 367 | +add_action('parse_request', 'rest_api_loaded'); |
|
| 368 | 368 | |
| 369 | 369 | /** |
| 370 | 370 | * Filters formerly mixed into wp-includes |
| 371 | 371 | */ |
| 372 | 372 | // Theme |
| 373 | -add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); |
|
| 374 | -add_action( 'wp_head', '_custom_logo_header_styles' ); |
|
| 375 | -add_action( 'plugins_loaded', '_wp_customize_include' ); |
|
| 376 | -add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); |
|
| 377 | -add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); |
|
| 373 | +add_action('wp_loaded', '_custom_header_background_just_in_time'); |
|
| 374 | +add_action('wp_head', '_custom_logo_header_styles'); |
|
| 375 | +add_action('plugins_loaded', '_wp_customize_include'); |
|
| 376 | +add_action('admin_enqueue_scripts', '_wp_customize_loader_settings'); |
|
| 377 | +add_action('delete_attachment', '_delete_attachment_theme_mod'); |
|
| 378 | 378 | |
| 379 | 379 | // Calendar widget cache |
| 380 | -add_action( 'save_post', 'delete_get_calendar_cache' ); |
|
| 381 | -add_action( 'delete_post', 'delete_get_calendar_cache' ); |
|
| 382 | -add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); |
|
| 383 | -add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); |
|
| 380 | +add_action('save_post', 'delete_get_calendar_cache'); |
|
| 381 | +add_action('delete_post', 'delete_get_calendar_cache'); |
|
| 382 | +add_action('update_option_start_of_week', 'delete_get_calendar_cache'); |
|
| 383 | +add_action('update_option_gmt_offset', 'delete_get_calendar_cache'); |
|
| 384 | 384 | |
| 385 | 385 | // Author |
| 386 | -add_action( 'transition_post_status', '__clear_multi_author_cache' ); |
|
| 386 | +add_action('transition_post_status', '__clear_multi_author_cache'); |
|
| 387 | 387 | |
| 388 | 388 | // Post |
| 389 | -add_action( 'init', 'create_initial_post_types', 0 ); // highest priority |
|
| 390 | -add_action( 'admin_menu', '_add_post_type_submenus' ); |
|
| 391 | -add_action( 'before_delete_post', '_reset_front_page_settings_for_post' ); |
|
| 392 | -add_action( 'wp_trash_post', '_reset_front_page_settings_for_post' ); |
|
| 389 | +add_action('init', 'create_initial_post_types', 0); // highest priority |
|
| 390 | +add_action('admin_menu', '_add_post_type_submenus'); |
|
| 391 | +add_action('before_delete_post', '_reset_front_page_settings_for_post'); |
|
| 392 | +add_action('wp_trash_post', '_reset_front_page_settings_for_post'); |
|
| 393 | 393 | |
| 394 | 394 | // Post Formats |
| 395 | -add_filter( 'request', '_post_format_request' ); |
|
| 396 | -add_filter( 'term_link', '_post_format_link', 10, 3 ); |
|
| 397 | -add_filter( 'get_post_format', '_post_format_get_term' ); |
|
| 398 | -add_filter( 'get_terms', '_post_format_get_terms', 10, 3 ); |
|
| 399 | -add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); |
|
| 395 | +add_filter('request', '_post_format_request'); |
|
| 396 | +add_filter('term_link', '_post_format_link', 10, 3); |
|
| 397 | +add_filter('get_post_format', '_post_format_get_term'); |
|
| 398 | +add_filter('get_terms', '_post_format_get_terms', 10, 3); |
|
| 399 | +add_filter('wp_get_object_terms', '_post_format_wp_get_object_terms'); |
|
| 400 | 400 | |
| 401 | 401 | // KSES |
| 402 | -add_action( 'init', 'kses_init' ); |
|
| 403 | -add_action( 'set_current_user', 'kses_init' ); |
|
| 402 | +add_action('init', 'kses_init'); |
|
| 403 | +add_action('set_current_user', 'kses_init'); |
|
| 404 | 404 | |
| 405 | 405 | // Script Loader |
| 406 | -add_action( 'wp_default_scripts', 'wp_default_scripts' ); |
|
| 407 | -add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); |
|
| 408 | -add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); |
|
| 406 | +add_action('wp_default_scripts', 'wp_default_scripts'); |
|
| 407 | +add_filter('wp_print_scripts', 'wp_just_in_time_script_localization'); |
|
| 408 | +add_filter('print_scripts_array', 'wp_prototype_before_jquery'); |
|
| 409 | 409 | |
| 410 | -add_action( 'wp_default_styles', 'wp_default_styles' ); |
|
| 411 | -add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); |
|
| 410 | +add_action('wp_default_styles', 'wp_default_styles'); |
|
| 411 | +add_filter('style_loader_src', 'wp_style_loader_src', 10, 2); |
|
| 412 | 412 | |
| 413 | 413 | // Taxonomy |
| 414 | -add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority |
|
| 414 | +add_action('init', 'create_initial_taxonomies', 0); // highest priority |
|
| 415 | 415 | |
| 416 | 416 | // Canonical |
| 417 | -add_action( 'template_redirect', 'redirect_canonical' ); |
|
| 418 | -add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 ); |
|
| 417 | +add_action('template_redirect', 'redirect_canonical'); |
|
| 418 | +add_action('template_redirect', 'wp_redirect_admin_locations', 1000); |
|
| 419 | 419 | |
| 420 | 420 | // Shortcodes |
| 421 | -add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop() |
|
| 421 | +add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() |
|
| 422 | 422 | |
| 423 | 423 | // Media |
| 424 | -add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' ); |
|
| 425 | -add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' ); |
|
| 424 | +add_action('wp_playlist_scripts', 'wp_playlist_scripts'); |
|
| 425 | +add_action('customize_controls_enqueue_scripts', 'wp_plupload_default_settings'); |
|
| 426 | 426 | |
| 427 | 427 | // Nav menu |
| 428 | -add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); |
|
| 428 | +add_filter('nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2); |
|
| 429 | 429 | |
| 430 | 430 | // Widgets |
| 431 | -add_action( 'init', 'wp_widgets_init', 1 ); |
|
| 431 | +add_action('init', 'wp_widgets_init', 1); |
|
| 432 | 432 | |
| 433 | 433 | // Admin Bar |
| 434 | 434 | // Don't remove. Wrong way to disable. |
| 435 | -add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); |
|
| 436 | -add_action( 'admin_init', '_wp_admin_bar_init' ); |
|
| 437 | -add_action( 'before_signup_header', '_wp_admin_bar_init' ); |
|
| 438 | -add_action( 'activate_header', '_wp_admin_bar_init' ); |
|
| 439 | -add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); |
|
| 440 | -add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); |
|
| 435 | +add_action('template_redirect', '_wp_admin_bar_init', 0); |
|
| 436 | +add_action('admin_init', '_wp_admin_bar_init'); |
|
| 437 | +add_action('before_signup_header', '_wp_admin_bar_init'); |
|
| 438 | +add_action('activate_header', '_wp_admin_bar_init'); |
|
| 439 | +add_action('wp_footer', 'wp_admin_bar_render', 1000); |
|
| 440 | +add_action('in_admin_header', 'wp_admin_bar_render', 0); |
|
| 441 | 441 | |
| 442 | 442 | // Former admin filters that can also be hooked on the front end |
| 443 | -add_action( 'media_buttons', 'media_buttons' ); |
|
| 444 | -add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); |
|
| 445 | -add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 ); |
|
| 443 | +add_action('media_buttons', 'media_buttons'); |
|
| 444 | +add_filter('image_send_to_editor', 'image_add_caption', 20, 8); |
|
| 445 | +add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); |
|
| 446 | 446 | |
| 447 | 447 | // Embeds |
| 448 | -add_action( 'rest_api_init', 'wp_oembed_register_route' ); |
|
| 449 | -add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); |
|
| 450 | - |
|
| 451 | -add_action( 'wp_head', 'wp_oembed_add_discovery_links' ); |
|
| 452 | -add_action( 'wp_head', 'wp_oembed_add_host_js' ); |
|
| 453 | - |
|
| 454 | -add_action( 'embed_head', 'enqueue_embed_scripts', 1 ); |
|
| 455 | -add_action( 'embed_head', 'print_emoji_detection_script' ); |
|
| 456 | -add_action( 'embed_head', 'print_embed_styles' ); |
|
| 457 | -add_action( 'embed_head', 'wp_print_head_scripts', 20 ); |
|
| 458 | -add_action( 'embed_head', 'wp_print_styles', 20 ); |
|
| 459 | -add_action( 'embed_head', 'wp_no_robots' ); |
|
| 460 | -add_action( 'embed_head', 'rel_canonical' ); |
|
| 461 | -add_action( 'embed_head', 'locale_stylesheet' ); |
|
| 462 | - |
|
| 463 | -add_action( 'embed_content_meta', 'print_embed_comments_button' ); |
|
| 464 | -add_action( 'embed_content_meta', 'print_embed_sharing_button' ); |
|
| 465 | - |
|
| 466 | -add_action( 'embed_footer', 'print_embed_sharing_dialog' ); |
|
| 467 | -add_action( 'embed_footer', 'print_embed_scripts' ); |
|
| 468 | -add_action( 'embed_footer', 'wp_print_footer_scripts', 20 ); |
|
| 469 | - |
|
| 470 | -add_filter( 'excerpt_more', 'wp_embed_excerpt_more', 20 ); |
|
| 471 | -add_filter( 'the_excerpt_embed', 'wptexturize' ); |
|
| 472 | -add_filter( 'the_excerpt_embed', 'convert_chars' ); |
|
| 473 | -add_filter( 'the_excerpt_embed', 'wpautop' ); |
|
| 474 | -add_filter( 'the_excerpt_embed', 'shortcode_unautop' ); |
|
| 475 | -add_filter( 'the_excerpt_embed', 'wp_embed_excerpt_attachment' ); |
|
| 476 | - |
|
| 477 | -add_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10, 3 ); |
|
| 478 | -add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 ); |
|
| 479 | - |
|
| 480 | -unset( $filter, $action ); |
|
| 448 | +add_action('rest_api_init', 'wp_oembed_register_route'); |
|
| 449 | +add_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4); |
|
| 450 | + |
|
| 451 | +add_action('wp_head', 'wp_oembed_add_discovery_links'); |
|
| 452 | +add_action('wp_head', 'wp_oembed_add_host_js'); |
|
| 453 | + |
|
| 454 | +add_action('embed_head', 'enqueue_embed_scripts', 1); |
|
| 455 | +add_action('embed_head', 'print_emoji_detection_script'); |
|
| 456 | +add_action('embed_head', 'print_embed_styles'); |
|
| 457 | +add_action('embed_head', 'wp_print_head_scripts', 20); |
|
| 458 | +add_action('embed_head', 'wp_print_styles', 20); |
|
| 459 | +add_action('embed_head', 'wp_no_robots'); |
|
| 460 | +add_action('embed_head', 'rel_canonical'); |
|
| 461 | +add_action('embed_head', 'locale_stylesheet'); |
|
| 462 | + |
|
| 463 | +add_action('embed_content_meta', 'print_embed_comments_button'); |
|
| 464 | +add_action('embed_content_meta', 'print_embed_sharing_button'); |
|
| 465 | + |
|
| 466 | +add_action('embed_footer', 'print_embed_sharing_dialog'); |
|
| 467 | +add_action('embed_footer', 'print_embed_scripts'); |
|
| 468 | +add_action('embed_footer', 'wp_print_footer_scripts', 20); |
|
| 469 | + |
|
| 470 | +add_filter('excerpt_more', 'wp_embed_excerpt_more', 20); |
|
| 471 | +add_filter('the_excerpt_embed', 'wptexturize'); |
|
| 472 | +add_filter('the_excerpt_embed', 'convert_chars'); |
|
| 473 | +add_filter('the_excerpt_embed', 'wpautop'); |
|
| 474 | +add_filter('the_excerpt_embed', 'shortcode_unautop'); |
|
| 475 | +add_filter('the_excerpt_embed', 'wp_embed_excerpt_attachment'); |
|
| 476 | + |
|
| 477 | +add_filter('oembed_dataparse', 'wp_filter_oembed_result', 10, 3); |
|
| 478 | +add_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4); |
|
| 479 | + |
|
| 480 | +unset($filter, $action); |
|
@@ -81,129 +81,129 @@ discard block |
||
| 81 | 81 | 'headers' => array(), 'body' => null, 'cookies' => array() |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - $r = wp_parse_args( $args, $defaults ); |
|
| 84 | + $r = wp_parse_args($args, $defaults); |
|
| 85 | 85 | |
| 86 | - if ( isset( $r['headers']['User-Agent'] ) ) { |
|
| 86 | + if (isset($r['headers']['User-Agent'])) { |
|
| 87 | 87 | $r['user-agent'] = $r['headers']['User-Agent']; |
| 88 | - unset( $r['headers']['User-Agent'] ); |
|
| 89 | - } elseif ( isset( $r['headers']['user-agent'] ) ) { |
|
| 88 | + unset($r['headers']['User-Agent']); |
|
| 89 | + } elseif (isset($r['headers']['user-agent'])) { |
|
| 90 | 90 | $r['user-agent'] = $r['headers']['user-agent']; |
| 91 | - unset( $r['headers']['user-agent'] ); |
|
| 91 | + unset($r['headers']['user-agent']); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // Construct Cookie: header if any cookies are set. |
| 95 | - WP_Http::buildCookieHeader( $r ); |
|
| 95 | + WP_Http::buildCookieHeader($r); |
|
| 96 | 96 | |
| 97 | 97 | $handle = curl_init(); |
| 98 | 98 | |
| 99 | 99 | // cURL offers really easy proxy support. |
| 100 | 100 | $proxy = new WP_HTTP_Proxy(); |
| 101 | 101 | |
| 102 | - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { |
|
| 102 | + if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) { |
|
| 103 | 103 | |
| 104 | - curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP ); |
|
| 105 | - curl_setopt( $handle, CURLOPT_PROXY, $proxy->host() ); |
|
| 106 | - curl_setopt( $handle, CURLOPT_PROXYPORT, $proxy->port() ); |
|
| 104 | + curl_setopt($handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); |
|
| 105 | + curl_setopt($handle, CURLOPT_PROXY, $proxy->host()); |
|
| 106 | + curl_setopt($handle, CURLOPT_PROXYPORT, $proxy->port()); |
|
| 107 | 107 | |
| 108 | - if ( $proxy->use_authentication() ) { |
|
| 109 | - curl_setopt( $handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY ); |
|
| 110 | - curl_setopt( $handle, CURLOPT_PROXYUSERPWD, $proxy->authentication() ); |
|
| 108 | + if ($proxy->use_authentication()) { |
|
| 109 | + curl_setopt($handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); |
|
| 110 | + curl_setopt($handle, CURLOPT_PROXYUSERPWD, $proxy->authentication()); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $is_local = isset($r['local']) && $r['local']; |
| 115 | 115 | $ssl_verify = isset($r['sslverify']) && $r['sslverify']; |
| 116 | - if ( $is_local ) { |
|
| 116 | + if ($is_local) { |
|
| 117 | 117 | /** This filter is documented in wp-includes/class-wp-http-streams.php */ |
| 118 | - $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); |
|
| 119 | - } elseif ( ! $is_local ) { |
|
| 118 | + $ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify); |
|
| 119 | + } elseif ( ! $is_local) { |
|
| 120 | 120 | /** This filter is documented in wp-includes/class-wp-http-streams.php */ |
| 121 | - $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); |
|
| 121 | + $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /* |
| 125 | 125 | * CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since. |
| 126 | 126 | * a value of 0 will allow an unlimited timeout. |
| 127 | 127 | */ |
| 128 | - $timeout = (int) ceil( $r['timeout'] ); |
|
| 129 | - curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout ); |
|
| 130 | - curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout ); |
|
| 128 | + $timeout = (int) ceil($r['timeout']); |
|
| 129 | + curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 130 | + curl_setopt($handle, CURLOPT_TIMEOUT, $timeout); |
|
| 131 | 131 | |
| 132 | - curl_setopt( $handle, CURLOPT_URL, $url); |
|
| 133 | - curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); |
|
| 134 | - curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( $ssl_verify === true ) ? 2 : false ); |
|
| 135 | - curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify ); |
|
| 132 | + curl_setopt($handle, CURLOPT_URL, $url); |
|
| 133 | + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); |
|
| 134 | + curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, ($ssl_verify === true) ? 2 : false); |
|
| 135 | + curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify); |
|
| 136 | 136 | |
| 137 | - if ( $ssl_verify ) { |
|
| 138 | - curl_setopt( $handle, CURLOPT_CAINFO, $r['sslcertificates'] ); |
|
| 137 | + if ($ssl_verify) { |
|
| 138 | + curl_setopt($handle, CURLOPT_CAINFO, $r['sslcertificates']); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); |
|
| 141 | + curl_setopt($handle, CURLOPT_USERAGENT, $r['user-agent']); |
|
| 142 | 142 | |
| 143 | 143 | /* |
| 144 | 144 | * The option doesn't work with safe mode or when open_basedir is set, and there's |
| 145 | 145 | * a bug #17490 with redirected POST requests, so handle redirections outside Curl. |
| 146 | 146 | */ |
| 147 | - curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, false ); |
|
| 148 | - if ( defined( 'CURLOPT_PROTOCOLS' ) ) // PHP 5.2.10 / cURL 7.19.4 |
|
| 149 | - curl_setopt( $handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS ); |
|
| 147 | + curl_setopt($handle, CURLOPT_FOLLOWLOCATION, false); |
|
| 148 | + if (defined('CURLOPT_PROTOCOLS')) // PHP 5.2.10 / cURL 7.19.4 |
|
| 149 | + curl_setopt($handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); |
|
| 150 | 150 | |
| 151 | - switch ( $r['method'] ) { |
|
| 151 | + switch ($r['method']) { |
|
| 152 | 152 | case 'HEAD': |
| 153 | - curl_setopt( $handle, CURLOPT_NOBODY, true ); |
|
| 153 | + curl_setopt($handle, CURLOPT_NOBODY, true); |
|
| 154 | 154 | break; |
| 155 | 155 | case 'POST': |
| 156 | - curl_setopt( $handle, CURLOPT_POST, true ); |
|
| 157 | - curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); |
|
| 156 | + curl_setopt($handle, CURLOPT_POST, true); |
|
| 157 | + curl_setopt($handle, CURLOPT_POSTFIELDS, $r['body']); |
|
| 158 | 158 | break; |
| 159 | 159 | case 'PUT': |
| 160 | - curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, 'PUT' ); |
|
| 161 | - curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); |
|
| 160 | + curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 161 | + curl_setopt($handle, CURLOPT_POSTFIELDS, $r['body']); |
|
| 162 | 162 | break; |
| 163 | 163 | default: |
| 164 | - curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, $r['method'] ); |
|
| 165 | - if ( ! is_null( $r['body'] ) ) |
|
| 166 | - curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); |
|
| 164 | + curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $r['method']); |
|
| 165 | + if ( ! is_null($r['body'])) |
|
| 166 | + curl_setopt($handle, CURLOPT_POSTFIELDS, $r['body']); |
|
| 167 | 167 | break; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( true === $r['blocking'] ) { |
|
| 171 | - curl_setopt( $handle, CURLOPT_HEADERFUNCTION, array( $this, 'stream_headers' ) ); |
|
| 172 | - curl_setopt( $handle, CURLOPT_WRITEFUNCTION, array( $this, 'stream_body' ) ); |
|
| 170 | + if (true === $r['blocking']) { |
|
| 171 | + curl_setopt($handle, CURLOPT_HEADERFUNCTION, array($this, 'stream_headers')); |
|
| 172 | + curl_setopt($handle, CURLOPT_WRITEFUNCTION, array($this, 'stream_body')); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - curl_setopt( $handle, CURLOPT_HEADER, false ); |
|
| 175 | + curl_setopt($handle, CURLOPT_HEADER, false); |
|
| 176 | 176 | |
| 177 | - if ( isset( $r['limit_response_size'] ) ) |
|
| 178 | - $this->max_body_length = intval( $r['limit_response_size'] ); |
|
| 177 | + if (isset($r['limit_response_size'])) |
|
| 178 | + $this->max_body_length = intval($r['limit_response_size']); |
|
| 179 | 179 | else |
| 180 | 180 | $this->max_body_length = false; |
| 181 | 181 | |
| 182 | 182 | // If streaming to a file open a file handle, and setup our curl streaming handler. |
| 183 | - if ( $r['stream'] ) { |
|
| 184 | - if ( ! WP_DEBUG ) |
|
| 185 | - $this->stream_handle = @fopen( $r['filename'], 'w+' ); |
|
| 183 | + if ($r['stream']) { |
|
| 184 | + if ( ! WP_DEBUG) |
|
| 185 | + $this->stream_handle = @fopen($r['filename'], 'w+'); |
|
| 186 | 186 | else |
| 187 | - $this->stream_handle = fopen( $r['filename'], 'w+' ); |
|
| 188 | - if ( ! $this->stream_handle ) |
|
| 189 | - return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) ); |
|
| 187 | + $this->stream_handle = fopen($r['filename'], 'w+'); |
|
| 188 | + if ( ! $this->stream_handle) |
|
| 189 | + return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $r['filename'])); |
|
| 190 | 190 | } else { |
| 191 | 191 | $this->stream_handle = false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( !empty( $r['headers'] ) ) { |
|
| 194 | + if ( ! empty($r['headers'])) { |
|
| 195 | 195 | // cURL expects full header strings in each element. |
| 196 | 196 | $headers = array(); |
| 197 | - foreach ( $r['headers'] as $name => $value ) { |
|
| 197 | + foreach ($r['headers'] as $name => $value) { |
|
| 198 | 198 | $headers[] = "{$name}: $value"; |
| 199 | 199 | } |
| 200 | - curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers ); |
|
| 200 | + curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( $r['httpversion'] == '1.0' ) |
|
| 204 | - curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); |
|
| 203 | + if ($r['httpversion'] == '1.0') |
|
| 204 | + curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
|
| 205 | 205 | else |
| 206 | - curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); |
|
| 206 | + curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
|
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * Fires before the cURL request is executed. |
@@ -217,27 +217,27 @@ discard block |
||
| 217 | 217 | * @param array $r The HTTP request arguments. |
| 218 | 218 | * @param string $url The request URL. |
| 219 | 219 | */ |
| 220 | - do_action_ref_array( 'http_api_curl', array( &$handle, $r, $url ) ); |
|
| 220 | + do_action_ref_array('http_api_curl', array(&$handle, $r, $url)); |
|
| 221 | 221 | |
| 222 | 222 | // We don't need to return the body, so don't. Just execute request and return. |
| 223 | - if ( ! $r['blocking'] ) { |
|
| 224 | - curl_exec( $handle ); |
|
| 223 | + if ( ! $r['blocking']) { |
|
| 224 | + curl_exec($handle); |
|
| 225 | 225 | |
| 226 | - if ( $curl_error = curl_error( $handle ) ) { |
|
| 227 | - curl_close( $handle ); |
|
| 228 | - return new WP_Error( 'http_request_failed', $curl_error ); |
|
| 226 | + if ($curl_error = curl_error($handle)) { |
|
| 227 | + curl_close($handle); |
|
| 228 | + return new WP_Error('http_request_failed', $curl_error); |
|
| 229 | 229 | } |
| 230 | - if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { |
|
| 231 | - curl_close( $handle ); |
|
| 232 | - return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); |
|
| 230 | + if (in_array(curl_getinfo($handle, CURLINFO_HTTP_CODE), array(301, 302))) { |
|
| 231 | + curl_close($handle); |
|
| 232 | + return new WP_Error('http_request_failed', __('Too many redirects.')); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - curl_close( $handle ); |
|
| 236 | - return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); |
|
| 235 | + curl_close($handle); |
|
| 236 | + return array('headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array()); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - curl_exec( $handle ); |
|
| 240 | - $theHeaders = WP_Http::processHeaders( $this->headers, $url ); |
|
| 239 | + curl_exec($handle); |
|
| 240 | + $theHeaders = WP_Http::processHeaders($this->headers, $url); |
|
| 241 | 241 | $theBody = $this->body; |
| 242 | 242 | $bytes_written_total = $this->bytes_written_total; |
| 243 | 243 | |
@@ -245,37 +245,37 @@ discard block |
||
| 245 | 245 | $this->body = ''; |
| 246 | 246 | $this->bytes_written_total = 0; |
| 247 | 247 | |
| 248 | - $curl_error = curl_errno( $handle ); |
|
| 248 | + $curl_error = curl_errno($handle); |
|
| 249 | 249 | |
| 250 | 250 | // If an error occurred, or, no response. |
| 251 | - if ( $curl_error || ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) ) { |
|
| 252 | - if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { |
|
| 253 | - if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { |
|
| 254 | - if ( $r['stream'] ) { |
|
| 255 | - curl_close( $handle ); |
|
| 256 | - fclose( $this->stream_handle ); |
|
| 257 | - return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); |
|
| 251 | + if ($curl_error || (0 == strlen($theBody) && empty($theHeaders['headers']))) { |
|
| 252 | + if (CURLE_WRITE_ERROR /* 23 */ == $curl_error) { |
|
| 253 | + if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total) { |
|
| 254 | + if ($r['stream']) { |
|
| 255 | + curl_close($handle); |
|
| 256 | + fclose($this->stream_handle); |
|
| 257 | + return new WP_Error('http_request_failed', __('Failed to write request to temporary file.')); |
|
| 258 | 258 | } else { |
| 259 | - curl_close( $handle ); |
|
| 260 | - return new WP_Error( 'http_request_failed', curl_error( $handle ) ); |
|
| 259 | + curl_close($handle); |
|
| 260 | + return new WP_Error('http_request_failed', curl_error($handle)); |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | } else { |
| 264 | - if ( $curl_error = curl_error( $handle ) ) { |
|
| 265 | - curl_close( $handle ); |
|
| 266 | - return new WP_Error( 'http_request_failed', $curl_error ); |
|
| 264 | + if ($curl_error = curl_error($handle)) { |
|
| 265 | + curl_close($handle); |
|
| 266 | + return new WP_Error('http_request_failed', $curl_error); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | - if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { |
|
| 270 | - curl_close( $handle ); |
|
| 271 | - return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); |
|
| 269 | + if (in_array(curl_getinfo($handle, CURLINFO_HTTP_CODE), array(301, 302))) { |
|
| 270 | + curl_close($handle); |
|
| 271 | + return new WP_Error('http_request_failed', __('Too many redirects.')); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - curl_close( $handle ); |
|
| 275 | + curl_close($handle); |
|
| 276 | 276 | |
| 277 | - if ( $r['stream'] ) |
|
| 278 | - fclose( $this->stream_handle ); |
|
| 277 | + if ($r['stream']) |
|
| 278 | + fclose($this->stream_handle); |
|
| 279 | 279 | |
| 280 | 280 | $response = array( |
| 281 | 281 | 'headers' => $theHeaders['headers'], |
@@ -286,11 +286,11 @@ discard block |
||
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | 288 | // Handle redirects. |
| 289 | - if ( false !== ( $redirect_response = WP_HTTP::handle_redirects( $url, $r, $response ) ) ) |
|
| 289 | + if (false !== ($redirect_response = WP_HTTP::handle_redirects($url, $r, $response))) |
|
| 290 | 290 | return $redirect_response; |
| 291 | 291 | |
| 292 | - if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) |
|
| 293 | - $theBody = WP_Http_Encoding::decompress( $theBody ); |
|
| 292 | + if (true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers'])) |
|
| 293 | + $theBody = WP_Http_Encoding::decompress($theBody); |
|
| 294 | 294 | |
| 295 | 295 | $response['body'] = $theBody; |
| 296 | 296 | |
@@ -310,9 +310,9 @@ discard block |
||
| 310 | 310 | * @param string $headers cURL request headers. |
| 311 | 311 | * @return int Length of the request headers. |
| 312 | 312 | */ |
| 313 | - private function stream_headers( $handle, $headers ) { |
|
| 313 | + private function stream_headers($handle, $headers) { |
|
| 314 | 314 | $this->headers .= $headers; |
| 315 | - return strlen( $headers ); |
|
| 315 | + return strlen($headers); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -329,16 +329,16 @@ discard block |
||
| 329 | 329 | * @param string $data cURL request body. |
| 330 | 330 | * @return int Total bytes of data written. |
| 331 | 331 | */ |
| 332 | - private function stream_body( $handle, $data ) { |
|
| 333 | - $data_length = strlen( $data ); |
|
| 332 | + private function stream_body($handle, $data) { |
|
| 333 | + $data_length = strlen($data); |
|
| 334 | 334 | |
| 335 | - if ( $this->max_body_length && ( $this->bytes_written_total + $data_length ) > $this->max_body_length ) { |
|
| 336 | - $data_length = ( $this->max_body_length - $this->bytes_written_total ); |
|
| 337 | - $data = substr( $data, 0, $data_length ); |
|
| 335 | + if ($this->max_body_length && ($this->bytes_written_total + $data_length) > $this->max_body_length) { |
|
| 336 | + $data_length = ($this->max_body_length - $this->bytes_written_total); |
|
| 337 | + $data = substr($data, 0, $data_length); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( $this->stream_handle ) { |
|
| 341 | - $bytes_written = fwrite( $this->stream_handle, $data ); |
|
| 340 | + if ($this->stream_handle) { |
|
| 341 | + $bytes_written = fwrite($this->stream_handle, $data); |
|
| 342 | 342 | } else { |
| 343 | 343 | $this->body .= $data; |
| 344 | 344 | $bytes_written = $data_length; |
@@ -359,16 +359,16 @@ discard block |
||
| 359 | 359 | * @param array $args Optional. Array of request arguments. Default empty array. |
| 360 | 360 | * @return bool False means this class can not be used, true means it can. |
| 361 | 361 | */ |
| 362 | - public static function test( $args = array() ) { |
|
| 363 | - if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) |
|
| 362 | + public static function test($args = array()) { |
|
| 363 | + if ( ! function_exists('curl_init') || ! function_exists('curl_exec')) |
|
| 364 | 364 | return false; |
| 365 | 365 | |
| 366 | - $is_ssl = isset( $args['ssl'] ) && $args['ssl']; |
|
| 366 | + $is_ssl = isset($args['ssl']) && $args['ssl']; |
|
| 367 | 367 | |
| 368 | - if ( $is_ssl ) { |
|
| 368 | + if ($is_ssl) { |
|
| 369 | 369 | $curl_version = curl_version(); |
| 370 | 370 | // Check whether this cURL version support SSL requests. |
| 371 | - if ( ! (CURL_VERSION_SSL & $curl_version['features']) ) |
|
| 371 | + if ( ! (CURL_VERSION_SSL & $curl_version['features'])) |
|
| 372 | 372 | return false; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -380,6 +380,6 @@ discard block |
||
| 380 | 380 | * @param bool $use_class Whether the class can be used. Default true. |
| 381 | 381 | * @param array $args An array of request arguments. |
| 382 | 382 | */ |
| 383 | - return apply_filters( 'use_curl_transport', true, $args ); |
|
| 383 | + return apply_filters('use_curl_transport', true, $args); |
|
| 384 | 384 | } |
| 385 | 385 | } |
@@ -145,8 +145,10 @@ discard block |
||
| 145 | 145 | * a bug #17490 with redirected POST requests, so handle redirections outside Curl. |
| 146 | 146 | */ |
| 147 | 147 | curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, false ); |
| 148 | - if ( defined( 'CURLOPT_PROTOCOLS' ) ) // PHP 5.2.10 / cURL 7.19.4 |
|
| 148 | + if ( defined( 'CURLOPT_PROTOCOLS' ) ) { |
|
| 149 | + // PHP 5.2.10 / cURL 7.19.4 |
|
| 149 | 150 | curl_setopt( $handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS ); |
| 151 | + } |
|
| 150 | 152 | |
| 151 | 153 | switch ( $r['method'] ) { |
| 152 | 154 | case 'HEAD': |
@@ -162,8 +164,9 @@ discard block |
||
| 162 | 164 | break; |
| 163 | 165 | default: |
| 164 | 166 | curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, $r['method'] ); |
| 165 | - if ( ! is_null( $r['body'] ) ) |
|
| 166 | - curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); |
|
| 167 | + if ( ! is_null( $r['body'] ) ) { |
|
| 168 | + curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); |
|
| 169 | + } |
|
| 167 | 170 | break; |
| 168 | 171 | } |
| 169 | 172 | |
@@ -174,19 +177,22 @@ discard block |
||
| 174 | 177 | |
| 175 | 178 | curl_setopt( $handle, CURLOPT_HEADER, false ); |
| 176 | 179 | |
| 177 | - if ( isset( $r['limit_response_size'] ) ) |
|
| 178 | - $this->max_body_length = intval( $r['limit_response_size'] ); |
|
| 179 | - else |
|
| 180 | - $this->max_body_length = false; |
|
| 180 | + if ( isset( $r['limit_response_size'] ) ) { |
|
| 181 | + $this->max_body_length = intval( $r['limit_response_size'] ); |
|
| 182 | + } else { |
|
| 183 | + $this->max_body_length = false; |
|
| 184 | + } |
|
| 181 | 185 | |
| 182 | 186 | // If streaming to a file open a file handle, and setup our curl streaming handler. |
| 183 | 187 | if ( $r['stream'] ) { |
| 184 | - if ( ! WP_DEBUG ) |
|
| 185 | - $this->stream_handle = @fopen( $r['filename'], 'w+' ); |
|
| 186 | - else |
|
| 187 | - $this->stream_handle = fopen( $r['filename'], 'w+' ); |
|
| 188 | - if ( ! $this->stream_handle ) |
|
| 189 | - return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) ); |
|
| 188 | + if ( ! WP_DEBUG ) { |
|
| 189 | + $this->stream_handle = @fopen( $r['filename'], 'w+' ); |
|
| 190 | + } else { |
|
| 191 | + $this->stream_handle = fopen( $r['filename'], 'w+' ); |
|
| 192 | + } |
|
| 193 | + if ( ! $this->stream_handle ) { |
|
| 194 | + return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) ); |
|
| 195 | + } |
|
| 190 | 196 | } else { |
| 191 | 197 | $this->stream_handle = false; |
| 192 | 198 | } |
@@ -200,10 +206,11 @@ discard block |
||
| 200 | 206 | curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers ); |
| 201 | 207 | } |
| 202 | 208 | |
| 203 | - if ( $r['httpversion'] == '1.0' ) |
|
| 204 | - curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); |
|
| 205 | - else |
|
| 206 | - curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); |
|
| 209 | + if ( $r['httpversion'] == '1.0' ) { |
|
| 210 | + curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); |
|
| 211 | + } else { |
|
| 212 | + curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); |
|
| 213 | + } |
|
| 207 | 214 | |
| 208 | 215 | /** |
| 209 | 216 | * Fires before the cURL request is executed. |
@@ -274,8 +281,9 @@ discard block |
||
| 274 | 281 | |
| 275 | 282 | curl_close( $handle ); |
| 276 | 283 | |
| 277 | - if ( $r['stream'] ) |
|
| 278 | - fclose( $this->stream_handle ); |
|
| 284 | + if ( $r['stream'] ) { |
|
| 285 | + fclose( $this->stream_handle ); |
|
| 286 | + } |
|
| 279 | 287 | |
| 280 | 288 | $response = array( |
| 281 | 289 | 'headers' => $theHeaders['headers'], |
@@ -286,11 +294,13 @@ discard block |
||
| 286 | 294 | ); |
| 287 | 295 | |
| 288 | 296 | // Handle redirects. |
| 289 | - if ( false !== ( $redirect_response = WP_HTTP::handle_redirects( $url, $r, $response ) ) ) |
|
| 290 | - return $redirect_response; |
|
| 297 | + if ( false !== ( $redirect_response = WP_HTTP::handle_redirects( $url, $r, $response ) ) ) { |
|
| 298 | + return $redirect_response; |
|
| 299 | + } |
|
| 291 | 300 | |
| 292 | - if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) |
|
| 293 | - $theBody = WP_Http_Encoding::decompress( $theBody ); |
|
| 301 | + if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) { |
|
| 302 | + $theBody = WP_Http_Encoding::decompress( $theBody ); |
|
| 303 | + } |
|
| 294 | 304 | |
| 295 | 305 | $response['body'] = $theBody; |
| 296 | 306 | |
@@ -360,16 +370,18 @@ discard block |
||
| 360 | 370 | * @return bool False means this class can not be used, true means it can. |
| 361 | 371 | */ |
| 362 | 372 | public static function test( $args = array() ) { |
| 363 | - if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) |
|
| 364 | - return false; |
|
| 373 | + if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) { |
|
| 374 | + return false; |
|
| 375 | + } |
|
| 365 | 376 | |
| 366 | 377 | $is_ssl = isset( $args['ssl'] ) && $args['ssl']; |
| 367 | 378 | |
| 368 | 379 | if ( $is_ssl ) { |
| 369 | 380 | $curl_version = curl_version(); |
| 370 | 381 | // Check whether this cURL version support SSL requests. |
| 371 | - if ( ! (CURL_VERSION_SSL & $curl_version['features']) ) |
|
| 372 | - return false; |
|
| 382 | + if ( ! (CURL_VERSION_SSL & $curl_version['features']) ) { |
|
| 383 | + return false; |
|
| 384 | + } |
|
| 373 | 385 | } |
| 374 | 386 | |
| 375 | 387 | /** |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | function wpmu_update_blogs_date() { |
| 19 | 19 | global $wpdb; |
| 20 | 20 | |
| 21 | - update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) ); |
|
| 21 | + update_blog_details($wpdb->blogid, array('last_updated' => current_time('mysql', true))); |
|
| 22 | 22 | /** |
| 23 | 23 | * Fires after the blog details are updated. |
| 24 | 24 | * |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param int $blog_id Site ID. |
| 28 | 28 | */ |
| 29 | - do_action( 'wpmu_blog_updated', $wpdb->blogid ); |
|
| 29 | + do_action('wpmu_blog_updated', $wpdb->blogid); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -37,17 +37,17 @@ discard block |
||
| 37 | 37 | * @param int $blog_id Blog ID |
| 38 | 38 | * @return string Full URL of the blog if found. Empty string if not. |
| 39 | 39 | */ |
| 40 | -function get_blogaddress_by_id( $blog_id ) { |
|
| 41 | - $bloginfo = get_blog_details( (int) $blog_id ); |
|
| 40 | +function get_blogaddress_by_id($blog_id) { |
|
| 41 | + $bloginfo = get_blog_details((int) $blog_id); |
|
| 42 | 42 | |
| 43 | - if ( empty( $bloginfo ) ) { |
|
| 43 | + if (empty($bloginfo)) { |
|
| 44 | 44 | return ''; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME ); |
|
| 48 | - $scheme = empty( $scheme ) ? 'http' : $scheme; |
|
| 47 | + $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME); |
|
| 48 | + $scheme = empty($scheme) ? 'http' : $scheme; |
|
| 49 | 49 | |
| 50 | - return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path ); |
|
| 50 | + return esc_url($scheme.'://'.$bloginfo->domain.$bloginfo->path); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -58,17 +58,17 @@ discard block |
||
| 58 | 58 | * @param string $blogname The (subdomain or directory) name |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | -function get_blogaddress_by_name( $blogname ) { |
|
| 62 | - if ( is_subdomain_install() ) { |
|
| 63 | - if ( $blogname == 'main' ) |
|
| 61 | +function get_blogaddress_by_name($blogname) { |
|
| 62 | + if (is_subdomain_install()) { |
|
| 63 | + if ($blogname == 'main') |
|
| 64 | 64 | $blogname = 'www'; |
| 65 | - $url = rtrim( network_home_url(), '/' ); |
|
| 66 | - if ( !empty( $blogname ) ) |
|
| 67 | - $url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url ); |
|
| 65 | + $url = rtrim(network_home_url(), '/'); |
|
| 66 | + if ( ! empty($blogname)) |
|
| 67 | + $url = preg_replace('|^([^\.]+://)|', "\${1}".$blogname.'.', $url); |
|
| 68 | 68 | } else { |
| 69 | - $url = network_home_url( $blogname ); |
|
| 69 | + $url = network_home_url($blogname); |
|
| 70 | 70 | } |
| 71 | - return esc_url( $url . '/' ); |
|
| 71 | + return esc_url($url.'/'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -81,26 +81,26 @@ discard block |
||
| 81 | 81 | * @param string $slug |
| 82 | 82 | * @return int A blog id |
| 83 | 83 | */ |
| 84 | -function get_id_from_blogname( $slug ) { |
|
| 84 | +function get_id_from_blogname($slug) { |
|
| 85 | 85 | global $wpdb; |
| 86 | 86 | |
| 87 | 87 | $current_site = get_current_site(); |
| 88 | - $slug = trim( $slug, '/' ); |
|
| 88 | + $slug = trim($slug, '/'); |
|
| 89 | 89 | |
| 90 | - $blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' ); |
|
| 91 | - if ( $blog_id ) |
|
| 90 | + $blog_id = wp_cache_get('get_id_from_blogname_'.$slug, 'blog-details'); |
|
| 91 | + if ($blog_id) |
|
| 92 | 92 | return $blog_id; |
| 93 | 93 | |
| 94 | - if ( is_subdomain_install() ) { |
|
| 95 | - $domain = $slug . '.' . $current_site->domain; |
|
| 94 | + if (is_subdomain_install()) { |
|
| 95 | + $domain = $slug.'.'.$current_site->domain; |
|
| 96 | 96 | $path = $current_site->path; |
| 97 | 97 | } else { |
| 98 | 98 | $domain = $current_site->domain; |
| 99 | - $path = $current_site->path . $slug . '/'; |
|
| 99 | + $path = $current_site->path.$slug.'/'; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) ); |
|
| 103 | - wp_cache_set( 'get_id_from_blogname_' . $slug, $blog_id, 'blog-details' ); |
|
| 102 | + $blog_id = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path)); |
|
| 103 | + wp_cache_set('get_id_from_blogname_'.$slug, $blog_id, 'blog-details'); |
|
| 104 | 104 | return $blog_id; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -117,42 +117,42 @@ discard block |
||
| 117 | 117 | * Default is true. |
| 118 | 118 | * @return WP_Site|false Blog details on success. False on failure. |
| 119 | 119 | */ |
| 120 | -function get_blog_details( $fields = null, $get_all = true ) { |
|
| 120 | +function get_blog_details($fields = null, $get_all = true) { |
|
| 121 | 121 | global $wpdb; |
| 122 | 122 | |
| 123 | - if ( is_array($fields ) ) { |
|
| 124 | - if ( isset($fields['blog_id']) ) { |
|
| 123 | + if (is_array($fields)) { |
|
| 124 | + if (isset($fields['blog_id'])) { |
|
| 125 | 125 | $blog_id = $fields['blog_id']; |
| 126 | - } elseif ( isset($fields['domain']) && isset($fields['path']) ) { |
|
| 127 | - $key = md5( $fields['domain'] . $fields['path'] ); |
|
| 126 | + } elseif (isset($fields['domain']) && isset($fields['path'])) { |
|
| 127 | + $key = md5($fields['domain'].$fields['path']); |
|
| 128 | 128 | $blog = wp_cache_get($key, 'blog-lookup'); |
| 129 | - if ( false !== $blog ) |
|
| 129 | + if (false !== $blog) |
|
| 130 | 130 | return $blog; |
| 131 | - if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { |
|
| 132 | - $nowww = substr( $fields['domain'], 4 ); |
|
| 133 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) ); |
|
| 131 | + if (substr($fields['domain'], 0, 4) == 'www.') { |
|
| 132 | + $nowww = substr($fields['domain'], 4); |
|
| 133 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'])); |
|
| 134 | 134 | } else { |
| 135 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) ); |
|
| 135 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'])); |
|
| 136 | 136 | } |
| 137 | - if ( $blog ) { |
|
| 138 | - wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details'); |
|
| 137 | + if ($blog) { |
|
| 138 | + wp_cache_set($blog->blog_id.'short', $blog, 'blog-details'); |
|
| 139 | 139 | $blog_id = $blog->blog_id; |
| 140 | 140 | } else { |
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | - } elseif ( isset($fields['domain']) && is_subdomain_install() ) { |
|
| 144 | - $key = md5( $fields['domain'] ); |
|
| 143 | + } elseif (isset($fields['domain']) && is_subdomain_install()) { |
|
| 144 | + $key = md5($fields['domain']); |
|
| 145 | 145 | $blog = wp_cache_get($key, 'blog-lookup'); |
| 146 | - if ( false !== $blog ) |
|
| 146 | + if (false !== $blog) |
|
| 147 | 147 | return $blog; |
| 148 | - if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { |
|
| 149 | - $nowww = substr( $fields['domain'], 4 ); |
|
| 150 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) ); |
|
| 148 | + if (substr($fields['domain'], 0, 4) == 'www.') { |
|
| 149 | + $nowww = substr($fields['domain'], 4); |
|
| 150 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'])); |
|
| 151 | 151 | } else { |
| 152 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) ); |
|
| 152 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'])); |
|
| 153 | 153 | } |
| 154 | - if ( $blog ) { |
|
| 155 | - wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details'); |
|
| 154 | + if ($blog) { |
|
| 155 | + wp_cache_set($blog->blog_id.'short', $blog, 'blog-details'); |
|
| 156 | 156 | $blog_id = $blog->blog_id; |
| 157 | 157 | } else { |
| 158 | 158 | return false; |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | return false; |
| 162 | 162 | } |
| 163 | 163 | } else { |
| 164 | - if ( ! $fields ) |
|
| 164 | + if ( ! $fields) |
|
| 165 | 165 | $blog_id = get_current_blog_id(); |
| 166 | - elseif ( ! is_numeric( $fields ) ) |
|
| 167 | - $blog_id = get_id_from_blogname( $fields ); |
|
| 166 | + elseif ( ! is_numeric($fields)) |
|
| 167 | + $blog_id = get_id_from_blogname($fields); |
|
| 168 | 168 | else |
| 169 | 169 | $blog_id = $fields; |
| 170 | 170 | } |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | $blog_id = (int) $blog_id; |
| 173 | 173 | |
| 174 | 174 | $all = $get_all == true ? '' : 'short'; |
| 175 | - $details = wp_cache_get( $blog_id . $all, 'blog-details' ); |
|
| 175 | + $details = wp_cache_get($blog_id.$all, 'blog-details'); |
|
| 176 | 176 | |
| 177 | - if ( $details ) { |
|
| 178 | - if ( ! is_object( $details ) ) { |
|
| 179 | - if ( $details == -1 ) { |
|
| 177 | + if ($details) { |
|
| 178 | + if ( ! is_object($details)) { |
|
| 179 | + if ($details == -1) { |
|
| 180 | 180 | return false; |
| 181 | 181 | } else { |
| 182 | 182 | // Clear old pre-serialized objects. Cache clients do better with that. |
| 183 | - wp_cache_delete( $blog_id . $all, 'blog-details' ); |
|
| 183 | + wp_cache_delete($blog_id.$all, 'blog-details'); |
|
| 184 | 184 | unset($details); |
| 185 | 185 | } |
| 186 | 186 | } else { |
@@ -189,18 +189,18 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // Try the other cache. |
| 192 | - if ( $get_all ) { |
|
| 193 | - $details = wp_cache_get( $blog_id . 'short', 'blog-details' ); |
|
| 192 | + if ($get_all) { |
|
| 193 | + $details = wp_cache_get($blog_id.'short', 'blog-details'); |
|
| 194 | 194 | } else { |
| 195 | - $details = wp_cache_get( $blog_id, 'blog-details' ); |
|
| 195 | + $details = wp_cache_get($blog_id, 'blog-details'); |
|
| 196 | 196 | // If short was requested and full cache is set, we can return. |
| 197 | - if ( $details ) { |
|
| 198 | - if ( ! is_object( $details ) ) { |
|
| 199 | - if ( $details == -1 ) { |
|
| 197 | + if ($details) { |
|
| 198 | + if ( ! is_object($details)) { |
|
| 199 | + if ($details == -1) { |
|
| 200 | 200 | return false; |
| 201 | 201 | } else { |
| 202 | 202 | // Clear old pre-serialized objects. Cache clients do better with that. |
| 203 | - wp_cache_delete( $blog_id, 'blog-details' ); |
|
| 203 | + wp_cache_delete($blog_id, 'blog-details'); |
|
| 204 | 204 | unset($details); |
| 205 | 205 | } |
| 206 | 206 | } else { |
@@ -209,29 +209,29 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( empty($details) ) { |
|
| 213 | - $details = WP_Site::get_instance( $blog_id ); |
|
| 214 | - if ( ! $details ) { |
|
| 212 | + if (empty($details)) { |
|
| 213 | + $details = WP_Site::get_instance($blog_id); |
|
| 214 | + if ( ! $details) { |
|
| 215 | 215 | // Set the full cache. |
| 216 | - wp_cache_set( $blog_id, -1, 'blog-details' ); |
|
| 216 | + wp_cache_set($blog_id, -1, 'blog-details'); |
|
| 217 | 217 | return false; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( ! $details instanceof WP_Site ) { |
|
| 222 | - $details = new WP_Site( $details ); |
|
| 221 | + if ( ! $details instanceof WP_Site) { |
|
| 222 | + $details = new WP_Site($details); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( ! $get_all ) { |
|
| 226 | - wp_cache_set( $blog_id . $all, $details, 'blog-details' ); |
|
| 225 | + if ( ! $get_all) { |
|
| 226 | + wp_cache_set($blog_id.$all, $details, 'blog-details'); |
|
| 227 | 227 | return $details; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - switch_to_blog( $blog_id ); |
|
| 231 | - $details->blogname = get_option( 'blogname' ); |
|
| 232 | - $details->siteurl = get_option( 'siteurl' ); |
|
| 233 | - $details->post_count = get_option( 'post_count' ); |
|
| 234 | - $details->home = get_option( 'home' ); |
|
| 230 | + switch_to_blog($blog_id); |
|
| 231 | + $details->blogname = get_option('blogname'); |
|
| 232 | + $details->siteurl = get_option('siteurl'); |
|
| 233 | + $details->post_count = get_option('post_count'); |
|
| 234 | + $details->home = get_option('home'); |
|
| 235 | 235 | restore_current_blog(); |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -241,12 +241,12 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @param object $details The blog details. |
| 243 | 243 | */ |
| 244 | - $details = apply_filters( 'blog_details', $details ); |
|
| 244 | + $details = apply_filters('blog_details', $details); |
|
| 245 | 245 | |
| 246 | - wp_cache_set( $blog_id . $all, $details, 'blog-details' ); |
|
| 246 | + wp_cache_set($blog_id.$all, $details, 'blog-details'); |
|
| 247 | 247 | |
| 248 | - $key = md5( $details->domain . $details->path ); |
|
| 249 | - wp_cache_set( $key, $details, 'blog-lookup' ); |
|
| 248 | + $key = md5($details->domain.$details->path); |
|
| 249 | + wp_cache_set($key, $details, 'blog-lookup'); |
|
| 250 | 250 | |
| 251 | 251 | return $details; |
| 252 | 252 | } |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @param int $blog_id Optional. Blog ID. Defaults to current blog. |
| 260 | 260 | */ |
| 261 | -function refresh_blog_details( $blog_id = 0 ) { |
|
| 261 | +function refresh_blog_details($blog_id = 0) { |
|
| 262 | 262 | $blog_id = (int) $blog_id; |
| 263 | - if ( ! $blog_id ) { |
|
| 263 | + if ( ! $blog_id) { |
|
| 264 | 264 | $blog_id = get_current_blog_id(); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - $details = get_blog_details( $blog_id, false ); |
|
| 268 | - if ( ! $details ) { |
|
| 267 | + $details = get_blog_details($blog_id, false); |
|
| 268 | + if ( ! $details) { |
|
| 269 | 269 | // Make sure clean_blog_cache() gets the blog ID |
| 270 | 270 | // when the blog has been previously cached as |
| 271 | 271 | // non-existent. |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | ); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - clean_blog_cache( $details ); |
|
| 279 | + clean_blog_cache($details); |
|
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * Fires after the blog details cache is cleared. |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @param int $blog_id Blog ID. |
| 287 | 287 | */ |
| 288 | - do_action( 'refresh_blog_details', $blog_id ); |
|
| 288 | + do_action('refresh_blog_details', $blog_id); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -299,17 +299,17 @@ discard block |
||
| 299 | 299 | * @param array $details Array of details keyed by blogs table field names. |
| 300 | 300 | * @return bool True if update succeeds, false otherwise. |
| 301 | 301 | */ |
| 302 | -function update_blog_details( $blog_id, $details = array() ) { |
|
| 302 | +function update_blog_details($blog_id, $details = array()) { |
|
| 303 | 303 | global $wpdb; |
| 304 | 304 | |
| 305 | - if ( empty($details) ) |
|
| 305 | + if (empty($details)) |
|
| 306 | 306 | return false; |
| 307 | 307 | |
| 308 | - if ( is_object($details) ) |
|
| 308 | + if (is_object($details)) |
|
| 309 | 309 | $details = get_object_vars($details); |
| 310 | 310 | |
| 311 | 311 | $current_details = get_blog_details($blog_id, false); |
| 312 | - if ( empty($current_details) ) |
|
| 312 | + if (empty($current_details)) |
|
| 313 | 313 | return false; |
| 314 | 314 | |
| 315 | 315 | $current_details = get_object_vars($current_details); |
@@ -318,23 +318,23 @@ discard block |
||
| 318 | 318 | $details['last_updated'] = current_time('mysql', true); |
| 319 | 319 | |
| 320 | 320 | $update_details = array(); |
| 321 | - $fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'); |
|
| 322 | - foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) { |
|
| 323 | - if ( 'path' === $field ) { |
|
| 324 | - $details[ $field ] = trailingslashit( '/' . trim( $details[ $field ], '/' ) ); |
|
| 321 | + $fields = array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'); |
|
| 322 | + foreach (array_intersect(array_keys($details), $fields) as $field) { |
|
| 323 | + if ('path' === $field) { |
|
| 324 | + $details[$field] = trailingslashit('/'.trim($details[$field], '/')); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - $update_details[ $field ] = $details[ $field ]; |
|
| 327 | + $update_details[$field] = $details[$field]; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) ); |
|
| 330 | + $result = $wpdb->update($wpdb->blogs, $update_details, array('blog_id' => $blog_id)); |
|
| 331 | 331 | |
| 332 | - if ( false === $result ) |
|
| 332 | + if (false === $result) |
|
| 333 | 333 | return false; |
| 334 | 334 | |
| 335 | 335 | // If spam status changed, issue actions. |
| 336 | - if ( $details['spam'] != $current_details['spam'] ) { |
|
| 337 | - if ( $details['spam'] == 1 ) { |
|
| 336 | + if ($details['spam'] != $current_details['spam']) { |
|
| 337 | + if ($details['spam'] == 1) { |
|
| 338 | 338 | /** |
| 339 | 339 | * Fires when the blog status is changed to 'spam'. |
| 340 | 340 | * |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @param int $blog_id Blog ID. |
| 344 | 344 | */ |
| 345 | - do_action( 'make_spam_blog', $blog_id ); |
|
| 345 | + do_action('make_spam_blog', $blog_id); |
|
| 346 | 346 | } else { |
| 347 | 347 | /** |
| 348 | 348 | * Fires when the blog status is changed to 'ham'. |
@@ -351,13 +351,13 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @param int $blog_id Blog ID. |
| 353 | 353 | */ |
| 354 | - do_action( 'make_ham_blog', $blog_id ); |
|
| 354 | + do_action('make_ham_blog', $blog_id); |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | // If mature status changed, issue actions. |
| 359 | - if ( $details['mature'] != $current_details['mature'] ) { |
|
| 360 | - if ( $details['mature'] == 1 ) { |
|
| 359 | + if ($details['mature'] != $current_details['mature']) { |
|
| 360 | + if ($details['mature'] == 1) { |
|
| 361 | 361 | /** |
| 362 | 362 | * Fires when the blog status is changed to 'mature'. |
| 363 | 363 | * |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @param int $blog_id Blog ID. |
| 367 | 367 | */ |
| 368 | - do_action( 'mature_blog', $blog_id ); |
|
| 368 | + do_action('mature_blog', $blog_id); |
|
| 369 | 369 | } else { |
| 370 | 370 | /** |
| 371 | 371 | * Fires when the blog status is changed to 'unmature'. |
@@ -374,13 +374,13 @@ discard block |
||
| 374 | 374 | * |
| 375 | 375 | * @param int $blog_id Blog ID. |
| 376 | 376 | */ |
| 377 | - do_action( 'unmature_blog', $blog_id ); |
|
| 377 | + do_action('unmature_blog', $blog_id); |
|
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // If archived status changed, issue actions. |
| 382 | - if ( $details['archived'] != $current_details['archived'] ) { |
|
| 383 | - if ( $details['archived'] == 1 ) { |
|
| 382 | + if ($details['archived'] != $current_details['archived']) { |
|
| 383 | + if ($details['archived'] == 1) { |
|
| 384 | 384 | /** |
| 385 | 385 | * Fires when the blog status is changed to 'archived'. |
| 386 | 386 | * |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @param int $blog_id Blog ID. |
| 390 | 390 | */ |
| 391 | - do_action( 'archive_blog', $blog_id ); |
|
| 391 | + do_action('archive_blog', $blog_id); |
|
| 392 | 392 | } else { |
| 393 | 393 | /** |
| 394 | 394 | * Fires when the blog status is changed to 'unarchived'. |
@@ -397,13 +397,13 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @param int $blog_id Blog ID. |
| 399 | 399 | */ |
| 400 | - do_action( 'unarchive_blog', $blog_id ); |
|
| 400 | + do_action('unarchive_blog', $blog_id); |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | // If deleted status changed, issue actions. |
| 405 | - if ( $details['deleted'] != $current_details['deleted'] ) { |
|
| 406 | - if ( $details['deleted'] == 1 ) { |
|
| 405 | + if ($details['deleted'] != $current_details['deleted']) { |
|
| 406 | + if ($details['deleted'] == 1) { |
|
| 407 | 407 | /** |
| 408 | 408 | * Fires when the blog status is changed to 'deleted'. |
| 409 | 409 | * |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @param int $blog_id Blog ID. |
| 413 | 413 | */ |
| 414 | - do_action( 'make_delete_blog', $blog_id ); |
|
| 414 | + do_action('make_delete_blog', $blog_id); |
|
| 415 | 415 | } else { |
| 416 | 416 | /** |
| 417 | 417 | * Fires when the blog status is changed to 'undeleted'. |
@@ -420,13 +420,13 @@ discard block |
||
| 420 | 420 | * |
| 421 | 421 | * @param int $blog_id Blog ID. |
| 422 | 422 | */ |
| 423 | - do_action( 'make_undelete_blog', $blog_id ); |
|
| 423 | + do_action('make_undelete_blog', $blog_id); |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - if ( isset( $details['public'] ) ) { |
|
| 428 | - switch_to_blog( $blog_id ); |
|
| 429 | - update_option( 'blog_public', $details['public'] ); |
|
| 427 | + if (isset($details['public'])) { |
|
| 428 | + switch_to_blog($blog_id); |
|
| 429 | + update_option('blog_public', $details['public']); |
|
| 430 | 430 | restore_current_blog(); |
| 431 | 431 | } |
| 432 | 432 | |
@@ -442,18 +442,18 @@ discard block |
||
| 442 | 442 | * |
| 443 | 443 | * @param WP_Site $blog The blog details as returned from get_blog_details() |
| 444 | 444 | */ |
| 445 | -function clean_blog_cache( $blog ) { |
|
| 445 | +function clean_blog_cache($blog) { |
|
| 446 | 446 | $blog_id = $blog->blog_id; |
| 447 | - $domain_path_key = md5( $blog->domain . $blog->path ); |
|
| 448 | - |
|
| 449 | - wp_cache_delete( $blog_id, 'sites' ); |
|
| 450 | - wp_cache_delete( $blog_id , 'blog-details' ); |
|
| 451 | - wp_cache_delete( $blog_id . 'short' , 'blog-details' ); |
|
| 452 | - wp_cache_delete( $domain_path_key, 'blog-lookup' ); |
|
| 453 | - wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' ); |
|
| 454 | - wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' ); |
|
| 455 | - wp_cache_delete( 'get_id_from_blogname_' . trim( $blog->path, '/' ), 'blog-details' ); |
|
| 456 | - wp_cache_delete( $domain_path_key, 'blog-id-cache' ); |
|
| 447 | + $domain_path_key = md5($blog->domain.$blog->path); |
|
| 448 | + |
|
| 449 | + wp_cache_delete($blog_id, 'sites'); |
|
| 450 | + wp_cache_delete($blog_id, 'blog-details'); |
|
| 451 | + wp_cache_delete($blog_id.'short', 'blog-details'); |
|
| 452 | + wp_cache_delete($domain_path_key, 'blog-lookup'); |
|
| 453 | + wp_cache_delete('current_blog_'.$blog->domain, 'site-options'); |
|
| 454 | + wp_cache_delete('current_blog_'.$blog->domain.$blog->path, 'site-options'); |
|
| 455 | + wp_cache_delete('get_id_from_blogname_'.trim($blog->path, '/'), 'blog-details'); |
|
| 456 | + wp_cache_delete($domain_path_key, 'blog-id-cache'); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -473,17 +473,17 @@ discard block |
||
| 473 | 473 | * @param mixed $default Optional. Default value to return if the option does not exist. |
| 474 | 474 | * @return mixed Value set for the option. |
| 475 | 475 | */ |
| 476 | -function get_blog_option( $id, $option, $default = false ) { |
|
| 476 | +function get_blog_option($id, $option, $default = false) { |
|
| 477 | 477 | $id = (int) $id; |
| 478 | 478 | |
| 479 | - if ( empty( $id ) ) |
|
| 479 | + if (empty($id)) |
|
| 480 | 480 | $id = get_current_blog_id(); |
| 481 | 481 | |
| 482 | - if ( get_current_blog_id() == $id ) |
|
| 483 | - return get_option( $option, $default ); |
|
| 482 | + if (get_current_blog_id() == $id) |
|
| 483 | + return get_option($option, $default); |
|
| 484 | 484 | |
| 485 | - switch_to_blog( $id ); |
|
| 486 | - $value = get_option( $option, $default ); |
|
| 485 | + switch_to_blog($id); |
|
| 486 | + $value = get_option($option, $default); |
|
| 487 | 487 | restore_current_blog(); |
| 488 | 488 | |
| 489 | 489 | /** |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | * @param string $value The option value. |
| 497 | 497 | * @param int $id Blog ID. |
| 498 | 498 | */ |
| 499 | - return apply_filters( "blog_option_{$option}", $value, $id ); |
|
| 499 | + return apply_filters("blog_option_{$option}", $value, $id); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -518,17 +518,17 @@ discard block |
||
| 518 | 518 | * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped. |
| 519 | 519 | * @return bool False if option was not added and true if option was added. |
| 520 | 520 | */ |
| 521 | -function add_blog_option( $id, $option, $value ) { |
|
| 521 | +function add_blog_option($id, $option, $value) { |
|
| 522 | 522 | $id = (int) $id; |
| 523 | 523 | |
| 524 | - if ( empty( $id ) ) |
|
| 524 | + if (empty($id)) |
|
| 525 | 525 | $id = get_current_blog_id(); |
| 526 | 526 | |
| 527 | - if ( get_current_blog_id() == $id ) |
|
| 528 | - return add_option( $option, $value ); |
|
| 527 | + if (get_current_blog_id() == $id) |
|
| 528 | + return add_option($option, $value); |
|
| 529 | 529 | |
| 530 | - switch_to_blog( $id ); |
|
| 531 | - $return = add_option( $option, $value ); |
|
| 530 | + switch_to_blog($id); |
|
| 531 | + $return = add_option($option, $value); |
|
| 532 | 532 | restore_current_blog(); |
| 533 | 533 | |
| 534 | 534 | return $return; |
@@ -543,17 +543,17 @@ discard block |
||
| 543 | 543 | * @param string $option Name of option to remove. Expected to not be SQL-escaped. |
| 544 | 544 | * @return bool True, if option is successfully deleted. False on failure. |
| 545 | 545 | */ |
| 546 | -function delete_blog_option( $id, $option ) { |
|
| 546 | +function delete_blog_option($id, $option) { |
|
| 547 | 547 | $id = (int) $id; |
| 548 | 548 | |
| 549 | - if ( empty( $id ) ) |
|
| 549 | + if (empty($id)) |
|
| 550 | 550 | $id = get_current_blog_id(); |
| 551 | 551 | |
| 552 | - if ( get_current_blog_id() == $id ) |
|
| 553 | - return delete_option( $option ); |
|
| 552 | + if (get_current_blog_id() == $id) |
|
| 553 | + return delete_option($option); |
|
| 554 | 554 | |
| 555 | - switch_to_blog( $id ); |
|
| 556 | - $return = delete_option( $option ); |
|
| 555 | + switch_to_blog($id); |
|
| 556 | + $return = delete_option($option); |
|
| 557 | 557 | restore_current_blog(); |
| 558 | 558 | |
| 559 | 559 | return $return; |
@@ -570,20 +570,20 @@ discard block |
||
| 570 | 570 | * @param mixed $deprecated Not used. |
| 571 | 571 | * @return bool True on success, false on failure. |
| 572 | 572 | */ |
| 573 | -function update_blog_option( $id, $option, $value, $deprecated = null ) { |
|
| 573 | +function update_blog_option($id, $option, $value, $deprecated = null) { |
|
| 574 | 574 | $id = (int) $id; |
| 575 | 575 | |
| 576 | - if ( null !== $deprecated ) |
|
| 577 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
| 576 | + if (null !== $deprecated) |
|
| 577 | + _deprecated_argument(__FUNCTION__, '3.1'); |
|
| 578 | 578 | |
| 579 | - if ( get_current_blog_id() == $id ) |
|
| 580 | - return update_option( $option, $value ); |
|
| 579 | + if (get_current_blog_id() == $id) |
|
| 580 | + return update_option($option, $value); |
|
| 581 | 581 | |
| 582 | - switch_to_blog( $id ); |
|
| 583 | - $return = update_option( $option, $value ); |
|
| 582 | + switch_to_blog($id); |
|
| 583 | + $return = update_option($option, $value); |
|
| 584 | 584 | restore_current_blog(); |
| 585 | 585 | |
| 586 | - refresh_blog_details( $id ); |
|
| 586 | + refresh_blog_details($id); |
|
| 587 | 587 | |
| 588 | 588 | return $return; |
| 589 | 589 | } |
@@ -612,10 +612,10 @@ discard block |
||
| 612 | 612 | * @param bool $deprecated Deprecated argument |
| 613 | 613 | * @return true Always returns True. |
| 614 | 614 | */ |
| 615 | -function switch_to_blog( $new_blog, $deprecated = null ) { |
|
| 615 | +function switch_to_blog($new_blog, $deprecated = null) { |
|
| 616 | 616 | global $wpdb; |
| 617 | 617 | |
| 618 | - if ( empty( $new_blog ) ) |
|
| 618 | + if (empty($new_blog)) |
|
| 619 | 619 | $new_blog = $GLOBALS['blog_id']; |
| 620 | 620 | |
| 621 | 621 | $GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id']; |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | * set the right vars, do the associated actions, but skip |
| 626 | 626 | * the extra unnecessary work |
| 627 | 627 | */ |
| 628 | - if ( $new_blog == $GLOBALS['blog_id'] ) { |
|
| 628 | + if ($new_blog == $GLOBALS['blog_id']) { |
|
| 629 | 629 | /** |
| 630 | 630 | * Fires when the blog is switched. |
| 631 | 631 | * |
@@ -634,46 +634,46 @@ discard block |
||
| 634 | 634 | * @param int $new_blog New blog ID. |
| 635 | 635 | * @param int $new_blog Blog ID. |
| 636 | 636 | */ |
| 637 | - do_action( 'switch_blog', $new_blog, $new_blog ); |
|
| 637 | + do_action('switch_blog', $new_blog, $new_blog); |
|
| 638 | 638 | $GLOBALS['switched'] = true; |
| 639 | 639 | return true; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - $wpdb->set_blog_id( $new_blog ); |
|
| 642 | + $wpdb->set_blog_id($new_blog); |
|
| 643 | 643 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
| 644 | 644 | $prev_blog_id = $GLOBALS['blog_id']; |
| 645 | 645 | $GLOBALS['blog_id'] = $new_blog; |
| 646 | 646 | |
| 647 | - if ( function_exists( 'wp_cache_switch_to_blog' ) ) { |
|
| 648 | - wp_cache_switch_to_blog( $new_blog ); |
|
| 647 | + if (function_exists('wp_cache_switch_to_blog')) { |
|
| 648 | + wp_cache_switch_to_blog($new_blog); |
|
| 649 | 649 | } else { |
| 650 | 650 | global $wp_object_cache; |
| 651 | 651 | |
| 652 | - if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) |
|
| 652 | + if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) |
|
| 653 | 653 | $global_groups = $wp_object_cache->global_groups; |
| 654 | 654 | else |
| 655 | 655 | $global_groups = false; |
| 656 | 656 | |
| 657 | 657 | wp_cache_init(); |
| 658 | 658 | |
| 659 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
| 660 | - if ( is_array( $global_groups ) ) { |
|
| 661 | - wp_cache_add_global_groups( $global_groups ); |
|
| 659 | + if (function_exists('wp_cache_add_global_groups')) { |
|
| 660 | + if (is_array($global_groups)) { |
|
| 661 | + wp_cache_add_global_groups($global_groups); |
|
| 662 | 662 | } else { |
| 663 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
|
| 663 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites')); |
|
| 664 | 664 | } |
| 665 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
| 665 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - if ( did_action( 'init' ) ) { |
|
| 669 | + if (did_action('init')) { |
|
| 670 | 670 | wp_roles()->reinit(); |
| 671 | 671 | $current_user = wp_get_current_user(); |
| 672 | - $current_user->for_blog( $new_blog ); |
|
| 672 | + $current_user->for_blog($new_blog); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 676 | - do_action( 'switch_blog', $new_blog, $prev_blog_id ); |
|
| 676 | + do_action('switch_blog', $new_blog, $prev_blog_id); |
|
| 677 | 677 | $GLOBALS['switched'] = true; |
| 678 | 678 | |
| 679 | 679 | return true; |
@@ -697,57 +697,57 @@ discard block |
||
| 697 | 697 | function restore_current_blog() { |
| 698 | 698 | global $wpdb; |
| 699 | 699 | |
| 700 | - if ( empty( $GLOBALS['_wp_switched_stack'] ) ) |
|
| 700 | + if (empty($GLOBALS['_wp_switched_stack'])) |
|
| 701 | 701 | return false; |
| 702 | 702 | |
| 703 | - $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
|
| 703 | + $blog = array_pop($GLOBALS['_wp_switched_stack']); |
|
| 704 | 704 | |
| 705 | - if ( $GLOBALS['blog_id'] == $blog ) { |
|
| 705 | + if ($GLOBALS['blog_id'] == $blog) { |
|
| 706 | 706 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 707 | - do_action( 'switch_blog', $blog, $blog ); |
|
| 707 | + do_action('switch_blog', $blog, $blog); |
|
| 708 | 708 | // If we still have items in the switched stack, consider ourselves still 'switched' |
| 709 | - $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
|
| 709 | + $GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']); |
|
| 710 | 710 | return true; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - $wpdb->set_blog_id( $blog ); |
|
| 713 | + $wpdb->set_blog_id($blog); |
|
| 714 | 714 | $prev_blog_id = $GLOBALS['blog_id']; |
| 715 | 715 | $GLOBALS['blog_id'] = $blog; |
| 716 | 716 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
| 717 | 717 | |
| 718 | - if ( function_exists( 'wp_cache_switch_to_blog' ) ) { |
|
| 719 | - wp_cache_switch_to_blog( $blog ); |
|
| 718 | + if (function_exists('wp_cache_switch_to_blog')) { |
|
| 719 | + wp_cache_switch_to_blog($blog); |
|
| 720 | 720 | } else { |
| 721 | 721 | global $wp_object_cache; |
| 722 | 722 | |
| 723 | - if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) |
|
| 723 | + if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) |
|
| 724 | 724 | $global_groups = $wp_object_cache->global_groups; |
| 725 | 725 | else |
| 726 | 726 | $global_groups = false; |
| 727 | 727 | |
| 728 | 728 | wp_cache_init(); |
| 729 | 729 | |
| 730 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
| 731 | - if ( is_array( $global_groups ) ) { |
|
| 732 | - wp_cache_add_global_groups( $global_groups ); |
|
| 730 | + if (function_exists('wp_cache_add_global_groups')) { |
|
| 731 | + if (is_array($global_groups)) { |
|
| 732 | + wp_cache_add_global_groups($global_groups); |
|
| 733 | 733 | } else { |
| 734 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
|
| 734 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites')); |
|
| 735 | 735 | } |
| 736 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
| 736 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
| 737 | 737 | } |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if ( did_action( 'init' ) ) { |
|
| 740 | + if (did_action('init')) { |
|
| 741 | 741 | wp_roles()->reinit(); |
| 742 | 742 | $current_user = wp_get_current_user(); |
| 743 | - $current_user->for_blog( $blog ); |
|
| 743 | + $current_user->for_blog($blog); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 747 | - do_action( 'switch_blog', $blog, $prev_blog_id ); |
|
| 747 | + do_action('switch_blog', $blog, $prev_blog_id); |
|
| 748 | 748 | |
| 749 | 749 | // If we still have items in the switched stack, consider ourselves still 'switched' |
| 750 | - $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
|
| 750 | + $GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']); |
|
| 751 | 751 | |
| 752 | 752 | return true; |
| 753 | 753 | } |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | * @return bool True if switched, false otherwise. |
| 763 | 763 | */ |
| 764 | 764 | function ms_is_switched() { |
| 765 | - return ! empty( $GLOBALS['_wp_switched_stack'] ); |
|
| 765 | + return ! empty($GLOBALS['_wp_switched_stack']); |
|
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | /** |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | * @param int $id The blog id |
| 774 | 774 | * @return string Whether the blog is archived or not |
| 775 | 775 | */ |
| 776 | -function is_archived( $id ) { |
|
| 776 | +function is_archived($id) { |
|
| 777 | 777 | return get_blog_status($id, 'archived'); |
| 778 | 778 | } |
| 779 | 779 | |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | * @param string $archived The new status |
| 787 | 787 | * @return string $archived |
| 788 | 788 | */ |
| 789 | -function update_archived( $id, $archived ) { |
|
| 789 | +function update_archived($id, $archived) { |
|
| 790 | 790 | update_blog_status($id, 'archived', $archived); |
| 791 | 791 | return $archived; |
| 792 | 792 | } |
@@ -804,55 +804,55 @@ discard block |
||
| 804 | 804 | * @param null $deprecated |
| 805 | 805 | * @return string|false $value |
| 806 | 806 | */ |
| 807 | -function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { |
|
| 807 | +function update_blog_status($blog_id, $pref, $value, $deprecated = null) { |
|
| 808 | 808 | global $wpdb; |
| 809 | 809 | |
| 810 | - if ( null !== $deprecated ) |
|
| 811 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
| 810 | + if (null !== $deprecated) |
|
| 811 | + _deprecated_argument(__FUNCTION__, '3.1'); |
|
| 812 | 812 | |
| 813 | - if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) |
|
| 813 | + if ( ! in_array($pref, array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'))) |
|
| 814 | 814 | return $value; |
| 815 | 815 | |
| 816 | - $result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) ); |
|
| 816 | + $result = $wpdb->update($wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id)); |
|
| 817 | 817 | |
| 818 | - if ( false === $result ) |
|
| 818 | + if (false === $result) |
|
| 819 | 819 | return false; |
| 820 | 820 | |
| 821 | - refresh_blog_details( $blog_id ); |
|
| 821 | + refresh_blog_details($blog_id); |
|
| 822 | 822 | |
| 823 | - if ( 'spam' == $pref ) { |
|
| 824 | - if ( $value == 1 ) { |
|
| 823 | + if ('spam' == $pref) { |
|
| 824 | + if ($value == 1) { |
|
| 825 | 825 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 826 | - do_action( 'make_spam_blog', $blog_id ); |
|
| 826 | + do_action('make_spam_blog', $blog_id); |
|
| 827 | 827 | } else { |
| 828 | 828 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 829 | - do_action( 'make_ham_blog', $blog_id ); |
|
| 829 | + do_action('make_ham_blog', $blog_id); |
|
| 830 | 830 | } |
| 831 | - } elseif ( 'mature' == $pref ) { |
|
| 832 | - if ( $value == 1 ) { |
|
| 831 | + } elseif ('mature' == $pref) { |
|
| 832 | + if ($value == 1) { |
|
| 833 | 833 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 834 | - do_action( 'mature_blog', $blog_id ); |
|
| 834 | + do_action('mature_blog', $blog_id); |
|
| 835 | 835 | } else { |
| 836 | 836 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 837 | - do_action( 'unmature_blog', $blog_id ); |
|
| 837 | + do_action('unmature_blog', $blog_id); |
|
| 838 | 838 | } |
| 839 | - } elseif ( 'archived' == $pref ) { |
|
| 840 | - if ( $value == 1 ) { |
|
| 839 | + } elseif ('archived' == $pref) { |
|
| 840 | + if ($value == 1) { |
|
| 841 | 841 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 842 | - do_action( 'archive_blog', $blog_id ); |
|
| 842 | + do_action('archive_blog', $blog_id); |
|
| 843 | 843 | } else { |
| 844 | 844 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 845 | - do_action( 'unarchive_blog', $blog_id ); |
|
| 845 | + do_action('unarchive_blog', $blog_id); |
|
| 846 | 846 | } |
| 847 | - } elseif ( 'deleted' == $pref ) { |
|
| 848 | - if ( $value == 1 ) { |
|
| 847 | + } elseif ('deleted' == $pref) { |
|
| 848 | + if ($value == 1) { |
|
| 849 | 849 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 850 | - do_action( 'make_delete_blog', $blog_id ); |
|
| 850 | + do_action('make_delete_blog', $blog_id); |
|
| 851 | 851 | } else { |
| 852 | 852 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 853 | - do_action( 'make_undelete_blog', $blog_id ); |
|
| 853 | + do_action('make_undelete_blog', $blog_id); |
|
| 854 | 854 | } |
| 855 | - } elseif ( 'public' == $pref ) { |
|
| 855 | + } elseif ('public' == $pref) { |
|
| 856 | 856 | /** |
| 857 | 857 | * Fires after the current blog's 'public' setting is updated. |
| 858 | 858 | * |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | * @param int $blog_id Blog ID. |
| 862 | 862 | * @param string $value The value of blog status. |
| 863 | 863 | */ |
| 864 | - do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public(). |
|
| 864 | + do_action('update_blog_public', $blog_id, $value); // Moved here from update_blog_public(). |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | return $value; |
@@ -878,14 +878,14 @@ discard block |
||
| 878 | 878 | * @param string $pref A field name |
| 879 | 879 | * @return bool|string|null $value |
| 880 | 880 | */ |
| 881 | -function get_blog_status( $id, $pref ) { |
|
| 881 | +function get_blog_status($id, $pref) { |
|
| 882 | 882 | global $wpdb; |
| 883 | 883 | |
| 884 | - $details = get_blog_details( $id, false ); |
|
| 885 | - if ( $details ) |
|
| 884 | + $details = get_blog_details($id, false); |
|
| 885 | + if ($details) |
|
| 886 | 886 | return $details->$pref; |
| 887 | 887 | |
| 888 | - return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) ); |
|
| 888 | + return $wpdb->get_var($wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id)); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -900,13 +900,13 @@ discard block |
||
| 900 | 900 | * @param int $quantity The maximum number of blogs to retrieve. Default is 40. |
| 901 | 901 | * @return array The list of blogs |
| 902 | 902 | */ |
| 903 | -function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { |
|
| 903 | +function get_last_updated($deprecated = '', $start = 0, $quantity = 40) { |
|
| 904 | 904 | global $wpdb; |
| 905 | 905 | |
| 906 | - if ( ! empty( $deprecated ) ) |
|
| 907 | - _deprecated_argument( __FUNCTION__, 'MU' ); // never used |
|
| 906 | + if ( ! empty($deprecated)) |
|
| 907 | + _deprecated_argument(__FUNCTION__, 'MU'); // never used |
|
| 908 | 908 | |
| 909 | - return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A ); |
|
| 909 | + return $wpdb->get_results($wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity), ARRAY_A); |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | /** |
@@ -918,13 +918,13 @@ discard block |
||
| 918 | 918 | * @param string $old_status The old post status |
| 919 | 919 | * @param object $post Post object |
| 920 | 920 | */ |
| 921 | -function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { |
|
| 922 | - $post_type_obj = get_post_type_object( $post->post_type ); |
|
| 923 | - if ( ! $post_type_obj || ! $post_type_obj->public ) { |
|
| 921 | +function _update_blog_date_on_post_publish($new_status, $old_status, $post) { |
|
| 922 | + $post_type_obj = get_post_type_object($post->post_type); |
|
| 923 | + if ( ! $post_type_obj || ! $post_type_obj->public) { |
|
| 924 | 924 | return; |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - if ( 'publish' != $new_status && 'publish' != $old_status ) { |
|
| 927 | + if ('publish' != $new_status && 'publish' != $old_status) { |
|
| 928 | 928 | return; |
| 929 | 929 | } |
| 930 | 930 | |
@@ -940,15 +940,15 @@ discard block |
||
| 940 | 940 | * |
| 941 | 941 | * @param int $post_id Post ID |
| 942 | 942 | */ |
| 943 | -function _update_blog_date_on_post_delete( $post_id ) { |
|
| 944 | - $post = get_post( $post_id ); |
|
| 943 | +function _update_blog_date_on_post_delete($post_id) { |
|
| 944 | + $post = get_post($post_id); |
|
| 945 | 945 | |
| 946 | - $post_type_obj = get_post_type_object( $post->post_type ); |
|
| 947 | - if ( ! $post_type_obj || ! $post_type_obj->public ) { |
|
| 946 | + $post_type_obj = get_post_type_object($post->post_type); |
|
| 947 | + if ( ! $post_type_obj || ! $post_type_obj->public) { |
|
| 948 | 948 | return; |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - if ( 'publish' != $post->post_status ) { |
|
| 951 | + if ('publish' != $post->post_status) { |
|
| 952 | 952 | return; |
| 953 | 953 | } |
| 954 | 954 | |
@@ -962,10 +962,10 @@ discard block |
||
| 962 | 962 | * |
| 963 | 963 | * @param int $post_id Post ID. |
| 964 | 964 | */ |
| 965 | -function _update_posts_count_on_delete( $post_id ) { |
|
| 966 | - $post = get_post( $post_id ); |
|
| 965 | +function _update_posts_count_on_delete($post_id) { |
|
| 966 | + $post = get_post($post_id); |
|
| 967 | 967 | |
| 968 | - if ( ! $post || 'publish' !== $post->post_status ) { |
|
| 968 | + if ( ! $post || 'publish' !== $post->post_status) { |
|
| 969 | 969 | return; |
| 970 | 970 | } |
| 971 | 971 | |
@@ -980,12 +980,12 @@ discard block |
||
| 980 | 980 | * @param string $new_status The status the post is changing to. |
| 981 | 981 | * @param string $old_status The status the post is changing from. |
| 982 | 982 | */ |
| 983 | -function _update_posts_count_on_transition_post_status( $new_status, $old_status ) { |
|
| 984 | - if ( $new_status === $old_status ) { |
|
| 983 | +function _update_posts_count_on_transition_post_status($new_status, $old_status) { |
|
| 984 | + if ($new_status === $old_status) { |
|
| 985 | 985 | return; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - if ( 'publish' !== $new_status && 'publish' !== $old_status ) { |
|
| 988 | + if ('publish' !== $new_status && 'publish' !== $old_status) { |
|
| 989 | 989 | return; |
| 990 | 990 | } |
| 991 | 991 | |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Core Metadata API |
|
| 4 | - * |
|
| 5 | - * Functions for retrieving and manipulating metadata of various WordPress object types. Metadata |
|
| 6 | - * for an object is a represented by a simple key-value pair. Objects may contain multiple |
|
| 7 | - * metadata entries that share the same key and differ only in their value. |
|
| 8 | - * |
|
| 9 | - * @package WordPress |
|
| 10 | - * @subpackage Meta |
|
| 11 | - */ |
|
| 3 | + * Core Metadata API |
|
| 4 | + * |
|
| 5 | + * Functions for retrieving and manipulating metadata of various WordPress object types. Metadata |
|
| 6 | + * for an object is a represented by a simple key-value pair. Objects may contain multiple |
|
| 7 | + * metadata entries that share the same key and differ only in their value. |
|
| 8 | + * |
|
| 9 | + * @package WordPress |
|
| 10 | + * @subpackage Meta |
|
| 11 | + */ |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Add metadata for the specified object. |
@@ -30,26 +30,26 @@ discard block |
||
| 30 | 30 | function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique = false) { |
| 31 | 31 | global $wpdb; |
| 32 | 32 | |
| 33 | - if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) ) { |
|
| 33 | + if ( ! $meta_type || ! $meta_key || ! is_numeric($object_id)) { |
|
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $object_id = absint( $object_id ); |
|
| 38 | - if ( ! $object_id ) { |
|
| 37 | + $object_id = absint($object_id); |
|
| 38 | + if ( ! $object_id) { |
|
| 39 | 39 | return false; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $table = _get_meta_table( $meta_type ); |
|
| 43 | - if ( ! $table ) { |
|
| 42 | + $table = _get_meta_table($meta_type); |
|
| 43 | + if ( ! $table) { |
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $column = sanitize_key($meta_type . '_id'); |
|
| 47 | + $column = sanitize_key($meta_type.'_id'); |
|
| 48 | 48 | |
| 49 | 49 | // expected_slashed ($meta_key) |
| 50 | 50 | $meta_key = wp_unslash($meta_key); |
| 51 | 51 | $meta_value = wp_unslash($meta_value); |
| 52 | - $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); |
|
| 52 | + $meta_value = sanitize_meta($meta_key, $meta_value, $meta_type); |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Filter whether to add metadata of a specific type. |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | * @param bool $unique Whether the specified meta key should be unique |
| 68 | 68 | * for the object. Optional. Default false. |
| 69 | 69 | */ |
| 70 | - $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique ); |
|
| 71 | - if ( null !== $check ) |
|
| 70 | + $check = apply_filters("add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique); |
|
| 71 | + if (null !== $check) |
|
| 72 | 72 | return $check; |
| 73 | 73 | |
| 74 | - if ( $unique && $wpdb->get_var( $wpdb->prepare( |
|
| 74 | + if ($unique && $wpdb->get_var($wpdb->prepare( |
|
| 75 | 75 | "SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d", |
| 76 | - $meta_key, $object_id ) ) ) |
|
| 76 | + $meta_key, $object_id ))) |
|
| 77 | 77 | return false; |
| 78 | 78 | |
| 79 | 79 | $_meta_value = $meta_value; |
| 80 | - $meta_value = maybe_serialize( $meta_value ); |
|
| 80 | + $meta_value = maybe_serialize($meta_value); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Fires immediately before meta of a specific type is added. |
@@ -91,20 +91,20 @@ discard block |
||
| 91 | 91 | * @param string $meta_key Meta key. |
| 92 | 92 | * @param mixed $meta_value Meta value. |
| 93 | 93 | */ |
| 94 | - do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value ); |
|
| 94 | + do_action("add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value); |
|
| 95 | 95 | |
| 96 | - $result = $wpdb->insert( $table, array( |
|
| 96 | + $result = $wpdb->insert($table, array( |
|
| 97 | 97 | $column => $object_id, |
| 98 | 98 | 'meta_key' => $meta_key, |
| 99 | 99 | 'meta_value' => $meta_value |
| 100 | - ) ); |
|
| 100 | + )); |
|
| 101 | 101 | |
| 102 | - if ( ! $result ) |
|
| 102 | + if ( ! $result) |
|
| 103 | 103 | return false; |
| 104 | 104 | |
| 105 | 105 | $mid = (int) $wpdb->insert_id; |
| 106 | 106 | |
| 107 | - wp_cache_delete($object_id, $meta_type . '_meta'); |
|
| 107 | + wp_cache_delete($object_id, $meta_type.'_meta'); |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Fires immediately after meta of a specific type is added. |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param string $meta_key Meta key. |
| 120 | 120 | * @param mixed $meta_value Meta value. |
| 121 | 121 | */ |
| 122 | - do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value ); |
|
| 122 | + do_action("added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value); |
|
| 123 | 123 | |
| 124 | 124 | return $mid; |
| 125 | 125 | } |
@@ -143,21 +143,21 @@ discard block |
||
| 143 | 143 | function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value = '') { |
| 144 | 144 | global $wpdb; |
| 145 | 145 | |
| 146 | - if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) ) { |
|
| 146 | + if ( ! $meta_type || ! $meta_key || ! is_numeric($object_id)) { |
|
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $object_id = absint( $object_id ); |
|
| 151 | - if ( ! $object_id ) { |
|
| 150 | + $object_id = absint($object_id); |
|
| 151 | + if ( ! $object_id) { |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - $table = _get_meta_table( $meta_type ); |
|
| 156 | - if ( ! $table ) { |
|
| 155 | + $table = _get_meta_table($meta_type); |
|
| 156 | + if ( ! $table) { |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $column = sanitize_key($meta_type . '_id'); |
|
| 160 | + $column = sanitize_key($meta_type.'_id'); |
|
| 161 | 161 | $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; |
| 162 | 162 | |
| 163 | 163 | // expected_slashed ($meta_key) |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $meta_key = wp_unslash($meta_key); |
| 166 | 166 | $passed_value = $meta_value; |
| 167 | 167 | $meta_value = wp_unslash($meta_value); |
| 168 | - $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); |
|
| 168 | + $meta_value = sanitize_meta($meta_key, $meta_value, $meta_type); |
|
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * Filter whether to update metadata of a specific type. |
@@ -184,36 +184,36 @@ discard block |
||
| 184 | 184 | * metadata entries with the specified value. |
| 185 | 185 | * Otherwise, update all entries. |
| 186 | 186 | */ |
| 187 | - $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value ); |
|
| 188 | - if ( null !== $check ) |
|
| 187 | + $check = apply_filters("update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value); |
|
| 188 | + if (null !== $check) |
|
| 189 | 189 | return (bool) $check; |
| 190 | 190 | |
| 191 | 191 | // Compare existing value to new value if no prev value given and the key exists only once. |
| 192 | - if ( empty($prev_value) ) { |
|
| 192 | + if (empty($prev_value)) { |
|
| 193 | 193 | $old_value = get_metadata($meta_type, $object_id, $meta_key); |
| 194 | - if ( count($old_value) == 1 ) { |
|
| 195 | - if ( $old_value[0] === $meta_value ) |
|
| 194 | + if (count($old_value) == 1) { |
|
| 195 | + if ($old_value[0] === $meta_value) |
|
| 196 | 196 | return false; |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ); |
|
| 201 | - if ( empty( $meta_ids ) ) { |
|
| 202 | - return add_metadata( $meta_type, $object_id, $raw_meta_key, $passed_value ); |
|
| 200 | + $meta_ids = $wpdb->get_col($wpdb->prepare("SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id)); |
|
| 201 | + if (empty($meta_ids)) { |
|
| 202 | + return add_metadata($meta_type, $object_id, $raw_meta_key, $passed_value); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $_meta_value = $meta_value; |
| 206 | - $meta_value = maybe_serialize( $meta_value ); |
|
| 206 | + $meta_value = maybe_serialize($meta_value); |
|
| 207 | 207 | |
| 208 | - $data = compact( 'meta_value' ); |
|
| 209 | - $where = array( $column => $object_id, 'meta_key' => $meta_key ); |
|
| 208 | + $data = compact('meta_value'); |
|
| 209 | + $where = array($column => $object_id, 'meta_key' => $meta_key); |
|
| 210 | 210 | |
| 211 | - if ( !empty( $prev_value ) ) { |
|
| 211 | + if ( ! empty($prev_value)) { |
|
| 212 | 212 | $prev_value = maybe_serialize($prev_value); |
| 213 | 213 | $where['meta_value'] = $prev_value; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - foreach ( $meta_ids as $meta_id ) { |
|
| 216 | + foreach ($meta_ids as $meta_id) { |
|
| 217 | 217 | /** |
| 218 | 218 | * Fires immediately before updating metadata of a specific type. |
| 219 | 219 | * |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | * @param string $meta_key Meta key. |
| 228 | 228 | * @param mixed $meta_value Meta value. |
| 229 | 229 | */ |
| 230 | - do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
|
| 230 | + do_action("update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value); |
|
| 231 | 231 | |
| 232 | - if ( 'post' == $meta_type ) { |
|
| 232 | + if ('post' == $meta_type) { |
|
| 233 | 233 | /** |
| 234 | 234 | * Fires immediately before updating a post's metadata. |
| 235 | 235 | * |
@@ -240,17 +240,17 @@ discard block |
||
| 240 | 240 | * @param string $meta_key Meta key. |
| 241 | 241 | * @param mixed $meta_value Meta value. |
| 242 | 242 | */ |
| 243 | - do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); |
|
| 243 | + do_action('update_postmeta', $meta_id, $object_id, $meta_key, $meta_value); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $result = $wpdb->update( $table, $data, $where ); |
|
| 248 | - if ( ! $result ) |
|
| 247 | + $result = $wpdb->update($table, $data, $where); |
|
| 248 | + if ( ! $result) |
|
| 249 | 249 | return false; |
| 250 | 250 | |
| 251 | - wp_cache_delete($object_id, $meta_type . '_meta'); |
|
| 251 | + wp_cache_delete($object_id, $meta_type.'_meta'); |
|
| 252 | 252 | |
| 253 | - foreach ( $meta_ids as $meta_id ) { |
|
| 253 | + foreach ($meta_ids as $meta_id) { |
|
| 254 | 254 | /** |
| 255 | 255 | * Fires immediately after updating metadata of a specific type. |
| 256 | 256 | * |
@@ -264,9 +264,9 @@ discard block |
||
| 264 | 264 | * @param string $meta_key Meta key. |
| 265 | 265 | * @param mixed $meta_value Meta value. |
| 266 | 266 | */ |
| 267 | - do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
|
| 267 | + do_action("updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value); |
|
| 268 | 268 | |
| 269 | - if ( 'post' == $meta_type ) { |
|
| 269 | + if ('post' == $meta_type) { |
|
| 270 | 270 | /** |
| 271 | 271 | * Fires immediately after updating a post's metadata. |
| 272 | 272 | * |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @param string $meta_key Meta key. |
| 278 | 278 | * @param mixed $meta_value Meta value. |
| 279 | 279 | */ |
| 280 | - do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); |
|
| 280 | + do_action('updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
@@ -307,21 +307,21 @@ discard block |
||
| 307 | 307 | function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $delete_all = false) { |
| 308 | 308 | global $wpdb; |
| 309 | 309 | |
| 310 | - if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) && ! $delete_all ) { |
|
| 310 | + if ( ! $meta_type || ! $meta_key || ! is_numeric($object_id) && ! $delete_all) { |
|
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $object_id = absint( $object_id ); |
|
| 315 | - if ( ! $object_id && ! $delete_all ) { |
|
| 314 | + $object_id = absint($object_id); |
|
| 315 | + if ( ! $object_id && ! $delete_all) { |
|
| 316 | 316 | return false; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - $table = _get_meta_table( $meta_type ); |
|
| 320 | - if ( ! $table ) { |
|
| 319 | + $table = _get_meta_table($meta_type); |
|
| 320 | + if ( ! $table) { |
|
| 321 | 321 | return false; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $type_column = sanitize_key($meta_type . '_id'); |
|
| 324 | + $type_column = sanitize_key($meta_type.'_id'); |
|
| 325 | 325 | $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; |
| 326 | 326 | // expected_slashed ($meta_key) |
| 327 | 327 | $meta_key = wp_unslash($meta_key); |
@@ -344,32 +344,32 @@ discard block |
||
| 344 | 344 | * for all objects, ignoring the specified $object_id. |
| 345 | 345 | * Default false. |
| 346 | 346 | */ |
| 347 | - $check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all ); |
|
| 348 | - if ( null !== $check ) |
|
| 347 | + $check = apply_filters("delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all); |
|
| 348 | + if (null !== $check) |
|
| 349 | 349 | return (bool) $check; |
| 350 | 350 | |
| 351 | 351 | $_meta_value = $meta_value; |
| 352 | - $meta_value = maybe_serialize( $meta_value ); |
|
| 352 | + $meta_value = maybe_serialize($meta_value); |
|
| 353 | 353 | |
| 354 | - $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key ); |
|
| 354 | + $query = $wpdb->prepare("SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key); |
|
| 355 | 355 | |
| 356 | - if ( !$delete_all ) |
|
| 357 | - $query .= $wpdb->prepare(" AND $type_column = %d", $object_id ); |
|
| 356 | + if ( ! $delete_all) |
|
| 357 | + $query .= $wpdb->prepare(" AND $type_column = %d", $object_id); |
|
| 358 | 358 | |
| 359 | - if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) |
|
| 360 | - $query .= $wpdb->prepare(" AND meta_value = %s", $meta_value ); |
|
| 359 | + if ('' !== $meta_value && null !== $meta_value && false !== $meta_value) |
|
| 360 | + $query .= $wpdb->prepare(" AND meta_value = %s", $meta_value); |
|
| 361 | 361 | |
| 362 | - $meta_ids = $wpdb->get_col( $query ); |
|
| 363 | - if ( !count( $meta_ids ) ) |
|
| 362 | + $meta_ids = $wpdb->get_col($query); |
|
| 363 | + if ( ! count($meta_ids)) |
|
| 364 | 364 | return false; |
| 365 | 365 | |
| 366 | - if ( $delete_all ) { |
|
| 366 | + if ($delete_all) { |
|
| 367 | 367 | $value_clause = ''; |
| 368 | - if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) { |
|
| 369 | - $value_clause = $wpdb->prepare( " AND meta_value = %s", $meta_value ); |
|
| 368 | + if ('' !== $meta_value && null !== $meta_value && false !== $meta_value) { |
|
| 369 | + $value_clause = $wpdb->prepare(" AND meta_value = %s", $meta_value); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s $value_clause", $meta_key ) ); |
|
| 372 | + $object_ids = $wpdb->get_col($wpdb->prepare("SELECT $type_column FROM $table WHERE meta_key = %s $value_clause", $meta_key)); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -385,10 +385,10 @@ discard block |
||
| 385 | 385 | * @param string $meta_key Meta key. |
| 386 | 386 | * @param mixed $meta_value Meta value. |
| 387 | 387 | */ |
| 388 | - do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); |
|
| 388 | + do_action("delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value); |
|
| 389 | 389 | |
| 390 | 390 | // Old-style action. |
| 391 | - if ( 'post' == $meta_type ) { |
|
| 391 | + if ('post' == $meta_type) { |
|
| 392 | 392 | /** |
| 393 | 393 | * Fires immediately before deleting metadata for a post. |
| 394 | 394 | * |
@@ -396,22 +396,22 @@ discard block |
||
| 396 | 396 | * |
| 397 | 397 | * @param array $meta_ids An array of post metadata entry IDs to delete. |
| 398 | 398 | */ |
| 399 | - do_action( 'delete_postmeta', $meta_ids ); |
|
| 399 | + do_action('delete_postmeta', $meta_ids); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - $query = "DELETE FROM $table WHERE $id_column IN( " . implode( ',', $meta_ids ) . " )"; |
|
| 402 | + $query = "DELETE FROM $table WHERE $id_column IN( ".implode(',', $meta_ids)." )"; |
|
| 403 | 403 | |
| 404 | 404 | $count = $wpdb->query($query); |
| 405 | 405 | |
| 406 | - if ( !$count ) |
|
| 406 | + if ( ! $count) |
|
| 407 | 407 | return false; |
| 408 | 408 | |
| 409 | - if ( $delete_all ) { |
|
| 410 | - foreach ( (array) $object_ids as $o_id ) { |
|
| 411 | - wp_cache_delete($o_id, $meta_type . '_meta'); |
|
| 409 | + if ($delete_all) { |
|
| 410 | + foreach ((array) $object_ids as $o_id) { |
|
| 411 | + wp_cache_delete($o_id, $meta_type.'_meta'); |
|
| 412 | 412 | } |
| 413 | 413 | } else { |
| 414 | - wp_cache_delete($object_id, $meta_type . '_meta'); |
|
| 414 | + wp_cache_delete($object_id, $meta_type.'_meta'); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
@@ -427,10 +427,10 @@ discard block |
||
| 427 | 427 | * @param string $meta_key Meta key. |
| 428 | 428 | * @param mixed $meta_value Meta value. |
| 429 | 429 | */ |
| 430 | - do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); |
|
| 430 | + do_action("deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value); |
|
| 431 | 431 | |
| 432 | 432 | // Old-style action. |
| 433 | - if ( 'post' == $meta_type ) { |
|
| 433 | + if ('post' == $meta_type) { |
|
| 434 | 434 | /** |
| 435 | 435 | * Fires immediately after deleting metadata for a post. |
| 436 | 436 | * |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * |
| 439 | 439 | * @param array $meta_ids An array of deleted post metadata entry IDs. |
| 440 | 440 | */ |
| 441 | - do_action( 'deleted_postmeta', $meta_ids ); |
|
| 441 | + do_action('deleted_postmeta', $meta_ids); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | return true; |
@@ -459,12 +459,12 @@ discard block |
||
| 459 | 459 | * @return mixed Single metadata value, or array of values |
| 460 | 460 | */ |
| 461 | 461 | function get_metadata($meta_type, $object_id, $meta_key = '', $single = false) { |
| 462 | - if ( ! $meta_type || ! is_numeric( $object_id ) ) { |
|
| 462 | + if ( ! $meta_type || ! is_numeric($object_id)) { |
|
| 463 | 463 | return false; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - $object_id = absint( $object_id ); |
|
| 467 | - if ( ! $object_id ) { |
|
| 466 | + $object_id = absint($object_id); |
|
| 467 | + if ( ! $object_id) { |
|
| 468 | 468 | return false; |
| 469 | 469 | } |
| 470 | 470 | |
@@ -483,28 +483,28 @@ discard block |
||
| 483 | 483 | * @param string $meta_key Meta key. |
| 484 | 484 | * @param bool $single Whether to return only the first value of the specified $meta_key. |
| 485 | 485 | */ |
| 486 | - $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single ); |
|
| 487 | - if ( null !== $check ) { |
|
| 488 | - if ( $single && is_array( $check ) ) |
|
| 486 | + $check = apply_filters("get_{$meta_type}_metadata", null, $object_id, $meta_key, $single); |
|
| 487 | + if (null !== $check) { |
|
| 488 | + if ($single && is_array($check)) |
|
| 489 | 489 | return $check[0]; |
| 490 | 490 | else |
| 491 | 491 | return $check; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - $meta_cache = wp_cache_get($object_id, $meta_type . '_meta'); |
|
| 494 | + $meta_cache = wp_cache_get($object_id, $meta_type.'_meta'); |
|
| 495 | 495 | |
| 496 | - if ( !$meta_cache ) { |
|
| 497 | - $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); |
|
| 496 | + if ( ! $meta_cache) { |
|
| 497 | + $meta_cache = update_meta_cache($meta_type, array($object_id)); |
|
| 498 | 498 | $meta_cache = $meta_cache[$object_id]; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - if ( ! $meta_key ) { |
|
| 501 | + if ( ! $meta_key) { |
|
| 502 | 502 | return $meta_cache; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - if ( isset($meta_cache[$meta_key]) ) { |
|
| 506 | - if ( $single ) |
|
| 507 | - return maybe_unserialize( $meta_cache[$meta_key][0] ); |
|
| 505 | + if (isset($meta_cache[$meta_key])) { |
|
| 506 | + if ($single) |
|
| 507 | + return maybe_unserialize($meta_cache[$meta_key][0]); |
|
| 508 | 508 | else |
| 509 | 509 | return array_map('maybe_unserialize', $meta_cache[$meta_key]); |
| 510 | 510 | } |
@@ -525,29 +525,29 @@ discard block |
||
| 525 | 525 | * @param string $meta_key Metadata key. |
| 526 | 526 | * @return bool True of the key is set, false if not. |
| 527 | 527 | */ |
| 528 | -function metadata_exists( $meta_type, $object_id, $meta_key ) { |
|
| 529 | - if ( ! $meta_type || ! is_numeric( $object_id ) ) { |
|
| 528 | +function metadata_exists($meta_type, $object_id, $meta_key) { |
|
| 529 | + if ( ! $meta_type || ! is_numeric($object_id)) { |
|
| 530 | 530 | return false; |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $object_id = absint( $object_id ); |
|
| 534 | - if ( ! $object_id ) { |
|
| 533 | + $object_id = absint($object_id); |
|
| 534 | + if ( ! $object_id) { |
|
| 535 | 535 | return false; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** This filter is documented in wp-includes/meta.php */ |
| 539 | - $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true ); |
|
| 540 | - if ( null !== $check ) |
|
| 539 | + $check = apply_filters("get_{$meta_type}_metadata", null, $object_id, $meta_key, true); |
|
| 540 | + if (null !== $check) |
|
| 541 | 541 | return (bool) $check; |
| 542 | 542 | |
| 543 | - $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); |
|
| 543 | + $meta_cache = wp_cache_get($object_id, $meta_type.'_meta'); |
|
| 544 | 544 | |
| 545 | - if ( !$meta_cache ) { |
|
| 546 | - $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); |
|
| 545 | + if ( ! $meta_cache) { |
|
| 546 | + $meta_cache = update_meta_cache($meta_type, array($object_id)); |
|
| 547 | 547 | $meta_cache = $meta_cache[$object_id]; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - if ( isset( $meta_cache[ $meta_key ] ) ) |
|
| 550 | + if (isset($meta_cache[$meta_key])) |
|
| 551 | 551 | return true; |
| 552 | 552 | |
| 553 | 553 | return false; |
@@ -564,32 +564,32 @@ discard block |
||
| 564 | 564 | * @param int $meta_id ID for a specific meta row |
| 565 | 565 | * @return object|false Meta object or false. |
| 566 | 566 | */ |
| 567 | -function get_metadata_by_mid( $meta_type, $meta_id ) { |
|
| 567 | +function get_metadata_by_mid($meta_type, $meta_id) { |
|
| 568 | 568 | global $wpdb; |
| 569 | 569 | |
| 570 | - if ( ! $meta_type || ! is_numeric( $meta_id ) ) { |
|
| 570 | + if ( ! $meta_type || ! is_numeric($meta_id)) { |
|
| 571 | 571 | return false; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - $meta_id = absint( $meta_id ); |
|
| 575 | - if ( ! $meta_id ) { |
|
| 574 | + $meta_id = absint($meta_id); |
|
| 575 | + if ( ! $meta_id) { |
|
| 576 | 576 | return false; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - $table = _get_meta_table( $meta_type ); |
|
| 580 | - if ( ! $table ) { |
|
| 579 | + $table = _get_meta_table($meta_type); |
|
| 580 | + if ( ! $table) { |
|
| 581 | 581 | return false; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $id_column = ( 'user' == $meta_type ) ? 'umeta_id' : 'meta_id'; |
|
| 584 | + $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id'; |
|
| 585 | 585 | |
| 586 | - $meta = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table WHERE $id_column = %d", $meta_id ) ); |
|
| 586 | + $meta = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE $id_column = %d", $meta_id)); |
|
| 587 | 587 | |
| 588 | - if ( empty( $meta ) ) |
|
| 588 | + if (empty($meta)) |
|
| 589 | 589 | return false; |
| 590 | 590 | |
| 591 | - if ( isset( $meta->meta_value ) ) |
|
| 592 | - $meta->meta_value = maybe_unserialize( $meta->meta_value ); |
|
| 591 | + if (isset($meta->meta_value)) |
|
| 592 | + $meta->meta_value = maybe_unserialize($meta->meta_value); |
|
| 593 | 593 | |
| 594 | 594 | return $meta; |
| 595 | 595 | } |
@@ -607,44 +607,44 @@ discard block |
||
| 607 | 607 | * @param string $meta_key Optional, you can provide a meta key to update it |
| 608 | 608 | * @return bool True on successful update, false on failure. |
| 609 | 609 | */ |
| 610 | -function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = false ) { |
|
| 610 | +function update_metadata_by_mid($meta_type, $meta_id, $meta_value, $meta_key = false) { |
|
| 611 | 611 | global $wpdb; |
| 612 | 612 | |
| 613 | 613 | // Make sure everything is valid. |
| 614 | - if ( ! $meta_type || ! is_numeric( $meta_id ) ) { |
|
| 614 | + if ( ! $meta_type || ! is_numeric($meta_id)) { |
|
| 615 | 615 | return false; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $meta_id = absint( $meta_id ); |
|
| 619 | - if ( ! $meta_id ) { |
|
| 618 | + $meta_id = absint($meta_id); |
|
| 619 | + if ( ! $meta_id) { |
|
| 620 | 620 | return false; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - $table = _get_meta_table( $meta_type ); |
|
| 624 | - if ( ! $table ) { |
|
| 623 | + $table = _get_meta_table($meta_type); |
|
| 624 | + if ( ! $table) { |
|
| 625 | 625 | return false; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - $column = sanitize_key($meta_type . '_id'); |
|
| 628 | + $column = sanitize_key($meta_type.'_id'); |
|
| 629 | 629 | $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; |
| 630 | 630 | |
| 631 | 631 | // Fetch the meta and go on if it's found. |
| 632 | - if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) { |
|
| 632 | + if ($meta = get_metadata_by_mid($meta_type, $meta_id)) { |
|
| 633 | 633 | $original_key = $meta->meta_key; |
| 634 | 634 | $object_id = $meta->{$column}; |
| 635 | 635 | |
| 636 | 636 | // If a new meta_key (last parameter) was specified, change the meta key, |
| 637 | 637 | // otherwise use the original key in the update statement. |
| 638 | - if ( false === $meta_key ) { |
|
| 638 | + if (false === $meta_key) { |
|
| 639 | 639 | $meta_key = $original_key; |
| 640 | - } elseif ( ! is_string( $meta_key ) ) { |
|
| 640 | + } elseif ( ! is_string($meta_key)) { |
|
| 641 | 641 | return false; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | // Sanitize the meta |
| 645 | 645 | $_meta_value = $meta_value; |
| 646 | - $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); |
|
| 647 | - $meta_value = maybe_serialize( $meta_value ); |
|
| 646 | + $meta_value = sanitize_meta($meta_key, $meta_value, $meta_type); |
|
| 647 | + $meta_value = maybe_serialize($meta_value); |
|
| 648 | 648 | |
| 649 | 649 | // Format the data query arguments. |
| 650 | 650 | $data = array( |
@@ -657,27 +657,27 @@ discard block |
||
| 657 | 657 | $where[$id_column] = $meta_id; |
| 658 | 658 | |
| 659 | 659 | /** This action is documented in wp-includes/meta.php */ |
| 660 | - do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
|
| 660 | + do_action("update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value); |
|
| 661 | 661 | |
| 662 | - if ( 'post' == $meta_type ) { |
|
| 662 | + if ('post' == $meta_type) { |
|
| 663 | 663 | /** This action is documented in wp-includes/meta.php */ |
| 664 | - do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); |
|
| 664 | + do_action('update_postmeta', $meta_id, $object_id, $meta_key, $meta_value); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | // Run the update query, all fields in $data are %s, $where is a %d. |
| 668 | - $result = $wpdb->update( $table, $data, $where, '%s', '%d' ); |
|
| 669 | - if ( ! $result ) |
|
| 668 | + $result = $wpdb->update($table, $data, $where, '%s', '%d'); |
|
| 669 | + if ( ! $result) |
|
| 670 | 670 | return false; |
| 671 | 671 | |
| 672 | 672 | // Clear the caches. |
| 673 | - wp_cache_delete($object_id, $meta_type . '_meta'); |
|
| 673 | + wp_cache_delete($object_id, $meta_type.'_meta'); |
|
| 674 | 674 | |
| 675 | 675 | /** This action is documented in wp-includes/meta.php */ |
| 676 | - do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
|
| 676 | + do_action("updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value); |
|
| 677 | 677 | |
| 678 | - if ( 'post' == $meta_type ) { |
|
| 678 | + if ('post' == $meta_type) { |
|
| 679 | 679 | /** This action is documented in wp-includes/meta.php */ |
| 680 | - do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); |
|
| 680 | + do_action('updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | return true; |
@@ -698,37 +698,37 @@ discard block |
||
| 698 | 698 | * @param int $meta_id ID for a specific meta row |
| 699 | 699 | * @return bool True on successful delete, false on failure. |
| 700 | 700 | */ |
| 701 | -function delete_metadata_by_mid( $meta_type, $meta_id ) { |
|
| 701 | +function delete_metadata_by_mid($meta_type, $meta_id) { |
|
| 702 | 702 | global $wpdb; |
| 703 | 703 | |
| 704 | 704 | // Make sure everything is valid. |
| 705 | - if ( ! $meta_type || ! is_numeric( $meta_id ) ) { |
|
| 705 | + if ( ! $meta_type || ! is_numeric($meta_id)) { |
|
| 706 | 706 | return false; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - $meta_id = absint( $meta_id ); |
|
| 710 | - if ( ! $meta_id ) { |
|
| 709 | + $meta_id = absint($meta_id); |
|
| 710 | + if ( ! $meta_id) { |
|
| 711 | 711 | return false; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - $table = _get_meta_table( $meta_type ); |
|
| 715 | - if ( ! $table ) { |
|
| 714 | + $table = _get_meta_table($meta_type); |
|
| 715 | + if ( ! $table) { |
|
| 716 | 716 | return false; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | // object and id columns |
| 720 | - $column = sanitize_key($meta_type . '_id'); |
|
| 720 | + $column = sanitize_key($meta_type.'_id'); |
|
| 721 | 721 | $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; |
| 722 | 722 | |
| 723 | 723 | // Fetch the meta and go on if it's found. |
| 724 | - if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) { |
|
| 724 | + if ($meta = get_metadata_by_mid($meta_type, $meta_id)) { |
|
| 725 | 725 | $object_id = $meta->{$column}; |
| 726 | 726 | |
| 727 | 727 | /** This action is documented in wp-includes/meta.php */ |
| 728 | - do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); |
|
| 728 | + do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value); |
|
| 729 | 729 | |
| 730 | 730 | // Old-style action. |
| 731 | - if ( 'post' == $meta_type || 'comment' == $meta_type ) { |
|
| 731 | + if ('post' == $meta_type || 'comment' == $meta_type) { |
|
| 732 | 732 | /** |
| 733 | 733 | * Fires immediately before deleting post or comment metadata of a specific type. |
| 734 | 734 | * |
@@ -739,20 +739,20 @@ discard block |
||
| 739 | 739 | * |
| 740 | 740 | * @param int $meta_id ID of the metadata entry to delete. |
| 741 | 741 | */ |
| 742 | - do_action( "delete_{$meta_type}meta", $meta_id ); |
|
| 742 | + do_action("delete_{$meta_type}meta", $meta_id); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | // Run the query, will return true if deleted, false otherwise |
| 746 | - $result = (bool) $wpdb->delete( $table, array( $id_column => $meta_id ) ); |
|
| 746 | + $result = (bool) $wpdb->delete($table, array($id_column => $meta_id)); |
|
| 747 | 747 | |
| 748 | 748 | // Clear the caches. |
| 749 | - wp_cache_delete($object_id, $meta_type . '_meta'); |
|
| 749 | + wp_cache_delete($object_id, $meta_type.'_meta'); |
|
| 750 | 750 | |
| 751 | 751 | /** This action is documented in wp-includes/meta.php */ |
| 752 | - do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); |
|
| 752 | + do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value); |
|
| 753 | 753 | |
| 754 | 754 | // Old-style action. |
| 755 | - if ( 'post' == $meta_type || 'comment' == $meta_type ) { |
|
| 755 | + if ('post' == $meta_type || 'comment' == $meta_type) { |
|
| 756 | 756 | /** |
| 757 | 757 | * Fires immediately after deleting post or comment metadata of a specific type. |
| 758 | 758 | * |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | * |
| 764 | 764 | * @param int $meta_ids Deleted metadata entry ID. |
| 765 | 765 | */ |
| 766 | - do_action( "deleted_{$meta_type}meta", $meta_id ); |
|
| 766 | + do_action("deleted_{$meta_type}meta", $meta_id); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | return $result; |
@@ -788,53 +788,53 @@ discard block |
||
| 788 | 788 | function update_meta_cache($meta_type, $object_ids) { |
| 789 | 789 | global $wpdb; |
| 790 | 790 | |
| 791 | - if ( ! $meta_type || ! $object_ids ) { |
|
| 791 | + if ( ! $meta_type || ! $object_ids) { |
|
| 792 | 792 | return false; |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - $table = _get_meta_table( $meta_type ); |
|
| 796 | - if ( ! $table ) { |
|
| 795 | + $table = _get_meta_table($meta_type); |
|
| 796 | + if ( ! $table) { |
|
| 797 | 797 | return false; |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - $column = sanitize_key($meta_type . '_id'); |
|
| 800 | + $column = sanitize_key($meta_type.'_id'); |
|
| 801 | 801 | |
| 802 | - if ( !is_array($object_ids) ) { |
|
| 802 | + if ( ! is_array($object_ids)) { |
|
| 803 | 803 | $object_ids = preg_replace('|[^0-9,]|', '', $object_ids); |
| 804 | 804 | $object_ids = explode(',', $object_ids); |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | $object_ids = array_map('intval', $object_ids); |
| 808 | 808 | |
| 809 | - $cache_key = $meta_type . '_meta'; |
|
| 809 | + $cache_key = $meta_type.'_meta'; |
|
| 810 | 810 | $ids = array(); |
| 811 | 811 | $cache = array(); |
| 812 | - foreach ( $object_ids as $id ) { |
|
| 813 | - $cached_object = wp_cache_get( $id, $cache_key ); |
|
| 814 | - if ( false === $cached_object ) |
|
| 812 | + foreach ($object_ids as $id) { |
|
| 813 | + $cached_object = wp_cache_get($id, $cache_key); |
|
| 814 | + if (false === $cached_object) |
|
| 815 | 815 | $ids[] = $id; |
| 816 | 816 | else |
| 817 | 817 | $cache[$id] = $cached_object; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - if ( empty( $ids ) ) |
|
| 820 | + if (empty($ids)) |
|
| 821 | 821 | return $cache; |
| 822 | 822 | |
| 823 | 823 | // Get meta info |
| 824 | - $id_list = join( ',', $ids ); |
|
| 824 | + $id_list = join(',', $ids); |
|
| 825 | 825 | $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; |
| 826 | - $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A ); |
|
| 826 | + $meta_list = $wpdb->get_results("SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A); |
|
| 827 | 827 | |
| 828 | - if ( !empty($meta_list) ) { |
|
| 829 | - foreach ( $meta_list as $metarow) { |
|
| 828 | + if ( ! empty($meta_list)) { |
|
| 829 | + foreach ($meta_list as $metarow) { |
|
| 830 | 830 | $mpid = intval($metarow[$column]); |
| 831 | 831 | $mkey = $metarow['meta_key']; |
| 832 | 832 | $mval = $metarow['meta_value']; |
| 833 | 833 | |
| 834 | 834 | // Force subkeys to be array type: |
| 835 | - if ( !isset($cache[$mpid]) || !is_array($cache[$mpid]) ) |
|
| 835 | + if ( ! isset($cache[$mpid]) || ! is_array($cache[$mpid])) |
|
| 836 | 836 | $cache[$mpid] = array(); |
| 837 | - if ( !isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey]) ) |
|
| 837 | + if ( ! isset($cache[$mpid][$mkey]) || ! is_array($cache[$mpid][$mkey])) |
|
| 838 | 838 | $cache[$mpid][$mkey] = array(); |
| 839 | 839 | |
| 840 | 840 | // Add a value to the current pid/key: |
@@ -842,10 +842,10 @@ discard block |
||
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - foreach ( $ids as $id ) { |
|
| 846 | - if ( ! isset($cache[$id]) ) |
|
| 845 | + foreach ($ids as $id) { |
|
| 846 | + if ( ! isset($cache[$id])) |
|
| 847 | 847 | $cache[$id] = array(); |
| 848 | - wp_cache_add( $id, $cache[$id], $cache_key ); |
|
| 848 | + wp_cache_add($id, $cache[$id], $cache_key); |
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | return $cache; |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | function wp_metadata_lazyloader() { |
| 862 | 862 | static $wp_metadata_lazyloader; |
| 863 | 863 | |
| 864 | - if ( null === $wp_metadata_lazyloader ) { |
|
| 864 | + if (null === $wp_metadata_lazyloader) { |
|
| 865 | 865 | $wp_metadata_lazyloader = new WP_Metadata_Lazyloader(); |
| 866 | 866 | } |
| 867 | 867 | |
@@ -882,9 +882,9 @@ discard block |
||
| 882 | 882 | * @param object $context Optional. The main query object |
| 883 | 883 | * @return array Associative array of `JOIN` and `WHERE` SQL. |
| 884 | 884 | */ |
| 885 | -function get_meta_sql( $meta_query, $type, $primary_table, $primary_id_column, $context = null ) { |
|
| 886 | - $meta_query_obj = new WP_Meta_Query( $meta_query ); |
|
| 887 | - return $meta_query_obj->get_sql( $type, $primary_table, $primary_id_column, $context ); |
|
| 885 | +function get_meta_sql($meta_query, $type, $primary_table, $primary_id_column, $context = null) { |
|
| 886 | + $meta_query_obj = new WP_Meta_Query($meta_query); |
|
| 887 | + return $meta_query_obj->get_sql($type, $primary_table, $primary_id_column, $context); |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
@@ -900,9 +900,9 @@ discard block |
||
| 900 | 900 | function _get_meta_table($type) { |
| 901 | 901 | global $wpdb; |
| 902 | 902 | |
| 903 | - $table_name = $type . 'meta'; |
|
| 903 | + $table_name = $type.'meta'; |
|
| 904 | 904 | |
| 905 | - if ( empty($wpdb->$table_name) ) |
|
| 905 | + if (empty($wpdb->$table_name)) |
|
| 906 | 906 | return false; |
| 907 | 907 | |
| 908 | 908 | return $wpdb->$table_name; |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | * @param string|null $meta_type |
| 918 | 918 | * @return bool True if the key is protected, false otherwise. |
| 919 | 919 | */ |
| 920 | -function is_protected_meta( $meta_key, $meta_type = null ) { |
|
| 921 | - $protected = ( '_' == $meta_key[0] ); |
|
| 920 | +function is_protected_meta($meta_key, $meta_type = null) { |
|
| 921 | + $protected = ('_' == $meta_key[0]); |
|
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | 924 | * Filter whether a meta key is protected. |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | * @param string $meta_key Meta key. |
| 930 | 930 | * @param string $meta_type Meta type. |
| 931 | 931 | */ |
| 932 | - return apply_filters( 'is_protected_meta', $protected, $meta_key, $meta_type ); |
|
| 932 | + return apply_filters('is_protected_meta', $protected, $meta_key, $meta_type); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | /** |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | * @param string $meta_type Type of meta |
| 943 | 943 | * @return mixed Sanitized $meta_value |
| 944 | 944 | */ |
| 945 | -function sanitize_meta( $meta_key, $meta_value, $meta_type ) { |
|
| 945 | +function sanitize_meta($meta_key, $meta_value, $meta_type) { |
|
| 946 | 946 | |
| 947 | 947 | /** |
| 948 | 948 | * Filter the sanitization of a specific meta key of a specific meta type. |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | * @param string $meta_key Meta key. |
| 959 | 959 | * @param string $meta_type Meta type. |
| 960 | 960 | */ |
| 961 | - return apply_filters( "sanitize_{$meta_type}_meta_{$meta_key}", $meta_value, $meta_key, $meta_type ); |
|
| 961 | + return apply_filters("sanitize_{$meta_type}_meta_{$meta_key}", $meta_value, $meta_key, $meta_type); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | /** |
@@ -971,17 +971,17 @@ discard block |
||
| 971 | 971 | * @param string|array $sanitize_callback A function or method to call when sanitizing the value of $meta_key. |
| 972 | 972 | * @param string|array $auth_callback Optional. A function or method to call when performing edit_post_meta, add_post_meta, and delete_post_meta capability checks. |
| 973 | 973 | */ |
| 974 | -function register_meta( $meta_type, $meta_key, $sanitize_callback, $auth_callback = null ) { |
|
| 975 | - if ( is_callable( $sanitize_callback ) ) |
|
| 976 | - add_filter( "sanitize_{$meta_type}_meta_{$meta_key}", $sanitize_callback, 10, 3 ); |
|
| 974 | +function register_meta($meta_type, $meta_key, $sanitize_callback, $auth_callback = null) { |
|
| 975 | + if (is_callable($sanitize_callback)) |
|
| 976 | + add_filter("sanitize_{$meta_type}_meta_{$meta_key}", $sanitize_callback, 10, 3); |
|
| 977 | 977 | |
| 978 | - if ( empty( $auth_callback ) ) { |
|
| 979 | - if ( is_protected_meta( $meta_key, $meta_type ) ) |
|
| 978 | + if (empty($auth_callback)) { |
|
| 979 | + if (is_protected_meta($meta_key, $meta_type)) |
|
| 980 | 980 | $auth_callback = '__return_false'; |
| 981 | 981 | else |
| 982 | 982 | $auth_callback = '__return_true'; |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | - if ( is_callable( $auth_callback ) ) |
|
| 986 | - add_filter( "auth_{$meta_type}_meta_{$meta_key}", $auth_callback, 10, 6 ); |
|
| 985 | + if (is_callable($auth_callback)) |
|
| 986 | + add_filter("auth_{$meta_type}_meta_{$meta_key}", $auth_callback, 10, 6); |
|
| 987 | 987 | } |
@@ -68,13 +68,15 @@ discard block |
||
| 68 | 68 | * for the object. Optional. Default false. |
| 69 | 69 | */ |
| 70 | 70 | $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique ); |
| 71 | - if ( null !== $check ) |
|
| 72 | - return $check; |
|
| 71 | + if ( null !== $check ) { |
|
| 72 | + return $check; |
|
| 73 | + } |
|
| 73 | 74 | |
| 74 | 75 | if ( $unique && $wpdb->get_var( $wpdb->prepare( |
| 75 | 76 | "SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d", |
| 76 | - $meta_key, $object_id ) ) ) |
|
| 77 | - return false; |
|
| 77 | + $meta_key, $object_id ) ) ) { |
|
| 78 | + return false; |
|
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | $_meta_value = $meta_value; |
| 80 | 82 | $meta_value = maybe_serialize( $meta_value ); |
@@ -99,8 +101,9 @@ discard block |
||
| 99 | 101 | 'meta_value' => $meta_value |
| 100 | 102 | ) ); |
| 101 | 103 | |
| 102 | - if ( ! $result ) |
|
| 103 | - return false; |
|
| 104 | + if ( ! $result ) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 104 | 107 | |
| 105 | 108 | $mid = (int) $wpdb->insert_id; |
| 106 | 109 | |
@@ -185,15 +188,17 @@ discard block |
||
| 185 | 188 | * Otherwise, update all entries. |
| 186 | 189 | */ |
| 187 | 190 | $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value ); |
| 188 | - if ( null !== $check ) |
|
| 189 | - return (bool) $check; |
|
| 191 | + if ( null !== $check ) { |
|
| 192 | + return (bool) $check; |
|
| 193 | + } |
|
| 190 | 194 | |
| 191 | 195 | // Compare existing value to new value if no prev value given and the key exists only once. |
| 192 | 196 | if ( empty($prev_value) ) { |
| 193 | 197 | $old_value = get_metadata($meta_type, $object_id, $meta_key); |
| 194 | 198 | if ( count($old_value) == 1 ) { |
| 195 | - if ( $old_value[0] === $meta_value ) |
|
| 196 | - return false; |
|
| 199 | + if ( $old_value[0] === $meta_value ) { |
|
| 200 | + return false; |
|
| 201 | + } |
|
| 197 | 202 | } |
| 198 | 203 | } |
| 199 | 204 | |
@@ -245,8 +250,9 @@ discard block |
||
| 245 | 250 | } |
| 246 | 251 | |
| 247 | 252 | $result = $wpdb->update( $table, $data, $where ); |
| 248 | - if ( ! $result ) |
|
| 249 | - return false; |
|
| 253 | + if ( ! $result ) { |
|
| 254 | + return false; |
|
| 255 | + } |
|
| 250 | 256 | |
| 251 | 257 | wp_cache_delete($object_id, $meta_type . '_meta'); |
| 252 | 258 | |
@@ -345,23 +351,27 @@ discard block |
||
| 345 | 351 | * Default false. |
| 346 | 352 | */ |
| 347 | 353 | $check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all ); |
| 348 | - if ( null !== $check ) |
|
| 349 | - return (bool) $check; |
|
| 354 | + if ( null !== $check ) { |
|
| 355 | + return (bool) $check; |
|
| 356 | + } |
|
| 350 | 357 | |
| 351 | 358 | $_meta_value = $meta_value; |
| 352 | 359 | $meta_value = maybe_serialize( $meta_value ); |
| 353 | 360 | |
| 354 | 361 | $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key ); |
| 355 | 362 | |
| 356 | - if ( !$delete_all ) |
|
| 357 | - $query .= $wpdb->prepare(" AND $type_column = %d", $object_id ); |
|
| 363 | + if ( !$delete_all ) { |
|
| 364 | + $query .= $wpdb->prepare(" AND $type_column = %d", $object_id ); |
|
| 365 | + } |
|
| 358 | 366 | |
| 359 | - if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) |
|
| 360 | - $query .= $wpdb->prepare(" AND meta_value = %s", $meta_value ); |
|
| 367 | + if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) { |
|
| 368 | + $query .= $wpdb->prepare(" AND meta_value = %s", $meta_value ); |
|
| 369 | + } |
|
| 361 | 370 | |
| 362 | 371 | $meta_ids = $wpdb->get_col( $query ); |
| 363 | - if ( !count( $meta_ids ) ) |
|
| 364 | - return false; |
|
| 372 | + if ( !count( $meta_ids ) ) { |
|
| 373 | + return false; |
|
| 374 | + } |
|
| 365 | 375 | |
| 366 | 376 | if ( $delete_all ) { |
| 367 | 377 | $value_clause = ''; |
@@ -403,8 +413,9 @@ discard block |
||
| 403 | 413 | |
| 404 | 414 | $count = $wpdb->query($query); |
| 405 | 415 | |
| 406 | - if ( !$count ) |
|
| 407 | - return false; |
|
| 416 | + if ( !$count ) { |
|
| 417 | + return false; |
|
| 418 | + } |
|
| 408 | 419 | |
| 409 | 420 | if ( $delete_all ) { |
| 410 | 421 | foreach ( (array) $object_ids as $o_id ) { |
@@ -485,10 +496,11 @@ discard block |
||
| 485 | 496 | */ |
| 486 | 497 | $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single ); |
| 487 | 498 | if ( null !== $check ) { |
| 488 | - if ( $single && is_array( $check ) ) |
|
| 489 | - return $check[0]; |
|
| 490 | - else |
|
| 491 | - return $check; |
|
| 499 | + if ( $single && is_array( $check ) ) { |
|
| 500 | + return $check[0]; |
|
| 501 | + } else { |
|
| 502 | + return $check; |
|
| 503 | + } |
|
| 492 | 504 | } |
| 493 | 505 | |
| 494 | 506 | $meta_cache = wp_cache_get($object_id, $meta_type . '_meta'); |
@@ -503,17 +515,19 @@ discard block |
||
| 503 | 515 | } |
| 504 | 516 | |
| 505 | 517 | if ( isset($meta_cache[$meta_key]) ) { |
| 506 | - if ( $single ) |
|
| 507 | - return maybe_unserialize( $meta_cache[$meta_key][0] ); |
|
| 508 | - else |
|
| 509 | - return array_map('maybe_unserialize', $meta_cache[$meta_key]); |
|
| 518 | + if ( $single ) { |
|
| 519 | + return maybe_unserialize( $meta_cache[$meta_key][0] ); |
|
| 520 | + } else { |
|
| 521 | + return array_map('maybe_unserialize', $meta_cache[$meta_key]); |
|
| 522 | + } |
|
| 510 | 523 | } |
| 511 | 524 | |
| 512 | - if ($single) |
|
| 513 | - return ''; |
|
| 514 | - else |
|
| 515 | - return array(); |
|
| 516 | -} |
|
| 525 | + if ($single) { |
|
| 526 | + return ''; |
|
| 527 | + } else { |
|
| 528 | + return array(); |
|
| 529 | + } |
|
| 530 | + } |
|
| 517 | 531 | |
| 518 | 532 | /** |
| 519 | 533 | * Determine if a meta key is set for a given object |
@@ -537,8 +551,9 @@ discard block |
||
| 537 | 551 | |
| 538 | 552 | /** This filter is documented in wp-includes/meta.php */ |
| 539 | 553 | $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true ); |
| 540 | - if ( null !== $check ) |
|
| 541 | - return (bool) $check; |
|
| 554 | + if ( null !== $check ) { |
|
| 555 | + return (bool) $check; |
|
| 556 | + } |
|
| 542 | 557 | |
| 543 | 558 | $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); |
| 544 | 559 | |
@@ -547,8 +562,9 @@ discard block |
||
| 547 | 562 | $meta_cache = $meta_cache[$object_id]; |
| 548 | 563 | } |
| 549 | 564 | |
| 550 | - if ( isset( $meta_cache[ $meta_key ] ) ) |
|
| 551 | - return true; |
|
| 565 | + if ( isset( $meta_cache[ $meta_key ] ) ) { |
|
| 566 | + return true; |
|
| 567 | + } |
|
| 552 | 568 | |
| 553 | 569 | return false; |
| 554 | 570 | } |
@@ -585,11 +601,13 @@ discard block |
||
| 585 | 601 | |
| 586 | 602 | $meta = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table WHERE $id_column = %d", $meta_id ) ); |
| 587 | 603 | |
| 588 | - if ( empty( $meta ) ) |
|
| 589 | - return false; |
|
| 604 | + if ( empty( $meta ) ) { |
|
| 605 | + return false; |
|
| 606 | + } |
|
| 590 | 607 | |
| 591 | - if ( isset( $meta->meta_value ) ) |
|
| 592 | - $meta->meta_value = maybe_unserialize( $meta->meta_value ); |
|
| 608 | + if ( isset( $meta->meta_value ) ) { |
|
| 609 | + $meta->meta_value = maybe_unserialize( $meta->meta_value ); |
|
| 610 | + } |
|
| 593 | 611 | |
| 594 | 612 | return $meta; |
| 595 | 613 | } |
@@ -666,8 +684,9 @@ discard block |
||
| 666 | 684 | |
| 667 | 685 | // Run the update query, all fields in $data are %s, $where is a %d. |
| 668 | 686 | $result = $wpdb->update( $table, $data, $where, '%s', '%d' ); |
| 669 | - if ( ! $result ) |
|
| 670 | - return false; |
|
| 687 | + if ( ! $result ) { |
|
| 688 | + return false; |
|
| 689 | + } |
|
| 671 | 690 | |
| 672 | 691 | // Clear the caches. |
| 673 | 692 | wp_cache_delete($object_id, $meta_type . '_meta'); |
@@ -811,14 +830,16 @@ discard block |
||
| 811 | 830 | $cache = array(); |
| 812 | 831 | foreach ( $object_ids as $id ) { |
| 813 | 832 | $cached_object = wp_cache_get( $id, $cache_key ); |
| 814 | - if ( false === $cached_object ) |
|
| 815 | - $ids[] = $id; |
|
| 816 | - else |
|
| 817 | - $cache[$id] = $cached_object; |
|
| 833 | + if ( false === $cached_object ) { |
|
| 834 | + $ids[] = $id; |
|
| 835 | + } else { |
|
| 836 | + $cache[$id] = $cached_object; |
|
| 837 | + } |
|
| 818 | 838 | } |
| 819 | 839 | |
| 820 | - if ( empty( $ids ) ) |
|
| 821 | - return $cache; |
|
| 840 | + if ( empty( $ids ) ) { |
|
| 841 | + return $cache; |
|
| 842 | + } |
|
| 822 | 843 | |
| 823 | 844 | // Get meta info |
| 824 | 845 | $id_list = join( ',', $ids ); |
@@ -832,10 +853,12 @@ discard block |
||
| 832 | 853 | $mval = $metarow['meta_value']; |
| 833 | 854 | |
| 834 | 855 | // Force subkeys to be array type: |
| 835 | - if ( !isset($cache[$mpid]) || !is_array($cache[$mpid]) ) |
|
| 836 | - $cache[$mpid] = array(); |
|
| 837 | - if ( !isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey]) ) |
|
| 838 | - $cache[$mpid][$mkey] = array(); |
|
| 856 | + if ( !isset($cache[$mpid]) || !is_array($cache[$mpid]) ) { |
|
| 857 | + $cache[$mpid] = array(); |
|
| 858 | + } |
|
| 859 | + if ( !isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey]) ) { |
|
| 860 | + $cache[$mpid][$mkey] = array(); |
|
| 861 | + } |
|
| 839 | 862 | |
| 840 | 863 | // Add a value to the current pid/key: |
| 841 | 864 | $cache[$mpid][$mkey][] = $mval; |
@@ -843,8 +866,9 @@ discard block |
||
| 843 | 866 | } |
| 844 | 867 | |
| 845 | 868 | foreach ( $ids as $id ) { |
| 846 | - if ( ! isset($cache[$id]) ) |
|
| 847 | - $cache[$id] = array(); |
|
| 869 | + if ( ! isset($cache[$id]) ) { |
|
| 870 | + $cache[$id] = array(); |
|
| 871 | + } |
|
| 848 | 872 | wp_cache_add( $id, $cache[$id], $cache_key ); |
| 849 | 873 | } |
| 850 | 874 | |
@@ -902,8 +926,9 @@ discard block |
||
| 902 | 926 | |
| 903 | 927 | $table_name = $type . 'meta'; |
| 904 | 928 | |
| 905 | - if ( empty($wpdb->$table_name) ) |
|
| 906 | - return false; |
|
| 929 | + if ( empty($wpdb->$table_name) ) { |
|
| 930 | + return false; |
|
| 931 | + } |
|
| 907 | 932 | |
| 908 | 933 | return $wpdb->$table_name; |
| 909 | 934 | } |
@@ -972,16 +997,19 @@ discard block |
||
| 972 | 997 | * @param string|array $auth_callback Optional. A function or method to call when performing edit_post_meta, add_post_meta, and delete_post_meta capability checks. |
| 973 | 998 | */ |
| 974 | 999 | function register_meta( $meta_type, $meta_key, $sanitize_callback, $auth_callback = null ) { |
| 975 | - if ( is_callable( $sanitize_callback ) ) |
|
| 976 | - add_filter( "sanitize_{$meta_type}_meta_{$meta_key}", $sanitize_callback, 10, 3 ); |
|
| 1000 | + if ( is_callable( $sanitize_callback ) ) { |
|
| 1001 | + add_filter( "sanitize_{$meta_type}_meta_{$meta_key}", $sanitize_callback, 10, 3 ); |
|
| 1002 | + } |
|
| 977 | 1003 | |
| 978 | 1004 | if ( empty( $auth_callback ) ) { |
| 979 | - if ( is_protected_meta( $meta_key, $meta_type ) ) |
|
| 980 | - $auth_callback = '__return_false'; |
|
| 981 | - else |
|
| 982 | - $auth_callback = '__return_true'; |
|
| 1005 | + if ( is_protected_meta( $meta_key, $meta_type ) ) { |
|
| 1006 | + $auth_callback = '__return_false'; |
|
| 1007 | + } else { |
|
| 1008 | + $auth_callback = '__return_true'; |
|
| 1009 | + } |
|
| 983 | 1010 | } |
| 984 | 1011 | |
| 985 | - if ( is_callable( $auth_callback ) ) |
|
| 986 | - add_filter( "auth_{$meta_type}_meta_{$meta_key}", $auth_callback, 10, 6 ); |
|
| 987 | -} |
|
| 1012 | + if ( is_callable( $auth_callback ) ) { |
|
| 1013 | + add_filter( "auth_{$meta_type}_meta_{$meta_key}", $auth_callback, 10, 6 ); |
|
| 1014 | + } |
|
| 1015 | + } |
|
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Toolbar API: Top-level Toolbar functionality |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Toolbar |
|
| 7 | - * @since 3.1.0 |
|
| 8 | - */ |
|
| 3 | + * Toolbar API: Top-level Toolbar functionality |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Toolbar |
|
| 7 | + * @since 3.1.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Instantiate the admin bar object and set it up as a global for access elsewhere. |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | function _wp_admin_bar_init() { |
| 24 | 24 | global $wp_admin_bar; |
| 25 | 25 | |
| 26 | - if ( ! is_admin_bar_showing() ) |
|
| 26 | + if ( ! is_admin_bar_showing()) |
|
| 27 | 27 | return false; |
| 28 | 28 | |
| 29 | 29 | /* Load the admin bar class code ready for instantiation */ |
| 30 | - require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' ); |
|
| 30 | + require_once(ABSPATH.WPINC.'/class-wp-admin-bar.php'); |
|
| 31 | 31 | |
| 32 | 32 | /* Instantiate the admin bar */ |
| 33 | 33 | |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'. |
| 40 | 40 | */ |
| 41 | - $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); |
|
| 42 | - if ( class_exists( $admin_bar_class ) ) |
|
| 41 | + $admin_bar_class = apply_filters('wp_admin_bar_class', 'WP_Admin_Bar'); |
|
| 42 | + if (class_exists($admin_bar_class)) |
|
| 43 | 43 | $wp_admin_bar = new $admin_bar_class; |
| 44 | 44 | else |
| 45 | 45 | return false; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | function wp_admin_bar_render() { |
| 67 | 67 | global $wp_admin_bar; |
| 68 | 68 | |
| 69 | - if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) |
|
| 69 | + if ( ! is_admin_bar_showing() || ! is_object($wp_admin_bar)) |
|
| 70 | 70 | return; |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference |
| 80 | 80 | */ |
| 81 | - do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) ); |
|
| 81 | + do_action_ref_array('admin_bar_menu', array(&$wp_admin_bar)); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Fires before the admin bar is rendered. |
| 85 | 85 | * |
| 86 | 86 | * @since 3.1.0 |
| 87 | 87 | */ |
| 88 | - do_action( 'wp_before_admin_bar_render' ); |
|
| 88 | + do_action('wp_before_admin_bar_render'); |
|
| 89 | 89 | |
| 90 | 90 | $wp_admin_bar->render(); |
| 91 | 91 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @since 3.1.0 |
| 96 | 96 | */ |
| 97 | - do_action( 'wp_after_admin_bar_render' ); |
|
| 97 | + do_action('wp_after_admin_bar_render'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,54 +104,54 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @param WP_Admin_Bar $wp_admin_bar |
| 106 | 106 | */ |
| 107 | -function wp_admin_bar_wp_menu( $wp_admin_bar ) { |
|
| 108 | - $wp_admin_bar->add_menu( array( |
|
| 107 | +function wp_admin_bar_wp_menu($wp_admin_bar) { |
|
| 108 | + $wp_admin_bar->add_menu(array( |
|
| 109 | 109 | 'id' => 'wp-logo', |
| 110 | - 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>', |
|
| 111 | - 'href' => self_admin_url( 'about.php' ), |
|
| 112 | - ) ); |
|
| 110 | + 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">'.__('About WordPress').'</span>', |
|
| 111 | + 'href' => self_admin_url('about.php'), |
|
| 112 | + )); |
|
| 113 | 113 | |
| 114 | - if ( is_user_logged_in() ) { |
|
| 114 | + if (is_user_logged_in()) { |
|
| 115 | 115 | // Add "About WordPress" link |
| 116 | - $wp_admin_bar->add_menu( array( |
|
| 116 | + $wp_admin_bar->add_menu(array( |
|
| 117 | 117 | 'parent' => 'wp-logo', |
| 118 | 118 | 'id' => 'about', |
| 119 | 119 | 'title' => __('About WordPress'), |
| 120 | - 'href' => self_admin_url( 'about.php' ), |
|
| 121 | - ) ); |
|
| 120 | + 'href' => self_admin_url('about.php'), |
|
| 121 | + )); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Add WordPress.org link |
| 125 | - $wp_admin_bar->add_menu( array( |
|
| 125 | + $wp_admin_bar->add_menu(array( |
|
| 126 | 126 | 'parent' => 'wp-logo-external', |
| 127 | 127 | 'id' => 'wporg', |
| 128 | 128 | 'title' => __('WordPress.org'), |
| 129 | 129 | 'href' => __('https://wordpress.org/'), |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | |
| 132 | 132 | // Add codex link |
| 133 | - $wp_admin_bar->add_menu( array( |
|
| 133 | + $wp_admin_bar->add_menu(array( |
|
| 134 | 134 | 'parent' => 'wp-logo-external', |
| 135 | 135 | 'id' => 'documentation', |
| 136 | 136 | 'title' => __('Documentation'), |
| 137 | 137 | 'href' => __('https://codex.wordpress.org/'), |
| 138 | - ) ); |
|
| 138 | + )); |
|
| 139 | 139 | |
| 140 | 140 | // Add forums link |
| 141 | - $wp_admin_bar->add_menu( array( |
|
| 141 | + $wp_admin_bar->add_menu(array( |
|
| 142 | 142 | 'parent' => 'wp-logo-external', |
| 143 | 143 | 'id' => 'support-forums', |
| 144 | 144 | 'title' => __('Support Forums'), |
| 145 | 145 | 'href' => __('https://wordpress.org/support/'), |
| 146 | - ) ); |
|
| 146 | + )); |
|
| 147 | 147 | |
| 148 | 148 | // Add feedback link |
| 149 | - $wp_admin_bar->add_menu( array( |
|
| 149 | + $wp_admin_bar->add_menu(array( |
|
| 150 | 150 | 'parent' => 'wp-logo-external', |
| 151 | 151 | 'id' => 'feedback', |
| 152 | 152 | 'title' => __('Feedback'), |
| 153 | 153 | 'href' => __('https://wordpress.org/support/forum/requests-and-feedback'), |
| 154 | - ) ); |
|
| 154 | + )); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -161,13 +161,13 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @param WP_Admin_Bar $wp_admin_bar |
| 163 | 163 | */ |
| 164 | -function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) { |
|
| 165 | - if ( is_admin() ) { |
|
| 166 | - $wp_admin_bar->add_menu( array( |
|
| 164 | +function wp_admin_bar_sidebar_toggle($wp_admin_bar) { |
|
| 165 | + if (is_admin()) { |
|
| 166 | + $wp_admin_bar->add_menu(array( |
|
| 167 | 167 | 'id' => 'menu-toggle', |
| 168 | - 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>', |
|
| 168 | + 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">'.__('Menu').'</span>', |
|
| 169 | 169 | 'href' => '#', |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,34 +178,34 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @param WP_Admin_Bar $wp_admin_bar |
| 180 | 180 | */ |
| 181 | -function wp_admin_bar_my_account_item( $wp_admin_bar ) { |
|
| 181 | +function wp_admin_bar_my_account_item($wp_admin_bar) { |
|
| 182 | 182 | $user_id = get_current_user_id(); |
| 183 | 183 | $current_user = wp_get_current_user(); |
| 184 | 184 | |
| 185 | - if ( ! $user_id ) |
|
| 185 | + if ( ! $user_id) |
|
| 186 | 186 | return; |
| 187 | 187 | |
| 188 | - if ( current_user_can( 'read' ) ) { |
|
| 189 | - $profile_url = get_edit_profile_url( $user_id ); |
|
| 190 | - } elseif ( is_multisite() ) { |
|
| 191 | - $profile_url = get_dashboard_url( $user_id, 'profile.php' ); |
|
| 188 | + if (current_user_can('read')) { |
|
| 189 | + $profile_url = get_edit_profile_url($user_id); |
|
| 190 | + } elseif (is_multisite()) { |
|
| 191 | + $profile_url = get_dashboard_url($user_id, 'profile.php'); |
|
| 192 | 192 | } else { |
| 193 | 193 | $profile_url = false; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $avatar = get_avatar( $user_id, 26 ); |
|
| 197 | - $howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name ); |
|
| 198 | - $class = empty( $avatar ) ? '' : 'with-avatar'; |
|
| 196 | + $avatar = get_avatar($user_id, 26); |
|
| 197 | + $howdy = sprintf(__('Howdy, %1$s'), $current_user->display_name); |
|
| 198 | + $class = empty($avatar) ? '' : 'with-avatar'; |
|
| 199 | 199 | |
| 200 | - $wp_admin_bar->add_menu( array( |
|
| 200 | + $wp_admin_bar->add_menu(array( |
|
| 201 | 201 | 'id' => 'my-account', |
| 202 | 202 | 'parent' => 'top-secondary', |
| 203 | - 'title' => $howdy . $avatar, |
|
| 203 | + 'title' => $howdy.$avatar, |
|
| 204 | 204 | 'href' => $profile_url, |
| 205 | 205 | 'meta' => array( |
| 206 | 206 | 'class' => $class, |
| 207 | 207 | ), |
| 208 | - ) ); |
|
| 208 | + )); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -215,33 +215,33 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @param WP_Admin_Bar $wp_admin_bar |
| 217 | 217 | */ |
| 218 | -function wp_admin_bar_my_account_menu( $wp_admin_bar ) { |
|
| 218 | +function wp_admin_bar_my_account_menu($wp_admin_bar) { |
|
| 219 | 219 | $user_id = get_current_user_id(); |
| 220 | 220 | $current_user = wp_get_current_user(); |
| 221 | 221 | |
| 222 | - if ( ! $user_id ) |
|
| 222 | + if ( ! $user_id) |
|
| 223 | 223 | return; |
| 224 | 224 | |
| 225 | - if ( current_user_can( 'read' ) ) { |
|
| 226 | - $profile_url = get_edit_profile_url( $user_id ); |
|
| 227 | - } elseif ( is_multisite() ) { |
|
| 228 | - $profile_url = get_dashboard_url( $user_id, 'profile.php' ); |
|
| 225 | + if (current_user_can('read')) { |
|
| 226 | + $profile_url = get_edit_profile_url($user_id); |
|
| 227 | + } elseif (is_multisite()) { |
|
| 228 | + $profile_url = get_dashboard_url($user_id, 'profile.php'); |
|
| 229 | 229 | } else { |
| 230 | 230 | $profile_url = false; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $wp_admin_bar->add_group( array( |
|
| 233 | + $wp_admin_bar->add_group(array( |
|
| 234 | 234 | 'parent' => 'my-account', |
| 235 | 235 | 'id' => 'user-actions', |
| 236 | - ) ); |
|
| 236 | + )); |
|
| 237 | 237 | |
| 238 | - $user_info = get_avatar( $user_id, 64 ); |
|
| 238 | + $user_info = get_avatar($user_id, 64); |
|
| 239 | 239 | $user_info .= "<span class='display-name'>{$current_user->display_name}</span>"; |
| 240 | 240 | |
| 241 | - if ( $current_user->display_name !== $current_user->user_login ) |
|
| 241 | + if ($current_user->display_name !== $current_user->user_login) |
|
| 242 | 242 | $user_info .= "<span class='username'>{$current_user->user_login}</span>"; |
| 243 | 243 | |
| 244 | - $wp_admin_bar->add_menu( array( |
|
| 244 | + $wp_admin_bar->add_menu(array( |
|
| 245 | 245 | 'parent' => 'user-actions', |
| 246 | 246 | 'id' => 'user-info', |
| 247 | 247 | 'title' => $user_info, |
@@ -249,23 +249,23 @@ discard block |
||
| 249 | 249 | 'meta' => array( |
| 250 | 250 | 'tabindex' => -1, |
| 251 | 251 | ), |
| 252 | - ) ); |
|
| 252 | + )); |
|
| 253 | 253 | |
| 254 | - if ( false !== $profile_url ) { |
|
| 255 | - $wp_admin_bar->add_menu( array( |
|
| 254 | + if (false !== $profile_url) { |
|
| 255 | + $wp_admin_bar->add_menu(array( |
|
| 256 | 256 | 'parent' => 'user-actions', |
| 257 | 257 | 'id' => 'edit-profile', |
| 258 | - 'title' => __( 'Edit My Profile' ), |
|
| 258 | + 'title' => __('Edit My Profile'), |
|
| 259 | 259 | 'href' => $profile_url, |
| 260 | - ) ); |
|
| 260 | + )); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - $wp_admin_bar->add_menu( array( |
|
| 263 | + $wp_admin_bar->add_menu(array( |
|
| 264 | 264 | 'parent' => 'user-actions', |
| 265 | 265 | 'id' => 'logout', |
| 266 | - 'title' => __( 'Log Out' ), |
|
| 266 | + 'title' => __('Log Out'), |
|
| 267 | 267 | 'href' => wp_logout_url(), |
| 268 | - ) ); |
|
| 268 | + )); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -275,66 +275,66 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @param WP_Admin_Bar $wp_admin_bar |
| 277 | 277 | */ |
| 278 | -function wp_admin_bar_site_menu( $wp_admin_bar ) { |
|
| 278 | +function wp_admin_bar_site_menu($wp_admin_bar) { |
|
| 279 | 279 | // Don't show for logged out users. |
| 280 | - if ( ! is_user_logged_in() ) |
|
| 280 | + if ( ! is_user_logged_in()) |
|
| 281 | 281 | return; |
| 282 | 282 | |
| 283 | 283 | // Show only when the user is a member of this site, or they're a super admin. |
| 284 | - if ( ! is_user_member_of_blog() && ! is_super_admin() ) |
|
| 284 | + if ( ! is_user_member_of_blog() && ! is_super_admin()) |
|
| 285 | 285 | return; |
| 286 | 286 | |
| 287 | 287 | $blogname = get_bloginfo('name'); |
| 288 | 288 | |
| 289 | - if ( ! $blogname ) { |
|
| 290 | - $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); |
|
| 289 | + if ( ! $blogname) { |
|
| 290 | + $blogname = preg_replace('#^(https?://)?(www.)?#', '', get_home_url()); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if ( is_network_admin() ) { |
|
| 294 | - $blogname = sprintf( __('Network Admin: %s'), esc_html( get_current_site()->site_name ) ); |
|
| 295 | - } elseif ( is_user_admin() ) { |
|
| 296 | - $blogname = sprintf( __('User Dashboard: %s'), esc_html( get_current_site()->site_name ) ); |
|
| 293 | + if (is_network_admin()) { |
|
| 294 | + $blogname = sprintf(__('Network Admin: %s'), esc_html(get_current_site()->site_name)); |
|
| 295 | + } elseif (is_user_admin()) { |
|
| 296 | + $blogname = sprintf(__('User Dashboard: %s'), esc_html(get_current_site()->site_name)); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $title = wp_html_excerpt( $blogname, 40, '…' ); |
|
| 299 | + $title = wp_html_excerpt($blogname, 40, '…'); |
|
| 300 | 300 | |
| 301 | - $wp_admin_bar->add_menu( array( |
|
| 301 | + $wp_admin_bar->add_menu(array( |
|
| 302 | 302 | 'id' => 'site-name', |
| 303 | 303 | 'title' => $title, |
| 304 | - 'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(), |
|
| 305 | - ) ); |
|
| 304 | + 'href' => (is_admin() || ! current_user_can('read')) ? home_url('/') : admin_url(), |
|
| 305 | + )); |
|
| 306 | 306 | |
| 307 | 307 | // Create submenu items. |
| 308 | 308 | |
| 309 | - if ( is_admin() ) { |
|
| 309 | + if (is_admin()) { |
|
| 310 | 310 | // Add an option to visit the site. |
| 311 | - $wp_admin_bar->add_menu( array( |
|
| 311 | + $wp_admin_bar->add_menu(array( |
|
| 312 | 312 | 'parent' => 'site-name', |
| 313 | 313 | 'id' => 'view-site', |
| 314 | - 'title' => __( 'Visit Site' ), |
|
| 315 | - 'href' => home_url( '/' ), |
|
| 316 | - ) ); |
|
| 314 | + 'title' => __('Visit Site'), |
|
| 315 | + 'href' => home_url('/'), |
|
| 316 | + )); |
|
| 317 | 317 | |
| 318 | - if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) { |
|
| 319 | - $wp_admin_bar->add_menu( array( |
|
| 318 | + if (is_blog_admin() && is_multisite() && current_user_can('manage_sites')) { |
|
| 319 | + $wp_admin_bar->add_menu(array( |
|
| 320 | 320 | 'parent' => 'site-name', |
| 321 | 321 | 'id' => 'edit-site', |
| 322 | - 'title' => __( 'Edit Site' ), |
|
| 323 | - 'href' => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ), |
|
| 324 | - ) ); |
|
| 322 | + 'title' => __('Edit Site'), |
|
| 323 | + 'href' => network_admin_url('site-info.php?id='.get_current_blog_id()), |
|
| 324 | + )); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - } else if ( current_user_can( 'read' ) ) { |
|
| 327 | + } else if (current_user_can('read')) { |
|
| 328 | 328 | // We're on the front end, link to the Dashboard. |
| 329 | - $wp_admin_bar->add_menu( array( |
|
| 329 | + $wp_admin_bar->add_menu(array( |
|
| 330 | 330 | 'parent' => 'site-name', |
| 331 | 331 | 'id' => 'dashboard', |
| 332 | - 'title' => __( 'Dashboard' ), |
|
| 332 | + 'title' => __('Dashboard'), |
|
| 333 | 333 | 'href' => admin_url(), |
| 334 | - ) ); |
|
| 334 | + )); |
|
| 335 | 335 | |
| 336 | 336 | // Add the appearance submenu items. |
| 337 | - wp_admin_bar_appearance_menu( $wp_admin_bar ); |
|
| 337 | + wp_admin_bar_appearance_menu($wp_admin_bar); |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
@@ -345,24 +345,24 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. |
| 347 | 347 | */ |
| 348 | -function wp_admin_bar_customize_menu( $wp_admin_bar ) { |
|
| 348 | +function wp_admin_bar_customize_menu($wp_admin_bar) { |
|
| 349 | 349 | // Don't show for users who can't access the customizer or when in the admin. |
| 350 | - if ( ! current_user_can( 'customize' ) || is_admin() ) { |
|
| 350 | + if ( ! current_user_can('customize') || is_admin()) { |
|
| 351 | 351 | return; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 355 | - $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ); |
|
| 354 | + $current_url = (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
| 355 | + $customize_url = add_query_arg('url', urlencode($current_url), wp_customize_url()); |
|
| 356 | 356 | |
| 357 | - $wp_admin_bar->add_menu( array( |
|
| 357 | + $wp_admin_bar->add_menu(array( |
|
| 358 | 358 | 'id' => 'customize', |
| 359 | - 'title' => __( 'Customize' ), |
|
| 359 | + 'title' => __('Customize'), |
|
| 360 | 360 | 'href' => $customize_url, |
| 361 | 361 | 'meta' => array( |
| 362 | 362 | 'class' => 'hide-if-no-customize', |
| 363 | 363 | ), |
| 364 | - ) ); |
|
| 365 | - add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); |
|
| 364 | + )); |
|
| 365 | + add_action('wp_before_admin_bar_render', 'wp_customize_support_script'); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -372,138 +372,138 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @param WP_Admin_Bar $wp_admin_bar |
| 374 | 374 | */ |
| 375 | -function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { |
|
| 375 | +function wp_admin_bar_my_sites_menu($wp_admin_bar) { |
|
| 376 | 376 | // Don't show for logged out users or single site mode. |
| 377 | - if ( ! is_user_logged_in() || ! is_multisite() ) |
|
| 377 | + if ( ! is_user_logged_in() || ! is_multisite()) |
|
| 378 | 378 | return; |
| 379 | 379 | |
| 380 | 380 | // Show only when the user has at least one site, or they're a super admin. |
| 381 | - if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) |
|
| 381 | + if (count($wp_admin_bar->user->blogs) < 1 && ! is_super_admin()) |
|
| 382 | 382 | return; |
| 383 | 383 | |
| 384 | - if ( $wp_admin_bar->user->active_blog ) { |
|
| 385 | - $my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' ); |
|
| 384 | + if ($wp_admin_bar->user->active_blog) { |
|
| 385 | + $my_sites_url = get_admin_url($wp_admin_bar->user->active_blog->blog_id, 'my-sites.php'); |
|
| 386 | 386 | } else { |
| 387 | - $my_sites_url = admin_url( 'my-sites.php' ); |
|
| 387 | + $my_sites_url = admin_url('my-sites.php'); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - $wp_admin_bar->add_menu( array( |
|
| 390 | + $wp_admin_bar->add_menu(array( |
|
| 391 | 391 | 'id' => 'my-sites', |
| 392 | - 'title' => __( 'My Sites' ), |
|
| 392 | + 'title' => __('My Sites'), |
|
| 393 | 393 | 'href' => $my_sites_url, |
| 394 | - ) ); |
|
| 394 | + )); |
|
| 395 | 395 | |
| 396 | - if ( is_super_admin() ) { |
|
| 397 | - $wp_admin_bar->add_group( array( |
|
| 396 | + if (is_super_admin()) { |
|
| 397 | + $wp_admin_bar->add_group(array( |
|
| 398 | 398 | 'parent' => 'my-sites', |
| 399 | 399 | 'id' => 'my-sites-super-admin', |
| 400 | - ) ); |
|
| 400 | + )); |
|
| 401 | 401 | |
| 402 | - $wp_admin_bar->add_menu( array( |
|
| 402 | + $wp_admin_bar->add_menu(array( |
|
| 403 | 403 | 'parent' => 'my-sites-super-admin', |
| 404 | 404 | 'id' => 'network-admin', |
| 405 | 405 | 'title' => __('Network Admin'), |
| 406 | 406 | 'href' => network_admin_url(), |
| 407 | - ) ); |
|
| 407 | + )); |
|
| 408 | 408 | |
| 409 | - $wp_admin_bar->add_menu( array( |
|
| 409 | + $wp_admin_bar->add_menu(array( |
|
| 410 | 410 | 'parent' => 'network-admin', |
| 411 | 411 | 'id' => 'network-admin-d', |
| 412 | - 'title' => __( 'Dashboard' ), |
|
| 412 | + 'title' => __('Dashboard'), |
|
| 413 | 413 | 'href' => network_admin_url(), |
| 414 | - ) ); |
|
| 415 | - $wp_admin_bar->add_menu( array( |
|
| 414 | + )); |
|
| 415 | + $wp_admin_bar->add_menu(array( |
|
| 416 | 416 | 'parent' => 'network-admin', |
| 417 | 417 | 'id' => 'network-admin-s', |
| 418 | - 'title' => __( 'Sites' ), |
|
| 419 | - 'href' => network_admin_url( 'sites.php' ), |
|
| 420 | - ) ); |
|
| 421 | - $wp_admin_bar->add_menu( array( |
|
| 418 | + 'title' => __('Sites'), |
|
| 419 | + 'href' => network_admin_url('sites.php'), |
|
| 420 | + )); |
|
| 421 | + $wp_admin_bar->add_menu(array( |
|
| 422 | 422 | 'parent' => 'network-admin', |
| 423 | 423 | 'id' => 'network-admin-u', |
| 424 | - 'title' => __( 'Users' ), |
|
| 425 | - 'href' => network_admin_url( 'users.php' ), |
|
| 426 | - ) ); |
|
| 427 | - $wp_admin_bar->add_menu( array( |
|
| 424 | + 'title' => __('Users'), |
|
| 425 | + 'href' => network_admin_url('users.php'), |
|
| 426 | + )); |
|
| 427 | + $wp_admin_bar->add_menu(array( |
|
| 428 | 428 | 'parent' => 'network-admin', |
| 429 | 429 | 'id' => 'network-admin-t', |
| 430 | - 'title' => __( 'Themes' ), |
|
| 431 | - 'href' => network_admin_url( 'themes.php' ), |
|
| 432 | - ) ); |
|
| 433 | - $wp_admin_bar->add_menu( array( |
|
| 430 | + 'title' => __('Themes'), |
|
| 431 | + 'href' => network_admin_url('themes.php'), |
|
| 432 | + )); |
|
| 433 | + $wp_admin_bar->add_menu(array( |
|
| 434 | 434 | 'parent' => 'network-admin', |
| 435 | 435 | 'id' => 'network-admin-p', |
| 436 | - 'title' => __( 'Plugins' ), |
|
| 437 | - 'href' => network_admin_url( 'plugins.php' ), |
|
| 438 | - ) ); |
|
| 439 | - $wp_admin_bar->add_menu( array( |
|
| 436 | + 'title' => __('Plugins'), |
|
| 437 | + 'href' => network_admin_url('plugins.php'), |
|
| 438 | + )); |
|
| 439 | + $wp_admin_bar->add_menu(array( |
|
| 440 | 440 | 'parent' => 'network-admin', |
| 441 | 441 | 'id' => 'network-admin-o', |
| 442 | - 'title' => __( 'Settings' ), |
|
| 443 | - 'href' => network_admin_url( 'settings.php' ), |
|
| 444 | - ) ); |
|
| 442 | + 'title' => __('Settings'), |
|
| 443 | + 'href' => network_admin_url('settings.php'), |
|
| 444 | + )); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | // Add site links |
| 448 | - $wp_admin_bar->add_group( array( |
|
| 448 | + $wp_admin_bar->add_group(array( |
|
| 449 | 449 | 'parent' => 'my-sites', |
| 450 | 450 | 'id' => 'my-sites-list', |
| 451 | 451 | 'meta' => array( |
| 452 | 452 | 'class' => is_super_admin() ? 'ab-sub-secondary' : '', |
| 453 | 453 | ), |
| 454 | - ) ); |
|
| 454 | + )); |
|
| 455 | 455 | |
| 456 | - foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { |
|
| 457 | - switch_to_blog( $blog->userblog_id ); |
|
| 456 | + foreach ((array) $wp_admin_bar->user->blogs as $blog) { |
|
| 457 | + switch_to_blog($blog->userblog_id); |
|
| 458 | 458 | |
| 459 | 459 | $blavatar = '<div class="blavatar"></div>'; |
| 460 | 460 | |
| 461 | 461 | $blogname = $blog->blogname; |
| 462 | 462 | |
| 463 | - if ( ! $blogname ) { |
|
| 464 | - $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); |
|
| 463 | + if ( ! $blogname) { |
|
| 464 | + $blogname = preg_replace('#^(https?://)?(www.)?#', '', get_home_url()); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - $menu_id = 'blog-' . $blog->userblog_id; |
|
| 467 | + $menu_id = 'blog-'.$blog->userblog_id; |
|
| 468 | 468 | |
| 469 | - $wp_admin_bar->add_menu( array( |
|
| 469 | + $wp_admin_bar->add_menu(array( |
|
| 470 | 470 | 'parent' => 'my-sites-list', |
| 471 | 471 | 'id' => $menu_id, |
| 472 | - 'title' => $blavatar . $blogname, |
|
| 472 | + 'title' => $blavatar.$blogname, |
|
| 473 | 473 | 'href' => admin_url(), |
| 474 | - ) ); |
|
| 474 | + )); |
|
| 475 | 475 | |
| 476 | - $wp_admin_bar->add_menu( array( |
|
| 476 | + $wp_admin_bar->add_menu(array( |
|
| 477 | 477 | 'parent' => $menu_id, |
| 478 | - 'id' => $menu_id . '-d', |
|
| 479 | - 'title' => __( 'Dashboard' ), |
|
| 478 | + 'id' => $menu_id.'-d', |
|
| 479 | + 'title' => __('Dashboard'), |
|
| 480 | 480 | 'href' => admin_url(), |
| 481 | - ) ); |
|
| 481 | + )); |
|
| 482 | 482 | |
| 483 | - if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
|
| 484 | - $wp_admin_bar->add_menu( array( |
|
| 483 | + if (current_user_can(get_post_type_object('post')->cap->create_posts)) { |
|
| 484 | + $wp_admin_bar->add_menu(array( |
|
| 485 | 485 | 'parent' => $menu_id, |
| 486 | - 'id' => $menu_id . '-n', |
|
| 487 | - 'title' => __( 'New Post' ), |
|
| 488 | - 'href' => admin_url( 'post-new.php' ), |
|
| 489 | - ) ); |
|
| 486 | + 'id' => $menu_id.'-n', |
|
| 487 | + 'title' => __('New Post'), |
|
| 488 | + 'href' => admin_url('post-new.php'), |
|
| 489 | + )); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - if ( current_user_can( 'edit_posts' ) ) { |
|
| 493 | - $wp_admin_bar->add_menu( array( |
|
| 492 | + if (current_user_can('edit_posts')) { |
|
| 493 | + $wp_admin_bar->add_menu(array( |
|
| 494 | 494 | 'parent' => $menu_id, |
| 495 | - 'id' => $menu_id . '-c', |
|
| 496 | - 'title' => __( 'Manage Comments' ), |
|
| 497 | - 'href' => admin_url( 'edit-comments.php' ), |
|
| 498 | - ) ); |
|
| 495 | + 'id' => $menu_id.'-c', |
|
| 496 | + 'title' => __('Manage Comments'), |
|
| 497 | + 'href' => admin_url('edit-comments.php'), |
|
| 498 | + )); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - $wp_admin_bar->add_menu( array( |
|
| 501 | + $wp_admin_bar->add_menu(array( |
|
| 502 | 502 | 'parent' => $menu_id, |
| 503 | - 'id' => $menu_id . '-v', |
|
| 504 | - 'title' => __( 'Visit Site' ), |
|
| 505 | - 'href' => home_url( '/' ), |
|
| 506 | - ) ); |
|
| 503 | + 'id' => $menu_id.'-v', |
|
| 504 | + 'title' => __('Visit Site'), |
|
| 505 | + 'href' => home_url('/'), |
|
| 506 | + )); |
|
| 507 | 507 | |
| 508 | 508 | restore_current_blog(); |
| 509 | 509 | } |
@@ -516,21 +516,21 @@ discard block |
||
| 516 | 516 | * |
| 517 | 517 | * @param WP_Admin_Bar $wp_admin_bar |
| 518 | 518 | */ |
| 519 | -function wp_admin_bar_shortlink_menu( $wp_admin_bar ) { |
|
| 520 | - $short = wp_get_shortlink( 0, 'query' ); |
|
| 519 | +function wp_admin_bar_shortlink_menu($wp_admin_bar) { |
|
| 520 | + $short = wp_get_shortlink(0, 'query'); |
|
| 521 | 521 | $id = 'get-shortlink'; |
| 522 | 522 | |
| 523 | - if ( empty( $short ) ) |
|
| 523 | + if (empty($short)) |
|
| 524 | 524 | return; |
| 525 | 525 | |
| 526 | - $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />'; |
|
| 526 | + $html = '<input class="shortlink-input" type="text" readonly="readonly" value="'.esc_attr($short).'" />'; |
|
| 527 | 527 | |
| 528 | - $wp_admin_bar->add_menu( array( |
|
| 528 | + $wp_admin_bar->add_menu(array( |
|
| 529 | 529 | 'id' => $id, |
| 530 | - 'title' => __( 'Shortlink' ), |
|
| 530 | + 'title' => __('Shortlink'), |
|
| 531 | 531 | 'href' => $short, |
| 532 | - 'meta' => array( 'html' => $html ), |
|
| 533 | - ) ); |
|
| 532 | + 'meta' => array('html' => $html), |
|
| 533 | + )); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
@@ -543,73 +543,73 @@ discard block |
||
| 543 | 543 | * |
| 544 | 544 | * @param WP_Admin_Bar $wp_admin_bar |
| 545 | 545 | */ |
| 546 | -function wp_admin_bar_edit_menu( $wp_admin_bar ) { |
|
| 546 | +function wp_admin_bar_edit_menu($wp_admin_bar) { |
|
| 547 | 547 | global $tag, $wp_the_query; |
| 548 | 548 | |
| 549 | - if ( is_admin() ) { |
|
| 549 | + if (is_admin()) { |
|
| 550 | 550 | $current_screen = get_current_screen(); |
| 551 | 551 | $post = get_post(); |
| 552 | 552 | |
| 553 | - if ( 'post' == $current_screen->base |
|
| 553 | + if ('post' == $current_screen->base |
|
| 554 | 554 | && 'add' != $current_screen->action |
| 555 | - && ( $post_type_object = get_post_type_object( $post->post_type ) ) |
|
| 556 | - && current_user_can( 'read_post', $post->ID ) |
|
| 557 | - && ( $post_type_object->public ) |
|
| 558 | - && ( $post_type_object->show_in_admin_bar ) ) |
|
| 555 | + && ($post_type_object = get_post_type_object($post->post_type)) |
|
| 556 | + && current_user_can('read_post', $post->ID) |
|
| 557 | + && ($post_type_object->public) |
|
| 558 | + && ($post_type_object->show_in_admin_bar)) |
|
| 559 | 559 | { |
| 560 | - if ( 'draft' == $post->post_status ) { |
|
| 561 | - $preview_link = get_preview_post_link( $post ); |
|
| 562 | - $wp_admin_bar->add_menu( array( |
|
| 560 | + if ('draft' == $post->post_status) { |
|
| 561 | + $preview_link = get_preview_post_link($post); |
|
| 562 | + $wp_admin_bar->add_menu(array( |
|
| 563 | 563 | 'id' => 'preview', |
| 564 | 564 | 'title' => $post_type_object->labels->view_item, |
| 565 | - 'href' => esc_url( $preview_link ), |
|
| 566 | - 'meta' => array( 'target' => 'wp-preview-' . $post->ID ), |
|
| 567 | - ) ); |
|
| 565 | + 'href' => esc_url($preview_link), |
|
| 566 | + 'meta' => array('target' => 'wp-preview-'.$post->ID), |
|
| 567 | + )); |
|
| 568 | 568 | } else { |
| 569 | - $wp_admin_bar->add_menu( array( |
|
| 569 | + $wp_admin_bar->add_menu(array( |
|
| 570 | 570 | 'id' => 'view', |
| 571 | 571 | 'title' => $post_type_object->labels->view_item, |
| 572 | - 'href' => get_permalink( $post->ID ) |
|
| 573 | - ) ); |
|
| 572 | + 'href' => get_permalink($post->ID) |
|
| 573 | + )); |
|
| 574 | 574 | } |
| 575 | - } elseif ( 'term' == $current_screen->base |
|
| 576 | - && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) |
|
| 577 | - && ( $tax = get_taxonomy( $tag->taxonomy ) ) |
|
| 578 | - && $tax->public ) |
|
| 575 | + } elseif ('term' == $current_screen->base |
|
| 576 | + && isset($tag) && is_object($tag) && ! is_wp_error($tag) |
|
| 577 | + && ($tax = get_taxonomy($tag->taxonomy)) |
|
| 578 | + && $tax->public) |
|
| 579 | 579 | { |
| 580 | - $wp_admin_bar->add_menu( array( |
|
| 580 | + $wp_admin_bar->add_menu(array( |
|
| 581 | 581 | 'id' => 'view', |
| 582 | 582 | 'title' => $tax->labels->view_item, |
| 583 | - 'href' => get_term_link( $tag ) |
|
| 584 | - ) ); |
|
| 583 | + 'href' => get_term_link($tag) |
|
| 584 | + )); |
|
| 585 | 585 | } |
| 586 | 586 | } else { |
| 587 | 587 | $current_object = $wp_the_query->get_queried_object(); |
| 588 | 588 | |
| 589 | - if ( empty( $current_object ) ) |
|
| 589 | + if (empty($current_object)) |
|
| 590 | 590 | return; |
| 591 | 591 | |
| 592 | - if ( ! empty( $current_object->post_type ) |
|
| 593 | - && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) |
|
| 594 | - && current_user_can( 'edit_post', $current_object->ID ) |
|
| 592 | + if ( ! empty($current_object->post_type) |
|
| 593 | + && ($post_type_object = get_post_type_object($current_object->post_type)) |
|
| 594 | + && current_user_can('edit_post', $current_object->ID) |
|
| 595 | 595 | && $post_type_object->show_in_admin_bar |
| 596 | - && $edit_post_link = get_edit_post_link( $current_object->ID ) ) |
|
| 596 | + && $edit_post_link = get_edit_post_link($current_object->ID)) |
|
| 597 | 597 | { |
| 598 | - $wp_admin_bar->add_menu( array( |
|
| 598 | + $wp_admin_bar->add_menu(array( |
|
| 599 | 599 | 'id' => 'edit', |
| 600 | 600 | 'title' => $post_type_object->labels->edit_item, |
| 601 | 601 | 'href' => $edit_post_link |
| 602 | - ) ); |
|
| 603 | - } elseif ( ! empty( $current_object->taxonomy ) |
|
| 604 | - && ( $tax = get_taxonomy( $current_object->taxonomy ) ) |
|
| 605 | - && current_user_can( $tax->cap->edit_terms ) |
|
| 606 | - && $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) |
|
| 602 | + )); |
|
| 603 | + } elseif ( ! empty($current_object->taxonomy) |
|
| 604 | + && ($tax = get_taxonomy($current_object->taxonomy)) |
|
| 605 | + && current_user_can($tax->cap->edit_terms) |
|
| 606 | + && $edit_term_link = get_edit_term_link($current_object->term_id, $current_object->taxonomy)) |
|
| 607 | 607 | { |
| 608 | - $wp_admin_bar->add_menu( array( |
|
| 608 | + $wp_admin_bar->add_menu(array( |
|
| 609 | 609 | 'id' => 'edit', |
| 610 | 610 | 'title' => $tax->labels->edit_item, |
| 611 | 611 | 'href' => $edit_term_link |
| 612 | - ) ); |
|
| 612 | + )); |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | } |
@@ -621,60 +621,60 @@ discard block |
||
| 621 | 621 | * |
| 622 | 622 | * @param WP_Admin_Bar $wp_admin_bar |
| 623 | 623 | */ |
| 624 | -function wp_admin_bar_new_content_menu( $wp_admin_bar ) { |
|
| 624 | +function wp_admin_bar_new_content_menu($wp_admin_bar) { |
|
| 625 | 625 | $actions = array(); |
| 626 | 626 | |
| 627 | - $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); |
|
| 627 | + $cpts = (array) get_post_types(array('show_in_admin_bar' => true), 'objects'); |
|
| 628 | 628 | |
| 629 | - if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) |
|
| 630 | - $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); |
|
| 629 | + if (isset($cpts['post']) && current_user_can($cpts['post']->cap->create_posts)) |
|
| 630 | + $actions['post-new.php'] = array($cpts['post']->labels->name_admin_bar, 'new-post'); |
|
| 631 | 631 | |
| 632 | - if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) |
|
| 633 | - $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' ); |
|
| 632 | + if (isset($cpts['attachment']) && current_user_can('upload_files')) |
|
| 633 | + $actions['media-new.php'] = array($cpts['attachment']->labels->name_admin_bar, 'new-media'); |
|
| 634 | 634 | |
| 635 | - if ( current_user_can( 'manage_links' ) ) |
|
| 636 | - $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); |
|
| 635 | + if (current_user_can('manage_links')) |
|
| 636 | + $actions['link-add.php'] = array(_x('Link', 'add new from admin bar'), 'new-link'); |
|
| 637 | 637 | |
| 638 | - if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) |
|
| 639 | - $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); |
|
| 638 | + if (isset($cpts['page']) && current_user_can($cpts['page']->cap->create_posts)) |
|
| 639 | + $actions['post-new.php?post_type=page'] = array($cpts['page']->labels->name_admin_bar, 'new-page'); |
|
| 640 | 640 | |
| 641 | - unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); |
|
| 641 | + unset($cpts['post'], $cpts['page'], $cpts['attachment']); |
|
| 642 | 642 | |
| 643 | 643 | // Add any additional custom post types. |
| 644 | - foreach ( $cpts as $cpt ) { |
|
| 645 | - if ( ! current_user_can( $cpt->cap->create_posts ) ) |
|
| 644 | + foreach ($cpts as $cpt) { |
|
| 645 | + if ( ! current_user_can($cpt->cap->create_posts)) |
|
| 646 | 646 | continue; |
| 647 | 647 | |
| 648 | - $key = 'post-new.php?post_type=' . $cpt->name; |
|
| 649 | - $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); |
|
| 648 | + $key = 'post-new.php?post_type='.$cpt->name; |
|
| 649 | + $actions[$key] = array($cpt->labels->name_admin_bar, 'new-'.$cpt->name); |
|
| 650 | 650 | } |
| 651 | 651 | // Avoid clash with parent node and a 'content' post type. |
| 652 | - if ( isset( $actions['post-new.php?post_type=content'] ) ) |
|
| 652 | + if (isset($actions['post-new.php?post_type=content'])) |
|
| 653 | 653 | $actions['post-new.php?post_type=content'][1] = 'add-new-content'; |
| 654 | 654 | |
| 655 | - if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) |
|
| 656 | - $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); |
|
| 655 | + if (current_user_can('create_users') || current_user_can('promote_users')) |
|
| 656 | + $actions['user-new.php'] = array(_x('User', 'add new from admin bar'), 'new-user'); |
|
| 657 | 657 | |
| 658 | - if ( ! $actions ) |
|
| 658 | + if ( ! $actions) |
|
| 659 | 659 | return; |
| 660 | 660 | |
| 661 | - $title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>'; |
|
| 661 | + $title = '<span class="ab-icon"></span><span class="ab-label">'._x('New', 'admin bar menu group label').'</span>'; |
|
| 662 | 662 | |
| 663 | - $wp_admin_bar->add_menu( array( |
|
| 663 | + $wp_admin_bar->add_menu(array( |
|
| 664 | 664 | 'id' => 'new-content', |
| 665 | 665 | 'title' => $title, |
| 666 | - 'href' => admin_url( current( array_keys( $actions ) ) ), |
|
| 667 | - ) ); |
|
| 666 | + 'href' => admin_url(current(array_keys($actions))), |
|
| 667 | + )); |
|
| 668 | 668 | |
| 669 | - foreach ( $actions as $link => $action ) { |
|
| 670 | - list( $title, $id ) = $action; |
|
| 669 | + foreach ($actions as $link => $action) { |
|
| 670 | + list($title, $id) = $action; |
|
| 671 | 671 | |
| 672 | - $wp_admin_bar->add_menu( array( |
|
| 672 | + $wp_admin_bar->add_menu(array( |
|
| 673 | 673 | 'parent' => 'new-content', |
| 674 | 674 | 'id' => $id, |
| 675 | 675 | 'title' => $title, |
| 676 | - 'href' => admin_url( $link ) |
|
| 677 | - ) ); |
|
| 676 | + 'href' => admin_url($link) |
|
| 677 | + )); |
|
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | |
@@ -685,23 +685,23 @@ discard block |
||
| 685 | 685 | * |
| 686 | 686 | * @param WP_Admin_Bar $wp_admin_bar |
| 687 | 687 | */ |
| 688 | -function wp_admin_bar_comments_menu( $wp_admin_bar ) { |
|
| 689 | - if ( !current_user_can('edit_posts') ) |
|
| 688 | +function wp_admin_bar_comments_menu($wp_admin_bar) { |
|
| 689 | + if ( ! current_user_can('edit_posts')) |
|
| 690 | 690 | return; |
| 691 | 691 | |
| 692 | 692 | $awaiting_mod = wp_count_comments(); |
| 693 | 693 | $awaiting_mod = $awaiting_mod->moderated; |
| 694 | - $awaiting_text = sprintf( _n( '%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod ), number_format_i18n( $awaiting_mod ) ); |
|
| 694 | + $awaiting_text = sprintf(_n('%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod), number_format_i18n($awaiting_mod)); |
|
| 695 | 695 | |
| 696 | 696 | $icon = '<span class="ab-icon"></span>'; |
| 697 | - $title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>'; |
|
| 698 | - $title .= '<span class="screen-reader-text">' . $awaiting_text . '</span>'; |
|
| 697 | + $title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-'.$awaiting_mod.'" aria-hidden="true">'.number_format_i18n($awaiting_mod).'</span>'; |
|
| 698 | + $title .= '<span class="screen-reader-text">'.$awaiting_text.'</span>'; |
|
| 699 | 699 | |
| 700 | - $wp_admin_bar->add_menu( array( |
|
| 700 | + $wp_admin_bar->add_menu(array( |
|
| 701 | 701 | 'id' => 'comments', |
| 702 | - 'title' => $icon . $title, |
|
| 702 | + 'title' => $icon.$title, |
|
| 703 | 703 | 'href' => admin_url('edit-comments.php'), |
| 704 | - ) ); |
|
| 704 | + )); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -711,56 +711,56 @@ discard block |
||
| 711 | 711 | * |
| 712 | 712 | * @param WP_Admin_Bar $wp_admin_bar |
| 713 | 713 | */ |
| 714 | -function wp_admin_bar_appearance_menu( $wp_admin_bar ) { |
|
| 715 | - $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) ); |
|
| 714 | +function wp_admin_bar_appearance_menu($wp_admin_bar) { |
|
| 715 | + $wp_admin_bar->add_group(array('parent' => 'site-name', 'id' => 'appearance')); |
|
| 716 | 716 | |
| 717 | - if ( current_user_can( 'switch_themes' ) ) { |
|
| 718 | - $wp_admin_bar->add_menu( array( |
|
| 717 | + if (current_user_can('switch_themes')) { |
|
| 718 | + $wp_admin_bar->add_menu(array( |
|
| 719 | 719 | 'parent' => 'appearance', |
| 720 | 720 | 'id' => 'themes', |
| 721 | - 'title' => __( 'Themes' ), |
|
| 722 | - 'href' => admin_url( 'themes.php' ), |
|
| 723 | - ) ); |
|
| 721 | + 'title' => __('Themes'), |
|
| 722 | + 'href' => admin_url('themes.php'), |
|
| 723 | + )); |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
| 726 | + if ( ! current_user_can('edit_theme_options')) { |
|
| 727 | 727 | return; |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - if ( current_theme_supports( 'widgets' ) ) { |
|
| 731 | - $wp_admin_bar->add_menu( array( |
|
| 730 | + if (current_theme_supports('widgets')) { |
|
| 731 | + $wp_admin_bar->add_menu(array( |
|
| 732 | 732 | 'parent' => 'appearance', |
| 733 | 733 | 'id' => 'widgets', |
| 734 | - 'title' => __( 'Widgets' ), |
|
| 735 | - 'href' => admin_url( 'widgets.php' ), |
|
| 736 | - ) ); |
|
| 734 | + 'title' => __('Widgets'), |
|
| 735 | + 'href' => admin_url('widgets.php'), |
|
| 736 | + )); |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | - if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) |
|
| 740 | - $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); |
|
| 739 | + if (current_theme_supports('menus') || current_theme_supports('widgets')) |
|
| 740 | + $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php'))); |
|
| 741 | 741 | |
| 742 | - if ( current_theme_supports( 'custom-background' ) ) { |
|
| 743 | - $wp_admin_bar->add_menu( array( |
|
| 742 | + if (current_theme_supports('custom-background')) { |
|
| 743 | + $wp_admin_bar->add_menu(array( |
|
| 744 | 744 | 'parent' => 'appearance', |
| 745 | 745 | 'id' => 'background', |
| 746 | - 'title' => __( 'Background' ), |
|
| 747 | - 'href' => admin_url( 'themes.php?page=custom-background' ), |
|
| 746 | + 'title' => __('Background'), |
|
| 747 | + 'href' => admin_url('themes.php?page=custom-background'), |
|
| 748 | 748 | 'meta' => array( |
| 749 | 749 | 'class' => 'hide-if-customize', |
| 750 | 750 | ), |
| 751 | - ) ); |
|
| 751 | + )); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if ( current_theme_supports( 'custom-header' ) ) { |
|
| 755 | - $wp_admin_bar->add_menu( array( |
|
| 754 | + if (current_theme_supports('custom-header')) { |
|
| 755 | + $wp_admin_bar->add_menu(array( |
|
| 756 | 756 | 'parent' => 'appearance', |
| 757 | 757 | 'id' => 'header', |
| 758 | - 'title' => __( 'Header' ), |
|
| 759 | - 'href' => admin_url( 'themes.php?page=custom-header' ), |
|
| 758 | + 'title' => __('Header'), |
|
| 759 | + 'href' => admin_url('themes.php?page=custom-header'), |
|
| 760 | 760 | 'meta' => array( |
| 761 | 761 | 'class' => 'hide-if-customize', |
| 762 | 762 | ), |
| 763 | - ) ); |
|
| 763 | + )); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | } |
@@ -772,24 +772,24 @@ discard block |
||
| 772 | 772 | * |
| 773 | 773 | * @param WP_Admin_Bar $wp_admin_bar |
| 774 | 774 | */ |
| 775 | -function wp_admin_bar_updates_menu( $wp_admin_bar ) { |
|
| 775 | +function wp_admin_bar_updates_menu($wp_admin_bar) { |
|
| 776 | 776 | |
| 777 | 777 | $update_data = wp_get_update_data(); |
| 778 | 778 | |
| 779 | - if ( !$update_data['counts']['total'] ) |
|
| 779 | + if ( ! $update_data['counts']['total']) |
|
| 780 | 780 | return; |
| 781 | 781 | |
| 782 | - $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; |
|
| 783 | - $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; |
|
| 782 | + $title = '<span class="ab-icon"></span><span class="ab-label">'.number_format_i18n($update_data['counts']['total']).'</span>'; |
|
| 783 | + $title .= '<span class="screen-reader-text">'.$update_data['title'].'</span>'; |
|
| 784 | 784 | |
| 785 | - $wp_admin_bar->add_menu( array( |
|
| 785 | + $wp_admin_bar->add_menu(array( |
|
| 786 | 786 | 'id' => 'updates', |
| 787 | 787 | 'title' => $title, |
| 788 | - 'href' => network_admin_url( 'update-core.php' ), |
|
| 788 | + 'href' => network_admin_url('update-core.php'), |
|
| 789 | 789 | 'meta' => array( |
| 790 | 790 | 'title' => $update_data['title'], |
| 791 | 791 | ), |
| 792 | - ) ); |
|
| 792 | + )); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
@@ -799,17 +799,17 @@ discard block |
||
| 799 | 799 | * |
| 800 | 800 | * @param WP_Admin_Bar $wp_admin_bar |
| 801 | 801 | */ |
| 802 | -function wp_admin_bar_search_menu( $wp_admin_bar ) { |
|
| 803 | - if ( is_admin() ) |
|
| 802 | +function wp_admin_bar_search_menu($wp_admin_bar) { |
|
| 803 | + if (is_admin()) |
|
| 804 | 804 | return; |
| 805 | 805 | |
| 806 | - $form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">'; |
|
| 806 | + $form = '<form action="'.esc_url(home_url('/')).'" method="get" id="adminbarsearch">'; |
|
| 807 | 807 | $form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />'; |
| 808 | - $form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>'; |
|
| 809 | - $form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>'; |
|
| 808 | + $form .= '<label for="adminbar-search" class="screen-reader-text">'.__('Search').'</label>'; |
|
| 809 | + $form .= '<input type="submit" class="adminbar-button" value="'.__('Search').'"/>'; |
|
| 810 | 810 | $form .= '</form>'; |
| 811 | 811 | |
| 812 | - $wp_admin_bar->add_menu( array( |
|
| 812 | + $wp_admin_bar->add_menu(array( |
|
| 813 | 813 | 'parent' => 'top-secondary', |
| 814 | 814 | 'id' => 'search', |
| 815 | 815 | 'title' => $form, |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | 'class' => 'admin-bar-search', |
| 818 | 818 | 'tabindex' => -1, |
| 819 | 819 | ) |
| 820 | - ) ); |
|
| 820 | + )); |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | /** |
@@ -827,21 +827,21 @@ discard block |
||
| 827 | 827 | * |
| 828 | 828 | * @param WP_Admin_Bar $wp_admin_bar |
| 829 | 829 | */ |
| 830 | -function wp_admin_bar_add_secondary_groups( $wp_admin_bar ) { |
|
| 831 | - $wp_admin_bar->add_group( array( |
|
| 830 | +function wp_admin_bar_add_secondary_groups($wp_admin_bar) { |
|
| 831 | + $wp_admin_bar->add_group(array( |
|
| 832 | 832 | 'id' => 'top-secondary', |
| 833 | 833 | 'meta' => array( |
| 834 | 834 | 'class' => 'ab-top-secondary', |
| 835 | 835 | ), |
| 836 | - ) ); |
|
| 836 | + )); |
|
| 837 | 837 | |
| 838 | - $wp_admin_bar->add_group( array( |
|
| 838 | + $wp_admin_bar->add_group(array( |
|
| 839 | 839 | 'parent' => 'wp-logo', |
| 840 | 840 | 'id' => 'wp-logo-external', |
| 841 | 841 | 'meta' => array( |
| 842 | 842 | 'class' => 'ab-sub-secondary', |
| 843 | 843 | ), |
| 844 | - ) ); |
|
| 844 | + )); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | /** |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @param bool $show Whether to allow the admin bar to show. |
| 884 | 884 | */ |
| 885 | -function show_admin_bar( $show ) { |
|
| 885 | +function show_admin_bar($show) { |
|
| 886 | 886 | global $show_admin_bar; |
| 887 | 887 | $show_admin_bar = (bool) $show; |
| 888 | 888 | } |
@@ -901,19 +901,19 @@ discard block |
||
| 901 | 901 | global $show_admin_bar, $pagenow; |
| 902 | 902 | |
| 903 | 903 | // For all these types of requests, we never want an admin bar. |
| 904 | - if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') ) |
|
| 904 | + if (defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST')) |
|
| 905 | 905 | return false; |
| 906 | 906 | |
| 907 | - if ( is_embed() ) { |
|
| 907 | + if (is_embed()) { |
|
| 908 | 908 | return false; |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | // Integrated into the admin. |
| 912 | - if ( is_admin() ) |
|
| 912 | + if (is_admin()) |
|
| 913 | 913 | return true; |
| 914 | 914 | |
| 915 | - if ( ! isset( $show_admin_bar ) ) { |
|
| 916 | - if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) { |
|
| 915 | + if ( ! isset($show_admin_bar)) { |
|
| 916 | + if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow) { |
|
| 917 | 917 | $show_admin_bar = false; |
| 918 | 918 | } else { |
| 919 | 919 | $show_admin_bar = _get_admin_bar_pref(); |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | * |
| 931 | 931 | * @param bool $show_admin_bar Whether the admin bar should be shown. Default false. |
| 932 | 932 | */ |
| 933 | - $show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar ); |
|
| 933 | + $show_admin_bar = apply_filters('show_admin_bar', $show_admin_bar); |
|
| 934 | 934 | |
| 935 | 935 | return $show_admin_bar; |
| 936 | 936 | } |
@@ -946,9 +946,9 @@ discard block |
||
| 946 | 946 | * @param int $user Optional. ID of the user to check, defaults to 0 for current user. |
| 947 | 947 | * @return bool Whether the admin bar should be showing for this user. |
| 948 | 948 | */ |
| 949 | -function _get_admin_bar_pref( $context = 'front', $user = 0 ) { |
|
| 950 | - $pref = get_user_option( "show_admin_bar_{$context}", $user ); |
|
| 951 | - if ( false === $pref ) |
|
| 949 | +function _get_admin_bar_pref($context = 'front', $user = 0) { |
|
| 950 | + $pref = get_user_option("show_admin_bar_{$context}", $user); |
|
| 951 | + if (false === $pref) |
|
| 952 | 952 | return true; |
| 953 | 953 | |
| 954 | 954 | return 'true' === $pref; |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | * @param array $templates An optional list of template candidates |
| 21 | 21 | * @return string Full path to template file. |
| 22 | 22 | */ |
| 23 | -function get_query_template( $type, $templates = array() ) { |
|
| 24 | - $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); |
|
| 23 | +function get_query_template($type, $templates = array()) { |
|
| 24 | + $type = preg_replace('|[^a-z0-9-]+|', '', $type); |
|
| 25 | 25 | |
| 26 | - if ( empty( $templates ) ) |
|
| 26 | + if (empty($templates)) |
|
| 27 | 27 | $templates = array("{$type}.php"); |
| 28 | 28 | |
| 29 | - $template = locate_template( $templates ); |
|
| 29 | + $template = locate_template($templates); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Filter the path of the queried template by type. |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @param string $template Path to the template. See locate_template(). |
| 44 | 44 | */ |
| 45 | - return apply_filters( "{$type}_template", $template ); |
|
| 45 | + return apply_filters("{$type}_template", $template); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -90,17 +90,17 @@ discard block |
||
| 90 | 90 | * @return string Full path to archive template file. |
| 91 | 91 | */ |
| 92 | 92 | function get_archive_template() { |
| 93 | - $post_types = array_filter( (array) get_query_var( 'post_type' ) ); |
|
| 93 | + $post_types = array_filter((array) get_query_var('post_type')); |
|
| 94 | 94 | |
| 95 | 95 | $templates = array(); |
| 96 | 96 | |
| 97 | - if ( count( $post_types ) == 1 ) { |
|
| 98 | - $post_type = reset( $post_types ); |
|
| 97 | + if (count($post_types) == 1) { |
|
| 98 | + $post_type = reset($post_types); |
|
| 99 | 99 | $templates[] = "archive-{$post_type}.php"; |
| 100 | 100 | } |
| 101 | 101 | $templates[] = 'archive.php'; |
| 102 | 102 | |
| 103 | - return get_query_template( 'archive', $templates ); |
|
| 103 | + return get_query_template('archive', $templates); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | * @return string Full path to archive template file. |
| 117 | 117 | */ |
| 118 | 118 | function get_post_type_archive_template() { |
| 119 | - $post_type = get_query_var( 'post_type' ); |
|
| 120 | - if ( is_array( $post_type ) ) |
|
| 121 | - $post_type = reset( $post_type ); |
|
| 119 | + $post_type = get_query_var('post_type'); |
|
| 120 | + if (is_array($post_type)) |
|
| 121 | + $post_type = reset($post_type); |
|
| 122 | 122 | |
| 123 | - $obj = get_post_type_object( $post_type ); |
|
| 124 | - if ( ! $obj->has_archive ) |
|
| 123 | + $obj = get_post_type_object($post_type); |
|
| 124 | + if ( ! $obj->has_archive) |
|
| 125 | 125 | return ''; |
| 126 | 126 | |
| 127 | 127 | return get_archive_template(); |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $templates = array(); |
| 146 | 146 | |
| 147 | - if ( $author instanceof WP_User ) { |
|
| 147 | + if ($author instanceof WP_User) { |
|
| 148 | 148 | $templates[] = "author-{$author->user_nicename}.php"; |
| 149 | 149 | $templates[] = "author-{$author->ID}.php"; |
| 150 | 150 | } |
| 151 | 151 | $templates[] = 'author.php'; |
| 152 | 152 | |
| 153 | - return get_query_template( 'author', $templates ); |
|
| 153 | + return get_query_template('author', $templates); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $templates = array(); |
| 176 | 176 | |
| 177 | - if ( ! empty( $category->slug ) ) { |
|
| 177 | + if ( ! empty($category->slug)) { |
|
| 178 | 178 | $templates[] = "category-{$category->slug}.php"; |
| 179 | 179 | $templates[] = "category-{$category->term_id}.php"; |
| 180 | 180 | } |
| 181 | 181 | $templates[] = 'category.php'; |
| 182 | 182 | |
| 183 | - return get_query_template( 'category', $templates ); |
|
| 183 | + return get_query_template('category', $templates); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $templates = array(); |
| 206 | 206 | |
| 207 | - if ( ! empty( $tag->slug ) ) { |
|
| 207 | + if ( ! empty($tag->slug)) { |
|
| 208 | 208 | $templates[] = "tag-{$tag->slug}.php"; |
| 209 | 209 | $templates[] = "tag-{$tag->term_id}.php"; |
| 210 | 210 | } |
| 211 | 211 | $templates[] = 'tag.php'; |
| 212 | 212 | |
| 213 | - return get_query_template( 'tag', $templates ); |
|
| 213 | + return get_query_template('tag', $templates); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $templates = array(); |
| 241 | 241 | |
| 242 | - if ( ! empty( $term->slug ) ) { |
|
| 242 | + if ( ! empty($term->slug)) { |
|
| 243 | 243 | $taxonomy = $term->taxonomy; |
| 244 | 244 | $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; |
| 245 | 245 | $templates[] = "taxonomy-$taxonomy.php"; |
| 246 | 246 | } |
| 247 | 247 | $templates[] = 'taxonomy.php'; |
| 248 | 248 | |
| 249 | - return get_query_template( 'taxonomy', $templates ); |
|
| 249 | + return get_query_template('taxonomy', $templates); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -281,9 +281,9 @@ discard block |
||
| 281 | 281 | * @return string Full path to home template file. |
| 282 | 282 | */ |
| 283 | 283 | function get_home_template() { |
| 284 | - $templates = array( 'home.php', 'index.php' ); |
|
| 284 | + $templates = array('home.php', 'index.php'); |
|
| 285 | 285 | |
| 286 | - return get_query_template( 'home', $templates ); |
|
| 286 | + return get_query_template('home', $templates); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | function get_front_page_template() { |
| 302 | 302 | $templates = array('front-page.php'); |
| 303 | 303 | |
| 304 | - return get_query_template( 'front_page', $templates ); |
|
| 304 | + return get_query_template('front_page', $templates); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -325,23 +325,23 @@ discard block |
||
| 325 | 325 | $template = get_page_template_slug(); |
| 326 | 326 | $pagename = get_query_var('pagename'); |
| 327 | 327 | |
| 328 | - if ( ! $pagename && $id ) { |
|
| 328 | + if ( ! $pagename && $id) { |
|
| 329 | 329 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
| 330 | 330 | $post = get_queried_object(); |
| 331 | - if ( $post ) |
|
| 331 | + if ($post) |
|
| 332 | 332 | $pagename = $post->post_name; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | $templates = array(); |
| 336 | - if ( $template && 0 === validate_file( $template ) ) |
|
| 336 | + if ($template && 0 === validate_file($template)) |
|
| 337 | 337 | $templates[] = $template; |
| 338 | - if ( $pagename ) |
|
| 338 | + if ($pagename) |
|
| 339 | 339 | $templates[] = "page-$pagename.php"; |
| 340 | - if ( $id ) |
|
| 340 | + if ($id) |
|
| 341 | 341 | $templates[] = "page-$id.php"; |
| 342 | 342 | $templates[] = 'page.php'; |
| 343 | 343 | |
| 344 | - return get_query_template( 'page', $templates ); |
|
| 344 | + return get_query_template('page', $templates); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -394,14 +394,14 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | $templates = array(); |
| 396 | 396 | |
| 397 | - if ( ! empty( $object->post_type ) ) { |
|
| 397 | + if ( ! empty($object->post_type)) { |
|
| 398 | 398 | $templates[] = "single-{$object->post_type}-{$object->post_name}.php"; |
| 399 | 399 | $templates[] = "single-{$object->post_type}.php"; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | $templates[] = "single.php"; |
| 403 | 403 | |
| 404 | - return get_query_template( 'single', $templates ); |
|
| 404 | + return get_query_template('single', $templates); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -423,9 +423,9 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | $templates = array(); |
| 425 | 425 | |
| 426 | - if ( ! empty( $object->post_type ) ) { |
|
| 427 | - $post_format = get_post_format( $object ); |
|
| 428 | - if ( $post_format ) { |
|
| 426 | + if ( ! empty($object->post_type)) { |
|
| 427 | + $post_format = get_post_format($object); |
|
| 428 | + if ($post_format) { |
|
| 429 | 429 | $templates[] = "embed-{$object->post_type}-{$post_format}.php"; |
| 430 | 430 | } |
| 431 | 431 | $templates[] = "embed-{$object->post_type}.php"; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | $templates[] = "embed.php"; |
| 435 | 435 | |
| 436 | - return get_query_template( 'embed', $templates ); |
|
| 436 | + return get_query_template('embed', $templates); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @return string Full path to singular template file |
| 450 | 450 | */ |
| 451 | 451 | function get_singular_template() { |
| 452 | - return get_query_template( 'singular' ); |
|
| 452 | + return get_query_template('singular'); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -479,14 +479,14 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | $templates = array(); |
| 481 | 481 | |
| 482 | - if ( $attachment ) { |
|
| 483 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
| 484 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
| 482 | + if ($attachment) { |
|
| 483 | + if (false !== strpos($attachment->post_mime_type, '/')) { |
|
| 484 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
| 485 | 485 | } else { |
| 486 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
| 486 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - if ( ! empty( $subtype ) ) { |
|
| 489 | + if ( ! empty($subtype)) { |
|
| 490 | 490 | $templates[] = "{$type}-{$subtype}.php"; |
| 491 | 491 | $templates[] = "{$subtype}.php"; |
| 492 | 492 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | $templates[] = 'attachment.php'; |
| 496 | 496 | |
| 497 | - return get_query_template( 'attachment', $templates ); |
|
| 497 | + return get_query_template('attachment', $templates); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -510,25 +510,25 @@ discard block |
||
| 510 | 510 | * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false. |
| 511 | 511 | * @return string The template filename if one is located. |
| 512 | 512 | */ |
| 513 | -function locate_template($template_names, $load = false, $require_once = true ) { |
|
| 513 | +function locate_template($template_names, $load = false, $require_once = true) { |
|
| 514 | 514 | $located = ''; |
| 515 | - foreach ( (array) $template_names as $template_name ) { |
|
| 516 | - if ( !$template_name ) |
|
| 515 | + foreach ((array) $template_names as $template_name) { |
|
| 516 | + if ( ! $template_name) |
|
| 517 | 517 | continue; |
| 518 | - if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { |
|
| 519 | - $located = STYLESHEETPATH . '/' . $template_name; |
|
| 518 | + if (file_exists(STYLESHEETPATH.'/'.$template_name)) { |
|
| 519 | + $located = STYLESHEETPATH.'/'.$template_name; |
|
| 520 | 520 | break; |
| 521 | - } elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) { |
|
| 522 | - $located = TEMPLATEPATH . '/' . $template_name; |
|
| 521 | + } elseif (file_exists(TEMPLATEPATH.'/'.$template_name)) { |
|
| 522 | + $located = TEMPLATEPATH.'/'.$template_name; |
|
| 523 | 523 | break; |
| 524 | - } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { |
|
| 525 | - $located = ABSPATH . WPINC . '/theme-compat/' . $template_name; |
|
| 524 | + } elseif (file_exists(ABSPATH.WPINC.'/theme-compat/'.$template_name)) { |
|
| 525 | + $located = ABSPATH.WPINC.'/theme-compat/'.$template_name; |
|
| 526 | 526 | break; |
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - if ( $load && '' != $located ) |
|
| 531 | - load_template( $located, $require_once ); |
|
| 530 | + if ($load && '' != $located) |
|
| 531 | + load_template($located, $require_once); |
|
| 532 | 532 | |
| 533 | 533 | return $located; |
| 534 | 534 | } |
@@ -557,21 +557,21 @@ discard block |
||
| 557 | 557 | * @param string $_template_file Path to template file. |
| 558 | 558 | * @param bool $require_once Whether to require_once or require. Default true. |
| 559 | 559 | */ |
| 560 | -function load_template( $_template_file, $require_once = true ) { |
|
| 560 | +function load_template($_template_file, $require_once = true) { |
|
| 561 | 561 | global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; |
| 562 | 562 | |
| 563 | - if ( is_array( $wp_query->query_vars ) ) { |
|
| 564 | - extract( $wp_query->query_vars, EXTR_SKIP ); |
|
| 563 | + if (is_array($wp_query->query_vars)) { |
|
| 564 | + extract($wp_query->query_vars, EXTR_SKIP); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - if ( isset( $s ) ) { |
|
| 568 | - $s = esc_attr( $s ); |
|
| 567 | + if (isset($s)) { |
|
| 568 | + $s = esc_attr($s); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if ( $require_once ) { |
|
| 572 | - require_once( $_template_file ); |
|
| 571 | + if ($require_once) { |
|
| 572 | + require_once($_template_file); |
|
| 573 | 573 | } else { |
| 574 | - require( $_template_file ); |
|
| 574 | + require($_template_file); |
|
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | |
@@ -23,8 +23,9 @@ discard block |
||
| 23 | 23 | function get_query_template( $type, $templates = array() ) { |
| 24 | 24 | $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); |
| 25 | 25 | |
| 26 | - if ( empty( $templates ) ) |
|
| 27 | - $templates = array("{$type}.php"); |
|
| 26 | + if ( empty( $templates ) ) { |
|
| 27 | + $templates = array("{$type}.php"); |
|
| 28 | + } |
|
| 28 | 29 | |
| 29 | 30 | $template = locate_template( $templates ); |
| 30 | 31 | |
@@ -117,12 +118,14 @@ discard block |
||
| 117 | 118 | */ |
| 118 | 119 | function get_post_type_archive_template() { |
| 119 | 120 | $post_type = get_query_var( 'post_type' ); |
| 120 | - if ( is_array( $post_type ) ) |
|
| 121 | - $post_type = reset( $post_type ); |
|
| 121 | + if ( is_array( $post_type ) ) { |
|
| 122 | + $post_type = reset( $post_type ); |
|
| 123 | + } |
|
| 122 | 124 | |
| 123 | 125 | $obj = get_post_type_object( $post_type ); |
| 124 | - if ( ! $obj->has_archive ) |
|
| 125 | - return ''; |
|
| 126 | + if ( ! $obj->has_archive ) { |
|
| 127 | + return ''; |
|
| 128 | + } |
|
| 126 | 129 | |
| 127 | 130 | return get_archive_template(); |
| 128 | 131 | } |
@@ -328,17 +331,21 @@ discard block |
||
| 328 | 331 | if ( ! $pagename && $id ) { |
| 329 | 332 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
| 330 | 333 | $post = get_queried_object(); |
| 331 | - if ( $post ) |
|
| 332 | - $pagename = $post->post_name; |
|
| 334 | + if ( $post ) { |
|
| 335 | + $pagename = $post->post_name; |
|
| 336 | + } |
|
| 333 | 337 | } |
| 334 | 338 | |
| 335 | 339 | $templates = array(); |
| 336 | - if ( $template && 0 === validate_file( $template ) ) |
|
| 337 | - $templates[] = $template; |
|
| 338 | - if ( $pagename ) |
|
| 339 | - $templates[] = "page-$pagename.php"; |
|
| 340 | - if ( $id ) |
|
| 341 | - $templates[] = "page-$id.php"; |
|
| 340 | + if ( $template && 0 === validate_file( $template ) ) { |
|
| 341 | + $templates[] = $template; |
|
| 342 | + } |
|
| 343 | + if ( $pagename ) { |
|
| 344 | + $templates[] = "page-$pagename.php"; |
|
| 345 | + } |
|
| 346 | + if ( $id ) { |
|
| 347 | + $templates[] = "page-$id.php"; |
|
| 348 | + } |
|
| 342 | 349 | $templates[] = 'page.php'; |
| 343 | 350 | |
| 344 | 351 | return get_query_template( 'page', $templates ); |
@@ -513,8 +520,9 @@ discard block |
||
| 513 | 520 | function locate_template($template_names, $load = false, $require_once = true ) { |
| 514 | 521 | $located = ''; |
| 515 | 522 | foreach ( (array) $template_names as $template_name ) { |
| 516 | - if ( !$template_name ) |
|
| 517 | - continue; |
|
| 523 | + if ( !$template_name ) { |
|
| 524 | + continue; |
|
| 525 | + } |
|
| 518 | 526 | if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { |
| 519 | 527 | $located = STYLESHEETPATH . '/' . $template_name; |
| 520 | 528 | break; |
@@ -527,8 +535,9 @@ discard block |
||
| 527 | 535 | } |
| 528 | 536 | } |
| 529 | 537 | |
| 530 | - if ( $load && '' != $located ) |
|
| 531 | - load_template( $located, $require_once ); |
|
| 538 | + if ( $load && '' != $located ) { |
|
| 539 | + load_template( $located, $require_once ); |
|
| 540 | + } |
|
| 532 | 541 | |
| 533 | 542 | return $located; |
| 534 | 543 | } |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * REST API: WP_REST_Response class |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage REST_API |
|
| 7 | - * @since 4.4.0 |
|
| 8 | - */ |
|
| 3 | + * REST API: WP_REST_Response class |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage REST_API |
|
| 7 | + * @since 4.4.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Core class used to implement a REST response object. |
@@ -59,17 +59,17 @@ discard block |
||
| 59 | 59 | * @param string $href Target URI for the link. |
| 60 | 60 | * @param array $attributes Optional. Link parameters to send along with the URL. Default empty array. |
| 61 | 61 | */ |
| 62 | - public function add_link( $rel, $href, $attributes = array() ) { |
|
| 63 | - if ( empty( $this->links[ $rel ] ) ) { |
|
| 64 | - $this->links[ $rel ] = array(); |
|
| 62 | + public function add_link($rel, $href, $attributes = array()) { |
|
| 63 | + if (empty($this->links[$rel])) { |
|
| 64 | + $this->links[$rel] = array(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( isset( $attributes['href'] ) ) { |
|
| 67 | + if (isset($attributes['href'])) { |
|
| 68 | 68 | // Remove the href attribute, as it's used for the main URL. |
| 69 | - unset( $attributes['href'] ); |
|
| 69 | + unset($attributes['href']); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $this->links[ $rel ][] = array( |
|
| 72 | + $this->links[$rel][] = array( |
|
| 73 | 73 | 'href' => $href, |
| 74 | 74 | 'attributes' => $attributes, |
| 75 | 75 | ); |
@@ -85,19 +85,19 @@ discard block |
||
| 85 | 85 | * @param string $href Optional. Only remove links for the relation matching the given href. |
| 86 | 86 | * Default null. |
| 87 | 87 | */ |
| 88 | - public function remove_link( $rel, $href = null ) { |
|
| 89 | - if ( ! isset( $this->links[ $rel ] ) ) { |
|
| 88 | + public function remove_link($rel, $href = null) { |
|
| 89 | + if ( ! isset($this->links[$rel])) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ( $href ) { |
|
| 94 | - $this->links[ $rel ] = wp_list_filter( $this->links[ $rel ], array( 'href' => $href ), 'NOT' ); |
|
| 93 | + if ($href) { |
|
| 94 | + $this->links[$rel] = wp_list_filter($this->links[$rel], array('href' => $href), 'NOT'); |
|
| 95 | 95 | } else { |
| 96 | - $this->links[ $rel ] = array(); |
|
| 96 | + $this->links[$rel] = array(); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( ! $this->links[ $rel ] ) { |
|
| 100 | - unset( $this->links[ $rel ] ); |
|
| 99 | + if ( ! $this->links[$rel]) { |
|
| 100 | + unset($this->links[$rel]); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param array $links Map of link relation to list of links. |
| 116 | 116 | */ |
| 117 | - public function add_links( $links ) { |
|
| 118 | - foreach ( $links as $rel => $set ) { |
|
| 117 | + public function add_links($links) { |
|
| 118 | + foreach ($links as $rel => $set) { |
|
| 119 | 119 | // If it's a single link, wrap with an array for consistent handling. |
| 120 | - if ( isset( $set['href'] ) ) { |
|
| 121 | - $set = array( $set ); |
|
| 120 | + if (isset($set['href'])) { |
|
| 121 | + $set = array($set); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - foreach ( $set as $attributes ) { |
|
| 125 | - $this->add_link( $rel, $attributes['href'], $attributes ); |
|
| 124 | + foreach ($set as $attributes) { |
|
| 125 | + $this->add_link($rel, $attributes['href'], $attributes); |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -155,16 +155,16 @@ discard block |
||
| 155 | 155 | * @param array $other Optional. Other parameters to send, as an assocative array. |
| 156 | 156 | * Default empty array. |
| 157 | 157 | */ |
| 158 | - public function link_header( $rel, $link, $other = array() ) { |
|
| 159 | - $header = '<' . $link . '>; rel="' . $rel . '"'; |
|
| 158 | + public function link_header($rel, $link, $other = array()) { |
|
| 159 | + $header = '<'.$link.'>; rel="'.$rel.'"'; |
|
| 160 | 160 | |
| 161 | - foreach ( $other as $key => $value ) { |
|
| 162 | - if ( 'title' === $key ) { |
|
| 163 | - $value = '"' . $value . '"'; |
|
| 161 | + foreach ($other as $key => $value) { |
|
| 162 | + if ('title' === $key) { |
|
| 163 | + $value = '"'.$value.'"'; |
|
| 164 | 164 | } |
| 165 | - $header .= '; ' . $key . '=' . $value; |
|
| 165 | + $header .= '; '.$key.'='.$value; |
|
| 166 | 166 | } |
| 167 | - $this->header( 'Link', $header, false ); |
|
| 167 | + $this->header('Link', $header, false); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @param string $route Route name. |
| 189 | 189 | */ |
| 190 | - public function set_matched_route( $route ) { |
|
| 190 | + public function set_matched_route($route) { |
|
| 191 | 191 | $this->matched_route = $route; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @param array $handler The matched handler. |
| 213 | 213 | */ |
| 214 | - public function set_matched_handler( $handler ) { |
|
| 214 | + public function set_matched_handler($handler) { |
|
| 215 | 215 | $this->matched_handler = $handler; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -236,22 +236,22 @@ discard block |
||
| 236 | 236 | * @return WP_Error|null WP_Error or null on not an errored response. |
| 237 | 237 | */ |
| 238 | 238 | public function as_error() { |
| 239 | - if ( ! $this->is_error() ) { |
|
| 239 | + if ( ! $this->is_error()) { |
|
| 240 | 240 | return null; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | $error = new WP_Error; |
| 244 | 244 | |
| 245 | - if ( is_array( $this->get_data() ) ) { |
|
| 245 | + if (is_array($this->get_data())) { |
|
| 246 | 246 | $data = $this->get_data(); |
| 247 | - $error->add( $data['code'], $data['message'], $data['data'] ); |
|
| 248 | - if ( ! empty( $data['additional_errors'] ) ) { |
|
| 249 | - foreach( $data['additional_errors'] as $err ) { |
|
| 250 | - $error->add( $err['code'], $err['message'], $err['data'] ); |
|
| 247 | + $error->add($data['code'], $data['message'], $data['data']); |
|
| 248 | + if ( ! empty($data['additional_errors'])) { |
|
| 249 | + foreach ($data['additional_errors'] as $err) { |
|
| 250 | + $error->add($err['code'], $err['message'], $err['data']); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | } else { |
| 254 | - $error->add( $this->get_status(), '', array( 'status' => $this->get_status() ) ); |
|
| 254 | + $error->add($this->get_status(), '', array('status' => $this->get_status())); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | return $error; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @param array $additional Additional CURIEs to register with the API. |
| 301 | 301 | */ |
| 302 | - $additional = apply_filters( 'rest_response_link_curies', array() ); |
|
| 303 | - return array_merge( $curies, $additional ); |
|
| 302 | + $additional = apply_filters('rest_response_link_curies', array()); |
|
| 303 | + return array_merge($curies, $additional); |
|
| 304 | 304 | } |
| 305 | 305 | } |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Customize API: WP_Customize_Nav_Menus_Panel class |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Customize |
|
| 7 | - * @since 4.4.0 |
|
| 8 | - */ |
|
| 3 | + * Customize API: WP_Customize_Nav_Menus_Panel class |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Customize |
|
| 7 | + * @since 4.4.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Customize Nav Menus Panel Class |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function render_screen_options() { |
| 37 | 37 | // Adds the screen options. |
| 38 | - require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
|
| 39 | - add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' ); |
|
| 38 | + require_once ABSPATH.'wp-admin/includes/nav-menu.php'; |
|
| 39 | + add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns'); |
|
| 40 | 40 | |
| 41 | 41 | // Display screen options. |
| 42 | - $screen = WP_Screen::get( 'nav-menus.php' ); |
|
| 43 | - $screen->render_screen_options( array( 'wrap' => false ) ); |
|
| 42 | + $screen = WP_Screen::get('nav-menus.php'); |
|
| 43 | + $screen->render_screen_options(array('wrap' => false)); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | * @deprecated 4.5.0 Deprecated in favor of wp_nav_menu_manage_columns(). |
| 53 | 53 | */ |
| 54 | 54 | public function wp_nav_menu_manage_columns() { |
| 55 | - _deprecated_function( __METHOD__, '4.5.0', 'wp_nav_menu_manage_columns' ); |
|
| 56 | - require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
|
| 55 | + _deprecated_function(__METHOD__, '4.5.0', 'wp_nav_menu_manage_columns'); |
|
| 56 | + require_once ABSPATH.'wp-admin/includes/nav-menu.php'; |
|
| 57 | 57 | return wp_nav_menu_manage_columns(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -72,20 +72,20 @@ discard block |
||
| 72 | 72 | ?> |
| 73 | 73 | <li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>"> |
| 74 | 74 | <button type="button" class="customize-panel-back" tabindex="-1"> |
| 75 | - <span class="screen-reader-text"><?php _e( 'Back' ); ?></span> |
|
| 75 | + <span class="screen-reader-text"><?php _e('Back'); ?></span> |
|
| 76 | 76 | </button> |
| 77 | 77 | <div class="accordion-section-title"> |
| 78 | 78 | <span class="preview-notice"> |
| 79 | 79 | <?php |
| 80 | 80 | /* translators: %s: the site/panel title in the Customizer */ |
| 81 | - printf( __( 'You are customizing %s' ), '<strong class="panel-title">{{ data.title }}</strong>' ); |
|
| 81 | + printf(__('You are customizing %s'), '<strong class="panel-title">{{ data.title }}</strong>'); |
|
| 82 | 82 | ?> |
| 83 | 83 | </span> |
| 84 | 84 | <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"> |
| 85 | - <span class="screen-reader-text"><?php _e( 'Help' ); ?></span> |
|
| 85 | + <span class="screen-reader-text"><?php _e('Help'); ?></span> |
|
| 86 | 86 | </button> |
| 87 | 87 | <button type="button" class="customize-screen-options-toggle" aria-expanded="false"> |
| 88 | - <span class="screen-reader-text"><?php _e( 'Menu Options' ); ?></span> |
|
| 88 | + <span class="screen-reader-text"><?php _e('Menu Options'); ?></span> |
|
| 89 | 89 | </button> |
| 90 | 90 | </div> |
| 91 | 91 | <# if ( data.description ) { #> |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | * @param string $id Control ID. |
| 38 | 38 | * @param array $args Optional. Arguments to override class property defaults. |
| 39 | 39 | */ |
| 40 | - public function __construct( $manager, $id, $args = array() ) { |
|
| 41 | - parent::__construct( $manager, $id, $args ); |
|
| 42 | - add_action( 'customize_controls_print_styles', 'wp_site_icon', 99 ); |
|
| 40 | + public function __construct($manager, $id, $args = array()) { |
|
| 41 | + parent::__construct($manager, $id, $args); |
|
| 42 | + add_action('customize_controls_print_styles', 'wp_site_icon', 99); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | <div class="container"> |
| 65 | 65 | <div class="site-icon-preview"> |
| 66 | 66 | <div class="favicon-preview"> |
| 67 | - <img src="<?php echo esc_url( admin_url( 'images/browser.png' ) ); ?>" class="browser-preview" width="182" alt="<?php esc_attr_e( 'Browser interface preview' ); ?>" /> |
|
| 67 | + <img src="<?php echo esc_url(admin_url('images/browser.png')); ?>" class="browser-preview" width="182" alt="<?php esc_attr_e('Browser interface preview'); ?>" /> |
|
| 68 | 68 | |
| 69 | 69 | <div class="favicon"> |
| 70 | - <img id="preview-favicon" src="{{ data.attachment.sizes.full.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/> |
|
| 70 | + <img id="preview-favicon" src="{{ data.attachment.sizes.full.url }}" alt="<?php esc_attr_e('Preview as a browser icon'); ?>"/> |
|
| 71 | 71 | </div> |
| 72 | - <span class="browser-title"><?php bloginfo( 'name' ); ?></span> |
|
| 72 | + <span class="browser-title"><?php bloginfo('name'); ?></span> |
|
| 73 | 73 | </div> |
| 74 | - <img class="app-icon-preview" src="{{ data.attachment.sizes.full.url }}" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"/> |
|
| 74 | + <img class="app-icon-preview" src="{{ data.attachment.sizes.full.url }}" alt="<?php esc_attr_e('Preview as an app icon'); ?>"/> |
|
| 75 | 75 | </div> |
| 76 | 76 | </div> |
| 77 | 77 | </div> |