@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | public function __construct() { |
| 26 | 26 | $widget_ops = array( |
| 27 | 27 | 'classname' => 'widget_recent_comments', |
| 28 | - 'description' => __( 'Your site’s most recent comments.' ), |
|
| 28 | + 'description' => __('Your site’s most recent comments.'), |
|
| 29 | 29 | 'customize_selective_refresh' => true, |
| 30 | 30 | ); |
| 31 | - parent::__construct( 'recent-comments', __( 'Recent Comments' ), $widget_ops ); |
|
| 31 | + parent::__construct('recent-comments', __('Recent Comments'), $widget_ops); |
|
| 32 | 32 | $this->alt_option_name = 'widget_recent_comments'; |
| 33 | 33 | |
| 34 | - if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) { |
|
| 35 | - add_action( 'wp_head', array( $this, 'recent_comments_style' ) ); |
|
| 34 | + if (is_active_widget(false, false, $this->id_base) || is_customize_preview()) { |
|
| 35 | + add_action('wp_head', array($this, 'recent_comments_style')); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | * @param bool $active Whether the widget is active. Default true. |
| 52 | 52 | * @param string $id_base The widget ID. |
| 53 | 53 | */ |
| 54 | - if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 |
|
| 55 | - || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) |
|
| 54 | + if ( ! current_theme_supports('widgets') // Temp hack #14876 |
|
| 55 | + || ! apply_filters('show_recent_comments_widget_style', true, $this->id_base)) |
|
| 56 | 56 | return; |
| 57 | 57 | ?> |
| 58 | 58 | <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | * 'before_widget', and 'after_widget'. |
| 70 | 70 | * @param array $instance Settings for the current Recent Comments widget instance. |
| 71 | 71 | */ |
| 72 | - public function widget( $args, $instance ) { |
|
| 73 | - if ( ! isset( $args['widget_id'] ) ) |
|
| 72 | + public function widget($args, $instance) { |
|
| 73 | + if ( ! isset($args['widget_id'])) |
|
| 74 | 74 | $args['widget_id'] = $this->id; |
| 75 | 75 | |
| 76 | 76 | $output = ''; |
| 77 | 77 | |
| 78 | - $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); |
|
| 78 | + $title = ( ! empty($instance['title'])) ? $instance['title'] : __('Recent Comments'); |
|
| 79 | 79 | |
| 80 | 80 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 81 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 81 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
| 82 | 82 | |
| 83 | - $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; |
|
| 84 | - if ( ! $number ) |
|
| 83 | + $number = ( ! empty($instance['number'])) ? absint($instance['number']) : 5; |
|
| 84 | + if ( ! $number) |
|
| 85 | 85 | $number = 5; |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -93,29 +93,29 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @param array $comment_args An array of arguments used to retrieve the recent comments. |
| 95 | 95 | */ |
| 96 | - $comments = get_comments( apply_filters( 'widget_comments_args', array( |
|
| 96 | + $comments = get_comments(apply_filters('widget_comments_args', array( |
|
| 97 | 97 | 'number' => $number, |
| 98 | 98 | 'status' => 'approve', |
| 99 | 99 | 'post_status' => 'publish' |
| 100 | - ) ) ); |
|
| 100 | + ))); |
|
| 101 | 101 | |
| 102 | 102 | $output .= $args['before_widget']; |
| 103 | - if ( $title ) { |
|
| 104 | - $output .= $args['before_title'] . $title . $args['after_title']; |
|
| 103 | + if ($title) { |
|
| 104 | + $output .= $args['before_title'].$title.$args['after_title']; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $output .= '<ul id="recentcomments">'; |
| 108 | - if ( is_array( $comments ) && $comments ) { |
|
| 108 | + if (is_array($comments) && $comments) { |
|
| 109 | 109 | // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.) |
| 110 | - $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) ); |
|
| 111 | - _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false ); |
|
| 110 | + $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID')); |
|
| 111 | + _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false); |
|
| 112 | 112 | |
| 113 | - foreach ( (array) $comments as $comment ) { |
|
| 113 | + foreach ((array) $comments as $comment) { |
|
| 114 | 114 | $output .= '<li class="recentcomments">'; |
| 115 | 115 | /* translators: comments widget: 1: comment author, 2: post link */ |
| 116 | - $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ), |
|
| 117 | - '<span class="comment-author-link">' . get_comment_author_link( $comment ) . '</span>', |
|
| 118 | - '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . get_the_title( $comment->comment_post_ID ) . '</a>' |
|
| 116 | + $output .= sprintf(_x('%1$s on %2$s', 'widgets'), |
|
| 117 | + '<span class="comment-author-link">'.get_comment_author_link($comment).'</span>', |
|
| 118 | + '<a href="'.esc_url(get_comment_link($comment)).'">'.get_the_title($comment->comment_post_ID).'</a>' |
|
| 119 | 119 | ); |
| 120 | 120 | $output .= '</li>'; |
| 121 | 121 | } |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | * @param array $old_instance Old settings for this instance. |
| 138 | 138 | * @return array Updated settings to save. |
| 139 | 139 | */ |
| 140 | - public function update( $new_instance, $old_instance ) { |
|
| 140 | + public function update($new_instance, $old_instance) { |
|
| 141 | 141 | $instance = $old_instance; |
| 142 | - $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
| 143 | - $instance['number'] = absint( $new_instance['number'] ); |
|
| 142 | + $instance['title'] = sanitize_text_field($new_instance['title']); |
|
| 143 | + $instance['number'] = absint($new_instance['number']); |
|
| 144 | 144 | return $instance; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @param array $instance Current settings. |
| 154 | 154 | */ |
| 155 | - public function form( $instance ) { |
|
| 156 | - $title = isset( $instance['title'] ) ? $instance['title'] : ''; |
|
| 157 | - $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; |
|
| 155 | + public function form($instance) { |
|
| 156 | + $title = isset($instance['title']) ? $instance['title'] : ''; |
|
| 157 | + $number = isset($instance['number']) ? absint($instance['number']) : 5; |
|
| 158 | 158 | ?> |
| 159 | - <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> |
|
| 160 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> |
|
| 159 | + <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> |
|
| 160 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
|
| 161 | 161 | |
| 162 | - <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label> |
|
| 163 | - <input class="tiny-text" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" step="1" min="1" value="<?php echo $number; ?>" size="3" /></p> |
|
| 162 | + <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of comments to show:'); ?></label> |
|
| 163 | + <input class="tiny-text" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="number" step="1" min="1" value="<?php echo $number; ?>" size="3" /></p> |
|
| 164 | 164 | <?php |
| 165 | 165 | } |
| 166 | 166 | |
@@ -173,6 +173,6 @@ discard block |
||
| 173 | 173 | * @deprecated 4.4.0 Fragment caching was removed in favor of split queries. |
| 174 | 174 | */ |
| 175 | 175 | public function flush_widget_cache() { |
| 176 | - _deprecated_function( __METHOD__, '4.4.0' ); |
|
| 176 | + _deprecated_function(__METHOD__, '4.4.0'); |
|
| 177 | 177 | } |
| 178 | 178 | } |
@@ -5,5 +5,5 @@ |
||
| 5 | 5 | * @package WordPress |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -_deprecated_file( basename(__FILE__), '2.1.0', WPINC . '/rss.php' ); |
|
| 9 | -require_once( ABSPATH . WPINC . '/rss.php' ); |
|
| 8 | +_deprecated_file(basename(__FILE__), '2.1.0', WPINC.'/rss.php'); |
|
| 9 | +require_once(ABSPATH.WPINC.'/rss.php'); |
|
@@ -13,481 +13,481 @@ |
||
| 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 | // Meta |
| 89 | -add_filter( 'register_meta_args', '_wp_register_meta_args_whitelist', 10, 2 ); |
|
| 89 | +add_filter('register_meta_args', '_wp_register_meta_args_whitelist', 10, 2); |
|
| 90 | 90 | |
| 91 | 91 | // Places to balance tags on input |
| 92 | -foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { |
|
| 93 | - add_filter( $filter, 'convert_invalid_entities' ); |
|
| 94 | - add_filter( $filter, 'balanceTags', 50 ); |
|
| 92 | +foreach (array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content') as $filter) { |
|
| 93 | + add_filter($filter, 'convert_invalid_entities'); |
|
| 94 | + add_filter($filter, 'balanceTags', 50); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Format strings for display. |
| 98 | -foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) { |
|
| 99 | - add_filter( $filter, 'wptexturize' ); |
|
| 100 | - add_filter( $filter, 'convert_chars' ); |
|
| 101 | - add_filter( $filter, 'esc_html' ); |
|
| 98 | +foreach (array('comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title') as $filter) { |
|
| 99 | + add_filter($filter, 'wptexturize'); |
|
| 100 | + add_filter($filter, 'convert_chars'); |
|
| 101 | + add_filter($filter, 'esc_html'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Format WordPress |
| 105 | -foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter ) |
|
| 106 | - add_filter( $filter, 'capital_P_dangit', 11 ); |
|
| 107 | -add_filter( 'comment_text', 'capital_P_dangit', 31 ); |
|
| 105 | +foreach (array('the_content', 'the_title', 'wp_title') as $filter) |
|
| 106 | + add_filter($filter, 'capital_P_dangit', 11); |
|
| 107 | +add_filter('comment_text', 'capital_P_dangit', 31); |
|
| 108 | 108 | |
| 109 | 109 | // Format titles |
| 110 | -foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) { |
|
| 111 | - add_filter( $filter, 'wptexturize' ); |
|
| 112 | - add_filter( $filter, 'strip_tags' ); |
|
| 110 | +foreach (array('single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description') as $filter) { |
|
| 111 | + add_filter($filter, 'wptexturize'); |
|
| 112 | + add_filter($filter, 'strip_tags'); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Format text area for display. |
| 116 | -foreach ( array( 'term_description' ) as $filter ) { |
|
| 117 | - add_filter( $filter, 'wptexturize' ); |
|
| 118 | - add_filter( $filter, 'convert_chars' ); |
|
| 119 | - add_filter( $filter, 'wpautop' ); |
|
| 120 | - add_filter( $filter, 'shortcode_unautop'); |
|
| 116 | +foreach (array('term_description') as $filter) { |
|
| 117 | + add_filter($filter, 'wptexturize'); |
|
| 118 | + add_filter($filter, 'convert_chars'); |
|
| 119 | + add_filter($filter, 'wpautop'); |
|
| 120 | + add_filter($filter, 'shortcode_unautop'); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Format for RSS |
| 124 | -add_filter( 'term_name_rss', 'convert_chars' ); |
|
| 124 | +add_filter('term_name_rss', 'convert_chars'); |
|
| 125 | 125 | |
| 126 | 126 | // Pre save hierarchy |
| 127 | -add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); |
|
| 128 | -add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); |
|
| 127 | +add_filter('wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2); |
|
| 128 | +add_filter('wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3); |
|
| 129 | 129 | |
| 130 | 130 | // Display filters |
| 131 | -add_filter( 'the_title', 'wptexturize' ); |
|
| 132 | -add_filter( 'the_title', 'convert_chars' ); |
|
| 133 | -add_filter( 'the_title', 'trim' ); |
|
| 131 | +add_filter('the_title', 'wptexturize'); |
|
| 132 | +add_filter('the_title', 'convert_chars'); |
|
| 133 | +add_filter('the_title', 'trim'); |
|
| 134 | 134 | |
| 135 | -add_filter( 'the_content', 'wptexturize' ); |
|
| 136 | -add_filter( 'the_content', 'convert_smilies', 20 ); |
|
| 137 | -add_filter( 'the_content', 'wpautop' ); |
|
| 138 | -add_filter( 'the_content', 'shortcode_unautop' ); |
|
| 139 | -add_filter( 'the_content', 'prepend_attachment' ); |
|
| 140 | -add_filter( 'the_content', 'wp_make_content_images_responsive' ); |
|
| 135 | +add_filter('the_content', 'wptexturize'); |
|
| 136 | +add_filter('the_content', 'convert_smilies', 20); |
|
| 137 | +add_filter('the_content', 'wpautop'); |
|
| 138 | +add_filter('the_content', 'shortcode_unautop'); |
|
| 139 | +add_filter('the_content', 'prepend_attachment'); |
|
| 140 | +add_filter('the_content', 'wp_make_content_images_responsive'); |
|
| 141 | 141 | |
| 142 | -add_filter( 'the_excerpt', 'wptexturize' ); |
|
| 143 | -add_filter( 'the_excerpt', 'convert_smilies' ); |
|
| 144 | -add_filter( 'the_excerpt', 'convert_chars' ); |
|
| 145 | -add_filter( 'the_excerpt', 'wpautop' ); |
|
| 146 | -add_filter( 'the_excerpt', 'shortcode_unautop'); |
|
| 147 | -add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); |
|
| 142 | +add_filter('the_excerpt', 'wptexturize'); |
|
| 143 | +add_filter('the_excerpt', 'convert_smilies'); |
|
| 144 | +add_filter('the_excerpt', 'convert_chars'); |
|
| 145 | +add_filter('the_excerpt', 'wpautop'); |
|
| 146 | +add_filter('the_excerpt', 'shortcode_unautop'); |
|
| 147 | +add_filter('get_the_excerpt', 'wp_trim_excerpt'); |
|
| 148 | 148 | |
| 149 | -add_filter( 'the_post_thumbnail_caption', 'wptexturize' ); |
|
| 150 | -add_filter( 'the_post_thumbnail_caption', 'convert_smilies' ); |
|
| 151 | -add_filter( 'the_post_thumbnail_caption', 'convert_chars' ); |
|
| 149 | +add_filter('the_post_thumbnail_caption', 'wptexturize'); |
|
| 150 | +add_filter('the_post_thumbnail_caption', 'convert_smilies'); |
|
| 151 | +add_filter('the_post_thumbnail_caption', 'convert_chars'); |
|
| 152 | 152 | |
| 153 | -add_filter( 'comment_text', 'wptexturize' ); |
|
| 154 | -add_filter( 'comment_text', 'convert_chars' ); |
|
| 155 | -add_filter( 'comment_text', 'make_clickable', 9 ); |
|
| 156 | -add_filter( 'comment_text', 'force_balance_tags', 25 ); |
|
| 157 | -add_filter( 'comment_text', 'convert_smilies', 20 ); |
|
| 158 | -add_filter( 'comment_text', 'wpautop', 30 ); |
|
| 153 | +add_filter('comment_text', 'wptexturize'); |
|
| 154 | +add_filter('comment_text', 'convert_chars'); |
|
| 155 | +add_filter('comment_text', 'make_clickable', 9); |
|
| 156 | +add_filter('comment_text', 'force_balance_tags', 25); |
|
| 157 | +add_filter('comment_text', 'convert_smilies', 20); |
|
| 158 | +add_filter('comment_text', 'wpautop', 30); |
|
| 159 | 159 | |
| 160 | -add_filter( 'comment_excerpt', 'convert_chars' ); |
|
| 160 | +add_filter('comment_excerpt', 'convert_chars'); |
|
| 161 | 161 | |
| 162 | -add_filter( 'list_cats', 'wptexturize' ); |
|
| 162 | +add_filter('list_cats', 'wptexturize'); |
|
| 163 | 163 | |
| 164 | -add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 ); |
|
| 164 | +add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2); |
|
| 165 | 165 | |
| 166 | -add_filter( 'widget_text', 'balanceTags' ); |
|
| 166 | +add_filter('widget_text', 'balanceTags'); |
|
| 167 | 167 | |
| 168 | -add_filter( 'date_i18n', 'wp_maybe_decline_date' ); |
|
| 168 | +add_filter('date_i18n', 'wp_maybe_decline_date'); |
|
| 169 | 169 | |
| 170 | 170 | // RSS filters |
| 171 | -add_filter( 'the_title_rss', 'strip_tags' ); |
|
| 172 | -add_filter( 'the_title_rss', 'ent2ncr', 8 ); |
|
| 173 | -add_filter( 'the_title_rss', 'esc_html' ); |
|
| 174 | -add_filter( 'the_content_rss', 'ent2ncr', 8 ); |
|
| 175 | -add_filter( 'the_content_feed', 'wp_staticize_emoji' ); |
|
| 176 | -add_filter( 'the_content_feed', '_oembed_filter_feed_content' ); |
|
| 177 | -add_filter( 'the_excerpt_rss', 'convert_chars' ); |
|
| 178 | -add_filter( 'the_excerpt_rss', 'ent2ncr', 8 ); |
|
| 179 | -add_filter( 'comment_author_rss', 'ent2ncr', 8 ); |
|
| 180 | -add_filter( 'comment_text_rss', 'ent2ncr', 8 ); |
|
| 181 | -add_filter( 'comment_text_rss', 'esc_html' ); |
|
| 182 | -add_filter( 'comment_text_rss', 'wp_staticize_emoji' ); |
|
| 183 | -add_filter( 'bloginfo_rss', 'ent2ncr', 8 ); |
|
| 184 | -add_filter( 'the_author', 'ent2ncr', 8 ); |
|
| 185 | -add_filter( 'the_guid', 'esc_url' ); |
|
| 171 | +add_filter('the_title_rss', 'strip_tags'); |
|
| 172 | +add_filter('the_title_rss', 'ent2ncr', 8); |
|
| 173 | +add_filter('the_title_rss', 'esc_html'); |
|
| 174 | +add_filter('the_content_rss', 'ent2ncr', 8); |
|
| 175 | +add_filter('the_content_feed', 'wp_staticize_emoji'); |
|
| 176 | +add_filter('the_content_feed', '_oembed_filter_feed_content'); |
|
| 177 | +add_filter('the_excerpt_rss', 'convert_chars'); |
|
| 178 | +add_filter('the_excerpt_rss', 'ent2ncr', 8); |
|
| 179 | +add_filter('comment_author_rss', 'ent2ncr', 8); |
|
| 180 | +add_filter('comment_text_rss', 'ent2ncr', 8); |
|
| 181 | +add_filter('comment_text_rss', 'esc_html'); |
|
| 182 | +add_filter('comment_text_rss', 'wp_staticize_emoji'); |
|
| 183 | +add_filter('bloginfo_rss', 'ent2ncr', 8); |
|
| 184 | +add_filter('the_author', 'ent2ncr', 8); |
|
| 185 | +add_filter('the_guid', 'esc_url'); |
|
| 186 | 186 | |
| 187 | 187 | // Email filters |
| 188 | -add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); |
|
| 188 | +add_filter('wp_mail', 'wp_staticize_emoji_for_email'); |
|
| 189 | 189 | |
| 190 | 190 | // Misc filters |
| 191 | -add_filter( 'option_ping_sites', 'privacy_ping_filter' ); |
|
| 192 | -add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop |
|
| 193 | -add_filter( 'option_blog_charset', '_canonical_charset' ); |
|
| 194 | -add_filter( 'option_home', '_config_wp_home' ); |
|
| 195 | -add_filter( 'option_siteurl', '_config_wp_siteurl' ); |
|
| 196 | -add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); |
|
| 197 | -add_filter( 'teeny_mce_before_init', '_mce_set_direction' ); |
|
| 198 | -add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); |
|
| 199 | -add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); |
|
| 200 | -add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); |
|
| 201 | -add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); |
|
| 202 | -add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); |
|
| 203 | -add_filter( 'comment_email', 'antispambot' ); |
|
| 204 | -add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); |
|
| 205 | -add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); |
|
| 206 | -add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2); |
|
| 207 | -add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); |
|
| 208 | -add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); |
|
| 209 | -add_filter( 'editable_slug', 'urldecode' ); |
|
| 210 | -add_filter( 'editable_slug', 'esc_textarea' ); |
|
| 211 | -add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); |
|
| 212 | -add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri' ); |
|
| 213 | -add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' ); |
|
| 214 | -add_filter( 'title_save_pre', 'trim' ); |
|
| 215 | - |
|
| 216 | -add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); |
|
| 191 | +add_filter('option_ping_sites', 'privacy_ping_filter'); |
|
| 192 | +add_filter('option_blog_charset', '_wp_specialchars'); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop |
|
| 193 | +add_filter('option_blog_charset', '_canonical_charset'); |
|
| 194 | +add_filter('option_home', '_config_wp_home'); |
|
| 195 | +add_filter('option_siteurl', '_config_wp_siteurl'); |
|
| 196 | +add_filter('tiny_mce_before_init', '_mce_set_direction'); |
|
| 197 | +add_filter('teeny_mce_before_init', '_mce_set_direction'); |
|
| 198 | +add_filter('pre_kses', 'wp_pre_kses_less_than'); |
|
| 199 | +add_filter('sanitize_title', 'sanitize_title_with_dashes', 10, 3); |
|
| 200 | +add_action('check_comment_flood', 'check_comment_flood_db', 10, 3); |
|
| 201 | +add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3); |
|
| 202 | +add_filter('pre_comment_content', 'wp_rel_nofollow', 15); |
|
| 203 | +add_filter('comment_email', 'antispambot'); |
|
| 204 | +add_filter('option_tag_base', '_wp_filter_taxonomy_base'); |
|
| 205 | +add_filter('option_category_base', '_wp_filter_taxonomy_base'); |
|
| 206 | +add_filter('the_posts', '_close_comments_for_old_posts', 10, 2); |
|
| 207 | +add_filter('comments_open', '_close_comments_for_old_post', 10, 2); |
|
| 208 | +add_filter('pings_open', '_close_comments_for_old_post', 10, 2); |
|
| 209 | +add_filter('editable_slug', 'urldecode'); |
|
| 210 | +add_filter('editable_slug', 'esc_textarea'); |
|
| 211 | +add_filter('nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'); |
|
| 212 | +add_filter('pingback_ping_source_uri', 'pingback_ping_source_uri'); |
|
| 213 | +add_filter('xmlrpc_pingback_error', 'xmlrpc_pingback_error'); |
|
| 214 | +add_filter('title_save_pre', 'trim'); |
|
| 215 | + |
|
| 216 | +add_filter('http_request_host_is_external', 'allowed_http_request_hosts', 10, 2); |
|
| 217 | 217 | |
| 218 | 218 | // REST API filters. |
| 219 | -add_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); |
|
| 220 | -add_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); |
|
| 221 | -add_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); |
|
| 222 | -add_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); |
|
| 223 | -add_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); |
|
| 224 | -add_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); |
|
| 225 | -add_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); |
|
| 226 | -add_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); |
|
| 227 | -add_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); |
|
| 219 | +add_action('xmlrpc_rsd_apis', 'rest_output_rsd'); |
|
| 220 | +add_action('wp_head', 'rest_output_link_wp_head', 10, 0); |
|
| 221 | +add_action('template_redirect', 'rest_output_link_header', 11, 0); |
|
| 222 | +add_action('auth_cookie_malformed', 'rest_cookie_collect_status'); |
|
| 223 | +add_action('auth_cookie_expired', 'rest_cookie_collect_status'); |
|
| 224 | +add_action('auth_cookie_bad_username', 'rest_cookie_collect_status'); |
|
| 225 | +add_action('auth_cookie_bad_hash', 'rest_cookie_collect_status'); |
|
| 226 | +add_action('auth_cookie_valid', 'rest_cookie_collect_status'); |
|
| 227 | +add_filter('rest_authentication_errors', 'rest_cookie_check_errors', 100); |
|
| 228 | 228 | |
| 229 | 229 | // Actions |
| 230 | -add_action( 'wp_head', '_wp_render_title_tag', 1 ); |
|
| 231 | -add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); |
|
| 232 | -add_action( 'wp_head', 'wp_resource_hints', 2 ); |
|
| 233 | -add_action( 'wp_head', 'feed_links', 2 ); |
|
| 234 | -add_action( 'wp_head', 'feed_links_extra', 3 ); |
|
| 235 | -add_action( 'wp_head', 'rsd_link' ); |
|
| 236 | -add_action( 'wp_head', 'wlwmanifest_link' ); |
|
| 237 | -add_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); |
|
| 238 | -add_action( 'wp_head', 'locale_stylesheet' ); |
|
| 239 | -add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); |
|
| 240 | -add_action( 'wp_head', 'noindex', 1 ); |
|
| 241 | -add_action( 'wp_head', 'print_emoji_detection_script', 7 ); |
|
| 242 | -add_action( 'wp_head', 'wp_print_styles', 8 ); |
|
| 243 | -add_action( 'wp_head', 'wp_print_head_scripts', 9 ); |
|
| 244 | -add_action( 'wp_head', 'wp_generator' ); |
|
| 245 | -add_action( 'wp_head', 'rel_canonical' ); |
|
| 246 | -add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); |
|
| 247 | -add_action( 'wp_head', 'wp_site_icon', 99 ); |
|
| 248 | -add_action( 'wp_footer', 'wp_print_footer_scripts', 20 ); |
|
| 249 | -add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 ); |
|
| 250 | -add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); |
|
| 251 | -add_action( 'init', 'check_theme_switched', 99 ); |
|
| 252 | -add_action( 'after_switch_theme', '_wp_sidebars_changed' ); |
|
| 253 | -add_action( 'wp_print_styles', 'print_emoji_styles' ); |
|
| 254 | - |
|
| 255 | -if ( isset( $_GET['replytocom'] ) ) |
|
| 256 | - add_action( 'wp_head', 'wp_no_robots' ); |
|
| 230 | +add_action('wp_head', '_wp_render_title_tag', 1); |
|
| 231 | +add_action('wp_head', 'wp_enqueue_scripts', 1); |
|
| 232 | +add_action('wp_head', 'wp_resource_hints', 2); |
|
| 233 | +add_action('wp_head', 'feed_links', 2); |
|
| 234 | +add_action('wp_head', 'feed_links_extra', 3); |
|
| 235 | +add_action('wp_head', 'rsd_link'); |
|
| 236 | +add_action('wp_head', 'wlwmanifest_link'); |
|
| 237 | +add_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); |
|
| 238 | +add_action('wp_head', 'locale_stylesheet'); |
|
| 239 | +add_action('publish_future_post', 'check_and_publish_future_post', 10, 1); |
|
| 240 | +add_action('wp_head', 'noindex', 1); |
|
| 241 | +add_action('wp_head', 'print_emoji_detection_script', 7); |
|
| 242 | +add_action('wp_head', 'wp_print_styles', 8); |
|
| 243 | +add_action('wp_head', 'wp_print_head_scripts', 9); |
|
| 244 | +add_action('wp_head', 'wp_generator'); |
|
| 245 | +add_action('wp_head', 'rel_canonical'); |
|
| 246 | +add_action('wp_head', 'wp_shortlink_wp_head', 10, 0); |
|
| 247 | +add_action('wp_head', 'wp_site_icon', 99); |
|
| 248 | +add_action('wp_footer', 'wp_print_footer_scripts', 20); |
|
| 249 | +add_action('template_redirect', 'wp_shortlink_header', 11, 0); |
|
| 250 | +add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
| 251 | +add_action('init', 'check_theme_switched', 99); |
|
| 252 | +add_action('after_switch_theme', '_wp_sidebars_changed'); |
|
| 253 | +add_action('wp_print_styles', 'print_emoji_styles'); |
|
| 254 | + |
|
| 255 | +if (isset($_GET['replytocom'])) |
|
| 256 | + add_action('wp_head', 'wp_no_robots'); |
|
| 257 | 257 | |
| 258 | 258 | // Login actions |
| 259 | -add_filter( 'login_head', 'wp_resource_hints', 8 ); |
|
| 260 | -add_action( 'login_head', 'wp_print_head_scripts', 9 ); |
|
| 261 | -add_action( 'login_head', 'print_admin_styles', 9 ); |
|
| 262 | -add_action( 'login_head', 'wp_site_icon', 99 ); |
|
| 263 | -add_action( 'login_footer', 'wp_print_footer_scripts', 20 ); |
|
| 264 | -add_action( 'login_init', 'send_frame_options_header', 10, 0 ); |
|
| 259 | +add_filter('login_head', 'wp_resource_hints', 8); |
|
| 260 | +add_action('login_head', 'wp_print_head_scripts', 9); |
|
| 261 | +add_action('login_head', 'print_admin_styles', 9); |
|
| 262 | +add_action('login_head', 'wp_site_icon', 99); |
|
| 263 | +add_action('login_footer', 'wp_print_footer_scripts', 20); |
|
| 264 | +add_action('login_init', 'send_frame_options_header', 10, 0); |
|
| 265 | 265 | |
| 266 | 266 | // Feed Generator Tags |
| 267 | -foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) { |
|
| 268 | - add_action( $action, 'the_generator' ); |
|
| 267 | +foreach (array('rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head') as $action) { |
|
| 268 | + add_action($action, 'the_generator'); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Feed Site Icon |
| 272 | -add_action( 'atom_head', 'atom_site_icon' ); |
|
| 273 | -add_action( 'rss2_head', 'rss2_site_icon' ); |
|
| 272 | +add_action('atom_head', 'atom_site_icon'); |
|
| 273 | +add_action('rss2_head', 'rss2_site_icon'); |
|
| 274 | 274 | |
| 275 | 275 | |
| 276 | 276 | // WP Cron |
| 277 | -if ( !defined( 'DOING_CRON' ) ) |
|
| 278 | - add_action( 'init', 'wp_cron' ); |
|
| 277 | +if ( ! defined('DOING_CRON')) |
|
| 278 | + add_action('init', 'wp_cron'); |
|
| 279 | 279 | |
| 280 | 280 | // 2 Actions 2 Furious |
| 281 | -add_action( 'do_feed_rdf', 'do_feed_rdf', 10, 1 ); |
|
| 282 | -add_action( 'do_feed_rss', 'do_feed_rss', 10, 1 ); |
|
| 283 | -add_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 ); |
|
| 284 | -add_action( 'do_feed_atom', 'do_feed_atom', 10, 1 ); |
|
| 285 | -add_action( 'do_pings', 'do_all_pings', 10, 1 ); |
|
| 286 | -add_action( 'do_robots', 'do_robots' ); |
|
| 287 | -add_action( 'set_comment_cookies', 'wp_set_comment_cookies', 10, 2 ); |
|
| 288 | -add_action( 'sanitize_comment_cookies', 'sanitize_comment_cookies' ); |
|
| 289 | -add_action( 'admin_print_scripts', 'print_emoji_detection_script' ); |
|
| 290 | -add_action( 'admin_print_scripts', 'print_head_scripts', 20 ); |
|
| 291 | -add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' ); |
|
| 292 | -add_action( 'admin_print_styles', 'print_emoji_styles' ); |
|
| 293 | -add_action( 'admin_print_styles', 'print_admin_styles', 20 ); |
|
| 294 | -add_action( 'init', 'smilies_init', 5 ); |
|
| 295 | -add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); |
|
| 296 | -add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); |
|
| 297 | -add_action( 'shutdown', 'wp_ob_end_flush_all', 1 ); |
|
| 281 | +add_action('do_feed_rdf', 'do_feed_rdf', 10, 1); |
|
| 282 | +add_action('do_feed_rss', 'do_feed_rss', 10, 1); |
|
| 283 | +add_action('do_feed_rss2', 'do_feed_rss2', 10, 1); |
|
| 284 | +add_action('do_feed_atom', 'do_feed_atom', 10, 1); |
|
| 285 | +add_action('do_pings', 'do_all_pings', 10, 1); |
|
| 286 | +add_action('do_robots', 'do_robots'); |
|
| 287 | +add_action('set_comment_cookies', 'wp_set_comment_cookies', 10, 2); |
|
| 288 | +add_action('sanitize_comment_cookies', 'sanitize_comment_cookies'); |
|
| 289 | +add_action('admin_print_scripts', 'print_emoji_detection_script'); |
|
| 290 | +add_action('admin_print_scripts', 'print_head_scripts', 20); |
|
| 291 | +add_action('admin_print_footer_scripts', '_wp_footer_scripts'); |
|
| 292 | +add_action('admin_print_styles', 'print_emoji_styles'); |
|
| 293 | +add_action('admin_print_styles', 'print_admin_styles', 20); |
|
| 294 | +add_action('init', 'smilies_init', 5); |
|
| 295 | +add_action('plugins_loaded', 'wp_maybe_load_widgets', 0); |
|
| 296 | +add_action('plugins_loaded', 'wp_maybe_load_embeds', 0); |
|
| 297 | +add_action('shutdown', 'wp_ob_end_flush_all', 1); |
|
| 298 | 298 | // Create a revision whenever a post is updated. |
| 299 | -add_action( 'post_updated', 'wp_save_post_revision', 10, 1 ); |
|
| 300 | -add_action( 'publish_post', '_publish_post_hook', 5, 1 ); |
|
| 301 | -add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); |
|
| 302 | -add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 ); |
|
| 303 | -add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); |
|
| 304 | -add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' ); |
|
| 305 | -add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' ); |
|
| 306 | -add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); |
|
| 307 | -add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' ); |
|
| 308 | -add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' ); |
|
| 309 | -add_action( 'welcome_panel', 'wp_welcome_panel' ); |
|
| 299 | +add_action('post_updated', 'wp_save_post_revision', 10, 1); |
|
| 300 | +add_action('publish_post', '_publish_post_hook', 5, 1); |
|
| 301 | +add_action('transition_post_status', '_transition_post_status', 5, 3); |
|
| 302 | +add_action('transition_post_status', '_update_term_count_on_transition_post_status', 10, 3); |
|
| 303 | +add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce'); |
|
| 304 | +add_action('wp_scheduled_delete', 'wp_scheduled_delete'); |
|
| 305 | +add_action('wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts'); |
|
| 306 | +add_action('admin_init', 'send_frame_options_header', 10, 0); |
|
| 307 | +add_action('importer_scheduled_cleanup', 'wp_delete_attachment'); |
|
| 308 | +add_action('upgrader_scheduled_cleanup', 'wp_delete_attachment'); |
|
| 309 | +add_action('welcome_panel', 'wp_welcome_panel'); |
|
| 310 | 310 | |
| 311 | 311 | // Navigation menu actions |
| 312 | -add_action( 'delete_post', '_wp_delete_post_menu_item' ); |
|
| 313 | -add_action( 'delete_term', '_wp_delete_tax_menu_item', 10, 3 ); |
|
| 314 | -add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 ); |
|
| 312 | +add_action('delete_post', '_wp_delete_post_menu_item'); |
|
| 313 | +add_action('delete_term', '_wp_delete_tax_menu_item', 10, 3); |
|
| 314 | +add_action('transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3); |
|
| 315 | 315 | |
| 316 | 316 | // Post Thumbnail CSS class filtering |
| 317 | -add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' ); |
|
| 318 | -add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove' ); |
|
| 317 | +add_action('begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'); |
|
| 318 | +add_action('end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove'); |
|
| 319 | 319 | |
| 320 | 320 | // Redirect Old Slugs |
| 321 | -add_action( 'template_redirect', 'wp_old_slug_redirect' ); |
|
| 322 | -add_action( 'post_updated', 'wp_check_for_changed_slugs', 12, 3 ); |
|
| 323 | -add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 ); |
|
| 321 | +add_action('template_redirect', 'wp_old_slug_redirect'); |
|
| 322 | +add_action('post_updated', 'wp_check_for_changed_slugs', 12, 3); |
|
| 323 | +add_action('attachment_updated', 'wp_check_for_changed_slugs', 12, 3); |
|
| 324 | 324 | |
| 325 | 325 | // Nonce check for Post Previews |
| 326 | -add_action( 'init', '_show_post_preview' ); |
|
| 326 | +add_action('init', '_show_post_preview'); |
|
| 327 | 327 | |
| 328 | 328 | // Output JS to reset window.name for previews |
| 329 | -add_action( 'wp_head', 'wp_post_preview_js', 1 ); |
|
| 329 | +add_action('wp_head', 'wp_post_preview_js', 1); |
|
| 330 | 330 | |
| 331 | 331 | // Timezone |
| 332 | -add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' ); |
|
| 332 | +add_filter('pre_option_gmt_offset', 'wp_timezone_override_offset'); |
|
| 333 | 333 | |
| 334 | 334 | // Admin Color Schemes |
| 335 | -add_action( 'admin_init', 'register_admin_color_schemes', 1); |
|
| 336 | -add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); |
|
| 335 | +add_action('admin_init', 'register_admin_color_schemes', 1); |
|
| 336 | +add_action('admin_color_scheme_picker', 'admin_color_scheme_picker'); |
|
| 337 | 337 | |
| 338 | 338 | // If the upgrade hasn't run yet, assume link manager is used. |
| 339 | -add_filter( 'default_option_link_manager_enabled', '__return_true' ); |
|
| 339 | +add_filter('default_option_link_manager_enabled', '__return_true'); |
|
| 340 | 340 | |
| 341 | 341 | // This option no longer exists; tell plugins we always support auto-embedding. |
| 342 | -add_filter( 'default_option_embed_autourls', '__return_true' ); |
|
| 342 | +add_filter('default_option_embed_autourls', '__return_true'); |
|
| 343 | 343 | |
| 344 | 344 | // Default settings for heartbeat |
| 345 | -add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' ); |
|
| 345 | +add_filter('heartbeat_settings', 'wp_heartbeat_settings'); |
|
| 346 | 346 | |
| 347 | 347 | // Check if the user is logged out |
| 348 | -add_action( 'admin_enqueue_scripts', 'wp_auth_check_load' ); |
|
| 349 | -add_filter( 'heartbeat_send', 'wp_auth_check' ); |
|
| 350 | -add_filter( 'heartbeat_nopriv_send', 'wp_auth_check' ); |
|
| 348 | +add_action('admin_enqueue_scripts', 'wp_auth_check_load'); |
|
| 349 | +add_filter('heartbeat_send', 'wp_auth_check'); |
|
| 350 | +add_filter('heartbeat_nopriv_send', 'wp_auth_check'); |
|
| 351 | 351 | |
| 352 | 352 | // Default authentication filters |
| 353 | -add_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); |
|
| 354 | -add_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 ); |
|
| 355 | -add_filter( 'authenticate', 'wp_authenticate_spam_check', 99 ); |
|
| 356 | -add_filter( 'determine_current_user', 'wp_validate_auth_cookie' ); |
|
| 357 | -add_filter( 'determine_current_user', 'wp_validate_logged_in_cookie', 20 ); |
|
| 353 | +add_filter('authenticate', 'wp_authenticate_username_password', 20, 3); |
|
| 354 | +add_filter('authenticate', 'wp_authenticate_email_password', 20, 3); |
|
| 355 | +add_filter('authenticate', 'wp_authenticate_spam_check', 99); |
|
| 356 | +add_filter('determine_current_user', 'wp_validate_auth_cookie'); |
|
| 357 | +add_filter('determine_current_user', 'wp_validate_logged_in_cookie', 20); |
|
| 358 | 358 | |
| 359 | 359 | // Split term updates. |
| 360 | -add_action( 'admin_init', '_wp_check_for_scheduled_split_terms' ); |
|
| 361 | -add_action( 'split_shared_term', '_wp_check_split_default_terms', 10, 4 ); |
|
| 362 | -add_action( 'split_shared_term', '_wp_check_split_terms_in_menus', 10, 4 ); |
|
| 363 | -add_action( 'split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4 ); |
|
| 364 | -add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' ); |
|
| 360 | +add_action('admin_init', '_wp_check_for_scheduled_split_terms'); |
|
| 361 | +add_action('split_shared_term', '_wp_check_split_default_terms', 10, 4); |
|
| 362 | +add_action('split_shared_term', '_wp_check_split_terms_in_menus', 10, 4); |
|
| 363 | +add_action('split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4); |
|
| 364 | +add_action('wp_split_shared_term_batch', '_wp_batch_split_terms'); |
|
| 365 | 365 | |
| 366 | 366 | // Email notifications. |
| 367 | -add_action( 'comment_post', 'wp_new_comment_notify_moderator' ); |
|
| 368 | -add_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); |
|
| 369 | -add_action( 'after_password_reset', 'wp_password_change_notification' ); |
|
| 370 | -add_action( 'register_new_user', 'wp_send_new_user_notifications' ); |
|
| 371 | -add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); |
|
| 367 | +add_action('comment_post', 'wp_new_comment_notify_moderator'); |
|
| 368 | +add_action('comment_post', 'wp_new_comment_notify_postauthor'); |
|
| 369 | +add_action('after_password_reset', 'wp_password_change_notification'); |
|
| 370 | +add_action('register_new_user', 'wp_send_new_user_notifications'); |
|
| 371 | +add_action('edit_user_created_user', 'wp_send_new_user_notifications', 10, 2); |
|
| 372 | 372 | |
| 373 | 373 | // REST API actions. |
| 374 | -add_action( 'init', 'rest_api_init' ); |
|
| 375 | -add_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); |
|
| 376 | -add_action( 'parse_request', 'rest_api_loaded' ); |
|
| 374 | +add_action('init', 'rest_api_init'); |
|
| 375 | +add_action('rest_api_init', 'rest_api_default_filters', 10, 1); |
|
| 376 | +add_action('parse_request', 'rest_api_loaded'); |
|
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | 379 | * Filters formerly mixed into wp-includes |
| 380 | 380 | */ |
| 381 | 381 | // Theme |
| 382 | -add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); |
|
| 383 | -add_action( 'wp_head', '_custom_logo_header_styles' ); |
|
| 384 | -add_action( 'plugins_loaded', '_wp_customize_include' ); |
|
| 385 | -add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); |
|
| 386 | -add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); |
|
| 382 | +add_action('wp_loaded', '_custom_header_background_just_in_time'); |
|
| 383 | +add_action('wp_head', '_custom_logo_header_styles'); |
|
| 384 | +add_action('plugins_loaded', '_wp_customize_include'); |
|
| 385 | +add_action('admin_enqueue_scripts', '_wp_customize_loader_settings'); |
|
| 386 | +add_action('delete_attachment', '_delete_attachment_theme_mod'); |
|
| 387 | 387 | |
| 388 | 388 | // Calendar widget cache |
| 389 | -add_action( 'save_post', 'delete_get_calendar_cache' ); |
|
| 390 | -add_action( 'delete_post', 'delete_get_calendar_cache' ); |
|
| 391 | -add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); |
|
| 392 | -add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); |
|
| 389 | +add_action('save_post', 'delete_get_calendar_cache'); |
|
| 390 | +add_action('delete_post', 'delete_get_calendar_cache'); |
|
| 391 | +add_action('update_option_start_of_week', 'delete_get_calendar_cache'); |
|
| 392 | +add_action('update_option_gmt_offset', 'delete_get_calendar_cache'); |
|
| 393 | 393 | |
| 394 | 394 | // Author |
| 395 | -add_action( 'transition_post_status', '__clear_multi_author_cache' ); |
|
| 395 | +add_action('transition_post_status', '__clear_multi_author_cache'); |
|
| 396 | 396 | |
| 397 | 397 | // Post |
| 398 | -add_action( 'init', 'create_initial_post_types', 0 ); // highest priority |
|
| 399 | -add_action( 'admin_menu', '_add_post_type_submenus' ); |
|
| 400 | -add_action( 'before_delete_post', '_reset_front_page_settings_for_post' ); |
|
| 401 | -add_action( 'wp_trash_post', '_reset_front_page_settings_for_post' ); |
|
| 398 | +add_action('init', 'create_initial_post_types', 0); // highest priority |
|
| 399 | +add_action('admin_menu', '_add_post_type_submenus'); |
|
| 400 | +add_action('before_delete_post', '_reset_front_page_settings_for_post'); |
|
| 401 | +add_action('wp_trash_post', '_reset_front_page_settings_for_post'); |
|
| 402 | 402 | |
| 403 | 403 | // Post Formats |
| 404 | -add_filter( 'request', '_post_format_request' ); |
|
| 405 | -add_filter( 'term_link', '_post_format_link', 10, 3 ); |
|
| 406 | -add_filter( 'get_post_format', '_post_format_get_term' ); |
|
| 407 | -add_filter( 'get_terms', '_post_format_get_terms', 10, 3 ); |
|
| 408 | -add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); |
|
| 404 | +add_filter('request', '_post_format_request'); |
|
| 405 | +add_filter('term_link', '_post_format_link', 10, 3); |
|
| 406 | +add_filter('get_post_format', '_post_format_get_term'); |
|
| 407 | +add_filter('get_terms', '_post_format_get_terms', 10, 3); |
|
| 408 | +add_filter('wp_get_object_terms', '_post_format_wp_get_object_terms'); |
|
| 409 | 409 | |
| 410 | 410 | // KSES |
| 411 | -add_action( 'init', 'kses_init' ); |
|
| 412 | -add_action( 'set_current_user', 'kses_init' ); |
|
| 411 | +add_action('init', 'kses_init'); |
|
| 412 | +add_action('set_current_user', 'kses_init'); |
|
| 413 | 413 | |
| 414 | 414 | // Script Loader |
| 415 | -add_action( 'wp_default_scripts', 'wp_default_scripts' ); |
|
| 416 | -add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); |
|
| 417 | -add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); |
|
| 418 | -add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); |
|
| 419 | -add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); |
|
| 420 | -add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); |
|
| 415 | +add_action('wp_default_scripts', 'wp_default_scripts'); |
|
| 416 | +add_action('wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000); |
|
| 417 | +add_action('admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000); |
|
| 418 | +add_filter('wp_print_scripts', 'wp_just_in_time_script_localization'); |
|
| 419 | +add_filter('print_scripts_array', 'wp_prototype_before_jquery'); |
|
| 420 | +add_filter('customize_controls_print_styles', 'wp_resource_hints', 1); |
|
| 421 | 421 | |
| 422 | -add_action( 'wp_default_styles', 'wp_default_styles' ); |
|
| 423 | -add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); |
|
| 422 | +add_action('wp_default_styles', 'wp_default_styles'); |
|
| 423 | +add_filter('style_loader_src', 'wp_style_loader_src', 10, 2); |
|
| 424 | 424 | |
| 425 | 425 | // Taxonomy |
| 426 | -add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority |
|
| 426 | +add_action('init', 'create_initial_taxonomies', 0); // highest priority |
|
| 427 | 427 | |
| 428 | 428 | // Canonical |
| 429 | -add_action( 'template_redirect', 'redirect_canonical' ); |
|
| 430 | -add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 ); |
|
| 429 | +add_action('template_redirect', 'redirect_canonical'); |
|
| 430 | +add_action('template_redirect', 'wp_redirect_admin_locations', 1000); |
|
| 431 | 431 | |
| 432 | 432 | // Shortcodes |
| 433 | -add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop() |
|
| 433 | +add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() |
|
| 434 | 434 | |
| 435 | 435 | // Media |
| 436 | -add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' ); |
|
| 437 | -add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' ); |
|
| 436 | +add_action('wp_playlist_scripts', 'wp_playlist_scripts'); |
|
| 437 | +add_action('customize_controls_enqueue_scripts', 'wp_plupload_default_settings'); |
|
| 438 | 438 | |
| 439 | 439 | // Nav menu |
| 440 | -add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); |
|
| 440 | +add_filter('nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2); |
|
| 441 | 441 | |
| 442 | 442 | // Widgets |
| 443 | -add_action( 'init', 'wp_widgets_init', 1 ); |
|
| 443 | +add_action('init', 'wp_widgets_init', 1); |
|
| 444 | 444 | |
| 445 | 445 | // Admin Bar |
| 446 | 446 | // Don't remove. Wrong way to disable. |
| 447 | -add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); |
|
| 448 | -add_action( 'admin_init', '_wp_admin_bar_init' ); |
|
| 449 | -add_action( 'before_signup_header', '_wp_admin_bar_init' ); |
|
| 450 | -add_action( 'activate_header', '_wp_admin_bar_init' ); |
|
| 451 | -add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); |
|
| 452 | -add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); |
|
| 447 | +add_action('template_redirect', '_wp_admin_bar_init', 0); |
|
| 448 | +add_action('admin_init', '_wp_admin_bar_init'); |
|
| 449 | +add_action('before_signup_header', '_wp_admin_bar_init'); |
|
| 450 | +add_action('activate_header', '_wp_admin_bar_init'); |
|
| 451 | +add_action('wp_footer', 'wp_admin_bar_render', 1000); |
|
| 452 | +add_action('in_admin_header', 'wp_admin_bar_render', 0); |
|
| 453 | 453 | |
| 454 | 454 | // Former admin filters that can also be hooked on the front end |
| 455 | -add_action( 'media_buttons', 'media_buttons' ); |
|
| 456 | -add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); |
|
| 457 | -add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 ); |
|
| 455 | +add_action('media_buttons', 'media_buttons'); |
|
| 456 | +add_filter('image_send_to_editor', 'image_add_caption', 20, 8); |
|
| 457 | +add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); |
|
| 458 | 458 | |
| 459 | 459 | // Embeds |
| 460 | -add_action( 'rest_api_init', 'wp_oembed_register_route' ); |
|
| 461 | -add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); |
|
| 462 | - |
|
| 463 | -add_action( 'wp_head', 'wp_oembed_add_discovery_links' ); |
|
| 464 | -add_action( 'wp_head', 'wp_oembed_add_host_js' ); |
|
| 465 | - |
|
| 466 | -add_action( 'embed_head', 'enqueue_embed_scripts', 1 ); |
|
| 467 | -add_action( 'embed_head', 'print_emoji_detection_script' ); |
|
| 468 | -add_action( 'embed_head', 'print_embed_styles' ); |
|
| 469 | -add_action( 'embed_head', 'wp_print_head_scripts', 20 ); |
|
| 470 | -add_action( 'embed_head', 'wp_print_styles', 20 ); |
|
| 471 | -add_action( 'embed_head', 'wp_no_robots' ); |
|
| 472 | -add_action( 'embed_head', 'rel_canonical' ); |
|
| 473 | -add_action( 'embed_head', 'locale_stylesheet', 30 ); |
|
| 474 | - |
|
| 475 | -add_action( 'embed_content_meta', 'print_embed_comments_button' ); |
|
| 476 | -add_action( 'embed_content_meta', 'print_embed_sharing_button' ); |
|
| 477 | - |
|
| 478 | -add_action( 'embed_footer', 'print_embed_sharing_dialog' ); |
|
| 479 | -add_action( 'embed_footer', 'print_embed_scripts' ); |
|
| 480 | -add_action( 'embed_footer', 'wp_print_footer_scripts', 20 ); |
|
| 481 | - |
|
| 482 | -add_filter( 'excerpt_more', 'wp_embed_excerpt_more', 20 ); |
|
| 483 | -add_filter( 'the_excerpt_embed', 'wptexturize' ); |
|
| 484 | -add_filter( 'the_excerpt_embed', 'convert_chars' ); |
|
| 485 | -add_filter( 'the_excerpt_embed', 'wpautop' ); |
|
| 486 | -add_filter( 'the_excerpt_embed', 'shortcode_unautop' ); |
|
| 487 | -add_filter( 'the_excerpt_embed', 'wp_embed_excerpt_attachment' ); |
|
| 488 | - |
|
| 489 | -add_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10, 3 ); |
|
| 490 | -add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 ); |
|
| 491 | -add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 ); |
|
| 492 | - |
|
| 493 | -unset( $filter, $action ); |
|
| 460 | +add_action('rest_api_init', 'wp_oembed_register_route'); |
|
| 461 | +add_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4); |
|
| 462 | + |
|
| 463 | +add_action('wp_head', 'wp_oembed_add_discovery_links'); |
|
| 464 | +add_action('wp_head', 'wp_oembed_add_host_js'); |
|
| 465 | + |
|
| 466 | +add_action('embed_head', 'enqueue_embed_scripts', 1); |
|
| 467 | +add_action('embed_head', 'print_emoji_detection_script'); |
|
| 468 | +add_action('embed_head', 'print_embed_styles'); |
|
| 469 | +add_action('embed_head', 'wp_print_head_scripts', 20); |
|
| 470 | +add_action('embed_head', 'wp_print_styles', 20); |
|
| 471 | +add_action('embed_head', 'wp_no_robots'); |
|
| 472 | +add_action('embed_head', 'rel_canonical'); |
|
| 473 | +add_action('embed_head', 'locale_stylesheet', 30); |
|
| 474 | + |
|
| 475 | +add_action('embed_content_meta', 'print_embed_comments_button'); |
|
| 476 | +add_action('embed_content_meta', 'print_embed_sharing_button'); |
|
| 477 | + |
|
| 478 | +add_action('embed_footer', 'print_embed_sharing_dialog'); |
|
| 479 | +add_action('embed_footer', 'print_embed_scripts'); |
|
| 480 | +add_action('embed_footer', 'wp_print_footer_scripts', 20); |
|
| 481 | + |
|
| 482 | +add_filter('excerpt_more', 'wp_embed_excerpt_more', 20); |
|
| 483 | +add_filter('the_excerpt_embed', 'wptexturize'); |
|
| 484 | +add_filter('the_excerpt_embed', 'convert_chars'); |
|
| 485 | +add_filter('the_excerpt_embed', 'wpautop'); |
|
| 486 | +add_filter('the_excerpt_embed', 'shortcode_unautop'); |
|
| 487 | +add_filter('the_excerpt_embed', 'wp_embed_excerpt_attachment'); |
|
| 488 | + |
|
| 489 | +add_filter('oembed_dataparse', 'wp_filter_oembed_result', 10, 3); |
|
| 490 | +add_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4); |
|
| 491 | +add_filter('pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3); |
|
| 492 | + |
|
| 493 | +unset($filter, $action); |
|
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $this->endpoints = array( |
| 92 | 92 | // Meta endpoints. |
| 93 | 93 | '/' => array( |
| 94 | - 'callback' => array( $this, 'get_index' ), |
|
| 94 | + 'callback' => array($this, 'get_index'), |
|
| 95 | 95 | 'methods' => 'GET', |
| 96 | 96 | 'args' => array( |
| 97 | 97 | 'context' => array( |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param WP_Error|null|bool WP_Error if authentication error, null if authentication |
| 138 | 138 | * method wasn't used, true if authentication succeeded. |
| 139 | 139 | */ |
| 140 | - return apply_filters( 'rest_authentication_errors', null ); |
|
| 140 | + return apply_filters('rest_authentication_errors', null); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | * @param WP_Error $error WP_Error instance. |
| 154 | 154 | * @return WP_REST_Response List of associative arrays with code and message keys. |
| 155 | 155 | */ |
| 156 | - protected function error_to_response( $error ) { |
|
| 156 | + protected function error_to_response($error) { |
|
| 157 | 157 | $error_data = $error->get_error_data(); |
| 158 | 158 | |
| 159 | - if ( is_array( $error_data ) && isset( $error_data['status'] ) ) { |
|
| 159 | + if (is_array($error_data) && isset($error_data['status'])) { |
|
| 160 | 160 | $status = $error_data['status']; |
| 161 | 161 | } else { |
| 162 | 162 | $status = 500; |
@@ -164,20 +164,20 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $errors = array(); |
| 166 | 166 | |
| 167 | - foreach ( (array) $error->errors as $code => $messages ) { |
|
| 168 | - foreach ( (array) $messages as $message ) { |
|
| 169 | - $errors[] = array( 'code' => $code, 'message' => $message, 'data' => $error->get_error_data( $code ) ); |
|
| 167 | + foreach ((array) $error->errors as $code => $messages) { |
|
| 168 | + foreach ((array) $messages as $message) { |
|
| 169 | + $errors[] = array('code' => $code, 'message' => $message, 'data' => $error->get_error_data($code)); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $data = $errors[0]; |
| 174 | - if ( count( $errors ) > 1 ) { |
|
| 174 | + if (count($errors) > 1) { |
|
| 175 | 175 | // Remove the primary error. |
| 176 | - array_shift( $errors ); |
|
| 176 | + array_shift($errors); |
|
| 177 | 177 | $data['additional_errors'] = $errors; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $response = new WP_REST_Response( $data, $status ); |
|
| 180 | + $response = new WP_REST_Response($data, $status); |
|
| 181 | 181 | |
| 182 | 182 | return $response; |
| 183 | 183 | } |
@@ -198,14 +198,14 @@ discard block |
||
| 198 | 198 | * @param int $status Optional. HTTP status code to send. Default null. |
| 199 | 199 | * @return string JSON representation of the error |
| 200 | 200 | */ |
| 201 | - protected function json_error( $code, $message, $status = null ) { |
|
| 202 | - if ( $status ) { |
|
| 203 | - $this->set_status( $status ); |
|
| 201 | + protected function json_error($code, $message, $status = null) { |
|
| 202 | + if ($status) { |
|
| 203 | + $this->set_status($status); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - $error = compact( 'code', 'message' ); |
|
| 206 | + $error = compact('code', 'message'); |
|
| 207 | 207 | |
| 208 | - return wp_json_encode( $error ); |
|
| 208 | + return wp_json_encode($error); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | * Default null. |
| 224 | 224 | * @return false|null Null if not served and a HEAD request, false otherwise. |
| 225 | 225 | */ |
| 226 | - public function serve_request( $path = null ) { |
|
| 227 | - $content_type = isset( $_GET['_jsonp'] ) ? 'application/javascript' : 'application/json'; |
|
| 228 | - $this->send_header( 'Content-Type', $content_type . '; charset=' . get_option( 'blog_charset' ) ); |
|
| 229 | - $this->send_header( 'X-Robots-Tag', 'noindex' ); |
|
| 226 | + public function serve_request($path = null) { |
|
| 227 | + $content_type = isset($_GET['_jsonp']) ? 'application/javascript' : 'application/json'; |
|
| 228 | + $this->send_header('Content-Type', $content_type.'; charset='.get_option('blog_charset')); |
|
| 229 | + $this->send_header('X-Robots-Tag', 'noindex'); |
|
| 230 | 230 | |
| 231 | 231 | $api_root = get_rest_url(); |
| 232 | - if ( ! empty( $api_root ) ) { |
|
| 233 | - $this->send_header( 'Link', '<' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"' ); |
|
| 232 | + if ( ! empty($api_root)) { |
|
| 233 | + $this->send_header('Link', '<'.esc_url_raw($api_root).'>; rel="https://api.w.org/"'); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /* |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ |
| 240 | 240 | */ |
| 241 | - $this->send_header( 'X-Content-Type-Options', 'nosniff' ); |
|
| 242 | - $this->send_header( 'Access-Control-Expose-Headers', 'X-WP-Total, X-WP-TotalPages' ); |
|
| 243 | - $this->send_header( 'Access-Control-Allow-Headers', 'Authorization' ); |
|
| 241 | + $this->send_header('X-Content-Type-Options', 'nosniff'); |
|
| 242 | + $this->send_header('Access-Control-Expose-Headers', 'X-WP-Total, X-WP-TotalPages'); |
|
| 243 | + $this->send_header('Access-Control-Allow-Headers', 'Authorization'); |
|
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * Send nocache headers on authenticated requests. |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @param bool $rest_send_nocache_headers Whether to send no-cache headers. |
| 251 | 251 | */ |
| 252 | - $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); |
|
| 253 | - if ( $send_no_cache_headers ) { |
|
| 254 | - foreach ( wp_get_nocache_headers() as $header => $header_value ) { |
|
| 255 | - $this->send_header( $header, $header_value ); |
|
| 252 | + $send_no_cache_headers = apply_filters('rest_send_nocache_headers', is_user_logged_in()); |
|
| 253 | + if ($send_no_cache_headers) { |
|
| 254 | + foreach (wp_get_nocache_headers() as $header => $header_value) { |
|
| 255 | + $this->send_header($header, $header_value); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @param bool $rest_enabled Whether the REST API is enabled. Default true. |
| 265 | 265 | */ |
| 266 | - $enabled = apply_filters( 'rest_enabled', true ); |
|
| 266 | + $enabled = apply_filters('rest_enabled', true); |
|
| 267 | 267 | |
| 268 | 268 | /** |
| 269 | 269 | * Filters whether jsonp is enabled. |
@@ -272,66 +272,66 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @param bool $jsonp_enabled Whether jsonp is enabled. Default true. |
| 274 | 274 | */ |
| 275 | - $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); |
|
| 275 | + $jsonp_enabled = apply_filters('rest_jsonp_enabled', true); |
|
| 276 | 276 | |
| 277 | 277 | $jsonp_callback = null; |
| 278 | 278 | |
| 279 | - if ( ! $enabled ) { |
|
| 280 | - echo $this->json_error( 'rest_disabled', __( 'The REST API is disabled on this site.' ), 404 ); |
|
| 279 | + if ( ! $enabled) { |
|
| 280 | + echo $this->json_error('rest_disabled', __('The REST API is disabled on this site.'), 404); |
|
| 281 | 281 | return false; |
| 282 | 282 | } |
| 283 | - if ( isset( $_GET['_jsonp'] ) ) { |
|
| 284 | - if ( ! $jsonp_enabled ) { |
|
| 285 | - echo $this->json_error( 'rest_callback_disabled', __( 'JSONP support is disabled on this site.' ), 400 ); |
|
| 283 | + if (isset($_GET['_jsonp'])) { |
|
| 284 | + if ( ! $jsonp_enabled) { |
|
| 285 | + echo $this->json_error('rest_callback_disabled', __('JSONP support is disabled on this site.'), 400); |
|
| 286 | 286 | return false; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | $jsonp_callback = $_GET['_jsonp']; |
| 290 | - if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { |
|
| 291 | - echo $this->json_error( 'rest_callback_invalid', __( 'The JSONP callback function is invalid.' ), 400 ); |
|
| 290 | + if ( ! wp_check_jsonp_callback($jsonp_callback)) { |
|
| 291 | + echo $this->json_error('rest_callback_invalid', __('The JSONP callback function is invalid.'), 400); |
|
| 292 | 292 | return false; |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if ( empty( $path ) ) { |
|
| 297 | - if ( isset( $_SERVER['PATH_INFO'] ) ) { |
|
| 296 | + if (empty($path)) { |
|
| 297 | + if (isset($_SERVER['PATH_INFO'])) { |
|
| 298 | 298 | $path = $_SERVER['PATH_INFO']; |
| 299 | 299 | } else { |
| 300 | 300 | $path = '/'; |
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - $request = new WP_REST_Request( $_SERVER['REQUEST_METHOD'], $path ); |
|
| 304 | + $request = new WP_REST_Request($_SERVER['REQUEST_METHOD'], $path); |
|
| 305 | 305 | |
| 306 | - $request->set_query_params( wp_unslash( $_GET ) ); |
|
| 307 | - $request->set_body_params( wp_unslash( $_POST ) ); |
|
| 308 | - $request->set_file_params( $_FILES ); |
|
| 309 | - $request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) ); |
|
| 310 | - $request->set_body( $this->get_raw_data() ); |
|
| 306 | + $request->set_query_params(wp_unslash($_GET)); |
|
| 307 | + $request->set_body_params(wp_unslash($_POST)); |
|
| 308 | + $request->set_file_params($_FILES); |
|
| 309 | + $request->set_headers($this->get_headers(wp_unslash($_SERVER))); |
|
| 310 | + $request->set_body($this->get_raw_data()); |
|
| 311 | 311 | |
| 312 | 312 | /* |
| 313 | 313 | * HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check |
| 314 | 314 | * $_GET['_method']. If that is not set, we check for the HTTP_X_HTTP_METHOD_OVERRIDE |
| 315 | 315 | * header. |
| 316 | 316 | */ |
| 317 | - if ( isset( $_GET['_method'] ) ) { |
|
| 318 | - $request->set_method( $_GET['_method'] ); |
|
| 319 | - } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { |
|
| 320 | - $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); |
|
| 317 | + if (isset($_GET['_method'])) { |
|
| 318 | + $request->set_method($_GET['_method']); |
|
| 319 | + } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { |
|
| 320 | + $request->set_method($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | $result = $this->check_authentication(); |
| 324 | 324 | |
| 325 | - if ( ! is_wp_error( $result ) ) { |
|
| 326 | - $result = $this->dispatch( $request ); |
|
| 325 | + if ( ! is_wp_error($result)) { |
|
| 326 | + $result = $this->dispatch($request); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // Normalize to either WP_Error or WP_REST_Response... |
| 330 | - $result = rest_ensure_response( $result ); |
|
| 330 | + $result = rest_ensure_response($result); |
|
| 331 | 331 | |
| 332 | 332 | // ...then convert WP_Error across. |
| 333 | - if ( is_wp_error( $result ) ) { |
|
| 334 | - $result = $this->error_to_response( $result ); |
|
| 333 | + if (is_wp_error($result)) { |
|
| 334 | + $result = $this->error_to_response($result); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -346,19 +346,19 @@ discard block |
||
| 346 | 346 | * @param WP_REST_Server $this Server instance. |
| 347 | 347 | * @param WP_REST_Request $request Request used to generate the response. |
| 348 | 348 | */ |
| 349 | - $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $request ); |
|
| 349 | + $result = apply_filters('rest_post_dispatch', rest_ensure_response($result), $this, $request); |
|
| 350 | 350 | |
| 351 | 351 | // Wrap the response in an envelope if asked for. |
| 352 | - if ( isset( $_GET['_envelope'] ) ) { |
|
| 353 | - $result = $this->envelope_response( $result, isset( $_GET['_embed'] ) ); |
|
| 352 | + if (isset($_GET['_envelope'])) { |
|
| 353 | + $result = $this->envelope_response($result, isset($_GET['_embed'])); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Send extra data from response objects. |
| 357 | 357 | $headers = $result->get_headers(); |
| 358 | - $this->send_headers( $headers ); |
|
| 358 | + $this->send_headers($headers); |
|
| 359 | 359 | |
| 360 | 360 | $code = $result->get_status(); |
| 361 | - $this->set_status( $code ); |
|
| 361 | + $this->set_status($code); |
|
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | 364 | * Filters whether the request has already been served. |
@@ -374,29 +374,29 @@ discard block |
||
| 374 | 374 | * @param WP_REST_Request $request Request used to generate the response. |
| 375 | 375 | * @param WP_REST_Server $this Server instance. |
| 376 | 376 | */ |
| 377 | - $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); |
|
| 377 | + $served = apply_filters('rest_pre_serve_request', false, $result, $request, $this); |
|
| 378 | 378 | |
| 379 | - if ( ! $served ) { |
|
| 380 | - if ( 'HEAD' === $request->get_method() ) { |
|
| 379 | + if ( ! $served) { |
|
| 380 | + if ('HEAD' === $request->get_method()) { |
|
| 381 | 381 | return null; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | // Embed links inside the request. |
| 385 | - $result = $this->response_to_data( $result, isset( $_GET['_embed'] ) ); |
|
| 385 | + $result = $this->response_to_data($result, isset($_GET['_embed'])); |
|
| 386 | 386 | |
| 387 | - $result = wp_json_encode( $result ); |
|
| 387 | + $result = wp_json_encode($result); |
|
| 388 | 388 | |
| 389 | 389 | $json_error_message = $this->get_json_last_error(); |
| 390 | - if ( $json_error_message ) { |
|
| 391 | - $json_error_obj = new WP_Error( 'rest_encode_error', $json_error_message, array( 'status' => 500 ) ); |
|
| 392 | - $result = $this->error_to_response( $json_error_obj ); |
|
| 393 | - $result = wp_json_encode( $result->data[0] ); |
|
| 390 | + if ($json_error_message) { |
|
| 391 | + $json_error_obj = new WP_Error('rest_encode_error', $json_error_message, array('status' => 500)); |
|
| 392 | + $result = $this->error_to_response($json_error_obj); |
|
| 393 | + $result = wp_json_encode($result->data[0]); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if ( $jsonp_callback ) { |
|
| 396 | + if ($jsonp_callback) { |
|
| 397 | 397 | // Prepend '/**/' to mitigate possible JSONP Flash attacks |
| 398 | 398 | // https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ |
| 399 | - echo '/**/' . $jsonp_callback . '(' . $result . ')'; |
|
| 399 | + echo '/**/'.$jsonp_callback.'('.$result.')'; |
|
| 400 | 400 | } else { |
| 401 | 401 | echo $result; |
| 402 | 402 | } |
@@ -419,20 +419,20 @@ discard block |
||
| 419 | 419 | * @type array [$_embedded] Embeddeds. |
| 420 | 420 | * } |
| 421 | 421 | */ |
| 422 | - public function response_to_data( $response, $embed ) { |
|
| 422 | + public function response_to_data($response, $embed) { |
|
| 423 | 423 | $data = $response->get_data(); |
| 424 | - $links = $this->get_compact_response_links( $response ); |
|
| 424 | + $links = $this->get_compact_response_links($response); |
|
| 425 | 425 | |
| 426 | - if ( ! empty( $links ) ) { |
|
| 426 | + if ( ! empty($links)) { |
|
| 427 | 427 | // Convert links to part of the data. |
| 428 | 428 | $data['_links'] = $links; |
| 429 | 429 | } |
| 430 | - if ( $embed ) { |
|
| 430 | + if ($embed) { |
|
| 431 | 431 | // Determine if this is a numeric array. |
| 432 | - if ( wp_is_numeric_array( $data ) ) { |
|
| 433 | - $data = array_map( array( $this, 'embed_links' ), $data ); |
|
| 432 | + if (wp_is_numeric_array($data)) { |
|
| 433 | + $data = array_map(array($this, 'embed_links'), $data); |
|
| 434 | 434 | } else { |
| 435 | - $data = $this->embed_links( $data ); |
|
| 435 | + $data = $this->embed_links($data); |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
@@ -452,21 +452,21 @@ discard block |
||
| 452 | 452 | * @param WP_REST_Response $response Response to extract links from. |
| 453 | 453 | * @return array Map of link relation to list of link hashes. |
| 454 | 454 | */ |
| 455 | - public static function get_response_links( $response ) { |
|
| 455 | + public static function get_response_links($response) { |
|
| 456 | 456 | $links = $response->get_links(); |
| 457 | - if ( empty( $links ) ) { |
|
| 457 | + if (empty($links)) { |
|
| 458 | 458 | return array(); |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // Convert links to part of the data. |
| 462 | 462 | $data = array(); |
| 463 | - foreach ( $links as $rel => $items ) { |
|
| 464 | - $data[ $rel ] = array(); |
|
| 463 | + foreach ($links as $rel => $items) { |
|
| 464 | + $data[$rel] = array(); |
|
| 465 | 465 | |
| 466 | - foreach ( $items as $item ) { |
|
| 466 | + foreach ($items as $item) { |
|
| 467 | 467 | $attributes = $item['attributes']; |
| 468 | 468 | $attributes['href'] = $item['href']; |
| 469 | - $data[ $rel ][] = $attributes; |
|
| 469 | + $data[$rel][] = $attributes; |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
@@ -486,41 +486,41 @@ discard block |
||
| 486 | 486 | * @param WP_REST_Response $response Response to extract links from. |
| 487 | 487 | * @return array Map of link relation to list of link hashes. |
| 488 | 488 | */ |
| 489 | - public static function get_compact_response_links( $response ) { |
|
| 490 | - $links = self::get_response_links( $response ); |
|
| 489 | + public static function get_compact_response_links($response) { |
|
| 490 | + $links = self::get_response_links($response); |
|
| 491 | 491 | |
| 492 | - if ( empty( $links ) ) { |
|
| 492 | + if (empty($links)) { |
|
| 493 | 493 | return array(); |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $curies = $response->get_curies(); |
| 497 | 497 | $used_curies = array(); |
| 498 | 498 | |
| 499 | - foreach ( $links as $rel => $items ) { |
|
| 499 | + foreach ($links as $rel => $items) { |
|
| 500 | 500 | |
| 501 | 501 | // Convert $rel URIs to their compact versions if they exist. |
| 502 | - foreach ( $curies as $curie ) { |
|
| 503 | - $href_prefix = substr( $curie['href'], 0, strpos( $curie['href'], '{rel}' ) ); |
|
| 504 | - if ( strpos( $rel, $href_prefix ) !== 0 ) { |
|
| 502 | + foreach ($curies as $curie) { |
|
| 503 | + $href_prefix = substr($curie['href'], 0, strpos($curie['href'], '{rel}')); |
|
| 504 | + if (strpos($rel, $href_prefix) !== 0) { |
|
| 505 | 505 | continue; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | // Relation now changes from '$uri' to '$curie:$relation' |
| 509 | - $rel_regex = str_replace( '\{rel\}', '(.+)', preg_quote( $curie['href'], '!' ) ); |
|
| 510 | - preg_match( '!' . $rel_regex . '!', $rel, $matches ); |
|
| 511 | - if ( $matches ) { |
|
| 512 | - $new_rel = $curie['name'] . ':' . $matches[1]; |
|
| 513 | - $used_curies[ $curie['name'] ] = $curie; |
|
| 514 | - $links[ $new_rel ] = $items; |
|
| 515 | - unset( $links[ $rel ] ); |
|
| 509 | + $rel_regex = str_replace('\{rel\}', '(.+)', preg_quote($curie['href'], '!')); |
|
| 510 | + preg_match('!'.$rel_regex.'!', $rel, $matches); |
|
| 511 | + if ($matches) { |
|
| 512 | + $new_rel = $curie['name'].':'.$matches[1]; |
|
| 513 | + $used_curies[$curie['name']] = $curie; |
|
| 514 | + $links[$new_rel] = $items; |
|
| 515 | + unset($links[$rel]); |
|
| 516 | 516 | break; |
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | // Push the curies onto the start of the links array. |
| 522 | - if ( $used_curies ) { |
|
| 523 | - $links['curies'] = array_values( $used_curies ); |
|
| 522 | + if ($used_curies) { |
|
| 523 | + $links['curies'] = array_values($used_curies); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | return $links; |
@@ -540,57 +540,57 @@ discard block |
||
| 540 | 540 | * @type array [$_embedded] Embeddeds. |
| 541 | 541 | * } |
| 542 | 542 | */ |
| 543 | - protected function embed_links( $data ) { |
|
| 544 | - if ( empty( $data['_links'] ) ) { |
|
| 543 | + protected function embed_links($data) { |
|
| 544 | + if (empty($data['_links'])) { |
|
| 545 | 545 | return $data; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | $embedded = array(); |
| 549 | 549 | |
| 550 | - foreach ( $data['_links'] as $rel => $links ) { |
|
| 550 | + foreach ($data['_links'] as $rel => $links) { |
|
| 551 | 551 | // Ignore links to self, for obvious reasons. |
| 552 | - if ( 'self' === $rel ) { |
|
| 552 | + if ('self' === $rel) { |
|
| 553 | 553 | continue; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | $embeds = array(); |
| 557 | 557 | |
| 558 | - foreach ( $links as $item ) { |
|
| 558 | + foreach ($links as $item) { |
|
| 559 | 559 | // Determine if the link is embeddable. |
| 560 | - if ( empty( $item['embeddable'] ) ) { |
|
| 560 | + if (empty($item['embeddable'])) { |
|
| 561 | 561 | // Ensure we keep the same order. |
| 562 | 562 | $embeds[] = array(); |
| 563 | 563 | continue; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | // Run through our internal routing and serve. |
| 567 | - $request = WP_REST_Request::from_url( $item['href'] ); |
|
| 568 | - if ( ! $request ) { |
|
| 567 | + $request = WP_REST_Request::from_url($item['href']); |
|
| 568 | + if ( ! $request) { |
|
| 569 | 569 | $embeds[] = array(); |
| 570 | 570 | continue; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | // Embedded resources get passed context=embed. |
| 574 | - if ( empty( $request['context'] ) ) { |
|
| 574 | + if (empty($request['context'])) { |
|
| 575 | 575 | $request['context'] = 'embed'; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $response = $this->dispatch( $request ); |
|
| 578 | + $response = $this->dispatch($request); |
|
| 579 | 579 | |
| 580 | 580 | /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
| 581 | - $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this, $request ); |
|
| 581 | + $response = apply_filters('rest_post_dispatch', rest_ensure_response($response), $this, $request); |
|
| 582 | 582 | |
| 583 | - $embeds[] = $this->response_to_data( $response, false ); |
|
| 583 | + $embeds[] = $this->response_to_data($response, false); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | // Determine if any real links were found. |
| 587 | - $has_links = count( array_filter( $embeds ) ); |
|
| 588 | - if ( $has_links ) { |
|
| 589 | - $embedded[ $rel ] = $embeds; |
|
| 587 | + $has_links = count(array_filter($embeds)); |
|
| 588 | + if ($has_links) { |
|
| 589 | + $embedded[$rel] = $embeds; |
|
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - if ( ! empty( $embedded ) ) { |
|
| 593 | + if ( ! empty($embedded)) { |
|
| 594 | 594 | $data['_embedded'] = $embedded; |
| 595 | 595 | } |
| 596 | 596 | |
@@ -611,9 +611,9 @@ discard block |
||
| 611 | 611 | * @param bool $embed Whether links should be embedded. |
| 612 | 612 | * @return WP_REST_Response New response with wrapped data |
| 613 | 613 | */ |
| 614 | - public function envelope_response( $response, $embed ) { |
|
| 614 | + public function envelope_response($response, $embed) { |
|
| 615 | 615 | $envelope = array( |
| 616 | - 'body' => $this->response_to_data( $response, $embed ), |
|
| 616 | + 'body' => $this->response_to_data($response, $embed), |
|
| 617 | 617 | 'status' => $response->get_status(), |
| 618 | 618 | 'headers' => $response->get_headers(), |
| 619 | 619 | ); |
@@ -626,10 +626,10 @@ discard block |
||
| 626 | 626 | * @param array $envelope Envelope data. |
| 627 | 627 | * @param WP_REST_Response $response Original response data. |
| 628 | 628 | */ |
| 629 | - $envelope = apply_filters( 'rest_envelope_response', $envelope, $response ); |
|
| 629 | + $envelope = apply_filters('rest_envelope_response', $envelope, $response); |
|
| 630 | 630 | |
| 631 | 631 | // Ensure it's still a response and return. |
| 632 | - return rest_ensure_response( $envelope ); |
|
| 632 | + return rest_ensure_response($envelope); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -644,14 +644,14 @@ discard block |
||
| 644 | 644 | * @param bool $override Optional. Whether the route should be overriden if it already exists. |
| 645 | 645 | * Default false. |
| 646 | 646 | */ |
| 647 | - public function register_route( $namespace, $route, $route_args, $override = false ) { |
|
| 648 | - if ( ! isset( $this->namespaces[ $namespace ] ) ) { |
|
| 649 | - $this->namespaces[ $namespace ] = array(); |
|
| 647 | + public function register_route($namespace, $route, $route_args, $override = false) { |
|
| 648 | + if ( ! isset($this->namespaces[$namespace])) { |
|
| 649 | + $this->namespaces[$namespace] = array(); |
|
| 650 | 650 | |
| 651 | - $this->register_route( $namespace, '/' . $namespace, array( |
|
| 651 | + $this->register_route($namespace, '/'.$namespace, array( |
|
| 652 | 652 | array( |
| 653 | 653 | 'methods' => self::READABLE, |
| 654 | - 'callback' => array( $this, 'get_namespace_index' ), |
|
| 654 | + 'callback' => array($this, 'get_namespace_index'), |
|
| 655 | 655 | 'args' => array( |
| 656 | 656 | 'namespace' => array( |
| 657 | 657 | 'default' => $namespace, |
@@ -661,17 +661,17 @@ discard block |
||
| 661 | 661 | ), |
| 662 | 662 | ), |
| 663 | 663 | ), |
| 664 | - ) ); |
|
| 664 | + )); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | // Associative to avoid double-registration. |
| 668 | - $this->namespaces[ $namespace ][ $route ] = true; |
|
| 668 | + $this->namespaces[$namespace][$route] = true; |
|
| 669 | 669 | $route_args['namespace'] = $namespace; |
| 670 | 670 | |
| 671 | - if ( $override || empty( $this->endpoints[ $route ] ) ) { |
|
| 672 | - $this->endpoints[ $route ] = $route_args; |
|
| 671 | + if ($override || empty($this->endpoints[$route])) { |
|
| 672 | + $this->endpoints[$route] = $route_args; |
|
| 673 | 673 | } else { |
| 674 | - $this->endpoints[ $route ] = array_merge( $this->endpoints[ $route ], $route_args ); |
|
| 674 | + $this->endpoints[$route] = array_merge($this->endpoints[$route], $route_args); |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | * `'/path/regex' => array( $callback, $bitmask )` or |
| 709 | 709 | * `'/path/regex' => array( array( $callback, $bitmask ). |
| 710 | 710 | */ |
| 711 | - $endpoints = apply_filters( 'rest_endpoints', $this->endpoints ); |
|
| 711 | + $endpoints = apply_filters('rest_endpoints', $this->endpoints); |
|
| 712 | 712 | |
| 713 | 713 | // Normalise the endpoints. |
| 714 | 714 | $defaults = array( |
@@ -719,32 +719,32 @@ discard block |
||
| 719 | 719 | 'args' => array(), |
| 720 | 720 | ); |
| 721 | 721 | |
| 722 | - foreach ( $endpoints as $route => &$handlers ) { |
|
| 722 | + foreach ($endpoints as $route => &$handlers) { |
|
| 723 | 723 | |
| 724 | - if ( isset( $handlers['callback'] ) ) { |
|
| 724 | + if (isset($handlers['callback'])) { |
|
| 725 | 725 | // Single endpoint, add one deeper. |
| 726 | - $handlers = array( $handlers ); |
|
| 726 | + $handlers = array($handlers); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( ! isset( $this->route_options[ $route ] ) ) { |
|
| 730 | - $this->route_options[ $route ] = array(); |
|
| 729 | + if ( ! isset($this->route_options[$route])) { |
|
| 730 | + $this->route_options[$route] = array(); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - foreach ( $handlers as $key => &$handler ) { |
|
| 733 | + foreach ($handlers as $key => &$handler) { |
|
| 734 | 734 | |
| 735 | - if ( ! is_numeric( $key ) ) { |
|
| 735 | + if ( ! is_numeric($key)) { |
|
| 736 | 736 | // Route option, move it to the options. |
| 737 | - $this->route_options[ $route ][ $key ] = $handler; |
|
| 738 | - unset( $handlers[ $key ] ); |
|
| 737 | + $this->route_options[$route][$key] = $handler; |
|
| 738 | + unset($handlers[$key]); |
|
| 739 | 739 | continue; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - $handler = wp_parse_args( $handler, $defaults ); |
|
| 742 | + $handler = wp_parse_args($handler, $defaults); |
|
| 743 | 743 | |
| 744 | 744 | // Allow comma-separated HTTP methods. |
| 745 | - if ( is_string( $handler['methods'] ) ) { |
|
| 746 | - $methods = explode( ',', $handler['methods'] ); |
|
| 747 | - } else if ( is_array( $handler['methods'] ) ) { |
|
| 745 | + if (is_string($handler['methods'])) { |
|
| 746 | + $methods = explode(',', $handler['methods']); |
|
| 747 | + } else if (is_array($handler['methods'])) { |
|
| 748 | 748 | $methods = $handler['methods']; |
| 749 | 749 | } else { |
| 750 | 750 | $methods = array(); |
@@ -752,9 +752,9 @@ discard block |
||
| 752 | 752 | |
| 753 | 753 | $handler['methods'] = array(); |
| 754 | 754 | |
| 755 | - foreach ( $methods as $method ) { |
|
| 756 | - $method = strtoupper( trim( $method ) ); |
|
| 757 | - $handler['methods'][ $method ] = true; |
|
| 755 | + foreach ($methods as $method) { |
|
| 756 | + $method = strtoupper(trim($method)); |
|
| 757 | + $handler['methods'][$method] = true; |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | } |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | * @return array List of registered namespaces. |
| 771 | 771 | */ |
| 772 | 772 | public function get_namespaces() { |
| 773 | - return array_keys( $this->namespaces ); |
|
| 773 | + return array_keys($this->namespaces); |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | /** |
@@ -782,12 +782,12 @@ discard block |
||
| 782 | 782 | * @param string $route Route pattern to fetch options for. |
| 783 | 783 | * @return array|null Data as an associative array if found, or null if not found. |
| 784 | 784 | */ |
| 785 | - public function get_route_options( $route ) { |
|
| 786 | - if ( ! isset( $this->route_options[ $route ] ) ) { |
|
| 785 | + public function get_route_options($route) { |
|
| 786 | + if ( ! isset($this->route_options[$route])) { |
|
| 787 | 787 | return null; |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - return $this->route_options[ $route ]; |
|
| 790 | + return $this->route_options[$route]; |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | * @param WP_REST_Request $request Request to attempt dispatching. |
| 800 | 800 | * @return WP_REST_Response Response returned by the callback. |
| 801 | 801 | */ |
| 802 | - public function dispatch( $request ) { |
|
| 802 | + public function dispatch($request) { |
|
| 803 | 803 | /** |
| 804 | 804 | * Filters the pre-calculated result of a REST dispatch request. |
| 805 | 805 | * |
@@ -813,78 +813,78 @@ discard block |
||
| 813 | 813 | * @param WP_REST_Server $this Server instance. |
| 814 | 814 | * @param WP_REST_Request $request Request used to generate the response. |
| 815 | 815 | */ |
| 816 | - $result = apply_filters( 'rest_pre_dispatch', null, $this, $request ); |
|
| 816 | + $result = apply_filters('rest_pre_dispatch', null, $this, $request); |
|
| 817 | 817 | |
| 818 | - if ( ! empty( $result ) ) { |
|
| 818 | + if ( ! empty($result)) { |
|
| 819 | 819 | return $result; |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | $method = $request->get_method(); |
| 823 | 823 | $path = $request->get_route(); |
| 824 | 824 | |
| 825 | - foreach ( $this->get_routes() as $route => $handlers ) { |
|
| 826 | - $match = preg_match( '@^' . $route . '$@i', $path, $args ); |
|
| 825 | + foreach ($this->get_routes() as $route => $handlers) { |
|
| 826 | + $match = preg_match('@^'.$route.'$@i', $path, $args); |
|
| 827 | 827 | |
| 828 | - if ( ! $match ) { |
|
| 828 | + if ( ! $match) { |
|
| 829 | 829 | continue; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - foreach ( $handlers as $handler ) { |
|
| 833 | - $callback = $handler['callback']; |
|
| 832 | + foreach ($handlers as $handler) { |
|
| 833 | + $callback = $handler['callback']; |
|
| 834 | 834 | $response = null; |
| 835 | 835 | |
| 836 | 836 | // Fallback to GET method if no HEAD method is registered. |
| 837 | 837 | $checked_method = $method; |
| 838 | - if ( 'HEAD' === $method && empty( $handler['methods']['HEAD'] ) ) { |
|
| 838 | + if ('HEAD' === $method && empty($handler['methods']['HEAD'])) { |
|
| 839 | 839 | $checked_method = 'GET'; |
| 840 | 840 | } |
| 841 | - if ( empty( $handler['methods'][ $checked_method ] ) ) { |
|
| 841 | + if (empty($handler['methods'][$checked_method])) { |
|
| 842 | 842 | continue; |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if ( ! is_callable( $callback ) ) { |
|
| 846 | - $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) ); |
|
| 845 | + if ( ! is_callable($callback)) { |
|
| 846 | + $response = new WP_Error('rest_invalid_handler', __('The handler for the route is invalid'), array('status' => 500)); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - if ( ! is_wp_error( $response ) ) { |
|
| 849 | + if ( ! is_wp_error($response)) { |
|
| 850 | 850 | // Remove the redundant preg_match argument. |
| 851 | - unset( $args[0] ); |
|
| 851 | + unset($args[0]); |
|
| 852 | 852 | |
| 853 | - $request->set_url_params( $args ); |
|
| 854 | - $request->set_attributes( $handler ); |
|
| 853 | + $request->set_url_params($args); |
|
| 854 | + $request->set_attributes($handler); |
|
| 855 | 855 | |
| 856 | 856 | $defaults = array(); |
| 857 | 857 | |
| 858 | - foreach ( $handler['args'] as $arg => $options ) { |
|
| 859 | - if ( isset( $options['default'] ) ) { |
|
| 860 | - $defaults[ $arg ] = $options['default']; |
|
| 858 | + foreach ($handler['args'] as $arg => $options) { |
|
| 859 | + if (isset($options['default'])) { |
|
| 860 | + $defaults[$arg] = $options['default']; |
|
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - $request->set_default_params( $defaults ); |
|
| 864 | + $request->set_default_params($defaults); |
|
| 865 | 865 | |
| 866 | 866 | $check_required = $request->has_valid_params(); |
| 867 | - if ( is_wp_error( $check_required ) ) { |
|
| 867 | + if (is_wp_error($check_required)) { |
|
| 868 | 868 | $response = $check_required; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | $request->sanitize_params(); |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - if ( ! is_wp_error( $response ) ) { |
|
| 874 | + if ( ! is_wp_error($response)) { |
|
| 875 | 875 | // Check permission specified on the route. |
| 876 | - if ( ! empty( $handler['permission_callback'] ) ) { |
|
| 877 | - $permission = call_user_func( $handler['permission_callback'], $request ); |
|
| 876 | + if ( ! empty($handler['permission_callback'])) { |
|
| 877 | + $permission = call_user_func($handler['permission_callback'], $request); |
|
| 878 | 878 | |
| 879 | - if ( is_wp_error( $permission ) ) { |
|
| 879 | + if (is_wp_error($permission)) { |
|
| 880 | 880 | $response = $permission; |
| 881 | - } else if ( false === $permission || null === $permission ) { |
|
| 882 | - $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) ); |
|
| 881 | + } else if (false === $permission || null === $permission) { |
|
| 882 | + $response = new WP_Error('rest_forbidden', __('Sorry, you are not allowed to do that.'), array('status' => 403)); |
|
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - if ( ! is_wp_error( $response ) ) { |
|
| 887 | + if ( ! is_wp_error($response)) { |
|
| 888 | 888 | /** |
| 889 | 889 | * Filters the REST dispatch request result. |
| 890 | 890 | * |
@@ -898,30 +898,30 @@ discard block |
||
| 898 | 898 | * @param string $route Route matched for the request. |
| 899 | 899 | * @param array $handler Route handler used for the request. |
| 900 | 900 | */ |
| 901 | - $dispatch_result = apply_filters( 'rest_dispatch_request', null, $request, $route, $handler ); |
|
| 901 | + $dispatch_result = apply_filters('rest_dispatch_request', null, $request, $route, $handler); |
|
| 902 | 902 | |
| 903 | 903 | // Allow plugins to halt the request via this filter. |
| 904 | - if ( null !== $dispatch_result ) { |
|
| 904 | + if (null !== $dispatch_result) { |
|
| 905 | 905 | $response = $dispatch_result; |
| 906 | 906 | } else { |
| 907 | - $response = call_user_func( $callback, $request ); |
|
| 907 | + $response = call_user_func($callback, $request); |
|
| 908 | 908 | } |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - if ( is_wp_error( $response ) ) { |
|
| 912 | - $response = $this->error_to_response( $response ); |
|
| 911 | + if (is_wp_error($response)) { |
|
| 912 | + $response = $this->error_to_response($response); |
|
| 913 | 913 | } else { |
| 914 | - $response = rest_ensure_response( $response ); |
|
| 914 | + $response = rest_ensure_response($response); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | - $response->set_matched_route( $route ); |
|
| 918 | - $response->set_matched_handler( $handler ); |
|
| 917 | + $response->set_matched_route($route); |
|
| 918 | + $response->set_matched_handler($handler); |
|
| 919 | 919 | |
| 920 | 920 | return $response; |
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - return $this->error_to_response( new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) ); |
|
| 924 | + return $this->error_to_response(new WP_Error('rest_no_route', __('No route was found matching the URL and request method'), array('status' => 404))); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
@@ -937,13 +937,13 @@ discard block |
||
| 937 | 937 | */ |
| 938 | 938 | protected function get_json_last_error() { |
| 939 | 939 | // See https://core.trac.wordpress.org/ticket/27799. |
| 940 | - if ( ! function_exists( 'json_last_error' ) ) { |
|
| 940 | + if ( ! function_exists('json_last_error')) { |
|
| 941 | 941 | return false; |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | $last_error_code = json_last_error(); |
| 945 | 945 | |
| 946 | - if ( ( defined( 'JSON_ERROR_NONE' ) && JSON_ERROR_NONE === $last_error_code ) || empty( $last_error_code ) ) { |
|
| 946 | + if ((defined('JSON_ERROR_NONE') && JSON_ERROR_NONE === $last_error_code) || empty($last_error_code)) { |
|
| 947 | 947 | return false; |
| 948 | 948 | } |
| 949 | 949 | |
@@ -965,21 +965,21 @@ discard block |
||
| 965 | 965 | * } |
| 966 | 966 | * @return array Index entity |
| 967 | 967 | */ |
| 968 | - public function get_index( $request ) { |
|
| 968 | + public function get_index($request) { |
|
| 969 | 969 | // General site data. |
| 970 | 970 | $available = array( |
| 971 | - 'name' => get_option( 'blogname' ), |
|
| 972 | - 'description' => get_option( 'blogdescription' ), |
|
| 973 | - 'url' => get_option( 'siteurl' ), |
|
| 971 | + 'name' => get_option('blogname'), |
|
| 972 | + 'description' => get_option('blogdescription'), |
|
| 973 | + 'url' => get_option('siteurl'), |
|
| 974 | 974 | 'home' => home_url(), |
| 975 | - 'namespaces' => array_keys( $this->namespaces ), |
|
| 975 | + 'namespaces' => array_keys($this->namespaces), |
|
| 976 | 976 | 'authentication' => array(), |
| 977 | - 'routes' => $this->get_data_for_routes( $this->get_routes(), $request['context'] ), |
|
| 977 | + 'routes' => $this->get_data_for_routes($this->get_routes(), $request['context']), |
|
| 978 | 978 | ); |
| 979 | 979 | |
| 980 | - $response = new WP_REST_Response( $available ); |
|
| 980 | + $response = new WP_REST_Response($available); |
|
| 981 | 981 | |
| 982 | - $response->add_link( 'help', 'http://v2.wp-api.org/' ); |
|
| 982 | + $response->add_link('help', 'http://v2.wp-api.org/'); |
|
| 983 | 983 | |
| 984 | 984 | /** |
| 985 | 985 | * Filters the API root index data. |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | * |
| 993 | 993 | * @param WP_REST_Response $response Response data. |
| 994 | 994 | */ |
| 995 | - return apply_filters( 'rest_index', $response ); |
|
| 995 | + return apply_filters('rest_index', $response); |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | /** |
@@ -1005,24 +1005,24 @@ discard block |
||
| 1005 | 1005 | * @return WP_REST_Response|WP_Error WP_REST_Response instance if the index was found, |
| 1006 | 1006 | * WP_Error if the namespace isn't set. |
| 1007 | 1007 | */ |
| 1008 | - public function get_namespace_index( $request ) { |
|
| 1008 | + public function get_namespace_index($request) { |
|
| 1009 | 1009 | $namespace = $request['namespace']; |
| 1010 | 1010 | |
| 1011 | - if ( ! isset( $this->namespaces[ $namespace ] ) ) { |
|
| 1012 | - return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) ); |
|
| 1011 | + if ( ! isset($this->namespaces[$namespace])) { |
|
| 1012 | + return new WP_Error('rest_invalid_namespace', __('The specified namespace could not be found.'), array('status' => 404)); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - $routes = $this->namespaces[ $namespace ]; |
|
| 1016 | - $endpoints = array_intersect_key( $this->get_routes(), $routes ); |
|
| 1015 | + $routes = $this->namespaces[$namespace]; |
|
| 1016 | + $endpoints = array_intersect_key($this->get_routes(), $routes); |
|
| 1017 | 1017 | |
| 1018 | 1018 | $data = array( |
| 1019 | 1019 | 'namespace' => $namespace, |
| 1020 | - 'routes' => $this->get_data_for_routes( $endpoints, $request['context'] ), |
|
| 1020 | + 'routes' => $this->get_data_for_routes($endpoints, $request['context']), |
|
| 1021 | 1021 | ); |
| 1022 | - $response = rest_ensure_response( $data ); |
|
| 1022 | + $response = rest_ensure_response($data); |
|
| 1023 | 1023 | |
| 1024 | 1024 | // Link to the root index. |
| 1025 | - $response->add_link( 'up', rest_url( '/' ) ); |
|
| 1025 | + $response->add_link('up', rest_url('/')); |
|
| 1026 | 1026 | |
| 1027 | 1027 | /** |
| 1028 | 1028 | * Filters the namespace index data. |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | * @param WP_REST_Response $response Response data. |
| 1036 | 1036 | * @param WP_REST_Request $request Request data. The namespace is passed as the 'namespace' parameter. |
| 1037 | 1037 | */ |
| 1038 | - return apply_filters( 'rest_namespace_index', $response, $request ); |
|
| 1038 | + return apply_filters('rest_namespace_index', $response, $request); |
|
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | /** |
@@ -1048,13 +1048,13 @@ discard block |
||
| 1048 | 1048 | * @param string $context Optional. Context for data. Accepts 'view' or 'help'. Default 'view'. |
| 1049 | 1049 | * @return array Route data to expose in indexes. |
| 1050 | 1050 | */ |
| 1051 | - public function get_data_for_routes( $routes, $context = 'view' ) { |
|
| 1051 | + public function get_data_for_routes($routes, $context = 'view') { |
|
| 1052 | 1052 | $available = array(); |
| 1053 | 1053 | |
| 1054 | 1054 | // Find the available routes. |
| 1055 | - foreach ( $routes as $route => $callbacks ) { |
|
| 1056 | - $data = $this->get_data_for_route( $route, $callbacks, $context ); |
|
| 1057 | - if ( empty( $data ) ) { |
|
| 1055 | + foreach ($routes as $route => $callbacks) { |
|
| 1056 | + $data = $this->get_data_for_route($route, $callbacks, $context); |
|
| 1057 | + if (empty($data)) { |
|
| 1058 | 1058 | continue; |
| 1059 | 1059 | } |
| 1060 | 1060 | |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | * |
| 1066 | 1066 | * @param WP_REST_Request $request Request data. The namespace is passed as the 'namespace' parameter. |
| 1067 | 1067 | */ |
| 1068 | - $available[ $route ] = apply_filters( 'rest_endpoints_description', $data ); |
|
| 1068 | + $available[$route] = apply_filters('rest_endpoints_description', $data); |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | /** |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | * @param array $available Map of route to route data. |
| 1081 | 1081 | * @param array $routes Internal route data as an associative array. |
| 1082 | 1082 | */ |
| 1083 | - return apply_filters( 'rest_route_data', $available, $routes ); |
|
| 1083 | + return apply_filters('rest_route_data', $available, $routes); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
@@ -1094,68 +1094,68 @@ discard block |
||
| 1094 | 1094 | * @param string $context Optional. Context for the data. Accepts 'view' or 'help'. Default 'view'. |
| 1095 | 1095 | * @return array|null Data for the route, or null if no publicly-visible data. |
| 1096 | 1096 | */ |
| 1097 | - public function get_data_for_route( $route, $callbacks, $context = 'view' ) { |
|
| 1097 | + public function get_data_for_route($route, $callbacks, $context = 'view') { |
|
| 1098 | 1098 | $data = array( |
| 1099 | 1099 | 'namespace' => '', |
| 1100 | 1100 | 'methods' => array(), |
| 1101 | 1101 | 'endpoints' => array(), |
| 1102 | 1102 | ); |
| 1103 | 1103 | |
| 1104 | - if ( isset( $this->route_options[ $route ] ) ) { |
|
| 1105 | - $options = $this->route_options[ $route ]; |
|
| 1104 | + if (isset($this->route_options[$route])) { |
|
| 1105 | + $options = $this->route_options[$route]; |
|
| 1106 | 1106 | |
| 1107 | - if ( isset( $options['namespace'] ) ) { |
|
| 1107 | + if (isset($options['namespace'])) { |
|
| 1108 | 1108 | $data['namespace'] = $options['namespace']; |
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | - if ( isset( $options['schema'] ) && 'help' === $context ) { |
|
| 1112 | - $data['schema'] = call_user_func( $options['schema'] ); |
|
| 1111 | + if (isset($options['schema']) && 'help' === $context) { |
|
| 1112 | + $data['schema'] = call_user_func($options['schema']); |
|
| 1113 | 1113 | } |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - $route = preg_replace( '#\(\?P<(\w+?)>.*?\)#', '{$1}', $route ); |
|
| 1116 | + $route = preg_replace('#\(\?P<(\w+?)>.*?\)#', '{$1}', $route); |
|
| 1117 | 1117 | |
| 1118 | - foreach ( $callbacks as $callback ) { |
|
| 1118 | + foreach ($callbacks as $callback) { |
|
| 1119 | 1119 | // Skip to the next route if any callback is hidden. |
| 1120 | - if ( empty( $callback['show_in_index'] ) ) { |
|
| 1120 | + if (empty($callback['show_in_index'])) { |
|
| 1121 | 1121 | continue; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - $data['methods'] = array_merge( $data['methods'], array_keys( $callback['methods'] ) ); |
|
| 1124 | + $data['methods'] = array_merge($data['methods'], array_keys($callback['methods'])); |
|
| 1125 | 1125 | $endpoint_data = array( |
| 1126 | - 'methods' => array_keys( $callback['methods'] ), |
|
| 1126 | + 'methods' => array_keys($callback['methods']), |
|
| 1127 | 1127 | ); |
| 1128 | 1128 | |
| 1129 | - if ( isset( $callback['args'] ) ) { |
|
| 1129 | + if (isset($callback['args'])) { |
|
| 1130 | 1130 | $endpoint_data['args'] = array(); |
| 1131 | - foreach ( $callback['args'] as $key => $opts ) { |
|
| 1131 | + foreach ($callback['args'] as $key => $opts) { |
|
| 1132 | 1132 | $arg_data = array( |
| 1133 | - 'required' => ! empty( $opts['required'] ), |
|
| 1133 | + 'required' => ! empty($opts['required']), |
|
| 1134 | 1134 | ); |
| 1135 | - if ( isset( $opts['default'] ) ) { |
|
| 1135 | + if (isset($opts['default'])) { |
|
| 1136 | 1136 | $arg_data['default'] = $opts['default']; |
| 1137 | 1137 | } |
| 1138 | - if ( isset( $opts['enum'] ) ) { |
|
| 1138 | + if (isset($opts['enum'])) { |
|
| 1139 | 1139 | $arg_data['enum'] = $opts['enum']; |
| 1140 | 1140 | } |
| 1141 | - if ( isset( $opts['description'] ) ) { |
|
| 1141 | + if (isset($opts['description'])) { |
|
| 1142 | 1142 | $arg_data['description'] = $opts['description']; |
| 1143 | 1143 | } |
| 1144 | - $endpoint_data['args'][ $key ] = $arg_data; |
|
| 1144 | + $endpoint_data['args'][$key] = $arg_data; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | $data['endpoints'][] = $endpoint_data; |
| 1149 | 1149 | |
| 1150 | 1150 | // For non-variable routes, generate links. |
| 1151 | - if ( strpos( $route, '{' ) === false ) { |
|
| 1151 | + if (strpos($route, '{') === false) { |
|
| 1152 | 1152 | $data['_links'] = array( |
| 1153 | - 'self' => rest_url( $route ), |
|
| 1153 | + 'self' => rest_url($route), |
|
| 1154 | 1154 | ); |
| 1155 | 1155 | } |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | - if ( empty( $data['methods'] ) ) { |
|
| 1158 | + if (empty($data['methods'])) { |
|
| 1159 | 1159 | // No methods supported, hide the route. |
| 1160 | 1160 | return null; |
| 1161 | 1161 | } |
@@ -1171,8 +1171,8 @@ discard block |
||
| 1171 | 1171 | * |
| 1172 | 1172 | * @param int $code HTTP status. |
| 1173 | 1173 | */ |
| 1174 | - protected function set_status( $code ) { |
|
| 1175 | - status_header( $code ); |
|
| 1174 | + protected function set_status($code) { |
|
| 1175 | + status_header($code); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | /** |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | * @param string $key Header key. |
| 1185 | 1185 | * @param string $value Header value. |
| 1186 | 1186 | */ |
| 1187 | - public function send_header( $key, $value ) { |
|
| 1187 | + public function send_header($key, $value) { |
|
| 1188 | 1188 | /* |
| 1189 | 1189 | * Sanitize as per RFC2616 (Section 4.2): |
| 1190 | 1190 | * |
@@ -1192,8 +1192,8 @@ discard block |
||
| 1192 | 1192 | * single SP before interpreting the field value or forwarding the |
| 1193 | 1193 | * message downstream. |
| 1194 | 1194 | */ |
| 1195 | - $value = preg_replace( '/\s+/', ' ', $value ); |
|
| 1196 | - header( sprintf( '%s: %s', $key, $value ) ); |
|
| 1195 | + $value = preg_replace('/\s+/', ' ', $value); |
|
| 1196 | + header(sprintf('%s: %s', $key, $value)); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | /** |
@@ -1204,9 +1204,9 @@ discard block |
||
| 1204 | 1204 | * |
| 1205 | 1205 | * @param array $headers Map of header name to header value. |
| 1206 | 1206 | */ |
| 1207 | - public function send_headers( $headers ) { |
|
| 1208 | - foreach ( $headers as $key => $value ) { |
|
| 1209 | - $this->send_header( $key, $value ); |
|
| 1207 | + public function send_headers($headers) { |
|
| 1208 | + foreach ($headers as $key => $value) { |
|
| 1209 | + $this->send_header($key, $value); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | } |
| 1212 | 1212 | |
@@ -1227,8 +1227,8 @@ discard block |
||
| 1227 | 1227 | * A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, |
| 1228 | 1228 | * but we can do it ourself. |
| 1229 | 1229 | */ |
| 1230 | - if ( ! isset( $HTTP_RAW_POST_DATA ) ) { |
|
| 1231 | - $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); |
|
| 1230 | + if ( ! isset($HTTP_RAW_POST_DATA)) { |
|
| 1231 | + $HTTP_RAW_POST_DATA = file_get_contents('php://input'); |
|
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | 1234 | return $HTTP_RAW_POST_DATA; |
@@ -1243,17 +1243,17 @@ discard block |
||
| 1243 | 1243 | * @param array $server Associative array similar to `$_SERVER`. |
| 1244 | 1244 | * @return array Headers extracted from the input. |
| 1245 | 1245 | */ |
| 1246 | - public function get_headers( $server ) { |
|
| 1246 | + public function get_headers($server) { |
|
| 1247 | 1247 | $headers = array(); |
| 1248 | 1248 | |
| 1249 | 1249 | // CONTENT_* headers are not prefixed with HTTP_. |
| 1250 | - $additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true ); |
|
| 1250 | + $additional = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); |
|
| 1251 | 1251 | |
| 1252 | - foreach ( $server as $key => $value ) { |
|
| 1253 | - if ( strpos( $key, 'HTTP_' ) === 0 ) { |
|
| 1254 | - $headers[ substr( $key, 5 ) ] = $value; |
|
| 1255 | - } elseif ( isset( $additional[ $key ] ) ) { |
|
| 1256 | - $headers[ $key ] = $value; |
|
| 1252 | + foreach ($server as $key => $value) { |
|
| 1253 | + if (strpos($key, 'HTTP_') === 0) { |
|
| 1254 | + $headers[substr($key, 5)] = $value; |
|
| 1255 | + } elseif (isset($additional[$key])) { |
|
| 1256 | + $headers[$key] = $value; |
|
| 1257 | 1257 | } |
| 1258 | 1258 | } |
| 1259 | 1259 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function wp_scripts() { |
| 21 | 21 | global $wp_scripts; |
| 22 | - if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
|
| 22 | + if ( ! ($wp_scripts instanceof WP_Scripts)) { |
|
| 23 | 23 | $wp_scripts = new WP_Scripts(); |
| 24 | 24 | } |
| 25 | 25 | return $wp_scripts; |
@@ -33,17 +33,17 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @param string $function Function name. |
| 35 | 35 | */ |
| 36 | -function _wp_scripts_maybe_doing_it_wrong( $function ) { |
|
| 37 | - if ( did_action( 'init' ) ) { |
|
| 36 | +function _wp_scripts_maybe_doing_it_wrong($function) { |
|
| 37 | + if (did_action('init')) { |
|
| 38 | 38 | return; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - _doing_it_wrong( $function, sprintf( |
|
| 42 | - __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ), |
|
| 41 | + _doing_it_wrong($function, sprintf( |
|
| 42 | + __('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), |
|
| 43 | 43 | '<code>wp_enqueue_scripts</code>', |
| 44 | 44 | '<code>admin_enqueue_scripts</code>', |
| 45 | 45 | '<code>login_enqueue_scripts</code>' |
| 46 | - ), '3.3.0' ); |
|
| 46 | + ), '3.3.0'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -62,27 +62,27 @@ discard block |
||
| 62 | 62 | * @param string|bool|array $handles Optional. Scripts to be printed. Default 'false'. |
| 63 | 63 | * @return array On success, a processed array of WP_Dependencies items; otherwise, an empty array. |
| 64 | 64 | */ |
| 65 | -function wp_print_scripts( $handles = false ) { |
|
| 65 | +function wp_print_scripts($handles = false) { |
|
| 66 | 66 | /** |
| 67 | 67 | * Fires before scripts in the $handles queue are printed. |
| 68 | 68 | * |
| 69 | 69 | * @since 2.1.0 |
| 70 | 70 | */ |
| 71 | - do_action( 'wp_print_scripts' ); |
|
| 72 | - if ( '' === $handles ) { // for wp_head |
|
| 71 | + do_action('wp_print_scripts'); |
|
| 72 | + if ('' === $handles) { // for wp_head |
|
| 73 | 73 | $handles = false; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 76 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 77 | 77 | |
| 78 | 78 | global $wp_scripts; |
| 79 | - if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
|
| 80 | - if ( ! $handles ) { |
|
| 79 | + if ( ! ($wp_scripts instanceof WP_Scripts)) { |
|
| 80 | + if ( ! $handles) { |
|
| 81 | 81 | return array(); // No need to instantiate if nothing is there. |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - return wp_scripts()->do_items( $handles ); |
|
| 85 | + return wp_scripts()->do_items($handles); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -103,20 +103,20 @@ discard block |
||
| 103 | 103 | * or after. Default 'after'. |
| 104 | 104 | * @return bool True on success, false on failure. |
| 105 | 105 | */ |
| 106 | -function wp_add_inline_script( $handle, $data, $position = 'after' ) { |
|
| 107 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 106 | +function wp_add_inline_script($handle, $data, $position = 'after') { |
|
| 107 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 108 | 108 | |
| 109 | - if ( false !== stripos( $data, '</script>' ) ) { |
|
| 110 | - _doing_it_wrong( __FUNCTION__, sprintf( |
|
| 109 | + if (false !== stripos($data, '</script>')) { |
|
| 110 | + _doing_it_wrong(__FUNCTION__, sprintf( |
|
| 111 | 111 | /* translators: 1: <script>, 2: wp_add_inline_script() */ |
| 112 | - __( 'Do not pass %1$s tags to %2$s.' ), |
|
| 112 | + __('Do not pass %1$s tags to %2$s.'), |
|
| 113 | 113 | '<code><script></code>', |
| 114 | 114 | '<code>wp_add_inline_script()</code>' |
| 115 | - ), '4.5.0' ); |
|
| 116 | - $data = trim( preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) ); |
|
| 115 | + ), '4.5.0'); |
|
| 116 | + $data = trim(preg_replace('#<script[^>]*>(.*)</script>#is', '$1', $data)); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - return wp_scripts()->add_inline_script( $handle, $data, $position ); |
|
| 119 | + return wp_scripts()->add_inline_script($handle, $data, $position); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | * Default 'false'. |
| 142 | 142 | * @return bool Whether the script has been registered. True on success, false on failure. |
| 143 | 143 | */ |
| 144 | -function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) { |
|
| 144 | +function wp_register_script($handle, $src, $deps = array(), $ver = false, $in_footer = false) { |
|
| 145 | 145 | $wp_scripts = wp_scripts(); |
| 146 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 146 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 147 | 147 | |
| 148 | - $registered = $wp_scripts->add( $handle, $src, $deps, $ver ); |
|
| 149 | - if ( $in_footer ) { |
|
| 150 | - $wp_scripts->add_data( $handle, 'group', 1 ); |
|
| 148 | + $registered = $wp_scripts->add($handle, $src, $deps, $ver); |
|
| 149 | + if ($in_footer) { |
|
| 150 | + $wp_scripts->add_data($handle, 'group', 1); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return $registered; |
@@ -181,14 +181,14 @@ discard block |
||
| 181 | 181 | * @param array $l10n The data itself. The data can be either a single or multi-dimensional array. |
| 182 | 182 | * @return bool True if the script was successfully localized, false otherwise. |
| 183 | 183 | */ |
| 184 | -function wp_localize_script( $handle, $object_name, $l10n ) { |
|
| 184 | +function wp_localize_script($handle, $object_name, $l10n) { |
|
| 185 | 185 | global $wp_scripts; |
| 186 | - if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
|
| 187 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 186 | + if ( ! ($wp_scripts instanceof WP_Scripts)) { |
|
| 187 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - return $wp_scripts->localize( $handle, $object_name, $l10n ); |
|
| 191 | + return $wp_scripts->localize($handle, $object_name, $l10n); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -203,16 +203,16 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @param string $handle Name of the script to be removed. |
| 205 | 205 | */ |
| 206 | -function wp_deregister_script( $handle ) { |
|
| 207 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 206 | +function wp_deregister_script($handle) { |
|
| 207 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * Do not allow accidental or negligent de-registering of critical scripts in the admin. |
| 211 | 211 | * Show minimal remorse if the correct hook is used. |
| 212 | 212 | */ |
| 213 | 213 | $current_filter = current_filter(); |
| 214 | - if ( ( is_admin() && 'admin_enqueue_scripts' !== $current_filter ) || |
|
| 215 | - ( 'wp-login.php' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter ) |
|
| 214 | + if ((is_admin() && 'admin_enqueue_scripts' !== $current_filter) || |
|
| 215 | + ('wp-login.php' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) |
|
| 216 | 216 | ) { |
| 217 | 217 | $no = array( |
| 218 | 218 | 'jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', |
@@ -223,15 +223,15 @@ discard block |
||
| 223 | 223 | 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone', |
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | - if ( in_array( $handle, $no ) ) { |
|
| 227 | - $message = sprintf( __( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ), |
|
| 228 | - "<code>$handle</code>", '<code>wp_enqueue_scripts</code>' ); |
|
| 229 | - _doing_it_wrong( __FUNCTION__, $message, '3.6.0' ); |
|
| 226 | + if (in_array($handle, $no)) { |
|
| 227 | + $message = sprintf(__('Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.'), |
|
| 228 | + "<code>$handle</code>", '<code>wp_enqueue_scripts</code>'); |
|
| 229 | + _doing_it_wrong(__FUNCTION__, $message, '3.6.0'); |
|
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - wp_scripts()->remove( $handle ); |
|
| 234 | + wp_scripts()->remove($handle); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -255,25 +255,25 @@ discard block |
||
| 255 | 255 | * @param bool $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>. |
| 256 | 256 | * Default 'false'. |
| 257 | 257 | */ |
| 258 | -function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) { |
|
| 258 | +function wp_enqueue_script($handle, $src = false, $deps = array(), $ver = false, $in_footer = false) { |
|
| 259 | 259 | $wp_scripts = wp_scripts(); |
| 260 | 260 | |
| 261 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 261 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 262 | 262 | |
| 263 | 263 | |
| 264 | - if ( $src || $in_footer ) { |
|
| 265 | - $_handle = explode( '?', $handle ); |
|
| 264 | + if ($src || $in_footer) { |
|
| 265 | + $_handle = explode('?', $handle); |
|
| 266 | 266 | |
| 267 | - if ( $src ) { |
|
| 268 | - $wp_scripts->add( $_handle[0], $src, $deps, $ver ); |
|
| 267 | + if ($src) { |
|
| 268 | + $wp_scripts->add($_handle[0], $src, $deps, $ver); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ( $in_footer ) { |
|
| 272 | - $wp_scripts->add_data( $_handle[0], 'group', 1 ); |
|
| 271 | + if ($in_footer) { |
|
| 272 | + $wp_scripts->add_data($_handle[0], 'group', 1); |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $wp_scripts->enqueue( $handle ); |
|
| 276 | + $wp_scripts->enqueue($handle); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @param string $handle Name of the script to be removed. |
| 287 | 287 | */ |
| 288 | -function wp_dequeue_script( $handle ) { |
|
| 289 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 288 | +function wp_dequeue_script($handle) { |
|
| 289 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 290 | 290 | |
| 291 | - wp_scripts()->dequeue( $handle ); |
|
| 291 | + wp_scripts()->dequeue($handle); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | * Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'. |
| 303 | 303 | * @return bool Whether the script is queued. |
| 304 | 304 | */ |
| 305 | -function wp_script_is( $handle, $list = 'enqueued' ) { |
|
| 306 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 305 | +function wp_script_is($handle, $list = 'enqueued') { |
|
| 306 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 307 | 307 | |
| 308 | - return (bool) wp_scripts()->query( $handle, $list ); |
|
| 308 | + return (bool) wp_scripts()->query($handle, $list); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -325,6 +325,6 @@ discard block |
||
| 325 | 325 | * @param mixed $value String containing the data to be added. |
| 326 | 326 | * @return bool True on success, false on failure. |
| 327 | 327 | */ |
| 328 | -function wp_script_add_data( $handle, $key, $value ){ |
|
| 329 | - return wp_scripts()->add_data( $handle, $key, $value ); |
|
| 328 | +function wp_script_add_data($handle, $key, $value) { |
|
| 329 | + return wp_scripts()->add_data($handle, $key, $value); |
|
| 330 | 330 | } |
@@ -39,45 +39,45 @@ discard block |
||
| 39 | 39 | * @param int $user_id The unique ID of the user |
| 40 | 40 | * @return WP_Site|void The blog object |
| 41 | 41 | */ |
| 42 | -function get_active_blog_for_user( $user_id ) { |
|
| 42 | +function get_active_blog_for_user($user_id) { |
|
| 43 | 43 | global $wpdb; |
| 44 | - $blogs = get_blogs_of_user( $user_id ); |
|
| 45 | - if ( empty( $blogs ) ) |
|
| 44 | + $blogs = get_blogs_of_user($user_id); |
|
| 45 | + if (empty($blogs)) |
|
| 46 | 46 | return; |
| 47 | 47 | |
| 48 | - if ( !is_multisite() ) |
|
| 48 | + if ( ! is_multisite()) |
|
| 49 | 49 | return $blogs[$wpdb->blogid]; |
| 50 | 50 | |
| 51 | - $primary_blog = get_user_meta( $user_id, 'primary_blog', true ); |
|
| 51 | + $primary_blog = get_user_meta($user_id, 'primary_blog', true); |
|
| 52 | 52 | $first_blog = current($blogs); |
| 53 | - if ( false !== $primary_blog ) { |
|
| 54 | - if ( ! isset( $blogs[ $primary_blog ] ) ) { |
|
| 55 | - update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id ); |
|
| 56 | - $primary = get_blog_details( $first_blog->userblog_id ); |
|
| 53 | + if (false !== $primary_blog) { |
|
| 54 | + if ( ! isset($blogs[$primary_blog])) { |
|
| 55 | + update_user_meta($user_id, 'primary_blog', $first_blog->userblog_id); |
|
| 56 | + $primary = get_blog_details($first_blog->userblog_id); |
|
| 57 | 57 | } else { |
| 58 | - $primary = get_blog_details( $primary_blog ); |
|
| 58 | + $primary = get_blog_details($primary_blog); |
|
| 59 | 59 | } |
| 60 | 60 | } else { |
| 61 | 61 | //TODO Review this call to add_user_to_blog too - to get here the user must have a role on this blog? |
| 62 | - add_user_to_blog( $first_blog->userblog_id, $user_id, 'subscriber' ); |
|
| 63 | - update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id ); |
|
| 62 | + add_user_to_blog($first_blog->userblog_id, $user_id, 'subscriber'); |
|
| 63 | + update_user_meta($user_id, 'primary_blog', $first_blog->userblog_id); |
|
| 64 | 64 | $primary = $first_blog; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) { |
|
| 68 | - $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs. |
|
| 67 | + if (( ! is_object($primary)) || ($primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1)) { |
|
| 68 | + $blogs = get_blogs_of_user($user_id, true); // if a user's primary blog is shut down, check their other blogs. |
|
| 69 | 69 | $ret = false; |
| 70 | - if ( is_array( $blogs ) && count( $blogs ) > 0 ) { |
|
| 71 | - foreach ( (array) $blogs as $blog_id => $blog ) { |
|
| 72 | - if ( $blog->site_id != $wpdb->siteid ) |
|
| 70 | + if (is_array($blogs) && count($blogs) > 0) { |
|
| 71 | + foreach ((array) $blogs as $blog_id => $blog) { |
|
| 72 | + if ($blog->site_id != $wpdb->siteid) |
|
| 73 | 73 | continue; |
| 74 | - $details = get_blog_details( $blog_id ); |
|
| 75 | - if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) { |
|
| 74 | + $details = get_blog_details($blog_id); |
|
| 75 | + if (is_object($details) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0) { |
|
| 76 | 76 | $ret = $blog; |
| 77 | - if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) |
|
| 78 | - update_user_meta( $user_id, 'primary_blog', $blog_id ); |
|
| 79 | - if ( !get_user_meta($user_id , 'source_domain', true) ) |
|
| 80 | - update_user_meta( $user_id, 'source_domain', $blog->domain ); |
|
| 77 | + if (get_user_meta($user_id, 'primary_blog', true) != $blog_id) |
|
| 78 | + update_user_meta($user_id, 'primary_blog', $blog_id); |
|
| 79 | + if ( ! get_user_meta($user_id, 'source_domain', true)) |
|
| 80 | + update_user_meta($user_id, 'source_domain', $blog->domain); |
|
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @return int |
| 101 | 101 | */ |
| 102 | 102 | function get_user_count() { |
| 103 | - return get_site_option( 'user_count' ); |
|
| 103 | + return get_site_option('user_count'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | * @param int $network_id Deprecated, not supported. |
| 114 | 114 | * @return int |
| 115 | 115 | */ |
| 116 | -function get_blog_count( $network_id = 0 ) { |
|
| 117 | - if ( func_num_args() ) |
|
| 118 | - _deprecated_argument( __FUNCTION__, '3.1.0' ); |
|
| 116 | +function get_blog_count($network_id = 0) { |
|
| 117 | + if (func_num_args()) |
|
| 118 | + _deprecated_argument(__FUNCTION__, '3.1.0'); |
|
| 119 | 119 | |
| 120 | - return get_site_option( 'blog_count' ); |
|
| 120 | + return get_site_option('blog_count'); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | * @param int $post_id ID of the post you're looking for. |
| 130 | 130 | * @return WP_Post|null WP_Post on success or null on failure |
| 131 | 131 | */ |
| 132 | -function get_blog_post( $blog_id, $post_id ) { |
|
| 133 | - switch_to_blog( $blog_id ); |
|
| 134 | - $post = get_post( $post_id ); |
|
| 132 | +function get_blog_post($blog_id, $post_id) { |
|
| 133 | + switch_to_blog($blog_id); |
|
| 134 | + $post = get_post($post_id); |
|
| 135 | 135 | restore_current_blog(); |
| 136 | 136 | |
| 137 | 137 | return $post; |
@@ -149,17 +149,17 @@ discard block |
||
| 149 | 149 | * @param string $role The role you want the user to have |
| 150 | 150 | * @return true|WP_Error |
| 151 | 151 | */ |
| 152 | -function add_user_to_blog( $blog_id, $user_id, $role ) { |
|
| 152 | +function add_user_to_blog($blog_id, $user_id, $role) { |
|
| 153 | 153 | switch_to_blog($blog_id); |
| 154 | 154 | |
| 155 | - $user = get_userdata( $user_id ); |
|
| 155 | + $user = get_userdata($user_id); |
|
| 156 | 156 | |
| 157 | - if ( ! $user ) { |
|
| 157 | + if ( ! $user) { |
|
| 158 | 158 | restore_current_blog(); |
| 159 | - return new WP_Error( 'user_does_not_exist', __( 'The requested user does not exist.' ) ); |
|
| 159 | + return new WP_Error('user_does_not_exist', __('The requested user does not exist.')); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( !get_user_meta($user_id, 'primary_blog', true) ) { |
|
| 162 | + if ( ! get_user_meta($user_id, 'primary_blog', true)) { |
|
| 163 | 163 | update_user_meta($user_id, 'primary_blog', $blog_id); |
| 164 | 164 | $details = get_blog_details($blog_id); |
| 165 | 165 | update_user_meta($user_id, 'source_domain', $details->domain); |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | * @param string $role User role. |
| 177 | 177 | * @param int $blog_id Blog ID. |
| 178 | 178 | */ |
| 179 | - do_action( 'add_user_to_blog', $user_id, $role, $blog_id ); |
|
| 180 | - wp_cache_delete( $user_id, 'users' ); |
|
| 181 | - wp_cache_delete( $blog_id . '_user_count', 'blog-details' ); |
|
| 179 | + do_action('add_user_to_blog', $user_id, $role, $blog_id); |
|
| 180 | + wp_cache_delete($user_id, 'users'); |
|
| 181 | + wp_cache_delete($blog_id.'_user_count', 'blog-details'); |
|
| 182 | 182 | restore_current_blog(); |
| 183 | 183 | return true; |
| 184 | 184 | } |
@@ -213,17 +213,17 @@ discard block |
||
| 213 | 213 | * @param int $user_id User ID. |
| 214 | 214 | * @param int $blog_id Blog ID. |
| 215 | 215 | */ |
| 216 | - do_action( 'remove_user_from_blog', $user_id, $blog_id ); |
|
| 216 | + do_action('remove_user_from_blog', $user_id, $blog_id); |
|
| 217 | 217 | |
| 218 | 218 | // If being removed from the primary blog, set a new primary if the user is assigned |
| 219 | 219 | // to multiple blogs. |
| 220 | 220 | $primary_blog = get_user_meta($user_id, 'primary_blog', true); |
| 221 | - if ( $primary_blog == $blog_id ) { |
|
| 221 | + if ($primary_blog == $blog_id) { |
|
| 222 | 222 | $new_id = ''; |
| 223 | 223 | $new_domain = ''; |
| 224 | 224 | $blogs = get_blogs_of_user($user_id); |
| 225 | - foreach ( (array) $blogs as $blog ) { |
|
| 226 | - if ( $blog->userblog_id == $blog_id ) |
|
| 225 | + foreach ((array) $blogs as $blog) { |
|
| 226 | + if ($blog->userblog_id == $blog_id) |
|
| 227 | 227 | continue; |
| 228 | 228 | $new_id = $blog->userblog_id; |
| 229 | 229 | $new_domain = $blog->domain; |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // wp_revoke_user($user_id); |
| 238 | - $user = get_userdata( $user_id ); |
|
| 239 | - if ( ! $user ) { |
|
| 238 | + $user = get_userdata($user_id); |
|
| 239 | + if ( ! $user) { |
|
| 240 | 240 | restore_current_blog(); |
| 241 | 241 | return new WP_Error('user_does_not_exist', __('That user does not exist.')); |
| 242 | 242 | } |
@@ -244,24 +244,24 @@ discard block |
||
| 244 | 244 | $user->remove_all_caps(); |
| 245 | 245 | |
| 246 | 246 | $blogs = get_blogs_of_user($user_id); |
| 247 | - if ( count($blogs) == 0 ) { |
|
| 247 | + if (count($blogs) == 0) { |
|
| 248 | 248 | update_user_meta($user_id, 'primary_blog', ''); |
| 249 | 249 | update_user_meta($user_id, 'source_domain', ''); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if ( $reassign != '' ) { |
|
| 252 | + if ($reassign != '') { |
|
| 253 | 253 | $reassign = (int) $reassign; |
| 254 | - $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) ); |
|
| 255 | - $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id ) ); |
|
| 254 | + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id)); |
|
| 255 | + $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id)); |
|
| 256 | 256 | |
| 257 | - if ( ! empty( $post_ids ) ) { |
|
| 258 | - $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id ) ); |
|
| 259 | - array_walk( $post_ids, 'clean_post_cache' ); |
|
| 257 | + if ( ! empty($post_ids)) { |
|
| 258 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id)); |
|
| 259 | + array_walk($post_ids, 'clean_post_cache'); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if ( ! empty( $link_ids ) ) { |
|
| 263 | - $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id ) ); |
|
| 264 | - array_walk( $link_ids, 'clean_bookmark_cache' ); |
|
| 262 | + if ( ! empty($link_ids)) { |
|
| 263 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id)); |
|
| 264 | + array_walk($link_ids, 'clean_bookmark_cache'); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -279,9 +279,9 @@ discard block |
||
| 279 | 279 | * @param int $post_id ID of the desired post. |
| 280 | 280 | * @return string The post's permalink |
| 281 | 281 | */ |
| 282 | -function get_blog_permalink( $blog_id, $post_id ) { |
|
| 283 | - switch_to_blog( $blog_id ); |
|
| 284 | - $link = get_permalink( $post_id ); |
|
| 282 | +function get_blog_permalink($blog_id, $post_id) { |
|
| 283 | + switch_to_blog($blog_id); |
|
| 284 | + $link = get_permalink($post_id); |
|
| 285 | 285 | restore_current_blog(); |
| 286 | 286 | |
| 287 | 287 | return $link; |
@@ -303,14 +303,14 @@ discard block |
||
| 303 | 303 | * @param string $path Optional. Not required for subdomain installations. |
| 304 | 304 | * @return int 0 if no blog found, otherwise the ID of the matching blog |
| 305 | 305 | */ |
| 306 | -function get_blog_id_from_url( $domain, $path = '/' ) { |
|
| 307 | - $domain = strtolower( $domain ); |
|
| 308 | - $path = strtolower( $path ); |
|
| 309 | - $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' ); |
|
| 306 | +function get_blog_id_from_url($domain, $path = '/') { |
|
| 307 | + $domain = strtolower($domain); |
|
| 308 | + $path = strtolower($path); |
|
| 309 | + $id = wp_cache_get(md5($domain.$path), 'blog-id-cache'); |
|
| 310 | 310 | |
| 311 | - if ( $id == -1 ) // blog does not exist |
|
| 311 | + if ($id == -1) // blog does not exist |
|
| 312 | 312 | return 0; |
| 313 | - elseif ( $id ) |
|
| 313 | + elseif ($id) |
|
| 314 | 314 | return (int) $id; |
| 315 | 315 | |
| 316 | 316 | $args = array( |
@@ -318,15 +318,15 @@ discard block |
||
| 318 | 318 | 'path' => $path, |
| 319 | 319 | 'fields' => 'ids', |
| 320 | 320 | ); |
| 321 | - $result = get_sites( $args ); |
|
| 322 | - $id = array_shift( $result ); |
|
| 321 | + $result = get_sites($args); |
|
| 322 | + $id = array_shift($result); |
|
| 323 | 323 | |
| 324 | - if ( ! $id ) { |
|
| 325 | - wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' ); |
|
| 324 | + if ( ! $id) { |
|
| 325 | + wp_cache_set(md5($domain.$path), -1, 'blog-id-cache'); |
|
| 326 | 326 | return 0; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' ); |
|
| 329 | + wp_cache_set(md5($domain.$path), $id, 'blog-id-cache'); |
|
| 330 | 330 | |
| 331 | 331 | return $id; |
| 332 | 332 | } |
@@ -346,30 +346,30 @@ discard block |
||
| 346 | 346 | * @param string $user_email The email provided by the user at registration. |
| 347 | 347 | * @return bool Returns true when the email address is banned. |
| 348 | 348 | */ |
| 349 | -function is_email_address_unsafe( $user_email ) { |
|
| 350 | - $banned_names = get_site_option( 'banned_email_domains' ); |
|
| 351 | - if ( $banned_names && ! is_array( $banned_names ) ) |
|
| 352 | - $banned_names = explode( "\n", $banned_names ); |
|
| 349 | +function is_email_address_unsafe($user_email) { |
|
| 350 | + $banned_names = get_site_option('banned_email_domains'); |
|
| 351 | + if ($banned_names && ! is_array($banned_names)) |
|
| 352 | + $banned_names = explode("\n", $banned_names); |
|
| 353 | 353 | |
| 354 | 354 | $is_email_address_unsafe = false; |
| 355 | 355 | |
| 356 | - if ( $banned_names && is_array( $banned_names ) ) { |
|
| 357 | - $banned_names = array_map( 'strtolower', $banned_names ); |
|
| 358 | - $normalized_email = strtolower( $user_email ); |
|
| 356 | + if ($banned_names && is_array($banned_names)) { |
|
| 357 | + $banned_names = array_map('strtolower', $banned_names); |
|
| 358 | + $normalized_email = strtolower($user_email); |
|
| 359 | 359 | |
| 360 | - list( $email_local_part, $email_domain ) = explode( '@', $normalized_email ); |
|
| 360 | + list($email_local_part, $email_domain) = explode('@', $normalized_email); |
|
| 361 | 361 | |
| 362 | - foreach ( $banned_names as $banned_domain ) { |
|
| 363 | - if ( ! $banned_domain ) |
|
| 362 | + foreach ($banned_names as $banned_domain) { |
|
| 363 | + if ( ! $banned_domain) |
|
| 364 | 364 | continue; |
| 365 | 365 | |
| 366 | - if ( $email_domain == $banned_domain ) { |
|
| 366 | + if ($email_domain == $banned_domain) { |
|
| 367 | 367 | $is_email_address_unsafe = true; |
| 368 | 368 | break; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $dotted_domain = ".$banned_domain"; |
| 372 | - if ( $dotted_domain === substr( $normalized_email, -strlen( $dotted_domain ) ) ) { |
|
| 372 | + if ($dotted_domain === substr($normalized_email, -strlen($dotted_domain))) { |
|
| 373 | 373 | $is_email_address_unsafe = true; |
| 374 | 374 | break; |
| 375 | 375 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * @param bool $is_email_address_unsafe Whether the email address is "unsafe". Default false. |
| 385 | 385 | * @param string $user_email User email address. |
| 386 | 386 | */ |
| 387 | - return apply_filters( 'is_email_address_unsafe', $is_email_address_unsafe, $user_email ); |
|
| 387 | + return apply_filters('is_email_address_unsafe', $is_email_address_unsafe, $user_email); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -413,86 +413,86 @@ discard block |
||
| 413 | 413 | $errors = new WP_Error(); |
| 414 | 414 | |
| 415 | 415 | $orig_username = $user_name; |
| 416 | - $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); |
|
| 416 | + $user_name = preg_replace('/\s+/', '', sanitize_user($user_name, true)); |
|
| 417 | 417 | |
| 418 | - if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) { |
|
| 419 | - $errors->add( 'user_name', __( 'Usernames can only contain lowercase letters (a-z) and numbers.' ) ); |
|
| 418 | + if ($user_name != $orig_username || preg_match('/[^a-z0-9]/', $user_name)) { |
|
| 419 | + $errors->add('user_name', __('Usernames can only contain lowercase letters (a-z) and numbers.')); |
|
| 420 | 420 | $user_name = $orig_username; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $user_email = sanitize_email( $user_email ); |
|
| 423 | + $user_email = sanitize_email($user_email); |
|
| 424 | 424 | |
| 425 | - if ( empty( $user_name ) ) |
|
| 426 | - $errors->add('user_name', __( 'Please enter a username.' ) ); |
|
| 425 | + if (empty($user_name)) |
|
| 426 | + $errors->add('user_name', __('Please enter a username.')); |
|
| 427 | 427 | |
| 428 | - $illegal_names = get_site_option( 'illegal_names' ); |
|
| 429 | - if ( ! is_array( $illegal_names ) ) { |
|
| 430 | - $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); |
|
| 431 | - add_site_option( 'illegal_names', $illegal_names ); |
|
| 428 | + $illegal_names = get_site_option('illegal_names'); |
|
| 429 | + if ( ! is_array($illegal_names)) { |
|
| 430 | + $illegal_names = array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator'); |
|
| 431 | + add_site_option('illegal_names', $illegal_names); |
|
| 432 | 432 | } |
| 433 | - if ( in_array( $user_name, $illegal_names ) ) { |
|
| 434 | - $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) ); |
|
| 433 | + if (in_array($user_name, $illegal_names)) { |
|
| 434 | + $errors->add('user_name', __('Sorry, that username is not allowed.')); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** This filter is documented in wp-includes/user.php */ |
| 438 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 438 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
| 439 | 439 | |
| 440 | - if ( in_array( strtolower( $user_name ), array_map( 'strtolower', $illegal_logins ) ) ) { |
|
| 441 | - $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) ); |
|
| 440 | + if (in_array(strtolower($user_name), array_map('strtolower', $illegal_logins))) { |
|
| 441 | + $errors->add('user_name', __('Sorry, that username is not allowed.')); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if ( is_email_address_unsafe( $user_email ) ) |
|
| 445 | - $errors->add('user_email', __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.')); |
|
| 444 | + if (is_email_address_unsafe($user_email)) |
|
| 445 | + $errors->add('user_email', __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.')); |
|
| 446 | 446 | |
| 447 | - if ( strlen( $user_name ) < 4 ) |
|
| 448 | - $errors->add('user_name', __( 'Username must be at least 4 characters.' ) ); |
|
| 447 | + if (strlen($user_name) < 4) |
|
| 448 | + $errors->add('user_name', __('Username must be at least 4 characters.')); |
|
| 449 | 449 | |
| 450 | - if ( strlen( $user_name ) > 60 ) { |
|
| 451 | - $errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) ); |
|
| 450 | + if (strlen($user_name) > 60) { |
|
| 451 | + $errors->add('user_name', __('Username may not be longer than 60 characters.')); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | // all numeric? |
| 455 | - if ( preg_match( '/^[0-9]*$/', $user_name ) ) |
|
| 455 | + if (preg_match('/^[0-9]*$/', $user_name)) |
|
| 456 | 456 | $errors->add('user_name', __('Sorry, usernames must have letters too!')); |
| 457 | 457 | |
| 458 | - if ( !is_email( $user_email ) ) |
|
| 459 | - $errors->add('user_email', __( 'Please enter a valid email address.' ) ); |
|
| 458 | + if ( ! is_email($user_email)) |
|
| 459 | + $errors->add('user_email', __('Please enter a valid email address.')); |
|
| 460 | 460 | |
| 461 | - $limited_email_domains = get_site_option( 'limited_email_domains' ); |
|
| 462 | - if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) { |
|
| 463 | - $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); |
|
| 464 | - if ( ! in_array( $emaildomain, $limited_email_domains ) ) { |
|
| 461 | + $limited_email_domains = get_site_option('limited_email_domains'); |
|
| 462 | + if (is_array($limited_email_domains) && ! empty($limited_email_domains)) { |
|
| 463 | + $emaildomain = substr($user_email, 1 + strpos($user_email, '@')); |
|
| 464 | + if ( ! in_array($emaildomain, $limited_email_domains)) { |
|
| 465 | 465 | $errors->add('user_email', __('Sorry, that email address is not allowed!')); |
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // Check if the username has been used already. |
| 470 | - if ( username_exists($user_name) ) |
|
| 471 | - $errors->add( 'user_name', __( 'Sorry, that username already exists!' ) ); |
|
| 470 | + if (username_exists($user_name)) |
|
| 471 | + $errors->add('user_name', __('Sorry, that username already exists!')); |
|
| 472 | 472 | |
| 473 | 473 | // Check if the email address has been used already. |
| 474 | - if ( email_exists($user_email) ) |
|
| 475 | - $errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) ); |
|
| 474 | + if (email_exists($user_email)) |
|
| 475 | + $errors->add('user_email', __('Sorry, that email address is already used!')); |
|
| 476 | 476 | |
| 477 | 477 | // Has someone already signed up for this username? |
| 478 | - $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) ); |
|
| 479 | - if ( $signup != null ) { |
|
| 480 | - $registered_at = mysql2date('U', $signup->registered); |
|
| 481 | - $now = current_time( 'timestamp', true ); |
|
| 478 | + $signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name)); |
|
| 479 | + if ($signup != null) { |
|
| 480 | + $registered_at = mysql2date('U', $signup->registered); |
|
| 481 | + $now = current_time('timestamp', true); |
|
| 482 | 482 | $diff = $now - $registered_at; |
| 483 | 483 | // If registered more than two days ago, cancel registration and let this signup go through. |
| 484 | - if ( $diff > 2 * DAY_IN_SECONDS ) |
|
| 485 | - $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) ); |
|
| 484 | + if ($diff > 2 * DAY_IN_SECONDS) |
|
| 485 | + $wpdb->delete($wpdb->signups, array('user_login' => $user_name)); |
|
| 486 | 486 | else |
| 487 | 487 | $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) ); |
|
| 491 | - if ( $signup != null ) { |
|
| 492 | - $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); |
|
| 490 | + $signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email)); |
|
| 491 | + if ($signup != null) { |
|
| 492 | + $diff = current_time('timestamp', true) - mysql2date('U', $signup->registered); |
|
| 493 | 493 | // If registered more than two days ago, cancel registration and let this signup go through. |
| 494 | - if ( $diff > 2 * DAY_IN_SECONDS ) |
|
| 495 | - $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) ); |
|
| 494 | + if ($diff > 2 * DAY_IN_SECONDS) |
|
| 495 | + $wpdb->delete($wpdb->signups, array('user_email' => $user_email)); |
|
| 496 | 496 | else |
| 497 | 497 | $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); |
| 498 | 498 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | * @type WP_Error $errors WP_Error object containing any errors found. |
| 517 | 517 | * } |
| 518 | 518 | */ |
| 519 | - return apply_filters( 'wpmu_validate_user_signup', $result ); |
|
| 519 | + return apply_filters('wpmu_validate_user_signup', $result); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -543,48 +543,48 @@ discard block |
||
| 543 | 543 | * @param WP_User|string $user Optional. The user object to check against the new site name. |
| 544 | 544 | * @return array Contains the new site data and error messages. |
| 545 | 545 | */ |
| 546 | -function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { |
|
| 546 | +function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') { |
|
| 547 | 547 | global $wpdb, $domain; |
| 548 | 548 | |
| 549 | 549 | $current_site = get_current_site(); |
| 550 | 550 | $base = $current_site->path; |
| 551 | 551 | |
| 552 | - $blog_title = strip_tags( $blog_title ); |
|
| 552 | + $blog_title = strip_tags($blog_title); |
|
| 553 | 553 | |
| 554 | 554 | $errors = new WP_Error(); |
| 555 | - $illegal_names = get_site_option( 'illegal_names' ); |
|
| 556 | - if ( $illegal_names == false ) { |
|
| 557 | - $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); |
|
| 558 | - add_site_option( 'illegal_names', $illegal_names ); |
|
| 555 | + $illegal_names = get_site_option('illegal_names'); |
|
| 556 | + if ($illegal_names == false) { |
|
| 557 | + $illegal_names = array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator'); |
|
| 558 | + add_site_option('illegal_names', $illegal_names); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | /* |
| 562 | 562 | * On sub dir installs, some names are so illegal, only a filter can |
| 563 | 563 | * spring them from jail. |
| 564 | 564 | */ |
| 565 | - if ( ! is_subdomain_install() ) { |
|
| 566 | - $illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() ); |
|
| 565 | + if ( ! is_subdomain_install()) { |
|
| 566 | + $illegal_names = array_merge($illegal_names, get_subdirectory_reserved_names()); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - if ( empty( $blogname ) ) |
|
| 570 | - $errors->add('blogname', __( 'Please enter a site name.' ) ); |
|
| 569 | + if (empty($blogname)) |
|
| 570 | + $errors->add('blogname', __('Please enter a site name.')); |
|
| 571 | 571 | |
| 572 | - if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) { |
|
| 573 | - $errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) ); |
|
| 572 | + if (preg_match('/[^a-z0-9]+/', $blogname)) { |
|
| 573 | + $errors->add('blogname', __('Site names can only contain lowercase letters (a-z) and numbers.')); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - if ( in_array( $blogname, $illegal_names ) ) |
|
| 577 | - $errors->add('blogname', __( 'That name is not allowed.' ) ); |
|
| 576 | + if (in_array($blogname, $illegal_names)) |
|
| 577 | + $errors->add('blogname', __('That name is not allowed.')); |
|
| 578 | 578 | |
| 579 | - if ( strlen( $blogname ) < 4 && !is_super_admin() ) |
|
| 580 | - $errors->add('blogname', __( 'Site name must be at least 4 characters.' ) ); |
|
| 579 | + if (strlen($blogname) < 4 && ! is_super_admin()) |
|
| 580 | + $errors->add('blogname', __('Site name must be at least 4 characters.')); |
|
| 581 | 581 | |
| 582 | 582 | // do not allow users to create a blog that conflicts with a page on the main blog. |
| 583 | - if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) |
|
| 584 | - $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) ); |
|
| 583 | + if ( ! is_subdomain_install() && $wpdb->get_var($wpdb->prepare("SELECT post_name FROM ".$wpdb->get_blog_prefix($current_site->blog_id)."posts WHERE post_type = 'page' AND post_name = %s", $blogname))) |
|
| 584 | + $errors->add('blogname', __('Sorry, you may not use that site name.')); |
|
| 585 | 585 | |
| 586 | 586 | // all numeric? |
| 587 | - if ( preg_match( '/^[0-9]*$/', $blogname ) ) |
|
| 587 | + if (preg_match('/^[0-9]*$/', $blogname)) |
|
| 588 | 588 | $errors->add('blogname', __('Sorry, site names must have letters too!')); |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -597,36 +597,36 @@ discard block |
||
| 597 | 597 | * |
| 598 | 598 | * @param string $blogname Site name. |
| 599 | 599 | */ |
| 600 | - $blogname = apply_filters( 'newblogname', $blogname ); |
|
| 600 | + $blogname = apply_filters('newblogname', $blogname); |
|
| 601 | 601 | |
| 602 | - $blog_title = wp_unslash( $blog_title ); |
|
| 602 | + $blog_title = wp_unslash($blog_title); |
|
| 603 | 603 | |
| 604 | - if ( empty( $blog_title ) ) |
|
| 605 | - $errors->add('blog_title', __( 'Please enter a site title.' ) ); |
|
| 604 | + if (empty($blog_title)) |
|
| 605 | + $errors->add('blog_title', __('Please enter a site title.')); |
|
| 606 | 606 | |
| 607 | 607 | // Check if the domain/path has been used already. |
| 608 | - if ( is_subdomain_install() ) { |
|
| 609 | - $mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain ); |
|
| 608 | + if (is_subdomain_install()) { |
|
| 609 | + $mydomain = $blogname.'.'.preg_replace('|^www\.|', '', $domain); |
|
| 610 | 610 | $path = $base; |
| 611 | 611 | } else { |
| 612 | 612 | $mydomain = "$domain"; |
| 613 | 613 | $path = $base.$blogname.'/'; |
| 614 | 614 | } |
| 615 | - if ( domain_exists($mydomain, $path, $current_site->id) ) |
|
| 616 | - $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) ); |
|
| 615 | + if (domain_exists($mydomain, $path, $current_site->id)) |
|
| 616 | + $errors->add('blogname', __('Sorry, that site already exists!')); |
|
| 617 | 617 | |
| 618 | - if ( username_exists( $blogname ) ) { |
|
| 619 | - if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) ) |
|
| 620 | - $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) ); |
|
| 618 | + if (username_exists($blogname)) { |
|
| 619 | + if ( ! is_object($user) || (is_object($user) && ($user->user_login != $blogname))) |
|
| 620 | + $errors->add('blogname', __('Sorry, that site is reserved!')); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | // Has someone already signed up for this domain? |
| 624 | - $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) ); // TODO: Check email too? |
|
| 625 | - if ( ! empty($signup) ) { |
|
| 626 | - $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); |
|
| 624 | + $signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path)); // TODO: Check email too? |
|
| 625 | + if ( ! empty($signup)) { |
|
| 626 | + $diff = current_time('timestamp', true) - mysql2date('U', $signup->registered); |
|
| 627 | 627 | // If registered more than two days ago, cancel registration and let this signup go through. |
| 628 | - if ( $diff > 2 * DAY_IN_SECONDS ) |
|
| 629 | - $wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) ); |
|
| 628 | + if ($diff > 2 * DAY_IN_SECONDS) |
|
| 629 | + $wpdb->delete($wpdb->signups, array('domain' => $mydomain, 'path' => $path)); |
|
| 630 | 630 | else |
| 631 | 631 | $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); |
| 632 | 632 | } |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | * @type WP_Error $errors WP_Error containing any errors found. |
| 650 | 650 | * } |
| 651 | 651 | */ |
| 652 | - return apply_filters( 'wpmu_validate_blog_signup', $result ); |
|
| 652 | + return apply_filters('wpmu_validate_blog_signup', $result); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | /** |
@@ -666,13 +666,13 @@ discard block |
||
| 666 | 666 | * @param string $user_email The user's email address. |
| 667 | 667 | * @param array $meta By default, contains the requested privacy setting and lang_id. |
| 668 | 668 | */ |
| 669 | -function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() ) { |
|
| 669 | +function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = array()) { |
|
| 670 | 670 | global $wpdb; |
| 671 | 671 | |
| 672 | - $key = substr( md5( time() . rand() . $domain ), 0, 16 ); |
|
| 672 | + $key = substr(md5(time().rand().$domain), 0, 16); |
|
| 673 | 673 | $meta = serialize($meta); |
| 674 | 674 | |
| 675 | - $wpdb->insert( $wpdb->signups, array( |
|
| 675 | + $wpdb->insert($wpdb->signups, array( |
|
| 676 | 676 | 'domain' => $domain, |
| 677 | 677 | 'path' => $path, |
| 678 | 678 | 'title' => $title, |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | 'registered' => current_time('mysql', true), |
| 682 | 682 | 'activation_key' => $key, |
| 683 | 683 | 'meta' => $meta |
| 684 | - ) ); |
|
| 684 | + )); |
|
| 685 | 685 | |
| 686 | 686 | /** |
| 687 | 687 | * Fires after site signup information has been written to the database. |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | * @param string $key The user's activation key |
| 697 | 697 | * @param array $meta By default, contains the requested privacy setting and lang_id. |
| 698 | 698 | */ |
| 699 | - do_action( 'after_signup_site', $domain, $path, $title, $user, $user_email, $key, $meta ); |
|
| 699 | + do_action('after_signup_site', $domain, $path, $title, $user, $user_email, $key, $meta); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | /** |
@@ -713,16 +713,16 @@ discard block |
||
| 713 | 713 | * @param string $user_email The user's email address. |
| 714 | 714 | * @param array $meta By default, this is an empty array. |
| 715 | 715 | */ |
| 716 | -function wpmu_signup_user( $user, $user_email, $meta = array() ) { |
|
| 716 | +function wpmu_signup_user($user, $user_email, $meta = array()) { |
|
| 717 | 717 | global $wpdb; |
| 718 | 718 | |
| 719 | 719 | // Format data |
| 720 | - $user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) ); |
|
| 721 | - $user_email = sanitize_email( $user_email ); |
|
| 722 | - $key = substr( md5( time() . rand() . $user_email ), 0, 16 ); |
|
| 720 | + $user = preg_replace('/\s+/', '', sanitize_user($user, true)); |
|
| 721 | + $user_email = sanitize_email($user_email); |
|
| 722 | + $key = substr(md5(time().rand().$user_email), 0, 16); |
|
| 723 | 723 | $meta = serialize($meta); |
| 724 | 724 | |
| 725 | - $wpdb->insert( $wpdb->signups, array( |
|
| 725 | + $wpdb->insert($wpdb->signups, array( |
|
| 726 | 726 | 'domain' => '', |
| 727 | 727 | 'path' => '', |
| 728 | 728 | 'title' => '', |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | 'registered' => current_time('mysql', true), |
| 732 | 732 | 'activation_key' => $key, |
| 733 | 733 | 'meta' => $meta |
| 734 | - ) ); |
|
| 734 | + )); |
|
| 735 | 735 | |
| 736 | 736 | /** |
| 737 | 737 | * Fires after a user's signup information has been written to the database. |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | * @param string $key The user's activation key |
| 744 | 744 | * @param array $meta Additional signup meta. By default, this is an empty array. |
| 745 | 745 | */ |
| 746 | - do_action( 'after_signup_user', $user, $user_email, $key, $meta ); |
|
| 746 | + do_action('after_signup_user', $user, $user_email, $key, $meta); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | * @param array $meta By default, contains the requested privacy setting and lang_id. |
| 771 | 771 | * @return bool |
| 772 | 772 | */ |
| 773 | -function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) { |
|
| 773 | +function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta = array()) { |
|
| 774 | 774 | /** |
| 775 | 775 | * Filters whether to bypass the new site email notification. |
| 776 | 776 | * |
@@ -784,22 +784,22 @@ discard block |
||
| 784 | 784 | * @param string $key Activation key created in wpmu_signup_blog(). |
| 785 | 785 | * @param array $meta By default, contains the requested privacy setting and lang_id. |
| 786 | 786 | */ |
| 787 | - if ( ! apply_filters( 'wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta ) ) { |
|
| 787 | + if ( ! apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta)) { |
|
| 788 | 788 | return false; |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | // Send email with activation link. |
| 792 | - if ( !is_subdomain_install() || get_current_site()->id != 1 ) |
|
| 792 | + if ( ! is_subdomain_install() || get_current_site()->id != 1) |
|
| 793 | 793 | $activate_url = network_site_url("wp-activate.php?key=$key"); |
| 794 | 794 | else |
| 795 | 795 | $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API |
| 796 | 796 | |
| 797 | 797 | $activate_url = esc_url($activate_url); |
| 798 | - $admin_email = get_site_option( 'admin_email' ); |
|
| 799 | - if ( $admin_email == '' ) |
|
| 800 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 801 | - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
|
| 802 | - $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
|
| 798 | + $admin_email = get_site_option('admin_email'); |
|
| 799 | + if ($admin_email == '') |
|
| 800 | + $admin_email = 'support@'.$_SERVER['SERVER_NAME']; |
|
| 801 | + $from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name')); |
|
| 802 | + $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n"; |
|
| 803 | 803 | $message = sprintf( |
| 804 | 804 | /** |
| 805 | 805 | * Filters the message content of the new blog notification email. |
@@ -817,12 +817,12 @@ discard block |
||
| 817 | 817 | * @param string $key Activation key created in wpmu_signup_blog(). |
| 818 | 818 | * @param array $meta By default, contains the requested privacy setting and lang_id. |
| 819 | 819 | */ |
| 820 | - apply_filters( 'wpmu_signup_blog_notification_email', |
|
| 821 | - __( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ), |
|
| 820 | + apply_filters('wpmu_signup_blog_notification_email', |
|
| 821 | + __("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s"), |
|
| 822 | 822 | $domain, $path, $title, $user, $user_email, $key, $meta |
| 823 | 823 | ), |
| 824 | 824 | $activate_url, |
| 825 | - esc_url( "http://{$domain}{$path}" ), |
|
| 825 | + esc_url("http://{$domain}{$path}"), |
|
| 826 | 826 | $key |
| 827 | 827 | ); |
| 828 | 828 | // TODO: Don't hard code activation link. |
@@ -841,14 +841,14 @@ discard block |
||
| 841 | 841 | * @param string $key Activation key created in wpmu_signup_blog(). |
| 842 | 842 | * @param array $meta By default, contains the requested privacy setting and lang_id. |
| 843 | 843 | */ |
| 844 | - apply_filters( 'wpmu_signup_blog_notification_subject', |
|
| 845 | - __( '[%1$s] Activate %2$s' ), |
|
| 844 | + apply_filters('wpmu_signup_blog_notification_subject', |
|
| 845 | + __('[%1$s] Activate %2$s'), |
|
| 846 | 846 | $domain, $path, $title, $user, $user_email, $key, $meta |
| 847 | 847 | ), |
| 848 | 848 | $from_name, |
| 849 | - esc_url( 'http://' . $domain . $path ) |
|
| 849 | + esc_url('http://'.$domain.$path) |
|
| 850 | 850 | ); |
| 851 | - wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
|
| 851 | + wp_mail($user_email, wp_specialchars_decode($subject), $message, $message_headers); |
|
| 852 | 852 | return true; |
| 853 | 853 | } |
| 854 | 854 | |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | * @param array $meta By default, an empty array. |
| 874 | 874 | * @return bool |
| 875 | 875 | */ |
| 876 | -function wpmu_signup_user_notification( $user, $user_email, $key, $meta = array() ) { |
|
| 876 | +function wpmu_signup_user_notification($user, $user_email, $key, $meta = array()) { |
|
| 877 | 877 | /** |
| 878 | 878 | * Filters whether to bypass the email notification for new user sign-up. |
| 879 | 879 | * |
@@ -884,15 +884,15 @@ discard block |
||
| 884 | 884 | * @param string $key Activation key created in wpmu_signup_user(). |
| 885 | 885 | * @param array $meta Signup meta data. |
| 886 | 886 | */ |
| 887 | - if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) ) |
|
| 887 | + if ( ! apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta)) |
|
| 888 | 888 | return false; |
| 889 | 889 | |
| 890 | 890 | // Send email with activation link. |
| 891 | - $admin_email = get_site_option( 'admin_email' ); |
|
| 892 | - if ( $admin_email == '' ) |
|
| 893 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 894 | - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
|
| 895 | - $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
|
| 891 | + $admin_email = get_site_option('admin_email'); |
|
| 892 | + if ($admin_email == '') |
|
| 893 | + $admin_email = 'support@'.$_SERVER['SERVER_NAME']; |
|
| 894 | + $from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name')); |
|
| 895 | + $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n"; |
|
| 896 | 896 | $message = sprintf( |
| 897 | 897 | /** |
| 898 | 898 | * Filters the content of the notification email for new user sign-up. |
@@ -907,11 +907,11 @@ discard block |
||
| 907 | 907 | * @param string $key Activation key created in wpmu_signup_user(). |
| 908 | 908 | * @param array $meta Signup meta data. |
| 909 | 909 | */ |
| 910 | - apply_filters( 'wpmu_signup_user_notification_email', |
|
| 911 | - __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ), |
|
| 910 | + apply_filters('wpmu_signup_user_notification_email', |
|
| 911 | + __("To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login."), |
|
| 912 | 912 | $user, $user_email, $key, $meta |
| 913 | 913 | ), |
| 914 | - site_url( "wp-activate.php?key=$key" ) |
|
| 914 | + site_url("wp-activate.php?key=$key") |
|
| 915 | 915 | ); |
| 916 | 916 | // TODO: Don't hard code activation link. |
| 917 | 917 | $subject = sprintf( |
@@ -926,14 +926,14 @@ discard block |
||
| 926 | 926 | * @param string $key Activation key created in wpmu_signup_user(). |
| 927 | 927 | * @param array $meta Signup meta data. |
| 928 | 928 | */ |
| 929 | - apply_filters( 'wpmu_signup_user_notification_subject', |
|
| 930 | - __( '[%1$s] Activate %2$s' ), |
|
| 929 | + apply_filters('wpmu_signup_user_notification_subject', |
|
| 930 | + __('[%1$s] Activate %2$s'), |
|
| 931 | 931 | $user, $user_email, $key, $meta |
| 932 | 932 | ), |
| 933 | 933 | $from_name, |
| 934 | 934 | $user |
| 935 | 935 | ); |
| 936 | - wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
|
| 936 | + wp_mail($user_email, wp_specialchars_decode($subject), $message, $message_headers); |
|
| 937 | 937 | return true; |
| 938 | 938 | } |
| 939 | 939 | |
@@ -955,38 +955,38 @@ discard block |
||
| 955 | 955 | function wpmu_activate_signup($key) { |
| 956 | 956 | global $wpdb; |
| 957 | 957 | |
| 958 | - $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) ); |
|
| 958 | + $signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key)); |
|
| 959 | 959 | |
| 960 | - if ( empty( $signup ) ) |
|
| 961 | - return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) ); |
|
| 960 | + if (empty($signup)) |
|
| 961 | + return new WP_Error('invalid_key', __('Invalid activation key.')); |
|
| 962 | 962 | |
| 963 | - if ( $signup->active ) { |
|
| 964 | - if ( empty( $signup->domain ) ) |
|
| 965 | - return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup ); |
|
| 963 | + if ($signup->active) { |
|
| 964 | + if (empty($signup->domain)) |
|
| 965 | + return new WP_Error('already_active', __('The user is already active.'), $signup); |
|
| 966 | 966 | else |
| 967 | - return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup ); |
|
| 967 | + return new WP_Error('already_active', __('The site is already active.'), $signup); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | $meta = maybe_unserialize($signup->meta); |
| 971 | - $password = wp_generate_password( 12, false ); |
|
| 971 | + $password = wp_generate_password(12, false); |
|
| 972 | 972 | |
| 973 | 973 | $user_id = username_exists($signup->user_login); |
| 974 | 974 | |
| 975 | - if ( ! $user_id ) |
|
| 975 | + if ( ! $user_id) |
|
| 976 | 976 | $user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email); |
| 977 | 977 | else |
| 978 | 978 | $user_already_exists = true; |
| 979 | 979 | |
| 980 | - if ( ! $user_id ) |
|
| 980 | + if ( ! $user_id) |
|
| 981 | 981 | return new WP_Error('create_user', __('Could not create user'), $signup); |
| 982 | 982 | |
| 983 | 983 | $now = current_time('mysql', true); |
| 984 | 984 | |
| 985 | - if ( empty($signup->domain) ) { |
|
| 986 | - $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); |
|
| 985 | + if (empty($signup->domain)) { |
|
| 986 | + $wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key)); |
|
| 987 | 987 | |
| 988 | - if ( isset( $user_already_exists ) ) |
|
| 989 | - return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup); |
|
| 988 | + if (isset($user_already_exists)) |
|
| 989 | + return new WP_Error('user_already_exists', __('That username is already activated.'), $signup); |
|
| 990 | 990 | |
| 991 | 991 | /** |
| 992 | 992 | * Fires immediately after a new user is activated. |
@@ -997,24 +997,24 @@ discard block |
||
| 997 | 997 | * @param int $password User password. |
| 998 | 998 | * @param array $meta Signup meta data. |
| 999 | 999 | */ |
| 1000 | - do_action( 'wpmu_activate_user', $user_id, $password, $meta ); |
|
| 1001 | - return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta ); |
|
| 1000 | + do_action('wpmu_activate_user', $user_id, $password, $meta); |
|
| 1001 | + return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | - $blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid ); |
|
| 1004 | + $blog_id = wpmu_create_blog($signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid); |
|
| 1005 | 1005 | |
| 1006 | 1006 | // TODO: What to do if we create a user but cannot create a blog? |
| 1007 | - if ( is_wp_error($blog_id) ) { |
|
| 1007 | + if (is_wp_error($blog_id)) { |
|
| 1008 | 1008 | // If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and |
| 1009 | 1009 | // setting the activation flag. Let's just set the active flag and instruct the user to reset their password. |
| 1010 | - if ( 'blog_taken' == $blog_id->get_error_code() ) { |
|
| 1011 | - $blog_id->add_data( $signup ); |
|
| 1012 | - $wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) ); |
|
| 1010 | + if ('blog_taken' == $blog_id->get_error_code()) { |
|
| 1011 | + $blog_id->add_data($signup); |
|
| 1012 | + $wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key)); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | return $blog_id; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); |
|
| 1017 | + $wpdb->update($wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key)); |
|
| 1018 | 1018 | /** |
| 1019 | 1019 | * Fires immediately after a site is activated. |
| 1020 | 1020 | * |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | * @param string $signup_title Site title. |
| 1027 | 1027 | * @param array $meta Signup meta data. |
| 1028 | 1028 | */ |
| 1029 | - do_action( 'wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta ); |
|
| 1029 | + do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta); |
|
| 1030 | 1030 | |
| 1031 | 1031 | return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta); |
| 1032 | 1032 | } |
@@ -1046,16 +1046,16 @@ discard block |
||
| 1046 | 1046 | * @param string $email The new user's email address. |
| 1047 | 1047 | * @return int|false Returns false on failure, or int $user_id on success |
| 1048 | 1048 | */ |
| 1049 | -function wpmu_create_user( $user_name, $password, $email ) { |
|
| 1050 | - $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); |
|
| 1049 | +function wpmu_create_user($user_name, $password, $email) { |
|
| 1050 | + $user_name = preg_replace('/\s+/', '', sanitize_user($user_name, true)); |
|
| 1051 | 1051 | |
| 1052 | - $user_id = wp_create_user( $user_name, $password, $email ); |
|
| 1053 | - if ( is_wp_error( $user_id ) ) |
|
| 1052 | + $user_id = wp_create_user($user_name, $password, $email); |
|
| 1053 | + if (is_wp_error($user_id)) |
|
| 1054 | 1054 | return false; |
| 1055 | 1055 | |
| 1056 | 1056 | // Newly created users have no roles or caps until they are added to a blog. |
| 1057 | - delete_user_option( $user_id, 'capabilities' ); |
|
| 1058 | - delete_user_option( $user_id, 'user_level' ); |
|
| 1057 | + delete_user_option($user_id, 'capabilities'); |
|
| 1058 | + delete_user_option($user_id, 'user_level'); |
|
| 1059 | 1059 | |
| 1060 | 1060 | /** |
| 1061 | 1061 | * Fires immediately after a new user is created. |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | * |
| 1065 | 1065 | * @param int $user_id User ID. |
| 1066 | 1066 | */ |
| 1067 | - do_action( 'wpmu_new_user', $user_id ); |
|
| 1067 | + do_action('wpmu_new_user', $user_id); |
|
| 1068 | 1068 | |
| 1069 | 1069 | return $user_id; |
| 1070 | 1070 | } |
@@ -1091,30 +1091,30 @@ discard block |
||
| 1091 | 1091 | * @param int $site_id Optional. Only relevant on multi-network installs. |
| 1092 | 1092 | * @return int|WP_Error Returns WP_Error object on failure, int $blog_id on success |
| 1093 | 1093 | */ |
| 1094 | -function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) { |
|
| 1095 | - $defaults = array( 'public' => 0 ); |
|
| 1096 | - $meta = wp_parse_args( $meta, $defaults ); |
|
| 1094 | +function wpmu_create_blog($domain, $path, $title, $user_id, $meta = array(), $site_id = 1) { |
|
| 1095 | + $defaults = array('public' => 0); |
|
| 1096 | + $meta = wp_parse_args($meta, $defaults); |
|
| 1097 | 1097 | |
| 1098 | - $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) ); |
|
| 1098 | + $domain = preg_replace('/\s+/', '', sanitize_user($domain, true)); |
|
| 1099 | 1099 | |
| 1100 | - if ( is_subdomain_install() ) |
|
| 1101 | - $domain = str_replace( '@', '', $domain ); |
|
| 1100 | + if (is_subdomain_install()) |
|
| 1101 | + $domain = str_replace('@', '', $domain); |
|
| 1102 | 1102 | |
| 1103 | - $title = strip_tags( $title ); |
|
| 1103 | + $title = strip_tags($title); |
|
| 1104 | 1104 | $user_id = (int) $user_id; |
| 1105 | 1105 | |
| 1106 | - if ( empty($path) ) |
|
| 1106 | + if (empty($path)) |
|
| 1107 | 1107 | $path = '/'; |
| 1108 | 1108 | |
| 1109 | 1109 | // Check if the domain has been used already. We should return an error message. |
| 1110 | - if ( domain_exists($domain, $path, $site_id) ) |
|
| 1111 | - return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); |
|
| 1110 | + if (domain_exists($domain, $path, $site_id)) |
|
| 1111 | + return new WP_Error('blog_taken', __('Sorry, that site already exists!')); |
|
| 1112 | 1112 | |
| 1113 | - if ( ! wp_installing() ) { |
|
| 1114 | - wp_installing( true ); |
|
| 1113 | + if ( ! wp_installing()) { |
|
| 1114 | + wp_installing(true); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) |
|
| 1117 | + if ( ! $blog_id = insert_blog($domain, $path, $site_id)) |
|
| 1118 | 1118 | return new WP_Error('insert_blog', __('Could not create site.')); |
| 1119 | 1119 | |
| 1120 | 1120 | switch_to_blog($blog_id); |
@@ -1123,18 +1123,18 @@ discard block |
||
| 1123 | 1123 | |
| 1124 | 1124 | add_user_to_blog($blog_id, $user_id, 'administrator'); |
| 1125 | 1125 | |
| 1126 | - foreach ( $meta as $key => $value ) { |
|
| 1127 | - if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) |
|
| 1128 | - update_blog_status( $blog_id, $key, $value ); |
|
| 1126 | + foreach ($meta as $key => $value) { |
|
| 1127 | + if (in_array($key, array('public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'))) |
|
| 1128 | + update_blog_status($blog_id, $key, $value); |
|
| 1129 | 1129 | else |
| 1130 | - update_option( $key, $value ); |
|
| 1130 | + update_option($key, $value); |
|
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - add_option( 'WPLANG', get_site_option( 'WPLANG' ) ); |
|
| 1134 | - update_option( 'blog_public', (int) $meta['public'] ); |
|
| 1133 | + add_option('WPLANG', get_site_option('WPLANG')); |
|
| 1134 | + update_option('blog_public', (int) $meta['public']); |
|
| 1135 | 1135 | |
| 1136 | - if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) |
|
| 1137 | - update_user_meta( $user_id, 'primary_blog', $blog_id ); |
|
| 1136 | + if ( ! is_super_admin($user_id) && ! get_user_meta($user_id, 'primary_blog', true)) |
|
| 1137 | + update_user_meta($user_id, 'primary_blog', $blog_id); |
|
| 1138 | 1138 | |
| 1139 | 1139 | restore_current_blog(); |
| 1140 | 1140 | /** |
@@ -1149,9 +1149,9 @@ discard block |
||
| 1149 | 1149 | * @param int $site_id Site ID. Only relevant on multi-network installs. |
| 1150 | 1150 | * @param array $meta Meta data. Used to set initial site options. |
| 1151 | 1151 | */ |
| 1152 | - do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta ); |
|
| 1152 | + do_action('wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta); |
|
| 1153 | 1153 | |
| 1154 | - wp_cache_set( 'last_changed', microtime(), 'sites' ); |
|
| 1154 | + wp_cache_set('last_changed', microtime(), 'sites'); |
|
| 1155 | 1155 | |
| 1156 | 1156 | return $blog_id; |
| 1157 | 1157 | } |
@@ -1168,26 +1168,26 @@ discard block |
||
| 1168 | 1168 | * @param string $deprecated Not used. |
| 1169 | 1169 | * @return bool |
| 1170 | 1170 | */ |
| 1171 | -function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { |
|
| 1172 | - if ( get_site_option( 'registrationnotification' ) != 'yes' ) |
|
| 1171 | +function newblog_notify_siteadmin($blog_id, $deprecated = '') { |
|
| 1172 | + if (get_site_option('registrationnotification') != 'yes') |
|
| 1173 | 1173 | return false; |
| 1174 | 1174 | |
| 1175 | - $email = get_site_option( 'admin_email' ); |
|
| 1176 | - if ( is_email($email) == false ) |
|
| 1175 | + $email = get_site_option('admin_email'); |
|
| 1176 | + if (is_email($email) == false) |
|
| 1177 | 1177 | return false; |
| 1178 | 1178 | |
| 1179 | 1179 | $options_site_url = esc_url(network_admin_url('settings.php')); |
| 1180 | 1180 | |
| 1181 | - switch_to_blog( $blog_id ); |
|
| 1182 | - $blogname = get_option( 'blogname' ); |
|
| 1181 | + switch_to_blog($blog_id); |
|
| 1182 | + $blogname = get_option('blogname'); |
|
| 1183 | 1183 | $siteurl = site_url(); |
| 1184 | 1184 | restore_current_blog(); |
| 1185 | 1185 | |
| 1186 | - $msg = sprintf( __( 'New Site: %1$s |
|
| 1186 | + $msg = sprintf(__('New Site: %1$s |
|
| 1187 | 1187 | URL: %2$s |
| 1188 | 1188 | Remote IP: %3$s |
| 1189 | 1189 | |
| 1190 | -Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); |
|
| 1190 | +Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash($_SERVER['REMOTE_ADDR']), $options_site_url); |
|
| 1191 | 1191 | /** |
| 1192 | 1192 | * Filters the message body of the new site activation email sent |
| 1193 | 1193 | * to the network administrator. |
@@ -1196,9 +1196,9 @@ discard block |
||
| 1196 | 1196 | * |
| 1197 | 1197 | * @param string $msg Email body. |
| 1198 | 1198 | */ |
| 1199 | - $msg = apply_filters( 'newblog_notify_siteadmin', $msg ); |
|
| 1199 | + $msg = apply_filters('newblog_notify_siteadmin', $msg); |
|
| 1200 | 1200 | |
| 1201 | - wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg ); |
|
| 1201 | + wp_mail($email, sprintf(__('New Site Registration: %s'), $siteurl), $msg); |
|
| 1202 | 1202 | return true; |
| 1203 | 1203 | } |
| 1204 | 1204 | |
@@ -1213,22 +1213,22 @@ discard block |
||
| 1213 | 1213 | * @param int $user_id The new user's ID. |
| 1214 | 1214 | * @return bool |
| 1215 | 1215 | */ |
| 1216 | -function newuser_notify_siteadmin( $user_id ) { |
|
| 1217 | - if ( get_site_option( 'registrationnotification' ) != 'yes' ) |
|
| 1216 | +function newuser_notify_siteadmin($user_id) { |
|
| 1217 | + if (get_site_option('registrationnotification') != 'yes') |
|
| 1218 | 1218 | return false; |
| 1219 | 1219 | |
| 1220 | - $email = get_site_option( 'admin_email' ); |
|
| 1220 | + $email = get_site_option('admin_email'); |
|
| 1221 | 1221 | |
| 1222 | - if ( is_email($email) == false ) |
|
| 1222 | + if (is_email($email) == false) |
|
| 1223 | 1223 | return false; |
| 1224 | 1224 | |
| 1225 | - $user = get_userdata( $user_id ); |
|
| 1225 | + $user = get_userdata($user_id); |
|
| 1226 | 1226 | |
| 1227 | 1227 | $options_site_url = esc_url(network_admin_url('settings.php')); |
| 1228 | 1228 | $msg = sprintf(__('New User: %1$s |
| 1229 | 1229 | Remote IP: %2$s |
| 1230 | 1230 | |
| 1231 | -Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); |
|
| 1231 | +Disable these notifications: %3$s'), $user->user_login, wp_unslash($_SERVER['REMOTE_ADDR']), $options_site_url); |
|
| 1232 | 1232 | |
| 1233 | 1233 | /** |
| 1234 | 1234 | * Filters the message body of the new user activation email sent |
@@ -1239,8 +1239,8 @@ discard block |
||
| 1239 | 1239 | * @param string $msg Email body. |
| 1240 | 1240 | * @param WP_User $user WP_User instance of the new user. |
| 1241 | 1241 | */ |
| 1242 | - $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user ); |
|
| 1243 | - wp_mail( $email, sprintf(__('New User Registration: %s'), $user->user_login), $msg ); |
|
| 1242 | + $msg = apply_filters('newuser_notify_siteadmin', $msg, $user); |
|
| 1243 | + wp_mail($email, sprintf(__('New User Registration: %s'), $user->user_login), $msg); |
|
| 1244 | 1244 | return true; |
| 1245 | 1245 | } |
| 1246 | 1246 | |
@@ -1260,15 +1260,15 @@ discard block |
||
| 1260 | 1260 | * @return int |
| 1261 | 1261 | */ |
| 1262 | 1262 | function domain_exists($domain, $path, $site_id = 1) { |
| 1263 | - $path = trailingslashit( $path ); |
|
| 1263 | + $path = trailingslashit($path); |
|
| 1264 | 1264 | $args = array( |
| 1265 | 1265 | 'network_id' => $site_id, |
| 1266 | 1266 | 'domain' => $domain, |
| 1267 | 1267 | 'path' => $path, |
| 1268 | 1268 | 'fields' => 'ids', |
| 1269 | 1269 | ); |
| 1270 | - $result = get_sites( $args ); |
|
| 1271 | - $result = array_shift( $result ); |
|
| 1270 | + $result = get_sites($args); |
|
| 1271 | + $result = array_shift($result); |
|
| 1272 | 1272 | |
| 1273 | 1273 | /** |
| 1274 | 1274 | * Filters whether a blogname is taken. |
@@ -1280,7 +1280,7 @@ discard block |
||
| 1280 | 1280 | * @param string $path Path to be checked. |
| 1281 | 1281 | * @param int $site_id Site ID. Relevant only on multi-network installs. |
| 1282 | 1282 | */ |
| 1283 | - return apply_filters( 'domain_exists', $result, $domain, $path, $site_id ); |
|
| 1283 | + return apply_filters('domain_exists', $result, $domain, $path, $site_id); |
|
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | 1286 | /** |
@@ -1304,12 +1304,12 @@ discard block |
||
| 1304 | 1304 | $path = trailingslashit($path); |
| 1305 | 1305 | $site_id = (int) $site_id; |
| 1306 | 1306 | |
| 1307 | - $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) ); |
|
| 1308 | - if ( ! $result ) |
|
| 1307 | + $result = $wpdb->insert($wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql'))); |
|
| 1308 | + if ( ! $result) |
|
| 1309 | 1309 | return false; |
| 1310 | 1310 | |
| 1311 | 1311 | $blog_id = $wpdb->insert_id; |
| 1312 | - refresh_blog_details( $blog_id ); |
|
| 1312 | + refresh_blog_details($blog_id); |
|
| 1313 | 1313 | |
| 1314 | 1314 | wp_maybe_update_network_site_counts(); |
| 1315 | 1315 | |
@@ -1331,57 +1331,57 @@ discard block |
||
| 1331 | 1331 | * @param int $blog_id The value returned by insert_blog(). |
| 1332 | 1332 | * @param string $blog_title The title of the new site. |
| 1333 | 1333 | */ |
| 1334 | -function install_blog( $blog_id, $blog_title = '' ) { |
|
| 1334 | +function install_blog($blog_id, $blog_title = '') { |
|
| 1335 | 1335 | global $wpdb, $wp_roles, $current_site; |
| 1336 | 1336 | |
| 1337 | 1337 | // Cast for security |
| 1338 | 1338 | $blog_id = (int) $blog_id; |
| 1339 | 1339 | |
| 1340 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 1340 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 1341 | 1341 | |
| 1342 | 1342 | $suppress = $wpdb->suppress_errors(); |
| 1343 | - if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) |
|
| 1344 | - die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' ); |
|
| 1345 | - $wpdb->suppress_errors( $suppress ); |
|
| 1343 | + if ($wpdb->get_results("DESCRIBE {$wpdb->posts}")) |
|
| 1344 | + die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>'); |
|
| 1345 | + $wpdb->suppress_errors($suppress); |
|
| 1346 | 1346 | |
| 1347 | - $url = get_blogaddress_by_id( $blog_id ); |
|
| 1347 | + $url = get_blogaddress_by_id($blog_id); |
|
| 1348 | 1348 | |
| 1349 | 1349 | // Set everything up |
| 1350 | - make_db_current_silent( 'blog' ); |
|
| 1350 | + make_db_current_silent('blog'); |
|
| 1351 | 1351 | populate_options(); |
| 1352 | 1352 | populate_roles(); |
| 1353 | 1353 | |
| 1354 | 1354 | // populate_roles() clears previous role definitions so we start over. |
| 1355 | 1355 | $wp_roles = new WP_Roles(); |
| 1356 | 1356 | |
| 1357 | - $siteurl = $home = untrailingslashit( $url ); |
|
| 1357 | + $siteurl = $home = untrailingslashit($url); |
|
| 1358 | 1358 | |
| 1359 | - if ( ! is_subdomain_install() ) { |
|
| 1359 | + if ( ! is_subdomain_install()) { |
|
| 1360 | 1360 | |
| 1361 | - if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) { |
|
| 1362 | - $siteurl = set_url_scheme( $siteurl, 'https' ); |
|
| 1361 | + if ('https' === parse_url(get_site_option('siteurl'), PHP_URL_SCHEME)) { |
|
| 1362 | + $siteurl = set_url_scheme($siteurl, 'https'); |
|
| 1363 | 1363 | } |
| 1364 | - if ( 'https' === parse_url( get_home_url( $current_site->blog_id ), PHP_URL_SCHEME ) ) { |
|
| 1365 | - $home = set_url_scheme( $home, 'https' ); |
|
| 1364 | + if ('https' === parse_url(get_home_url($current_site->blog_id), PHP_URL_SCHEME)) { |
|
| 1365 | + $home = set_url_scheme($home, 'https'); |
|
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | - update_option( 'siteurl', $siteurl ); |
|
| 1371 | - update_option( 'home', $home ); |
|
| 1370 | + update_option('siteurl', $siteurl); |
|
| 1371 | + update_option('home', $home); |
|
| 1372 | 1372 | |
| 1373 | - if ( get_site_option( 'ms_files_rewriting' ) ) |
|
| 1374 | - update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" ); |
|
| 1373 | + if (get_site_option('ms_files_rewriting')) |
|
| 1374 | + update_option('upload_path', UPLOADBLOGSDIR."/$blog_id/files"); |
|
| 1375 | 1375 | else |
| 1376 | - update_option( 'upload_path', get_blog_option( get_current_site()->blog_id, 'upload_path' ) ); |
|
| 1376 | + update_option('upload_path', get_blog_option(get_current_site()->blog_id, 'upload_path')); |
|
| 1377 | 1377 | |
| 1378 | - update_option( 'blogname', wp_unslash( $blog_title ) ); |
|
| 1379 | - update_option( 'admin_email', '' ); |
|
| 1378 | + update_option('blogname', wp_unslash($blog_title)); |
|
| 1379 | + update_option('admin_email', ''); |
|
| 1380 | 1380 | |
| 1381 | 1381 | // remove all perms |
| 1382 | 1382 | $table_prefix = $wpdb->get_blog_prefix(); |
| 1383 | - delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all |
|
| 1384 | - delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all |
|
| 1383 | + delete_metadata('user', 0, $table_prefix.'user_level', null, true); // delete all |
|
| 1384 | + delete_metadata('user', 0, $table_prefix.'capabilities', null, true); // delete all |
|
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | /** |
@@ -1401,13 +1401,13 @@ discard block |
||
| 1401 | 1401 | function install_blog_defaults($blog_id, $user_id) { |
| 1402 | 1402 | global $wpdb; |
| 1403 | 1403 | |
| 1404 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 1404 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 1405 | 1405 | |
| 1406 | 1406 | $suppress = $wpdb->suppress_errors(); |
| 1407 | 1407 | |
| 1408 | 1408 | wp_install_defaults($user_id); |
| 1409 | 1409 | |
| 1410 | - $wpdb->suppress_errors( $suppress ); |
|
| 1410 | + $wpdb->suppress_errors($suppress); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | /** |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. |
| 1428 | 1428 | * @return bool |
| 1429 | 1429 | */ |
| 1430 | -function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) { |
|
| 1430 | +function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = array()) { |
|
| 1431 | 1431 | $current_site = get_current_site(); |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1443,13 +1443,13 @@ discard block |
||
| 1443 | 1443 | * @param string $title Site title. |
| 1444 | 1444 | * @param array $meta Signup meta data. |
| 1445 | 1445 | */ |
| 1446 | - if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) |
|
| 1446 | + if ( ! apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta)) |
|
| 1447 | 1447 | return false; |
| 1448 | 1448 | |
| 1449 | - $welcome_email = get_site_option( 'welcome_email' ); |
|
| 1450 | - if ( $welcome_email == false ) { |
|
| 1449 | + $welcome_email = get_site_option('welcome_email'); |
|
| 1450 | + if ($welcome_email == false) { |
|
| 1451 | 1451 | /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ |
| 1452 | - $welcome_email = __( 'Howdy USERNAME, |
|
| 1452 | + $welcome_email = __('Howdy USERNAME, |
|
| 1453 | 1453 | |
| 1454 | 1454 | Your new SITE_NAME site has been successfully set up at: |
| 1455 | 1455 | BLOG_URL |
@@ -1466,13 +1466,13 @@ discard block |
||
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | $url = get_blogaddress_by_id($blog_id); |
| 1469 | - $user = get_userdata( $user_id ); |
|
| 1469 | + $user = get_userdata($user_id); |
|
| 1470 | 1470 | |
| 1471 | - $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); |
|
| 1472 | - $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email ); |
|
| 1473 | - $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email ); |
|
| 1474 | - $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); |
|
| 1475 | - $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); |
|
| 1471 | + $welcome_email = str_replace('SITE_NAME', $current_site->site_name, $welcome_email); |
|
| 1472 | + $welcome_email = str_replace('BLOG_TITLE', $title, $welcome_email); |
|
| 1473 | + $welcome_email = str_replace('BLOG_URL', $url, $welcome_email); |
|
| 1474 | + $welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email); |
|
| 1475 | + $welcome_email = str_replace('PASSWORD', $password, $welcome_email); |
|
| 1476 | 1476 | |
| 1477 | 1477 | /** |
| 1478 | 1478 | * Filters the content of the welcome email after site activation. |
@@ -1488,17 +1488,17 @@ discard block |
||
| 1488 | 1488 | * @param string $title Site title. |
| 1489 | 1489 | * @param array $meta Signup meta data. |
| 1490 | 1490 | */ |
| 1491 | - $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta ); |
|
| 1492 | - $admin_email = get_site_option( 'admin_email' ); |
|
| 1491 | + $welcome_email = apply_filters('update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta); |
|
| 1492 | + $admin_email = get_site_option('admin_email'); |
|
| 1493 | 1493 | |
| 1494 | - if ( $admin_email == '' ) |
|
| 1495 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 1494 | + if ($admin_email == '') |
|
| 1495 | + $admin_email = 'support@'.$_SERVER['SERVER_NAME']; |
|
| 1496 | 1496 | |
| 1497 | - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
|
| 1498 | - $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
|
| 1497 | + $from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name')); |
|
| 1498 | + $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n"; |
|
| 1499 | 1499 | $message = $welcome_email; |
| 1500 | 1500 | |
| 1501 | - if ( empty( $current_site->site_name ) ) |
|
| 1501 | + if (empty($current_site->site_name)) |
|
| 1502 | 1502 | $current_site->site_name = 'WordPress'; |
| 1503 | 1503 | |
| 1504 | 1504 | /** |
@@ -1508,8 +1508,8 @@ discard block |
||
| 1508 | 1508 | * |
| 1509 | 1509 | * @param string $subject Subject of the email. |
| 1510 | 1510 | */ |
| 1511 | - $subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_site->site_name, wp_unslash( $title ) ) ); |
|
| 1512 | - wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
|
| 1511 | + $subject = apply_filters('update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, wp_unslash($title))); |
|
| 1512 | + wp_mail($user->user_email, wp_specialchars_decode($subject), $message, $message_headers); |
|
| 1513 | 1513 | return true; |
| 1514 | 1514 | } |
| 1515 | 1515 | |
@@ -1528,7 +1528,7 @@ discard block |
||
| 1528 | 1528 | * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. |
| 1529 | 1529 | * @return bool |
| 1530 | 1530 | */ |
| 1531 | -function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) { |
|
| 1531 | +function wpmu_welcome_user_notification($user_id, $password, $meta = array()) { |
|
| 1532 | 1532 | $current_site = get_current_site(); |
| 1533 | 1533 | |
| 1534 | 1534 | /** |
@@ -1542,12 +1542,12 @@ discard block |
||
| 1542 | 1542 | * @param string $password User password. |
| 1543 | 1543 | * @param array $meta Signup meta data. |
| 1544 | 1544 | */ |
| 1545 | - if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) |
|
| 1545 | + if ( ! apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta)) |
|
| 1546 | 1546 | return false; |
| 1547 | 1547 | |
| 1548 | - $welcome_email = get_site_option( 'welcome_user_email' ); |
|
| 1548 | + $welcome_email = get_site_option('welcome_user_email'); |
|
| 1549 | 1549 | |
| 1550 | - $user = get_userdata( $user_id ); |
|
| 1550 | + $user = get_userdata($user_id); |
|
| 1551 | 1551 | |
| 1552 | 1552 | /** |
| 1553 | 1553 | * Filters the content of the welcome email after user activation. |
@@ -1561,22 +1561,22 @@ discard block |
||
| 1561 | 1561 | * @param string $password User password. |
| 1562 | 1562 | * @param array $meta Signup meta data. |
| 1563 | 1563 | */ |
| 1564 | - $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta ); |
|
| 1565 | - $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); |
|
| 1566 | - $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); |
|
| 1567 | - $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); |
|
| 1568 | - $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email ); |
|
| 1564 | + $welcome_email = apply_filters('update_welcome_user_email', $welcome_email, $user_id, $password, $meta); |
|
| 1565 | + $welcome_email = str_replace('SITE_NAME', $current_site->site_name, $welcome_email); |
|
| 1566 | + $welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email); |
|
| 1567 | + $welcome_email = str_replace('PASSWORD', $password, $welcome_email); |
|
| 1568 | + $welcome_email = str_replace('LOGINLINK', wp_login_url(), $welcome_email); |
|
| 1569 | 1569 | |
| 1570 | - $admin_email = get_site_option( 'admin_email' ); |
|
| 1570 | + $admin_email = get_site_option('admin_email'); |
|
| 1571 | 1571 | |
| 1572 | - if ( $admin_email == '' ) |
|
| 1573 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 1572 | + if ($admin_email == '') |
|
| 1573 | + $admin_email = 'support@'.$_SERVER['SERVER_NAME']; |
|
| 1574 | 1574 | |
| 1575 | - $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
|
| 1576 | - $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
|
| 1575 | + $from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name')); |
|
| 1576 | + $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n"."Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n"; |
|
| 1577 | 1577 | $message = $welcome_email; |
| 1578 | 1578 | |
| 1579 | - if ( empty( $current_site->site_name ) ) |
|
| 1579 | + if (empty($current_site->site_name)) |
|
| 1580 | 1580 | $current_site->site_name = 'WordPress'; |
| 1581 | 1581 | |
| 1582 | 1582 | /** |
@@ -1586,8 +1586,8 @@ discard block |
||
| 1586 | 1586 | * |
| 1587 | 1587 | * @param string $subject Subject of the email. |
| 1588 | 1588 | */ |
| 1589 | - $subject = apply_filters( 'update_welcome_user_subject', sprintf( __( 'New %1$s User: %2$s' ), $current_site->site_name, $user->user_login) ); |
|
| 1590 | - wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
|
| 1589 | + $subject = apply_filters('update_welcome_user_subject', sprintf(__('New %1$s User: %2$s'), $current_site->site_name, $user->user_login)); |
|
| 1590 | + wp_mail($user->user_email, wp_specialchars_decode($subject), $message, $message_headers); |
|
| 1591 | 1591 | return true; |
| 1592 | 1592 | } |
| 1593 | 1593 | |
@@ -1623,26 +1623,26 @@ discard block |
||
| 1623 | 1623 | * @param int $user_id |
| 1624 | 1624 | * @return array Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts |
| 1625 | 1625 | */ |
| 1626 | -function get_most_recent_post_of_user( $user_id ) { |
|
| 1626 | +function get_most_recent_post_of_user($user_id) { |
|
| 1627 | 1627 | global $wpdb; |
| 1628 | 1628 | |
| 1629 | - $user_blogs = get_blogs_of_user( (int) $user_id ); |
|
| 1629 | + $user_blogs = get_blogs_of_user((int) $user_id); |
|
| 1630 | 1630 | $most_recent_post = array(); |
| 1631 | 1631 | |
| 1632 | 1632 | // Walk through each blog and get the most recent post |
| 1633 | 1633 | // published by $user_id |
| 1634 | - foreach ( (array) $user_blogs as $blog ) { |
|
| 1635 | - $prefix = $wpdb->get_blog_prefix( $blog->userblog_id ); |
|
| 1636 | - $recent_post = $wpdb->get_row( $wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A); |
|
| 1634 | + foreach ((array) $user_blogs as $blog) { |
|
| 1635 | + $prefix = $wpdb->get_blog_prefix($blog->userblog_id); |
|
| 1636 | + $recent_post = $wpdb->get_row($wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id), ARRAY_A); |
|
| 1637 | 1637 | |
| 1638 | 1638 | // Make sure we found a post |
| 1639 | - if ( isset($recent_post['ID']) ) { |
|
| 1639 | + if (isset($recent_post['ID'])) { |
|
| 1640 | 1640 | $post_gmt_ts = strtotime($recent_post['post_date_gmt']); |
| 1641 | 1641 | |
| 1642 | 1642 | // If this is the first post checked or if this post is |
| 1643 | 1643 | // newer than the current recent post, make it the new |
| 1644 | 1644 | // most recent post. |
| 1645 | - if ( !isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) { |
|
| 1645 | + if ( ! isset($most_recent_post['post_gmt_ts']) || ($post_gmt_ts > $most_recent_post['post_gmt_ts'])) { |
|
| 1646 | 1646 | $most_recent_post = array( |
| 1647 | 1647 | 'blog_id' => $blog->userblog_id, |
| 1648 | 1648 | 'post_id' => $recent_post['ID'], |
@@ -1669,24 +1669,24 @@ discard block |
||
| 1669 | 1669 | * @param string $directory Full path of a directory. |
| 1670 | 1670 | * @return int Size of the directory in MB. |
| 1671 | 1671 | */ |
| 1672 | -function get_dirsize( $directory ) { |
|
| 1673 | - $dirsize = get_transient( 'dirsize_cache' ); |
|
| 1674 | - if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) |
|
| 1675 | - return $dirsize[ $directory ][ 'size' ]; |
|
| 1672 | +function get_dirsize($directory) { |
|
| 1673 | + $dirsize = get_transient('dirsize_cache'); |
|
| 1674 | + if (is_array($dirsize) && isset($dirsize[$directory]['size'])) |
|
| 1675 | + return $dirsize[$directory]['size']; |
|
| 1676 | 1676 | |
| 1677 | - if ( ! is_array( $dirsize ) ) |
|
| 1677 | + if ( ! is_array($dirsize)) |
|
| 1678 | 1678 | $dirsize = array(); |
| 1679 | 1679 | |
| 1680 | 1680 | // Exclude individual site directories from the total when checking the main site, |
| 1681 | 1681 | // as they are subdirectories and should not be counted. |
| 1682 | - if ( is_main_site() ) { |
|
| 1683 | - $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory, $directory . '/sites' ); |
|
| 1682 | + if (is_main_site()) { |
|
| 1683 | + $dirsize[$directory]['size'] = recurse_dirsize($directory, $directory.'/sites'); |
|
| 1684 | 1684 | } else { |
| 1685 | - $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory ); |
|
| 1685 | + $dirsize[$directory]['size'] = recurse_dirsize($directory); |
|
| 1686 | 1686 | } |
| 1687 | 1687 | |
| 1688 | - set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS ); |
|
| 1689 | - return $dirsize[ $directory ][ 'size' ]; |
|
| 1688 | + set_transient('dirsize_cache', $dirsize, HOUR_IN_SECONDS); |
|
| 1689 | + return $dirsize[$directory]['size']; |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | /** |
@@ -1702,23 +1702,23 @@ discard block |
||
| 1702 | 1702 | * @param string $exclude Optional. Full path of a subdirectory to exclude from the total. |
| 1703 | 1703 | * @return int|false Size in MB if a valid directory. False if not. |
| 1704 | 1704 | */ |
| 1705 | -function recurse_dirsize( $directory, $exclude = null ) { |
|
| 1705 | +function recurse_dirsize($directory, $exclude = null) { |
|
| 1706 | 1706 | $size = 0; |
| 1707 | 1707 | |
| 1708 | - $directory = untrailingslashit( $directory ); |
|
| 1708 | + $directory = untrailingslashit($directory); |
|
| 1709 | 1709 | |
| 1710 | - if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) || $directory === $exclude ) { |
|
| 1710 | + if ( ! file_exists($directory) || ! is_dir($directory) || ! is_readable($directory) || $directory === $exclude) { |
|
| 1711 | 1711 | return false; |
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | if ($handle = opendir($directory)) { |
| 1715 | - while(($file = readdir($handle)) !== false) { |
|
| 1715 | + while (($file = readdir($handle)) !== false) { |
|
| 1716 | 1716 | $path = $directory.'/'.$file; |
| 1717 | 1717 | if ($file != '.' && $file != '..') { |
| 1718 | 1718 | if (is_file($path)) { |
| 1719 | 1719 | $size += filesize($path); |
| 1720 | 1720 | } elseif (is_dir($path)) { |
| 1721 | - $handlesize = recurse_dirsize( $path, $exclude ); |
|
| 1721 | + $handlesize = recurse_dirsize($path, $exclude); |
|
| 1722 | 1722 | if ($handlesize > 0) |
| 1723 | 1723 | $size += $handlesize; |
| 1724 | 1724 | } |
@@ -1743,12 +1743,12 @@ discard block |
||
| 1743 | 1743 | * @param array $mimes |
| 1744 | 1744 | * @return array |
| 1745 | 1745 | */ |
| 1746 | -function check_upload_mimes( $mimes ) { |
|
| 1747 | - $site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) ); |
|
| 1746 | +function check_upload_mimes($mimes) { |
|
| 1747 | + $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif')); |
|
| 1748 | 1748 | $site_mimes = array(); |
| 1749 | - foreach ( $site_exts as $ext ) { |
|
| 1750 | - foreach ( $mimes as $ext_pattern => $mime ) { |
|
| 1751 | - if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) |
|
| 1749 | + foreach ($site_exts as $ext) { |
|
| 1750 | + foreach ($mimes as $ext_pattern => $mime) { |
|
| 1751 | + if ($ext != '' && strpos($ext_pattern, $ext) !== false) |
|
| 1752 | 1752 | $site_mimes[$ext_pattern] = $mime; |
| 1753 | 1753 | } |
| 1754 | 1754 | } |
@@ -1769,9 +1769,9 @@ discard block |
||
| 1769 | 1769 | * |
| 1770 | 1770 | * @param string $deprecated Not used. |
| 1771 | 1771 | */ |
| 1772 | -function update_posts_count( $deprecated = '' ) { |
|
| 1772 | +function update_posts_count($deprecated = '') { |
|
| 1773 | 1773 | global $wpdb; |
| 1774 | - update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) ); |
|
| 1774 | + update_option('post_count', (int) $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'")); |
|
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | 1777 | /** |
@@ -1784,11 +1784,11 @@ discard block |
||
| 1784 | 1784 | * @param int $blog_id |
| 1785 | 1785 | * @param int $user_id |
| 1786 | 1786 | */ |
| 1787 | -function wpmu_log_new_registrations( $blog_id, $user_id ) { |
|
| 1787 | +function wpmu_log_new_registrations($blog_id, $user_id) { |
|
| 1788 | 1788 | global $wpdb; |
| 1789 | - $user = get_userdata( (int) $user_id ); |
|
| 1790 | - if ( $user ) |
|
| 1791 | - $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) ); |
|
| 1789 | + $user = get_userdata((int) $user_id); |
|
| 1790 | + if ($user) |
|
| 1791 | + $wpdb->insert($wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace('/[^0-9., ]/', '', wp_unslash($_SERVER['REMOTE_ADDR'])), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql'))); |
|
| 1792 | 1792 | } |
| 1793 | 1793 | |
| 1794 | 1794 | /** |
@@ -1805,61 +1805,61 @@ discard block |
||
| 1805 | 1805 | * @param string $deprecated Not used. |
| 1806 | 1806 | * @return int An ID from the global terms table mapped from $term_id. |
| 1807 | 1807 | */ |
| 1808 | -function global_terms( $term_id, $deprecated = '' ) { |
|
| 1808 | +function global_terms($term_id, $deprecated = '') { |
|
| 1809 | 1809 | global $wpdb; |
| 1810 | 1810 | static $global_terms_recurse = null; |
| 1811 | 1811 | |
| 1812 | - if ( !global_terms_enabled() ) |
|
| 1812 | + if ( ! global_terms_enabled()) |
|
| 1813 | 1813 | return $term_id; |
| 1814 | 1814 | |
| 1815 | 1815 | // prevent a race condition |
| 1816 | 1816 | $recurse_start = false; |
| 1817 | - if ( $global_terms_recurse === null ) { |
|
| 1817 | + if ($global_terms_recurse === null) { |
|
| 1818 | 1818 | $recurse_start = true; |
| 1819 | 1819 | $global_terms_recurse = 1; |
| 1820 | - } elseif ( 10 < $global_terms_recurse++ ) { |
|
| 1820 | + } elseif (10 < $global_terms_recurse++) { |
|
| 1821 | 1821 | return $term_id; |
| 1822 | 1822 | } |
| 1823 | 1823 | |
| 1824 | - $term_id = intval( $term_id ); |
|
| 1825 | - $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) ); |
|
| 1824 | + $term_id = intval($term_id); |
|
| 1825 | + $c = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id)); |
|
| 1826 | 1826 | |
| 1827 | - $global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) ); |
|
| 1828 | - if ( $global_id == null ) { |
|
| 1829 | - $used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) ); |
|
| 1830 | - if ( null == $used_global_id ) { |
|
| 1831 | - $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); |
|
| 1827 | + $global_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug)); |
|
| 1828 | + if ($global_id == null) { |
|
| 1829 | + $used_global_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id)); |
|
| 1830 | + if (null == $used_global_id) { |
|
| 1831 | + $wpdb->insert($wpdb->sitecategories, array('cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug)); |
|
| 1832 | 1832 | $global_id = $wpdb->insert_id; |
| 1833 | - if ( empty( $global_id ) ) |
|
| 1833 | + if (empty($global_id)) |
|
| 1834 | 1834 | return $term_id; |
| 1835 | 1835 | } else { |
| 1836 | - $max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" ); |
|
| 1837 | - $max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" ); |
|
| 1838 | - $new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 ); |
|
| 1839 | - $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); |
|
| 1836 | + $max_global_id = $wpdb->get_var("SELECT MAX(cat_ID) FROM $wpdb->sitecategories"); |
|
| 1837 | + $max_local_id = $wpdb->get_var("SELECT MAX(term_id) FROM $wpdb->terms"); |
|
| 1838 | + $new_global_id = max($max_global_id, $max_local_id) + mt_rand(100, 400); |
|
| 1839 | + $wpdb->insert($wpdb->sitecategories, array('cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug)); |
|
| 1840 | 1840 | $global_id = $wpdb->insert_id; |
| 1841 | 1841 | } |
| 1842 | - } elseif ( $global_id != $term_id ) { |
|
| 1843 | - $local_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) ); |
|
| 1844 | - if ( null != $local_id ) { |
|
| 1845 | - global_terms( $local_id ); |
|
| 1846 | - if ( 10 < $global_terms_recurse ) { |
|
| 1842 | + } elseif ($global_id != $term_id) { |
|
| 1843 | + $local_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id)); |
|
| 1844 | + if (null != $local_id) { |
|
| 1845 | + global_terms($local_id); |
|
| 1846 | + if (10 < $global_terms_recurse) { |
|
| 1847 | 1847 | $global_id = $term_id; |
| 1848 | 1848 | } |
| 1849 | 1849 | } |
| 1850 | 1850 | } |
| 1851 | 1851 | |
| 1852 | - if ( $global_id != $term_id ) { |
|
| 1853 | - if ( get_option( 'default_category' ) == $term_id ) |
|
| 1854 | - update_option( 'default_category', $global_id ); |
|
| 1852 | + if ($global_id != $term_id) { |
|
| 1853 | + if (get_option('default_category') == $term_id) |
|
| 1854 | + update_option('default_category', $global_id); |
|
| 1855 | 1855 | |
| 1856 | - $wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) ); |
|
| 1857 | - $wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) ); |
|
| 1858 | - $wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) ); |
|
| 1856 | + $wpdb->update($wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id)); |
|
| 1857 | + $wpdb->update($wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id)); |
|
| 1858 | + $wpdb->update($wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id)); |
|
| 1859 | 1859 | |
| 1860 | 1860 | clean_term_cache($term_id); |
| 1861 | 1861 | } |
| 1862 | - if ( $recurse_start ) |
|
| 1862 | + if ($recurse_start) |
|
| 1863 | 1863 | $global_terms_recurse = null; |
| 1864 | 1864 | |
| 1865 | 1865 | return $global_id; |
@@ -1874,8 +1874,8 @@ discard block |
||
| 1874 | 1874 | * @param array|string $deprecated Not used. |
| 1875 | 1875 | * @return array The current site's domain |
| 1876 | 1876 | */ |
| 1877 | -function redirect_this_site( $deprecated = '' ) { |
|
| 1878 | - return array( get_current_site()->domain ); |
|
| 1877 | +function redirect_this_site($deprecated = '') { |
|
| 1878 | + return array(get_current_site()->domain); |
|
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | 1881 | /** |
@@ -1888,12 +1888,12 @@ discard block |
||
| 1888 | 1888 | * @param array $upload |
| 1889 | 1889 | * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message. |
| 1890 | 1890 | */ |
| 1891 | -function upload_is_file_too_big( $upload ) { |
|
| 1892 | - if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) |
|
| 1891 | +function upload_is_file_too_big($upload) { |
|
| 1892 | + if ( ! is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) |
|
| 1893 | 1893 | return $upload; |
| 1894 | 1894 | |
| 1895 | - if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { |
|
| 1896 | - return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) ); |
|
| 1895 | + if (strlen($upload['bits']) > (KB_IN_BYTES * get_site_option('fileupload_maxk', 1500))) { |
|
| 1896 | + return sprintf(__('This file is too big. Files must be less than %d KB in size.').'<br />', get_site_option('fileupload_maxk', 1500)); |
|
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | 1899 | return $upload; |
@@ -1907,7 +1907,7 @@ discard block |
||
| 1907 | 1907 | function signup_nonce_fields() { |
| 1908 | 1908 | $id = mt_rand(); |
| 1909 | 1909 | echo "<input type='hidden' name='signup_form_id' value='{$id}' />"; |
| 1910 | - wp_nonce_field('signup_form_' . $id, '_signup_form', false); |
|
| 1910 | + wp_nonce_field('signup_form_'.$id, '_signup_form', false); |
|
| 1911 | 1911 | } |
| 1912 | 1912 | |
| 1913 | 1913 | /** |
@@ -1918,12 +1918,12 @@ discard block |
||
| 1918 | 1918 | * @param array $result |
| 1919 | 1919 | * @return array |
| 1920 | 1920 | */ |
| 1921 | -function signup_nonce_check( $result ) { |
|
| 1922 | - if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) ) |
|
| 1921 | +function signup_nonce_check($result) { |
|
| 1922 | + if ( ! strpos($_SERVER['PHP_SELF'], 'wp-signup.php')) |
|
| 1923 | 1923 | return $result; |
| 1924 | 1924 | |
| 1925 | - if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] ) |
|
| 1926 | - wp_die( __( 'Please try again.' ) ); |
|
| 1925 | + if (wp_create_nonce('signup_form_'.$_POST['signup_form_id']) != $_POST['_signup_form']) |
|
| 1926 | + wp_die(__('Please try again.')); |
|
| 1927 | 1927 | |
| 1928 | 1928 | return $result; |
| 1929 | 1929 | } |
@@ -1943,10 +1943,10 @@ discard block |
||
| 1943 | 1943 | * |
| 1944 | 1944 | * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT. |
| 1945 | 1945 | */ |
| 1946 | - if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) { |
|
| 1947 | - if ( $destination == '%siteurl%' ) |
|
| 1946 | + if (is_main_site() && is_404() && defined('NOBLOGREDIRECT') && ($destination = apply_filters('blog_redirect_404', NOBLOGREDIRECT))) { |
|
| 1947 | + if ($destination == '%siteurl%') |
|
| 1948 | 1948 | $destination = network_home_url(); |
| 1949 | - wp_redirect( $destination ); |
|
| 1949 | + wp_redirect($destination); |
|
| 1950 | 1950 | exit(); |
| 1951 | 1951 | } |
| 1952 | 1952 | } |
@@ -1961,23 +1961,23 @@ discard block |
||
| 1961 | 1961 | * @since MU |
| 1962 | 1962 | */ |
| 1963 | 1963 | function maybe_add_existing_user_to_blog() { |
| 1964 | - if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) |
|
| 1964 | + if (false === strpos($_SERVER['REQUEST_URI'], '/newbloguser/')) |
|
| 1965 | 1965 | return; |
| 1966 | 1966 | |
| 1967 | - $parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] ); |
|
| 1968 | - $key = array_pop( $parts ); |
|
| 1967 | + $parts = explode('/', $_SERVER['REQUEST_URI']); |
|
| 1968 | + $key = array_pop($parts); |
|
| 1969 | 1969 | |
| 1970 | - if ( $key == '' ) |
|
| 1971 | - $key = array_pop( $parts ); |
|
| 1970 | + if ($key == '') |
|
| 1971 | + $key = array_pop($parts); |
|
| 1972 | 1972 | |
| 1973 | - $details = get_option( 'new_user_' . $key ); |
|
| 1974 | - if ( !empty( $details ) ) |
|
| 1975 | - delete_option( 'new_user_' . $key ); |
|
| 1973 | + $details = get_option('new_user_'.$key); |
|
| 1974 | + if ( ! empty($details)) |
|
| 1975 | + delete_option('new_user_'.$key); |
|
| 1976 | 1976 | |
| 1977 | - if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) |
|
| 1978 | - wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) ); |
|
| 1977 | + if (empty($details) || is_wp_error(add_existing_user_to_blog($details))) |
|
| 1978 | + wp_die(sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url())); |
|
| 1979 | 1979 | |
| 1980 | - wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress › Success' ), array( 'response' => 200 ) ); |
|
| 1980 | + wp_die(sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.'), home_url(), admin_url()), __('WordPress › Success'), array('response' => 200)); |
|
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | /** |
@@ -1990,11 +1990,11 @@ discard block |
||
| 1990 | 1990 | * @param array $details |
| 1991 | 1991 | * @return true|WP_Error|void |
| 1992 | 1992 | */ |
| 1993 | -function add_existing_user_to_blog( $details = false ) { |
|
| 1993 | +function add_existing_user_to_blog($details = false) { |
|
| 1994 | 1994 | global $blog_id; |
| 1995 | 1995 | |
| 1996 | - if ( is_array( $details ) ) { |
|
| 1997 | - $result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] ); |
|
| 1996 | + if (is_array($details)) { |
|
| 1997 | + $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']); |
|
| 1998 | 1998 | /** |
| 1999 | 1999 | * Fires immediately after an existing user is added to a site. |
| 2000 | 2000 | * |
@@ -2003,7 +2003,7 @@ discard block |
||
| 2003 | 2003 | * @param int $user_id User ID. |
| 2004 | 2004 | * @param mixed $result True on success or a WP_Error object if the user doesn't exist. |
| 2005 | 2005 | */ |
| 2006 | - do_action( 'added_existing_user', $details['user_id'], $result ); |
|
| 2006 | + do_action('added_existing_user', $details['user_id'], $result); |
|
| 2007 | 2007 | return $result; |
| 2008 | 2008 | } |
| 2009 | 2009 | } |
@@ -2021,13 +2021,13 @@ discard block |
||
| 2021 | 2021 | * @param mixed $password Ignored. |
| 2022 | 2022 | * @param array $meta |
| 2023 | 2023 | */ |
| 2024 | -function add_new_user_to_blog( $user_id, $password, $meta ) { |
|
| 2025 | - if ( !empty( $meta[ 'add_to_blog' ] ) ) { |
|
| 2026 | - $blog_id = $meta[ 'add_to_blog' ]; |
|
| 2027 | - $role = $meta[ 'new_role' ]; |
|
| 2024 | +function add_new_user_to_blog($user_id, $password, $meta) { |
|
| 2025 | + if ( ! empty($meta['add_to_blog'])) { |
|
| 2026 | + $blog_id = $meta['add_to_blog']; |
|
| 2027 | + $role = $meta['new_role']; |
|
| 2028 | 2028 | remove_user_from_blog($user_id, get_current_site()->blog_id); // remove user from main blog. |
| 2029 | - add_user_to_blog( $blog_id, $user_id, $role ); |
|
| 2030 | - update_user_meta( $user_id, 'primary_blog', $blog_id ); |
|
| 2029 | + add_user_to_blog($blog_id, $user_id, $role); |
|
| 2030 | + update_user_meta($user_id, 'primary_blog', $blog_id); |
|
| 2031 | 2031 | } |
| 2032 | 2032 | } |
| 2033 | 2033 | |
@@ -2038,7 +2038,7 @@ discard block |
||
| 2038 | 2038 | * |
| 2039 | 2039 | * @param PHPMailer $phpmailer The PHPMailer instance, passed by reference. |
| 2040 | 2040 | */ |
| 2041 | -function fix_phpmailer_messageid( $phpmailer ) { |
|
| 2041 | +function fix_phpmailer_messageid($phpmailer) { |
|
| 2042 | 2042 | $phpmailer->Hostname = get_current_site()->domain; |
| 2043 | 2043 | } |
| 2044 | 2044 | |
@@ -2051,16 +2051,16 @@ discard block |
||
| 2051 | 2051 | * or user login name as a string. |
| 2052 | 2052 | * @return bool |
| 2053 | 2053 | */ |
| 2054 | -function is_user_spammy( $user = null ) { |
|
| 2055 | - if ( ! ( $user instanceof WP_User ) ) { |
|
| 2056 | - if ( $user ) { |
|
| 2057 | - $user = get_user_by( 'login', $user ); |
|
| 2054 | +function is_user_spammy($user = null) { |
|
| 2055 | + if ( ! ($user instanceof WP_User)) { |
|
| 2056 | + if ($user) { |
|
| 2057 | + $user = get_user_by('login', $user); |
|
| 2058 | 2058 | } else { |
| 2059 | 2059 | $user = wp_get_current_user(); |
| 2060 | 2060 | } |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | - return $user && isset( $user->spam ) && 1 == $user->spam; |
|
| 2063 | + return $user && isset($user->spam) && 1 == $user->spam; |
|
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | 2066 | /** |
@@ -2073,8 +2073,8 @@ discard block |
||
| 2073 | 2073 | * @param int $old_value |
| 2074 | 2074 | * @param int $value The new public value |
| 2075 | 2075 | */ |
| 2076 | -function update_blog_public( $old_value, $value ) { |
|
| 2077 | - update_blog_status( get_current_blog_id(), 'public', (int) $value ); |
|
| 2076 | +function update_blog_public($old_value, $value) { |
|
| 2077 | + update_blog_status(get_current_blog_id(), 'public', (int) $value); |
|
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | /** |
@@ -2089,16 +2089,16 @@ discard block |
||
| 2089 | 2089 | * @param int $blog_id Optional. Defaults to current blog. |
| 2090 | 2090 | * @return bool |
| 2091 | 2091 | */ |
| 2092 | -function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) { |
|
| 2092 | +function is_user_option_local($key, $user_id = 0, $blog_id = 0) { |
|
| 2093 | 2093 | global $wpdb; |
| 2094 | 2094 | |
| 2095 | 2095 | $current_user = wp_get_current_user(); |
| 2096 | - if ( $blog_id == 0 ) { |
|
| 2096 | + if ($blog_id == 0) { |
|
| 2097 | 2097 | $blog_id = $wpdb->blogid; |
| 2098 | 2098 | } |
| 2099 | - $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key; |
|
| 2099 | + $local_key = $wpdb->get_blog_prefix($blog_id).$key; |
|
| 2100 | 2100 | |
| 2101 | - return isset( $current_user->$local_key ); |
|
| 2101 | + return isset($current_user->$local_key); |
|
| 2102 | 2102 | } |
| 2103 | 2103 | |
| 2104 | 2104 | /** |
@@ -2110,7 +2110,7 @@ discard block |
||
| 2110 | 2110 | */ |
| 2111 | 2111 | function users_can_register_signup_filter() { |
| 2112 | 2112 | $registration = get_site_option('registration'); |
| 2113 | - return ( $registration == 'all' || $registration == 'user' ); |
|
| 2113 | + return ($registration == 'all' || $registration == 'user'); |
|
| 2114 | 2114 | } |
| 2115 | 2115 | |
| 2116 | 2116 | /** |
@@ -2121,12 +2121,12 @@ discard block |
||
| 2121 | 2121 | * @param string $text |
| 2122 | 2122 | * @return string |
| 2123 | 2123 | */ |
| 2124 | -function welcome_user_msg_filter( $text ) { |
|
| 2125 | - if ( !$text ) { |
|
| 2126 | - remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' ); |
|
| 2124 | +function welcome_user_msg_filter($text) { |
|
| 2125 | + if ( ! $text) { |
|
| 2126 | + remove_filter('site_option_welcome_user_email', 'welcome_user_msg_filter'); |
|
| 2127 | 2127 | |
| 2128 | 2128 | /* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */ |
| 2129 | - $text = __( 'Howdy USERNAME, |
|
| 2129 | + $text = __('Howdy USERNAME, |
|
| 2130 | 2130 | |
| 2131 | 2131 | Your new account is set up. |
| 2132 | 2132 | |
@@ -2138,7 +2138,7 @@ discard block |
||
| 2138 | 2138 | Thanks! |
| 2139 | 2139 | |
| 2140 | 2140 | --The Team @ SITE_NAME' ); |
| 2141 | - update_site_option( 'welcome_user_email', $text ); |
|
| 2141 | + update_site_option('welcome_user_email', $text); |
|
| 2142 | 2142 | } |
| 2143 | 2143 | return $text; |
| 2144 | 2144 | } |
@@ -2153,10 +2153,10 @@ discard block |
||
| 2153 | 2153 | * @param bool $force |
| 2154 | 2154 | * @return bool True if forced, false if not forced. |
| 2155 | 2155 | */ |
| 2156 | -function force_ssl_content( $force = '' ) { |
|
| 2156 | +function force_ssl_content($force = '') { |
|
| 2157 | 2157 | static $forced_content = false; |
| 2158 | 2158 | |
| 2159 | - if ( '' != $force ) { |
|
| 2159 | + if ('' != $force) { |
|
| 2160 | 2160 | $old_forced = $forced_content; |
| 2161 | 2161 | $forced_content = $force; |
| 2162 | 2162 | return $old_forced; |
@@ -2175,12 +2175,12 @@ discard block |
||
| 2175 | 2175 | * @param string $url URL |
| 2176 | 2176 | * @return string URL with https as the scheme |
| 2177 | 2177 | */ |
| 2178 | -function filter_SSL( $url ) { |
|
| 2179 | - if ( ! is_string( $url ) ) |
|
| 2180 | - return get_bloginfo( 'url' ); // Return home blog url with proper scheme |
|
| 2178 | +function filter_SSL($url) { |
|
| 2179 | + if ( ! is_string($url)) |
|
| 2180 | + return get_bloginfo('url'); // Return home blog url with proper scheme |
|
| 2181 | 2181 | |
| 2182 | - if ( force_ssl_content() && is_ssl() ) |
|
| 2183 | - $url = set_url_scheme( $url, 'https' ); |
|
| 2182 | + if (force_ssl_content() && is_ssl()) |
|
| 2183 | + $url = set_url_scheme($url, 'https'); |
|
| 2184 | 2184 | |
| 2185 | 2185 | return $url; |
| 2186 | 2186 | } |
@@ -2191,10 +2191,10 @@ discard block |
||
| 2191 | 2191 | * @since 3.1.0 |
| 2192 | 2192 | */ |
| 2193 | 2193 | function wp_schedule_update_network_counts() { |
| 2194 | - if ( !is_main_site() ) |
|
| 2194 | + if ( ! is_main_site()) |
|
| 2195 | 2195 | return; |
| 2196 | 2196 | |
| 2197 | - if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) |
|
| 2197 | + if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing()) |
|
| 2198 | 2198 | wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); |
| 2199 | 2199 | } |
| 2200 | 2200 | |
@@ -2217,7 +2217,7 @@ discard block |
||
| 2217 | 2217 | * @since 3.7.0 |
| 2218 | 2218 | */ |
| 2219 | 2219 | function wp_maybe_update_network_site_counts() { |
| 2220 | - $is_small_network = ! wp_is_large_network( 'sites' ); |
|
| 2220 | + $is_small_network = ! wp_is_large_network('sites'); |
|
| 2221 | 2221 | |
| 2222 | 2222 | /** |
| 2223 | 2223 | * Filters whether to update network site or user counts when a new site is created. |
@@ -2229,7 +2229,7 @@ discard block |
||
| 2229 | 2229 | * @param bool $small_network Whether the network is considered small. |
| 2230 | 2230 | * @param string $context Context. Either 'users' or 'sites'. |
| 2231 | 2231 | */ |
| 2232 | - if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) |
|
| 2232 | + if ( ! apply_filters('enable_live_network_counts', $is_small_network, 'sites')) |
|
| 2233 | 2233 | return; |
| 2234 | 2234 | |
| 2235 | 2235 | wp_update_network_site_counts(); |
@@ -2244,10 +2244,10 @@ discard block |
||
| 2244 | 2244 | * @since 3.7.0 |
| 2245 | 2245 | */ |
| 2246 | 2246 | function wp_maybe_update_network_user_counts() { |
| 2247 | - $is_small_network = ! wp_is_large_network( 'users' ); |
|
| 2247 | + $is_small_network = ! wp_is_large_network('users'); |
|
| 2248 | 2248 | |
| 2249 | 2249 | /** This filter is documented in wp-includes/ms-functions.php */ |
| 2250 | - if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) |
|
| 2250 | + if ( ! apply_filters('enable_live_network_counts', $is_small_network, 'users')) |
|
| 2251 | 2251 | return; |
| 2252 | 2252 | |
| 2253 | 2253 | wp_update_network_user_counts(); |
@@ -2263,15 +2263,15 @@ discard block |
||
| 2263 | 2263 | function wp_update_network_site_counts() { |
| 2264 | 2264 | global $wpdb; |
| 2265 | 2265 | |
| 2266 | - $count = get_sites( array( |
|
| 2266 | + $count = get_sites(array( |
|
| 2267 | 2267 | 'network_id' => $wpdb->siteid, |
| 2268 | 2268 | 'spam' => 0, |
| 2269 | 2269 | 'deleted' => 0, |
| 2270 | 2270 | 'archived' => 0, |
| 2271 | 2271 | 'count' => true, |
| 2272 | - ) ); |
|
| 2272 | + )); |
|
| 2273 | 2273 | |
| 2274 | - update_site_option( 'blog_count', $count ); |
|
| 2274 | + update_site_option('blog_count', $count); |
|
| 2275 | 2275 | } |
| 2276 | 2276 | |
| 2277 | 2277 | /** |
@@ -2284,8 +2284,8 @@ discard block |
||
| 2284 | 2284 | function wp_update_network_user_counts() { |
| 2285 | 2285 | global $wpdb; |
| 2286 | 2286 | |
| 2287 | - $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); |
|
| 2288 | - update_site_option( 'user_count', $count ); |
|
| 2287 | + $count = $wpdb->get_var("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'"); |
|
| 2288 | + update_site_option('user_count', $count); |
|
| 2289 | 2289 | } |
| 2290 | 2290 | |
| 2291 | 2291 | /** |
@@ -2303,10 +2303,10 @@ discard block |
||
| 2303 | 2303 | * |
| 2304 | 2304 | * @param int|bool $space_used The amount of used space, in megabytes. Default false. |
| 2305 | 2305 | */ |
| 2306 | - $space_used = apply_filters( 'pre_get_space_used', false ); |
|
| 2307 | - if ( false === $space_used ) { |
|
| 2306 | + $space_used = apply_filters('pre_get_space_used', false); |
|
| 2307 | + if (false === $space_used) { |
|
| 2308 | 2308 | $upload_dir = wp_upload_dir(); |
| 2309 | - $space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES; |
|
| 2309 | + $space_used = get_dirsize($upload_dir['basedir']) / MB_IN_BYTES; |
|
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | 2312 | return $space_used; |
@@ -2320,12 +2320,12 @@ discard block |
||
| 2320 | 2320 | * @return int Quota in megabytes |
| 2321 | 2321 | */ |
| 2322 | 2322 | function get_space_allowed() { |
| 2323 | - $space_allowed = get_option( 'blog_upload_space' ); |
|
| 2323 | + $space_allowed = get_option('blog_upload_space'); |
|
| 2324 | 2324 | |
| 2325 | - if ( ! is_numeric( $space_allowed ) ) |
|
| 2326 | - $space_allowed = get_site_option( 'blog_upload_space' ); |
|
| 2325 | + if ( ! is_numeric($space_allowed)) |
|
| 2326 | + $space_allowed = get_site_option('blog_upload_space'); |
|
| 2327 | 2327 | |
| 2328 | - if ( ! is_numeric( $space_allowed ) ) |
|
| 2328 | + if ( ! is_numeric($space_allowed)) |
|
| 2329 | 2329 | $space_allowed = 100; |
| 2330 | 2330 | |
| 2331 | 2331 | /** |
@@ -2335,7 +2335,7 @@ discard block |
||
| 2335 | 2335 | * |
| 2336 | 2336 | * @param int $space_allowed Upload quota in megabytes for the current blog. |
| 2337 | 2337 | */ |
| 2338 | - return apply_filters( 'get_space_allowed', $space_allowed ); |
|
| 2338 | + return apply_filters('get_space_allowed', $space_allowed); |
|
| 2339 | 2339 | } |
| 2340 | 2340 | |
| 2341 | 2341 | /** |
@@ -2347,16 +2347,16 @@ discard block |
||
| 2347 | 2347 | */ |
| 2348 | 2348 | function get_upload_space_available() { |
| 2349 | 2349 | $allowed = get_space_allowed(); |
| 2350 | - if ( $allowed < 0 ) { |
|
| 2350 | + if ($allowed < 0) { |
|
| 2351 | 2351 | $allowed = 0; |
| 2352 | 2352 | } |
| 2353 | 2353 | $space_allowed = $allowed * MB_IN_BYTES; |
| 2354 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 2354 | + if (get_site_option('upload_space_check_disabled')) |
|
| 2355 | 2355 | return $space_allowed; |
| 2356 | 2356 | |
| 2357 | 2357 | $space_used = get_space_used() * MB_IN_BYTES; |
| 2358 | 2358 | |
| 2359 | - if ( ( $space_allowed - $space_used ) <= 0 ) |
|
| 2359 | + if (($space_allowed - $space_used) <= 0) |
|
| 2360 | 2360 | return 0; |
| 2361 | 2361 | |
| 2362 | 2362 | return $space_allowed - $space_used; |
@@ -2369,7 +2369,7 @@ discard block |
||
| 2369 | 2369 | * @return bool True if space is available, false otherwise. |
| 2370 | 2370 | */ |
| 2371 | 2371 | function is_upload_space_available() { |
| 2372 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 2372 | + if (get_site_option('upload_space_check_disabled')) |
|
| 2373 | 2373 | return true; |
| 2374 | 2374 | |
| 2375 | 2375 | return (bool) get_upload_space_available(); |
@@ -2383,12 +2383,12 @@ discard block |
||
| 2383 | 2383 | * @param int $size Upload size limit in bytes. |
| 2384 | 2384 | * @return int Upload size limit in bytes. |
| 2385 | 2385 | */ |
| 2386 | -function upload_size_limit_filter( $size ) { |
|
| 2387 | - $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ); |
|
| 2388 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 2389 | - return min( $size, $fileupload_maxk ); |
|
| 2386 | +function upload_size_limit_filter($size) { |
|
| 2387 | + $fileupload_maxk = KB_IN_BYTES * get_site_option('fileupload_maxk', 1500); |
|
| 2388 | + if (get_site_option('upload_space_check_disabled')) |
|
| 2389 | + return min($size, $fileupload_maxk); |
|
| 2390 | 2390 | |
| 2391 | - return min( $size, $fileupload_maxk, get_upload_space_available() ); |
|
| 2391 | + return min($size, $fileupload_maxk, get_upload_space_available()); |
|
| 2392 | 2392 | } |
| 2393 | 2393 | |
| 2394 | 2394 | /** |
@@ -2401,8 +2401,8 @@ discard block |
||
| 2401 | 2401 | * @param string $using 'sites or 'users'. Default is 'sites'. |
| 2402 | 2402 | * @return bool True if the network meets the criteria for large. False otherwise. |
| 2403 | 2403 | */ |
| 2404 | -function wp_is_large_network( $using = 'sites' ) { |
|
| 2405 | - if ( 'users' == $using ) { |
|
| 2404 | +function wp_is_large_network($using = 'sites') { |
|
| 2405 | + if ('users' == $using) { |
|
| 2406 | 2406 | $count = get_user_count(); |
| 2407 | 2407 | /** |
| 2408 | 2408 | * Filters whether the network is considered large. |
@@ -2413,12 +2413,12 @@ discard block |
||
| 2413 | 2413 | * @param string $component The component to count. Accepts 'users', or 'sites'. |
| 2414 | 2414 | * @param int $count The count of items for the component. |
| 2415 | 2415 | */ |
| 2416 | - return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count ); |
|
| 2416 | + return apply_filters('wp_is_large_network', $count > 10000, 'users', $count); |
|
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | 2419 | $count = get_blog_count(); |
| 2420 | 2420 | /** This filter is documented in wp-includes/ms-functions.php */ |
| 2421 | - return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count ); |
|
| 2421 | + return apply_filters('wp_is_large_network', $count > 10000, 'sites', $count); |
|
| 2422 | 2422 | } |
| 2423 | 2423 | |
| 2424 | 2424 | /** |
@@ -2443,5 +2443,5 @@ discard block |
||
| 2443 | 2443 | * |
| 2444 | 2444 | * @param array $subdirectory_reserved_names Array of reserved names. |
| 2445 | 2445 | */ |
| 2446 | - return apply_filters( 'subdirectory_reserved_names', $names ); |
|
| 2446 | + return apply_filters('subdirectory_reserved_names', $names); |
|
| 2447 | 2447 | } |
@@ -42,11 +42,13 @@ discard block |
||
| 42 | 42 | function get_active_blog_for_user( $user_id ) { |
| 43 | 43 | global $wpdb; |
| 44 | 44 | $blogs = get_blogs_of_user( $user_id ); |
| 45 | - if ( empty( $blogs ) ) |
|
| 46 | - return; |
|
| 45 | + if ( empty( $blogs ) ) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 47 | 48 | |
| 48 | - if ( !is_multisite() ) |
|
| 49 | - return $blogs[$wpdb->blogid]; |
|
| 49 | + if ( !is_multisite() ) { |
|
| 50 | + return $blogs[$wpdb->blogid]; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $primary_blog = get_user_meta( $user_id, 'primary_blog', true ); |
| 52 | 54 | $first_blog = current($blogs); |
@@ -69,15 +71,18 @@ discard block |
||
| 69 | 71 | $ret = false; |
| 70 | 72 | if ( is_array( $blogs ) && count( $blogs ) > 0 ) { |
| 71 | 73 | foreach ( (array) $blogs as $blog_id => $blog ) { |
| 72 | - if ( $blog->site_id != $wpdb->siteid ) |
|
| 73 | - continue; |
|
| 74 | + if ( $blog->site_id != $wpdb->siteid ) { |
|
| 75 | + continue; |
|
| 76 | + } |
|
| 74 | 77 | $details = get_blog_details( $blog_id ); |
| 75 | 78 | if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) { |
| 76 | 79 | $ret = $blog; |
| 77 | - if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) |
|
| 78 | - update_user_meta( $user_id, 'primary_blog', $blog_id ); |
|
| 79 | - if ( !get_user_meta($user_id , 'source_domain', true) ) |
|
| 80 | - update_user_meta( $user_id, 'source_domain', $blog->domain ); |
|
| 80 | + if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) { |
|
| 81 | + update_user_meta( $user_id, 'primary_blog', $blog_id ); |
|
| 82 | + } |
|
| 83 | + if ( !get_user_meta($user_id , 'source_domain', true) ) { |
|
| 84 | + update_user_meta( $user_id, 'source_domain', $blog->domain ); |
|
| 85 | + } |
|
| 81 | 86 | break; |
| 82 | 87 | } |
| 83 | 88 | } |
@@ -114,8 +119,9 @@ discard block |
||
| 114 | 119 | * @return int |
| 115 | 120 | */ |
| 116 | 121 | function get_blog_count( $network_id = 0 ) { |
| 117 | - if ( func_num_args() ) |
|
| 118 | - _deprecated_argument( __FUNCTION__, '3.1.0' ); |
|
| 122 | + if ( func_num_args() ) { |
|
| 123 | + _deprecated_argument( __FUNCTION__, '3.1.0' ); |
|
| 124 | + } |
|
| 119 | 125 | |
| 120 | 126 | return get_site_option( 'blog_count' ); |
| 121 | 127 | } |
@@ -223,8 +229,9 @@ discard block |
||
| 223 | 229 | $new_domain = ''; |
| 224 | 230 | $blogs = get_blogs_of_user($user_id); |
| 225 | 231 | foreach ( (array) $blogs as $blog ) { |
| 226 | - if ( $blog->userblog_id == $blog_id ) |
|
| 227 | - continue; |
|
| 232 | + if ( $blog->userblog_id == $blog_id ) { |
|
| 233 | + continue; |
|
| 234 | + } |
|
| 228 | 235 | $new_id = $blog->userblog_id; |
| 229 | 236 | $new_domain = $blog->domain; |
| 230 | 237 | break; |
@@ -308,10 +315,12 @@ discard block |
||
| 308 | 315 | $path = strtolower( $path ); |
| 309 | 316 | $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' ); |
| 310 | 317 | |
| 311 | - if ( $id == -1 ) // blog does not exist |
|
| 318 | + if ( $id == -1 ) { |
|
| 319 | + // blog does not exist |
|
| 312 | 320 | return 0; |
| 313 | - elseif ( $id ) |
|
| 314 | - return (int) $id; |
|
| 321 | + } elseif ( $id ) { |
|
| 322 | + return (int) $id; |
|
| 323 | + } |
|
| 315 | 324 | |
| 316 | 325 | $args = array( |
| 317 | 326 | 'domain' => $domain, |
@@ -348,8 +357,9 @@ discard block |
||
| 348 | 357 | */ |
| 349 | 358 | function is_email_address_unsafe( $user_email ) { |
| 350 | 359 | $banned_names = get_site_option( 'banned_email_domains' ); |
| 351 | - if ( $banned_names && ! is_array( $banned_names ) ) |
|
| 352 | - $banned_names = explode( "\n", $banned_names ); |
|
| 360 | + if ( $banned_names && ! is_array( $banned_names ) ) { |
|
| 361 | + $banned_names = explode( "\n", $banned_names ); |
|
| 362 | + } |
|
| 353 | 363 | |
| 354 | 364 | $is_email_address_unsafe = false; |
| 355 | 365 | |
@@ -360,8 +370,9 @@ discard block |
||
| 360 | 370 | list( $email_local_part, $email_domain ) = explode( '@', $normalized_email ); |
| 361 | 371 | |
| 362 | 372 | foreach ( $banned_names as $banned_domain ) { |
| 363 | - if ( ! $banned_domain ) |
|
| 364 | - continue; |
|
| 373 | + if ( ! $banned_domain ) { |
|
| 374 | + continue; |
|
| 375 | + } |
|
| 365 | 376 | |
| 366 | 377 | if ( $email_domain == $banned_domain ) { |
| 367 | 378 | $is_email_address_unsafe = true; |
@@ -422,8 +433,9 @@ discard block |
||
| 422 | 433 | |
| 423 | 434 | $user_email = sanitize_email( $user_email ); |
| 424 | 435 | |
| 425 | - if ( empty( $user_name ) ) |
|
| 426 | - $errors->add('user_name', __( 'Please enter a username.' ) ); |
|
| 436 | + if ( empty( $user_name ) ) { |
|
| 437 | + $errors->add('user_name', __( 'Please enter a username.' ) ); |
|
| 438 | + } |
|
| 427 | 439 | |
| 428 | 440 | $illegal_names = get_site_option( 'illegal_names' ); |
| 429 | 441 | if ( ! is_array( $illegal_names ) ) { |
@@ -441,22 +453,26 @@ discard block |
||
| 441 | 453 | $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) ); |
| 442 | 454 | } |
| 443 | 455 | |
| 444 | - if ( is_email_address_unsafe( $user_email ) ) |
|
| 445 | - $errors->add('user_email', __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.')); |
|
| 456 | + if ( is_email_address_unsafe( $user_email ) ) { |
|
| 457 | + $errors->add('user_email', __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.')); |
|
| 458 | + } |
|
| 446 | 459 | |
| 447 | - if ( strlen( $user_name ) < 4 ) |
|
| 448 | - $errors->add('user_name', __( 'Username must be at least 4 characters.' ) ); |
|
| 460 | + if ( strlen( $user_name ) < 4 ) { |
|
| 461 | + $errors->add('user_name', __( 'Username must be at least 4 characters.' ) ); |
|
| 462 | + } |
|
| 449 | 463 | |
| 450 | 464 | if ( strlen( $user_name ) > 60 ) { |
| 451 | 465 | $errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) ); |
| 452 | 466 | } |
| 453 | 467 | |
| 454 | 468 | // all numeric? |
| 455 | - if ( preg_match( '/^[0-9]*$/', $user_name ) ) |
|
| 456 | - $errors->add('user_name', __('Sorry, usernames must have letters too!')); |
|
| 469 | + if ( preg_match( '/^[0-9]*$/', $user_name ) ) { |
|
| 470 | + $errors->add('user_name', __('Sorry, usernames must have letters too!')); |
|
| 471 | + } |
|
| 457 | 472 | |
| 458 | - if ( !is_email( $user_email ) ) |
|
| 459 | - $errors->add('user_email', __( 'Please enter a valid email address.' ) ); |
|
| 473 | + if ( !is_email( $user_email ) ) { |
|
| 474 | + $errors->add('user_email', __( 'Please enter a valid email address.' ) ); |
|
| 475 | + } |
|
| 460 | 476 | |
| 461 | 477 | $limited_email_domains = get_site_option( 'limited_email_domains' ); |
| 462 | 478 | if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) { |
@@ -467,12 +483,14 @@ discard block |
||
| 467 | 483 | } |
| 468 | 484 | |
| 469 | 485 | // Check if the username has been used already. |
| 470 | - if ( username_exists($user_name) ) |
|
| 471 | - $errors->add( 'user_name', __( 'Sorry, that username already exists!' ) ); |
|
| 486 | + if ( username_exists($user_name) ) { |
|
| 487 | + $errors->add( 'user_name', __( 'Sorry, that username already exists!' ) ); |
|
| 488 | + } |
|
| 472 | 489 | |
| 473 | 490 | // Check if the email address has been used already. |
| 474 | - if ( email_exists($user_email) ) |
|
| 475 | - $errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) ); |
|
| 491 | + if ( email_exists($user_email) ) { |
|
| 492 | + $errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) ); |
|
| 493 | + } |
|
| 476 | 494 | |
| 477 | 495 | // Has someone already signed up for this username? |
| 478 | 496 | $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) ); |
@@ -481,20 +499,22 @@ discard block |
||
| 481 | 499 | $now = current_time( 'timestamp', true ); |
| 482 | 500 | $diff = $now - $registered_at; |
| 483 | 501 | // If registered more than two days ago, cancel registration and let this signup go through. |
| 484 | - if ( $diff > 2 * DAY_IN_SECONDS ) |
|
| 485 | - $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) ); |
|
| 486 | - else |
|
| 487 | - $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); |
|
| 502 | + if ( $diff > 2 * DAY_IN_SECONDS ) { |
|
| 503 | + $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) ); |
|
| 504 | + } else { |
|
| 505 | + $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); |
|
| 506 | + } |
|
| 488 | 507 | } |
| 489 | 508 | |
| 490 | 509 | $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) ); |
| 491 | 510 | if ( $signup != null ) { |
| 492 | 511 | $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); |
| 493 | 512 | // If registered more than two days ago, cancel registration and let this signup go through. |
| 494 | - if ( $diff > 2 * DAY_IN_SECONDS ) |
|
| 495 | - $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) ); |
|
| 496 | - else |
|
| 497 | - $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); |
|
| 513 | + if ( $diff > 2 * DAY_IN_SECONDS ) { |
|
| 514 | + $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) ); |
|
| 515 | + } else { |
|
| 516 | + $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); |
|
| 517 | + } |
|
| 498 | 518 | } |
| 499 | 519 | |
| 500 | 520 | $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors); |
@@ -566,26 +586,31 @@ discard block |
||
| 566 | 586 | $illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() ); |
| 567 | 587 | } |
| 568 | 588 | |
| 569 | - if ( empty( $blogname ) ) |
|
| 570 | - $errors->add('blogname', __( 'Please enter a site name.' ) ); |
|
| 589 | + if ( empty( $blogname ) ) { |
|
| 590 | + $errors->add('blogname', __( 'Please enter a site name.' ) ); |
|
| 591 | + } |
|
| 571 | 592 | |
| 572 | 593 | if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) { |
| 573 | 594 | $errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) ); |
| 574 | 595 | } |
| 575 | 596 | |
| 576 | - if ( in_array( $blogname, $illegal_names ) ) |
|
| 577 | - $errors->add('blogname', __( 'That name is not allowed.' ) ); |
|
| 597 | + if ( in_array( $blogname, $illegal_names ) ) { |
|
| 598 | + $errors->add('blogname', __( 'That name is not allowed.' ) ); |
|
| 599 | + } |
|
| 578 | 600 | |
| 579 | - if ( strlen( $blogname ) < 4 && !is_super_admin() ) |
|
| 580 | - $errors->add('blogname', __( 'Site name must be at least 4 characters.' ) ); |
|
| 601 | + if ( strlen( $blogname ) < 4 && !is_super_admin() ) { |
|
| 602 | + $errors->add('blogname', __( 'Site name must be at least 4 characters.' ) ); |
|
| 603 | + } |
|
| 581 | 604 | |
| 582 | 605 | // do not allow users to create a blog that conflicts with a page on the main blog. |
| 583 | - if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) |
|
| 584 | - $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) ); |
|
| 606 | + if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) { |
|
| 607 | + $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) ); |
|
| 608 | + } |
|
| 585 | 609 | |
| 586 | 610 | // all numeric? |
| 587 | - if ( preg_match( '/^[0-9]*$/', $blogname ) ) |
|
| 588 | - $errors->add('blogname', __('Sorry, site names must have letters too!')); |
|
| 611 | + if ( preg_match( '/^[0-9]*$/', $blogname ) ) { |
|
| 612 | + $errors->add('blogname', __('Sorry, site names must have letters too!')); |
|
| 613 | + } |
|
| 589 | 614 | |
| 590 | 615 | /** |
| 591 | 616 | * Filters the new site name during registration. |
@@ -601,8 +626,9 @@ discard block |
||
| 601 | 626 | |
| 602 | 627 | $blog_title = wp_unslash( $blog_title ); |
| 603 | 628 | |
| 604 | - if ( empty( $blog_title ) ) |
|
| 605 | - $errors->add('blog_title', __( 'Please enter a site title.' ) ); |
|
| 629 | + if ( empty( $blog_title ) ) { |
|
| 630 | + $errors->add('blog_title', __( 'Please enter a site title.' ) ); |
|
| 631 | + } |
|
| 606 | 632 | |
| 607 | 633 | // Check if the domain/path has been used already. |
| 608 | 634 | if ( is_subdomain_install() ) { |
@@ -612,12 +638,14 @@ discard block |
||
| 612 | 638 | $mydomain = "$domain"; |
| 613 | 639 | $path = $base.$blogname.'/'; |
| 614 | 640 | } |
| 615 | - if ( domain_exists($mydomain, $path, $current_site->id) ) |
|
| 616 | - $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) ); |
|
| 641 | + if ( domain_exists($mydomain, $path, $current_site->id) ) { |
|
| 642 | + $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) ); |
|
| 643 | + } |
|
| 617 | 644 | |
| 618 | 645 | if ( username_exists( $blogname ) ) { |
| 619 | - if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) ) |
|
| 620 | - $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) ); |
|
| 646 | + if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) ) { |
|
| 647 | + $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) ); |
|
| 648 | + } |
|
| 621 | 649 | } |
| 622 | 650 | |
| 623 | 651 | // Has someone already signed up for this domain? |
@@ -625,10 +653,11 @@ discard block |
||
| 625 | 653 | if ( ! empty($signup) ) { |
| 626 | 654 | $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); |
| 627 | 655 | // If registered more than two days ago, cancel registration and let this signup go through. |
| 628 | - if ( $diff > 2 * DAY_IN_SECONDS ) |
|
| 629 | - $wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) ); |
|
| 630 | - else |
|
| 631 | - $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); |
|
| 656 | + if ( $diff > 2 * DAY_IN_SECONDS ) { |
|
| 657 | + $wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) ); |
|
| 658 | + } else { |
|
| 659 | + $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); |
|
| 660 | + } |
|
| 632 | 661 | } |
| 633 | 662 | |
| 634 | 663 | $result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors); |
@@ -789,15 +818,18 @@ discard block |
||
| 789 | 818 | } |
| 790 | 819 | |
| 791 | 820 | // Send email with activation link. |
| 792 | - if ( !is_subdomain_install() || get_current_site()->id != 1 ) |
|
| 793 | - $activate_url = network_site_url("wp-activate.php?key=$key"); |
|
| 794 | - else |
|
| 795 | - $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API |
|
| 821 | + if ( !is_subdomain_install() || get_current_site()->id != 1 ) { |
|
| 822 | + $activate_url = network_site_url("wp-activate.php?key=$key"); |
|
| 823 | + } else { |
|
| 824 | + $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; |
|
| 825 | + } |
|
| 826 | + // @todo use *_url() API |
|
| 796 | 827 | |
| 797 | 828 | $activate_url = esc_url($activate_url); |
| 798 | 829 | $admin_email = get_site_option( 'admin_email' ); |
| 799 | - if ( $admin_email == '' ) |
|
| 800 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 830 | + if ( $admin_email == '' ) { |
|
| 831 | + $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 832 | + } |
|
| 801 | 833 | $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
| 802 | 834 | $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
| 803 | 835 | $message = sprintf( |
@@ -884,13 +916,15 @@ discard block |
||
| 884 | 916 | * @param string $key Activation key created in wpmu_signup_user(). |
| 885 | 917 | * @param array $meta Signup meta data. |
| 886 | 918 | */ |
| 887 | - if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) ) |
|
| 888 | - return false; |
|
| 919 | + if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) ) { |
|
| 920 | + return false; |
|
| 921 | + } |
|
| 889 | 922 | |
| 890 | 923 | // Send email with activation link. |
| 891 | 924 | $admin_email = get_site_option( 'admin_email' ); |
| 892 | - if ( $admin_email == '' ) |
|
| 893 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 925 | + if ( $admin_email == '' ) { |
|
| 926 | + $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 927 | + } |
|
| 894 | 928 | $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
| 895 | 929 | $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
| 896 | 930 | $message = sprintf( |
@@ -957,14 +991,16 @@ discard block |
||
| 957 | 991 | |
| 958 | 992 | $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) ); |
| 959 | 993 | |
| 960 | - if ( empty( $signup ) ) |
|
| 961 | - return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) ); |
|
| 994 | + if ( empty( $signup ) ) { |
|
| 995 | + return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) ); |
|
| 996 | + } |
|
| 962 | 997 | |
| 963 | 998 | if ( $signup->active ) { |
| 964 | - if ( empty( $signup->domain ) ) |
|
| 965 | - return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup ); |
|
| 966 | - else |
|
| 967 | - return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup ); |
|
| 999 | + if ( empty( $signup->domain ) ) { |
|
| 1000 | + return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup ); |
|
| 1001 | + } else { |
|
| 1002 | + return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup ); |
|
| 1003 | + } |
|
| 968 | 1004 | } |
| 969 | 1005 | |
| 970 | 1006 | $meta = maybe_unserialize($signup->meta); |
@@ -972,21 +1008,24 @@ discard block |
||
| 972 | 1008 | |
| 973 | 1009 | $user_id = username_exists($signup->user_login); |
| 974 | 1010 | |
| 975 | - if ( ! $user_id ) |
|
| 976 | - $user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email); |
|
| 977 | - else |
|
| 978 | - $user_already_exists = true; |
|
| 1011 | + if ( ! $user_id ) { |
|
| 1012 | + $user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email); |
|
| 1013 | + } else { |
|
| 1014 | + $user_already_exists = true; |
|
| 1015 | + } |
|
| 979 | 1016 | |
| 980 | - if ( ! $user_id ) |
|
| 981 | - return new WP_Error('create_user', __('Could not create user'), $signup); |
|
| 1017 | + if ( ! $user_id ) { |
|
| 1018 | + return new WP_Error('create_user', __('Could not create user'), $signup); |
|
| 1019 | + } |
|
| 982 | 1020 | |
| 983 | 1021 | $now = current_time('mysql', true); |
| 984 | 1022 | |
| 985 | 1023 | if ( empty($signup->domain) ) { |
| 986 | 1024 | $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); |
| 987 | 1025 | |
| 988 | - if ( isset( $user_already_exists ) ) |
|
| 989 | - return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup); |
|
| 1026 | + if ( isset( $user_already_exists ) ) { |
|
| 1027 | + return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup); |
|
| 1028 | + } |
|
| 990 | 1029 | |
| 991 | 1030 | /** |
| 992 | 1031 | * Fires immediately after a new user is activated. |
@@ -1050,8 +1089,9 @@ discard block |
||
| 1050 | 1089 | $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); |
| 1051 | 1090 | |
| 1052 | 1091 | $user_id = wp_create_user( $user_name, $password, $email ); |
| 1053 | - if ( is_wp_error( $user_id ) ) |
|
| 1054 | - return false; |
|
| 1092 | + if ( is_wp_error( $user_id ) ) { |
|
| 1093 | + return false; |
|
| 1094 | + } |
|
| 1055 | 1095 | |
| 1056 | 1096 | // Newly created users have no roles or caps until they are added to a blog. |
| 1057 | 1097 | delete_user_option( $user_id, 'capabilities' ); |
@@ -1097,25 +1137,29 @@ discard block |
||
| 1097 | 1137 | |
| 1098 | 1138 | $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) ); |
| 1099 | 1139 | |
| 1100 | - if ( is_subdomain_install() ) |
|
| 1101 | - $domain = str_replace( '@', '', $domain ); |
|
| 1140 | + if ( is_subdomain_install() ) { |
|
| 1141 | + $domain = str_replace( '@', '', $domain ); |
|
| 1142 | + } |
|
| 1102 | 1143 | |
| 1103 | 1144 | $title = strip_tags( $title ); |
| 1104 | 1145 | $user_id = (int) $user_id; |
| 1105 | 1146 | |
| 1106 | - if ( empty($path) ) |
|
| 1107 | - $path = '/'; |
|
| 1147 | + if ( empty($path) ) { |
|
| 1148 | + $path = '/'; |
|
| 1149 | + } |
|
| 1108 | 1150 | |
| 1109 | 1151 | // Check if the domain has been used already. We should return an error message. |
| 1110 | - if ( domain_exists($domain, $path, $site_id) ) |
|
| 1111 | - return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); |
|
| 1152 | + if ( domain_exists($domain, $path, $site_id) ) { |
|
| 1153 | + return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); |
|
| 1154 | + } |
|
| 1112 | 1155 | |
| 1113 | 1156 | if ( ! wp_installing() ) { |
| 1114 | 1157 | wp_installing( true ); |
| 1115 | 1158 | } |
| 1116 | 1159 | |
| 1117 | - if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) |
|
| 1118 | - return new WP_Error('insert_blog', __('Could not create site.')); |
|
| 1160 | + if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) { |
|
| 1161 | + return new WP_Error('insert_blog', __('Could not create site.')); |
|
| 1162 | + } |
|
| 1119 | 1163 | |
| 1120 | 1164 | switch_to_blog($blog_id); |
| 1121 | 1165 | install_blog($blog_id, $title); |
@@ -1124,17 +1168,19 @@ discard block |
||
| 1124 | 1168 | add_user_to_blog($blog_id, $user_id, 'administrator'); |
| 1125 | 1169 | |
| 1126 | 1170 | foreach ( $meta as $key => $value ) { |
| 1127 | - if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) |
|
| 1128 | - update_blog_status( $blog_id, $key, $value ); |
|
| 1129 | - else |
|
| 1130 | - update_option( $key, $value ); |
|
| 1171 | + if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) { |
|
| 1172 | + update_blog_status( $blog_id, $key, $value ); |
|
| 1173 | + } else { |
|
| 1174 | + update_option( $key, $value ); |
|
| 1175 | + } |
|
| 1131 | 1176 | } |
| 1132 | 1177 | |
| 1133 | 1178 | add_option( 'WPLANG', get_site_option( 'WPLANG' ) ); |
| 1134 | 1179 | update_option( 'blog_public', (int) $meta['public'] ); |
| 1135 | 1180 | |
| 1136 | - if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) |
|
| 1137 | - update_user_meta( $user_id, 'primary_blog', $blog_id ); |
|
| 1181 | + if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) { |
|
| 1182 | + update_user_meta( $user_id, 'primary_blog', $blog_id ); |
|
| 1183 | + } |
|
| 1138 | 1184 | |
| 1139 | 1185 | restore_current_blog(); |
| 1140 | 1186 | /** |
@@ -1169,12 +1215,14 @@ discard block |
||
| 1169 | 1215 | * @return bool |
| 1170 | 1216 | */ |
| 1171 | 1217 | function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { |
| 1172 | - if ( get_site_option( 'registrationnotification' ) != 'yes' ) |
|
| 1173 | - return false; |
|
| 1218 | + if ( get_site_option( 'registrationnotification' ) != 'yes' ) { |
|
| 1219 | + return false; |
|
| 1220 | + } |
|
| 1174 | 1221 | |
| 1175 | 1222 | $email = get_site_option( 'admin_email' ); |
| 1176 | - if ( is_email($email) == false ) |
|
| 1177 | - return false; |
|
| 1223 | + if ( is_email($email) == false ) { |
|
| 1224 | + return false; |
|
| 1225 | + } |
|
| 1178 | 1226 | |
| 1179 | 1227 | $options_site_url = esc_url(network_admin_url('settings.php')); |
| 1180 | 1228 | |
@@ -1214,13 +1262,15 @@ discard block |
||
| 1214 | 1262 | * @return bool |
| 1215 | 1263 | */ |
| 1216 | 1264 | function newuser_notify_siteadmin( $user_id ) { |
| 1217 | - if ( get_site_option( 'registrationnotification' ) != 'yes' ) |
|
| 1218 | - return false; |
|
| 1265 | + if ( get_site_option( 'registrationnotification' ) != 'yes' ) { |
|
| 1266 | + return false; |
|
| 1267 | + } |
|
| 1219 | 1268 | |
| 1220 | 1269 | $email = get_site_option( 'admin_email' ); |
| 1221 | 1270 | |
| 1222 | - if ( is_email($email) == false ) |
|
| 1223 | - return false; |
|
| 1271 | + if ( is_email($email) == false ) { |
|
| 1272 | + return false; |
|
| 1273 | + } |
|
| 1224 | 1274 | |
| 1225 | 1275 | $user = get_userdata( $user_id ); |
| 1226 | 1276 | |
@@ -1305,8 +1355,9 @@ discard block |
||
| 1305 | 1355 | $site_id = (int) $site_id; |
| 1306 | 1356 | |
| 1307 | 1357 | $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) ); |
| 1308 | - if ( ! $result ) |
|
| 1309 | - return false; |
|
| 1358 | + if ( ! $result ) { |
|
| 1359 | + return false; |
|
| 1360 | + } |
|
| 1310 | 1361 | |
| 1311 | 1362 | $blog_id = $wpdb->insert_id; |
| 1312 | 1363 | refresh_blog_details( $blog_id ); |
@@ -1340,8 +1391,9 @@ discard block |
||
| 1340 | 1391 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 1341 | 1392 | |
| 1342 | 1393 | $suppress = $wpdb->suppress_errors(); |
| 1343 | - if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) |
|
| 1344 | - die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' ); |
|
| 1394 | + if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) { |
|
| 1395 | + die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' ); |
|
| 1396 | + } |
|
| 1345 | 1397 | $wpdb->suppress_errors( $suppress ); |
| 1346 | 1398 | |
| 1347 | 1399 | $url = get_blogaddress_by_id( $blog_id ); |
@@ -1370,10 +1422,11 @@ discard block |
||
| 1370 | 1422 | update_option( 'siteurl', $siteurl ); |
| 1371 | 1423 | update_option( 'home', $home ); |
| 1372 | 1424 | |
| 1373 | - if ( get_site_option( 'ms_files_rewriting' ) ) |
|
| 1374 | - update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" ); |
|
| 1375 | - else |
|
| 1376 | - update_option( 'upload_path', get_blog_option( get_current_site()->blog_id, 'upload_path' ) ); |
|
| 1425 | + if ( get_site_option( 'ms_files_rewriting' ) ) { |
|
| 1426 | + update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" ); |
|
| 1427 | + } else { |
|
| 1428 | + update_option( 'upload_path', get_blog_option( get_current_site()->blog_id, 'upload_path' ) ); |
|
| 1429 | + } |
|
| 1377 | 1430 | |
| 1378 | 1431 | update_option( 'blogname', wp_unslash( $blog_title ) ); |
| 1379 | 1432 | update_option( 'admin_email', '' ); |
@@ -1443,8 +1496,9 @@ discard block |
||
| 1443 | 1496 | * @param string $title Site title. |
| 1444 | 1497 | * @param array $meta Signup meta data. |
| 1445 | 1498 | */ |
| 1446 | - if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) |
|
| 1447 | - return false; |
|
| 1499 | + if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) { |
|
| 1500 | + return false; |
|
| 1501 | + } |
|
| 1448 | 1502 | |
| 1449 | 1503 | $welcome_email = get_site_option( 'welcome_email' ); |
| 1450 | 1504 | if ( $welcome_email == false ) { |
@@ -1491,15 +1545,17 @@ discard block |
||
| 1491 | 1545 | $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta ); |
| 1492 | 1546 | $admin_email = get_site_option( 'admin_email' ); |
| 1493 | 1547 | |
| 1494 | - if ( $admin_email == '' ) |
|
| 1495 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 1548 | + if ( $admin_email == '' ) { |
|
| 1549 | + $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 1550 | + } |
|
| 1496 | 1551 | |
| 1497 | 1552 | $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
| 1498 | 1553 | $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
| 1499 | 1554 | $message = $welcome_email; |
| 1500 | 1555 | |
| 1501 | - if ( empty( $current_site->site_name ) ) |
|
| 1502 | - $current_site->site_name = 'WordPress'; |
|
| 1556 | + if ( empty( $current_site->site_name ) ) { |
|
| 1557 | + $current_site->site_name = 'WordPress'; |
|
| 1558 | + } |
|
| 1503 | 1559 | |
| 1504 | 1560 | /** |
| 1505 | 1561 | * Filters the subject of the welcome email after site activation. |
@@ -1542,8 +1598,9 @@ discard block |
||
| 1542 | 1598 | * @param string $password User password. |
| 1543 | 1599 | * @param array $meta Signup meta data. |
| 1544 | 1600 | */ |
| 1545 | - if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) |
|
| 1546 | - return false; |
|
| 1601 | + if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) { |
|
| 1602 | + return false; |
|
| 1603 | + } |
|
| 1547 | 1604 | |
| 1548 | 1605 | $welcome_email = get_site_option( 'welcome_user_email' ); |
| 1549 | 1606 | |
@@ -1569,15 +1626,17 @@ discard block |
||
| 1569 | 1626 | |
| 1570 | 1627 | $admin_email = get_site_option( 'admin_email' ); |
| 1571 | 1628 | |
| 1572 | - if ( $admin_email == '' ) |
|
| 1573 | - $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 1629 | + if ( $admin_email == '' ) { |
|
| 1630 | + $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
|
| 1631 | + } |
|
| 1574 | 1632 | |
| 1575 | 1633 | $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
| 1576 | 1634 | $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
| 1577 | 1635 | $message = $welcome_email; |
| 1578 | 1636 | |
| 1579 | - if ( empty( $current_site->site_name ) ) |
|
| 1580 | - $current_site->site_name = 'WordPress'; |
|
| 1637 | + if ( empty( $current_site->site_name ) ) { |
|
| 1638 | + $current_site->site_name = 'WordPress'; |
|
| 1639 | + } |
|
| 1581 | 1640 | |
| 1582 | 1641 | /** |
| 1583 | 1642 | * Filters the subject of the welcome email after user activation. |
@@ -1671,11 +1730,13 @@ discard block |
||
| 1671 | 1730 | */ |
| 1672 | 1731 | function get_dirsize( $directory ) { |
| 1673 | 1732 | $dirsize = get_transient( 'dirsize_cache' ); |
| 1674 | - if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) |
|
| 1675 | - return $dirsize[ $directory ][ 'size' ]; |
|
| 1733 | + if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) { |
|
| 1734 | + return $dirsize[ $directory ][ 'size' ]; |
|
| 1735 | + } |
|
| 1676 | 1736 | |
| 1677 | - if ( ! is_array( $dirsize ) ) |
|
| 1678 | - $dirsize = array(); |
|
| 1737 | + if ( ! is_array( $dirsize ) ) { |
|
| 1738 | + $dirsize = array(); |
|
| 1739 | + } |
|
| 1679 | 1740 | |
| 1680 | 1741 | // Exclude individual site directories from the total when checking the main site, |
| 1681 | 1742 | // as they are subdirectories and should not be counted. |
@@ -1719,8 +1780,9 @@ discard block |
||
| 1719 | 1780 | $size += filesize($path); |
| 1720 | 1781 | } elseif (is_dir($path)) { |
| 1721 | 1782 | $handlesize = recurse_dirsize( $path, $exclude ); |
| 1722 | - if ($handlesize > 0) |
|
| 1723 | - $size += $handlesize; |
|
| 1783 | + if ($handlesize > 0) { |
|
| 1784 | + $size += $handlesize; |
|
| 1785 | + } |
|
| 1724 | 1786 | } |
| 1725 | 1787 | } |
| 1726 | 1788 | } |
@@ -1748,8 +1810,9 @@ discard block |
||
| 1748 | 1810 | $site_mimes = array(); |
| 1749 | 1811 | foreach ( $site_exts as $ext ) { |
| 1750 | 1812 | foreach ( $mimes as $ext_pattern => $mime ) { |
| 1751 | - if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) |
|
| 1752 | - $site_mimes[$ext_pattern] = $mime; |
|
| 1813 | + if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) { |
|
| 1814 | + $site_mimes[$ext_pattern] = $mime; |
|
| 1815 | + } |
|
| 1753 | 1816 | } |
| 1754 | 1817 | } |
| 1755 | 1818 | return $site_mimes; |
@@ -1787,9 +1850,10 @@ discard block |
||
| 1787 | 1850 | function wpmu_log_new_registrations( $blog_id, $user_id ) { |
| 1788 | 1851 | global $wpdb; |
| 1789 | 1852 | $user = get_userdata( (int) $user_id ); |
| 1790 | - if ( $user ) |
|
| 1791 | - $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) ); |
|
| 1792 | -} |
|
| 1853 | + if ( $user ) { |
|
| 1854 | + $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) ); |
|
| 1855 | + } |
|
| 1856 | + } |
|
| 1793 | 1857 | |
| 1794 | 1858 | /** |
| 1795 | 1859 | * Maintains a canonical list of terms by syncing terms created for each blog with the global terms table. |
@@ -1809,8 +1873,9 @@ discard block |
||
| 1809 | 1873 | global $wpdb; |
| 1810 | 1874 | static $global_terms_recurse = null; |
| 1811 | 1875 | |
| 1812 | - if ( !global_terms_enabled() ) |
|
| 1813 | - return $term_id; |
|
| 1876 | + if ( !global_terms_enabled() ) { |
|
| 1877 | + return $term_id; |
|
| 1878 | + } |
|
| 1814 | 1879 | |
| 1815 | 1880 | // prevent a race condition |
| 1816 | 1881 | $recurse_start = false; |
@@ -1830,8 +1895,9 @@ discard block |
||
| 1830 | 1895 | if ( null == $used_global_id ) { |
| 1831 | 1896 | $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); |
| 1832 | 1897 | $global_id = $wpdb->insert_id; |
| 1833 | - if ( empty( $global_id ) ) |
|
| 1834 | - return $term_id; |
|
| 1898 | + if ( empty( $global_id ) ) { |
|
| 1899 | + return $term_id; |
|
| 1900 | + } |
|
| 1835 | 1901 | } else { |
| 1836 | 1902 | $max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" ); |
| 1837 | 1903 | $max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" ); |
@@ -1850,8 +1916,9 @@ discard block |
||
| 1850 | 1916 | } |
| 1851 | 1917 | |
| 1852 | 1918 | if ( $global_id != $term_id ) { |
| 1853 | - if ( get_option( 'default_category' ) == $term_id ) |
|
| 1854 | - update_option( 'default_category', $global_id ); |
|
| 1919 | + if ( get_option( 'default_category' ) == $term_id ) { |
|
| 1920 | + update_option( 'default_category', $global_id ); |
|
| 1921 | + } |
|
| 1855 | 1922 | |
| 1856 | 1923 | $wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) ); |
| 1857 | 1924 | $wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) ); |
@@ -1859,8 +1926,9 @@ discard block |
||
| 1859 | 1926 | |
| 1860 | 1927 | clean_term_cache($term_id); |
| 1861 | 1928 | } |
| 1862 | - if ( $recurse_start ) |
|
| 1863 | - $global_terms_recurse = null; |
|
| 1929 | + if ( $recurse_start ) { |
|
| 1930 | + $global_terms_recurse = null; |
|
| 1931 | + } |
|
| 1864 | 1932 | |
| 1865 | 1933 | return $global_id; |
| 1866 | 1934 | } |
@@ -1889,8 +1957,9 @@ discard block |
||
| 1889 | 1957 | * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message. |
| 1890 | 1958 | */ |
| 1891 | 1959 | function upload_is_file_too_big( $upload ) { |
| 1892 | - if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) |
|
| 1893 | - return $upload; |
|
| 1960 | + if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) { |
|
| 1961 | + return $upload; |
|
| 1962 | + } |
|
| 1894 | 1963 | |
| 1895 | 1964 | if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { |
| 1896 | 1965 | return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) ); |
@@ -1919,11 +1988,13 @@ discard block |
||
| 1919 | 1988 | * @return array |
| 1920 | 1989 | */ |
| 1921 | 1990 | function signup_nonce_check( $result ) { |
| 1922 | - if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) ) |
|
| 1923 | - return $result; |
|
| 1991 | + if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) ) { |
|
| 1992 | + return $result; |
|
| 1993 | + } |
|
| 1924 | 1994 | |
| 1925 | - if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] ) |
|
| 1926 | - wp_die( __( 'Please try again.' ) ); |
|
| 1995 | + if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] ) { |
|
| 1996 | + wp_die( __( 'Please try again.' ) ); |
|
| 1997 | + } |
|
| 1927 | 1998 | |
| 1928 | 1999 | return $result; |
| 1929 | 2000 | } |
@@ -1944,8 +2015,9 @@ discard block |
||
| 1944 | 2015 | * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT. |
| 1945 | 2016 | */ |
| 1946 | 2017 | if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) { |
| 1947 | - if ( $destination == '%siteurl%' ) |
|
| 1948 | - $destination = network_home_url(); |
|
| 2018 | + if ( $destination == '%siteurl%' ) { |
|
| 2019 | + $destination = network_home_url(); |
|
| 2020 | + } |
|
| 1949 | 2021 | wp_redirect( $destination ); |
| 1950 | 2022 | exit(); |
| 1951 | 2023 | } |
@@ -1961,21 +2033,25 @@ discard block |
||
| 1961 | 2033 | * @since MU |
| 1962 | 2034 | */ |
| 1963 | 2035 | function maybe_add_existing_user_to_blog() { |
| 1964 | - if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) |
|
| 1965 | - return; |
|
| 2036 | + if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) { |
|
| 2037 | + return; |
|
| 2038 | + } |
|
| 1966 | 2039 | |
| 1967 | 2040 | $parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] ); |
| 1968 | 2041 | $key = array_pop( $parts ); |
| 1969 | 2042 | |
| 1970 | - if ( $key == '' ) |
|
| 1971 | - $key = array_pop( $parts ); |
|
| 2043 | + if ( $key == '' ) { |
|
| 2044 | + $key = array_pop( $parts ); |
|
| 2045 | + } |
|
| 1972 | 2046 | |
| 1973 | 2047 | $details = get_option( 'new_user_' . $key ); |
| 1974 | - if ( !empty( $details ) ) |
|
| 1975 | - delete_option( 'new_user_' . $key ); |
|
| 2048 | + if ( !empty( $details ) ) { |
|
| 2049 | + delete_option( 'new_user_' . $key ); |
|
| 2050 | + } |
|
| 1976 | 2051 | |
| 1977 | - if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) |
|
| 1978 | - wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) ); |
|
| 2052 | + if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) { |
|
| 2053 | + wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) ); |
|
| 2054 | + } |
|
| 1979 | 2055 | |
| 1980 | 2056 | wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress › Success' ), array( 'response' => 200 ) ); |
| 1981 | 2057 | } |
@@ -2176,11 +2252,14 @@ discard block |
||
| 2176 | 2252 | * @return string URL with https as the scheme |
| 2177 | 2253 | */ |
| 2178 | 2254 | function filter_SSL( $url ) { |
| 2179 | - if ( ! is_string( $url ) ) |
|
| 2180 | - return get_bloginfo( 'url' ); // Return home blog url with proper scheme |
|
| 2255 | + if ( ! is_string( $url ) ) { |
|
| 2256 | + return get_bloginfo( 'url' ); |
|
| 2257 | + } |
|
| 2258 | + // Return home blog url with proper scheme |
|
| 2181 | 2259 | |
| 2182 | - if ( force_ssl_content() && is_ssl() ) |
|
| 2183 | - $url = set_url_scheme( $url, 'https' ); |
|
| 2260 | + if ( force_ssl_content() && is_ssl() ) { |
|
| 2261 | + $url = set_url_scheme( $url, 'https' ); |
|
| 2262 | + } |
|
| 2184 | 2263 | |
| 2185 | 2264 | return $url; |
| 2186 | 2265 | } |
@@ -2191,12 +2270,14 @@ discard block |
||
| 2191 | 2270 | * @since 3.1.0 |
| 2192 | 2271 | */ |
| 2193 | 2272 | function wp_schedule_update_network_counts() { |
| 2194 | - if ( !is_main_site() ) |
|
| 2195 | - return; |
|
| 2273 | + if ( !is_main_site() ) { |
|
| 2274 | + return; |
|
| 2275 | + } |
|
| 2196 | 2276 | |
| 2197 | - if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) |
|
| 2198 | - wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); |
|
| 2199 | -} |
|
| 2277 | + if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) { |
|
| 2278 | + wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); |
|
| 2279 | + } |
|
| 2280 | + } |
|
| 2200 | 2281 | |
| 2201 | 2282 | /** |
| 2202 | 2283 | * Update the network-wide counts for the current network. |
@@ -2229,8 +2310,9 @@ discard block |
||
| 2229 | 2310 | * @param bool $small_network Whether the network is considered small. |
| 2230 | 2311 | * @param string $context Context. Either 'users' or 'sites'. |
| 2231 | 2312 | */ |
| 2232 | - if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) |
|
| 2233 | - return; |
|
| 2313 | + if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) { |
|
| 2314 | + return; |
|
| 2315 | + } |
|
| 2234 | 2316 | |
| 2235 | 2317 | wp_update_network_site_counts(); |
| 2236 | 2318 | } |
@@ -2247,8 +2329,9 @@ discard block |
||
| 2247 | 2329 | $is_small_network = ! wp_is_large_network( 'users' ); |
| 2248 | 2330 | |
| 2249 | 2331 | /** This filter is documented in wp-includes/ms-functions.php */ |
| 2250 | - if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) |
|
| 2251 | - return; |
|
| 2332 | + if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) { |
|
| 2333 | + return; |
|
| 2334 | + } |
|
| 2252 | 2335 | |
| 2253 | 2336 | wp_update_network_user_counts(); |
| 2254 | 2337 | } |
@@ -2322,11 +2405,13 @@ discard block |
||
| 2322 | 2405 | function get_space_allowed() { |
| 2323 | 2406 | $space_allowed = get_option( 'blog_upload_space' ); |
| 2324 | 2407 | |
| 2325 | - if ( ! is_numeric( $space_allowed ) ) |
|
| 2326 | - $space_allowed = get_site_option( 'blog_upload_space' ); |
|
| 2408 | + if ( ! is_numeric( $space_allowed ) ) { |
|
| 2409 | + $space_allowed = get_site_option( 'blog_upload_space' ); |
|
| 2410 | + } |
|
| 2327 | 2411 | |
| 2328 | - if ( ! is_numeric( $space_allowed ) ) |
|
| 2329 | - $space_allowed = 100; |
|
| 2412 | + if ( ! is_numeric( $space_allowed ) ) { |
|
| 2413 | + $space_allowed = 100; |
|
| 2414 | + } |
|
| 2330 | 2415 | |
| 2331 | 2416 | /** |
| 2332 | 2417 | * Filters the upload quota for the current site. |
@@ -2351,13 +2436,15 @@ discard block |
||
| 2351 | 2436 | $allowed = 0; |
| 2352 | 2437 | } |
| 2353 | 2438 | $space_allowed = $allowed * MB_IN_BYTES; |
| 2354 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 2355 | - return $space_allowed; |
|
| 2439 | + if ( get_site_option( 'upload_space_check_disabled' ) ) { |
|
| 2440 | + return $space_allowed; |
|
| 2441 | + } |
|
| 2356 | 2442 | |
| 2357 | 2443 | $space_used = get_space_used() * MB_IN_BYTES; |
| 2358 | 2444 | |
| 2359 | - if ( ( $space_allowed - $space_used ) <= 0 ) |
|
| 2360 | - return 0; |
|
| 2445 | + if ( ( $space_allowed - $space_used ) <= 0 ) { |
|
| 2446 | + return 0; |
|
| 2447 | + } |
|
| 2361 | 2448 | |
| 2362 | 2449 | return $space_allowed - $space_used; |
| 2363 | 2450 | } |
@@ -2369,8 +2456,9 @@ discard block |
||
| 2369 | 2456 | * @return bool True if space is available, false otherwise. |
| 2370 | 2457 | */ |
| 2371 | 2458 | function is_upload_space_available() { |
| 2372 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 2373 | - return true; |
|
| 2459 | + if ( get_site_option( 'upload_space_check_disabled' ) ) { |
|
| 2460 | + return true; |
|
| 2461 | + } |
|
| 2374 | 2462 | |
| 2375 | 2463 | return (bool) get_upload_space_available(); |
| 2376 | 2464 | } |
@@ -2385,8 +2473,9 @@ discard block |
||
| 2385 | 2473 | */ |
| 2386 | 2474 | function upload_size_limit_filter( $size ) { |
| 2387 | 2475 | $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ); |
| 2388 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 2389 | - return min( $size, $fileupload_maxk ); |
|
| 2476 | + if ( get_site_option( 'upload_space_check_disabled' ) ) { |
|
| 2477 | + return min( $size, $fileupload_maxk ); |
|
| 2478 | + } |
|
| 2390 | 2479 | |
| 2391 | 2480 | return min( $size, $fileupload_maxk, get_upload_space_available() ); |
| 2392 | 2481 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | function create_initial_taxonomies() { |
| 25 | 25 | global $wp_rewrite; |
| 26 | 26 | |
| 27 | - if ( ! did_action( 'init' ) ) { |
|
| 28 | - $rewrite = array( 'category' => false, 'post_tag' => false, 'post_format' => false ); |
|
| 27 | + if ( ! did_action('init')) { |
|
| 28 | + $rewrite = array('category' => false, 'post_tag' => false, 'post_format' => false); |
|
| 29 | 29 | } else { |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param string $context Context of the rewrite base. Default 'type'. |
| 37 | 37 | */ |
| 38 | - $post_format_base = apply_filters( 'post_format_rewrite_base', 'type' ); |
|
| 38 | + $post_format_base = apply_filters('post_format_rewrite_base', 'type'); |
|
| 39 | 39 | $rewrite = array( |
| 40 | 40 | 'category' => array( |
| 41 | 41 | 'hierarchical' => true, |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | 'with_front' => ! get_option('tag_base') || $wp_rewrite->using_index_permalinks(), |
| 50 | 50 | 'ep_mask' => EP_TAGS, |
| 51 | 51 | ), |
| 52 | - 'post_format' => $post_format_base ? array( 'slug' => $post_format_base ) : false, |
|
| 52 | + 'post_format' => $post_format_base ? array('slug' => $post_format_base) : false, |
|
| 53 | 53 | ); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - register_taxonomy( 'category', 'post', array( |
|
| 56 | + register_taxonomy('category', 'post', array( |
|
| 57 | 57 | 'hierarchical' => true, |
| 58 | 58 | 'query_var' => 'category_name', |
| 59 | 59 | 'rewrite' => $rewrite['category'], |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | 'show_ui' => true, |
| 62 | 62 | 'show_admin_column' => true, |
| 63 | 63 | '_builtin' => true, |
| 64 | - ) ); |
|
| 64 | + )); |
|
| 65 | 65 | |
| 66 | - register_taxonomy( 'post_tag', 'post', array( |
|
| 66 | + register_taxonomy('post_tag', 'post', array( |
|
| 67 | 67 | 'hierarchical' => false, |
| 68 | 68 | 'query_var' => 'tag', |
| 69 | 69 | 'rewrite' => $rewrite['post_tag'], |
@@ -71,34 +71,34 @@ discard block |
||
| 71 | 71 | 'show_ui' => true, |
| 72 | 72 | 'show_admin_column' => true, |
| 73 | 73 | '_builtin' => true, |
| 74 | - ) ); |
|
| 74 | + )); |
|
| 75 | 75 | |
| 76 | - register_taxonomy( 'nav_menu', 'nav_menu_item', array( |
|
| 76 | + register_taxonomy('nav_menu', 'nav_menu_item', array( |
|
| 77 | 77 | 'public' => false, |
| 78 | 78 | 'hierarchical' => false, |
| 79 | 79 | 'labels' => array( |
| 80 | - 'name' => __( 'Navigation Menus' ), |
|
| 81 | - 'singular_name' => __( 'Navigation Menu' ), |
|
| 80 | + 'name' => __('Navigation Menus'), |
|
| 81 | + 'singular_name' => __('Navigation Menu'), |
|
| 82 | 82 | ), |
| 83 | 83 | 'query_var' => false, |
| 84 | 84 | 'rewrite' => false, |
| 85 | 85 | 'show_ui' => false, |
| 86 | 86 | '_builtin' => true, |
| 87 | 87 | 'show_in_nav_menus' => false, |
| 88 | - ) ); |
|
| 88 | + )); |
|
| 89 | 89 | |
| 90 | - register_taxonomy( 'link_category', 'link', array( |
|
| 90 | + register_taxonomy('link_category', 'link', array( |
|
| 91 | 91 | 'hierarchical' => false, |
| 92 | 92 | 'labels' => array( |
| 93 | - 'name' => __( 'Link Categories' ), |
|
| 94 | - 'singular_name' => __( 'Link Category' ), |
|
| 95 | - 'search_items' => __( 'Search Link Categories' ), |
|
| 93 | + 'name' => __('Link Categories'), |
|
| 94 | + 'singular_name' => __('Link Category'), |
|
| 95 | + 'search_items' => __('Search Link Categories'), |
|
| 96 | 96 | 'popular_items' => null, |
| 97 | - 'all_items' => __( 'All Link Categories' ), |
|
| 98 | - 'edit_item' => __( 'Edit Link Category' ), |
|
| 99 | - 'update_item' => __( 'Update Link Category' ), |
|
| 100 | - 'add_new_item' => __( 'Add New Link Category' ), |
|
| 101 | - 'new_item_name' => __( 'New Link Category Name' ), |
|
| 97 | + 'all_items' => __('All Link Categories'), |
|
| 98 | + 'edit_item' => __('Edit Link Category'), |
|
| 99 | + 'update_item' => __('Update Link Category'), |
|
| 100 | + 'add_new_item' => __('Add New Link Category'), |
|
| 101 | + 'new_item_name' => __('New Link Category Name'), |
|
| 102 | 102 | 'separate_items_with_commas' => null, |
| 103 | 103 | 'add_or_remove_items' => null, |
| 104 | 104 | 'choose_from_most_used' => null, |
@@ -114,21 +114,21 @@ discard block |
||
| 114 | 114 | 'public' => false, |
| 115 | 115 | 'show_ui' => true, |
| 116 | 116 | '_builtin' => true, |
| 117 | - ) ); |
|
| 117 | + )); |
|
| 118 | 118 | |
| 119 | - register_taxonomy( 'post_format', 'post', array( |
|
| 119 | + register_taxonomy('post_format', 'post', array( |
|
| 120 | 120 | 'public' => true, |
| 121 | 121 | 'hierarchical' => false, |
| 122 | 122 | 'labels' => array( |
| 123 | - 'name' => _x( 'Format', 'post format' ), |
|
| 124 | - 'singular_name' => _x( 'Format', 'post format' ), |
|
| 123 | + 'name' => _x('Format', 'post format'), |
|
| 124 | + 'singular_name' => _x('Format', 'post format'), |
|
| 125 | 125 | ), |
| 126 | 126 | 'query_var' => true, |
| 127 | 127 | 'rewrite' => $rewrite['post_format'], |
| 128 | 128 | 'show_ui' => false, |
| 129 | 129 | '_builtin' => true, |
| 130 | - 'show_in_nav_menus' => current_theme_supports( 'post-formats' ), |
|
| 131 | - ) ); |
|
| 130 | + 'show_in_nav_menus' => current_theme_supports('post-formats'), |
|
| 131 | + )); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * Default 'and'. |
| 148 | 148 | * @return array A list of taxonomy names or objects. |
| 149 | 149 | */ |
| 150 | -function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) { |
|
| 150 | +function get_taxonomies($args = array(), $output = 'names', $operator = 'and') { |
|
| 151 | 151 | global $wp_taxonomies; |
| 152 | 152 | |
| 153 | 153 | $field = ('names' == $output) ? 'name' : false; |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | * taxonomy 'names' or 'objects'. Default 'names'. |
| 177 | 177 | * @return array The names of all taxonomy of $object_type. |
| 178 | 178 | */ |
| 179 | -function get_object_taxonomies( $object, $output = 'names' ) { |
|
| 179 | +function get_object_taxonomies($object, $output = 'names') { |
|
| 180 | 180 | global $wp_taxonomies; |
| 181 | 181 | |
| 182 | - if ( is_object($object) ) { |
|
| 183 | - if ( $object->post_type == 'attachment' ) |
|
| 182 | + if (is_object($object)) { |
|
| 183 | + if ($object->post_type == 'attachment') |
|
| 184 | 184 | return get_attachment_taxonomies($object); |
| 185 | 185 | $object = $object->post_type; |
| 186 | 186 | } |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | $object = (array) $object; |
| 189 | 189 | |
| 190 | 190 | $taxonomies = array(); |
| 191 | - foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) { |
|
| 192 | - if ( array_intersect($object, (array) $tax_obj->object_type) ) { |
|
| 193 | - if ( 'names' == $output ) |
|
| 191 | + foreach ((array) $wp_taxonomies as $tax_name => $tax_obj) { |
|
| 192 | + if (array_intersect($object, (array) $tax_obj->object_type)) { |
|
| 193 | + if ('names' == $output) |
|
| 194 | 194 | $taxonomies[] = $tax_name; |
| 195 | 195 | else |
| 196 | - $taxonomies[ $tax_name ] = $tax_obj; |
|
| 196 | + $taxonomies[$tax_name] = $tax_obj; |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | * @param string $taxonomy Name of taxonomy object to return. |
| 214 | 214 | * @return object|false The Taxonomy Object or false if $taxonomy doesn't exist. |
| 215 | 215 | */ |
| 216 | -function get_taxonomy( $taxonomy ) { |
|
| 216 | +function get_taxonomy($taxonomy) { |
|
| 217 | 217 | global $wp_taxonomies; |
| 218 | 218 | |
| 219 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
| 219 | + if ( ! taxonomy_exists($taxonomy)) |
|
| 220 | 220 | return false; |
| 221 | 221 | |
| 222 | 222 | return $wp_taxonomies[$taxonomy]; |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | * @param string $taxonomy Name of taxonomy object. |
| 235 | 235 | * @return bool Whether the taxonomy exists. |
| 236 | 236 | */ |
| 237 | -function taxonomy_exists( $taxonomy ) { |
|
| 237 | +function taxonomy_exists($taxonomy) { |
|
| 238 | 238 | global $wp_taxonomies; |
| 239 | 239 | |
| 240 | - return isset( $wp_taxonomies[$taxonomy] ); |
|
| 240 | + return isset($wp_taxonomies[$taxonomy]); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @return bool Whether the taxonomy is hierarchical. |
| 255 | 255 | */ |
| 256 | 256 | function is_taxonomy_hierarchical($taxonomy) { |
| 257 | - if ( ! taxonomy_exists($taxonomy) ) |
|
| 257 | + if ( ! taxonomy_exists($taxonomy)) |
|
| 258 | 258 | return false; |
| 259 | 259 | |
| 260 | 260 | $taxonomy = get_taxonomy($taxonomy); |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | * } |
| 349 | 349 | * @return WP_Error|void WP_Error, if errors. |
| 350 | 350 | */ |
| 351 | -function register_taxonomy( $taxonomy, $object_type, $args = array() ) { |
|
| 351 | +function register_taxonomy($taxonomy, $object_type, $args = array()) { |
|
| 352 | 352 | global $wp_taxonomies, $wp; |
| 353 | 353 | |
| 354 | - if ( ! is_array( $wp_taxonomies ) ) |
|
| 354 | + if ( ! is_array($wp_taxonomies)) |
|
| 355 | 355 | $wp_taxonomies = array(); |
| 356 | 356 | |
| 357 | - $args = wp_parse_args( $args ); |
|
| 357 | + $args = wp_parse_args($args); |
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * Filters the arguments for registering a taxonomy. |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param string $taxonomy Taxonomy key. |
| 366 | 366 | * @param array $object_type Array of names of object types for the taxonomy. |
| 367 | 367 | */ |
| 368 | - $args = apply_filters( 'register_taxonomy_args', $args, $taxonomy, (array) $object_type ); |
|
| 368 | + $args = apply_filters('register_taxonomy_args', $args, $taxonomy, (array) $object_type); |
|
| 369 | 369 | |
| 370 | 370 | $defaults = array( |
| 371 | 371 | 'labels' => array(), |
@@ -386,67 +386,67 @@ discard block |
||
| 386 | 386 | 'update_count_callback' => '', |
| 387 | 387 | '_builtin' => false, |
| 388 | 388 | ); |
| 389 | - $args = array_merge( $defaults, $args ); |
|
| 389 | + $args = array_merge($defaults, $args); |
|
| 390 | 390 | |
| 391 | - if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) { |
|
| 392 | - _doing_it_wrong( __FUNCTION__, __( 'Taxonomy names must be between 1 and 32 characters in length.' ), '4.2.0' ); |
|
| 393 | - return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) ); |
|
| 391 | + if (empty($taxonomy) || strlen($taxonomy) > 32) { |
|
| 392 | + _doing_it_wrong(__FUNCTION__, __('Taxonomy names must be between 1 and 32 characters in length.'), '4.2.0'); |
|
| 393 | + return new WP_Error('taxonomy_length_invalid', __('Taxonomy names must be between 1 and 32 characters in length.')); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | // If not set, default to the setting for public. |
| 397 | - if ( null === $args['publicly_queryable'] ) { |
|
| 397 | + if (null === $args['publicly_queryable']) { |
|
| 398 | 398 | $args['publicly_queryable'] = $args['public']; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // Non-publicly queryable taxonomies should not register query vars, except in the admin. |
| 402 | - if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) && ! empty( $wp ) ) { |
|
| 403 | - if ( true === $args['query_var'] ) |
|
| 402 | + if (false !== $args['query_var'] && (is_admin() || false !== $args['publicly_queryable']) && ! empty($wp)) { |
|
| 403 | + if (true === $args['query_var']) |
|
| 404 | 404 | $args['query_var'] = $taxonomy; |
| 405 | 405 | else |
| 406 | - $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); |
|
| 407 | - $wp->add_query_var( $args['query_var'] ); |
|
| 406 | + $args['query_var'] = sanitize_title_with_dashes($args['query_var']); |
|
| 407 | + $wp->add_query_var($args['query_var']); |
|
| 408 | 408 | } else { |
| 409 | 409 | // Force query_var to false for non-public taxonomies. |
| 410 | 410 | $args['query_var'] = false; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { |
|
| 414 | - $args['rewrite'] = wp_parse_args( $args['rewrite'], array( |
|
| 413 | + if (false !== $args['rewrite'] && (is_admin() || '' != get_option('permalink_structure'))) { |
|
| 414 | + $args['rewrite'] = wp_parse_args($args['rewrite'], array( |
|
| 415 | 415 | 'with_front' => true, |
| 416 | 416 | 'hierarchical' => false, |
| 417 | 417 | 'ep_mask' => EP_NONE, |
| 418 | - ) ); |
|
| 418 | + )); |
|
| 419 | 419 | |
| 420 | - if ( empty( $args['rewrite']['slug'] ) ) |
|
| 421 | - $args['rewrite']['slug'] = sanitize_title_with_dashes( $taxonomy ); |
|
| 420 | + if (empty($args['rewrite']['slug'])) |
|
| 421 | + $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy); |
|
| 422 | 422 | |
| 423 | - if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] ) |
|
| 423 | + if ($args['hierarchical'] && $args['rewrite']['hierarchical']) |
|
| 424 | 424 | $tag = '(.+?)'; |
| 425 | 425 | else |
| 426 | 426 | $tag = '([^/]+)'; |
| 427 | 427 | |
| 428 | - add_rewrite_tag( "%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=" ); |
|
| 429 | - add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite'] ); |
|
| 428 | + add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term="); |
|
| 429 | + add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // If not set, default to the setting for public. |
| 433 | - if ( null === $args['show_ui'] ) |
|
| 433 | + if (null === $args['show_ui']) |
|
| 434 | 434 | $args['show_ui'] = $args['public']; |
| 435 | 435 | |
| 436 | 436 | // If not set, default to the setting for show_ui. |
| 437 | - if ( null === $args['show_in_menu' ] || ! $args['show_ui'] ) |
|
| 438 | - $args['show_in_menu' ] = $args['show_ui']; |
|
| 437 | + if (null === $args['show_in_menu'] || ! $args['show_ui']) |
|
| 438 | + $args['show_in_menu'] = $args['show_ui']; |
|
| 439 | 439 | |
| 440 | 440 | // If not set, default to the setting for public. |
| 441 | - if ( null === $args['show_in_nav_menus'] ) |
|
| 441 | + if (null === $args['show_in_nav_menus']) |
|
| 442 | 442 | $args['show_in_nav_menus'] = $args['public']; |
| 443 | 443 | |
| 444 | 444 | // If not set, default to the setting for show_ui. |
| 445 | - if ( null === $args['show_tagcloud'] ) |
|
| 445 | + if (null === $args['show_tagcloud']) |
|
| 446 | 446 | $args['show_tagcloud'] = $args['show_ui']; |
| 447 | 447 | |
| 448 | 448 | // If not set, default to the setting for show_ui. |
| 449 | - if ( null === $args['show_in_quick_edit'] ) { |
|
| 449 | + if (null === $args['show_in_quick_edit']) { |
|
| 450 | 450 | $args['show_in_quick_edit'] = $args['show_ui']; |
| 451 | 451 | } |
| 452 | 452 | |
@@ -456,27 +456,27 @@ discard block |
||
| 456 | 456 | 'delete_terms' => 'manage_categories', |
| 457 | 457 | 'assign_terms' => 'edit_posts', |
| 458 | 458 | ); |
| 459 | - $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] ); |
|
| 460 | - unset( $args['capabilities'] ); |
|
| 459 | + $args['cap'] = (object) array_merge($default_caps, $args['capabilities']); |
|
| 460 | + unset($args['capabilities']); |
|
| 461 | 461 | |
| 462 | 462 | $args['name'] = $taxonomy; |
| 463 | - $args['object_type'] = array_unique( (array) $object_type ); |
|
| 463 | + $args['object_type'] = array_unique((array) $object_type); |
|
| 464 | 464 | |
| 465 | - $args['labels'] = get_taxonomy_labels( (object) $args ); |
|
| 465 | + $args['labels'] = get_taxonomy_labels((object) $args); |
|
| 466 | 466 | $args['label'] = $args['labels']->name; |
| 467 | 467 | |
| 468 | 468 | // If not set, use the default meta box |
| 469 | - if ( null === $args['meta_box_cb'] ) { |
|
| 470 | - if ( $args['hierarchical'] ) |
|
| 469 | + if (null === $args['meta_box_cb']) { |
|
| 470 | + if ($args['hierarchical']) |
|
| 471 | 471 | $args['meta_box_cb'] = 'post_categories_meta_box'; |
| 472 | 472 | else |
| 473 | 473 | $args['meta_box_cb'] = 'post_tags_meta_box'; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - $wp_taxonomies[ $taxonomy ] = (object) $args; |
|
| 476 | + $wp_taxonomies[$taxonomy] = (object) $args; |
|
| 477 | 477 | |
| 478 | 478 | // Register callback handling for meta box. |
| 479 | - add_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' ); |
|
| 479 | + add_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term'); |
|
| 480 | 480 | |
| 481 | 481 | /** |
| 482 | 482 | * Fires after a taxonomy is registered. |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | * @param array|string $object_type Object type or array of object types. |
| 488 | 488 | * @param array $args Array of taxonomy registration arguments. |
| 489 | 489 | */ |
| 490 | - do_action( 'registered_taxonomy', $taxonomy, $object_type, $args ); |
|
| 490 | + do_action('registered_taxonomy', $taxonomy, $object_type, $args); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
@@ -503,36 +503,36 @@ discard block |
||
| 503 | 503 | * @param string $taxonomy Taxonomy name. |
| 504 | 504 | * @return bool|WP_Error True on success, WP_Error on failure or if the taxonomy doesn't exist. |
| 505 | 505 | */ |
| 506 | -function unregister_taxonomy( $taxonomy ) { |
|
| 507 | - if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 508 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 506 | +function unregister_taxonomy($taxonomy) { |
|
| 507 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 508 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - $taxonomy_args = get_taxonomy( $taxonomy ); |
|
| 511 | + $taxonomy_args = get_taxonomy($taxonomy); |
|
| 512 | 512 | |
| 513 | 513 | // Do not allow unregistering internal taxonomies. |
| 514 | - if ( $taxonomy_args->_builtin ) { |
|
| 515 | - return new WP_Error( 'invalid_taxonomy', __( 'Unregistering a built-in taxonomy is not allowed' ) ); |
|
| 514 | + if ($taxonomy_args->_builtin) { |
|
| 515 | + return new WP_Error('invalid_taxonomy', __('Unregistering a built-in taxonomy is not allowed')); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | global $wp, $wp_taxonomies; |
| 519 | 519 | |
| 520 | 520 | // Remove query var. |
| 521 | - if ( false !== $taxonomy_args->query_var ) { |
|
| 522 | - $wp->remove_query_var( $taxonomy_args->query_var ); |
|
| 521 | + if (false !== $taxonomy_args->query_var) { |
|
| 522 | + $wp->remove_query_var($taxonomy_args->query_var); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | // Remove rewrite tags and permastructs. |
| 526 | - if ( false !== $taxonomy_args->rewrite ) { |
|
| 527 | - remove_rewrite_tag( "%$taxonomy%" ); |
|
| 528 | - remove_permastruct( $taxonomy ); |
|
| 526 | + if (false !== $taxonomy_args->rewrite) { |
|
| 527 | + remove_rewrite_tag("%$taxonomy%"); |
|
| 528 | + remove_permastruct($taxonomy); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | // Unregister callback handling for meta box. |
| 532 | - remove_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' ); |
|
| 532 | + remove_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term'); |
|
| 533 | 533 | |
| 534 | 534 | // Remove the taxonomy. |
| 535 | - unset( $wp_taxonomies[ $taxonomy ] ); |
|
| 535 | + unset($wp_taxonomies[$taxonomy]); |
|
| 536 | 536 | |
| 537 | 537 | /** |
| 538 | 538 | * Fires after a taxonomy is unregistered. |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * |
| 542 | 542 | * @param string $taxonomy Taxonomy name. |
| 543 | 543 | */ |
| 544 | - do_action( 'unregistered_taxonomy', $taxonomy ); |
|
| 544 | + do_action('unregistered_taxonomy', $taxonomy); |
|
| 545 | 545 | |
| 546 | 546 | return true; |
| 547 | 547 | } |
@@ -582,39 +582,39 @@ discard block |
||
| 582 | 582 | * @param object $tax Taxonomy object. |
| 583 | 583 | * @return object object with all the labels as member variables. |
| 584 | 584 | */ |
| 585 | -function get_taxonomy_labels( $tax ) { |
|
| 585 | +function get_taxonomy_labels($tax) { |
|
| 586 | 586 | $tax->labels = (array) $tax->labels; |
| 587 | 587 | |
| 588 | - if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) ) |
|
| 588 | + if (isset($tax->helps) && empty($tax->labels['separate_items_with_commas'])) |
|
| 589 | 589 | $tax->labels['separate_items_with_commas'] = $tax->helps; |
| 590 | 590 | |
| 591 | - if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) ) |
|
| 591 | + if (isset($tax->no_tagcloud) && empty($tax->labels['not_found'])) |
|
| 592 | 592 | $tax->labels['not_found'] = $tax->no_tagcloud; |
| 593 | 593 | |
| 594 | 594 | $nohier_vs_hier_defaults = array( |
| 595 | - 'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), |
|
| 596 | - 'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ), |
|
| 597 | - 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), |
|
| 598 | - 'popular_items' => array( __( 'Popular Tags' ), null ), |
|
| 599 | - 'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ), |
|
| 600 | - 'parent_item' => array( null, __( 'Parent Category' ) ), |
|
| 601 | - 'parent_item_colon' => array( null, __( 'Parent Category:' ) ), |
|
| 602 | - 'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ), |
|
| 603 | - 'view_item' => array( __( 'View Tag' ), __( 'View Category' ) ), |
|
| 604 | - 'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ), |
|
| 605 | - 'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ), |
|
| 606 | - 'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ), |
|
| 607 | - 'separate_items_with_commas' => array( __( 'Separate tags with commas' ), null ), |
|
| 608 | - 'add_or_remove_items' => array( __( 'Add or remove tags' ), null ), |
|
| 609 | - 'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ), |
|
| 610 | - 'not_found' => array( __( 'No tags found.' ), __( 'No categories found.' ) ), |
|
| 611 | - 'no_terms' => array( __( 'No tags' ), __( 'No categories' ) ), |
|
| 612 | - 'items_list_navigation' => array( __( 'Tags list navigation' ), __( 'Categories list navigation' ) ), |
|
| 613 | - 'items_list' => array( __( 'Tags list' ), __( 'Categories list' ) ), |
|
| 595 | + 'name' => array(_x('Tags', 'taxonomy general name'), _x('Categories', 'taxonomy general name')), |
|
| 596 | + 'singular_name' => array(_x('Tag', 'taxonomy singular name'), _x('Category', 'taxonomy singular name')), |
|
| 597 | + 'search_items' => array(__('Search Tags'), __('Search Categories')), |
|
| 598 | + 'popular_items' => array(__('Popular Tags'), null), |
|
| 599 | + 'all_items' => array(__('All Tags'), __('All Categories')), |
|
| 600 | + 'parent_item' => array(null, __('Parent Category')), |
|
| 601 | + 'parent_item_colon' => array(null, __('Parent Category:')), |
|
| 602 | + 'edit_item' => array(__('Edit Tag'), __('Edit Category')), |
|
| 603 | + 'view_item' => array(__('View Tag'), __('View Category')), |
|
| 604 | + 'update_item' => array(__('Update Tag'), __('Update Category')), |
|
| 605 | + 'add_new_item' => array(__('Add New Tag'), __('Add New Category')), |
|
| 606 | + 'new_item_name' => array(__('New Tag Name'), __('New Category Name')), |
|
| 607 | + 'separate_items_with_commas' => array(__('Separate tags with commas'), null), |
|
| 608 | + 'add_or_remove_items' => array(__('Add or remove tags'), null), |
|
| 609 | + 'choose_from_most_used' => array(__('Choose from the most used tags'), null), |
|
| 610 | + 'not_found' => array(__('No tags found.'), __('No categories found.')), |
|
| 611 | + 'no_terms' => array(__('No tags'), __('No categories')), |
|
| 612 | + 'items_list_navigation' => array(__('Tags list navigation'), __('Categories list navigation')), |
|
| 613 | + 'items_list' => array(__('Tags list'), __('Categories list')), |
|
| 614 | 614 | ); |
| 615 | 615 | $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; |
| 616 | 616 | |
| 617 | - $labels = _get_custom_object_labels( $tax, $nohier_vs_hier_defaults ); |
|
| 617 | + $labels = _get_custom_object_labels($tax, $nohier_vs_hier_defaults); |
|
| 618 | 618 | |
| 619 | 619 | $taxonomy = $tax->name; |
| 620 | 620 | |
@@ -631,10 +631,10 @@ discard block |
||
| 631 | 631 | * |
| 632 | 632 | * @param object $labels Object with labels for the taxonomy as member variables. |
| 633 | 633 | */ |
| 634 | - $labels = apply_filters( "taxonomy_labels_{$taxonomy}", $labels ); |
|
| 634 | + $labels = apply_filters("taxonomy_labels_{$taxonomy}", $labels); |
|
| 635 | 635 | |
| 636 | 636 | // Ensure that the filtered labels contain all required default values. |
| 637 | - $labels = (object) array_merge( (array) $default_labels, (array) $labels ); |
|
| 637 | + $labels = (object) array_merge((array) $default_labels, (array) $labels); |
|
| 638 | 638 | |
| 639 | 639 | return $labels; |
| 640 | 640 | } |
@@ -650,20 +650,20 @@ discard block |
||
| 650 | 650 | * @param string $object_type Name of the object type. |
| 651 | 651 | * @return bool True if successful, false if not. |
| 652 | 652 | */ |
| 653 | -function register_taxonomy_for_object_type( $taxonomy, $object_type) { |
|
| 653 | +function register_taxonomy_for_object_type($taxonomy, $object_type) { |
|
| 654 | 654 | global $wp_taxonomies; |
| 655 | 655 | |
| 656 | - if ( !isset($wp_taxonomies[$taxonomy]) ) |
|
| 656 | + if ( ! isset($wp_taxonomies[$taxonomy])) |
|
| 657 | 657 | return false; |
| 658 | 658 | |
| 659 | - if ( ! get_post_type_object($object_type) ) |
|
| 659 | + if ( ! get_post_type_object($object_type)) |
|
| 660 | 660 | return false; |
| 661 | 661 | |
| 662 | - if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) ) |
|
| 662 | + if ( ! in_array($object_type, $wp_taxonomies[$taxonomy]->object_type)) |
|
| 663 | 663 | $wp_taxonomies[$taxonomy]->object_type[] = $object_type; |
| 664 | 664 | |
| 665 | 665 | // Filter out empties. |
| 666 | - $wp_taxonomies[ $taxonomy ]->object_type = array_filter( $wp_taxonomies[ $taxonomy ]->object_type ); |
|
| 666 | + $wp_taxonomies[$taxonomy]->object_type = array_filter($wp_taxonomies[$taxonomy]->object_type); |
|
| 667 | 667 | |
| 668 | 668 | return true; |
| 669 | 669 | } |
@@ -679,20 +679,20 @@ discard block |
||
| 679 | 679 | * @param string $object_type Name of the object type. |
| 680 | 680 | * @return bool True if successful, false if not. |
| 681 | 681 | */ |
| 682 | -function unregister_taxonomy_for_object_type( $taxonomy, $object_type ) { |
|
| 682 | +function unregister_taxonomy_for_object_type($taxonomy, $object_type) { |
|
| 683 | 683 | global $wp_taxonomies; |
| 684 | 684 | |
| 685 | - if ( ! isset( $wp_taxonomies[ $taxonomy ] ) ) |
|
| 685 | + if ( ! isset($wp_taxonomies[$taxonomy])) |
|
| 686 | 686 | return false; |
| 687 | 687 | |
| 688 | - if ( ! get_post_type_object( $object_type ) ) |
|
| 688 | + if ( ! get_post_type_object($object_type)) |
|
| 689 | 689 | return false; |
| 690 | 690 | |
| 691 | - $key = array_search( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true ); |
|
| 692 | - if ( false === $key ) |
|
| 691 | + $key = array_search($object_type, $wp_taxonomies[$taxonomy]->object_type, true); |
|
| 692 | + if (false === $key) |
|
| 693 | 693 | return false; |
| 694 | 694 | |
| 695 | - unset( $wp_taxonomies[ $taxonomy ]->object_type[ $key ] ); |
|
| 695 | + unset($wp_taxonomies[$taxonomy]->object_type[$key]); |
|
| 696 | 696 | return true; |
| 697 | 697 | } |
| 698 | 698 | |
@@ -725,34 +725,34 @@ discard block |
||
| 725 | 725 | * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success. |
| 726 | 726 | * the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found. |
| 727 | 727 | */ |
| 728 | -function get_objects_in_term( $term_ids, $taxonomies, $args = array() ) { |
|
| 728 | +function get_objects_in_term($term_ids, $taxonomies, $args = array()) { |
|
| 729 | 729 | global $wpdb; |
| 730 | 730 | |
| 731 | - if ( ! is_array( $term_ids ) ) { |
|
| 732 | - $term_ids = array( $term_ids ); |
|
| 731 | + if ( ! is_array($term_ids)) { |
|
| 732 | + $term_ids = array($term_ids); |
|
| 733 | 733 | } |
| 734 | - if ( ! is_array( $taxonomies ) ) { |
|
| 735 | - $taxonomies = array( $taxonomies ); |
|
| 734 | + if ( ! is_array($taxonomies)) { |
|
| 735 | + $taxonomies = array($taxonomies); |
|
| 736 | 736 | } |
| 737 | - foreach ( (array) $taxonomies as $taxonomy ) { |
|
| 738 | - if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 739 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 737 | + foreach ((array) $taxonomies as $taxonomy) { |
|
| 738 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 739 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - $defaults = array( 'order' => 'ASC' ); |
|
| 744 | - $args = wp_parse_args( $args, $defaults ); |
|
| 743 | + $defaults = array('order' => 'ASC'); |
|
| 744 | + $args = wp_parse_args($args, $defaults); |
|
| 745 | 745 | |
| 746 | - $order = ( 'desc' == strtolower( $args['order'] ) ) ? 'DESC' : 'ASC'; |
|
| 746 | + $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC'; |
|
| 747 | 747 | |
| 748 | - $term_ids = array_map('intval', $term_ids ); |
|
| 748 | + $term_ids = array_map('intval', $term_ids); |
|
| 749 | 749 | |
| 750 | - $taxonomies = "'" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "'"; |
|
| 751 | - $term_ids = "'" . implode( "', '", $term_ids ) . "'"; |
|
| 750 | + $taxonomies = "'".implode("', '", array_map('esc_sql', $taxonomies))."'"; |
|
| 751 | + $term_ids = "'".implode("', '", $term_ids)."'"; |
|
| 752 | 752 | |
| 753 | 753 | $object_ids = $wpdb->get_col("SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order"); |
| 754 | 754 | |
| 755 | - if ( ! $object_ids ){ |
|
| 755 | + if ( ! $object_ids) { |
|
| 756 | 756 | return array(); |
| 757 | 757 | } |
| 758 | 758 | return $object_ids; |
@@ -770,9 +770,9 @@ discard block |
||
| 770 | 770 | * @param string $primary_id_column |
| 771 | 771 | * @return array |
| 772 | 772 | */ |
| 773 | -function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) { |
|
| 774 | - $tax_query_obj = new WP_Tax_Query( $tax_query ); |
|
| 775 | - return $tax_query_obj->get_sql( $primary_table, $primary_id_column ); |
|
| 773 | +function get_tax_sql($tax_query, $primary_table, $primary_id_column) { |
|
| 774 | + $tax_query_obj = new WP_Tax_Query($tax_query); |
|
| 775 | + return $tax_query_obj->get_sql($primary_table, $primary_id_column); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
@@ -820,31 +820,31 @@ discard block |
||
| 820 | 820 | * a WP_Term instance is returned. If taxonomy does not exist, a WP_Error is |
| 821 | 821 | * returned. Returns null for miscellaneous failure. |
| 822 | 822 | */ |
| 823 | -function get_term( $term, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) { |
|
| 824 | - if ( empty( $term ) ) { |
|
| 825 | - return new WP_Error( 'invalid_term', __( 'Empty Term' ) ); |
|
| 823 | +function get_term($term, $taxonomy = '', $output = OBJECT, $filter = 'raw') { |
|
| 824 | + if (empty($term)) { |
|
| 825 | + return new WP_Error('invalid_term', __('Empty Term')); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - if ( $taxonomy && ! taxonomy_exists( $taxonomy ) ) { |
|
| 829 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 828 | + if ($taxonomy && ! taxonomy_exists($taxonomy)) { |
|
| 829 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - if ( $term instanceof WP_Term ) { |
|
| 832 | + if ($term instanceof WP_Term) { |
|
| 833 | 833 | $_term = $term; |
| 834 | - } elseif ( is_object( $term ) ) { |
|
| 835 | - if ( empty( $term->filter ) || 'raw' === $term->filter ) { |
|
| 836 | - $_term = sanitize_term( $term, $taxonomy, 'raw' ); |
|
| 837 | - $_term = new WP_Term( $_term ); |
|
| 834 | + } elseif (is_object($term)) { |
|
| 835 | + if (empty($term->filter) || 'raw' === $term->filter) { |
|
| 836 | + $_term = sanitize_term($term, $taxonomy, 'raw'); |
|
| 837 | + $_term = new WP_Term($_term); |
|
| 838 | 838 | } else { |
| 839 | - $_term = WP_Term::get_instance( $term->term_id ); |
|
| 839 | + $_term = WP_Term::get_instance($term->term_id); |
|
| 840 | 840 | } |
| 841 | 841 | } else { |
| 842 | - $_term = WP_Term::get_instance( $term, $taxonomy ); |
|
| 842 | + $_term = WP_Term::get_instance($term, $taxonomy); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if ( is_wp_error( $_term ) ) { |
|
| 845 | + if (is_wp_error($_term)) { |
|
| 846 | 846 | return $_term; |
| 847 | - } elseif ( ! $_term ) { |
|
| 847 | + } elseif ( ! $_term) { |
|
| 848 | 848 | return null; |
| 849 | 849 | } |
| 850 | 850 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | * @param int|WP_Term $_term Term object or ID. |
| 858 | 858 | * @param string $taxonomy The taxonomy slug. |
| 859 | 859 | */ |
| 860 | - $_term = apply_filters( 'get_term', $_term, $taxonomy ); |
|
| 860 | + $_term = apply_filters('get_term', $_term, $taxonomy); |
|
| 861 | 861 | |
| 862 | 862 | /** |
| 863 | 863 | * Filters a taxonomy. |
@@ -871,20 +871,20 @@ discard block |
||
| 871 | 871 | * @param int|WP_Term $_term Term object or ID. |
| 872 | 872 | * @param string $taxonomy The taxonomy slug. |
| 873 | 873 | */ |
| 874 | - $_term = apply_filters( "get_$taxonomy", $_term, $taxonomy ); |
|
| 874 | + $_term = apply_filters("get_$taxonomy", $_term, $taxonomy); |
|
| 875 | 875 | |
| 876 | 876 | // Bail if a filter callback has changed the type of the `$_term` object. |
| 877 | - if ( ! ( $_term instanceof WP_Term ) ) { |
|
| 877 | + if ( ! ($_term instanceof WP_Term)) { |
|
| 878 | 878 | return $_term; |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | // Sanitize term, according to the specified filter. |
| 882 | - $_term->filter( $filter ); |
|
| 882 | + $_term->filter($filter); |
|
| 883 | 883 | |
| 884 | - if ( $output == ARRAY_A ) { |
|
| 884 | + if ($output == ARRAY_A) { |
|
| 885 | 885 | return $_term->to_array(); |
| 886 | - } elseif ( $output == ARRAY_N ) { |
|
| 887 | - return array_values( $_term->to_array() ); |
|
| 886 | + } elseif ($output == ARRAY_N) { |
|
| 887 | + return array_values($_term->to_array()); |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | return $_term; |
@@ -926,51 +926,51 @@ discard block |
||
| 926 | 926 | * @return WP_Term|bool WP_Term instance on success. Will return false if `$taxonomy` does not exist |
| 927 | 927 | * or `$term` was not found. |
| 928 | 928 | */ |
| 929 | -function get_term_by( $field, $value, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) { |
|
| 929 | +function get_term_by($field, $value, $taxonomy = '', $output = OBJECT, $filter = 'raw') { |
|
| 930 | 930 | global $wpdb; |
| 931 | 931 | |
| 932 | 932 | // 'term_taxonomy_id' lookups don't require taxonomy checks. |
| 933 | - if ( 'term_taxonomy_id' !== $field && ! taxonomy_exists( $taxonomy ) ) { |
|
| 933 | + if ('term_taxonomy_id' !== $field && ! taxonomy_exists($taxonomy)) { |
|
| 934 | 934 | return false; |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - $tax_clause = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); |
|
| 937 | + $tax_clause = $wpdb->prepare("AND tt.taxonomy = %s", $taxonomy); |
|
| 938 | 938 | |
| 939 | - if ( 'slug' == $field ) { |
|
| 939 | + if ('slug' == $field) { |
|
| 940 | 940 | $_field = 't.slug'; |
| 941 | 941 | $value = sanitize_title($value); |
| 942 | - if ( empty($value) ) |
|
| 942 | + if (empty($value)) |
|
| 943 | 943 | return false; |
| 944 | - } elseif ( 'name' == $field ) { |
|
| 944 | + } elseif ('name' == $field) { |
|
| 945 | 945 | // Assume already escaped |
| 946 | 946 | $value = wp_unslash($value); |
| 947 | 947 | $_field = 't.name'; |
| 948 | - } elseif ( 'term_taxonomy_id' == $field ) { |
|
| 948 | + } elseif ('term_taxonomy_id' == $field) { |
|
| 949 | 949 | $value = (int) $value; |
| 950 | 950 | $_field = 'tt.term_taxonomy_id'; |
| 951 | 951 | |
| 952 | 952 | // No `taxonomy` clause when searching by 'term_taxonomy_id'. |
| 953 | 953 | $tax_clause = ''; |
| 954 | 954 | } else { |
| 955 | - $term = get_term( (int) $value, $taxonomy, $output, $filter ); |
|
| 956 | - if ( is_wp_error( $term ) || is_null( $term ) ) { |
|
| 955 | + $term = get_term((int) $value, $taxonomy, $output, $filter); |
|
| 956 | + if (is_wp_error($term) || is_null($term)) { |
|
| 957 | 957 | $term = false; |
| 958 | 958 | } |
| 959 | 959 | return $term; |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | - $term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE $_field = %s", $value ) . " $tax_clause LIMIT 1" ); |
|
| 963 | - if ( ! $term ) |
|
| 962 | + $term = $wpdb->get_row($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE $_field = %s", $value)." $tax_clause LIMIT 1"); |
|
| 963 | + if ( ! $term) |
|
| 964 | 964 | return false; |
| 965 | 965 | |
| 966 | 966 | // In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the db. |
| 967 | - if ( 'term_taxonomy_id' === $field ) { |
|
| 967 | + if ('term_taxonomy_id' === $field) { |
|
| 968 | 968 | $taxonomy = $term->taxonomy; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - wp_cache_add( $term->term_id, $term, 'terms' ); |
|
| 971 | + wp_cache_add($term->term_id, $term, 'terms'); |
|
| 972 | 972 | |
| 973 | - return get_term( $term, $taxonomy, $output, $filter ); |
|
| 973 | + return get_term($term, $taxonomy, $output, $filter); |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /** |
@@ -987,26 +987,26 @@ discard block |
||
| 987 | 987 | * @param string $taxonomy Taxonomy Name. |
| 988 | 988 | * @return array|WP_Error List of Term IDs. WP_Error returned if `$taxonomy` does not exist. |
| 989 | 989 | */ |
| 990 | -function get_term_children( $term_id, $taxonomy ) { |
|
| 991 | - if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 992 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 990 | +function get_term_children($term_id, $taxonomy) { |
|
| 991 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 992 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | - $term_id = intval( $term_id ); |
|
| 995 | + $term_id = intval($term_id); |
|
| 996 | 996 | |
| 997 | 997 | $terms = _get_term_hierarchy($taxonomy); |
| 998 | 998 | |
| 999 | - if ( ! isset($terms[$term_id]) ) |
|
| 999 | + if ( ! isset($terms[$term_id])) |
|
| 1000 | 1000 | return array(); |
| 1001 | 1001 | |
| 1002 | 1002 | $children = $terms[$term_id]; |
| 1003 | 1003 | |
| 1004 | - foreach ( (array) $terms[$term_id] as $child ) { |
|
| 1005 | - if ( $term_id == $child ) { |
|
| 1004 | + foreach ((array) $terms[$term_id] as $child) { |
|
| 1005 | + if ($term_id == $child) { |
|
| 1006 | 1006 | continue; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - if ( isset($terms[$child]) ) |
|
| 1009 | + if (isset($terms[$child])) |
|
| 1010 | 1010 | $children = array_merge($children, get_term_children($child, $taxonomy)); |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1029,18 +1029,18 @@ discard block |
||
| 1029 | 1029 | * @param string $context Optional, default is display. Look at sanitize_term_field() for available options. |
| 1030 | 1030 | * @return string|int|null|WP_Error Will return an empty string if $term is not an object or if $field is not set in $term. |
| 1031 | 1031 | */ |
| 1032 | -function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) { |
|
| 1033 | - $term = get_term( $term, $taxonomy ); |
|
| 1034 | - if ( is_wp_error($term) ) |
|
| 1032 | +function get_term_field($field, $term, $taxonomy = '', $context = 'display') { |
|
| 1033 | + $term = get_term($term, $taxonomy); |
|
| 1034 | + if (is_wp_error($term)) |
|
| 1035 | 1035 | return $term; |
| 1036 | 1036 | |
| 1037 | - if ( !is_object($term) ) |
|
| 1037 | + if ( ! is_object($term)) |
|
| 1038 | 1038 | return ''; |
| 1039 | 1039 | |
| 1040 | - if ( !isset($term->$field) ) |
|
| 1040 | + if ( ! isset($term->$field)) |
|
| 1041 | 1041 | return ''; |
| 1042 | 1042 | |
| 1043 | - return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context ); |
|
| 1043 | + return sanitize_term_field($field, $term->$field, $term->term_id, $term->taxonomy, $context); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | /** |
@@ -1055,13 +1055,13 @@ discard block |
||
| 1055 | 1055 | * @param string $taxonomy Taxonomy name. |
| 1056 | 1056 | * @return string|int|null|WP_Error Will return empty string if $term is not an object. |
| 1057 | 1057 | */ |
| 1058 | -function get_term_to_edit( $id, $taxonomy ) { |
|
| 1059 | - $term = get_term( $id, $taxonomy ); |
|
| 1058 | +function get_term_to_edit($id, $taxonomy) { |
|
| 1059 | + $term = get_term($id, $taxonomy); |
|
| 1060 | 1060 | |
| 1061 | - if ( is_wp_error($term) ) |
|
| 1061 | + if (is_wp_error($term)) |
|
| 1062 | 1062 | return $term; |
| 1063 | 1063 | |
| 1064 | - if ( !is_object($term) ) |
|
| 1064 | + if ( ! is_object($term)) |
|
| 1065 | 1065 | return ''; |
| 1066 | 1066 | |
| 1067 | 1067 | return sanitize_term($term, $taxonomy, 'edit'); |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | * @return array|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of $taxonomies |
| 1180 | 1180 | * do not exist. |
| 1181 | 1181 | */ |
| 1182 | -function get_terms( $args = array(), $deprecated = '' ) { |
|
| 1182 | +function get_terms($args = array(), $deprecated = '') { |
|
| 1183 | 1183 | global $wpdb; |
| 1184 | 1184 | |
| 1185 | 1185 | $term_query = new WP_Term_Query(); |
@@ -1191,33 +1191,33 @@ discard block |
||
| 1191 | 1191 | * (a) a second non-empty parameter is passed, or |
| 1192 | 1192 | * (b) the first parameter shares no keys with the default array (ie, it's a list of taxonomies) |
| 1193 | 1193 | */ |
| 1194 | - $_args = wp_parse_args( $args ); |
|
| 1195 | - $key_intersect = array_intersect_key( $term_query->query_var_defaults, (array) $_args ); |
|
| 1196 | - $do_legacy_args = $deprecated || empty( $key_intersect ); |
|
| 1194 | + $_args = wp_parse_args($args); |
|
| 1195 | + $key_intersect = array_intersect_key($term_query->query_var_defaults, (array) $_args); |
|
| 1196 | + $do_legacy_args = $deprecated || empty($key_intersect); |
|
| 1197 | 1197 | |
| 1198 | - if ( $do_legacy_args ) { |
|
| 1198 | + if ($do_legacy_args) { |
|
| 1199 | 1199 | $taxonomies = (array) $args; |
| 1200 | - $args = wp_parse_args( $deprecated ); |
|
| 1200 | + $args = wp_parse_args($deprecated); |
|
| 1201 | 1201 | $args['taxonomy'] = $taxonomies; |
| 1202 | 1202 | } else { |
| 1203 | - $args = wp_parse_args( $args ); |
|
| 1204 | - if ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) { |
|
| 1203 | + $args = wp_parse_args($args); |
|
| 1204 | + if (isset($args['taxonomy']) && null !== $args['taxonomy']) { |
|
| 1205 | 1205 | $args['taxonomy'] = (array) $args['taxonomy']; |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | - if ( ! empty( $args['taxonomy'] ) ) { |
|
| 1210 | - foreach ( $args['taxonomy'] as $taxonomy ) { |
|
| 1211 | - if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 1212 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 1209 | + if ( ! empty($args['taxonomy'])) { |
|
| 1210 | + foreach ($args['taxonomy'] as $taxonomy) { |
|
| 1211 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 1212 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | - $terms = $term_query->query( $args ); |
|
| 1217 | + $terms = $term_query->query($args); |
|
| 1218 | 1218 | |
| 1219 | 1219 | // Count queries are not filtered, for legacy reasons. |
| 1220 | - if ( ! is_array( $terms ) ) { |
|
| 1220 | + if ( ! is_array($terms)) { |
|
| 1221 | 1221 | return $terms; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | * @param array $args An array of get_terms() arguments. |
| 1233 | 1233 | * @param WP_Term_Query $term_query The WP_Term_Query object. |
| 1234 | 1234 | */ |
| 1235 | - return apply_filters( 'get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query ); |
|
| 1235 | + return apply_filters('get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | 1238 | /** |
@@ -1248,21 +1248,21 @@ discard block |
||
| 1248 | 1248 | * @return int|WP_Error|bool Meta ID on success. WP_Error when term_id is ambiguous between taxonomies. |
| 1249 | 1249 | * False on failure. |
| 1250 | 1250 | */ |
| 1251 | -function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { |
|
| 1251 | +function add_term_meta($term_id, $meta_key, $meta_value, $unique = false) { |
|
| 1252 | 1252 | // Bail if term meta table is not installed. |
| 1253 | - if ( get_option( 'db_version' ) < 34370 ) { |
|
| 1253 | + if (get_option('db_version') < 34370) { |
|
| 1254 | 1254 | return false; |
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | - if ( wp_term_is_shared( $term_id ) ) { |
|
| 1258 | - return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id ); |
|
| 1257 | + if (wp_term_is_shared($term_id)) { |
|
| 1258 | + return new WP_Error('ambiguous_term_id', __('Term meta cannot be added to terms that are shared between taxonomies.'), $term_id); |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | - $added = add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); |
|
| 1261 | + $added = add_metadata('term', $term_id, $meta_key, $meta_value, $unique); |
|
| 1262 | 1262 | |
| 1263 | 1263 | // Bust term query cache. |
| 1264 | - if ( $added ) { |
|
| 1265 | - wp_cache_set( 'last_changed', microtime(), 'terms' ); |
|
| 1264 | + if ($added) { |
|
| 1265 | + wp_cache_set('last_changed', microtime(), 'terms'); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | return $added; |
@@ -1278,17 +1278,17 @@ discard block |
||
| 1278 | 1278 | * @param mixed $meta_value Optional. Metadata value. If provided, rows will only be removed that match the value. |
| 1279 | 1279 | * @return bool True on success, false on failure. |
| 1280 | 1280 | */ |
| 1281 | -function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) { |
|
| 1281 | +function delete_term_meta($term_id, $meta_key, $meta_value = '') { |
|
| 1282 | 1282 | // Bail if term meta table is not installed. |
| 1283 | - if ( get_option( 'db_version' ) < 34370 ) { |
|
| 1283 | + if (get_option('db_version') < 34370) { |
|
| 1284 | 1284 | return false; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | - $deleted = delete_metadata( 'term', $term_id, $meta_key, $meta_value ); |
|
| 1287 | + $deleted = delete_metadata('term', $term_id, $meta_key, $meta_value); |
|
| 1288 | 1288 | |
| 1289 | 1289 | // Bust term query cache. |
| 1290 | - if ( $deleted ) { |
|
| 1291 | - wp_cache_set( 'last_changed', microtime(), 'terms' ); |
|
| 1290 | + if ($deleted) { |
|
| 1291 | + wp_cache_set('last_changed', microtime(), 'terms'); |
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | return $deleted; |
@@ -1305,13 +1305,13 @@ discard block |
||
| 1305 | 1305 | * `$term_id`/`$key` pair will be returned. Default: false. |
| 1306 | 1306 | * @return mixed If `$single` is false, an array of metadata values. If `$single` is true, a single metadata value. |
| 1307 | 1307 | */ |
| 1308 | -function get_term_meta( $term_id, $key = '', $single = false ) { |
|
| 1308 | +function get_term_meta($term_id, $key = '', $single = false) { |
|
| 1309 | 1309 | // Bail if term meta table is not installed. |
| 1310 | - if ( get_option( 'db_version' ) < 34370 ) { |
|
| 1310 | + if (get_option('db_version') < 34370) { |
|
| 1311 | 1311 | return false; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | - return get_metadata( 'term', $term_id, $key, $single ); |
|
| 1314 | + return get_metadata('term', $term_id, $key, $single); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | /** |
@@ -1330,21 +1330,21 @@ discard block |
||
| 1330 | 1330 | * @return int|WP_Error|bool Meta ID if the key didn't previously exist. True on successful update. |
| 1331 | 1331 | * WP_Error when term_id is ambiguous between taxonomies. False on failure. |
| 1332 | 1332 | */ |
| 1333 | -function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
| 1333 | +function update_term_meta($term_id, $meta_key, $meta_value, $prev_value = '') { |
|
| 1334 | 1334 | // Bail if term meta table is not installed. |
| 1335 | - if ( get_option( 'db_version' ) < 34370 ) { |
|
| 1335 | + if (get_option('db_version') < 34370) { |
|
| 1336 | 1336 | return false; |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | - if ( wp_term_is_shared( $term_id ) ) { |
|
| 1340 | - return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id ); |
|
| 1339 | + if (wp_term_is_shared($term_id)) { |
|
| 1340 | + return new WP_Error('ambiguous_term_id', __('Term meta cannot be added to terms that are shared between taxonomies.'), $term_id); |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | - $updated = update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); |
|
| 1343 | + $updated = update_metadata('term', $term_id, $meta_key, $meta_value, $prev_value); |
|
| 1344 | 1344 | |
| 1345 | 1345 | // Bust term query cache. |
| 1346 | - if ( $updated ) { |
|
| 1347 | - wp_cache_set( 'last_changed', microtime(), 'terms' ); |
|
| 1346 | + if ($updated) { |
|
| 1347 | + wp_cache_set('last_changed', microtime(), 'terms'); |
|
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | 1350 | return $updated; |
@@ -1361,13 +1361,13 @@ discard block |
||
| 1361 | 1361 | * @param array $term_ids List of term IDs. |
| 1362 | 1362 | * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success. |
| 1363 | 1363 | */ |
| 1364 | -function update_termmeta_cache( $term_ids ) { |
|
| 1364 | +function update_termmeta_cache($term_ids) { |
|
| 1365 | 1365 | // Bail if term meta table is not installed. |
| 1366 | - if ( get_option( 'db_version' ) < 34370 ) { |
|
| 1366 | + if (get_option('db_version') < 34370) { |
|
| 1367 | 1367 | return; |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | - return update_meta_cache( 'term', $term_ids ); |
|
| 1370 | + return update_meta_cache('term', $term_ids); |
|
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | 1373 | /** |
@@ -1387,24 +1387,24 @@ discard block |
||
| 1387 | 1387 | * an array of the term ID and the term taxonomy ID the taxonomy |
| 1388 | 1388 | * is specified and the pairing exists. |
| 1389 | 1389 | */ |
| 1390 | -function term_exists( $term, $taxonomy = '', $parent = null ) { |
|
| 1390 | +function term_exists($term, $taxonomy = '', $parent = null) { |
|
| 1391 | 1391 | global $wpdb; |
| 1392 | 1392 | |
| 1393 | 1393 | $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
| 1394 | 1394 | $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
| 1395 | 1395 | |
| 1396 | - if ( is_int($term) ) { |
|
| 1397 | - if ( 0 == $term ) |
|
| 1396 | + if (is_int($term)) { |
|
| 1397 | + if (0 == $term) |
|
| 1398 | 1398 | return 0; |
| 1399 | 1399 | $where = 't.term_id = %d'; |
| 1400 | - if ( !empty($taxonomy) ) |
|
| 1401 | - return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A ); |
|
| 1400 | + if ( ! empty($taxonomy)) |
|
| 1401 | + return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1402 | 1402 | else |
| 1403 | - return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) ); |
|
| 1403 | + return $wpdb->get_var($wpdb->prepare($select.$where, $term)); |
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | - $term = trim( wp_unslash( $term ) ); |
|
| 1407 | - $slug = sanitize_title( $term ); |
|
| 1406 | + $term = trim(wp_unslash($term)); |
|
| 1407 | + $slug = sanitize_title($term); |
|
| 1408 | 1408 | |
| 1409 | 1409 | $where = 't.slug = %s'; |
| 1410 | 1410 | $else_where = 't.name = %s'; |
@@ -1412,8 +1412,8 @@ discard block |
||
| 1412 | 1412 | $else_where_fields = array($term); |
| 1413 | 1413 | $orderby = 'ORDER BY t.term_id ASC'; |
| 1414 | 1414 | $limit = 'LIMIT 1'; |
| 1415 | - if ( !empty($taxonomy) ) { |
|
| 1416 | - if ( is_numeric( $parent ) ) { |
|
| 1415 | + if ( ! empty($taxonomy)) { |
|
| 1416 | + if (is_numeric($parent)) { |
|
| 1417 | 1417 | $parent = (int) $parent; |
| 1418 | 1418 | $where_fields[] = $parent; |
| 1419 | 1419 | $else_where_fields[] = $parent; |
@@ -1424,16 +1424,16 @@ discard block |
||
| 1424 | 1424 | $where_fields[] = $taxonomy; |
| 1425 | 1425 | $else_where_fields[] = $taxonomy; |
| 1426 | 1426 | |
| 1427 | - if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A) ) |
|
| 1427 | + if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A)) |
|
| 1428 | 1428 | return $result; |
| 1429 | 1429 | |
| 1430 | - return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields), ARRAY_A); |
|
| 1430 | + return $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields), ARRAY_A); |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | - if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) ) |
|
| 1433 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields))) |
|
| 1434 | 1434 | return $result; |
| 1435 | 1435 | |
| 1436 | - return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields) ); |
|
| 1436 | + return $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields)); |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | /** |
@@ -1448,18 +1448,18 @@ discard block |
||
| 1448 | 1448 | * @param string $taxonomy Taxonomy name that $term1 and `$term2` belong to. |
| 1449 | 1449 | * @return bool Whether `$term2` is a child of `$term1`. |
| 1450 | 1450 | */ |
| 1451 | -function term_is_ancestor_of( $term1, $term2, $taxonomy ) { |
|
| 1452 | - if ( ! isset( $term1->term_id ) ) |
|
| 1453 | - $term1 = get_term( $term1, $taxonomy ); |
|
| 1454 | - if ( ! isset( $term2->parent ) ) |
|
| 1455 | - $term2 = get_term( $term2, $taxonomy ); |
|
| 1451 | +function term_is_ancestor_of($term1, $term2, $taxonomy) { |
|
| 1452 | + if ( ! isset($term1->term_id)) |
|
| 1453 | + $term1 = get_term($term1, $taxonomy); |
|
| 1454 | + if ( ! isset($term2->parent)) |
|
| 1455 | + $term2 = get_term($term2, $taxonomy); |
|
| 1456 | 1456 | |
| 1457 | - if ( empty( $term1->term_id ) || empty( $term2->parent ) ) |
|
| 1457 | + if (empty($term1->term_id) || empty($term2->parent)) |
|
| 1458 | 1458 | return false; |
| 1459 | - if ( $term2->parent == $term1->term_id ) |
|
| 1459 | + if ($term2->parent == $term1->term_id) |
|
| 1460 | 1460 | return true; |
| 1461 | 1461 | |
| 1462 | - return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy ); |
|
| 1462 | + return term_is_ancestor_of($term1, get_term($term2->parent, $taxonomy), $taxonomy); |
|
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | 1465 | /** |
@@ -1480,23 +1480,23 @@ discard block |
||
| 1480 | 1480 | * @return array|object Term with all fields sanitized. |
| 1481 | 1481 | */ |
| 1482 | 1482 | function sanitize_term($term, $taxonomy, $context = 'display') { |
| 1483 | - $fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id' ); |
|
| 1483 | + $fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id'); |
|
| 1484 | 1484 | |
| 1485 | - $do_object = is_object( $term ); |
|
| 1485 | + $do_object = is_object($term); |
|
| 1486 | 1486 | |
| 1487 | 1487 | $term_id = $do_object ? $term->term_id : (isset($term['term_id']) ? $term['term_id'] : 0); |
| 1488 | 1488 | |
| 1489 | - foreach ( (array) $fields as $field ) { |
|
| 1490 | - if ( $do_object ) { |
|
| 1491 | - if ( isset($term->$field) ) |
|
| 1489 | + foreach ((array) $fields as $field) { |
|
| 1490 | + if ($do_object) { |
|
| 1491 | + if (isset($term->$field)) |
|
| 1492 | 1492 | $term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context); |
| 1493 | 1493 | } else { |
| 1494 | - if ( isset($term[$field]) ) |
|
| 1494 | + if (isset($term[$field])) |
|
| 1495 | 1495 | $term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context); |
| 1496 | 1496 | } |
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | - if ( $do_object ) |
|
| 1499 | + if ($do_object) |
|
| 1500 | 1500 | $term->filter = $context; |
| 1501 | 1501 | else |
| 1502 | 1502 | $term['filter'] = $context; |
@@ -1528,17 +1528,17 @@ discard block |
||
| 1528 | 1528 | * @return mixed Sanitized field. |
| 1529 | 1529 | */ |
| 1530 | 1530 | function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { |
| 1531 | - $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); |
|
| 1532 | - if ( in_array( $field, $int_fields ) ) { |
|
| 1531 | + $int_fields = array('parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id'); |
|
| 1532 | + if (in_array($field, $int_fields)) { |
|
| 1533 | 1533 | $value = (int) $value; |
| 1534 | - if ( $value < 0 ) |
|
| 1534 | + if ($value < 0) |
|
| 1535 | 1535 | $value = 0; |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | - if ( 'raw' == $context ) |
|
| 1538 | + if ('raw' == $context) |
|
| 1539 | 1539 | return $value; |
| 1540 | 1540 | |
| 1541 | - if ( 'edit' == $context ) { |
|
| 1541 | + if ('edit' == $context) { |
|
| 1542 | 1542 | |
| 1543 | 1543 | /** |
| 1544 | 1544 | * Filters a term field to edit before it is sanitized. |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | * @param int $term_id Term ID. |
| 1552 | 1552 | * @param string $taxonomy Taxonomy slug. |
| 1553 | 1553 | */ |
| 1554 | - $value = apply_filters( "edit_term_{$field}", $value, $term_id, $taxonomy ); |
|
| 1554 | + $value = apply_filters("edit_term_{$field}", $value, $term_id, $taxonomy); |
|
| 1555 | 1555 | |
| 1556 | 1556 | /** |
| 1557 | 1557 | * Filters the taxonomy field to edit before it is sanitized. |
@@ -1564,13 +1564,13 @@ discard block |
||
| 1564 | 1564 | * @param mixed $value Value of the taxonomy field to edit. |
| 1565 | 1565 | * @param int $term_id Term ID. |
| 1566 | 1566 | */ |
| 1567 | - $value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id ); |
|
| 1567 | + $value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id); |
|
| 1568 | 1568 | |
| 1569 | - if ( 'description' == $field ) |
|
| 1569 | + if ('description' == $field) |
|
| 1570 | 1570 | $value = esc_html($value); // textarea_escaped |
| 1571 | 1571 | else |
| 1572 | 1572 | $value = esc_attr($value); |
| 1573 | - } elseif ( 'db' == $context ) { |
|
| 1573 | + } elseif ('db' == $context) { |
|
| 1574 | 1574 | |
| 1575 | 1575 | /** |
| 1576 | 1576 | * Filters a term field value before it is sanitized. |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | * @param mixed $value Value of the term field. |
| 1583 | 1583 | * @param string $taxonomy Taxonomy slug. |
| 1584 | 1584 | */ |
| 1585 | - $value = apply_filters( "pre_term_{$field}", $value, $taxonomy ); |
|
| 1585 | + $value = apply_filters("pre_term_{$field}", $value, $taxonomy); |
|
| 1586 | 1586 | |
| 1587 | 1587 | /** |
| 1588 | 1588 | * Filters a taxonomy field before it is sanitized. |
@@ -1594,10 +1594,10 @@ discard block |
||
| 1594 | 1594 | * |
| 1595 | 1595 | * @param mixed $value Value of the taxonomy field. |
| 1596 | 1596 | */ |
| 1597 | - $value = apply_filters( "pre_{$taxonomy}_{$field}", $value ); |
|
| 1597 | + $value = apply_filters("pre_{$taxonomy}_{$field}", $value); |
|
| 1598 | 1598 | |
| 1599 | 1599 | // Back compat filters |
| 1600 | - if ( 'slug' == $field ) { |
|
| 1600 | + if ('slug' == $field) { |
|
| 1601 | 1601 | /** |
| 1602 | 1602 | * Filters the category nicename before it is sanitized. |
| 1603 | 1603 | * |
@@ -1607,10 +1607,10 @@ discard block |
||
| 1607 | 1607 | * |
| 1608 | 1608 | * @param string $value The category nicename. |
| 1609 | 1609 | */ |
| 1610 | - $value = apply_filters( 'pre_category_nicename', $value ); |
|
| 1610 | + $value = apply_filters('pre_category_nicename', $value); |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | - } elseif ( 'rss' == $context ) { |
|
| 1613 | + } elseif ('rss' == $context) { |
|
| 1614 | 1614 | |
| 1615 | 1615 | /** |
| 1616 | 1616 | * Filters the term field for use in RSS. |
@@ -1622,7 +1622,7 @@ discard block |
||
| 1622 | 1622 | * @param mixed $value Value of the term field. |
| 1623 | 1623 | * @param string $taxonomy Taxonomy slug. |
| 1624 | 1624 | */ |
| 1625 | - $value = apply_filters( "term_{$field}_rss", $value, $taxonomy ); |
|
| 1625 | + $value = apply_filters("term_{$field}_rss", $value, $taxonomy); |
|
| 1626 | 1626 | |
| 1627 | 1627 | /** |
| 1628 | 1628 | * Filters the taxonomy field for use in RSS. |
@@ -1634,7 +1634,7 @@ discard block |
||
| 1634 | 1634 | * |
| 1635 | 1635 | * @param mixed $value Value of the taxonomy field. |
| 1636 | 1636 | */ |
| 1637 | - $value = apply_filters( "{$taxonomy}_{$field}_rss", $value ); |
|
| 1637 | + $value = apply_filters("{$taxonomy}_{$field}_rss", $value); |
|
| 1638 | 1638 | } else { |
| 1639 | 1639 | // Use display filters by default. |
| 1640 | 1640 | |
@@ -1650,7 +1650,7 @@ discard block |
||
| 1650 | 1650 | * @param string $taxonomy Taxonomy slug. |
| 1651 | 1651 | * @param string $context Context to retrieve the term field value. |
| 1652 | 1652 | */ |
| 1653 | - $value = apply_filters( "term_{$field}", $value, $term_id, $taxonomy, $context ); |
|
| 1653 | + $value = apply_filters("term_{$field}", $value, $term_id, $taxonomy, $context); |
|
| 1654 | 1654 | |
| 1655 | 1655 | /** |
| 1656 | 1656 | * Filters the taxonomy field sanitized for display. |
@@ -1664,12 +1664,12 @@ discard block |
||
| 1664 | 1664 | * @param int $term_id Term ID. |
| 1665 | 1665 | * @param string $context Context to retrieve the taxonomy field value. |
| 1666 | 1666 | */ |
| 1667 | - $value = apply_filters( "{$taxonomy}_{$field}", $value, $term_id, $context ); |
|
| 1667 | + $value = apply_filters("{$taxonomy}_{$field}", $value, $term_id, $context); |
|
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | - if ( 'attribute' == $context ) { |
|
| 1670 | + if ('attribute' == $context) { |
|
| 1671 | 1671 | $value = esc_attr($value); |
| 1672 | - } elseif ( 'js' == $context ) { |
|
| 1672 | + } elseif ('js' == $context) { |
|
| 1673 | 1673 | $value = esc_js($value); |
| 1674 | 1674 | } |
| 1675 | 1675 | return $value; |
@@ -1687,12 +1687,12 @@ discard block |
||
| 1687 | 1687 | * Default empty array. |
| 1688 | 1688 | * @return array|int|WP_Error Number of terms in that taxonomy or WP_Error if the taxonomy does not exist. |
| 1689 | 1689 | */ |
| 1690 | -function wp_count_terms( $taxonomy, $args = array() ) { |
|
| 1690 | +function wp_count_terms($taxonomy, $args = array()) { |
|
| 1691 | 1691 | $defaults = array('hide_empty' => false); |
| 1692 | 1692 | $args = wp_parse_args($args, $defaults); |
| 1693 | 1693 | |
| 1694 | 1694 | // backward compatibility |
| 1695 | - if ( isset($args['ignore_empty']) ) { |
|
| 1695 | + if (isset($args['ignore_empty'])) { |
|
| 1696 | 1696 | $args['hide_empty'] = $args['ignore_empty']; |
| 1697 | 1697 | unset($args['ignore_empty']); |
| 1698 | 1698 | } |
@@ -1714,16 +1714,16 @@ discard block |
||
| 1714 | 1714 | * @param int $object_id The term Object Id that refers to the term. |
| 1715 | 1715 | * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name. |
| 1716 | 1716 | */ |
| 1717 | -function wp_delete_object_term_relationships( $object_id, $taxonomies ) { |
|
| 1717 | +function wp_delete_object_term_relationships($object_id, $taxonomies) { |
|
| 1718 | 1718 | $object_id = (int) $object_id; |
| 1719 | 1719 | |
| 1720 | - if ( !is_array($taxonomies) ) |
|
| 1720 | + if ( ! is_array($taxonomies)) |
|
| 1721 | 1721 | $taxonomies = array($taxonomies); |
| 1722 | 1722 | |
| 1723 | - foreach ( (array) $taxonomies as $taxonomy ) { |
|
| 1724 | - $term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1725 | - $term_ids = array_map( 'intval', $term_ids ); |
|
| 1726 | - wp_remove_object_terms( $object_id, $term_ids, $taxonomy ); |
|
| 1723 | + foreach ((array) $taxonomies as $taxonomy) { |
|
| 1724 | + $term_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'ids')); |
|
| 1725 | + $term_ids = array_map('intval', $term_ids); |
|
| 1726 | + wp_remove_object_terms($object_id, $term_ids, $taxonomy); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | } |
| 1729 | 1729 | |
@@ -1754,36 +1754,36 @@ discard block |
||
| 1754 | 1754 | * @return bool|int|WP_Error True on success, false if term does not exist. Zero on attempted |
| 1755 | 1755 | * deletion of default Category. WP_Error if the taxonomy does not exist. |
| 1756 | 1756 | */ |
| 1757 | -function wp_delete_term( $term, $taxonomy, $args = array() ) { |
|
| 1757 | +function wp_delete_term($term, $taxonomy, $args = array()) { |
|
| 1758 | 1758 | global $wpdb; |
| 1759 | 1759 | |
| 1760 | 1760 | $term = (int) $term; |
| 1761 | 1761 | |
| 1762 | - if ( ! $ids = term_exists($term, $taxonomy) ) |
|
| 1762 | + if ( ! $ids = term_exists($term, $taxonomy)) |
|
| 1763 | 1763 | return false; |
| 1764 | - if ( is_wp_error( $ids ) ) |
|
| 1764 | + if (is_wp_error($ids)) |
|
| 1765 | 1765 | return $ids; |
| 1766 | 1766 | |
| 1767 | 1767 | $tt_id = $ids['term_taxonomy_id']; |
| 1768 | 1768 | |
| 1769 | 1769 | $defaults = array(); |
| 1770 | 1770 | |
| 1771 | - if ( 'category' == $taxonomy ) { |
|
| 1772 | - $defaults['default'] = get_option( 'default_category' ); |
|
| 1773 | - if ( $defaults['default'] == $term ) |
|
| 1771 | + if ('category' == $taxonomy) { |
|
| 1772 | + $defaults['default'] = get_option('default_category'); |
|
| 1773 | + if ($defaults['default'] == $term) |
|
| 1774 | 1774 | return 0; // Don't delete the default category |
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | 1777 | $args = wp_parse_args($args, $defaults); |
| 1778 | 1778 | |
| 1779 | - if ( isset( $args['default'] ) ) { |
|
| 1779 | + if (isset($args['default'])) { |
|
| 1780 | 1780 | $default = (int) $args['default']; |
| 1781 | - if ( ! term_exists( $default, $taxonomy ) ) { |
|
| 1782 | - unset( $default ); |
|
| 1781 | + if ( ! term_exists($default, $taxonomy)) { |
|
| 1782 | + unset($default); |
|
| 1783 | 1783 | } |
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | - if ( isset( $args['force_default'] ) ) { |
|
| 1786 | + if (isset($args['force_default'])) { |
|
| 1787 | 1787 | $force_default = $args['force_default']; |
| 1788 | 1788 | } |
| 1789 | 1789 | |
@@ -1795,17 +1795,17 @@ discard block |
||
| 1795 | 1795 | * @param int $term Term ID. |
| 1796 | 1796 | * @param string $taxonomy Taxonomy Name. |
| 1797 | 1797 | */ |
| 1798 | - do_action( 'pre_delete_term', $term, $taxonomy ); |
|
| 1798 | + do_action('pre_delete_term', $term, $taxonomy); |
|
| 1799 | 1799 | |
| 1800 | 1800 | // Update children to point to new parent |
| 1801 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 1801 | + if (is_taxonomy_hierarchical($taxonomy)) { |
|
| 1802 | 1802 | $term_obj = get_term($term, $taxonomy); |
| 1803 | - if ( is_wp_error( $term_obj ) ) |
|
| 1803 | + if (is_wp_error($term_obj)) |
|
| 1804 | 1804 | return $term_obj; |
| 1805 | 1805 | $parent = $term_obj->parent; |
| 1806 | 1806 | |
| 1807 | - $edit_ids = $wpdb->get_results( "SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id ); |
|
| 1808 | - $edit_tt_ids = wp_list_pluck( $edit_ids, 'term_taxonomy_id' ); |
|
| 1807 | + $edit_ids = $wpdb->get_results("SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = ".(int) $term_obj->term_id); |
|
| 1808 | + $edit_tt_ids = wp_list_pluck($edit_ids, 'term_taxonomy_id'); |
|
| 1809 | 1809 | |
| 1810 | 1810 | /** |
| 1811 | 1811 | * Fires immediately before a term to delete's children are reassigned a parent. |
@@ -1814,13 +1814,13 @@ discard block |
||
| 1814 | 1814 | * |
| 1815 | 1815 | * @param array $edit_tt_ids An array of term taxonomy IDs for the given term. |
| 1816 | 1816 | */ |
| 1817 | - do_action( 'edit_term_taxonomies', $edit_tt_ids ); |
|
| 1817 | + do_action('edit_term_taxonomies', $edit_tt_ids); |
|
| 1818 | 1818 | |
| 1819 | - $wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) ); |
|
| 1819 | + $wpdb->update($wpdb->term_taxonomy, compact('parent'), array('parent' => $term_obj->term_id) + compact('taxonomy')); |
|
| 1820 | 1820 | |
| 1821 | 1821 | // Clean the cache for all child terms. |
| 1822 | - $edit_term_ids = wp_list_pluck( $edit_ids, 'term_id' ); |
|
| 1823 | - clean_term_cache( $edit_term_ids, $taxonomy ); |
|
| 1822 | + $edit_term_ids = wp_list_pluck($edit_ids, 'term_id'); |
|
| 1823 | + clean_term_cache($edit_term_ids, $taxonomy); |
|
| 1824 | 1824 | |
| 1825 | 1825 | /** |
| 1826 | 1826 | * Fires immediately after a term to delete's children are reassigned a parent. |
@@ -1829,17 +1829,17 @@ discard block |
||
| 1829 | 1829 | * |
| 1830 | 1830 | * @param array $edit_tt_ids An array of term taxonomy IDs for the given term. |
| 1831 | 1831 | */ |
| 1832 | - do_action( 'edited_term_taxonomies', $edit_tt_ids ); |
|
| 1832 | + do_action('edited_term_taxonomies', $edit_tt_ids); |
|
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | 1835 | // Get the term before deleting it or its term relationships so we can pass to actions below. |
| 1836 | - $deleted_term = get_term( $term, $taxonomy ); |
|
| 1836 | + $deleted_term = get_term($term, $taxonomy); |
|
| 1837 | 1837 | |
| 1838 | - $object_ids = (array) $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) ); |
|
| 1838 | + $object_ids = (array) $wpdb->get_col($wpdb->prepare("SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id)); |
|
| 1839 | 1839 | |
| 1840 | - foreach ( $object_ids as $object_id ) { |
|
| 1841 | - $terms = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids', 'orderby' => 'none' ) ); |
|
| 1842 | - if ( 1 == count($terms) && isset($default) ) { |
|
| 1840 | + foreach ($object_ids as $object_id) { |
|
| 1841 | + $terms = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'ids', 'orderby' => 'none')); |
|
| 1842 | + if (1 == count($terms) && isset($default)) { |
|
| 1843 | 1843 | $terms = array($default); |
| 1844 | 1844 | } else { |
| 1845 | 1845 | $terms = array_diff($terms, array($term)); |
@@ -1847,17 +1847,17 @@ discard block |
||
| 1847 | 1847 | $terms = array_merge($terms, array($default)); |
| 1848 | 1848 | } |
| 1849 | 1849 | $terms = array_map('intval', $terms); |
| 1850 | - wp_set_object_terms( $object_id, $terms, $taxonomy ); |
|
| 1850 | + wp_set_object_terms($object_id, $terms, $taxonomy); |
|
| 1851 | 1851 | } |
| 1852 | 1852 | |
| 1853 | 1853 | // Clean the relationship caches for all object types using this term. |
| 1854 | - $tax_object = get_taxonomy( $taxonomy ); |
|
| 1855 | - foreach ( $tax_object->object_type as $object_type ) |
|
| 1856 | - clean_object_term_cache( $object_ids, $object_type ); |
|
| 1854 | + $tax_object = get_taxonomy($taxonomy); |
|
| 1855 | + foreach ($tax_object->object_type as $object_type) |
|
| 1856 | + clean_object_term_cache($object_ids, $object_type); |
|
| 1857 | 1857 | |
| 1858 | - $term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) ); |
|
| 1859 | - foreach ( $term_meta_ids as $mid ) { |
|
| 1860 | - delete_metadata_by_mid( 'term', $mid ); |
|
| 1858 | + $term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term)); |
|
| 1859 | + foreach ($term_meta_ids as $mid) { |
|
| 1860 | + delete_metadata_by_mid('term', $mid); |
|
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | 1863 | /** |
@@ -1867,8 +1867,8 @@ discard block |
||
| 1867 | 1867 | * |
| 1868 | 1868 | * @param int $tt_id Term taxonomy ID. |
| 1869 | 1869 | */ |
| 1870 | - do_action( 'delete_term_taxonomy', $tt_id ); |
|
| 1871 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) ); |
|
| 1870 | + do_action('delete_term_taxonomy', $tt_id); |
|
| 1871 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $tt_id)); |
|
| 1872 | 1872 | |
| 1873 | 1873 | /** |
| 1874 | 1874 | * Fires immediately after a term taxonomy ID is deleted. |
@@ -1877,11 +1877,11 @@ discard block |
||
| 1877 | 1877 | * |
| 1878 | 1878 | * @param int $tt_id Term taxonomy ID. |
| 1879 | 1879 | */ |
| 1880 | - do_action( 'deleted_term_taxonomy', $tt_id ); |
|
| 1880 | + do_action('deleted_term_taxonomy', $tt_id); |
|
| 1881 | 1881 | |
| 1882 | 1882 | // Delete the term if no taxonomies use it. |
| 1883 | - if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) ) |
|
| 1884 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) ); |
|
| 1883 | + if ( ! $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term))) |
|
| 1884 | + $wpdb->delete($wpdb->terms, array('term_id' => $term)); |
|
| 1885 | 1885 | |
| 1886 | 1886 | clean_term_cache($term, $taxonomy); |
| 1887 | 1887 | |
@@ -1898,7 +1898,7 @@ discard block |
||
| 1898 | 1898 | * by the parent function. WP_Error otherwise. |
| 1899 | 1899 | * @param array $object_ids List of term object IDs. |
| 1900 | 1900 | */ |
| 1901 | - do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids ); |
|
| 1901 | + do_action('delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids); |
|
| 1902 | 1902 | |
| 1903 | 1903 | /** |
| 1904 | 1904 | * Fires after a term in a specific taxonomy is deleted. |
@@ -1915,7 +1915,7 @@ discard block |
||
| 1915 | 1915 | * by the parent function. WP_Error otherwise. |
| 1916 | 1916 | * @param array $object_ids List of term object IDs. |
| 1917 | 1917 | */ |
| 1918 | - do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids ); |
|
| 1918 | + do_action("delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids); |
|
| 1919 | 1919 | |
| 1920 | 1920 | return true; |
| 1921 | 1921 | } |
@@ -1929,8 +1929,8 @@ discard block |
||
| 1929 | 1929 | * @return bool|int|WP_Error Returns true if completes delete action; false if term doesn't exist; |
| 1930 | 1930 | * Zero on attempted deletion of default Category; WP_Error object is also a possibility. |
| 1931 | 1931 | */ |
| 1932 | -function wp_delete_category( $cat_ID ) { |
|
| 1933 | - return wp_delete_term( $cat_ID, 'category' ); |
|
| 1932 | +function wp_delete_category($cat_ID) { |
|
| 1933 | + return wp_delete_term($cat_ID, 'category'); |
|
| 1934 | 1934 | } |
| 1935 | 1935 | |
| 1936 | 1936 | /** |
@@ -1968,18 +1968,18 @@ discard block |
||
| 1968 | 1968 | function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { |
| 1969 | 1969 | global $wpdb; |
| 1970 | 1970 | |
| 1971 | - if ( empty( $object_ids ) || empty( $taxonomies ) ) |
|
| 1971 | + if (empty($object_ids) || empty($taxonomies)) |
|
| 1972 | 1972 | return array(); |
| 1973 | 1973 | |
| 1974 | - if ( !is_array($taxonomies) ) |
|
| 1974 | + if ( ! is_array($taxonomies)) |
|
| 1975 | 1975 | $taxonomies = array($taxonomies); |
| 1976 | 1976 | |
| 1977 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 1978 | - if ( ! taxonomy_exists($taxonomy) ) |
|
| 1979 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 1977 | + foreach ($taxonomies as $taxonomy) { |
|
| 1978 | + if ( ! taxonomy_exists($taxonomy)) |
|
| 1979 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | - if ( !is_array($object_ids) ) |
|
| 1982 | + if ( ! is_array($object_ids)) |
|
| 1983 | 1983 | $object_ids = array($object_ids); |
| 1984 | 1984 | $object_ids = array_map('intval', $object_ids); |
| 1985 | 1985 | |
@@ -1991,20 +1991,20 @@ discard block |
||
| 1991 | 1991 | 'update_term_meta_cache' => true, |
| 1992 | 1992 | 'meta_query' => '', |
| 1993 | 1993 | ); |
| 1994 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1994 | + $args = wp_parse_args($args, $defaults); |
|
| 1995 | 1995 | |
| 1996 | 1996 | $terms = array(); |
| 1997 | - if ( count($taxonomies) > 1 ) { |
|
| 1998 | - foreach ( $taxonomies as $index => $taxonomy ) { |
|
| 1997 | + if (count($taxonomies) > 1) { |
|
| 1998 | + foreach ($taxonomies as $index => $taxonomy) { |
|
| 1999 | 1999 | $t = get_taxonomy($taxonomy); |
| 2000 | - if ( isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args) ) { |
|
| 2000 | + if (isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args)) { |
|
| 2001 | 2001 | unset($taxonomies[$index]); |
| 2002 | 2002 | $terms = array_merge($terms, wp_get_object_terms($object_ids, $taxonomy, array_merge($args, $t->args))); |
| 2003 | 2003 | } |
| 2004 | 2004 | } |
| 2005 | 2005 | } else { |
| 2006 | 2006 | $t = get_taxonomy($taxonomies[0]); |
| 2007 | - if ( isset($t->args) && is_array($t->args) ) |
|
| 2007 | + if (isset($t->args) && is_array($t->args)) |
|
| 2008 | 2008 | $args = array_merge($args, $t->args); |
| 2009 | 2009 | } |
| 2010 | 2010 | |
@@ -2012,13 +2012,13 @@ discard block |
||
| 2012 | 2012 | $order = $args['order']; |
| 2013 | 2013 | $fields = $args['fields']; |
| 2014 | 2014 | |
| 2015 | - if ( in_array( $orderby, array( 'term_id', 'name', 'slug', 'term_group' ) ) ) { |
|
| 2015 | + if (in_array($orderby, array('term_id', 'name', 'slug', 'term_group'))) { |
|
| 2016 | 2016 | $orderby = "t.$orderby"; |
| 2017 | - } elseif ( in_array( $orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id' ) ) ) { |
|
| 2017 | + } elseif (in_array($orderby, array('count', 'parent', 'taxonomy', 'term_taxonomy_id'))) { |
|
| 2018 | 2018 | $orderby = "tt.$orderby"; |
| 2019 | - } elseif ( 'term_order' === $orderby ) { |
|
| 2019 | + } elseif ('term_order' === $orderby) { |
|
| 2020 | 2020 | $orderby = 'tr.term_order'; |
| 2021 | - } elseif ( 'none' === $orderby ) { |
|
| 2021 | + } elseif ('none' === $orderby) { |
|
| 2022 | 2022 | $orderby = ''; |
| 2023 | 2023 | $order = ''; |
| 2024 | 2024 | } else { |
@@ -2026,31 +2026,31 @@ discard block |
||
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | 2028 | // tt_ids queries can only be none or tr.term_taxonomy_id |
| 2029 | - if ( ('tt_ids' == $fields) && !empty($orderby) ) |
|
| 2029 | + if (('tt_ids' == $fields) && ! empty($orderby)) |
|
| 2030 | 2030 | $orderby = 'tr.term_taxonomy_id'; |
| 2031 | 2031 | |
| 2032 | - if ( !empty($orderby) ) |
|
| 2032 | + if ( ! empty($orderby)) |
|
| 2033 | 2033 | $orderby = "ORDER BY $orderby"; |
| 2034 | 2034 | |
| 2035 | - $order = strtoupper( $order ); |
|
| 2036 | - if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) |
|
| 2035 | + $order = strtoupper($order); |
|
| 2036 | + if ('' !== $order && ! in_array($order, array('ASC', 'DESC'))) |
|
| 2037 | 2037 | $order = 'ASC'; |
| 2038 | 2038 | |
| 2039 | 2039 | $taxonomy_array = $taxonomies; |
| 2040 | 2040 | $object_id_array = $object_ids; |
| 2041 | - $taxonomies = "'" . implode("', '", array_map( 'esc_sql', $taxonomies ) ) . "'"; |
|
| 2041 | + $taxonomies = "'".implode("', '", array_map('esc_sql', $taxonomies))."'"; |
|
| 2042 | 2042 | $object_ids = implode(', ', $object_ids); |
| 2043 | 2043 | |
| 2044 | 2044 | $select_this = ''; |
| 2045 | - if ( 'all' == $fields ) { |
|
| 2045 | + if ('all' == $fields) { |
|
| 2046 | 2046 | $select_this = 't.*, tt.*'; |
| 2047 | - } elseif ( 'ids' == $fields ) { |
|
| 2047 | + } elseif ('ids' == $fields) { |
|
| 2048 | 2048 | $select_this = 't.term_id'; |
| 2049 | - } elseif ( 'names' == $fields ) { |
|
| 2049 | + } elseif ('names' == $fields) { |
|
| 2050 | 2050 | $select_this = 't.name'; |
| 2051 | - } elseif ( 'slugs' == $fields ) { |
|
| 2051 | + } elseif ('slugs' == $fields) { |
|
| 2052 | 2052 | $select_this = 't.slug'; |
| 2053 | - } elseif ( 'all_with_object_id' == $fields ) { |
|
| 2053 | + } elseif ('all_with_object_id' == $fields) { |
|
| 2054 | 2054 | $select_this = 't.*, tt.*, tr.object_id'; |
| 2055 | 2055 | } |
| 2056 | 2056 | |
@@ -2059,86 +2059,86 @@ discard block |
||
| 2059 | 2059 | "tr.object_id IN ($object_ids)", |
| 2060 | 2060 | ); |
| 2061 | 2061 | |
| 2062 | - if ( '' !== $args['parent'] ) { |
|
| 2063 | - $where[] = $wpdb->prepare( 'tt.parent = %d', $args['parent'] ); |
|
| 2062 | + if ('' !== $args['parent']) { |
|
| 2063 | + $where[] = $wpdb->prepare('tt.parent = %d', $args['parent']); |
|
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | 2066 | // Meta query support. |
| 2067 | 2067 | $meta_query_join = ''; |
| 2068 | - if ( ! empty( $args['meta_query'] ) ) { |
|
| 2069 | - $mquery = new WP_Meta_Query( $args['meta_query'] ); |
|
| 2070 | - $mq_sql = $mquery->get_sql( 'term', 't', 'term_id' ); |
|
| 2068 | + if ( ! empty($args['meta_query'])) { |
|
| 2069 | + $mquery = new WP_Meta_Query($args['meta_query']); |
|
| 2070 | + $mq_sql = $mquery->get_sql('term', 't', 'term_id'); |
|
| 2071 | 2071 | |
| 2072 | 2072 | $meta_query_join .= $mq_sql['join']; |
| 2073 | 2073 | |
| 2074 | 2074 | // Strip leading AND. |
| 2075 | - $where[] = preg_replace( '/^\s*AND/', '', $mq_sql['where'] ); |
|
| 2075 | + $where[] = preg_replace('/^\s*AND/', '', $mq_sql['where']); |
|
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | - $where = implode( ' AND ', $where ); |
|
| 2078 | + $where = implode(' AND ', $where); |
|
| 2079 | 2079 | |
| 2080 | 2080 | $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id $meta_query_join WHERE $where $orderby $order"; |
| 2081 | 2081 | |
| 2082 | 2082 | $objects = false; |
| 2083 | - if ( 'all' == $fields || 'all_with_object_id' == $fields ) { |
|
| 2084 | - $_terms = $wpdb->get_results( $query ); |
|
| 2083 | + if ('all' == $fields || 'all_with_object_id' == $fields) { |
|
| 2084 | + $_terms = $wpdb->get_results($query); |
|
| 2085 | 2085 | $object_id_index = array(); |
| 2086 | - foreach ( $_terms as $key => $term ) { |
|
| 2087 | - $term = sanitize_term( $term, $taxonomy, 'raw' ); |
|
| 2088 | - $_terms[ $key ] = $term; |
|
| 2086 | + foreach ($_terms as $key => $term) { |
|
| 2087 | + $term = sanitize_term($term, $taxonomy, 'raw'); |
|
| 2088 | + $_terms[$key] = $term; |
|
| 2089 | 2089 | |
| 2090 | - if ( isset( $term->object_id ) ) { |
|
| 2091 | - $object_id_index[ $key ] = $term->object_id; |
|
| 2090 | + if (isset($term->object_id)) { |
|
| 2091 | + $object_id_index[$key] = $term->object_id; |
|
| 2092 | 2092 | } |
| 2093 | 2093 | } |
| 2094 | 2094 | |
| 2095 | - update_term_cache( $_terms ); |
|
| 2096 | - $_terms = array_map( 'get_term', $_terms ); |
|
| 2095 | + update_term_cache($_terms); |
|
| 2096 | + $_terms = array_map('get_term', $_terms); |
|
| 2097 | 2097 | |
| 2098 | 2098 | // Re-add the object_id data, which is lost when fetching terms from cache. |
| 2099 | - if ( 'all_with_object_id' === $fields ) { |
|
| 2100 | - foreach ( $_terms as $key => $_term ) { |
|
| 2101 | - if ( isset( $object_id_index[ $key ] ) ) { |
|
| 2102 | - $_term->object_id = $object_id_index[ $key ]; |
|
| 2099 | + if ('all_with_object_id' === $fields) { |
|
| 2100 | + foreach ($_terms as $key => $_term) { |
|
| 2101 | + if (isset($object_id_index[$key])) { |
|
| 2102 | + $_term->object_id = $object_id_index[$key]; |
|
| 2103 | 2103 | } |
| 2104 | 2104 | } |
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | - $terms = array_merge( $terms, $_terms ); |
|
| 2107 | + $terms = array_merge($terms, $_terms); |
|
| 2108 | 2108 | $objects = true; |
| 2109 | 2109 | |
| 2110 | - } elseif ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) { |
|
| 2111 | - $_terms = $wpdb->get_col( $query ); |
|
| 2112 | - $_field = ( 'ids' == $fields ) ? 'term_id' : 'name'; |
|
| 2113 | - foreach ( $_terms as $key => $term ) { |
|
| 2114 | - $_terms[$key] = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw' ); |
|
| 2110 | + } elseif ('ids' == $fields || 'names' == $fields || 'slugs' == $fields) { |
|
| 2111 | + $_terms = $wpdb->get_col($query); |
|
| 2112 | + $_field = ('ids' == $fields) ? 'term_id' : 'name'; |
|
| 2113 | + foreach ($_terms as $key => $term) { |
|
| 2114 | + $_terms[$key] = sanitize_term_field($_field, $term, $term, $taxonomy, 'raw'); |
|
| 2115 | 2115 | } |
| 2116 | - $terms = array_merge( $terms, $_terms ); |
|
| 2117 | - } elseif ( 'tt_ids' == $fields ) { |
|
| 2116 | + $terms = array_merge($terms, $_terms); |
|
| 2117 | + } elseif ('tt_ids' == $fields) { |
|
| 2118 | 2118 | $terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order"); |
| 2119 | - foreach ( $terms as $key => $tt_id ) { |
|
| 2120 | - $terms[$key] = sanitize_term_field( 'term_taxonomy_id', $tt_id, 0, $taxonomy, 'raw' ); // 0 should be the term id, however is not needed when using raw context. |
|
| 2119 | + foreach ($terms as $key => $tt_id) { |
|
| 2120 | + $terms[$key] = sanitize_term_field('term_taxonomy_id', $tt_id, 0, $taxonomy, 'raw'); // 0 should be the term id, however is not needed when using raw context. |
|
| 2121 | 2121 | } |
| 2122 | 2122 | } |
| 2123 | 2123 | |
| 2124 | 2124 | // Update termmeta cache, if necessary. |
| 2125 | - if ( $args['update_term_meta_cache'] && ( 'all' === $fields || 'all_with_object_id' === $fields || 'ids' === $fields ) ) { |
|
| 2126 | - if ( 'ids' === $fields ) { |
|
| 2125 | + if ($args['update_term_meta_cache'] && ('all' === $fields || 'all_with_object_id' === $fields || 'ids' === $fields)) { |
|
| 2126 | + if ('ids' === $fields) { |
|
| 2127 | 2127 | $term_ids = $terms; |
| 2128 | 2128 | } else { |
| 2129 | - $term_ids = wp_list_pluck( $terms, 'term_id' ); |
|
| 2129 | + $term_ids = wp_list_pluck($terms, 'term_id'); |
|
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | - update_termmeta_cache( $term_ids ); |
|
| 2132 | + update_termmeta_cache($term_ids); |
|
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | - if ( ! $terms ) { |
|
| 2135 | + if ( ! $terms) { |
|
| 2136 | 2136 | $terms = array(); |
| 2137 | - } elseif ( $objects && 'all_with_object_id' !== $fields ) { |
|
| 2137 | + } elseif ($objects && 'all_with_object_id' !== $fields) { |
|
| 2138 | 2138 | $_tt_ids = array(); |
| 2139 | 2139 | $_terms = array(); |
| 2140 | - foreach ( $terms as $term ) { |
|
| 2141 | - if ( in_array( $term->term_taxonomy_id, $_tt_ids ) ) { |
|
| 2140 | + foreach ($terms as $term) { |
|
| 2141 | + if (in_array($term->term_taxonomy_id, $_tt_ids)) { |
|
| 2142 | 2142 | continue; |
| 2143 | 2143 | } |
| 2144 | 2144 | |
@@ -2146,8 +2146,8 @@ discard block |
||
| 2146 | 2146 | $_terms[] = $term; |
| 2147 | 2147 | } |
| 2148 | 2148 | $terms = $_terms; |
| 2149 | - } elseif ( ! $objects ) { |
|
| 2150 | - $terms = array_values( array_unique( $terms ) ); |
|
| 2149 | + } elseif ( ! $objects) { |
|
| 2150 | + $terms = array_values(array_unique($terms)); |
|
| 2151 | 2151 | } |
| 2152 | 2152 | |
| 2153 | 2153 | /** |
@@ -2161,7 +2161,7 @@ discard block |
||
| 2161 | 2161 | * @param array $args An array of arguments for retrieving terms for the given |
| 2162 | 2162 | * object(s). See wp_get_object_terms() for details. |
| 2163 | 2163 | */ |
| 2164 | - $terms = apply_filters( 'get_object_terms', $terms, $object_id_array, $taxonomy_array, $args ); |
|
| 2164 | + $terms = apply_filters('get_object_terms', $terms, $object_id_array, $taxonomy_array, $args); |
|
| 2165 | 2165 | |
| 2166 | 2166 | /** |
| 2167 | 2167 | * Filters the terms for a given object or objects. |
@@ -2177,7 +2177,7 @@ discard block |
||
| 2177 | 2177 | * @param array $args An array of arguments for retrieving terms for the given object(s). |
| 2178 | 2178 | * See wp_get_object_terms() for details. |
| 2179 | 2179 | */ |
| 2180 | - return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args ); |
|
| 2180 | + return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args); |
|
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | /** |
@@ -2223,11 +2223,11 @@ discard block |
||
| 2223 | 2223 | * @return array|WP_Error An array containing the `term_id` and `term_taxonomy_id`, |
| 2224 | 2224 | * WP_Error otherwise. |
| 2225 | 2225 | */ |
| 2226 | -function wp_insert_term( $term, $taxonomy, $args = array() ) { |
|
| 2226 | +function wp_insert_term($term, $taxonomy, $args = array()) { |
|
| 2227 | 2227 | global $wpdb; |
| 2228 | 2228 | |
| 2229 | - if ( ! taxonomy_exists($taxonomy) ) { |
|
| 2230 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 2229 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 2230 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | /** |
| 2233 | 2233 | * Filters a term before it is sanitized and inserted into the database. |
@@ -2237,21 +2237,21 @@ discard block |
||
| 2237 | 2237 | * @param string $term The term to add or update. |
| 2238 | 2238 | * @param string $taxonomy Taxonomy slug. |
| 2239 | 2239 | */ |
| 2240 | - $term = apply_filters( 'pre_insert_term', $term, $taxonomy ); |
|
| 2241 | - if ( is_wp_error( $term ) ) { |
|
| 2240 | + $term = apply_filters('pre_insert_term', $term, $taxonomy); |
|
| 2241 | + if (is_wp_error($term)) { |
|
| 2242 | 2242 | return $term; |
| 2243 | 2243 | } |
| 2244 | - if ( is_int( $term ) && 0 == $term ) { |
|
| 2245 | - return new WP_Error( 'invalid_term_id', __( 'Invalid term ID.' ) ); |
|
| 2244 | + if (is_int($term) && 0 == $term) { |
|
| 2245 | + return new WP_Error('invalid_term_id', __('Invalid term ID.')); |
|
| 2246 | 2246 | } |
| 2247 | - if ( '' == trim( $term ) ) { |
|
| 2248 | - return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) ); |
|
| 2247 | + if ('' == trim($term)) { |
|
| 2248 | + return new WP_Error('empty_term_name', __('A name is required for this term.')); |
|
| 2249 | 2249 | } |
| 2250 | - $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 2251 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2250 | + $defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 2251 | + $args = wp_parse_args($args, $defaults); |
|
| 2252 | 2252 | |
| 2253 | - if ( $args['parent'] > 0 && ! term_exists( (int) $args['parent'] ) ) { |
|
| 2254 | - return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) ); |
|
| 2253 | + if ($args['parent'] > 0 && ! term_exists((int) $args['parent'])) { |
|
| 2254 | + return new WP_Error('missing_parent', __('Parent term does not exist.')); |
|
| 2255 | 2255 | } |
| 2256 | 2256 | |
| 2257 | 2257 | $args['name'] = $term; |
@@ -2263,33 +2263,33 @@ discard block |
||
| 2263 | 2263 | $args = sanitize_term($args, $taxonomy, 'db'); |
| 2264 | 2264 | |
| 2265 | 2265 | // expected_slashed ($name) |
| 2266 | - $name = wp_unslash( $args['name'] ); |
|
| 2267 | - $description = wp_unslash( $args['description'] ); |
|
| 2266 | + $name = wp_unslash($args['name']); |
|
| 2267 | + $description = wp_unslash($args['description']); |
|
| 2268 | 2268 | $parent = (int) $args['parent']; |
| 2269 | 2269 | |
| 2270 | - $slug_provided = ! empty( $args['slug'] ); |
|
| 2271 | - if ( ! $slug_provided ) { |
|
| 2272 | - $slug = sanitize_title( $name ); |
|
| 2270 | + $slug_provided = ! empty($args['slug']); |
|
| 2271 | + if ( ! $slug_provided) { |
|
| 2272 | + $slug = sanitize_title($name); |
|
| 2273 | 2273 | } else { |
| 2274 | 2274 | $slug = $args['slug']; |
| 2275 | 2275 | } |
| 2276 | 2276 | |
| 2277 | 2277 | $term_group = 0; |
| 2278 | - if ( $args['alias_of'] ) { |
|
| 2279 | - $alias = get_term_by( 'slug', $args['alias_of'], $taxonomy ); |
|
| 2280 | - if ( ! empty( $alias->term_group ) ) { |
|
| 2278 | + if ($args['alias_of']) { |
|
| 2279 | + $alias = get_term_by('slug', $args['alias_of'], $taxonomy); |
|
| 2280 | + if ( ! empty($alias->term_group)) { |
|
| 2281 | 2281 | // The alias we want is already in a group, so let's use that one. |
| 2282 | 2282 | $term_group = $alias->term_group; |
| 2283 | - } elseif ( ! empty( $alias->term_id ) ) { |
|
| 2283 | + } elseif ( ! empty($alias->term_id)) { |
|
| 2284 | 2284 | /* |
| 2285 | 2285 | * The alias is not in a group, so we create a new one |
| 2286 | 2286 | * and add the alias to it. |
| 2287 | 2287 | */ |
| 2288 | 2288 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
| 2289 | 2289 | |
| 2290 | - wp_update_term( $alias->term_id, $taxonomy, array( |
|
| 2290 | + wp_update_term($alias->term_id, $taxonomy, array( |
|
| 2291 | 2291 | 'term_group' => $term_group, |
| 2292 | - ) ); |
|
| 2292 | + )); |
|
| 2293 | 2293 | } |
| 2294 | 2294 | } |
| 2295 | 2295 | |
@@ -2297,73 +2297,73 @@ discard block |
||
| 2297 | 2297 | * Prevent the creation of terms with duplicate names at the same level of a taxonomy hierarchy, |
| 2298 | 2298 | * unless a unique slug has been explicitly provided. |
| 2299 | 2299 | */ |
| 2300 | - $name_matches = get_terms( $taxonomy, array( |
|
| 2300 | + $name_matches = get_terms($taxonomy, array( |
|
| 2301 | 2301 | 'name' => $name, |
| 2302 | 2302 | 'hide_empty' => false, |
| 2303 | - ) ); |
|
| 2303 | + )); |
|
| 2304 | 2304 | |
| 2305 | 2305 | /* |
| 2306 | 2306 | * The `name` match in `get_terms()` doesn't differentiate accented characters, |
| 2307 | 2307 | * so we do a stricter comparison here. |
| 2308 | 2308 | */ |
| 2309 | 2309 | $name_match = null; |
| 2310 | - if ( $name_matches ) { |
|
| 2311 | - foreach ( $name_matches as $_match ) { |
|
| 2312 | - if ( strtolower( $name ) === strtolower( $_match->name ) ) { |
|
| 2310 | + if ($name_matches) { |
|
| 2311 | + foreach ($name_matches as $_match) { |
|
| 2312 | + if (strtolower($name) === strtolower($_match->name)) { |
|
| 2313 | 2313 | $name_match = $_match; |
| 2314 | 2314 | break; |
| 2315 | 2315 | } |
| 2316 | 2316 | } |
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | - if ( $name_match ) { |
|
| 2320 | - $slug_match = get_term_by( 'slug', $slug, $taxonomy ); |
|
| 2321 | - if ( ! $slug_provided || $name_match->slug === $slug || $slug_match ) { |
|
| 2322 | - if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
| 2323 | - $siblings = get_terms( $taxonomy, array( 'get' => 'all', 'parent' => $parent ) ); |
|
| 2319 | + if ($name_match) { |
|
| 2320 | + $slug_match = get_term_by('slug', $slug, $taxonomy); |
|
| 2321 | + if ( ! $slug_provided || $name_match->slug === $slug || $slug_match) { |
|
| 2322 | + if (is_taxonomy_hierarchical($taxonomy)) { |
|
| 2323 | + $siblings = get_terms($taxonomy, array('get' => 'all', 'parent' => $parent)); |
|
| 2324 | 2324 | |
| 2325 | 2325 | $existing_term = null; |
| 2326 | - if ( $name_match->slug === $slug && in_array( $name, wp_list_pluck( $siblings, 'name' ) ) ) { |
|
| 2326 | + if ($name_match->slug === $slug && in_array($name, wp_list_pluck($siblings, 'name'))) { |
|
| 2327 | 2327 | $existing_term = $name_match; |
| 2328 | - } elseif ( $slug_match && in_array( $slug, wp_list_pluck( $siblings, 'slug' ) ) ) { |
|
| 2328 | + } elseif ($slug_match && in_array($slug, wp_list_pluck($siblings, 'slug'))) { |
|
| 2329 | 2329 | $existing_term = $slug_match; |
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | - if ( $existing_term ) { |
|
| 2333 | - return new WP_Error( 'term_exists', __( 'A term with the name provided already exists with this parent.' ), $existing_term->term_id ); |
|
| 2332 | + if ($existing_term) { |
|
| 2333 | + return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $existing_term->term_id); |
|
| 2334 | 2334 | } |
| 2335 | 2335 | } else { |
| 2336 | - return new WP_Error( 'term_exists', __( 'A term with the name provided already exists in this taxonomy.' ), $name_match->term_id ); |
|
| 2336 | + return new WP_Error('term_exists', __('A term with the name provided already exists in this taxonomy.'), $name_match->term_id); |
|
| 2337 | 2337 | } |
| 2338 | 2338 | } |
| 2339 | 2339 | } |
| 2340 | 2340 | |
| 2341 | - $slug = wp_unique_term_slug( $slug, (object) $args ); |
|
| 2341 | + $slug = wp_unique_term_slug($slug, (object) $args); |
|
| 2342 | 2342 | |
| 2343 | - if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) { |
|
| 2344 | - return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database' ), $wpdb->last_error ); |
|
| 2343 | + if (false === $wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group'))) { |
|
| 2344 | + return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
|
| 2345 | 2345 | } |
| 2346 | 2346 | |
| 2347 | 2347 | $term_id = (int) $wpdb->insert_id; |
| 2348 | 2348 | |
| 2349 | 2349 | // Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string. |
| 2350 | - if ( empty($slug) ) { |
|
| 2350 | + if (empty($slug)) { |
|
| 2351 | 2351 | $slug = sanitize_title($slug, $term_id); |
| 2352 | 2352 | |
| 2353 | 2353 | /** This action is documented in wp-includes/taxonomy.php */ |
| 2354 | - do_action( 'edit_terms', $term_id, $taxonomy ); |
|
| 2355 | - $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
|
| 2354 | + do_action('edit_terms', $term_id, $taxonomy); |
|
| 2355 | + $wpdb->update($wpdb->terms, compact('slug'), compact('term_id')); |
|
| 2356 | 2356 | |
| 2357 | 2357 | /** This action is documented in wp-includes/taxonomy.php */ |
| 2358 | - do_action( 'edited_terms', $term_id, $taxonomy ); |
|
| 2358 | + do_action('edited_terms', $term_id, $taxonomy); |
|
| 2359 | 2359 | } |
| 2360 | 2360 | |
| 2361 | - $tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id ) ); |
|
| 2361 | + $tt_id = $wpdb->get_var($wpdb->prepare("SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id)); |
|
| 2362 | 2362 | |
| 2363 | - if ( !empty($tt_id) ) { |
|
| 2363 | + if ( ! empty($tt_id)) { |
|
| 2364 | 2364 | return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
| 2365 | 2365 | } |
| 2366 | - $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) ); |
|
| 2366 | + $wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent') + array('count' => 0)); |
|
| 2367 | 2367 | $tt_id = (int) $wpdb->insert_id; |
| 2368 | 2368 | |
| 2369 | 2369 | /* |
@@ -2372,16 +2372,16 @@ discard block |
||
| 2372 | 2372 | * and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks |
| 2373 | 2373 | * are not fired. |
| 2374 | 2374 | */ |
| 2375 | - $duplicate_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, tt.term_taxonomy_id FROM $wpdb->terms t INNER JOIN $wpdb->term_taxonomy tt ON ( tt.term_id = t.term_id ) WHERE t.slug = %s AND tt.parent = %d AND tt.taxonomy = %s AND t.term_id < %d AND tt.term_taxonomy_id != %d", $slug, $parent, $taxonomy, $term_id, $tt_id ) ); |
|
| 2376 | - if ( $duplicate_term ) { |
|
| 2377 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term_id ) ); |
|
| 2378 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) ); |
|
| 2375 | + $duplicate_term = $wpdb->get_row($wpdb->prepare("SELECT t.term_id, tt.term_taxonomy_id FROM $wpdb->terms t INNER JOIN $wpdb->term_taxonomy tt ON ( tt.term_id = t.term_id ) WHERE t.slug = %s AND tt.parent = %d AND tt.taxonomy = %s AND t.term_id < %d AND tt.term_taxonomy_id != %d", $slug, $parent, $taxonomy, $term_id, $tt_id)); |
|
| 2376 | + if ($duplicate_term) { |
|
| 2377 | + $wpdb->delete($wpdb->terms, array('term_id' => $term_id)); |
|
| 2378 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $tt_id)); |
|
| 2379 | 2379 | |
| 2380 | 2380 | $term_id = (int) $duplicate_term->term_id; |
| 2381 | 2381 | $tt_id = (int) $duplicate_term->term_taxonomy_id; |
| 2382 | 2382 | |
| 2383 | - clean_term_cache( $term_id, $taxonomy ); |
|
| 2384 | - return array( 'term_id' => $term_id, 'term_taxonomy_id' => $tt_id ); |
|
| 2383 | + clean_term_cache($term_id, $taxonomy); |
|
| 2384 | + return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
|
| 2385 | 2385 | } |
| 2386 | 2386 | |
| 2387 | 2387 | /** |
@@ -2393,7 +2393,7 @@ discard block |
||
| 2393 | 2393 | * @param int $tt_id Term taxonomy ID. |
| 2394 | 2394 | * @param string $taxonomy Taxonomy slug. |
| 2395 | 2395 | */ |
| 2396 | - do_action( "create_term", $term_id, $tt_id, $taxonomy ); |
|
| 2396 | + do_action("create_term", $term_id, $tt_id, $taxonomy); |
|
| 2397 | 2397 | |
| 2398 | 2398 | /** |
| 2399 | 2399 | * Fires after a new term is created for a specific taxonomy. |
@@ -2406,7 +2406,7 @@ discard block |
||
| 2406 | 2406 | * @param int $term_id Term ID. |
| 2407 | 2407 | * @param int $tt_id Term taxonomy ID. |
| 2408 | 2408 | */ |
| 2409 | - do_action( "create_$taxonomy", $term_id, $tt_id ); |
|
| 2409 | + do_action("create_$taxonomy", $term_id, $tt_id); |
|
| 2410 | 2410 | |
| 2411 | 2411 | /** |
| 2412 | 2412 | * Filters the term ID after a new term is created. |
@@ -2416,7 +2416,7 @@ discard block |
||
| 2416 | 2416 | * @param int $term_id Term ID. |
| 2417 | 2417 | * @param int $tt_id Taxonomy term ID. |
| 2418 | 2418 | */ |
| 2419 | - $term_id = apply_filters( 'term_id_filter', $term_id, $tt_id ); |
|
| 2419 | + $term_id = apply_filters('term_id_filter', $term_id, $tt_id); |
|
| 2420 | 2420 | |
| 2421 | 2421 | clean_term_cache($term_id, $taxonomy); |
| 2422 | 2422 | |
@@ -2429,7 +2429,7 @@ discard block |
||
| 2429 | 2429 | * @param int $tt_id Term taxonomy ID. |
| 2430 | 2430 | * @param string $taxonomy Taxonomy slug. |
| 2431 | 2431 | */ |
| 2432 | - do_action( 'created_term', $term_id, $tt_id, $taxonomy ); |
|
| 2432 | + do_action('created_term', $term_id, $tt_id, $taxonomy); |
|
| 2433 | 2433 | |
| 2434 | 2434 | /** |
| 2435 | 2435 | * Fires after a new term in a specific taxonomy is created, and after the term |
@@ -2442,7 +2442,7 @@ discard block |
||
| 2442 | 2442 | * @param int $term_id Term ID. |
| 2443 | 2443 | * @param int $tt_id Term taxonomy ID. |
| 2444 | 2444 | */ |
| 2445 | - do_action( "created_$taxonomy", $term_id, $tt_id ); |
|
| 2445 | + do_action("created_$taxonomy", $term_id, $tt_id); |
|
| 2446 | 2446 | |
| 2447 | 2447 | return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
| 2448 | 2448 | } |
@@ -2469,20 +2469,20 @@ discard block |
||
| 2469 | 2469 | * @param bool $append Optional. If false will delete difference of terms. Default false. |
| 2470 | 2470 | * @return array|WP_Error Term taxonomy IDs of the affected terms. |
| 2471 | 2471 | */ |
| 2472 | -function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { |
|
| 2472 | +function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) { |
|
| 2473 | 2473 | global $wpdb; |
| 2474 | 2474 | |
| 2475 | 2475 | $object_id = (int) $object_id; |
| 2476 | 2476 | |
| 2477 | - if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 2478 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 2477 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 2478 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 2479 | 2479 | } |
| 2480 | 2480 | |
| 2481 | - if ( !is_array($terms) ) |
|
| 2481 | + if ( ! is_array($terms)) |
|
| 2482 | 2482 | $terms = array($terms); |
| 2483 | 2483 | |
| 2484 | - if ( ! $append ) |
|
| 2485 | - $old_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none')); |
|
| 2484 | + if ( ! $append) |
|
| 2485 | + $old_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none')); |
|
| 2486 | 2486 | else |
| 2487 | 2487 | $old_tt_ids = array(); |
| 2488 | 2488 | |
@@ -2490,23 +2490,23 @@ discard block |
||
| 2490 | 2490 | $term_ids = array(); |
| 2491 | 2491 | $new_tt_ids = array(); |
| 2492 | 2492 | |
| 2493 | - foreach ( (array) $terms as $term) { |
|
| 2494 | - if ( !strlen(trim($term)) ) |
|
| 2493 | + foreach ((array) $terms as $term) { |
|
| 2494 | + if ( ! strlen(trim($term))) |
|
| 2495 | 2495 | continue; |
| 2496 | 2496 | |
| 2497 | - if ( !$term_info = term_exists($term, $taxonomy) ) { |
|
| 2497 | + if ( ! $term_info = term_exists($term, $taxonomy)) { |
|
| 2498 | 2498 | // Skip if a non-existent term ID is passed. |
| 2499 | - if ( is_int($term) ) |
|
| 2499 | + if (is_int($term)) |
|
| 2500 | 2500 | continue; |
| 2501 | 2501 | $term_info = wp_insert_term($term, $taxonomy); |
| 2502 | 2502 | } |
| 2503 | - if ( is_wp_error($term_info) ) |
|
| 2503 | + if (is_wp_error($term_info)) |
|
| 2504 | 2504 | return $term_info; |
| 2505 | 2505 | $term_ids[] = $term_info['term_id']; |
| 2506 | 2506 | $tt_id = $term_info['term_taxonomy_id']; |
| 2507 | 2507 | $tt_ids[] = $tt_id; |
| 2508 | 2508 | |
| 2509 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) ) |
|
| 2509 | + if ($wpdb->get_var($wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id))) |
|
| 2510 | 2510 | continue; |
| 2511 | 2511 | |
| 2512 | 2512 | /** |
@@ -2517,8 +2517,8 @@ discard block |
||
| 2517 | 2517 | * @param int $object_id Object ID. |
| 2518 | 2518 | * @param int $tt_id Term taxonomy ID. |
| 2519 | 2519 | */ |
| 2520 | - do_action( 'add_term_relationship', $object_id, $tt_id ); |
|
| 2521 | - $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) ); |
|
| 2520 | + do_action('add_term_relationship', $object_id, $tt_id); |
|
| 2521 | + $wpdb->insert($wpdb->term_relationships, array('object_id' => $object_id, 'term_taxonomy_id' => $tt_id)); |
|
| 2522 | 2522 | |
| 2523 | 2523 | /** |
| 2524 | 2524 | * Fires immediately after an object-term relationship is added. |
@@ -2528,42 +2528,42 @@ discard block |
||
| 2528 | 2528 | * @param int $object_id Object ID. |
| 2529 | 2529 | * @param int $tt_id Term taxonomy ID. |
| 2530 | 2530 | */ |
| 2531 | - do_action( 'added_term_relationship', $object_id, $tt_id ); |
|
| 2531 | + do_action('added_term_relationship', $object_id, $tt_id); |
|
| 2532 | 2532 | $new_tt_ids[] = $tt_id; |
| 2533 | 2533 | } |
| 2534 | 2534 | |
| 2535 | - if ( $new_tt_ids ) |
|
| 2536 | - wp_update_term_count( $new_tt_ids, $taxonomy ); |
|
| 2535 | + if ($new_tt_ids) |
|
| 2536 | + wp_update_term_count($new_tt_ids, $taxonomy); |
|
| 2537 | 2537 | |
| 2538 | - if ( ! $append ) { |
|
| 2539 | - $delete_tt_ids = array_diff( $old_tt_ids, $tt_ids ); |
|
| 2538 | + if ( ! $append) { |
|
| 2539 | + $delete_tt_ids = array_diff($old_tt_ids, $tt_ids); |
|
| 2540 | 2540 | |
| 2541 | - if ( $delete_tt_ids ) { |
|
| 2542 | - $in_delete_tt_ids = "'" . implode( "', '", $delete_tt_ids ) . "'"; |
|
| 2543 | - $delete_term_ids = $wpdb->get_col( $wpdb->prepare( "SELECT tt.term_id FROM $wpdb->term_taxonomy AS tt WHERE tt.taxonomy = %s AND tt.term_taxonomy_id IN ($in_delete_tt_ids)", $taxonomy ) ); |
|
| 2544 | - $delete_term_ids = array_map( 'intval', $delete_term_ids ); |
|
| 2541 | + if ($delete_tt_ids) { |
|
| 2542 | + $in_delete_tt_ids = "'".implode("', '", $delete_tt_ids)."'"; |
|
| 2543 | + $delete_term_ids = $wpdb->get_col($wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_taxonomy AS tt WHERE tt.taxonomy = %s AND tt.term_taxonomy_id IN ($in_delete_tt_ids)", $taxonomy)); |
|
| 2544 | + $delete_term_ids = array_map('intval', $delete_term_ids); |
|
| 2545 | 2545 | |
| 2546 | - $remove = wp_remove_object_terms( $object_id, $delete_term_ids, $taxonomy ); |
|
| 2547 | - if ( is_wp_error( $remove ) ) { |
|
| 2546 | + $remove = wp_remove_object_terms($object_id, $delete_term_ids, $taxonomy); |
|
| 2547 | + if (is_wp_error($remove)) { |
|
| 2548 | 2548 | return $remove; |
| 2549 | 2549 | } |
| 2550 | 2550 | } |
| 2551 | 2551 | } |
| 2552 | 2552 | |
| 2553 | 2553 | $t = get_taxonomy($taxonomy); |
| 2554 | - if ( ! $append && isset($t->sort) && $t->sort ) { |
|
| 2554 | + if ( ! $append && isset($t->sort) && $t->sort) { |
|
| 2555 | 2555 | $values = array(); |
| 2556 | 2556 | $term_order = 0; |
| 2557 | 2557 | $final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids')); |
| 2558 | - foreach ( $tt_ids as $tt_id ) |
|
| 2559 | - if ( in_array($tt_id, $final_tt_ids) ) |
|
| 2560 | - $values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order); |
|
| 2561 | - if ( $values ) |
|
| 2562 | - if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) ) |
|
| 2563 | - return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error ); |
|
| 2558 | + foreach ($tt_ids as $tt_id) |
|
| 2559 | + if (in_array($tt_id, $final_tt_ids)) |
|
| 2560 | + $values[] = $wpdb->prepare("(%d, %d, %d)", $object_id, $tt_id, ++$term_order); |
|
| 2561 | + if ($values) |
|
| 2562 | + if (false === $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES ".join(',', $values)." ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)")) |
|
| 2563 | + return new WP_Error('db_insert_error', __('Could not insert term relationship into the database'), $wpdb->last_error); |
|
| 2564 | 2564 | } |
| 2565 | 2565 | |
| 2566 | - wp_cache_delete( $object_id, $taxonomy . '_relationships' ); |
|
| 2566 | + wp_cache_delete($object_id, $taxonomy.'_relationships'); |
|
| 2567 | 2567 | |
| 2568 | 2568 | /** |
| 2569 | 2569 | * Fires after an object's terms have been set. |
@@ -2577,7 +2577,7 @@ discard block |
||
| 2577 | 2577 | * @param bool $append Whether to append new terms to the old terms. |
| 2578 | 2578 | * @param array $old_tt_ids Old array of term taxonomy IDs. |
| 2579 | 2579 | */ |
| 2580 | - do_action( 'set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ); |
|
| 2580 | + do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); |
|
| 2581 | 2581 | return $tt_ids; |
| 2582 | 2582 | } |
| 2583 | 2583 | |
@@ -2591,8 +2591,8 @@ discard block |
||
| 2591 | 2591 | * @param array|string $taxonomy Taxonomy name. |
| 2592 | 2592 | * @return array|WP_Error Term taxonomy IDs of the affected terms. |
| 2593 | 2593 | */ |
| 2594 | -function wp_add_object_terms( $object_id, $terms, $taxonomy ) { |
|
| 2595 | - return wp_set_object_terms( $object_id, $terms, $taxonomy, true ); |
|
| 2594 | +function wp_add_object_terms($object_id, $terms, $taxonomy) { |
|
| 2595 | + return wp_set_object_terms($object_id, $terms, $taxonomy, true); |
|
| 2596 | 2596 | } |
| 2597 | 2597 | |
| 2598 | 2598 | /** |
@@ -2607,42 +2607,42 @@ discard block |
||
| 2607 | 2607 | * @param array|string $taxonomy Taxonomy name. |
| 2608 | 2608 | * @return bool|WP_Error True on success, false or WP_Error on failure. |
| 2609 | 2609 | */ |
| 2610 | -function wp_remove_object_terms( $object_id, $terms, $taxonomy ) { |
|
| 2610 | +function wp_remove_object_terms($object_id, $terms, $taxonomy) { |
|
| 2611 | 2611 | global $wpdb; |
| 2612 | 2612 | |
| 2613 | 2613 | $object_id = (int) $object_id; |
| 2614 | 2614 | |
| 2615 | - if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 2616 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 2615 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 2616 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 2617 | 2617 | } |
| 2618 | 2618 | |
| 2619 | - if ( ! is_array( $terms ) ) { |
|
| 2620 | - $terms = array( $terms ); |
|
| 2619 | + if ( ! is_array($terms)) { |
|
| 2620 | + $terms = array($terms); |
|
| 2621 | 2621 | } |
| 2622 | 2622 | |
| 2623 | 2623 | $tt_ids = array(); |
| 2624 | 2624 | |
| 2625 | - foreach ( (array) $terms as $term ) { |
|
| 2626 | - if ( ! strlen( trim( $term ) ) ) { |
|
| 2625 | + foreach ((array) $terms as $term) { |
|
| 2626 | + if ( ! strlen(trim($term))) { |
|
| 2627 | 2627 | continue; |
| 2628 | 2628 | } |
| 2629 | 2629 | |
| 2630 | - if ( ! $term_info = term_exists( $term, $taxonomy ) ) { |
|
| 2630 | + if ( ! $term_info = term_exists($term, $taxonomy)) { |
|
| 2631 | 2631 | // Skip if a non-existent term ID is passed. |
| 2632 | - if ( is_int( $term ) ) { |
|
| 2632 | + if (is_int($term)) { |
|
| 2633 | 2633 | continue; |
| 2634 | 2634 | } |
| 2635 | 2635 | } |
| 2636 | 2636 | |
| 2637 | - if ( is_wp_error( $term_info ) ) { |
|
| 2637 | + if (is_wp_error($term_info)) { |
|
| 2638 | 2638 | return $term_info; |
| 2639 | 2639 | } |
| 2640 | 2640 | |
| 2641 | 2641 | $tt_ids[] = $term_info['term_taxonomy_id']; |
| 2642 | 2642 | } |
| 2643 | 2643 | |
| 2644 | - if ( $tt_ids ) { |
|
| 2645 | - $in_tt_ids = "'" . implode( "', '", $tt_ids ) . "'"; |
|
| 2644 | + if ($tt_ids) { |
|
| 2645 | + $in_tt_ids = "'".implode("', '", $tt_ids)."'"; |
|
| 2646 | 2646 | |
| 2647 | 2647 | /** |
| 2648 | 2648 | * Fires immediately before an object-term relationship is deleted. |
@@ -2652,10 +2652,10 @@ discard block |
||
| 2652 | 2652 | * @param int $object_id Object ID. |
| 2653 | 2653 | * @param array $tt_ids An array of term taxonomy IDs. |
| 2654 | 2654 | */ |
| 2655 | - do_action( 'delete_term_relationships', $object_id, $tt_ids ); |
|
| 2656 | - $deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) ); |
|
| 2655 | + do_action('delete_term_relationships', $object_id, $tt_ids); |
|
| 2656 | + $deleted = $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id)); |
|
| 2657 | 2657 | |
| 2658 | - wp_cache_delete( $object_id, $taxonomy . '_relationships' ); |
|
| 2658 | + wp_cache_delete($object_id, $taxonomy.'_relationships'); |
|
| 2659 | 2659 | |
| 2660 | 2660 | /** |
| 2661 | 2661 | * Fires immediately after an object-term relationship is deleted. |
@@ -2665,9 +2665,9 @@ discard block |
||
| 2665 | 2665 | * @param int $object_id Object ID. |
| 2666 | 2666 | * @param array $tt_ids An array of term taxonomy IDs. |
| 2667 | 2667 | */ |
| 2668 | - do_action( 'deleted_term_relationships', $object_id, $tt_ids ); |
|
| 2668 | + do_action('deleted_term_relationships', $object_id, $tt_ids); |
|
| 2669 | 2669 | |
| 2670 | - wp_update_term_count( $tt_ids, $taxonomy ); |
|
| 2670 | + wp_update_term_count($tt_ids, $taxonomy); |
|
| 2671 | 2671 | |
| 2672 | 2672 | return (bool) $deleted; |
| 2673 | 2673 | } |
@@ -2698,14 +2698,14 @@ discard block |
||
| 2698 | 2698 | * @param object $term The term object that the `$slug` will belong to. |
| 2699 | 2699 | * @return string Will return a true unique slug. |
| 2700 | 2700 | */ |
| 2701 | -function wp_unique_term_slug( $slug, $term ) { |
|
| 2701 | +function wp_unique_term_slug($slug, $term) { |
|
| 2702 | 2702 | global $wpdb; |
| 2703 | 2703 | |
| 2704 | 2704 | $needs_suffix = true; |
| 2705 | 2705 | $original_slug = $slug; |
| 2706 | 2706 | |
| 2707 | 2707 | // As of 4.1, duplicate slugs are allowed as long as they're in different taxonomies. |
| 2708 | - if ( ! term_exists( $slug ) || get_option( 'db_version' ) >= 30133 && ! get_term_by( 'slug', $slug, $term->taxonomy ) ) { |
|
| 2708 | + if ( ! term_exists($slug) || get_option('db_version') >= 30133 && ! get_term_by('slug', $slug, $term->taxonomy)) { |
|
| 2709 | 2709 | $needs_suffix = false; |
| 2710 | 2710 | } |
| 2711 | 2711 | |
@@ -2714,18 +2714,18 @@ discard block |
||
| 2714 | 2714 | * by incorporating parent slugs. |
| 2715 | 2715 | */ |
| 2716 | 2716 | $parent_suffix = ''; |
| 2717 | - if ( $needs_suffix && is_taxonomy_hierarchical( $term->taxonomy ) && ! empty( $term->parent ) ) { |
|
| 2717 | + if ($needs_suffix && is_taxonomy_hierarchical($term->taxonomy) && ! empty($term->parent)) { |
|
| 2718 | 2718 | $the_parent = $term->parent; |
| 2719 | - while ( ! empty($the_parent) ) { |
|
| 2719 | + while ( ! empty($the_parent)) { |
|
| 2720 | 2720 | $parent_term = get_term($the_parent, $term->taxonomy); |
| 2721 | - if ( is_wp_error($parent_term) || empty($parent_term) ) |
|
| 2721 | + if (is_wp_error($parent_term) || empty($parent_term)) |
|
| 2722 | 2722 | break; |
| 2723 | - $parent_suffix .= '-' . $parent_term->slug; |
|
| 2724 | - if ( ! term_exists( $slug . $parent_suffix ) ) { |
|
| 2723 | + $parent_suffix .= '-'.$parent_term->slug; |
|
| 2724 | + if ( ! term_exists($slug.$parent_suffix)) { |
|
| 2725 | 2725 | break; |
| 2726 | 2726 | } |
| 2727 | 2727 | |
| 2728 | - if ( empty($parent_term->parent) ) |
|
| 2728 | + if (empty($parent_term->parent)) |
|
| 2729 | 2729 | break; |
| 2730 | 2730 | $the_parent = $parent_term->parent; |
| 2731 | 2731 | } |
@@ -2742,22 +2742,22 @@ discard block |
||
| 2742 | 2742 | * @param string $slug The slug. |
| 2743 | 2743 | * @param object $term Term object. |
| 2744 | 2744 | */ |
| 2745 | - if ( apply_filters( 'wp_unique_term_slug_is_bad_slug', $needs_suffix, $slug, $term ) ) { |
|
| 2746 | - if ( $parent_suffix ) { |
|
| 2745 | + if (apply_filters('wp_unique_term_slug_is_bad_slug', $needs_suffix, $slug, $term)) { |
|
| 2746 | + if ($parent_suffix) { |
|
| 2747 | 2747 | $slug .= $parent_suffix; |
| 2748 | 2748 | } else { |
| 2749 | - if ( ! empty( $term->term_id ) ) |
|
| 2750 | - $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id ); |
|
| 2749 | + if ( ! empty($term->term_id)) |
|
| 2750 | + $query = $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id); |
|
| 2751 | 2751 | else |
| 2752 | - $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug ); |
|
| 2752 | + $query = $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug); |
|
| 2753 | 2753 | |
| 2754 | - if ( $wpdb->get_var( $query ) ) { |
|
| 2754 | + if ($wpdb->get_var($query)) { |
|
| 2755 | 2755 | $num = 2; |
| 2756 | 2756 | do { |
| 2757 | - $alt_slug = $slug . "-$num"; |
|
| 2757 | + $alt_slug = $slug."-$num"; |
|
| 2758 | 2758 | $num++; |
| 2759 | - $slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) ); |
|
| 2760 | - } while ( $slug_check ); |
|
| 2759 | + $slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug)); |
|
| 2760 | + } while ($slug_check); |
|
| 2761 | 2761 | $slug = $alt_slug; |
| 2762 | 2762 | } |
| 2763 | 2763 | } |
@@ -2772,7 +2772,7 @@ discard block |
||
| 2772 | 2772 | * @param object $term Term object. |
| 2773 | 2773 | * @param string $original_slug Slug originally passed to the function for testing. |
| 2774 | 2774 | */ |
| 2775 | - return apply_filters( 'wp_unique_term_slug', $slug, $term, $original_slug ); |
|
| 2775 | + return apply_filters('wp_unique_term_slug', $slug, $term, $original_slug); |
|
| 2776 | 2776 | } |
| 2777 | 2777 | |
| 2778 | 2778 | /** |
@@ -2805,56 +2805,56 @@ discard block |
||
| 2805 | 2805 | * @param array|string $args Optional. Array of get_terms() arguments. Default empty array. |
| 2806 | 2806 | * @return array|WP_Error Returns Term ID and Taxonomy Term ID |
| 2807 | 2807 | */ |
| 2808 | -function wp_update_term( $term_id, $taxonomy, $args = array() ) { |
|
| 2808 | +function wp_update_term($term_id, $taxonomy, $args = array()) { |
|
| 2809 | 2809 | global $wpdb; |
| 2810 | 2810 | |
| 2811 | - if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 2812 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 2811 | + if ( ! taxonomy_exists($taxonomy)) { |
|
| 2812 | + return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 2813 | 2813 | } |
| 2814 | 2814 | |
| 2815 | 2815 | $term_id = (int) $term_id; |
| 2816 | 2816 | |
| 2817 | 2817 | // First, get all of the original args |
| 2818 | - $term = get_term( $term_id, $taxonomy ); |
|
| 2818 | + $term = get_term($term_id, $taxonomy); |
|
| 2819 | 2819 | |
| 2820 | - if ( is_wp_error( $term ) ) { |
|
| 2820 | + if (is_wp_error($term)) { |
|
| 2821 | 2821 | return $term; |
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | - if ( ! $term ) { |
|
| 2825 | - return new WP_Error( 'invalid_term', __( 'Empty Term' ) ); |
|
| 2824 | + if ( ! $term) { |
|
| 2825 | + return new WP_Error('invalid_term', __('Empty Term')); |
|
| 2826 | 2826 | } |
| 2827 | 2827 | |
| 2828 | 2828 | $term = (array) $term->data; |
| 2829 | 2829 | |
| 2830 | 2830 | // Escape data pulled from DB. |
| 2831 | - $term = wp_slash( $term ); |
|
| 2831 | + $term = wp_slash($term); |
|
| 2832 | 2832 | |
| 2833 | 2833 | // Merge old and new args with new args overwriting old ones. |
| 2834 | 2834 | $args = array_merge($term, $args); |
| 2835 | 2835 | |
| 2836 | - $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 2836 | + $defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 2837 | 2837 | $args = wp_parse_args($args, $defaults); |
| 2838 | 2838 | $args = sanitize_term($args, $taxonomy, 'db'); |
| 2839 | 2839 | $parsed_args = $args; |
| 2840 | 2840 | |
| 2841 | 2841 | // expected_slashed ($name) |
| 2842 | - $name = wp_unslash( $args['name'] ); |
|
| 2843 | - $description = wp_unslash( $args['description'] ); |
|
| 2842 | + $name = wp_unslash($args['name']); |
|
| 2843 | + $description = wp_unslash($args['description']); |
|
| 2844 | 2844 | |
| 2845 | 2845 | $parsed_args['name'] = $name; |
| 2846 | 2846 | $parsed_args['description'] = $description; |
| 2847 | 2847 | |
| 2848 | - if ( '' == trim( $name ) ) { |
|
| 2849 | - return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) ); |
|
| 2848 | + if ('' == trim($name)) { |
|
| 2849 | + return new WP_Error('empty_term_name', __('A name is required for this term.')); |
|
| 2850 | 2850 | } |
| 2851 | 2851 | |
| 2852 | - if ( $parsed_args['parent'] > 0 && ! term_exists( (int) $parsed_args['parent'] ) ) { |
|
| 2853 | - return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) ); |
|
| 2852 | + if ($parsed_args['parent'] > 0 && ! term_exists((int) $parsed_args['parent'])) { |
|
| 2853 | + return new WP_Error('missing_parent', __('Parent term does not exist.')); |
|
| 2854 | 2854 | } |
| 2855 | 2855 | |
| 2856 | 2856 | $empty_slug = false; |
| 2857 | - if ( empty( $args['slug'] ) ) { |
|
| 2857 | + if (empty($args['slug'])) { |
|
| 2858 | 2858 | $empty_slug = true; |
| 2859 | 2859 | $slug = sanitize_title($name); |
| 2860 | 2860 | } else { |
@@ -2863,22 +2863,22 @@ discard block |
||
| 2863 | 2863 | |
| 2864 | 2864 | $parsed_args['slug'] = $slug; |
| 2865 | 2865 | |
| 2866 | - $term_group = isset( $parsed_args['term_group'] ) ? $parsed_args['term_group'] : 0; |
|
| 2867 | - if ( $args['alias_of'] ) { |
|
| 2868 | - $alias = get_term_by( 'slug', $args['alias_of'], $taxonomy ); |
|
| 2869 | - if ( ! empty( $alias->term_group ) ) { |
|
| 2866 | + $term_group = isset($parsed_args['term_group']) ? $parsed_args['term_group'] : 0; |
|
| 2867 | + if ($args['alias_of']) { |
|
| 2868 | + $alias = get_term_by('slug', $args['alias_of'], $taxonomy); |
|
| 2869 | + if ( ! empty($alias->term_group)) { |
|
| 2870 | 2870 | // The alias we want is already in a group, so let's use that one. |
| 2871 | 2871 | $term_group = $alias->term_group; |
| 2872 | - } elseif ( ! empty( $alias->term_id ) ) { |
|
| 2872 | + } elseif ( ! empty($alias->term_id)) { |
|
| 2873 | 2873 | /* |
| 2874 | 2874 | * The alias is not in a group, so we create a new one |
| 2875 | 2875 | * and add the alias to it. |
| 2876 | 2876 | */ |
| 2877 | 2877 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
| 2878 | 2878 | |
| 2879 | - wp_update_term( $alias->term_id, $taxonomy, array( |
|
| 2879 | + wp_update_term($alias->term_id, $taxonomy, array( |
|
| 2880 | 2880 | 'term_group' => $term_group, |
| 2881 | - ) ); |
|
| 2881 | + )); |
|
| 2882 | 2882 | } |
| 2883 | 2883 | |
| 2884 | 2884 | $parsed_args['term_group'] = $term_group; |
@@ -2897,24 +2897,24 @@ discard block |
||
| 2897 | 2897 | * @param array $parsed_args An array of potentially altered update arguments for the given term. |
| 2898 | 2898 | * @param array $args An array of update arguments for the given term. |
| 2899 | 2899 | */ |
| 2900 | - $parent = apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args ); |
|
| 2900 | + $parent = apply_filters('wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args); |
|
| 2901 | 2901 | |
| 2902 | 2902 | // Check for duplicate slug |
| 2903 | - $duplicate = get_term_by( 'slug', $slug, $taxonomy ); |
|
| 2904 | - if ( $duplicate && $duplicate->term_id != $term_id ) { |
|
| 2903 | + $duplicate = get_term_by('slug', $slug, $taxonomy); |
|
| 2904 | + if ($duplicate && $duplicate->term_id != $term_id) { |
|
| 2905 | 2905 | // If an empty slug was passed or the parent changed, reset the slug to something unique. |
| 2906 | 2906 | // Otherwise, bail. |
| 2907 | - if ( $empty_slug || ( $parent != $term['parent']) ) |
|
| 2907 | + if ($empty_slug || ($parent != $term['parent'])) |
|
| 2908 | 2908 | $slug = wp_unique_term_slug($slug, (object) $args); |
| 2909 | 2909 | else |
| 2910 | 2910 | return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug)); |
| 2911 | 2911 | } |
| 2912 | 2912 | |
| 2913 | - $tt_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) ); |
|
| 2913 | + $tt_id = (int) $wpdb->get_var($wpdb->prepare("SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id)); |
|
| 2914 | 2914 | |
| 2915 | 2915 | // Check whether this is a shared term that needs splitting. |
| 2916 | - $_term_id = _split_shared_term( $term_id, $tt_id ); |
|
| 2917 | - if ( ! is_wp_error( $_term_id ) ) { |
|
| 2916 | + $_term_id = _split_shared_term($term_id, $tt_id); |
|
| 2917 | + if ( ! is_wp_error($_term_id)) { |
|
| 2918 | 2918 | $term_id = $_term_id; |
| 2919 | 2919 | } |
| 2920 | 2920 | |
@@ -2926,11 +2926,11 @@ discard block |
||
| 2926 | 2926 | * @param int $term_id Term ID. |
| 2927 | 2927 | * @param string $taxonomy Taxonomy slug. |
| 2928 | 2928 | */ |
| 2929 | - do_action( 'edit_terms', $term_id, $taxonomy ); |
|
| 2930 | - $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) ); |
|
| 2931 | - if ( empty($slug) ) { |
|
| 2929 | + do_action('edit_terms', $term_id, $taxonomy); |
|
| 2930 | + $wpdb->update($wpdb->terms, compact('name', 'slug', 'term_group'), compact('term_id')); |
|
| 2931 | + if (empty($slug)) { |
|
| 2932 | 2932 | $slug = sanitize_title($name, $term_id); |
| 2933 | - $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
|
| 2933 | + $wpdb->update($wpdb->terms, compact('slug'), compact('term_id')); |
|
| 2934 | 2934 | } |
| 2935 | 2935 | |
| 2936 | 2936 | /** |
@@ -2941,7 +2941,7 @@ discard block |
||
| 2941 | 2941 | * @param int $term_id Term ID |
| 2942 | 2942 | * @param string $taxonomy Taxonomy slug. |
| 2943 | 2943 | */ |
| 2944 | - do_action( 'edited_terms', $term_id, $taxonomy ); |
|
| 2944 | + do_action('edited_terms', $term_id, $taxonomy); |
|
| 2945 | 2945 | |
| 2946 | 2946 | /** |
| 2947 | 2947 | * Fires immediate before a term-taxonomy relationship is updated. |
@@ -2951,9 +2951,9 @@ discard block |
||
| 2951 | 2951 | * @param int $tt_id Term taxonomy ID. |
| 2952 | 2952 | * @param string $taxonomy Taxonomy slug. |
| 2953 | 2953 | */ |
| 2954 | - do_action( 'edit_term_taxonomy', $tt_id, $taxonomy ); |
|
| 2954 | + do_action('edit_term_taxonomy', $tt_id, $taxonomy); |
|
| 2955 | 2955 | |
| 2956 | - $wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) ); |
|
| 2956 | + $wpdb->update($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent'), array('term_taxonomy_id' => $tt_id)); |
|
| 2957 | 2957 | |
| 2958 | 2958 | /** |
| 2959 | 2959 | * Fires immediately after a term-taxonomy relationship is updated. |
@@ -2963,7 +2963,7 @@ discard block |
||
| 2963 | 2963 | * @param int $tt_id Term taxonomy ID. |
| 2964 | 2964 | * @param string $taxonomy Taxonomy slug. |
| 2965 | 2965 | */ |
| 2966 | - do_action( 'edited_term_taxonomy', $tt_id, $taxonomy ); |
|
| 2966 | + do_action('edited_term_taxonomy', $tt_id, $taxonomy); |
|
| 2967 | 2967 | |
| 2968 | 2968 | /** |
| 2969 | 2969 | * Fires after a term has been updated, but before the term cache has been cleaned. |
@@ -2974,7 +2974,7 @@ discard block |
||
| 2974 | 2974 | * @param int $tt_id Term taxonomy ID. |
| 2975 | 2975 | * @param string $taxonomy Taxonomy slug. |
| 2976 | 2976 | */ |
| 2977 | - do_action( "edit_term", $term_id, $tt_id, $taxonomy ); |
|
| 2977 | + do_action("edit_term", $term_id, $tt_id, $taxonomy); |
|
| 2978 | 2978 | |
| 2979 | 2979 | /** |
| 2980 | 2980 | * Fires after a term in a specific taxonomy has been updated, but before the term |
@@ -2987,10 +2987,10 @@ discard block |
||
| 2987 | 2987 | * @param int $term_id Term ID. |
| 2988 | 2988 | * @param int $tt_id Term taxonomy ID. |
| 2989 | 2989 | */ |
| 2990 | - do_action( "edit_$taxonomy", $term_id, $tt_id ); |
|
| 2990 | + do_action("edit_$taxonomy", $term_id, $tt_id); |
|
| 2991 | 2991 | |
| 2992 | 2992 | /** This filter is documented in wp-includes/taxonomy.php */ |
| 2993 | - $term_id = apply_filters( 'term_id_filter', $term_id, $tt_id ); |
|
| 2993 | + $term_id = apply_filters('term_id_filter', $term_id, $tt_id); |
|
| 2994 | 2994 | |
| 2995 | 2995 | clean_term_cache($term_id, $taxonomy); |
| 2996 | 2996 | |
@@ -3003,7 +3003,7 @@ discard block |
||
| 3003 | 3003 | * @param int $tt_id Term taxonomy ID. |
| 3004 | 3004 | * @param string $taxonomy Taxonomy slug. |
| 3005 | 3005 | */ |
| 3006 | - do_action( "edited_term", $term_id, $tt_id, $taxonomy ); |
|
| 3006 | + do_action("edited_term", $term_id, $tt_id, $taxonomy); |
|
| 3007 | 3007 | |
| 3008 | 3008 | /** |
| 3009 | 3009 | * Fires after a term for a specific taxonomy has been updated, and the term |
@@ -3016,7 +3016,7 @@ discard block |
||
| 3016 | 3016 | * @param int $term_id Term ID. |
| 3017 | 3017 | * @param int $tt_id Term taxonomy ID. |
| 3018 | 3018 | */ |
| 3019 | - do_action( "edited_$taxonomy", $term_id, $tt_id ); |
|
| 3019 | + do_action("edited_$taxonomy", $term_id, $tt_id); |
|
| 3020 | 3020 | |
| 3021 | 3021 | return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
| 3022 | 3022 | } |
@@ -3031,14 +3031,14 @@ discard block |
||
| 3031 | 3031 | * @param bool $defer Optional. Enable if true, disable if false. |
| 3032 | 3032 | * @return bool Whether term counting is enabled or disabled. |
| 3033 | 3033 | */ |
| 3034 | -function wp_defer_term_counting($defer=null) { |
|
| 3034 | +function wp_defer_term_counting($defer = null) { |
|
| 3035 | 3035 | static $_defer = false; |
| 3036 | 3036 | |
| 3037 | - if ( is_bool($defer) ) { |
|
| 3037 | + if (is_bool($defer)) { |
|
| 3038 | 3038 | $_defer = $defer; |
| 3039 | 3039 | // flush any deferred counts |
| 3040 | - if ( !$defer ) |
|
| 3041 | - wp_update_term_count( null, null, true ); |
|
| 3040 | + if ( ! $defer) |
|
| 3041 | + wp_update_term_count(null, null, true); |
|
| 3042 | 3042 | } |
| 3043 | 3043 | |
| 3044 | 3044 | return $_defer; |
@@ -3062,30 +3062,30 @@ discard block |
||
| 3062 | 3062 | * @param bool $do_deferred Whether to flush the deferred term counts too. Default false. |
| 3063 | 3063 | * @return bool If no terms will return false, and if successful will return true. |
| 3064 | 3064 | */ |
| 3065 | -function wp_update_term_count( $terms, $taxonomy, $do_deferred = false ) { |
|
| 3065 | +function wp_update_term_count($terms, $taxonomy, $do_deferred = false) { |
|
| 3066 | 3066 | static $_deferred = array(); |
| 3067 | 3067 | |
| 3068 | - if ( $do_deferred ) { |
|
| 3069 | - foreach ( (array) array_keys($_deferred) as $tax ) { |
|
| 3070 | - wp_update_term_count_now( $_deferred[$tax], $tax ); |
|
| 3071 | - unset( $_deferred[$tax] ); |
|
| 3068 | + if ($do_deferred) { |
|
| 3069 | + foreach ((array) array_keys($_deferred) as $tax) { |
|
| 3070 | + wp_update_term_count_now($_deferred[$tax], $tax); |
|
| 3071 | + unset($_deferred[$tax]); |
|
| 3072 | 3072 | } |
| 3073 | 3073 | } |
| 3074 | 3074 | |
| 3075 | - if ( empty($terms) ) |
|
| 3075 | + if (empty($terms)) |
|
| 3076 | 3076 | return false; |
| 3077 | 3077 | |
| 3078 | - if ( !is_array($terms) ) |
|
| 3078 | + if ( ! is_array($terms)) |
|
| 3079 | 3079 | $terms = array($terms); |
| 3080 | 3080 | |
| 3081 | - if ( wp_defer_term_counting() ) { |
|
| 3082 | - if ( !isset($_deferred[$taxonomy]) ) |
|
| 3081 | + if (wp_defer_term_counting()) { |
|
| 3082 | + if ( ! isset($_deferred[$taxonomy])) |
|
| 3083 | 3083 | $_deferred[$taxonomy] = array(); |
| 3084 | - $_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) ); |
|
| 3084 | + $_deferred[$taxonomy] = array_unique(array_merge($_deferred[$taxonomy], $terms)); |
|
| 3085 | 3085 | return true; |
| 3086 | 3086 | } |
| 3087 | 3087 | |
| 3088 | - return wp_update_term_count_now( $terms, $taxonomy ); |
|
| 3088 | + return wp_update_term_count_now($terms, $taxonomy); |
|
| 3089 | 3089 | } |
| 3090 | 3090 | |
| 3091 | 3091 | /** |
@@ -3097,25 +3097,25 @@ discard block |
||
| 3097 | 3097 | * @param string $taxonomy The context of the term. |
| 3098 | 3098 | * @return true Always true when complete. |
| 3099 | 3099 | */ |
| 3100 | -function wp_update_term_count_now( $terms, $taxonomy ) { |
|
| 3100 | +function wp_update_term_count_now($terms, $taxonomy) { |
|
| 3101 | 3101 | $terms = array_map('intval', $terms); |
| 3102 | 3102 | |
| 3103 | 3103 | $taxonomy = get_taxonomy($taxonomy); |
| 3104 | - if ( !empty($taxonomy->update_count_callback) ) { |
|
| 3104 | + if ( ! empty($taxonomy->update_count_callback)) { |
|
| 3105 | 3105 | call_user_func($taxonomy->update_count_callback, $terms, $taxonomy); |
| 3106 | 3106 | } else { |
| 3107 | 3107 | $object_types = (array) $taxonomy->object_type; |
| 3108 | - foreach ( $object_types as &$object_type ) { |
|
| 3109 | - if ( 0 === strpos( $object_type, 'attachment:' ) ) |
|
| 3110 | - list( $object_type ) = explode( ':', $object_type ); |
|
| 3108 | + foreach ($object_types as &$object_type) { |
|
| 3109 | + if (0 === strpos($object_type, 'attachment:')) |
|
| 3110 | + list($object_type) = explode(':', $object_type); |
|
| 3111 | 3111 | } |
| 3112 | 3112 | |
| 3113 | - if ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) { |
|
| 3113 | + if ($object_types == array_filter($object_types, 'post_type_exists')) { |
|
| 3114 | 3114 | // Only post types are attached to this taxonomy |
| 3115 | - _update_post_term_count( $terms, $taxonomy ); |
|
| 3115 | + _update_post_term_count($terms, $taxonomy); |
|
| 3116 | 3116 | } else { |
| 3117 | 3117 | // Default count updater |
| 3118 | - _update_generic_term_count( $terms, $taxonomy ); |
|
| 3118 | + _update_generic_term_count($terms, $taxonomy); |
|
| 3119 | 3119 | } |
| 3120 | 3120 | } |
| 3121 | 3121 | |
@@ -3147,17 +3147,17 @@ discard block |
||
| 3147 | 3147 | function clean_object_term_cache($object_ids, $object_type) { |
| 3148 | 3148 | global $_wp_suspend_cache_invalidation; |
| 3149 | 3149 | |
| 3150 | - if ( ! empty( $_wp_suspend_cache_invalidation ) ) { |
|
| 3150 | + if ( ! empty($_wp_suspend_cache_invalidation)) { |
|
| 3151 | 3151 | return; |
| 3152 | 3152 | } |
| 3153 | 3153 | |
| 3154 | - if ( !is_array($object_ids) ) |
|
| 3154 | + if ( ! is_array($object_ids)) |
|
| 3155 | 3155 | $object_ids = array($object_ids); |
| 3156 | 3156 | |
| 3157 | - $taxonomies = get_object_taxonomies( $object_type ); |
|
| 3157 | + $taxonomies = get_object_taxonomies($object_type); |
|
| 3158 | 3158 | |
| 3159 | - foreach ( $object_ids as $id ) { |
|
| 3160 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 3159 | + foreach ($object_ids as $id) { |
|
| 3160 | + foreach ($taxonomies as $taxonomy) { |
|
| 3161 | 3161 | wp_cache_delete($id, "{$taxonomy}_relationships"); |
| 3162 | 3162 | } |
| 3163 | 3163 | } |
@@ -3170,7 +3170,7 @@ discard block |
||
| 3170 | 3170 | * @param array $object_ids An array of object IDs. |
| 3171 | 3171 | * @param string $objet_type Object type. |
| 3172 | 3172 | */ |
| 3173 | - do_action( 'clean_object_term_cache', $object_ids, $object_type ); |
|
| 3173 | + do_action('clean_object_term_cache', $object_ids, $object_type); |
|
| 3174 | 3174 | } |
| 3175 | 3175 | |
| 3176 | 3176 | /** |
@@ -3190,37 +3190,37 @@ discard block |
||
| 3190 | 3190 | function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { |
| 3191 | 3191 | global $wpdb, $_wp_suspend_cache_invalidation; |
| 3192 | 3192 | |
| 3193 | - if ( ! empty( $_wp_suspend_cache_invalidation ) ) { |
|
| 3193 | + if ( ! empty($_wp_suspend_cache_invalidation)) { |
|
| 3194 | 3194 | return; |
| 3195 | 3195 | } |
| 3196 | 3196 | |
| 3197 | - if ( !is_array($ids) ) |
|
| 3197 | + if ( ! is_array($ids)) |
|
| 3198 | 3198 | $ids = array($ids); |
| 3199 | 3199 | |
| 3200 | 3200 | $taxonomies = array(); |
| 3201 | 3201 | // If no taxonomy, assume tt_ids. |
| 3202 | - if ( empty($taxonomy) ) { |
|
| 3202 | + if (empty($taxonomy)) { |
|
| 3203 | 3203 | $tt_ids = array_map('intval', $ids); |
| 3204 | 3204 | $tt_ids = implode(', ', $tt_ids); |
| 3205 | 3205 | $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)"); |
| 3206 | 3206 | $ids = array(); |
| 3207 | - foreach ( (array) $terms as $term ) { |
|
| 3207 | + foreach ((array) $terms as $term) { |
|
| 3208 | 3208 | $taxonomies[] = $term->taxonomy; |
| 3209 | 3209 | $ids[] = $term->term_id; |
| 3210 | - wp_cache_delete( $term->term_id, 'terms' ); |
|
| 3210 | + wp_cache_delete($term->term_id, 'terms'); |
|
| 3211 | 3211 | } |
| 3212 | 3212 | $taxonomies = array_unique($taxonomies); |
| 3213 | 3213 | } else { |
| 3214 | 3214 | $taxonomies = array($taxonomy); |
| 3215 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 3216 | - foreach ( $ids as $id ) { |
|
| 3217 | - wp_cache_delete( $id, 'terms' ); |
|
| 3215 | + foreach ($taxonomies as $taxonomy) { |
|
| 3216 | + foreach ($ids as $id) { |
|
| 3217 | + wp_cache_delete($id, 'terms'); |
|
| 3218 | 3218 | } |
| 3219 | 3219 | } |
| 3220 | 3220 | } |
| 3221 | 3221 | |
| 3222 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 3223 | - if ( $clean_taxonomy ) { |
|
| 3222 | + foreach ($taxonomies as $taxonomy) { |
|
| 3223 | + if ($clean_taxonomy) { |
|
| 3224 | 3224 | wp_cache_delete('all_ids', $taxonomy); |
| 3225 | 3225 | wp_cache_delete('get', $taxonomy); |
| 3226 | 3226 | delete_option("{$taxonomy}_children"); |
@@ -3238,10 +3238,10 @@ discard block |
||
| 3238 | 3238 | * @param string $taxonomy Taxonomy slug. |
| 3239 | 3239 | * @param bool $clean_taxonomy Whether or not to clean taxonomy-wide caches |
| 3240 | 3240 | */ |
| 3241 | - do_action( 'clean_term_cache', $ids, $taxonomy, $clean_taxonomy ); |
|
| 3241 | + do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy); |
|
| 3242 | 3242 | } |
| 3243 | 3243 | |
| 3244 | - wp_cache_set( 'last_changed', microtime(), 'terms' ); |
|
| 3244 | + wp_cache_set('last_changed', microtime(), 'terms'); |
|
| 3245 | 3245 | } |
| 3246 | 3246 | |
| 3247 | 3247 | /** |
@@ -3257,33 +3257,33 @@ discard block |
||
| 3257 | 3257 | * @param string $taxonomy Taxonomy name. |
| 3258 | 3258 | * @return bool|array Array of `WP_Term` objects, if cached False if cache is empty for `$taxonomy` and `$id`. |
| 3259 | 3259 | */ |
| 3260 | -function get_object_term_cache( $id, $taxonomy ) { |
|
| 3261 | - $_term_ids = wp_cache_get( $id, "{$taxonomy}_relationships" ); |
|
| 3260 | +function get_object_term_cache($id, $taxonomy) { |
|
| 3261 | + $_term_ids = wp_cache_get($id, "{$taxonomy}_relationships"); |
|
| 3262 | 3262 | |
| 3263 | 3263 | // We leave the priming of relationship caches to upstream functions. |
| 3264 | - if ( false === $_term_ids ) { |
|
| 3264 | + if (false === $_term_ids) { |
|
| 3265 | 3265 | return false; |
| 3266 | 3266 | } |
| 3267 | 3267 | |
| 3268 | 3268 | // Backward compatibility for if a plugin is putting objects into the cache, rather than IDs. |
| 3269 | 3269 | $term_ids = array(); |
| 3270 | - foreach ( $_term_ids as $term_id ) { |
|
| 3271 | - if ( is_numeric( $term_id ) ) { |
|
| 3272 | - $term_ids[] = intval( $term_id ); |
|
| 3273 | - } elseif ( isset( $term_id->term_id ) ) { |
|
| 3274 | - $term_ids[] = intval( $term_id->term_id ); |
|
| 3270 | + foreach ($_term_ids as $term_id) { |
|
| 3271 | + if (is_numeric($term_id)) { |
|
| 3272 | + $term_ids[] = intval($term_id); |
|
| 3273 | + } elseif (isset($term_id->term_id)) { |
|
| 3274 | + $term_ids[] = intval($term_id->term_id); |
|
| 3275 | 3275 | } |
| 3276 | 3276 | } |
| 3277 | 3277 | |
| 3278 | 3278 | // Fill the term objects. |
| 3279 | - _prime_term_caches( $term_ids ); |
|
| 3279 | + _prime_term_caches($term_ids); |
|
| 3280 | 3280 | |
| 3281 | 3281 | $terms = array(); |
| 3282 | - foreach ( $term_ids as $term_id ) { |
|
| 3283 | - $terms[] = wp_cache_get( $term_id, 'terms' ); |
|
| 3282 | + foreach ($term_ids as $term_id) { |
|
| 3283 | + $terms[] = wp_cache_get($term_id, 'terms'); |
|
| 3284 | 3284 | } |
| 3285 | 3285 | |
| 3286 | - return array_map( 'get_term', $terms ); |
|
| 3286 | + return array_map('get_term', $terms); |
|
| 3287 | 3287 | } |
| 3288 | 3288 | |
| 3289 | 3289 | /** |
@@ -3303,10 +3303,10 @@ discard block |
||
| 3303 | 3303 | * @return void|false False if all of the terms in `$object_ids` are already cached. |
| 3304 | 3304 | */ |
| 3305 | 3305 | function update_object_term_cache($object_ids, $object_type) { |
| 3306 | - if ( empty($object_ids) ) |
|
| 3306 | + if (empty($object_ids)) |
|
| 3307 | 3307 | return; |
| 3308 | 3308 | |
| 3309 | - if ( !is_array($object_ids) ) |
|
| 3309 | + if ( ! is_array($object_ids)) |
|
| 3310 | 3310 | $object_ids = explode(',', $object_ids); |
| 3311 | 3311 | |
| 3312 | 3312 | $object_ids = array_map('intval', $object_ids); |
@@ -3314,42 +3314,42 @@ discard block |
||
| 3314 | 3314 | $taxonomies = get_object_taxonomies($object_type); |
| 3315 | 3315 | |
| 3316 | 3316 | $ids = array(); |
| 3317 | - foreach ( (array) $object_ids as $id ) { |
|
| 3318 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 3319 | - if ( false === wp_cache_get($id, "{$taxonomy}_relationships") ) { |
|
| 3317 | + foreach ((array) $object_ids as $id) { |
|
| 3318 | + foreach ($taxonomies as $taxonomy) { |
|
| 3319 | + if (false === wp_cache_get($id, "{$taxonomy}_relationships")) { |
|
| 3320 | 3320 | $ids[] = $id; |
| 3321 | 3321 | break; |
| 3322 | 3322 | } |
| 3323 | 3323 | } |
| 3324 | 3324 | } |
| 3325 | 3325 | |
| 3326 | - if ( empty( $ids ) ) |
|
| 3326 | + if (empty($ids)) |
|
| 3327 | 3327 | return false; |
| 3328 | 3328 | |
| 3329 | - $terms = wp_get_object_terms( $ids, $taxonomies, array( |
|
| 3329 | + $terms = wp_get_object_terms($ids, $taxonomies, array( |
|
| 3330 | 3330 | 'fields' => 'all_with_object_id', |
| 3331 | 3331 | 'orderby' => 'name', |
| 3332 | 3332 | 'update_term_meta_cache' => false, |
| 3333 | - ) ); |
|
| 3333 | + )); |
|
| 3334 | 3334 | |
| 3335 | 3335 | $object_terms = array(); |
| 3336 | - foreach ( (array) $terms as $term ) { |
|
| 3337 | - $object_terms[ $term->object_id ][ $term->taxonomy ][] = $term->term_id; |
|
| 3336 | + foreach ((array) $terms as $term) { |
|
| 3337 | + $object_terms[$term->object_id][$term->taxonomy][] = $term->term_id; |
|
| 3338 | 3338 | } |
| 3339 | 3339 | |
| 3340 | - foreach ( $ids as $id ) { |
|
| 3341 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 3342 | - if ( ! isset($object_terms[$id][$taxonomy]) ) { |
|
| 3343 | - if ( !isset($object_terms[$id]) ) |
|
| 3340 | + foreach ($ids as $id) { |
|
| 3341 | + foreach ($taxonomies as $taxonomy) { |
|
| 3342 | + if ( ! isset($object_terms[$id][$taxonomy])) { |
|
| 3343 | + if ( ! isset($object_terms[$id])) |
|
| 3344 | 3344 | $object_terms[$id] = array(); |
| 3345 | 3345 | $object_terms[$id][$taxonomy] = array(); |
| 3346 | 3346 | } |
| 3347 | 3347 | } |
| 3348 | 3348 | } |
| 3349 | 3349 | |
| 3350 | - foreach ( $object_terms as $id => $value ) { |
|
| 3351 | - foreach ( $value as $taxonomy => $terms ) { |
|
| 3352 | - wp_cache_add( $id, $terms, "{$taxonomy}_relationships" ); |
|
| 3350 | + foreach ($object_terms as $id => $value) { |
|
| 3351 | + foreach ($value as $taxonomy => $terms) { |
|
| 3352 | + wp_cache_add($id, $terms, "{$taxonomy}_relationships"); |
|
| 3353 | 3353 | } |
| 3354 | 3354 | } |
| 3355 | 3355 | } |
@@ -3362,15 +3362,15 @@ discard block |
||
| 3362 | 3362 | * @param array $terms List of term objects to change. |
| 3363 | 3363 | * @param string $taxonomy Optional. Update Term to this taxonomy in cache. Default empty. |
| 3364 | 3364 | */ |
| 3365 | -function update_term_cache( $terms, $taxonomy = '' ) { |
|
| 3366 | - foreach ( (array) $terms as $term ) { |
|
| 3365 | +function update_term_cache($terms, $taxonomy = '') { |
|
| 3366 | + foreach ((array) $terms as $term) { |
|
| 3367 | 3367 | // Create a copy in case the array was passed by reference. |
| 3368 | 3368 | $_term = clone $term; |
| 3369 | 3369 | |
| 3370 | 3370 | // Object ID should not be cached. |
| 3371 | - unset( $_term->object_id ); |
|
| 3371 | + unset($_term->object_id); |
|
| 3372 | 3372 | |
| 3373 | - wp_cache_add( $term->term_id, $_term, 'terms' ); |
|
| 3373 | + wp_cache_add($term->term_id, $_term, 'terms'); |
|
| 3374 | 3374 | } |
| 3375 | 3375 | } |
| 3376 | 3376 | |
@@ -3387,17 +3387,17 @@ discard block |
||
| 3387 | 3387 | * @param string $taxonomy Taxonomy name. |
| 3388 | 3388 | * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs. |
| 3389 | 3389 | */ |
| 3390 | -function _get_term_hierarchy( $taxonomy ) { |
|
| 3391 | - if ( !is_taxonomy_hierarchical($taxonomy) ) |
|
| 3390 | +function _get_term_hierarchy($taxonomy) { |
|
| 3391 | + if ( ! is_taxonomy_hierarchical($taxonomy)) |
|
| 3392 | 3392 | return array(); |
| 3393 | 3393 | $children = get_option("{$taxonomy}_children"); |
| 3394 | 3394 | |
| 3395 | - if ( is_array($children) ) |
|
| 3395 | + if (is_array($children)) |
|
| 3396 | 3396 | return $children; |
| 3397 | 3397 | $children = array(); |
| 3398 | 3398 | $terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent')); |
| 3399 | - foreach ( $terms as $term_id => $parent ) { |
|
| 3400 | - if ( $parent > 0 ) |
|
| 3399 | + foreach ($terms as $term_id => $parent) { |
|
| 3400 | + if ($parent > 0) |
|
| 3401 | 3401 | $children[$parent][] = $term_id; |
| 3402 | 3402 | } |
| 3403 | 3403 | update_option("{$taxonomy}_children", $children); |
@@ -3424,48 +3424,48 @@ discard block |
||
| 3424 | 3424 | * with 1 as value. Default empty array. |
| 3425 | 3425 | * @return array|WP_Error The subset of $terms that are descendants of $term_id. |
| 3426 | 3426 | */ |
| 3427 | -function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) { |
|
| 3427 | +function _get_term_children($term_id, $terms, $taxonomy, &$ancestors = array()) { |
|
| 3428 | 3428 | $empty_array = array(); |
| 3429 | - if ( empty($terms) ) |
|
| 3429 | + if (empty($terms)) |
|
| 3430 | 3430 | return $empty_array; |
| 3431 | 3431 | |
| 3432 | 3432 | $term_list = array(); |
| 3433 | 3433 | $has_children = _get_term_hierarchy($taxonomy); |
| 3434 | 3434 | |
| 3435 | - if ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) |
|
| 3435 | + if ((0 != $term_id) && ! isset($has_children[$term_id])) |
|
| 3436 | 3436 | return $empty_array; |
| 3437 | 3437 | |
| 3438 | 3438 | // Include the term itself in the ancestors array, so we can properly detect when a loop has occurred. |
| 3439 | - if ( empty( $ancestors ) ) { |
|
| 3440 | - $ancestors[ $term_id ] = 1; |
|
| 3439 | + if (empty($ancestors)) { |
|
| 3440 | + $ancestors[$term_id] = 1; |
|
| 3441 | 3441 | } |
| 3442 | 3442 | |
| 3443 | - foreach ( (array) $terms as $term ) { |
|
| 3443 | + foreach ((array) $terms as $term) { |
|
| 3444 | 3444 | $use_id = false; |
| 3445 | - if ( !is_object($term) ) { |
|
| 3445 | + if ( ! is_object($term)) { |
|
| 3446 | 3446 | $term = get_term($term, $taxonomy); |
| 3447 | - if ( is_wp_error( $term ) ) |
|
| 3447 | + if (is_wp_error($term)) |
|
| 3448 | 3448 | return $term; |
| 3449 | 3449 | $use_id = true; |
| 3450 | 3450 | } |
| 3451 | 3451 | |
| 3452 | 3452 | // Don't recurse if we've already identified the term as a child - this indicates a loop. |
| 3453 | - if ( isset( $ancestors[ $term->term_id ] ) ) { |
|
| 3453 | + if (isset($ancestors[$term->term_id])) { |
|
| 3454 | 3454 | continue; |
| 3455 | 3455 | } |
| 3456 | 3456 | |
| 3457 | - if ( $term->parent == $term_id ) { |
|
| 3458 | - if ( $use_id ) |
|
| 3457 | + if ($term->parent == $term_id) { |
|
| 3458 | + if ($use_id) |
|
| 3459 | 3459 | $term_list[] = $term->term_id; |
| 3460 | 3460 | else |
| 3461 | 3461 | $term_list[] = $term; |
| 3462 | 3462 | |
| 3463 | - if ( !isset($has_children[$term->term_id]) ) |
|
| 3463 | + if ( ! isset($has_children[$term->term_id])) |
|
| 3464 | 3464 | continue; |
| 3465 | 3465 | |
| 3466 | - $ancestors[ $term->term_id ] = 1; |
|
| 3466 | + $ancestors[$term->term_id] = 1; |
|
| 3467 | 3467 | |
| 3468 | - if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) ) |
|
| 3468 | + if ($children = _get_term_children($term->term_id, $terms, $taxonomy, $ancestors)) |
|
| 3469 | 3469 | $term_list = array_merge($term_list, $children); |
| 3470 | 3470 | } |
| 3471 | 3471 | } |
@@ -3487,23 +3487,23 @@ discard block |
||
| 3487 | 3487 | * @param array $terms List of term objects, passed by reference. |
| 3488 | 3488 | * @param string $taxonomy Term context. |
| 3489 | 3489 | */ |
| 3490 | -function _pad_term_counts( &$terms, $taxonomy ) { |
|
| 3490 | +function _pad_term_counts(&$terms, $taxonomy) { |
|
| 3491 | 3491 | global $wpdb; |
| 3492 | 3492 | |
| 3493 | 3493 | // This function only works for hierarchical taxonomies like post categories. |
| 3494 | - if ( !is_taxonomy_hierarchical( $taxonomy ) ) |
|
| 3494 | + if ( ! is_taxonomy_hierarchical($taxonomy)) |
|
| 3495 | 3495 | return; |
| 3496 | 3496 | |
| 3497 | 3497 | $term_hier = _get_term_hierarchy($taxonomy); |
| 3498 | 3498 | |
| 3499 | - if ( empty($term_hier) ) |
|
| 3499 | + if (empty($term_hier)) |
|
| 3500 | 3500 | return; |
| 3501 | 3501 | |
| 3502 | 3502 | $term_items = array(); |
| 3503 | 3503 | $terms_by_id = array(); |
| 3504 | 3504 | $term_ids = array(); |
| 3505 | 3505 | |
| 3506 | - foreach ( (array) $terms as $key => $term ) { |
|
| 3506 | + foreach ((array) $terms as $key => $term) { |
|
| 3507 | 3507 | $terms_by_id[$term->term_id] = & $terms[$key]; |
| 3508 | 3508 | $term_ids[$term->term_taxonomy_id] = $term->term_id; |
| 3509 | 3509 | } |
@@ -3511,33 +3511,33 @@ discard block |
||
| 3511 | 3511 | // Get the object and term ids and stick them in a lookup table. |
| 3512 | 3512 | $tax_obj = get_taxonomy($taxonomy); |
| 3513 | 3513 | $object_types = esc_sql($tax_obj->object_type); |
| 3514 | - $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'"); |
|
| 3515 | - foreach ( $results as $row ) { |
|
| 3514 | + $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".implode(',', array_keys($term_ids)).") AND post_type IN ('".implode("', '", $object_types)."') AND post_status = 'publish'"); |
|
| 3515 | + foreach ($results as $row) { |
|
| 3516 | 3516 | $id = $term_ids[$row->term_taxonomy_id]; |
| 3517 | 3517 | $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1; |
| 3518 | 3518 | } |
| 3519 | 3519 | |
| 3520 | 3520 | // Touch every ancestor's lookup row for each post in each term. |
| 3521 | - foreach ( $term_ids as $term_id ) { |
|
| 3521 | + foreach ($term_ids as $term_id) { |
|
| 3522 | 3522 | $child = $term_id; |
| 3523 | 3523 | $ancestors = array(); |
| 3524 | - while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) { |
|
| 3524 | + while ( ! empty($terms_by_id[$child]) && $parent = $terms_by_id[$child]->parent) { |
|
| 3525 | 3525 | $ancestors[] = $child; |
| 3526 | - if ( !empty( $term_items[$term_id] ) ) |
|
| 3527 | - foreach ( $term_items[$term_id] as $item_id => $touches ) { |
|
| 3528 | - $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1; |
|
| 3526 | + if ( ! empty($term_items[$term_id])) |
|
| 3527 | + foreach ($term_items[$term_id] as $item_id => $touches) { |
|
| 3528 | + $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id] : 1; |
|
| 3529 | 3529 | } |
| 3530 | 3530 | $child = $parent; |
| 3531 | 3531 | |
| 3532 | - if ( in_array( $parent, $ancestors ) ) { |
|
| 3532 | + if (in_array($parent, $ancestors)) { |
|
| 3533 | 3533 | break; |
| 3534 | 3534 | } |
| 3535 | 3535 | } |
| 3536 | 3536 | } |
| 3537 | 3537 | |
| 3538 | 3538 | // Transfer the touched cells. |
| 3539 | - foreach ( (array) $term_items as $id => $items ) |
|
| 3540 | - if ( isset($terms_by_id[$id]) ) |
|
| 3539 | + foreach ((array) $term_items as $id => $items) |
|
| 3540 | + if (isset($terms_by_id[$id])) |
|
| 3541 | 3541 | $terms_by_id[$id]->count = count($items); |
| 3542 | 3542 | } |
| 3543 | 3543 | |
@@ -3552,17 +3552,17 @@ discard block |
||
| 3552 | 3552 | * @param array $term_ids Array of term IDs. |
| 3553 | 3553 | * @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true. |
| 3554 | 3554 | */ |
| 3555 | -function _prime_term_caches( $term_ids, $update_meta_cache = true ) { |
|
| 3555 | +function _prime_term_caches($term_ids, $update_meta_cache = true) { |
|
| 3556 | 3556 | global $wpdb; |
| 3557 | 3557 | |
| 3558 | - $non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' ); |
|
| 3559 | - if ( ! empty( $non_cached_ids ) ) { |
|
| 3560 | - $fresh_terms = $wpdb->get_results( sprintf( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) ); |
|
| 3558 | + $non_cached_ids = _get_non_cached_ids($term_ids, 'terms'); |
|
| 3559 | + if ( ! empty($non_cached_ids)) { |
|
| 3560 | + $fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", join(",", array_map('intval', $non_cached_ids)))); |
|
| 3561 | 3561 | |
| 3562 | - update_term_cache( $fresh_terms, $update_meta_cache ); |
|
| 3562 | + update_term_cache($fresh_terms, $update_meta_cache); |
|
| 3563 | 3563 | |
| 3564 | - if ( $update_meta_cache ) { |
|
| 3565 | - update_termmeta_cache( $non_cached_ids ); |
|
| 3564 | + if ($update_meta_cache) { |
|
| 3565 | + update_termmeta_cache($non_cached_ids); |
|
| 3566 | 3566 | } |
| 3567 | 3567 | } |
| 3568 | 3568 | } |
@@ -3585,40 +3585,40 @@ discard block |
||
| 3585 | 3585 | * @param array $terms List of Term taxonomy IDs. |
| 3586 | 3586 | * @param object $taxonomy Current taxonomy object of terms. |
| 3587 | 3587 | */ |
| 3588 | -function _update_post_term_count( $terms, $taxonomy ) { |
|
| 3588 | +function _update_post_term_count($terms, $taxonomy) { |
|
| 3589 | 3589 | global $wpdb; |
| 3590 | 3590 | |
| 3591 | 3591 | $object_types = (array) $taxonomy->object_type; |
| 3592 | 3592 | |
| 3593 | - foreach ( $object_types as &$object_type ) |
|
| 3594 | - list( $object_type ) = explode( ':', $object_type ); |
|
| 3593 | + foreach ($object_types as &$object_type) |
|
| 3594 | + list($object_type) = explode(':', $object_type); |
|
| 3595 | 3595 | |
| 3596 | - $object_types = array_unique( $object_types ); |
|
| 3596 | + $object_types = array_unique($object_types); |
|
| 3597 | 3597 | |
| 3598 | - if ( false !== ( $check_attachments = array_search( 'attachment', $object_types ) ) ) { |
|
| 3599 | - unset( $object_types[ $check_attachments ] ); |
|
| 3598 | + if (false !== ($check_attachments = array_search('attachment', $object_types))) { |
|
| 3599 | + unset($object_types[$check_attachments]); |
|
| 3600 | 3600 | $check_attachments = true; |
| 3601 | 3601 | } |
| 3602 | 3602 | |
| 3603 | - if ( $object_types ) |
|
| 3604 | - $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) ); |
|
| 3603 | + if ($object_types) |
|
| 3604 | + $object_types = esc_sql(array_filter($object_types, 'post_type_exists')); |
|
| 3605 | 3605 | |
| 3606 | - foreach ( (array) $terms as $term ) { |
|
| 3606 | + foreach ((array) $terms as $term) { |
|
| 3607 | 3607 | $count = 0; |
| 3608 | 3608 | |
| 3609 | 3609 | // Attachments can be 'inherit' status, we need to base count off the parent's status if so. |
| 3610 | - if ( $check_attachments ) |
|
| 3611 | - $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) ); |
|
| 3610 | + if ($check_attachments) |
|
| 3611 | + $count += (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term)); |
|
| 3612 | 3612 | |
| 3613 | - if ( $object_types ) |
|
| 3614 | - $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) ); |
|
| 3613 | + if ($object_types) |
|
| 3614 | + $count += (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('".implode("', '", $object_types)."') AND term_taxonomy_id = %d", $term)); |
|
| 3615 | 3615 | |
| 3616 | 3616 | /** This action is documented in wp-includes/taxonomy.php */ |
| 3617 | - do_action( 'edit_term_taxonomy', $term, $taxonomy->name ); |
|
| 3618 | - $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); |
|
| 3617 | + do_action('edit_term_taxonomy', $term, $taxonomy->name); |
|
| 3618 | + $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term)); |
|
| 3619 | 3619 | |
| 3620 | 3620 | /** This action is documented in wp-includes/taxonomy.php */ |
| 3621 | - do_action( 'edited_term_taxonomy', $term, $taxonomy->name ); |
|
| 3621 | + do_action('edited_term_taxonomy', $term, $taxonomy->name); |
|
| 3622 | 3622 | } |
| 3623 | 3623 | } |
| 3624 | 3624 | |
@@ -3634,18 +3634,18 @@ discard block |
||
| 3634 | 3634 | * @param array $terms List of term taxonomy IDs. |
| 3635 | 3635 | * @param object $taxonomy Current taxonomy object of terms. |
| 3636 | 3636 | */ |
| 3637 | -function _update_generic_term_count( $terms, $taxonomy ) { |
|
| 3637 | +function _update_generic_term_count($terms, $taxonomy) { |
|
| 3638 | 3638 | global $wpdb; |
| 3639 | 3639 | |
| 3640 | - foreach ( (array) $terms as $term ) { |
|
| 3641 | - $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) ); |
|
| 3640 | + foreach ((array) $terms as $term) { |
|
| 3641 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term)); |
|
| 3642 | 3642 | |
| 3643 | 3643 | /** This action is documented in wp-includes/taxonomy.php */ |
| 3644 | - do_action( 'edit_term_taxonomy', $term, $taxonomy->name ); |
|
| 3645 | - $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); |
|
| 3644 | + do_action('edit_term_taxonomy', $term, $taxonomy->name); |
|
| 3645 | + $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term)); |
|
| 3646 | 3646 | |
| 3647 | 3647 | /** This action is documented in wp-includes/taxonomy.php */ |
| 3648 | - do_action( 'edited_term_taxonomy', $term, $taxonomy->name ); |
|
| 3648 | + do_action('edited_term_taxonomy', $term, $taxonomy->name); |
|
| 3649 | 3649 | } |
| 3650 | 3650 | } |
| 3651 | 3651 | |
@@ -3672,23 +3672,23 @@ discard block |
||
| 3672 | 3672 | * database schema), `$term_id` is returned. When the term is successfully split, the |
| 3673 | 3673 | * new term_id is returned. A WP_Error is returned for miscellaneous errors. |
| 3674 | 3674 | */ |
| 3675 | -function _split_shared_term( $term_id, $term_taxonomy_id, $record = true ) { |
|
| 3675 | +function _split_shared_term($term_id, $term_taxonomy_id, $record = true) { |
|
| 3676 | 3676 | global $wpdb; |
| 3677 | 3677 | |
| 3678 | - if ( is_object( $term_id ) ) { |
|
| 3678 | + if (is_object($term_id)) { |
|
| 3679 | 3679 | $shared_term = $term_id; |
| 3680 | - $term_id = intval( $shared_term->term_id ); |
|
| 3680 | + $term_id = intval($shared_term->term_id); |
|
| 3681 | 3681 | } |
| 3682 | 3682 | |
| 3683 | - if ( is_object( $term_taxonomy_id ) ) { |
|
| 3683 | + if (is_object($term_taxonomy_id)) { |
|
| 3684 | 3684 | $term_taxonomy = $term_taxonomy_id; |
| 3685 | - $term_taxonomy_id = intval( $term_taxonomy->term_taxonomy_id ); |
|
| 3685 | + $term_taxonomy_id = intval($term_taxonomy->term_taxonomy_id); |
|
| 3686 | 3686 | } |
| 3687 | 3687 | |
| 3688 | 3688 | // If there are no shared term_taxonomy rows, there's nothing to do here. |
| 3689 | - $shared_tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy tt WHERE tt.term_id = %d AND tt.term_taxonomy_id != %d", $term_id, $term_taxonomy_id ) ); |
|
| 3689 | + $shared_tt_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy tt WHERE tt.term_id = %d AND tt.term_taxonomy_id != %d", $term_id, $term_taxonomy_id)); |
|
| 3690 | 3690 | |
| 3691 | - if ( ! $shared_tt_count ) { |
|
| 3691 | + if ( ! $shared_tt_count) { |
|
| 3692 | 3692 | return $term_id; |
| 3693 | 3693 | } |
| 3694 | 3694 | |
@@ -3696,14 +3696,14 @@ discard block |
||
| 3696 | 3696 | * Verify that the term_taxonomy_id passed to the function is actually associated with the term_id. |
| 3697 | 3697 | * If there's a mismatch, it may mean that the term is already split. Return the actual term_id from the db. |
| 3698 | 3698 | */ |
| 3699 | - $check_term_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) ); |
|
| 3700 | - if ( $check_term_id != $term_id ) { |
|
| 3699 | + $check_term_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id)); |
|
| 3700 | + if ($check_term_id != $term_id) { |
|
| 3701 | 3701 | return $check_term_id; |
| 3702 | 3702 | } |
| 3703 | 3703 | |
| 3704 | 3704 | // Pull up data about the currently shared slug, which we'll use to populate the new one. |
| 3705 | - if ( empty( $shared_term ) ) { |
|
| 3706 | - $shared_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id ) ); |
|
| 3705 | + if (empty($shared_term)) { |
|
| 3706 | + $shared_term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id)); |
|
| 3707 | 3707 | } |
| 3708 | 3708 | |
| 3709 | 3709 | $new_term_data = array( |
@@ -3712,54 +3712,54 @@ discard block |
||
| 3712 | 3712 | 'term_group' => $shared_term->term_group, |
| 3713 | 3713 | ); |
| 3714 | 3714 | |
| 3715 | - if ( false === $wpdb->insert( $wpdb->terms, $new_term_data ) ) { |
|
| 3716 | - return new WP_Error( 'db_insert_error', __( 'Could not split shared term.' ), $wpdb->last_error ); |
|
| 3715 | + if (false === $wpdb->insert($wpdb->terms, $new_term_data)) { |
|
| 3716 | + return new WP_Error('db_insert_error', __('Could not split shared term.'), $wpdb->last_error); |
|
| 3717 | 3717 | } |
| 3718 | 3718 | |
| 3719 | 3719 | $new_term_id = (int) $wpdb->insert_id; |
| 3720 | 3720 | |
| 3721 | 3721 | // Update the existing term_taxonomy to point to the newly created term. |
| 3722 | - $wpdb->update( $wpdb->term_taxonomy, |
|
| 3723 | - array( 'term_id' => $new_term_id ), |
|
| 3724 | - array( 'term_taxonomy_id' => $term_taxonomy_id ) |
|
| 3722 | + $wpdb->update($wpdb->term_taxonomy, |
|
| 3723 | + array('term_id' => $new_term_id), |
|
| 3724 | + array('term_taxonomy_id' => $term_taxonomy_id) |
|
| 3725 | 3725 | ); |
| 3726 | 3726 | |
| 3727 | 3727 | // Reassign child terms to the new parent. |
| 3728 | - if ( empty( $term_taxonomy ) ) { |
|
| 3729 | - $term_taxonomy = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) ); |
|
| 3728 | + if (empty($term_taxonomy)) { |
|
| 3729 | + $term_taxonomy = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id)); |
|
| 3730 | 3730 | } |
| 3731 | 3731 | |
| 3732 | - $children_tt_ids = $wpdb->get_col( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE parent = %d AND taxonomy = %s", $term_id, $term_taxonomy->taxonomy ) ); |
|
| 3733 | - if ( ! empty( $children_tt_ids ) ) { |
|
| 3734 | - foreach ( $children_tt_ids as $child_tt_id ) { |
|
| 3735 | - $wpdb->update( $wpdb->term_taxonomy, |
|
| 3736 | - array( 'parent' => $new_term_id ), |
|
| 3737 | - array( 'term_taxonomy_id' => $child_tt_id ) |
|
| 3732 | + $children_tt_ids = $wpdb->get_col($wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE parent = %d AND taxonomy = %s", $term_id, $term_taxonomy->taxonomy)); |
|
| 3733 | + if ( ! empty($children_tt_ids)) { |
|
| 3734 | + foreach ($children_tt_ids as $child_tt_id) { |
|
| 3735 | + $wpdb->update($wpdb->term_taxonomy, |
|
| 3736 | + array('parent' => $new_term_id), |
|
| 3737 | + array('term_taxonomy_id' => $child_tt_id) |
|
| 3738 | 3738 | ); |
| 3739 | - clean_term_cache( $term_id, $term_taxonomy->taxonomy ); |
|
| 3739 | + clean_term_cache($term_id, $term_taxonomy->taxonomy); |
|
| 3740 | 3740 | } |
| 3741 | 3741 | } else { |
| 3742 | 3742 | // If the term has no children, we must force its taxonomy cache to be rebuilt separately. |
| 3743 | - clean_term_cache( $new_term_id, $term_taxonomy->taxonomy ); |
|
| 3743 | + clean_term_cache($new_term_id, $term_taxonomy->taxonomy); |
|
| 3744 | 3744 | } |
| 3745 | 3745 | |
| 3746 | 3746 | // Clean the cache for term taxonomies formerly shared with the current term. |
| 3747 | - $shared_term_taxonomies = $wpdb->get_row( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) ); |
|
| 3748 | - if ( $shared_term_taxonomies ) { |
|
| 3749 | - foreach ( $shared_term_taxonomies as $shared_term_taxonomy ) { |
|
| 3750 | - clean_term_cache( $term_id, $shared_term_taxonomy ); |
|
| 3747 | + $shared_term_taxonomies = $wpdb->get_row($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id)); |
|
| 3748 | + if ($shared_term_taxonomies) { |
|
| 3749 | + foreach ($shared_term_taxonomies as $shared_term_taxonomy) { |
|
| 3750 | + clean_term_cache($term_id, $shared_term_taxonomy); |
|
| 3751 | 3751 | } |
| 3752 | 3752 | } |
| 3753 | 3753 | |
| 3754 | 3754 | // Keep a record of term_ids that have been split, keyed by old term_id. See wp_get_split_term(). |
| 3755 | - if ( $record ) { |
|
| 3756 | - $split_term_data = get_option( '_split_terms', array() ); |
|
| 3757 | - if ( ! isset( $split_term_data[ $term_id ] ) ) { |
|
| 3758 | - $split_term_data[ $term_id ] = array(); |
|
| 3755 | + if ($record) { |
|
| 3756 | + $split_term_data = get_option('_split_terms', array()); |
|
| 3757 | + if ( ! isset($split_term_data[$term_id])) { |
|
| 3758 | + $split_term_data[$term_id] = array(); |
|
| 3759 | 3759 | } |
| 3760 | 3760 | |
| 3761 | - $split_term_data[ $term_id ][ $term_taxonomy->taxonomy ] = $new_term_id; |
|
| 3762 | - update_option( '_split_terms', $split_term_data ); |
|
| 3761 | + $split_term_data[$term_id][$term_taxonomy->taxonomy] = $new_term_id; |
|
| 3762 | + update_option('_split_terms', $split_term_data); |
|
| 3763 | 3763 | } |
| 3764 | 3764 | |
| 3765 | 3765 | // If we've just split the final shared term, set the "finished" flag. |
@@ -3770,8 +3770,8 @@ discard block |
||
| 3770 | 3770 | HAVING term_tt_count > 1 |
| 3771 | 3771 | LIMIT 1" |
| 3772 | 3772 | ); |
| 3773 | - if ( ! $shared_terms_exist ) { |
|
| 3774 | - update_option( 'finished_splitting_shared_terms', true ); |
|
| 3773 | + if ( ! $shared_terms_exist) { |
|
| 3774 | + update_option('finished_splitting_shared_terms', true); |
|
| 3775 | 3775 | } |
| 3776 | 3776 | |
| 3777 | 3777 | /** |
@@ -3784,7 +3784,7 @@ discard block |
||
| 3784 | 3784 | * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. |
| 3785 | 3785 | * @param string $taxonomy Taxonomy for the split term. |
| 3786 | 3786 | */ |
| 3787 | - do_action( 'split_shared_term', $term_id, $new_term_id, $term_taxonomy_id, $term_taxonomy->taxonomy ); |
|
| 3787 | + do_action('split_shared_term', $term_id, $new_term_id, $term_taxonomy_id, $term_taxonomy->taxonomy); |
|
| 3788 | 3788 | |
| 3789 | 3789 | return $new_term_id; |
| 3790 | 3790 | } |
@@ -3802,20 +3802,20 @@ discard block |
||
| 3802 | 3802 | $lock_name = 'term_split.lock'; |
| 3803 | 3803 | |
| 3804 | 3804 | // Try to lock. |
| 3805 | - $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) ); |
|
| 3805 | + $lock_result = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time())); |
|
| 3806 | 3806 | |
| 3807 | - if ( ! $lock_result ) { |
|
| 3808 | - $lock_result = get_option( $lock_name ); |
|
| 3807 | + if ( ! $lock_result) { |
|
| 3808 | + $lock_result = get_option($lock_name); |
|
| 3809 | 3809 | |
| 3810 | 3810 | // Bail if we were unable to create a lock, or if the existing lock is still valid. |
| 3811 | - if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) { |
|
| 3812 | - wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' ); |
|
| 3811 | + if ( ! $lock_result || ($lock_result > (time() - HOUR_IN_SECONDS))) { |
|
| 3812 | + wp_schedule_single_event(time() + (5 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch'); |
|
| 3813 | 3813 | return; |
| 3814 | 3814 | } |
| 3815 | 3815 | } |
| 3816 | 3816 | |
| 3817 | 3817 | // Update the lock, as by this point we've definitely got a lock, just need to fire the actions. |
| 3818 | - update_option( $lock_name, time() ); |
|
| 3818 | + update_option($lock_name, time()); |
|
| 3819 | 3819 | |
| 3820 | 3820 | // Get a list of shared terms (those with more than one associated row in term_taxonomy). |
| 3821 | 3821 | $shared_terms = $wpdb->get_results( |
@@ -3827,61 +3827,61 @@ discard block |
||
| 3827 | 3827 | ); |
| 3828 | 3828 | |
| 3829 | 3829 | // No more terms, we're done here. |
| 3830 | - if ( ! $shared_terms ) { |
|
| 3831 | - update_option( 'finished_splitting_shared_terms', true ); |
|
| 3832 | - delete_option( $lock_name ); |
|
| 3830 | + if ( ! $shared_terms) { |
|
| 3831 | + update_option('finished_splitting_shared_terms', true); |
|
| 3832 | + delete_option($lock_name); |
|
| 3833 | 3833 | return; |
| 3834 | 3834 | } |
| 3835 | 3835 | |
| 3836 | 3836 | // Shared terms found? We'll need to run this script again. |
| 3837 | - wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' ); |
|
| 3837 | + wp_schedule_single_event(time() + (2 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch'); |
|
| 3838 | 3838 | |
| 3839 | 3839 | // Rekey shared term array for faster lookups. |
| 3840 | 3840 | $_shared_terms = array(); |
| 3841 | - foreach ( $shared_terms as $shared_term ) { |
|
| 3842 | - $term_id = intval( $shared_term->term_id ); |
|
| 3843 | - $_shared_terms[ $term_id ] = $shared_term; |
|
| 3841 | + foreach ($shared_terms as $shared_term) { |
|
| 3842 | + $term_id = intval($shared_term->term_id); |
|
| 3843 | + $_shared_terms[$term_id] = $shared_term; |
|
| 3844 | 3844 | } |
| 3845 | 3845 | $shared_terms = $_shared_terms; |
| 3846 | 3846 | |
| 3847 | 3847 | // Get term taxonomy data for all shared terms. |
| 3848 | - $shared_term_ids = implode( ',', array_keys( $shared_terms ) ); |
|
| 3849 | - $shared_tts = $wpdb->get_results( "SELECT * FROM {$wpdb->term_taxonomy} WHERE `term_id` IN ({$shared_term_ids})" ); |
|
| 3848 | + $shared_term_ids = implode(',', array_keys($shared_terms)); |
|
| 3849 | + $shared_tts = $wpdb->get_results("SELECT * FROM {$wpdb->term_taxonomy} WHERE `term_id` IN ({$shared_term_ids})"); |
|
| 3850 | 3850 | |
| 3851 | 3851 | // Split term data recording is slow, so we do it just once, outside the loop. |
| 3852 | - $split_term_data = get_option( '_split_terms', array() ); |
|
| 3852 | + $split_term_data = get_option('_split_terms', array()); |
|
| 3853 | 3853 | $skipped_first_term = $taxonomies = array(); |
| 3854 | - foreach ( $shared_tts as $shared_tt ) { |
|
| 3855 | - $term_id = intval( $shared_tt->term_id ); |
|
| 3854 | + foreach ($shared_tts as $shared_tt) { |
|
| 3855 | + $term_id = intval($shared_tt->term_id); |
|
| 3856 | 3856 | |
| 3857 | 3857 | // Don't split the first tt belonging to a given term_id. |
| 3858 | - if ( ! isset( $skipped_first_term[ $term_id ] ) ) { |
|
| 3859 | - $skipped_first_term[ $term_id ] = 1; |
|
| 3858 | + if ( ! isset($skipped_first_term[$term_id])) { |
|
| 3859 | + $skipped_first_term[$term_id] = 1; |
|
| 3860 | 3860 | continue; |
| 3861 | 3861 | } |
| 3862 | 3862 | |
| 3863 | - if ( ! isset( $split_term_data[ $term_id ] ) ) { |
|
| 3864 | - $split_term_data[ $term_id ] = array(); |
|
| 3863 | + if ( ! isset($split_term_data[$term_id])) { |
|
| 3864 | + $split_term_data[$term_id] = array(); |
|
| 3865 | 3865 | } |
| 3866 | 3866 | |
| 3867 | 3867 | // Keep track of taxonomies whose hierarchies need flushing. |
| 3868 | - if ( ! isset( $taxonomies[ $shared_tt->taxonomy ] ) ) { |
|
| 3869 | - $taxonomies[ $shared_tt->taxonomy ] = 1; |
|
| 3868 | + if ( ! isset($taxonomies[$shared_tt->taxonomy])) { |
|
| 3869 | + $taxonomies[$shared_tt->taxonomy] = 1; |
|
| 3870 | 3870 | } |
| 3871 | 3871 | |
| 3872 | 3872 | // Split the term. |
| 3873 | - $split_term_data[ $term_id ][ $shared_tt->taxonomy ] = _split_shared_term( $shared_terms[ $term_id ], $shared_tt, false ); |
|
| 3873 | + $split_term_data[$term_id][$shared_tt->taxonomy] = _split_shared_term($shared_terms[$term_id], $shared_tt, false); |
|
| 3874 | 3874 | } |
| 3875 | 3875 | |
| 3876 | 3876 | // Rebuild the cached hierarchy for each affected taxonomy. |
| 3877 | - foreach ( array_keys( $taxonomies ) as $tax ) { |
|
| 3878 | - delete_option( "{$tax}_children" ); |
|
| 3879 | - _get_term_hierarchy( $tax ); |
|
| 3877 | + foreach (array_keys($taxonomies) as $tax) { |
|
| 3878 | + delete_option("{$tax}_children"); |
|
| 3879 | + _get_term_hierarchy($tax); |
|
| 3880 | 3880 | } |
| 3881 | 3881 | |
| 3882 | - update_option( '_split_terms', $split_term_data ); |
|
| 3882 | + update_option('_split_terms', $split_term_data); |
|
| 3883 | 3883 | |
| 3884 | - delete_option( $lock_name ); |
|
| 3884 | + delete_option($lock_name); |
|
| 3885 | 3885 | } |
| 3886 | 3886 | |
| 3887 | 3887 | /** |
@@ -3892,8 +3892,8 @@ discard block |
||
| 3892 | 3892 | * @since 4.3.0 |
| 3893 | 3893 | */ |
| 3894 | 3894 | function _wp_check_for_scheduled_split_terms() { |
| 3895 | - if ( ! get_option( 'finished_splitting_shared_terms' ) && ! wp_next_scheduled( 'wp_split_shared_term_batch' ) ) { |
|
| 3896 | - wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'wp_split_shared_term_batch' ); |
|
| 3895 | + if ( ! get_option('finished_splitting_shared_terms') && ! wp_next_scheduled('wp_split_shared_term_batch')) { |
|
| 3896 | + wp_schedule_single_event(time() + MINUTE_IN_SECONDS, 'wp_split_shared_term_batch'); |
|
| 3897 | 3897 | } |
| 3898 | 3898 | } |
| 3899 | 3899 | |
@@ -3908,14 +3908,14 @@ discard block |
||
| 3908 | 3908 | * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. |
| 3909 | 3909 | * @param string $taxonomy Taxonomy for the split term. |
| 3910 | 3910 | */ |
| 3911 | -function _wp_check_split_default_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { |
|
| 3912 | - if ( 'category' != $taxonomy ) { |
|
| 3911 | +function _wp_check_split_default_terms($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) { |
|
| 3912 | + if ('category' != $taxonomy) { |
|
| 3913 | 3913 | return; |
| 3914 | 3914 | } |
| 3915 | 3915 | |
| 3916 | - foreach ( array( 'default_category', 'default_link_category', 'default_email_category' ) as $option ) { |
|
| 3917 | - if ( $term_id == get_option( $option, -1 ) ) { |
|
| 3918 | - update_option( $option, $new_term_id ); |
|
| 3916 | + foreach (array('default_category', 'default_link_category', 'default_email_category') as $option) { |
|
| 3917 | + if ($term_id == get_option($option, -1)) { |
|
| 3918 | + update_option($option, $new_term_id); |
|
| 3919 | 3919 | } |
| 3920 | 3920 | } |
| 3921 | 3921 | } |
@@ -3933,9 +3933,9 @@ discard block |
||
| 3933 | 3933 | * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. |
| 3934 | 3934 | * @param string $taxonomy Taxonomy for the split term. |
| 3935 | 3935 | */ |
| 3936 | -function _wp_check_split_terms_in_menus( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { |
|
| 3936 | +function _wp_check_split_terms_in_menus($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) { |
|
| 3937 | 3937 | global $wpdb; |
| 3938 | - $post_ids = $wpdb->get_col( $wpdb->prepare( |
|
| 3938 | + $post_ids = $wpdb->get_col($wpdb->prepare( |
|
| 3939 | 3939 | "SELECT m1.post_id |
| 3940 | 3940 | FROM {$wpdb->postmeta} AS m1 |
| 3941 | 3941 | INNER JOIN {$wpdb->postmeta} AS m2 ON ( m2.post_id = m1.post_id ) |
@@ -3945,11 +3945,11 @@ discard block |
||
| 3945 | 3945 | AND ( m3.meta_key = '_menu_item_object_id' AND m3.meta_value = %d )", |
| 3946 | 3946 | $taxonomy, |
| 3947 | 3947 | $term_id |
| 3948 | - ) ); |
|
| 3948 | + )); |
|
| 3949 | 3949 | |
| 3950 | - if ( $post_ids ) { |
|
| 3951 | - foreach ( $post_ids as $post_id ) { |
|
| 3952 | - update_post_meta( $post_id, '_menu_item_object_id', $new_term_id, $term_id ); |
|
| 3950 | + if ($post_ids) { |
|
| 3951 | + foreach ($post_ids as $post_id) { |
|
| 3952 | + update_post_meta($post_id, '_menu_item_object_id', $new_term_id, $term_id); |
|
| 3953 | 3953 | } |
| 3954 | 3954 | } |
| 3955 | 3955 | } |
@@ -3965,19 +3965,19 @@ discard block |
||
| 3965 | 3965 | * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. |
| 3966 | 3966 | * @param string $taxonomy Taxonomy for the split term. |
| 3967 | 3967 | */ |
| 3968 | -function _wp_check_split_nav_menu_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { |
|
| 3969 | - if ( 'nav_menu' !== $taxonomy ) { |
|
| 3968 | +function _wp_check_split_nav_menu_terms($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) { |
|
| 3969 | + if ('nav_menu' !== $taxonomy) { |
|
| 3970 | 3970 | return; |
| 3971 | 3971 | } |
| 3972 | 3972 | |
| 3973 | 3973 | // Update menu locations. |
| 3974 | 3974 | $locations = get_nav_menu_locations(); |
| 3975 | - foreach ( $locations as $location => $menu_id ) { |
|
| 3976 | - if ( $term_id == $menu_id ) { |
|
| 3977 | - $locations[ $location ] = $new_term_id; |
|
| 3975 | + foreach ($locations as $location => $menu_id) { |
|
| 3976 | + if ($term_id == $menu_id) { |
|
| 3977 | + $locations[$location] = $new_term_id; |
|
| 3978 | 3978 | } |
| 3979 | 3979 | } |
| 3980 | - set_theme_mod( 'nav_menu_locations', $locations ); |
|
| 3980 | + set_theme_mod('nav_menu_locations', $locations); |
|
| 3981 | 3981 | } |
| 3982 | 3982 | |
| 3983 | 3983 | /** |
@@ -3988,12 +3988,12 @@ discard block |
||
| 3988 | 3988 | * @param int $old_term_id Term ID. This is the old, pre-split term ID. |
| 3989 | 3989 | * @return array Array of new term IDs, keyed by taxonomy. |
| 3990 | 3990 | */ |
| 3991 | -function wp_get_split_terms( $old_term_id ) { |
|
| 3992 | - $split_terms = get_option( '_split_terms', array() ); |
|
| 3991 | +function wp_get_split_terms($old_term_id) { |
|
| 3992 | + $split_terms = get_option('_split_terms', array()); |
|
| 3993 | 3993 | |
| 3994 | 3994 | $terms = array(); |
| 3995 | - if ( isset( $split_terms[ $old_term_id ] ) ) { |
|
| 3996 | - $terms = $split_terms[ $old_term_id ]; |
|
| 3995 | + if (isset($split_terms[$old_term_id])) { |
|
| 3996 | + $terms = $split_terms[$old_term_id]; |
|
| 3997 | 3997 | } |
| 3998 | 3998 | |
| 3999 | 3999 | return $terms; |
@@ -4010,12 +4010,12 @@ discard block |
||
| 4010 | 4010 | * the new term_id will be returned. If no previously split term is found matching |
| 4011 | 4011 | * the parameters, returns false. |
| 4012 | 4012 | */ |
| 4013 | -function wp_get_split_term( $old_term_id, $taxonomy ) { |
|
| 4014 | - $split_terms = wp_get_split_terms( $old_term_id ); |
|
| 4013 | +function wp_get_split_term($old_term_id, $taxonomy) { |
|
| 4014 | + $split_terms = wp_get_split_terms($old_term_id); |
|
| 4015 | 4015 | |
| 4016 | 4016 | $term_id = false; |
| 4017 | - if ( isset( $split_terms[ $taxonomy ] ) ) { |
|
| 4018 | - $term_id = (int) $split_terms[ $taxonomy ]; |
|
| 4017 | + if (isset($split_terms[$taxonomy])) { |
|
| 4018 | + $term_id = (int) $split_terms[$taxonomy]; |
|
| 4019 | 4019 | } |
| 4020 | 4020 | |
| 4021 | 4021 | return $term_id; |
@@ -4032,14 +4032,14 @@ discard block |
||
| 4032 | 4032 | * @param int $term_id |
| 4033 | 4033 | * @return bool |
| 4034 | 4034 | */ |
| 4035 | -function wp_term_is_shared( $term_id ) { |
|
| 4035 | +function wp_term_is_shared($term_id) { |
|
| 4036 | 4036 | global $wpdb; |
| 4037 | 4037 | |
| 4038 | - if ( get_option( 'finished_splitting_shared_terms' ) ) { |
|
| 4038 | + if (get_option('finished_splitting_shared_terms')) { |
|
| 4039 | 4039 | return false; |
| 4040 | 4040 | } |
| 4041 | 4041 | |
| 4042 | - $tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) ); |
|
| 4042 | + $tt_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id)); |
|
| 4043 | 4043 | |
| 4044 | 4044 | return $tt_count > 1; |
| 4045 | 4045 | } |
@@ -4055,21 +4055,21 @@ discard block |
||
| 4055 | 4055 | * @param string $taxonomy Optional. Taxonomy. Default empty. |
| 4056 | 4056 | * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist. |
| 4057 | 4057 | */ |
| 4058 | -function get_term_link( $term, $taxonomy = '' ) { |
|
| 4058 | +function get_term_link($term, $taxonomy = '') { |
|
| 4059 | 4059 | global $wp_rewrite; |
| 4060 | 4060 | |
| 4061 | - if ( !is_object($term) ) { |
|
| 4062 | - if ( is_int( $term ) ) { |
|
| 4063 | - $term = get_term( $term, $taxonomy ); |
|
| 4061 | + if ( ! is_object($term)) { |
|
| 4062 | + if (is_int($term)) { |
|
| 4063 | + $term = get_term($term, $taxonomy); |
|
| 4064 | 4064 | } else { |
| 4065 | - $term = get_term_by( 'slug', $term, $taxonomy ); |
|
| 4065 | + $term = get_term_by('slug', $term, $taxonomy); |
|
| 4066 | 4066 | } |
| 4067 | 4067 | } |
| 4068 | 4068 | |
| 4069 | - if ( !is_object($term) ) |
|
| 4069 | + if ( ! is_object($term)) |
|
| 4070 | 4070 | $term = new WP_Error('invalid_term', __('Empty Term')); |
| 4071 | 4071 | |
| 4072 | - if ( is_wp_error( $term ) ) |
|
| 4072 | + if (is_wp_error($term)) |
|
| 4073 | 4073 | return $term; |
| 4074 | 4074 | |
| 4075 | 4075 | $taxonomy = $term->taxonomy; |
@@ -4079,19 +4079,19 @@ discard block |
||
| 4079 | 4079 | $slug = $term->slug; |
| 4080 | 4080 | $t = get_taxonomy($taxonomy); |
| 4081 | 4081 | |
| 4082 | - if ( empty($termlink) ) { |
|
| 4083 | - if ( 'category' == $taxonomy ) |
|
| 4084 | - $termlink = '?cat=' . $term->term_id; |
|
| 4085 | - elseif ( $t->query_var ) |
|
| 4082 | + if (empty($termlink)) { |
|
| 4083 | + if ('category' == $taxonomy) |
|
| 4084 | + $termlink = '?cat='.$term->term_id; |
|
| 4085 | + elseif ($t->query_var) |
|
| 4086 | 4086 | $termlink = "?$t->query_var=$slug"; |
| 4087 | 4087 | else |
| 4088 | 4088 | $termlink = "?taxonomy=$taxonomy&term=$slug"; |
| 4089 | 4089 | $termlink = home_url($termlink); |
| 4090 | 4090 | } else { |
| 4091 | - if ( $t->rewrite['hierarchical'] ) { |
|
| 4091 | + if ($t->rewrite['hierarchical']) { |
|
| 4092 | 4092 | $hierarchical_slugs = array(); |
| 4093 | - $ancestors = get_ancestors( $term->term_id, $taxonomy, 'taxonomy' ); |
|
| 4094 | - foreach ( (array)$ancestors as $ancestor ) { |
|
| 4093 | + $ancestors = get_ancestors($term->term_id, $taxonomy, 'taxonomy'); |
|
| 4094 | + foreach ((array) $ancestors as $ancestor) { |
|
| 4095 | 4095 | $ancestor_term = get_term($ancestor, $taxonomy); |
| 4096 | 4096 | $hierarchical_slugs[] = $ancestor_term->slug; |
| 4097 | 4097 | } |
@@ -4101,10 +4101,10 @@ discard block |
||
| 4101 | 4101 | } else { |
| 4102 | 4102 | $termlink = str_replace("%$taxonomy%", $slug, $termlink); |
| 4103 | 4103 | } |
| 4104 | - $termlink = home_url( user_trailingslashit($termlink, 'category') ); |
|
| 4104 | + $termlink = home_url(user_trailingslashit($termlink, 'category')); |
|
| 4105 | 4105 | } |
| 4106 | 4106 | // Back Compat filters. |
| 4107 | - if ( 'post_tag' == $taxonomy ) { |
|
| 4107 | + if ('post_tag' == $taxonomy) { |
|
| 4108 | 4108 | |
| 4109 | 4109 | /** |
| 4110 | 4110 | * Filters the tag link. |
@@ -4115,8 +4115,8 @@ discard block |
||
| 4115 | 4115 | * @param string $termlink Tag link URL. |
| 4116 | 4116 | * @param int $term_id Term ID. |
| 4117 | 4117 | */ |
| 4118 | - $termlink = apply_filters( 'tag_link', $termlink, $term->term_id ); |
|
| 4119 | - } elseif ( 'category' == $taxonomy ) { |
|
| 4118 | + $termlink = apply_filters('tag_link', $termlink, $term->term_id); |
|
| 4119 | + } elseif ('category' == $taxonomy) { |
|
| 4120 | 4120 | |
| 4121 | 4121 | /** |
| 4122 | 4122 | * Filters the category link. |
@@ -4127,7 +4127,7 @@ discard block |
||
| 4127 | 4127 | * @param string $termlink Category link URL. |
| 4128 | 4128 | * @param int $term_id Term ID. |
| 4129 | 4129 | */ |
| 4130 | - $termlink = apply_filters( 'category_link', $termlink, $term->term_id ); |
|
| 4130 | + $termlink = apply_filters('category_link', $termlink, $term->term_id); |
|
| 4131 | 4131 | } |
| 4132 | 4132 | |
| 4133 | 4133 | /** |
@@ -4139,7 +4139,7 @@ discard block |
||
| 4139 | 4139 | * @param object $term Term object. |
| 4140 | 4140 | * @param string $taxonomy Taxonomy slug. |
| 4141 | 4141 | */ |
| 4142 | - return apply_filters( 'term_link', $termlink, $term, $taxonomy ); |
|
| 4142 | + return apply_filters('term_link', $termlink, $term, $taxonomy); |
|
| 4143 | 4143 | } |
| 4144 | 4144 | |
| 4145 | 4145 | /** |
@@ -4161,7 +4161,7 @@ discard block |
||
| 4161 | 4161 | * @type string $after Displays after the taxonomies. Default empty string. |
| 4162 | 4162 | * } |
| 4163 | 4163 | */ |
| 4164 | -function the_taxonomies( $args = array() ) { |
|
| 4164 | +function the_taxonomies($args = array()) { |
|
| 4165 | 4165 | $defaults = array( |
| 4166 | 4166 | 'post' => 0, |
| 4167 | 4167 | 'before' => '', |
@@ -4169,9 +4169,9 @@ discard block |
||
| 4169 | 4169 | 'after' => '', |
| 4170 | 4170 | ); |
| 4171 | 4171 | |
| 4172 | - $r = wp_parse_args( $args, $defaults ); |
|
| 4172 | + $r = wp_parse_args($args, $defaults); |
|
| 4173 | 4173 | |
| 4174 | - echo $r['before'] . join( $r['sep'], get_the_taxonomies( $r['post'], $r ) ) . $r['after']; |
|
| 4174 | + echo $r['before'].join($r['sep'], get_the_taxonomies($r['post'], $r)).$r['after']; |
|
| 4175 | 4175 | } |
| 4176 | 4176 | |
| 4177 | 4177 | /** |
@@ -4193,47 +4193,47 @@ discard block |
||
| 4193 | 4193 | * } |
| 4194 | 4194 | * @return array List of taxonomies. |
| 4195 | 4195 | */ |
| 4196 | -function get_the_taxonomies( $post = 0, $args = array() ) { |
|
| 4197 | - $post = get_post( $post ); |
|
| 4196 | +function get_the_taxonomies($post = 0, $args = array()) { |
|
| 4197 | + $post = get_post($post); |
|
| 4198 | 4198 | |
| 4199 | - $args = wp_parse_args( $args, array( |
|
| 4199 | + $args = wp_parse_args($args, array( |
|
| 4200 | 4200 | /* translators: %s: taxonomy label, %l: list of terms formatted as per $term_template */ |
| 4201 | - 'template' => __( '%s: %l.' ), |
|
| 4201 | + 'template' => __('%s: %l.'), |
|
| 4202 | 4202 | 'term_template' => '<a href="%1$s">%2$s</a>', |
| 4203 | - ) ); |
|
| 4203 | + )); |
|
| 4204 | 4204 | |
| 4205 | 4205 | $taxonomies = array(); |
| 4206 | 4206 | |
| 4207 | - if ( ! $post ) { |
|
| 4207 | + if ( ! $post) { |
|
| 4208 | 4208 | return $taxonomies; |
| 4209 | 4209 | } |
| 4210 | 4210 | |
| 4211 | - foreach ( get_object_taxonomies( $post ) as $taxonomy ) { |
|
| 4212 | - $t = (array) get_taxonomy( $taxonomy ); |
|
| 4213 | - if ( empty( $t['label'] ) ) { |
|
| 4211 | + foreach (get_object_taxonomies($post) as $taxonomy) { |
|
| 4212 | + $t = (array) get_taxonomy($taxonomy); |
|
| 4213 | + if (empty($t['label'])) { |
|
| 4214 | 4214 | $t['label'] = $taxonomy; |
| 4215 | 4215 | } |
| 4216 | - if ( empty( $t['args'] ) ) { |
|
| 4216 | + if (empty($t['args'])) { |
|
| 4217 | 4217 | $t['args'] = array(); |
| 4218 | 4218 | } |
| 4219 | - if ( empty( $t['template'] ) ) { |
|
| 4219 | + if (empty($t['template'])) { |
|
| 4220 | 4220 | $t['template'] = $args['template']; |
| 4221 | 4221 | } |
| 4222 | - if ( empty( $t['term_template'] ) ) { |
|
| 4222 | + if (empty($t['term_template'])) { |
|
| 4223 | 4223 | $t['term_template'] = $args['term_template']; |
| 4224 | 4224 | } |
| 4225 | 4225 | |
| 4226 | - $terms = get_object_term_cache( $post->ID, $taxonomy ); |
|
| 4227 | - if ( false === $terms ) { |
|
| 4228 | - $terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] ); |
|
| 4226 | + $terms = get_object_term_cache($post->ID, $taxonomy); |
|
| 4227 | + if (false === $terms) { |
|
| 4228 | + $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); |
|
| 4229 | 4229 | } |
| 4230 | 4230 | $links = array(); |
| 4231 | 4231 | |
| 4232 | - foreach ( $terms as $term ) { |
|
| 4233 | - $links[] = wp_sprintf( $t['term_template'], esc_attr( get_term_link( $term ) ), $term->name ); |
|
| 4232 | + foreach ($terms as $term) { |
|
| 4233 | + $links[] = wp_sprintf($t['term_template'], esc_attr(get_term_link($term)), $term->name); |
|
| 4234 | 4234 | } |
| 4235 | - if ( $links ) { |
|
| 4236 | - $taxonomies[$taxonomy] = wp_sprintf( $t['template'], $t['label'], $links, $terms ); |
|
| 4235 | + if ($links) { |
|
| 4236 | + $taxonomies[$taxonomy] = wp_sprintf($t['template'], $t['label'], $links, $terms); |
|
| 4237 | 4237 | } |
| 4238 | 4238 | } |
| 4239 | 4239 | return $taxonomies; |
@@ -4247,8 +4247,8 @@ discard block |
||
| 4247 | 4247 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
| 4248 | 4248 | * @return array |
| 4249 | 4249 | */ |
| 4250 | -function get_post_taxonomies( $post = 0 ) { |
|
| 4251 | - $post = get_post( $post ); |
|
| 4250 | +function get_post_taxonomies($post = 0) { |
|
| 4251 | + $post = get_post($post); |
|
| 4252 | 4252 | |
| 4253 | 4253 | return get_object_taxonomies($post); |
| 4254 | 4254 | } |
@@ -4267,45 +4267,45 @@ discard block |
||
| 4267 | 4267 | * @param int|string|array $terms Optional. Term term_id, name, slug or array of said. Default null. |
| 4268 | 4268 | * @return bool|WP_Error WP_Error on input error. |
| 4269 | 4269 | */ |
| 4270 | -function is_object_in_term( $object_id, $taxonomy, $terms = null ) { |
|
| 4271 | - if ( !$object_id = (int) $object_id ) |
|
| 4272 | - return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) ); |
|
| 4270 | +function is_object_in_term($object_id, $taxonomy, $terms = null) { |
|
| 4271 | + if ( ! $object_id = (int) $object_id) |
|
| 4272 | + return new WP_Error('invalid_object', __('Invalid object ID')); |
|
| 4273 | 4273 | |
| 4274 | - $object_terms = get_object_term_cache( $object_id, $taxonomy ); |
|
| 4275 | - if ( false === $object_terms ) { |
|
| 4276 | - $object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) ); |
|
| 4277 | - wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" ); |
|
| 4274 | + $object_terms = get_object_term_cache($object_id, $taxonomy); |
|
| 4275 | + if (false === $object_terms) { |
|
| 4276 | + $object_terms = wp_get_object_terms($object_id, $taxonomy, array('update_term_meta_cache' => false)); |
|
| 4277 | + wp_cache_set($object_id, wp_list_pluck($object_terms, 'term_id'), "{$taxonomy}_relationships"); |
|
| 4278 | 4278 | } |
| 4279 | 4279 | |
| 4280 | - if ( is_wp_error( $object_terms ) ) |
|
| 4280 | + if (is_wp_error($object_terms)) |
|
| 4281 | 4281 | return $object_terms; |
| 4282 | - if ( empty( $object_terms ) ) |
|
| 4282 | + if (empty($object_terms)) |
|
| 4283 | 4283 | return false; |
| 4284 | - if ( empty( $terms ) ) |
|
| 4285 | - return ( !empty( $object_terms ) ); |
|
| 4284 | + if (empty($terms)) |
|
| 4285 | + return ( ! empty($object_terms)); |
|
| 4286 | 4286 | |
| 4287 | 4287 | $terms = (array) $terms; |
| 4288 | 4288 | |
| 4289 | - if ( $ints = array_filter( $terms, 'is_int' ) ) |
|
| 4290 | - $strs = array_diff( $terms, $ints ); |
|
| 4289 | + if ($ints = array_filter($terms, 'is_int')) |
|
| 4290 | + $strs = array_diff($terms, $ints); |
|
| 4291 | 4291 | else |
| 4292 | - $strs =& $terms; |
|
| 4292 | + $strs = & $terms; |
|
| 4293 | 4293 | |
| 4294 | - foreach ( $object_terms as $object_term ) { |
|
| 4294 | + foreach ($object_terms as $object_term) { |
|
| 4295 | 4295 | // If term is an int, check against term_ids only. |
| 4296 | - if ( $ints && in_array( $object_term->term_id, $ints ) ) { |
|
| 4296 | + if ($ints && in_array($object_term->term_id, $ints)) { |
|
| 4297 | 4297 | return true; |
| 4298 | 4298 | } |
| 4299 | 4299 | |
| 4300 | - if ( $strs ) { |
|
| 4300 | + if ($strs) { |
|
| 4301 | 4301 | // Only check numeric strings against term_id, to avoid false matches due to type juggling. |
| 4302 | - $numeric_strs = array_map( 'intval', array_filter( $strs, 'is_numeric' ) ); |
|
| 4303 | - if ( in_array( $object_term->term_id, $numeric_strs, true ) ) { |
|
| 4302 | + $numeric_strs = array_map('intval', array_filter($strs, 'is_numeric')); |
|
| 4303 | + if (in_array($object_term->term_id, $numeric_strs, true)) { |
|
| 4304 | 4304 | return true; |
| 4305 | 4305 | } |
| 4306 | 4306 | |
| 4307 | - if ( in_array( $object_term->name, $strs ) ) return true; |
|
| 4308 | - if ( in_array( $object_term->slug, $strs ) ) return true; |
|
| 4307 | + if (in_array($object_term->name, $strs)) return true; |
|
| 4308 | + if (in_array($object_term->slug, $strs)) return true; |
|
| 4309 | 4309 | } |
| 4310 | 4310 | } |
| 4311 | 4311 | |
@@ -4321,12 +4321,12 @@ discard block |
||
| 4321 | 4321 | * @param string $taxonomy Single taxonomy name. |
| 4322 | 4322 | * @return bool True if object is associated with the taxonomy, otherwise false. |
| 4323 | 4323 | */ |
| 4324 | -function is_object_in_taxonomy( $object_type, $taxonomy ) { |
|
| 4325 | - $taxonomies = get_object_taxonomies( $object_type ); |
|
| 4326 | - if ( empty( $taxonomies ) ) { |
|
| 4324 | +function is_object_in_taxonomy($object_type, $taxonomy) { |
|
| 4325 | + $taxonomies = get_object_taxonomies($object_type); |
|
| 4326 | + if (empty($taxonomies)) { |
|
| 4327 | 4327 | return false; |
| 4328 | 4328 | } |
| 4329 | - return in_array( $taxonomy, $taxonomies ); |
|
| 4329 | + return in_array($taxonomy, $taxonomies); |
|
| 4330 | 4330 | } |
| 4331 | 4331 | |
| 4332 | 4332 | /** |
@@ -4342,32 +4342,32 @@ discard block |
||
| 4342 | 4342 | * or 'taxonomy'. Default empty. |
| 4343 | 4343 | * @return array An array of ancestors from lowest to highest in the hierarchy. |
| 4344 | 4344 | */ |
| 4345 | -function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) { |
|
| 4345 | +function get_ancestors($object_id = 0, $object_type = '', $resource_type = '') { |
|
| 4346 | 4346 | $object_id = (int) $object_id; |
| 4347 | 4347 | |
| 4348 | 4348 | $ancestors = array(); |
| 4349 | 4349 | |
| 4350 | - if ( empty( $object_id ) ) { |
|
| 4350 | + if (empty($object_id)) { |
|
| 4351 | 4351 | |
| 4352 | 4352 | /** This filter is documented in wp-includes/taxonomy.php */ |
| 4353 | - return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type ); |
|
| 4353 | + return apply_filters('get_ancestors', $ancestors, $object_id, $object_type, $resource_type); |
|
| 4354 | 4354 | } |
| 4355 | 4355 | |
| 4356 | - if ( ! $resource_type ) { |
|
| 4357 | - if ( is_taxonomy_hierarchical( $object_type ) ) { |
|
| 4356 | + if ( ! $resource_type) { |
|
| 4357 | + if (is_taxonomy_hierarchical($object_type)) { |
|
| 4358 | 4358 | $resource_type = 'taxonomy'; |
| 4359 | - } elseif ( post_type_exists( $object_type ) ) { |
|
| 4359 | + } elseif (post_type_exists($object_type)) { |
|
| 4360 | 4360 | $resource_type = 'post_type'; |
| 4361 | 4361 | } |
| 4362 | 4362 | } |
| 4363 | 4363 | |
| 4364 | - if ( 'taxonomy' === $resource_type ) { |
|
| 4364 | + if ('taxonomy' === $resource_type) { |
|
| 4365 | 4365 | $term = get_term($object_id, $object_type); |
| 4366 | - while ( ! is_wp_error($term) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors ) ) { |
|
| 4366 | + while ( ! is_wp_error($term) && ! empty($term->parent) && ! in_array($term->parent, $ancestors)) { |
|
| 4367 | 4367 | $ancestors[] = (int) $term->parent; |
| 4368 | 4368 | $term = get_term($term->parent, $object_type); |
| 4369 | 4369 | } |
| 4370 | - } elseif ( 'post_type' === $resource_type ) { |
|
| 4370 | + } elseif ('post_type' === $resource_type) { |
|
| 4371 | 4371 | $ancestors = get_post_ancestors($object_id); |
| 4372 | 4372 | } |
| 4373 | 4373 | |
@@ -4382,7 +4382,7 @@ discard block |
||
| 4382 | 4382 | * @param string $object_type Type of object. |
| 4383 | 4383 | * @param string $resource_type Type of resource $object_type is. |
| 4384 | 4384 | */ |
| 4385 | - return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type ); |
|
| 4385 | + return apply_filters('get_ancestors', $ancestors, $object_id, $object_type, $resource_type); |
|
| 4386 | 4386 | } |
| 4387 | 4387 | |
| 4388 | 4388 | /** |
@@ -4394,9 +4394,9 @@ discard block |
||
| 4394 | 4394 | * @param string $taxonomy Taxonomy name. |
| 4395 | 4395 | * @return int|false False on error. |
| 4396 | 4396 | */ |
| 4397 | -function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) { |
|
| 4398 | - $term = get_term( $term_id, $taxonomy ); |
|
| 4399 | - if ( ! $term || is_wp_error( $term ) ) { |
|
| 4397 | +function wp_get_term_taxonomy_parent_id($term_id, $taxonomy) { |
|
| 4398 | + $term = get_term($term_id, $taxonomy); |
|
| 4399 | + if ( ! $term || is_wp_error($term)) { |
|
| 4400 | 4400 | return false; |
| 4401 | 4401 | } |
| 4402 | 4402 | return (int) $term->parent; |
@@ -4416,26 +4416,26 @@ discard block |
||
| 4416 | 4416 | * |
| 4417 | 4417 | * @return int The new parent for the term. |
| 4418 | 4418 | */ |
| 4419 | -function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) { |
|
| 4419 | +function wp_check_term_hierarchy_for_loops($parent, $term_id, $taxonomy) { |
|
| 4420 | 4420 | // Nothing fancy here - bail |
| 4421 | - if ( !$parent ) |
|
| 4421 | + if ( ! $parent) |
|
| 4422 | 4422 | return 0; |
| 4423 | 4423 | |
| 4424 | 4424 | // Can't be its own parent. |
| 4425 | - if ( $parent == $term_id ) |
|
| 4425 | + if ($parent == $term_id) |
|
| 4426 | 4426 | return 0; |
| 4427 | 4427 | |
| 4428 | 4428 | // Now look for larger loops. |
| 4429 | - if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) ) |
|
| 4429 | + if ( ! $loop = wp_find_hierarchy_loop('wp_get_term_taxonomy_parent_id', $term_id, $parent, array($taxonomy))) |
|
| 4430 | 4430 | return $parent; // No loop |
| 4431 | 4431 | |
| 4432 | 4432 | // Setting $parent to the given value causes a loop. |
| 4433 | - if ( isset( $loop[$term_id] ) ) |
|
| 4433 | + if (isset($loop[$term_id])) |
|
| 4434 | 4434 | return 0; |
| 4435 | 4435 | |
| 4436 | 4436 | // There's a loop, but it doesn't contain $term_id. Break the loop. |
| 4437 | - foreach ( array_keys( $loop ) as $loop_member ) |
|
| 4438 | - wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) ); |
|
| 4437 | + foreach (array_keys($loop) as $loop_member) |
|
| 4438 | + wp_update_term($loop_member, $taxonomy, array('parent' => 0)); |
|
| 4439 | 4439 | |
| 4440 | 4440 | return $parent; |
| 4441 | 4441 | } |
@@ -180,8 +180,9 @@ discard block |
||
| 180 | 180 | global $wp_taxonomies; |
| 181 | 181 | |
| 182 | 182 | if ( is_object($object) ) { |
| 183 | - if ( $object->post_type == 'attachment' ) |
|
| 184 | - return get_attachment_taxonomies($object); |
|
| 183 | + if ( $object->post_type == 'attachment' ) { |
|
| 184 | + return get_attachment_taxonomies($object); |
|
| 185 | + } |
|
| 185 | 186 | $object = $object->post_type; |
| 186 | 187 | } |
| 187 | 188 | |
@@ -190,10 +191,11 @@ discard block |
||
| 190 | 191 | $taxonomies = array(); |
| 191 | 192 | foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) { |
| 192 | 193 | if ( array_intersect($object, (array) $tax_obj->object_type) ) { |
| 193 | - if ( 'names' == $output ) |
|
| 194 | - $taxonomies[] = $tax_name; |
|
| 195 | - else |
|
| 196 | - $taxonomies[ $tax_name ] = $tax_obj; |
|
| 194 | + if ( 'names' == $output ) { |
|
| 195 | + $taxonomies[] = $tax_name; |
|
| 196 | + } else { |
|
| 197 | + $taxonomies[ $tax_name ] = $tax_obj; |
|
| 198 | + } |
|
| 197 | 199 | } |
| 198 | 200 | } |
| 199 | 201 | |
@@ -216,8 +218,9 @@ discard block |
||
| 216 | 218 | function get_taxonomy( $taxonomy ) { |
| 217 | 219 | global $wp_taxonomies; |
| 218 | 220 | |
| 219 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
| 220 | - return false; |
|
| 221 | + if ( ! taxonomy_exists( $taxonomy ) ) { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 221 | 224 | |
| 222 | 225 | return $wp_taxonomies[$taxonomy]; |
| 223 | 226 | } |
@@ -254,8 +257,9 @@ discard block |
||
| 254 | 257 | * @return bool Whether the taxonomy is hierarchical. |
| 255 | 258 | */ |
| 256 | 259 | function is_taxonomy_hierarchical($taxonomy) { |
| 257 | - if ( ! taxonomy_exists($taxonomy) ) |
|
| 258 | - return false; |
|
| 260 | + if ( ! taxonomy_exists($taxonomy) ) { |
|
| 261 | + return false; |
|
| 262 | + } |
|
| 259 | 263 | |
| 260 | 264 | $taxonomy = get_taxonomy($taxonomy); |
| 261 | 265 | return $taxonomy->hierarchical; |
@@ -351,8 +355,9 @@ discard block |
||
| 351 | 355 | function register_taxonomy( $taxonomy, $object_type, $args = array() ) { |
| 352 | 356 | global $wp_taxonomies, $wp; |
| 353 | 357 | |
| 354 | - if ( ! is_array( $wp_taxonomies ) ) |
|
| 355 | - $wp_taxonomies = array(); |
|
| 358 | + if ( ! is_array( $wp_taxonomies ) ) { |
|
| 359 | + $wp_taxonomies = array(); |
|
| 360 | + } |
|
| 356 | 361 | |
| 357 | 362 | $args = wp_parse_args( $args ); |
| 358 | 363 | |
@@ -400,10 +405,11 @@ discard block |
||
| 400 | 405 | |
| 401 | 406 | // Non-publicly queryable taxonomies should not register query vars, except in the admin. |
| 402 | 407 | if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) && ! empty( $wp ) ) { |
| 403 | - if ( true === $args['query_var'] ) |
|
| 404 | - $args['query_var'] = $taxonomy; |
|
| 405 | - else |
|
| 406 | - $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); |
|
| 408 | + if ( true === $args['query_var'] ) { |
|
| 409 | + $args['query_var'] = $taxonomy; |
|
| 410 | + } else { |
|
| 411 | + $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); |
|
| 412 | + } |
|
| 407 | 413 | $wp->add_query_var( $args['query_var'] ); |
| 408 | 414 | } else { |
| 409 | 415 | // Force query_var to false for non-public taxonomies. |
@@ -417,33 +423,39 @@ discard block |
||
| 417 | 423 | 'ep_mask' => EP_NONE, |
| 418 | 424 | ) ); |
| 419 | 425 | |
| 420 | - if ( empty( $args['rewrite']['slug'] ) ) |
|
| 421 | - $args['rewrite']['slug'] = sanitize_title_with_dashes( $taxonomy ); |
|
| 426 | + if ( empty( $args['rewrite']['slug'] ) ) { |
|
| 427 | + $args['rewrite']['slug'] = sanitize_title_with_dashes( $taxonomy ); |
|
| 428 | + } |
|
| 422 | 429 | |
| 423 | - if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] ) |
|
| 424 | - $tag = '(.+?)'; |
|
| 425 | - else |
|
| 426 | - $tag = '([^/]+)'; |
|
| 430 | + if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] ) { |
|
| 431 | + $tag = '(.+?)'; |
|
| 432 | + } else { |
|
| 433 | + $tag = '([^/]+)'; |
|
| 434 | + } |
|
| 427 | 435 | |
| 428 | 436 | add_rewrite_tag( "%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=" ); |
| 429 | 437 | add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite'] ); |
| 430 | 438 | } |
| 431 | 439 | |
| 432 | 440 | // If not set, default to the setting for public. |
| 433 | - if ( null === $args['show_ui'] ) |
|
| 434 | - $args['show_ui'] = $args['public']; |
|
| 441 | + if ( null === $args['show_ui'] ) { |
|
| 442 | + $args['show_ui'] = $args['public']; |
|
| 443 | + } |
|
| 435 | 444 | |
| 436 | 445 | // If not set, default to the setting for show_ui. |
| 437 | - if ( null === $args['show_in_menu' ] || ! $args['show_ui'] ) |
|
| 438 | - $args['show_in_menu' ] = $args['show_ui']; |
|
| 446 | + if ( null === $args['show_in_menu' ] || ! $args['show_ui'] ) { |
|
| 447 | + $args['show_in_menu' ] = $args['show_ui']; |
|
| 448 | + } |
|
| 439 | 449 | |
| 440 | 450 | // If not set, default to the setting for public. |
| 441 | - if ( null === $args['show_in_nav_menus'] ) |
|
| 442 | - $args['show_in_nav_menus'] = $args['public']; |
|
| 451 | + if ( null === $args['show_in_nav_menus'] ) { |
|
| 452 | + $args['show_in_nav_menus'] = $args['public']; |
|
| 453 | + } |
|
| 443 | 454 | |
| 444 | 455 | // If not set, default to the setting for show_ui. |
| 445 | - if ( null === $args['show_tagcloud'] ) |
|
| 446 | - $args['show_tagcloud'] = $args['show_ui']; |
|
| 456 | + if ( null === $args['show_tagcloud'] ) { |
|
| 457 | + $args['show_tagcloud'] = $args['show_ui']; |
|
| 458 | + } |
|
| 447 | 459 | |
| 448 | 460 | // If not set, default to the setting for show_ui. |
| 449 | 461 | if ( null === $args['show_in_quick_edit'] ) { |
@@ -467,10 +479,11 @@ discard block |
||
| 467 | 479 | |
| 468 | 480 | // If not set, use the default meta box |
| 469 | 481 | if ( null === $args['meta_box_cb'] ) { |
| 470 | - if ( $args['hierarchical'] ) |
|
| 471 | - $args['meta_box_cb'] = 'post_categories_meta_box'; |
|
| 472 | - else |
|
| 473 | - $args['meta_box_cb'] = 'post_tags_meta_box'; |
|
| 482 | + if ( $args['hierarchical'] ) { |
|
| 483 | + $args['meta_box_cb'] = 'post_categories_meta_box'; |
|
| 484 | + } else { |
|
| 485 | + $args['meta_box_cb'] = 'post_tags_meta_box'; |
|
| 486 | + } |
|
| 474 | 487 | } |
| 475 | 488 | |
| 476 | 489 | $wp_taxonomies[ $taxonomy ] = (object) $args; |
@@ -585,11 +598,13 @@ discard block |
||
| 585 | 598 | function get_taxonomy_labels( $tax ) { |
| 586 | 599 | $tax->labels = (array) $tax->labels; |
| 587 | 600 | |
| 588 | - if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) ) |
|
| 589 | - $tax->labels['separate_items_with_commas'] = $tax->helps; |
|
| 601 | + if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) ) { |
|
| 602 | + $tax->labels['separate_items_with_commas'] = $tax->helps; |
|
| 603 | + } |
|
| 590 | 604 | |
| 591 | - if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) ) |
|
| 592 | - $tax->labels['not_found'] = $tax->no_tagcloud; |
|
| 605 | + if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) ) { |
|
| 606 | + $tax->labels['not_found'] = $tax->no_tagcloud; |
|
| 607 | + } |
|
| 593 | 608 | |
| 594 | 609 | $nohier_vs_hier_defaults = array( |
| 595 | 610 | 'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), |
@@ -653,14 +668,17 @@ discard block |
||
| 653 | 668 | function register_taxonomy_for_object_type( $taxonomy, $object_type) { |
| 654 | 669 | global $wp_taxonomies; |
| 655 | 670 | |
| 656 | - if ( !isset($wp_taxonomies[$taxonomy]) ) |
|
| 657 | - return false; |
|
| 671 | + if ( !isset($wp_taxonomies[$taxonomy]) ) { |
|
| 672 | + return false; |
|
| 673 | + } |
|
| 658 | 674 | |
| 659 | - if ( ! get_post_type_object($object_type) ) |
|
| 660 | - return false; |
|
| 675 | + if ( ! get_post_type_object($object_type) ) { |
|
| 676 | + return false; |
|
| 677 | + } |
|
| 661 | 678 | |
| 662 | - if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) ) |
|
| 663 | - $wp_taxonomies[$taxonomy]->object_type[] = $object_type; |
|
| 679 | + if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) ) { |
|
| 680 | + $wp_taxonomies[$taxonomy]->object_type[] = $object_type; |
|
| 681 | + } |
|
| 664 | 682 | |
| 665 | 683 | // Filter out empties. |
| 666 | 684 | $wp_taxonomies[ $taxonomy ]->object_type = array_filter( $wp_taxonomies[ $taxonomy ]->object_type ); |
@@ -682,15 +700,18 @@ discard block |
||
| 682 | 700 | function unregister_taxonomy_for_object_type( $taxonomy, $object_type ) { |
| 683 | 701 | global $wp_taxonomies; |
| 684 | 702 | |
| 685 | - if ( ! isset( $wp_taxonomies[ $taxonomy ] ) ) |
|
| 686 | - return false; |
|
| 703 | + if ( ! isset( $wp_taxonomies[ $taxonomy ] ) ) { |
|
| 704 | + return false; |
|
| 705 | + } |
|
| 687 | 706 | |
| 688 | - if ( ! get_post_type_object( $object_type ) ) |
|
| 689 | - return false; |
|
| 707 | + if ( ! get_post_type_object( $object_type ) ) { |
|
| 708 | + return false; |
|
| 709 | + } |
|
| 690 | 710 | |
| 691 | 711 | $key = array_search( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true ); |
| 692 | - if ( false === $key ) |
|
| 693 | - return false; |
|
| 712 | + if ( false === $key ) { |
|
| 713 | + return false; |
|
| 714 | + } |
|
| 694 | 715 | |
| 695 | 716 | unset( $wp_taxonomies[ $taxonomy ]->object_type[ $key ] ); |
| 696 | 717 | return true; |
@@ -939,8 +960,9 @@ discard block |
||
| 939 | 960 | if ( 'slug' == $field ) { |
| 940 | 961 | $_field = 't.slug'; |
| 941 | 962 | $value = sanitize_title($value); |
| 942 | - if ( empty($value) ) |
|
| 943 | - return false; |
|
| 963 | + if ( empty($value) ) { |
|
| 964 | + return false; |
|
| 965 | + } |
|
| 944 | 966 | } elseif ( 'name' == $field ) { |
| 945 | 967 | // Assume already escaped |
| 946 | 968 | $value = wp_unslash($value); |
@@ -960,8 +982,9 @@ discard block |
||
| 960 | 982 | } |
| 961 | 983 | |
| 962 | 984 | $term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE $_field = %s", $value ) . " $tax_clause LIMIT 1" ); |
| 963 | - if ( ! $term ) |
|
| 964 | - return false; |
|
| 985 | + if ( ! $term ) { |
|
| 986 | + return false; |
|
| 987 | + } |
|
| 965 | 988 | |
| 966 | 989 | // In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the db. |
| 967 | 990 | if ( 'term_taxonomy_id' === $field ) { |
@@ -996,8 +1019,9 @@ discard block |
||
| 996 | 1019 | |
| 997 | 1020 | $terms = _get_term_hierarchy($taxonomy); |
| 998 | 1021 | |
| 999 | - if ( ! isset($terms[$term_id]) ) |
|
| 1000 | - return array(); |
|
| 1022 | + if ( ! isset($terms[$term_id]) ) { |
|
| 1023 | + return array(); |
|
| 1024 | + } |
|
| 1001 | 1025 | |
| 1002 | 1026 | $children = $terms[$term_id]; |
| 1003 | 1027 | |
@@ -1006,8 +1030,9 @@ discard block |
||
| 1006 | 1030 | continue; |
| 1007 | 1031 | } |
| 1008 | 1032 | |
| 1009 | - if ( isset($terms[$child]) ) |
|
| 1010 | - $children = array_merge($children, get_term_children($child, $taxonomy)); |
|
| 1033 | + if ( isset($terms[$child]) ) { |
|
| 1034 | + $children = array_merge($children, get_term_children($child, $taxonomy)); |
|
| 1035 | + } |
|
| 1011 | 1036 | } |
| 1012 | 1037 | |
| 1013 | 1038 | return $children; |
@@ -1031,14 +1056,17 @@ discard block |
||
| 1031 | 1056 | */ |
| 1032 | 1057 | function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) { |
| 1033 | 1058 | $term = get_term( $term, $taxonomy ); |
| 1034 | - if ( is_wp_error($term) ) |
|
| 1035 | - return $term; |
|
| 1059 | + if ( is_wp_error($term) ) { |
|
| 1060 | + return $term; |
|
| 1061 | + } |
|
| 1036 | 1062 | |
| 1037 | - if ( !is_object($term) ) |
|
| 1038 | - return ''; |
|
| 1063 | + if ( !is_object($term) ) { |
|
| 1064 | + return ''; |
|
| 1065 | + } |
|
| 1039 | 1066 | |
| 1040 | - if ( !isset($term->$field) ) |
|
| 1041 | - return ''; |
|
| 1067 | + if ( !isset($term->$field) ) { |
|
| 1068 | + return ''; |
|
| 1069 | + } |
|
| 1042 | 1070 | |
| 1043 | 1071 | return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context ); |
| 1044 | 1072 | } |
@@ -1058,11 +1086,13 @@ discard block |
||
| 1058 | 1086 | function get_term_to_edit( $id, $taxonomy ) { |
| 1059 | 1087 | $term = get_term( $id, $taxonomy ); |
| 1060 | 1088 | |
| 1061 | - if ( is_wp_error($term) ) |
|
| 1062 | - return $term; |
|
| 1089 | + if ( is_wp_error($term) ) { |
|
| 1090 | + return $term; |
|
| 1091 | + } |
|
| 1063 | 1092 | |
| 1064 | - if ( !is_object($term) ) |
|
| 1065 | - return ''; |
|
| 1093 | + if ( !is_object($term) ) { |
|
| 1094 | + return ''; |
|
| 1095 | + } |
|
| 1066 | 1096 | |
| 1067 | 1097 | return sanitize_term($term, $taxonomy, 'edit'); |
| 1068 | 1098 | } |
@@ -1394,13 +1424,15 @@ discard block |
||
| 1394 | 1424 | $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
| 1395 | 1425 | |
| 1396 | 1426 | if ( is_int($term) ) { |
| 1397 | - if ( 0 == $term ) |
|
| 1398 | - return 0; |
|
| 1427 | + if ( 0 == $term ) { |
|
| 1428 | + return 0; |
|
| 1429 | + } |
|
| 1399 | 1430 | $where = 't.term_id = %d'; |
| 1400 | - if ( !empty($taxonomy) ) |
|
| 1401 | - return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A ); |
|
| 1402 | - else |
|
| 1403 | - return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) ); |
|
| 1431 | + if ( !empty($taxonomy) ) { |
|
| 1432 | + return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A ); |
|
| 1433 | + } else { |
|
| 1434 | + return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) ); |
|
| 1435 | + } |
|
| 1404 | 1436 | } |
| 1405 | 1437 | |
| 1406 | 1438 | $term = trim( wp_unslash( $term ) ); |
@@ -1424,14 +1456,16 @@ discard block |
||
| 1424 | 1456 | $where_fields[] = $taxonomy; |
| 1425 | 1457 | $else_where_fields[] = $taxonomy; |
| 1426 | 1458 | |
| 1427 | - if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A) ) |
|
| 1428 | - return $result; |
|
| 1459 | + if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A) ) { |
|
| 1460 | + return $result; |
|
| 1461 | + } |
|
| 1429 | 1462 | |
| 1430 | 1463 | return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields), ARRAY_A); |
| 1431 | 1464 | } |
| 1432 | 1465 | |
| 1433 | - if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) ) |
|
| 1434 | - return $result; |
|
| 1466 | + if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) ) { |
|
| 1467 | + return $result; |
|
| 1468 | + } |
|
| 1435 | 1469 | |
| 1436 | 1470 | return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields) ); |
| 1437 | 1471 | } |
@@ -1449,15 +1483,19 @@ discard block |
||
| 1449 | 1483 | * @return bool Whether `$term2` is a child of `$term1`. |
| 1450 | 1484 | */ |
| 1451 | 1485 | function term_is_ancestor_of( $term1, $term2, $taxonomy ) { |
| 1452 | - if ( ! isset( $term1->term_id ) ) |
|
| 1453 | - $term1 = get_term( $term1, $taxonomy ); |
|
| 1454 | - if ( ! isset( $term2->parent ) ) |
|
| 1455 | - $term2 = get_term( $term2, $taxonomy ); |
|
| 1486 | + if ( ! isset( $term1->term_id ) ) { |
|
| 1487 | + $term1 = get_term( $term1, $taxonomy ); |
|
| 1488 | + } |
|
| 1489 | + if ( ! isset( $term2->parent ) ) { |
|
| 1490 | + $term2 = get_term( $term2, $taxonomy ); |
|
| 1491 | + } |
|
| 1456 | 1492 | |
| 1457 | - if ( empty( $term1->term_id ) || empty( $term2->parent ) ) |
|
| 1458 | - return false; |
|
| 1459 | - if ( $term2->parent == $term1->term_id ) |
|
| 1460 | - return true; |
|
| 1493 | + if ( empty( $term1->term_id ) || empty( $term2->parent ) ) { |
|
| 1494 | + return false; |
|
| 1495 | + } |
|
| 1496 | + if ( $term2->parent == $term1->term_id ) { |
|
| 1497 | + return true; |
|
| 1498 | + } |
|
| 1461 | 1499 | |
| 1462 | 1500 | return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy ); |
| 1463 | 1501 | } |
@@ -1488,18 +1526,21 @@ discard block |
||
| 1488 | 1526 | |
| 1489 | 1527 | foreach ( (array) $fields as $field ) { |
| 1490 | 1528 | if ( $do_object ) { |
| 1491 | - if ( isset($term->$field) ) |
|
| 1492 | - $term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context); |
|
| 1529 | + if ( isset($term->$field) ) { |
|
| 1530 | + $term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context); |
|
| 1531 | + } |
|
| 1493 | 1532 | } else { |
| 1494 | - if ( isset($term[$field]) ) |
|
| 1495 | - $term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context); |
|
| 1533 | + if ( isset($term[$field]) ) { |
|
| 1534 | + $term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context); |
|
| 1535 | + } |
|
| 1496 | 1536 | } |
| 1497 | 1537 | } |
| 1498 | 1538 | |
| 1499 | - if ( $do_object ) |
|
| 1500 | - $term->filter = $context; |
|
| 1501 | - else |
|
| 1502 | - $term['filter'] = $context; |
|
| 1539 | + if ( $do_object ) { |
|
| 1540 | + $term->filter = $context; |
|
| 1541 | + } else { |
|
| 1542 | + $term['filter'] = $context; |
|
| 1543 | + } |
|
| 1503 | 1544 | |
| 1504 | 1545 | return $term; |
| 1505 | 1546 | } |
@@ -1531,12 +1572,14 @@ discard block |
||
| 1531 | 1572 | $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); |
| 1532 | 1573 | if ( in_array( $field, $int_fields ) ) { |
| 1533 | 1574 | $value = (int) $value; |
| 1534 | - if ( $value < 0 ) |
|
| 1535 | - $value = 0; |
|
| 1575 | + if ( $value < 0 ) { |
|
| 1576 | + $value = 0; |
|
| 1577 | + } |
|
| 1536 | 1578 | } |
| 1537 | 1579 | |
| 1538 | - if ( 'raw' == $context ) |
|
| 1539 | - return $value; |
|
| 1580 | + if ( 'raw' == $context ) { |
|
| 1581 | + return $value; |
|
| 1582 | + } |
|
| 1540 | 1583 | |
| 1541 | 1584 | if ( 'edit' == $context ) { |
| 1542 | 1585 | |
@@ -1566,10 +1609,13 @@ discard block |
||
| 1566 | 1609 | */ |
| 1567 | 1610 | $value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id ); |
| 1568 | 1611 | |
| 1569 | - if ( 'description' == $field ) |
|
| 1570 | - $value = esc_html($value); // textarea_escaped |
|
| 1571 | - else |
|
| 1572 | - $value = esc_attr($value); |
|
| 1612 | + if ( 'description' == $field ) { |
|
| 1613 | + $value = esc_html($value); |
|
| 1614 | + } |
|
| 1615 | + // textarea_escaped |
|
| 1616 | + else { |
|
| 1617 | + $value = esc_attr($value); |
|
| 1618 | + } |
|
| 1573 | 1619 | } elseif ( 'db' == $context ) { |
| 1574 | 1620 | |
| 1575 | 1621 | /** |
@@ -1717,8 +1763,9 @@ discard block |
||
| 1717 | 1763 | function wp_delete_object_term_relationships( $object_id, $taxonomies ) { |
| 1718 | 1764 | $object_id = (int) $object_id; |
| 1719 | 1765 | |
| 1720 | - if ( !is_array($taxonomies) ) |
|
| 1721 | - $taxonomies = array($taxonomies); |
|
| 1766 | + if ( !is_array($taxonomies) ) { |
|
| 1767 | + $taxonomies = array($taxonomies); |
|
| 1768 | + } |
|
| 1722 | 1769 | |
| 1723 | 1770 | foreach ( (array) $taxonomies as $taxonomy ) { |
| 1724 | 1771 | $term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) ); |
@@ -1759,10 +1806,12 @@ discard block |
||
| 1759 | 1806 | |
| 1760 | 1807 | $term = (int) $term; |
| 1761 | 1808 | |
| 1762 | - if ( ! $ids = term_exists($term, $taxonomy) ) |
|
| 1763 | - return false; |
|
| 1764 | - if ( is_wp_error( $ids ) ) |
|
| 1765 | - return $ids; |
|
| 1809 | + if ( ! $ids = term_exists($term, $taxonomy) ) { |
|
| 1810 | + return false; |
|
| 1811 | + } |
|
| 1812 | + if ( is_wp_error( $ids ) ) { |
|
| 1813 | + return $ids; |
|
| 1814 | + } |
|
| 1766 | 1815 | |
| 1767 | 1816 | $tt_id = $ids['term_taxonomy_id']; |
| 1768 | 1817 | |
@@ -1770,8 +1819,10 @@ discard block |
||
| 1770 | 1819 | |
| 1771 | 1820 | if ( 'category' == $taxonomy ) { |
| 1772 | 1821 | $defaults['default'] = get_option( 'default_category' ); |
| 1773 | - if ( $defaults['default'] == $term ) |
|
| 1774 | - return 0; // Don't delete the default category |
|
| 1822 | + if ( $defaults['default'] == $term ) { |
|
| 1823 | + return 0; |
|
| 1824 | + } |
|
| 1825 | + // Don't delete the default category |
|
| 1775 | 1826 | } |
| 1776 | 1827 | |
| 1777 | 1828 | $args = wp_parse_args($args, $defaults); |
@@ -1800,8 +1851,9 @@ discard block |
||
| 1800 | 1851 | // Update children to point to new parent |
| 1801 | 1852 | if ( is_taxonomy_hierarchical($taxonomy) ) { |
| 1802 | 1853 | $term_obj = get_term($term, $taxonomy); |
| 1803 | - if ( is_wp_error( $term_obj ) ) |
|
| 1804 | - return $term_obj; |
|
| 1854 | + if ( is_wp_error( $term_obj ) ) { |
|
| 1855 | + return $term_obj; |
|
| 1856 | + } |
|
| 1805 | 1857 | $parent = $term_obj->parent; |
| 1806 | 1858 | |
| 1807 | 1859 | $edit_ids = $wpdb->get_results( "SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id ); |
@@ -1843,8 +1895,9 @@ discard block |
||
| 1843 | 1895 | $terms = array($default); |
| 1844 | 1896 | } else { |
| 1845 | 1897 | $terms = array_diff($terms, array($term)); |
| 1846 | - if (isset($default) && isset($force_default) && $force_default) |
|
| 1847 | - $terms = array_merge($terms, array($default)); |
|
| 1898 | + if (isset($default) && isset($force_default) && $force_default) { |
|
| 1899 | + $terms = array_merge($terms, array($default)); |
|
| 1900 | + } |
|
| 1848 | 1901 | } |
| 1849 | 1902 | $terms = array_map('intval', $terms); |
| 1850 | 1903 | wp_set_object_terms( $object_id, $terms, $taxonomy ); |
@@ -1852,8 +1905,9 @@ discard block |
||
| 1852 | 1905 | |
| 1853 | 1906 | // Clean the relationship caches for all object types using this term. |
| 1854 | 1907 | $tax_object = get_taxonomy( $taxonomy ); |
| 1855 | - foreach ( $tax_object->object_type as $object_type ) |
|
| 1856 | - clean_object_term_cache( $object_ids, $object_type ); |
|
| 1908 | + foreach ( $tax_object->object_type as $object_type ) { |
|
| 1909 | + clean_object_term_cache( $object_ids, $object_type ); |
|
| 1910 | + } |
|
| 1857 | 1911 | |
| 1858 | 1912 | $term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) ); |
| 1859 | 1913 | foreach ( $term_meta_ids as $mid ) { |
@@ -1880,8 +1934,9 @@ discard block |
||
| 1880 | 1934 | do_action( 'deleted_term_taxonomy', $tt_id ); |
| 1881 | 1935 | |
| 1882 | 1936 | // Delete the term if no taxonomies use it. |
| 1883 | - if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) ) |
|
| 1884 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) ); |
|
| 1937 | + if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) ) { |
|
| 1938 | + $wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) ); |
|
| 1939 | + } |
|
| 1885 | 1940 | |
| 1886 | 1941 | clean_term_cache($term, $taxonomy); |
| 1887 | 1942 | |
@@ -1968,19 +2023,23 @@ discard block |
||
| 1968 | 2023 | function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { |
| 1969 | 2024 | global $wpdb; |
| 1970 | 2025 | |
| 1971 | - if ( empty( $object_ids ) || empty( $taxonomies ) ) |
|
| 1972 | - return array(); |
|
| 2026 | + if ( empty( $object_ids ) || empty( $taxonomies ) ) { |
|
| 2027 | + return array(); |
|
| 2028 | + } |
|
| 1973 | 2029 | |
| 1974 | - if ( !is_array($taxonomies) ) |
|
| 1975 | - $taxonomies = array($taxonomies); |
|
| 2030 | + if ( !is_array($taxonomies) ) { |
|
| 2031 | + $taxonomies = array($taxonomies); |
|
| 2032 | + } |
|
| 1976 | 2033 | |
| 1977 | 2034 | foreach ( $taxonomies as $taxonomy ) { |
| 1978 | - if ( ! taxonomy_exists($taxonomy) ) |
|
| 1979 | - return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 2035 | + if ( ! taxonomy_exists($taxonomy) ) { |
|
| 2036 | + return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 2037 | + } |
|
| 1980 | 2038 | } |
| 1981 | 2039 | |
| 1982 | - if ( !is_array($object_ids) ) |
|
| 1983 | - $object_ids = array($object_ids); |
|
| 2040 | + if ( !is_array($object_ids) ) { |
|
| 2041 | + $object_ids = array($object_ids); |
|
| 2042 | + } |
|
| 1984 | 2043 | $object_ids = array_map('intval', $object_ids); |
| 1985 | 2044 | |
| 1986 | 2045 | $defaults = array( |
@@ -2004,8 +2063,9 @@ discard block |
||
| 2004 | 2063 | } |
| 2005 | 2064 | } else { |
| 2006 | 2065 | $t = get_taxonomy($taxonomies[0]); |
| 2007 | - if ( isset($t->args) && is_array($t->args) ) |
|
| 2008 | - $args = array_merge($args, $t->args); |
|
| 2066 | + if ( isset($t->args) && is_array($t->args) ) { |
|
| 2067 | + $args = array_merge($args, $t->args); |
|
| 2068 | + } |
|
| 2009 | 2069 | } |
| 2010 | 2070 | |
| 2011 | 2071 | $orderby = $args['orderby']; |
@@ -2026,15 +2086,18 @@ discard block |
||
| 2026 | 2086 | } |
| 2027 | 2087 | |
| 2028 | 2088 | // tt_ids queries can only be none or tr.term_taxonomy_id |
| 2029 | - if ( ('tt_ids' == $fields) && !empty($orderby) ) |
|
| 2030 | - $orderby = 'tr.term_taxonomy_id'; |
|
| 2089 | + if ( ('tt_ids' == $fields) && !empty($orderby) ) { |
|
| 2090 | + $orderby = 'tr.term_taxonomy_id'; |
|
| 2091 | + } |
|
| 2031 | 2092 | |
| 2032 | - if ( !empty($orderby) ) |
|
| 2033 | - $orderby = "ORDER BY $orderby"; |
|
| 2093 | + if ( !empty($orderby) ) { |
|
| 2094 | + $orderby = "ORDER BY $orderby"; |
|
| 2095 | + } |
|
| 2034 | 2096 | |
| 2035 | 2097 | $order = strtoupper( $order ); |
| 2036 | - if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) |
|
| 2037 | - $order = 'ASC'; |
|
| 2098 | + if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) { |
|
| 2099 | + $order = 'ASC'; |
|
| 2100 | + } |
|
| 2038 | 2101 | |
| 2039 | 2102 | $taxonomy_array = $taxonomies; |
| 2040 | 2103 | $object_id_array = $object_ids; |
@@ -2478,36 +2541,42 @@ discard block |
||
| 2478 | 2541 | return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
| 2479 | 2542 | } |
| 2480 | 2543 | |
| 2481 | - if ( !is_array($terms) ) |
|
| 2482 | - $terms = array($terms); |
|
| 2544 | + if ( !is_array($terms) ) { |
|
| 2545 | + $terms = array($terms); |
|
| 2546 | + } |
|
| 2483 | 2547 | |
| 2484 | - if ( ! $append ) |
|
| 2485 | - $old_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none')); |
|
| 2486 | - else |
|
| 2487 | - $old_tt_ids = array(); |
|
| 2548 | + if ( ! $append ) { |
|
| 2549 | + $old_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none')); |
|
| 2550 | + } else { |
|
| 2551 | + $old_tt_ids = array(); |
|
| 2552 | + } |
|
| 2488 | 2553 | |
| 2489 | 2554 | $tt_ids = array(); |
| 2490 | 2555 | $term_ids = array(); |
| 2491 | 2556 | $new_tt_ids = array(); |
| 2492 | 2557 | |
| 2493 | 2558 | foreach ( (array) $terms as $term) { |
| 2494 | - if ( !strlen(trim($term)) ) |
|
| 2495 | - continue; |
|
| 2559 | + if ( !strlen(trim($term)) ) { |
|
| 2560 | + continue; |
|
| 2561 | + } |
|
| 2496 | 2562 | |
| 2497 | 2563 | if ( !$term_info = term_exists($term, $taxonomy) ) { |
| 2498 | 2564 | // Skip if a non-existent term ID is passed. |
| 2499 | - if ( is_int($term) ) |
|
| 2500 | - continue; |
|
| 2565 | + if ( is_int($term) ) { |
|
| 2566 | + continue; |
|
| 2567 | + } |
|
| 2501 | 2568 | $term_info = wp_insert_term($term, $taxonomy); |
| 2502 | 2569 | } |
| 2503 | - if ( is_wp_error($term_info) ) |
|
| 2504 | - return $term_info; |
|
| 2570 | + if ( is_wp_error($term_info) ) { |
|
| 2571 | + return $term_info; |
|
| 2572 | + } |
|
| 2505 | 2573 | $term_ids[] = $term_info['term_id']; |
| 2506 | 2574 | $tt_id = $term_info['term_taxonomy_id']; |
| 2507 | 2575 | $tt_ids[] = $tt_id; |
| 2508 | 2576 | |
| 2509 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) ) |
|
| 2510 | - continue; |
|
| 2577 | + if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) ) { |
|
| 2578 | + continue; |
|
| 2579 | + } |
|
| 2511 | 2580 | |
| 2512 | 2581 | /** |
| 2513 | 2582 | * Fires immediately before an object-term relationship is added. |
@@ -2532,8 +2601,9 @@ discard block |
||
| 2532 | 2601 | $new_tt_ids[] = $tt_id; |
| 2533 | 2602 | } |
| 2534 | 2603 | |
| 2535 | - if ( $new_tt_ids ) |
|
| 2536 | - wp_update_term_count( $new_tt_ids, $taxonomy ); |
|
| 2604 | + if ( $new_tt_ids ) { |
|
| 2605 | + wp_update_term_count( $new_tt_ids, $taxonomy ); |
|
| 2606 | + } |
|
| 2537 | 2607 | |
| 2538 | 2608 | if ( ! $append ) { |
| 2539 | 2609 | $delete_tt_ids = array_diff( $old_tt_ids, $tt_ids ); |
@@ -2555,12 +2625,14 @@ discard block |
||
| 2555 | 2625 | $values = array(); |
| 2556 | 2626 | $term_order = 0; |
| 2557 | 2627 | $final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids')); |
| 2558 | - foreach ( $tt_ids as $tt_id ) |
|
| 2559 | - if ( in_array($tt_id, $final_tt_ids) ) |
|
| 2628 | + foreach ( $tt_ids as $tt_id ) { |
|
| 2629 | + if ( in_array($tt_id, $final_tt_ids) ) |
|
| 2560 | 2630 | $values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order); |
| 2561 | - if ( $values ) |
|
| 2562 | - if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) ) |
|
| 2631 | + } |
|
| 2632 | + if ( $values ) { |
|
| 2633 | + if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) ) |
|
| 2563 | 2634 | return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error ); |
| 2635 | + } |
|
| 2564 | 2636 | } |
| 2565 | 2637 | |
| 2566 | 2638 | wp_cache_delete( $object_id, $taxonomy . '_relationships' ); |
@@ -2718,15 +2790,17 @@ discard block |
||
| 2718 | 2790 | $the_parent = $term->parent; |
| 2719 | 2791 | while ( ! empty($the_parent) ) { |
| 2720 | 2792 | $parent_term = get_term($the_parent, $term->taxonomy); |
| 2721 | - if ( is_wp_error($parent_term) || empty($parent_term) ) |
|
| 2722 | - break; |
|
| 2793 | + if ( is_wp_error($parent_term) || empty($parent_term) ) { |
|
| 2794 | + break; |
|
| 2795 | + } |
|
| 2723 | 2796 | $parent_suffix .= '-' . $parent_term->slug; |
| 2724 | 2797 | if ( ! term_exists( $slug . $parent_suffix ) ) { |
| 2725 | 2798 | break; |
| 2726 | 2799 | } |
| 2727 | 2800 | |
| 2728 | - if ( empty($parent_term->parent) ) |
|
| 2729 | - break; |
|
| 2801 | + if ( empty($parent_term->parent) ) { |
|
| 2802 | + break; |
|
| 2803 | + } |
|
| 2730 | 2804 | $the_parent = $parent_term->parent; |
| 2731 | 2805 | } |
| 2732 | 2806 | } |
@@ -2746,10 +2820,11 @@ discard block |
||
| 2746 | 2820 | if ( $parent_suffix ) { |
| 2747 | 2821 | $slug .= $parent_suffix; |
| 2748 | 2822 | } else { |
| 2749 | - if ( ! empty( $term->term_id ) ) |
|
| 2750 | - $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id ); |
|
| 2751 | - else |
|
| 2752 | - $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug ); |
|
| 2823 | + if ( ! empty( $term->term_id ) ) { |
|
| 2824 | + $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id ); |
|
| 2825 | + } else { |
|
| 2826 | + $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug ); |
|
| 2827 | + } |
|
| 2753 | 2828 | |
| 2754 | 2829 | if ( $wpdb->get_var( $query ) ) { |
| 2755 | 2830 | $num = 2; |
@@ -2904,10 +2979,11 @@ discard block |
||
| 2904 | 2979 | if ( $duplicate && $duplicate->term_id != $term_id ) { |
| 2905 | 2980 | // If an empty slug was passed or the parent changed, reset the slug to something unique. |
| 2906 | 2981 | // Otherwise, bail. |
| 2907 | - if ( $empty_slug || ( $parent != $term['parent']) ) |
|
| 2908 | - $slug = wp_unique_term_slug($slug, (object) $args); |
|
| 2909 | - else |
|
| 2910 | - return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug)); |
|
| 2982 | + if ( $empty_slug || ( $parent != $term['parent']) ) { |
|
| 2983 | + $slug = wp_unique_term_slug($slug, (object) $args); |
|
| 2984 | + } else { |
|
| 2985 | + return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug)); |
|
| 2986 | + } |
|
| 2911 | 2987 | } |
| 2912 | 2988 | |
| 2913 | 2989 | $tt_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) ); |
@@ -3037,8 +3113,9 @@ discard block |
||
| 3037 | 3113 | if ( is_bool($defer) ) { |
| 3038 | 3114 | $_defer = $defer; |
| 3039 | 3115 | // flush any deferred counts |
| 3040 | - if ( !$defer ) |
|
| 3041 | - wp_update_term_count( null, null, true ); |
|
| 3116 | + if ( !$defer ) { |
|
| 3117 | + wp_update_term_count( null, null, true ); |
|
| 3118 | + } |
|
| 3042 | 3119 | } |
| 3043 | 3120 | |
| 3044 | 3121 | return $_defer; |
@@ -3072,15 +3149,18 @@ discard block |
||
| 3072 | 3149 | } |
| 3073 | 3150 | } |
| 3074 | 3151 | |
| 3075 | - if ( empty($terms) ) |
|
| 3076 | - return false; |
|
| 3152 | + if ( empty($terms) ) { |
|
| 3153 | + return false; |
|
| 3154 | + } |
|
| 3077 | 3155 | |
| 3078 | - if ( !is_array($terms) ) |
|
| 3079 | - $terms = array($terms); |
|
| 3156 | + if ( !is_array($terms) ) { |
|
| 3157 | + $terms = array($terms); |
|
| 3158 | + } |
|
| 3080 | 3159 | |
| 3081 | 3160 | if ( wp_defer_term_counting() ) { |
| 3082 | - if ( !isset($_deferred[$taxonomy]) ) |
|
| 3083 | - $_deferred[$taxonomy] = array(); |
|
| 3161 | + if ( !isset($_deferred[$taxonomy]) ) { |
|
| 3162 | + $_deferred[$taxonomy] = array(); |
|
| 3163 | + } |
|
| 3084 | 3164 | $_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) ); |
| 3085 | 3165 | return true; |
| 3086 | 3166 | } |
@@ -3106,8 +3186,9 @@ discard block |
||
| 3106 | 3186 | } else { |
| 3107 | 3187 | $object_types = (array) $taxonomy->object_type; |
| 3108 | 3188 | foreach ( $object_types as &$object_type ) { |
| 3109 | - if ( 0 === strpos( $object_type, 'attachment:' ) ) |
|
| 3110 | - list( $object_type ) = explode( ':', $object_type ); |
|
| 3189 | + if ( 0 === strpos( $object_type, 'attachment:' ) ) { |
|
| 3190 | + list( $object_type ) = explode( ':', $object_type ); |
|
| 3191 | + } |
|
| 3111 | 3192 | } |
| 3112 | 3193 | |
| 3113 | 3194 | if ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) { |
@@ -3151,8 +3232,9 @@ discard block |
||
| 3151 | 3232 | return; |
| 3152 | 3233 | } |
| 3153 | 3234 | |
| 3154 | - if ( !is_array($object_ids) ) |
|
| 3155 | - $object_ids = array($object_ids); |
|
| 3235 | + if ( !is_array($object_ids) ) { |
|
| 3236 | + $object_ids = array($object_ids); |
|
| 3237 | + } |
|
| 3156 | 3238 | |
| 3157 | 3239 | $taxonomies = get_object_taxonomies( $object_type ); |
| 3158 | 3240 | |
@@ -3194,8 +3276,9 @@ discard block |
||
| 3194 | 3276 | return; |
| 3195 | 3277 | } |
| 3196 | 3278 | |
| 3197 | - if ( !is_array($ids) ) |
|
| 3198 | - $ids = array($ids); |
|
| 3279 | + if ( !is_array($ids) ) { |
|
| 3280 | + $ids = array($ids); |
|
| 3281 | + } |
|
| 3199 | 3282 | |
| 3200 | 3283 | $taxonomies = array(); |
| 3201 | 3284 | // If no taxonomy, assume tt_ids. |
@@ -3303,11 +3386,13 @@ discard block |
||
| 3303 | 3386 | * @return void|false False if all of the terms in `$object_ids` are already cached. |
| 3304 | 3387 | */ |
| 3305 | 3388 | function update_object_term_cache($object_ids, $object_type) { |
| 3306 | - if ( empty($object_ids) ) |
|
| 3307 | - return; |
|
| 3389 | + if ( empty($object_ids) ) { |
|
| 3390 | + return; |
|
| 3391 | + } |
|
| 3308 | 3392 | |
| 3309 | - if ( !is_array($object_ids) ) |
|
| 3310 | - $object_ids = explode(',', $object_ids); |
|
| 3393 | + if ( !is_array($object_ids) ) { |
|
| 3394 | + $object_ids = explode(',', $object_ids); |
|
| 3395 | + } |
|
| 3311 | 3396 | |
| 3312 | 3397 | $object_ids = array_map('intval', $object_ids); |
| 3313 | 3398 | |
@@ -3323,8 +3408,9 @@ discard block |
||
| 3323 | 3408 | } |
| 3324 | 3409 | } |
| 3325 | 3410 | |
| 3326 | - if ( empty( $ids ) ) |
|
| 3327 | - return false; |
|
| 3411 | + if ( empty( $ids ) ) { |
|
| 3412 | + return false; |
|
| 3413 | + } |
|
| 3328 | 3414 | |
| 3329 | 3415 | $terms = wp_get_object_terms( $ids, $taxonomies, array( |
| 3330 | 3416 | 'fields' => 'all_with_object_id', |
@@ -3340,8 +3426,9 @@ discard block |
||
| 3340 | 3426 | foreach ( $ids as $id ) { |
| 3341 | 3427 | foreach ( $taxonomies as $taxonomy ) { |
| 3342 | 3428 | if ( ! isset($object_terms[$id][$taxonomy]) ) { |
| 3343 | - if ( !isset($object_terms[$id]) ) |
|
| 3344 | - $object_terms[$id] = array(); |
|
| 3429 | + if ( !isset($object_terms[$id]) ) { |
|
| 3430 | + $object_terms[$id] = array(); |
|
| 3431 | + } |
|
| 3345 | 3432 | $object_terms[$id][$taxonomy] = array(); |
| 3346 | 3433 | } |
| 3347 | 3434 | } |
@@ -3388,17 +3475,20 @@ discard block |
||
| 3388 | 3475 | * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs. |
| 3389 | 3476 | */ |
| 3390 | 3477 | function _get_term_hierarchy( $taxonomy ) { |
| 3391 | - if ( !is_taxonomy_hierarchical($taxonomy) ) |
|
| 3392 | - return array(); |
|
| 3478 | + if ( !is_taxonomy_hierarchical($taxonomy) ) { |
|
| 3479 | + return array(); |
|
| 3480 | + } |
|
| 3393 | 3481 | $children = get_option("{$taxonomy}_children"); |
| 3394 | 3482 | |
| 3395 | - if ( is_array($children) ) |
|
| 3396 | - return $children; |
|
| 3483 | + if ( is_array($children) ) { |
|
| 3484 | + return $children; |
|
| 3485 | + } |
|
| 3397 | 3486 | $children = array(); |
| 3398 | 3487 | $terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent')); |
| 3399 | 3488 | foreach ( $terms as $term_id => $parent ) { |
| 3400 | - if ( $parent > 0 ) |
|
| 3401 | - $children[$parent][] = $term_id; |
|
| 3489 | + if ( $parent > 0 ) { |
|
| 3490 | + $children[$parent][] = $term_id; |
|
| 3491 | + } |
|
| 3402 | 3492 | } |
| 3403 | 3493 | update_option("{$taxonomy}_children", $children); |
| 3404 | 3494 | |
@@ -3426,14 +3516,16 @@ discard block |
||
| 3426 | 3516 | */ |
| 3427 | 3517 | function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) { |
| 3428 | 3518 | $empty_array = array(); |
| 3429 | - if ( empty($terms) ) |
|
| 3430 | - return $empty_array; |
|
| 3519 | + if ( empty($terms) ) { |
|
| 3520 | + return $empty_array; |
|
| 3521 | + } |
|
| 3431 | 3522 | |
| 3432 | 3523 | $term_list = array(); |
| 3433 | 3524 | $has_children = _get_term_hierarchy($taxonomy); |
| 3434 | 3525 | |
| 3435 | - if ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) |
|
| 3436 | - return $empty_array; |
|
| 3526 | + if ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) { |
|
| 3527 | + return $empty_array; |
|
| 3528 | + } |
|
| 3437 | 3529 | |
| 3438 | 3530 | // Include the term itself in the ancestors array, so we can properly detect when a loop has occurred. |
| 3439 | 3531 | if ( empty( $ancestors ) ) { |
@@ -3444,8 +3536,9 @@ discard block |
||
| 3444 | 3536 | $use_id = false; |
| 3445 | 3537 | if ( !is_object($term) ) { |
| 3446 | 3538 | $term = get_term($term, $taxonomy); |
| 3447 | - if ( is_wp_error( $term ) ) |
|
| 3448 | - return $term; |
|
| 3539 | + if ( is_wp_error( $term ) ) { |
|
| 3540 | + return $term; |
|
| 3541 | + } |
|
| 3449 | 3542 | $use_id = true; |
| 3450 | 3543 | } |
| 3451 | 3544 | |
@@ -3455,18 +3548,21 @@ discard block |
||
| 3455 | 3548 | } |
| 3456 | 3549 | |
| 3457 | 3550 | if ( $term->parent == $term_id ) { |
| 3458 | - if ( $use_id ) |
|
| 3459 | - $term_list[] = $term->term_id; |
|
| 3460 | - else |
|
| 3461 | - $term_list[] = $term; |
|
| 3551 | + if ( $use_id ) { |
|
| 3552 | + $term_list[] = $term->term_id; |
|
| 3553 | + } else { |
|
| 3554 | + $term_list[] = $term; |
|
| 3555 | + } |
|
| 3462 | 3556 | |
| 3463 | - if ( !isset($has_children[$term->term_id]) ) |
|
| 3464 | - continue; |
|
| 3557 | + if ( !isset($has_children[$term->term_id]) ) { |
|
| 3558 | + continue; |
|
| 3559 | + } |
|
| 3465 | 3560 | |
| 3466 | 3561 | $ancestors[ $term->term_id ] = 1; |
| 3467 | 3562 | |
| 3468 | - if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) ) |
|
| 3469 | - $term_list = array_merge($term_list, $children); |
|
| 3563 | + if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) ) { |
|
| 3564 | + $term_list = array_merge($term_list, $children); |
|
| 3565 | + } |
|
| 3470 | 3566 | } |
| 3471 | 3567 | } |
| 3472 | 3568 | |
@@ -3491,13 +3587,15 @@ discard block |
||
| 3491 | 3587 | global $wpdb; |
| 3492 | 3588 | |
| 3493 | 3589 | // This function only works for hierarchical taxonomies like post categories. |
| 3494 | - if ( !is_taxonomy_hierarchical( $taxonomy ) ) |
|
| 3495 | - return; |
|
| 3590 | + if ( !is_taxonomy_hierarchical( $taxonomy ) ) { |
|
| 3591 | + return; |
|
| 3592 | + } |
|
| 3496 | 3593 | |
| 3497 | 3594 | $term_hier = _get_term_hierarchy($taxonomy); |
| 3498 | 3595 | |
| 3499 | - if ( empty($term_hier) ) |
|
| 3500 | - return; |
|
| 3596 | + if ( empty($term_hier) ) { |
|
| 3597 | + return; |
|
| 3598 | + } |
|
| 3501 | 3599 | |
| 3502 | 3600 | $term_items = array(); |
| 3503 | 3601 | $terms_by_id = array(); |
@@ -3523,9 +3621,10 @@ discard block |
||
| 3523 | 3621 | $ancestors = array(); |
| 3524 | 3622 | while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) { |
| 3525 | 3623 | $ancestors[] = $child; |
| 3526 | - if ( !empty( $term_items[$term_id] ) ) |
|
| 3527 | - foreach ( $term_items[$term_id] as $item_id => $touches ) { |
|
| 3624 | + if ( !empty( $term_items[$term_id] ) ) { |
|
| 3625 | + foreach ( $term_items[$term_id] as $item_id => $touches ) { |
|
| 3528 | 3626 | $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1; |
| 3627 | + } |
|
| 3529 | 3628 | } |
| 3530 | 3629 | $child = $parent; |
| 3531 | 3630 | |
@@ -3536,10 +3635,11 @@ discard block |
||
| 3536 | 3635 | } |
| 3537 | 3636 | |
| 3538 | 3637 | // Transfer the touched cells. |
| 3539 | - foreach ( (array) $term_items as $id => $items ) |
|
| 3540 | - if ( isset($terms_by_id[$id]) ) |
|
| 3638 | + foreach ( (array) $term_items as $id => $items ) { |
|
| 3639 | + if ( isset($terms_by_id[$id]) ) |
|
| 3541 | 3640 | $terms_by_id[$id]->count = count($items); |
| 3542 | -} |
|
| 3641 | + } |
|
| 3642 | + } |
|
| 3543 | 3643 | |
| 3544 | 3644 | /** |
| 3545 | 3645 | * Adds any terms from the given IDs to the cache that do not already exist in cache. |
@@ -3590,8 +3690,9 @@ discard block |
||
| 3590 | 3690 | |
| 3591 | 3691 | $object_types = (array) $taxonomy->object_type; |
| 3592 | 3692 | |
| 3593 | - foreach ( $object_types as &$object_type ) |
|
| 3594 | - list( $object_type ) = explode( ':', $object_type ); |
|
| 3693 | + foreach ( $object_types as &$object_type ) { |
|
| 3694 | + list( $object_type ) = explode( ':', $object_type ); |
|
| 3695 | + } |
|
| 3595 | 3696 | |
| 3596 | 3697 | $object_types = array_unique( $object_types ); |
| 3597 | 3698 | |
@@ -3600,18 +3701,21 @@ discard block |
||
| 3600 | 3701 | $check_attachments = true; |
| 3601 | 3702 | } |
| 3602 | 3703 | |
| 3603 | - if ( $object_types ) |
|
| 3604 | - $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) ); |
|
| 3704 | + if ( $object_types ) { |
|
| 3705 | + $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) ); |
|
| 3706 | + } |
|
| 3605 | 3707 | |
| 3606 | 3708 | foreach ( (array) $terms as $term ) { |
| 3607 | 3709 | $count = 0; |
| 3608 | 3710 | |
| 3609 | 3711 | // Attachments can be 'inherit' status, we need to base count off the parent's status if so. |
| 3610 | - if ( $check_attachments ) |
|
| 3611 | - $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) ); |
|
| 3712 | + if ( $check_attachments ) { |
|
| 3713 | + $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) ); |
|
| 3714 | + } |
|
| 3612 | 3715 | |
| 3613 | - if ( $object_types ) |
|
| 3614 | - $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) ); |
|
| 3716 | + if ( $object_types ) { |
|
| 3717 | + $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) ); |
|
| 3718 | + } |
|
| 3615 | 3719 | |
| 3616 | 3720 | /** This action is documented in wp-includes/taxonomy.php */ |
| 3617 | 3721 | do_action( 'edit_term_taxonomy', $term, $taxonomy->name ); |
@@ -4066,11 +4170,13 @@ discard block |
||
| 4066 | 4170 | } |
| 4067 | 4171 | } |
| 4068 | 4172 | |
| 4069 | - if ( !is_object($term) ) |
|
| 4070 | - $term = new WP_Error('invalid_term', __('Empty Term')); |
|
| 4173 | + if ( !is_object($term) ) { |
|
| 4174 | + $term = new WP_Error('invalid_term', __('Empty Term')); |
|
| 4175 | + } |
|
| 4071 | 4176 | |
| 4072 | - if ( is_wp_error( $term ) ) |
|
| 4073 | - return $term; |
|
| 4177 | + if ( is_wp_error( $term ) ) { |
|
| 4178 | + return $term; |
|
| 4179 | + } |
|
| 4074 | 4180 | |
| 4075 | 4181 | $taxonomy = $term->taxonomy; |
| 4076 | 4182 | |
@@ -4080,12 +4186,13 @@ discard block |
||
| 4080 | 4186 | $t = get_taxonomy($taxonomy); |
| 4081 | 4187 | |
| 4082 | 4188 | if ( empty($termlink) ) { |
| 4083 | - if ( 'category' == $taxonomy ) |
|
| 4084 | - $termlink = '?cat=' . $term->term_id; |
|
| 4085 | - elseif ( $t->query_var ) |
|
| 4086 | - $termlink = "?$t->query_var=$slug"; |
|
| 4087 | - else |
|
| 4088 | - $termlink = "?taxonomy=$taxonomy&term=$slug"; |
|
| 4189 | + if ( 'category' == $taxonomy ) { |
|
| 4190 | + $termlink = '?cat=' . $term->term_id; |
|
| 4191 | + } elseif ( $t->query_var ) { |
|
| 4192 | + $termlink = "?$t->query_var=$slug"; |
|
| 4193 | + } else { |
|
| 4194 | + $termlink = "?taxonomy=$taxonomy&term=$slug"; |
|
| 4195 | + } |
|
| 4089 | 4196 | $termlink = home_url($termlink); |
| 4090 | 4197 | } else { |
| 4091 | 4198 | if ( $t->rewrite['hierarchical'] ) { |
@@ -4268,8 +4375,9 @@ discard block |
||
| 4268 | 4375 | * @return bool|WP_Error WP_Error on input error. |
| 4269 | 4376 | */ |
| 4270 | 4377 | function is_object_in_term( $object_id, $taxonomy, $terms = null ) { |
| 4271 | - if ( !$object_id = (int) $object_id ) |
|
| 4272 | - return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) ); |
|
| 4378 | + if ( !$object_id = (int) $object_id ) { |
|
| 4379 | + return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) ); |
|
| 4380 | + } |
|
| 4273 | 4381 | |
| 4274 | 4382 | $object_terms = get_object_term_cache( $object_id, $taxonomy ); |
| 4275 | 4383 | if ( false === $object_terms ) { |
@@ -4277,19 +4385,23 @@ discard block |
||
| 4277 | 4385 | wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" ); |
| 4278 | 4386 | } |
| 4279 | 4387 | |
| 4280 | - if ( is_wp_error( $object_terms ) ) |
|
| 4281 | - return $object_terms; |
|
| 4282 | - if ( empty( $object_terms ) ) |
|
| 4283 | - return false; |
|
| 4284 | - if ( empty( $terms ) ) |
|
| 4285 | - return ( !empty( $object_terms ) ); |
|
| 4388 | + if ( is_wp_error( $object_terms ) ) { |
|
| 4389 | + return $object_terms; |
|
| 4390 | + } |
|
| 4391 | + if ( empty( $object_terms ) ) { |
|
| 4392 | + return false; |
|
| 4393 | + } |
|
| 4394 | + if ( empty( $terms ) ) { |
|
| 4395 | + return ( !empty( $object_terms ) ); |
|
| 4396 | + } |
|
| 4286 | 4397 | |
| 4287 | 4398 | $terms = (array) $terms; |
| 4288 | 4399 | |
| 4289 | - if ( $ints = array_filter( $terms, 'is_int' ) ) |
|
| 4290 | - $strs = array_diff( $terms, $ints ); |
|
| 4291 | - else |
|
| 4292 | - $strs =& $terms; |
|
| 4400 | + if ( $ints = array_filter( $terms, 'is_int' ) ) { |
|
| 4401 | + $strs = array_diff( $terms, $ints ); |
|
| 4402 | + } else { |
|
| 4403 | + $strs =& $terms; |
|
| 4404 | + } |
|
| 4293 | 4405 | |
| 4294 | 4406 | foreach ( $object_terms as $object_term ) { |
| 4295 | 4407 | // If term is an int, check against term_ids only. |
@@ -4304,8 +4416,12 @@ discard block |
||
| 4304 | 4416 | return true; |
| 4305 | 4417 | } |
| 4306 | 4418 | |
| 4307 | - if ( in_array( $object_term->name, $strs ) ) return true; |
|
| 4308 | - if ( in_array( $object_term->slug, $strs ) ) return true; |
|
| 4419 | + if ( in_array( $object_term->name, $strs ) ) { |
|
| 4420 | + return true; |
|
| 4421 | + } |
|
| 4422 | + if ( in_array( $object_term->slug, $strs ) ) { |
|
| 4423 | + return true; |
|
| 4424 | + } |
|
| 4309 | 4425 | } |
| 4310 | 4426 | } |
| 4311 | 4427 | |
@@ -4418,24 +4534,30 @@ discard block |
||
| 4418 | 4534 | */ |
| 4419 | 4535 | function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) { |
| 4420 | 4536 | // Nothing fancy here - bail |
| 4421 | - if ( !$parent ) |
|
| 4422 | - return 0; |
|
| 4537 | + if ( !$parent ) { |
|
| 4538 | + return 0; |
|
| 4539 | + } |
|
| 4423 | 4540 | |
| 4424 | 4541 | // Can't be its own parent. |
| 4425 | - if ( $parent == $term_id ) |
|
| 4426 | - return 0; |
|
| 4542 | + if ( $parent == $term_id ) { |
|
| 4543 | + return 0; |
|
| 4544 | + } |
|
| 4427 | 4545 | |
| 4428 | 4546 | // Now look for larger loops. |
| 4429 | - if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) ) |
|
| 4430 | - return $parent; // No loop |
|
| 4547 | + if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) ) { |
|
| 4548 | + return $parent; |
|
| 4549 | + } |
|
| 4550 | + // No loop |
|
| 4431 | 4551 | |
| 4432 | 4552 | // Setting $parent to the given value causes a loop. |
| 4433 | - if ( isset( $loop[$term_id] ) ) |
|
| 4434 | - return 0; |
|
| 4553 | + if ( isset( $loop[$term_id] ) ) { |
|
| 4554 | + return 0; |
|
| 4555 | + } |
|
| 4435 | 4556 | |
| 4436 | 4557 | // There's a loop, but it doesn't contain $term_id. Break the loop. |
| 4437 | - foreach ( array_keys( $loop ) as $loop_member ) |
|
| 4438 | - wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) ); |
|
| 4558 | + foreach ( array_keys( $loop ) as $loop_member ) { |
|
| 4559 | + wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) ); |
|
| 4560 | + } |
|
| 4439 | 4561 | |
| 4440 | 4562 | return $parent; |
| 4441 | 4563 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @param string $name The name of the specialised header. |
| 21 | 21 | */ |
| 22 | -function get_header( $name = null ) { |
|
| 22 | +function get_header($name = null) { |
|
| 23 | 23 | /** |
| 24 | 24 | * Fires before the header template file is loaded. |
| 25 | 25 | * |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param string $name Name of the specific header file to use. |
| 34 | 34 | */ |
| 35 | - do_action( 'get_header', $name ); |
|
| 35 | + do_action('get_header', $name); |
|
| 36 | 36 | |
| 37 | 37 | $templates = array(); |
| 38 | 38 | $name = (string) $name; |
| 39 | - if ( '' !== $name ) { |
|
| 39 | + if ('' !== $name) { |
|
| 40 | 40 | $templates[] = "header-{$name}.php"; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $templates[] = 'header.php'; |
| 44 | 44 | |
| 45 | - locate_template( $templates, true ); |
|
| 45 | + locate_template($templates, true); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param string $name The name of the specialised footer. |
| 60 | 60 | */ |
| 61 | -function get_footer( $name = null ) { |
|
| 61 | +function get_footer($name = null) { |
|
| 62 | 62 | /** |
| 63 | 63 | * Fires before the footer template file is loaded. |
| 64 | 64 | * |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @param string $name Name of the specific footer file to use. |
| 73 | 73 | */ |
| 74 | - do_action( 'get_footer', $name ); |
|
| 74 | + do_action('get_footer', $name); |
|
| 75 | 75 | |
| 76 | 76 | $templates = array(); |
| 77 | 77 | $name = (string) $name; |
| 78 | - if ( '' !== $name ) { |
|
| 78 | + if ('' !== $name) { |
|
| 79 | 79 | $templates[] = "footer-{$name}.php"; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $templates[] = 'footer.php'; |
|
| 82 | + $templates[] = 'footer.php'; |
|
| 83 | 83 | |
| 84 | - locate_template( $templates, true ); |
|
| 84 | + locate_template($templates, true); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @param string $name The name of the specialised sidebar. |
| 99 | 99 | */ |
| 100 | -function get_sidebar( $name = null ) { |
|
| 100 | +function get_sidebar($name = null) { |
|
| 101 | 101 | /** |
| 102 | 102 | * Fires before the sidebar template file is loaded. |
| 103 | 103 | * |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @param string $name Name of the specific sidebar file to use. |
| 112 | 112 | */ |
| 113 | - do_action( 'get_sidebar', $name ); |
|
| 113 | + do_action('get_sidebar', $name); |
|
| 114 | 114 | |
| 115 | 115 | $templates = array(); |
| 116 | 116 | $name = (string) $name; |
| 117 | - if ( '' !== $name ) |
|
| 117 | + if ('' !== $name) |
|
| 118 | 118 | $templates[] = "sidebar-{$name}.php"; |
| 119 | 119 | |
| 120 | 120 | $templates[] = 'sidebar.php'; |
| 121 | 121 | |
| 122 | - locate_template( $templates, true ); |
|
| 122 | + locate_template($templates, true); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param string $slug The slug name for the generic template. |
| 144 | 144 | * @param string $name The name of the specialised template. |
| 145 | 145 | */ |
| 146 | -function get_template_part( $slug, $name = null ) { |
|
| 146 | +function get_template_part($slug, $name = null) { |
|
| 147 | 147 | /** |
| 148 | 148 | * Fires before the specified template part file is loaded. |
| 149 | 149 | * |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | * @param string $slug The slug name for the generic template. |
| 156 | 156 | * @param string $name The name of the specialized template. |
| 157 | 157 | */ |
| 158 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
| 158 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
| 159 | 159 | |
| 160 | 160 | $templates = array(); |
| 161 | 161 | $name = (string) $name; |
| 162 | - if ( '' !== $name ) |
|
| 162 | + if ('' !== $name) |
|
| 163 | 163 | $templates[] = "{$slug}-{$name}.php"; |
| 164 | 164 | |
| 165 | 165 | $templates[] = "{$slug}.php"; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param bool $echo Default to echo and not return the form. |
| 190 | 190 | * @return string|void String when $echo is false. |
| 191 | 191 | */ |
| 192 | -function get_search_form( $echo = true ) { |
|
| 192 | +function get_search_form($echo = true) { |
|
| 193 | 193 | /** |
| 194 | 194 | * Fires before the search form is retrieved, at the start of get_search_form(). |
| 195 | 195 | * |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @link https://core.trac.wordpress.org/ticket/19321 |
| 200 | 200 | */ |
| 201 | - do_action( 'pre_get_search_form' ); |
|
| 201 | + do_action('pre_get_search_form'); |
|
| 202 | 202 | |
| 203 | - $format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml'; |
|
| 203 | + $format = current_theme_supports('html5', 'search-form') ? 'html5' : 'xhtml'; |
|
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Filters the HTML format of the search form. |
@@ -210,28 +210,28 @@ discard block |
||
| 210 | 210 | * @param string $format The type of markup to use in the search form. |
| 211 | 211 | * Accepts 'html5', 'xhtml'. |
| 212 | 212 | */ |
| 213 | - $format = apply_filters( 'search_form_format', $format ); |
|
| 213 | + $format = apply_filters('search_form_format', $format); |
|
| 214 | 214 | |
| 215 | - $search_form_template = locate_template( 'searchform.php' ); |
|
| 216 | - if ( '' != $search_form_template ) { |
|
| 215 | + $search_form_template = locate_template('searchform.php'); |
|
| 216 | + if ('' != $search_form_template) { |
|
| 217 | 217 | ob_start(); |
| 218 | - require( $search_form_template ); |
|
| 218 | + require($search_form_template); |
|
| 219 | 219 | $form = ob_get_clean(); |
| 220 | 220 | } else { |
| 221 | - if ( 'html5' == $format ) { |
|
| 222 | - $form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '"> |
|
| 221 | + if ('html5' == $format) { |
|
| 222 | + $form = '<form role="search" method="get" class="search-form" action="'.esc_url(home_url('/')).'"> |
|
| 223 | 223 | <label> |
| 224 | - <span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span> |
|
| 225 | - <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" /> |
|
| 224 | + <span class="screen-reader-text">' . _x('Search for:', 'label').'</span> |
|
| 225 | + <input type="search" class="search-field" placeholder="' . esc_attr_x('Search …', 'placeholder').'" value="'.get_search_query().'" name="s" /> |
|
| 226 | 226 | </label> |
| 227 | - <input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" /> |
|
| 227 | + <input type="submit" class="search-submit" value="'. esc_attr_x('Search', 'submit button').'" /> |
|
| 228 | 228 | </form>'; |
| 229 | 229 | } else { |
| 230 | - $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '"> |
|
| 230 | + $form = '<form role="search" method="get" id="searchform" class="searchform" action="'.esc_url(home_url('/')).'"> |
|
| 231 | 231 | <div> |
| 232 | - <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label> |
|
| 233 | - <input type="text" value="' . get_search_query() . '" name="s" id="s" /> |
|
| 234 | - <input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" /> |
|
| 232 | + <label class="screen-reader-text" for="s">' . _x('Search for:', 'label').'</label> |
|
| 233 | + <input type="text" value="' . get_search_query().'" name="s" id="s" /> |
|
| 234 | + <input type="submit" id="searchsubmit" value="'. esc_attr_x('Search', 'submit button').'" /> |
|
| 235 | 235 | </div> |
| 236 | 236 | </form>'; |
| 237 | 237 | } |
@@ -244,12 +244,12 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @param string $form The search form HTML output. |
| 246 | 246 | */ |
| 247 | - $result = apply_filters( 'get_search_form', $form ); |
|
| 247 | + $result = apply_filters('get_search_form', $form); |
|
| 248 | 248 | |
| 249 | - if ( null === $result ) |
|
| 249 | + if (null === $result) |
|
| 250 | 250 | $result = $form; |
| 251 | 251 | |
| 252 | - if ( $echo ) |
|
| 252 | + if ($echo) |
|
| 253 | 253 | echo $result; |
| 254 | 254 | else |
| 255 | 255 | return $result; |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | * @return string|void String when retrieving. |
| 269 | 269 | */ |
| 270 | 270 | function wp_loginout($redirect = '', $echo = true) { |
| 271 | - if ( ! is_user_logged_in() ) |
|
| 272 | - $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>'; |
|
| 271 | + if ( ! is_user_logged_in()) |
|
| 272 | + $link = '<a href="'.esc_url(wp_login_url($redirect)).'">'.__('Log in').'</a>'; |
|
| 273 | 273 | else |
| 274 | - $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>'; |
|
| 274 | + $link = '<a href="'.esc_url(wp_logout_url($redirect)).'">'.__('Log out').'</a>'; |
|
| 275 | 275 | |
| 276 | - if ( $echo ) { |
|
| 276 | + if ($echo) { |
|
| 277 | 277 | /** |
| 278 | 278 | * Filters the HTML output for the Log In/Log Out link. |
| 279 | 279 | * |
@@ -281,10 +281,10 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @param string $link The HTML link content. |
| 283 | 283 | */ |
| 284 | - echo apply_filters( 'loginout', $link ); |
|
| 284 | + echo apply_filters('loginout', $link); |
|
| 285 | 285 | } else { |
| 286 | 286 | /** This filter is documented in wp-includes/general-template.php */ |
| 287 | - return apply_filters( 'loginout', $link ); |
|
| 287 | + return apply_filters('loginout', $link); |
|
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | |
@@ -299,13 +299,13 @@ discard block |
||
| 299 | 299 | * @return string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url(). |
| 300 | 300 | */ |
| 301 | 301 | function wp_logout_url($redirect = '') { |
| 302 | - $args = array( 'action' => 'logout' ); |
|
| 303 | - if ( !empty($redirect) ) { |
|
| 304 | - $args['redirect_to'] = urlencode( $redirect ); |
|
| 302 | + $args = array('action' => 'logout'); |
|
| 303 | + if ( ! empty($redirect)) { |
|
| 304 | + $args['redirect_to'] = urlencode($redirect); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | $logout_url = add_query_arg($args, site_url('wp-login.php', 'login')); |
| 308 | - $logout_url = wp_nonce_url( $logout_url, 'log-out' ); |
|
| 308 | + $logout_url = wp_nonce_url($logout_url, 'log-out'); |
|
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | 311 | * Filters the logout URL. |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @param string $logout_url The HTML-encoded logout URL. |
| 316 | 316 | * @param string $redirect Path to redirect to on logout. |
| 317 | 317 | */ |
| 318 | - return apply_filters( 'logout_url', $logout_url, $redirect ); |
|
| 318 | + return apply_filters('logout_url', $logout_url, $redirect); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -331,10 +331,10 @@ discard block |
||
| 331 | 331 | function wp_login_url($redirect = '', $force_reauth = false) { |
| 332 | 332 | $login_url = site_url('wp-login.php', 'login'); |
| 333 | 333 | |
| 334 | - if ( !empty($redirect) ) |
|
| 334 | + if ( ! empty($redirect)) |
|
| 335 | 335 | $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url); |
| 336 | 336 | |
| 337 | - if ( $force_reauth ) |
|
| 337 | + if ($force_reauth) |
|
| 338 | 338 | $login_url = add_query_arg('reauth', '1', $login_url); |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @param string $redirect The path to redirect to on login, if supplied. |
| 348 | 348 | * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. |
| 349 | 349 | */ |
| 350 | - return apply_filters( 'login_url', $login_url, $redirect, $force_reauth ); |
|
| 350 | + return apply_filters('login_url', $login_url, $redirect, $force_reauth); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @param string $register The user registration URL. |
| 367 | 367 | */ |
| 368 | - return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) ); |
|
| 368 | + return apply_filters('register_url', site_url('wp-login.php?action=register', 'login')); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -399,16 +399,16 @@ discard block |
||
| 399 | 399 | * } |
| 400 | 400 | * @return string|void String when retrieving. |
| 401 | 401 | */ |
| 402 | -function wp_login_form( $args = array() ) { |
|
| 402 | +function wp_login_form($args = array()) { |
|
| 403 | 403 | $defaults = array( |
| 404 | 404 | 'echo' => true, |
| 405 | 405 | // Default 'redirect' value takes the user back to the request URI. |
| 406 | - 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], |
|
| 406 | + 'redirect' => (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], |
|
| 407 | 407 | 'form_id' => 'loginform', |
| 408 | - 'label_username' => __( 'Username or Email' ), |
|
| 409 | - 'label_password' => __( 'Password' ), |
|
| 410 | - 'label_remember' => __( 'Remember Me' ), |
|
| 411 | - 'label_log_in' => __( 'Log In' ), |
|
| 408 | + 'label_username' => __('Username or Email'), |
|
| 409 | + 'label_password' => __('Password'), |
|
| 410 | + 'label_remember' => __('Remember Me'), |
|
| 411 | + 'label_log_in' => __('Log In'), |
|
| 412 | 412 | 'id_username' => 'user_login', |
| 413 | 413 | 'id_password' => 'user_pass', |
| 414 | 414 | 'id_remember' => 'rememberme', |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * |
| 429 | 429 | * @param array $defaults An array of default login form arguments. |
| 430 | 430 | */ |
| 431 | - $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) ); |
|
| 431 | + $args = wp_parse_args($args, apply_filters('login_form_defaults', $defaults)); |
|
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | 434 | * Filters content to display at the top of the login form. |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | * @param string $content Content to display. Default empty. |
| 441 | 441 | * @param array $args Array of login form arguments. |
| 442 | 442 | */ |
| 443 | - $login_form_top = apply_filters( 'login_form_top', '', $args ); |
|
| 443 | + $login_form_top = apply_filters('login_form_top', '', $args); |
|
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | 446 | * Filters content to display in the middle of the login form. |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | * @param string $content Content to display. Default empty. |
| 454 | 454 | * @param array $args Array of login form arguments. |
| 455 | 455 | */ |
| 456 | - $login_form_middle = apply_filters( 'login_form_middle', '', $args ); |
|
| 456 | + $login_form_middle = apply_filters('login_form_middle', '', $args); |
|
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | 459 | * Filters content to display at the bottom of the login form. |
@@ -465,29 +465,29 @@ discard block |
||
| 465 | 465 | * @param string $content Content to display. Default empty. |
| 466 | 466 | * @param array $args Array of login form arguments. |
| 467 | 467 | */ |
| 468 | - $login_form_bottom = apply_filters( 'login_form_bottom', '', $args ); |
|
| 468 | + $login_form_bottom = apply_filters('login_form_bottom', '', $args); |
|
| 469 | 469 | |
| 470 | 470 | $form = ' |
| 471 | - <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post"> |
|
| 472 | - ' . $login_form_top . ' |
|
| 471 | + <form name="' . $args['form_id'].'" id="'.$args['form_id'].'" action="'.esc_url(site_url('wp-login.php', 'login_post')).'" method="post"> |
|
| 472 | + ' . $login_form_top.' |
|
| 473 | 473 | <p class="login-username"> |
| 474 | - <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label> |
|
| 475 | - <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" /> |
|
| 474 | + <label for="' . esc_attr($args['id_username']).'">'.esc_html($args['label_username']).'</label> |
|
| 475 | + <input type="text" name="log" id="' . esc_attr($args['id_username']).'" class="input" value="'.esc_attr($args['value_username']).'" size="20" /> |
|
| 476 | 476 | </p> |
| 477 | 477 | <p class="login-password"> |
| 478 | - <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label> |
|
| 479 | - <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" /> |
|
| 478 | + <label for="' . esc_attr($args['id_password']).'">'.esc_html($args['label_password']).'</label> |
|
| 479 | + <input type="password" name="pwd" id="' . esc_attr($args['id_password']).'" class="input" value="" size="20" /> |
|
| 480 | 480 | </p> |
| 481 | - ' . $login_form_middle . ' |
|
| 482 | - ' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . ' |
|
| 481 | + ' . $login_form_middle.' |
|
| 482 | + ' . ($args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="'.esc_attr($args['id_remember']).'" value="forever"'.($args['value_remember'] ? ' checked="checked"' : '').' /> '.esc_html($args['label_remember']).'</label></p>' : '').' |
|
| 483 | 483 | <p class="login-submit"> |
| 484 | - <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" /> |
|
| 485 | - <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" /> |
|
| 484 | + <input type="submit" name="wp-submit" id="' . esc_attr($args['id_submit']).'" class="button-primary" value="'.esc_attr($args['label_log_in']).'" /> |
|
| 485 | + <input type="hidden" name="redirect_to" value="' . esc_url($args['redirect']).'" /> |
|
| 486 | 486 | </p> |
| 487 | - ' . $login_form_bottom . ' |
|
| 487 | + ' . $login_form_bottom.' |
|
| 488 | 488 | </form>'; |
| 489 | 489 | |
| 490 | - if ( $args['echo'] ) |
|
| 490 | + if ($args['echo']) |
|
| 491 | 491 | echo $form; |
| 492 | 492 | else |
| 493 | 493 | return $form; |
@@ -501,13 +501,13 @@ discard block |
||
| 501 | 501 | * @param string $redirect Path to redirect to on login. |
| 502 | 502 | * @return string Lost password URL. |
| 503 | 503 | */ |
| 504 | -function wp_lostpassword_url( $redirect = '' ) { |
|
| 505 | - $args = array( 'action' => 'lostpassword' ); |
|
| 506 | - if ( !empty($redirect) ) { |
|
| 504 | +function wp_lostpassword_url($redirect = '') { |
|
| 505 | + $args = array('action' => 'lostpassword'); |
|
| 506 | + if ( ! empty($redirect)) { |
|
| 507 | 507 | $args['redirect_to'] = $redirect; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - $lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') ); |
|
| 510 | + $lostpassword_url = add_query_arg($args, network_site_url('wp-login.php', 'login')); |
|
| 511 | 511 | |
| 512 | 512 | /** |
| 513 | 513 | * Filters the Lost Password URL. |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * @param string $lostpassword_url The lost password page URL. |
| 518 | 518 | * @param string $redirect The path to redirect to on login. |
| 519 | 519 | */ |
| 520 | - return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect ); |
|
| 520 | + return apply_filters('lostpassword_url', $lostpassword_url, $redirect); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | /** |
@@ -533,14 +533,14 @@ discard block |
||
| 533 | 533 | * @param bool $echo Default to echo and not return the link. |
| 534 | 534 | * @return string|void String when retrieving. |
| 535 | 535 | */ |
| 536 | -function wp_register( $before = '<li>', $after = '</li>', $echo = true ) { |
|
| 537 | - if ( ! is_user_logged_in() ) { |
|
| 538 | - if ( get_option('users_can_register') ) |
|
| 539 | - $link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after; |
|
| 536 | +function wp_register($before = '<li>', $after = '</li>', $echo = true) { |
|
| 537 | + if ( ! is_user_logged_in()) { |
|
| 538 | + if (get_option('users_can_register')) |
|
| 539 | + $link = $before.'<a href="'.esc_url(wp_registration_url()).'">'.__('Register').'</a>'.$after; |
|
| 540 | 540 | else |
| 541 | 541 | $link = ''; |
| 542 | - } elseif ( current_user_can( 'read' ) ) { |
|
| 543 | - $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after; |
|
| 542 | + } elseif (current_user_can('read')) { |
|
| 543 | + $link = $before.'<a href="'.admin_url().'">'.__('Site Admin').'</a>'.$after; |
|
| 544 | 544 | } else { |
| 545 | 545 | $link = ''; |
| 546 | 546 | } |
@@ -555,9 +555,9 @@ discard block |
||
| 555 | 555 | * |
| 556 | 556 | * @param string $link The HTML code for the link to the Registration or Admin page. |
| 557 | 557 | */ |
| 558 | - $link = apply_filters( 'register', $link ); |
|
| 558 | + $link = apply_filters('register', $link); |
|
| 559 | 559 | |
| 560 | - if ( $echo ) { |
|
| 560 | + if ($echo) { |
|
| 561 | 561 | echo $link; |
| 562 | 562 | } else { |
| 563 | 563 | return $link; |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | * |
| 581 | 581 | * @since 1.5.0 |
| 582 | 582 | */ |
| 583 | - do_action( 'wp_meta' ); |
|
| 583 | + do_action('wp_meta'); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -592,8 +592,8 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @param string $show Optional. Site information to display. Default empty. |
| 594 | 594 | */ |
| 595 | -function bloginfo( $show = '' ) { |
|
| 596 | - echo get_bloginfo( $show, 'display' ); |
|
| 595 | +function bloginfo($show = '') { |
|
| 596 | + echo get_bloginfo($show, 'display'); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
@@ -643,17 +643,17 @@ discard block |
||
| 643 | 643 | * @param string $filter Optional. How to filter what is retrieved. Default 'raw'. |
| 644 | 644 | * @return string Mostly string values, might be empty. |
| 645 | 645 | */ |
| 646 | -function get_bloginfo( $show = '', $filter = 'raw' ) { |
|
| 647 | - switch( $show ) { |
|
| 646 | +function get_bloginfo($show = '', $filter = 'raw') { |
|
| 647 | + switch ($show) { |
|
| 648 | 648 | case 'home' : // DEPRECATED |
| 649 | 649 | case 'siteurl' : // DEPRECATED |
| 650 | - _deprecated_argument( __FUNCTION__, '2.2.0', sprintf( |
|
| 650 | + _deprecated_argument(__FUNCTION__, '2.2.0', sprintf( |
|
| 651 | 651 | /* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */ |
| 652 | - __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ), |
|
| 653 | - '<code>' . $show . '</code>', |
|
| 652 | + __('The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.'), |
|
| 653 | + '<code>'.$show.'</code>', |
|
| 654 | 654 | '<code>bloginfo()</code>', |
| 655 | 655 | '<code>url</code>' |
| 656 | - ) ); |
|
| 656 | + )); |
|
| 657 | 657 | case 'url' : |
| 658 | 658 | $output = home_url(); |
| 659 | 659 | break; |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | $output = get_feed_link('comments_rss2'); |
| 683 | 683 | break; |
| 684 | 684 | case 'pingback_url': |
| 685 | - $output = site_url( 'xmlrpc.php' ); |
|
| 685 | + $output = site_url('xmlrpc.php'); |
|
| 686 | 686 | break; |
| 687 | 687 | case 'stylesheet_url': |
| 688 | 688 | $output = get_stylesheet_uri(); |
@@ -713,21 +713,21 @@ discard block |
||
| 713 | 713 | * see https://www.w3.org/International/articles/language-tags/ for reference. |
| 714 | 714 | * Do not translate into your own language. |
| 715 | 715 | */ |
| 716 | - $output = __( 'html_lang_attribute' ); |
|
| 717 | - if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) { |
|
| 716 | + $output = __('html_lang_attribute'); |
|
| 717 | + if ('html_lang_attribute' === $output || preg_match('/[^a-zA-Z0-9-]/', $output)) { |
|
| 718 | 718 | $output = get_locale(); |
| 719 | - $output = str_replace( '_', '-', $output ); |
|
| 719 | + $output = str_replace('_', '-', $output); |
|
| 720 | 720 | } |
| 721 | 721 | break; |
| 722 | 722 | case 'text_direction': |
| 723 | - _deprecated_argument( __FUNCTION__, '2.2.0', sprintf( |
|
| 723 | + _deprecated_argument(__FUNCTION__, '2.2.0', sprintf( |
|
| 724 | 724 | /* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */ |
| 725 | - __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ), |
|
| 726 | - '<code>' . $show . '</code>', |
|
| 725 | + __('The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.'), |
|
| 726 | + '<code>'.$show.'</code>', |
|
| 727 | 727 | '<code>bloginfo()</code>', |
| 728 | 728 | '<code>is_rtl()</code>' |
| 729 | - ) ); |
|
| 730 | - if ( function_exists( 'is_rtl' ) ) { |
|
| 729 | + )); |
|
| 730 | + if (function_exists('is_rtl')) { |
|
| 731 | 731 | $output = is_rtl() ? 'rtl' : 'ltr'; |
| 732 | 732 | } else { |
| 733 | 733 | $output = 'ltr'; |
@@ -745,8 +745,8 @@ discard block |
||
| 745 | 745 | strpos($show, 'home') === false) |
| 746 | 746 | $url = false; |
| 747 | 747 | |
| 748 | - if ( 'display' == $filter ) { |
|
| 749 | - if ( $url ) { |
|
| 748 | + if ('display' == $filter) { |
|
| 749 | + if ($url) { |
|
| 750 | 750 | /** |
| 751 | 751 | * Filters the URL returned by get_bloginfo(). |
| 752 | 752 | * |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | * @param mixed $output The URL returned by bloginfo(). |
| 756 | 756 | * @param mixed $show Type of information requested. |
| 757 | 757 | */ |
| 758 | - $output = apply_filters( 'bloginfo_url', $output, $show ); |
|
| 758 | + $output = apply_filters('bloginfo_url', $output, $show); |
|
| 759 | 759 | } else { |
| 760 | 760 | /** |
| 761 | 761 | * Filters the site information returned by get_bloginfo(). |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | * @param mixed $output The requested non-URL site information. |
| 766 | 766 | * @param mixed $show Type of information requested. |
| 767 | 767 | */ |
| 768 | - $output = apply_filters( 'bloginfo', $output, $show ); |
|
| 768 | + $output = apply_filters('bloginfo', $output, $show); |
|
| 769 | 769 | } |
| 770 | 770 | } |
| 771 | 771 | |
@@ -782,23 +782,23 @@ discard block |
||
| 782 | 782 | * @param int $blog_id Optional. ID of the blog to get the site icon for. Default current blog. |
| 783 | 783 | * @return string Site Icon URL. |
| 784 | 784 | */ |
| 785 | -function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) { |
|
| 786 | - if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) { |
|
| 787 | - switch_to_blog( $blog_id ); |
|
| 785 | +function get_site_icon_url($size = 512, $url = '', $blog_id = 0) { |
|
| 786 | + if (is_multisite() && (int) $blog_id !== get_current_blog_id()) { |
|
| 787 | + switch_to_blog($blog_id); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - $site_icon_id = get_option( 'site_icon' ); |
|
| 790 | + $site_icon_id = get_option('site_icon'); |
|
| 791 | 791 | |
| 792 | - if ( $site_icon_id ) { |
|
| 793 | - if ( $size >= 512 ) { |
|
| 792 | + if ($site_icon_id) { |
|
| 793 | + if ($size >= 512) { |
|
| 794 | 794 | $size_data = 'full'; |
| 795 | 795 | } else { |
| 796 | - $size_data = array( $size, $size ); |
|
| 796 | + $size_data = array($size, $size); |
|
| 797 | 797 | } |
| 798 | - $url = wp_get_attachment_image_url( $site_icon_id, $size_data ); |
|
| 798 | + $url = wp_get_attachment_image_url($site_icon_id, $size_data); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if ( is_multisite() && ms_is_switched() ) { |
|
| 801 | + if (is_multisite() && ms_is_switched()) { |
|
| 802 | 802 | restore_current_blog(); |
| 803 | 803 | } |
| 804 | 804 | |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | * @param int $size Size of the site icon. |
| 812 | 812 | * @param int $blog_id ID of the blog to get the site icon for. |
| 813 | 813 | */ |
| 814 | - return apply_filters( 'get_site_icon_url', $url, $size, $blog_id ); |
|
| 814 | + return apply_filters('get_site_icon_url', $url, $size, $blog_id); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /** |
@@ -823,8 +823,8 @@ discard block |
||
| 823 | 823 | * @param string $url Optional. Fallback url if no site icon is found. Default empty. |
| 824 | 824 | * @param int $blog_id Optional. ID of the blog to get the site icon for. Default current blog. |
| 825 | 825 | */ |
| 826 | -function site_icon_url( $size = 512, $url = '', $blog_id = 0 ) { |
|
| 827 | - echo esc_url( get_site_icon_url( $size, $url, $blog_id ) ); |
|
| 826 | +function site_icon_url($size = 512, $url = '', $blog_id = 0) { |
|
| 827 | + echo esc_url(get_site_icon_url($size, $url, $blog_id)); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | /** |
@@ -835,8 +835,8 @@ discard block |
||
| 835 | 835 | * @param int $blog_id Optional. ID of the blog in question. Default current blog. |
| 836 | 836 | * @return bool Whether the site has a site icon or not. |
| 837 | 837 | */ |
| 838 | -function has_site_icon( $blog_id = 0 ) { |
|
| 839 | - return (bool) get_site_icon_url( 512, '', $blog_id ); |
|
| 838 | +function has_site_icon($blog_id = 0) { |
|
| 839 | + return (bool) get_site_icon_url(512, '', $blog_id); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -847,14 +847,14 @@ discard block |
||
| 847 | 847 | * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. |
| 848 | 848 | * @return bool Whether the site has a custom logo or not. |
| 849 | 849 | */ |
| 850 | -function has_custom_logo( $blog_id = 0 ) { |
|
| 851 | - if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) { |
|
| 852 | - switch_to_blog( $blog_id ); |
|
| 850 | +function has_custom_logo($blog_id = 0) { |
|
| 851 | + if (is_multisite() && (int) $blog_id !== get_current_blog_id()) { |
|
| 852 | + switch_to_blog($blog_id); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - $custom_logo_id = get_theme_mod( 'custom_logo' ); |
|
| 855 | + $custom_logo_id = get_theme_mod('custom_logo'); |
|
| 856 | 856 | |
| 857 | - if ( is_multisite() && ms_is_switched() ) { |
|
| 857 | + if (is_multisite() && ms_is_switched()) { |
|
| 858 | 858 | restore_current_blog(); |
| 859 | 859 | } |
| 860 | 860 | |
@@ -869,34 +869,34 @@ discard block |
||
| 869 | 869 | * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. |
| 870 | 870 | * @return string Custom logo markup. |
| 871 | 871 | */ |
| 872 | -function get_custom_logo( $blog_id = 0 ) { |
|
| 872 | +function get_custom_logo($blog_id = 0) { |
|
| 873 | 873 | $html = ''; |
| 874 | 874 | |
| 875 | - if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) { |
|
| 876 | - switch_to_blog( $blog_id ); |
|
| 875 | + if (is_multisite() && (int) $blog_id !== get_current_blog_id()) { |
|
| 876 | + switch_to_blog($blog_id); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - $custom_logo_id = get_theme_mod( 'custom_logo' ); |
|
| 879 | + $custom_logo_id = get_theme_mod('custom_logo'); |
|
| 880 | 880 | |
| 881 | 881 | // We have a logo. Logo is go. |
| 882 | - if ( $custom_logo_id ) { |
|
| 883 | - $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', |
|
| 884 | - esc_url( home_url( '/' ) ), |
|
| 885 | - wp_get_attachment_image( $custom_logo_id, 'full', false, array( |
|
| 882 | + if ($custom_logo_id) { |
|
| 883 | + $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', |
|
| 884 | + esc_url(home_url('/')), |
|
| 885 | + wp_get_attachment_image($custom_logo_id, 'full', false, array( |
|
| 886 | 886 | 'class' => 'custom-logo', |
| 887 | 887 | 'itemprop' => 'logo', |
| 888 | - ) ) |
|
| 888 | + )) |
|
| 889 | 889 | ); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview). |
| 893 | - elseif ( is_customize_preview() ) { |
|
| 894 | - $html = sprintf( '<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', |
|
| 895 | - esc_url( home_url( '/' ) ) |
|
| 893 | + elseif (is_customize_preview()) { |
|
| 894 | + $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', |
|
| 895 | + esc_url(home_url('/')) |
|
| 896 | 896 | ); |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - if ( is_multisite() && ms_is_switched() ) { |
|
| 899 | + if (is_multisite() && ms_is_switched()) { |
|
| 900 | 900 | restore_current_blog(); |
| 901 | 901 | } |
| 902 | 902 | |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | * @param string $html Custom logo HTML output. |
| 910 | 910 | * @param int $blog_id ID of the blog to get the custom logo for. |
| 911 | 911 | */ |
| 912 | - return apply_filters( 'get_custom_logo', $html, $blog_id ); |
|
| 912 | + return apply_filters('get_custom_logo', $html, $blog_id); |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | /** |
@@ -919,8 +919,8 @@ discard block |
||
| 919 | 919 | * |
| 920 | 920 | * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. |
| 921 | 921 | */ |
| 922 | -function the_custom_logo( $blog_id = 0 ) { |
|
| 923 | - echo get_custom_logo( $blog_id ); |
|
| 922 | +function the_custom_logo($blog_id = 0) { |
|
| 923 | + echo get_custom_logo($blog_id); |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | /** |
@@ -945,8 +945,8 @@ discard block |
||
| 945 | 945 | * |
| 946 | 946 | * @param string $title The document title. Default empty string. |
| 947 | 947 | */ |
| 948 | - $title = apply_filters( 'pre_get_document_title', '' ); |
|
| 949 | - if ( ! empty( $title ) ) { |
|
| 948 | + $title = apply_filters('pre_get_document_title', ''); |
|
| 949 | + if ( ! empty($title)) { |
|
| 950 | 950 | return $title; |
| 951 | 951 | } |
| 952 | 952 | |
@@ -957,62 +957,62 @@ discard block |
||
| 957 | 957 | ); |
| 958 | 958 | |
| 959 | 959 | // If it's a 404 page, use a "Page not found" title. |
| 960 | - if ( is_404() ) { |
|
| 961 | - $title['title'] = __( 'Page not found' ); |
|
| 960 | + if (is_404()) { |
|
| 961 | + $title['title'] = __('Page not found'); |
|
| 962 | 962 | |
| 963 | 963 | // If it's a search, use a dynamic search results title. |
| 964 | - } elseif ( is_search() ) { |
|
| 964 | + } elseif (is_search()) { |
|
| 965 | 965 | /* translators: %s: search phrase */ |
| 966 | - $title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() ); |
|
| 966 | + $title['title'] = sprintf(__('Search Results for “%s”'), get_search_query()); |
|
| 967 | 967 | |
| 968 | 968 | // If on the front page, use the site title. |
| 969 | - } elseif ( is_front_page() ) { |
|
| 970 | - $title['title'] = get_bloginfo( 'name', 'display' ); |
|
| 969 | + } elseif (is_front_page()) { |
|
| 970 | + $title['title'] = get_bloginfo('name', 'display'); |
|
| 971 | 971 | |
| 972 | 972 | // If on a post type archive, use the post type archive title. |
| 973 | - } elseif ( is_post_type_archive() ) { |
|
| 974 | - $title['title'] = post_type_archive_title( '', false ); |
|
| 973 | + } elseif (is_post_type_archive()) { |
|
| 974 | + $title['title'] = post_type_archive_title('', false); |
|
| 975 | 975 | |
| 976 | 976 | // If on a taxonomy archive, use the term title. |
| 977 | - } elseif ( is_tax() ) { |
|
| 978 | - $title['title'] = single_term_title( '', false ); |
|
| 977 | + } elseif (is_tax()) { |
|
| 978 | + $title['title'] = single_term_title('', false); |
|
| 979 | 979 | |
| 980 | 980 | /* |
| 981 | 981 | * If we're on the blog page that is not the homepage or |
| 982 | 982 | * a single post of any post type, use the post title. |
| 983 | 983 | */ |
| 984 | - } elseif ( is_home() || is_singular() ) { |
|
| 985 | - $title['title'] = single_post_title( '', false ); |
|
| 984 | + } elseif (is_home() || is_singular()) { |
|
| 985 | + $title['title'] = single_post_title('', false); |
|
| 986 | 986 | |
| 987 | 987 | // If on a category or tag archive, use the term title. |
| 988 | - } elseif ( is_category() || is_tag() ) { |
|
| 989 | - $title['title'] = single_term_title( '', false ); |
|
| 988 | + } elseif (is_category() || is_tag()) { |
|
| 989 | + $title['title'] = single_term_title('', false); |
|
| 990 | 990 | |
| 991 | 991 | // If on an author archive, use the author's display name. |
| 992 | - } elseif ( is_author() && $author = get_queried_object() ) { |
|
| 992 | + } elseif (is_author() && $author = get_queried_object()) { |
|
| 993 | 993 | $title['title'] = $author->display_name; |
| 994 | 994 | |
| 995 | 995 | // If it's a date archive, use the date as the title. |
| 996 | - } elseif ( is_year() ) { |
|
| 997 | - $title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) ); |
|
| 996 | + } elseif (is_year()) { |
|
| 997 | + $title['title'] = get_the_date(_x('Y', 'yearly archives date format')); |
|
| 998 | 998 | |
| 999 | - } elseif ( is_month() ) { |
|
| 1000 | - $title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) ); |
|
| 999 | + } elseif (is_month()) { |
|
| 1000 | + $title['title'] = get_the_date(_x('F Y', 'monthly archives date format')); |
|
| 1001 | 1001 | |
| 1002 | - } elseif ( is_day() ) { |
|
| 1002 | + } elseif (is_day()) { |
|
| 1003 | 1003 | $title['title'] = get_the_date(); |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | // Add a page number if necessary. |
| 1007 | - if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { |
|
| 1008 | - $title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) ); |
|
| 1007 | + if (($paged >= 2 || $page >= 2) && ! is_404()) { |
|
| 1008 | + $title['page'] = sprintf(__('Page %s'), max($paged, $page)); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | // Append the description or site title to give context. |
| 1012 | - if ( is_front_page() ) { |
|
| 1013 | - $title['tagline'] = get_bloginfo( 'description', 'display' ); |
|
| 1012 | + if (is_front_page()) { |
|
| 1013 | + $title['tagline'] = get_bloginfo('description', 'display'); |
|
| 1014 | 1014 | } else { |
| 1015 | - $title['site'] = get_bloginfo( 'name', 'display' ); |
|
| 1015 | + $title['site'] = get_bloginfo('name', 'display'); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | /** |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | * |
| 1023 | 1023 | * @param string $sep Document title separator. Default '-'. |
| 1024 | 1024 | */ |
| 1025 | - $sep = apply_filters( 'document_title_separator', '-' ); |
|
| 1025 | + $sep = apply_filters('document_title_separator', '-'); |
|
| 1026 | 1026 | |
| 1027 | 1027 | /** |
| 1028 | 1028 | * Filters the parts of the document title. |
@@ -1038,13 +1038,13 @@ discard block |
||
| 1038 | 1038 | * @type string $site Optional. Site title when not on home page. |
| 1039 | 1039 | * } |
| 1040 | 1040 | */ |
| 1041 | - $title = apply_filters( 'document_title_parts', $title ); |
|
| 1041 | + $title = apply_filters('document_title_parts', $title); |
|
| 1042 | 1042 | |
| 1043 | - $title = implode( " $sep ", array_filter( $title ) ); |
|
| 1044 | - $title = wptexturize( $title ); |
|
| 1045 | - $title = convert_chars( $title ); |
|
| 1046 | - $title = esc_html( $title ); |
|
| 1047 | - $title = capital_P_dangit( $title ); |
|
| 1043 | + $title = implode(" $sep ", array_filter($title)); |
|
| 1044 | + $title = wptexturize($title); |
|
| 1045 | + $title = convert_chars($title); |
|
| 1046 | + $title = esc_html($title); |
|
| 1047 | + $title = capital_P_dangit($title); |
|
| 1048 | 1048 | |
| 1049 | 1049 | return $title; |
| 1050 | 1050 | } |
@@ -1058,11 +1058,11 @@ discard block |
||
| 1058 | 1058 | * @access private |
| 1059 | 1059 | */ |
| 1060 | 1060 | function _wp_render_title_tag() { |
| 1061 | - if ( ! current_theme_supports( 'title-tag' ) ) { |
|
| 1061 | + if ( ! current_theme_supports('title-tag')) { |
|
| 1062 | 1062 | return; |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | - echo '<title>' . wp_get_document_title() . '</title>' . "\n"; |
|
| 1065 | + echo '<title>'.wp_get_document_title().'</title>'."\n"; |
|
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | /** |
@@ -1090,94 +1090,94 @@ discard block |
||
| 1090 | 1090 | * @param string $seplocation Optional. Direction to display title, 'right'. |
| 1091 | 1091 | * @return string|null String on retrieve, null when displaying. |
| 1092 | 1092 | */ |
| 1093 | -function wp_title( $sep = '»', $display = true, $seplocation = '' ) { |
|
| 1093 | +function wp_title($sep = '»', $display = true, $seplocation = '') { |
|
| 1094 | 1094 | global $wp_locale; |
| 1095 | 1095 | |
| 1096 | - $m = get_query_var( 'm' ); |
|
| 1097 | - $year = get_query_var( 'year' ); |
|
| 1098 | - $monthnum = get_query_var( 'monthnum' ); |
|
| 1099 | - $day = get_query_var( 'day' ); |
|
| 1100 | - $search = get_query_var( 's' ); |
|
| 1096 | + $m = get_query_var('m'); |
|
| 1097 | + $year = get_query_var('year'); |
|
| 1098 | + $monthnum = get_query_var('monthnum'); |
|
| 1099 | + $day = get_query_var('day'); |
|
| 1100 | + $search = get_query_var('s'); |
|
| 1101 | 1101 | $title = ''; |
| 1102 | 1102 | |
| 1103 | 1103 | $t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary |
| 1104 | 1104 | |
| 1105 | 1105 | // If there is a post |
| 1106 | - if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) { |
|
| 1107 | - $title = single_post_title( '', false ); |
|
| 1106 | + if (is_single() || (is_home() && ! is_front_page()) || (is_page() && ! is_front_page())) { |
|
| 1107 | + $title = single_post_title('', false); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | // If there's a post type archive |
| 1111 | - if ( is_post_type_archive() ) { |
|
| 1112 | - $post_type = get_query_var( 'post_type' ); |
|
| 1113 | - if ( is_array( $post_type ) ) { |
|
| 1114 | - $post_type = reset( $post_type ); |
|
| 1111 | + if (is_post_type_archive()) { |
|
| 1112 | + $post_type = get_query_var('post_type'); |
|
| 1113 | + if (is_array($post_type)) { |
|
| 1114 | + $post_type = reset($post_type); |
|
| 1115 | 1115 | } |
| 1116 | - $post_type_object = get_post_type_object( $post_type ); |
|
| 1117 | - if ( ! $post_type_object->has_archive ) { |
|
| 1118 | - $title = post_type_archive_title( '', false ); |
|
| 1116 | + $post_type_object = get_post_type_object($post_type); |
|
| 1117 | + if ( ! $post_type_object->has_archive) { |
|
| 1118 | + $title = post_type_archive_title('', false); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | // If there's a category or tag |
| 1123 | - if ( is_category() || is_tag() ) { |
|
| 1124 | - $title = single_term_title( '', false ); |
|
| 1123 | + if (is_category() || is_tag()) { |
|
| 1124 | + $title = single_term_title('', false); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | // If there's a taxonomy |
| 1128 | - if ( is_tax() ) { |
|
| 1128 | + if (is_tax()) { |
|
| 1129 | 1129 | $term = get_queried_object(); |
| 1130 | - if ( $term ) { |
|
| 1131 | - $tax = get_taxonomy( $term->taxonomy ); |
|
| 1132 | - $title = single_term_title( $tax->labels->name . $t_sep, false ); |
|
| 1130 | + if ($term) { |
|
| 1131 | + $tax = get_taxonomy($term->taxonomy); |
|
| 1132 | + $title = single_term_title($tax->labels->name.$t_sep, false); |
|
| 1133 | 1133 | } |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | // If there's an author |
| 1137 | - if ( is_author() && ! is_post_type_archive() ) { |
|
| 1137 | + if (is_author() && ! is_post_type_archive()) { |
|
| 1138 | 1138 | $author = get_queried_object(); |
| 1139 | - if ( $author ) { |
|
| 1139 | + if ($author) { |
|
| 1140 | 1140 | $title = $author->display_name; |
| 1141 | 1141 | } |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | // Post type archives with has_archive should override terms. |
| 1145 | - if ( is_post_type_archive() && $post_type_object->has_archive ) { |
|
| 1146 | - $title = post_type_archive_title( '', false ); |
|
| 1145 | + if (is_post_type_archive() && $post_type_object->has_archive) { |
|
| 1146 | + $title = post_type_archive_title('', false); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | // If there's a month |
| 1150 | - if ( is_archive() && ! empty( $m ) ) { |
|
| 1151 | - $my_year = substr( $m, 0, 4 ); |
|
| 1152 | - $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) ); |
|
| 1153 | - $my_day = intval( substr( $m, 6, 2 ) ); |
|
| 1154 | - $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' ); |
|
| 1150 | + if (is_archive() && ! empty($m)) { |
|
| 1151 | + $my_year = substr($m, 0, 4); |
|
| 1152 | + $my_month = $wp_locale->get_month(substr($m, 4, 2)); |
|
| 1153 | + $my_day = intval(substr($m, 6, 2)); |
|
| 1154 | + $title = $my_year.($my_month ? $t_sep.$my_month : '').($my_day ? $t_sep.$my_day : ''); |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | // If there's a year |
| 1158 | - if ( is_archive() && ! empty( $year ) ) { |
|
| 1158 | + if (is_archive() && ! empty($year)) { |
|
| 1159 | 1159 | $title = $year; |
| 1160 | - if ( ! empty( $monthnum ) ) { |
|
| 1161 | - $title .= $t_sep . $wp_locale->get_month( $monthnum ); |
|
| 1160 | + if ( ! empty($monthnum)) { |
|
| 1161 | + $title .= $t_sep.$wp_locale->get_month($monthnum); |
|
| 1162 | 1162 | } |
| 1163 | - if ( ! empty( $day ) ) { |
|
| 1164 | - $title .= $t_sep . zeroise( $day, 2 ); |
|
| 1163 | + if ( ! empty($day)) { |
|
| 1164 | + $title .= $t_sep.zeroise($day, 2); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | // If it's a search |
| 1169 | - if ( is_search() ) { |
|
| 1169 | + if (is_search()) { |
|
| 1170 | 1170 | /* translators: 1: separator, 2: search phrase */ |
| 1171 | - $title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) ); |
|
| 1171 | + $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search)); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | // If it's a 404 page |
| 1175 | - if ( is_404() ) { |
|
| 1176 | - $title = __( 'Page not found' ); |
|
| 1175 | + if (is_404()) { |
|
| 1176 | + $title = __('Page not found'); |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | $prefix = ''; |
| 1180 | - if ( ! empty( $title ) ) { |
|
| 1180 | + if ( ! empty($title)) { |
|
| 1181 | 1181 | $prefix = " $sep "; |
| 1182 | 1182 | } |
| 1183 | 1183 | |
@@ -1188,14 +1188,14 @@ discard block |
||
| 1188 | 1188 | * |
| 1189 | 1189 | * @param array $title_array Parts of the page title. |
| 1190 | 1190 | */ |
| 1191 | - $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) ); |
|
| 1191 | + $title_array = apply_filters('wp_title_parts', explode($t_sep, $title)); |
|
| 1192 | 1192 | |
| 1193 | 1193 | // Determines position of the separator and direction of the breadcrumb |
| 1194 | - if ( 'right' == $seplocation ) { // sep on right, so reverse the order |
|
| 1195 | - $title_array = array_reverse( $title_array ); |
|
| 1196 | - $title = implode( " $sep ", $title_array ) . $prefix; |
|
| 1194 | + if ('right' == $seplocation) { // sep on right, so reverse the order |
|
| 1195 | + $title_array = array_reverse($title_array); |
|
| 1196 | + $title = implode(" $sep ", $title_array).$prefix; |
|
| 1197 | 1197 | } else { |
| 1198 | - $title = $prefix . implode( " $sep ", $title_array ); |
|
| 1198 | + $title = $prefix.implode(" $sep ", $title_array); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | /** |
@@ -1207,10 +1207,10 @@ discard block |
||
| 1207 | 1207 | * @param string $sep Title separator. |
| 1208 | 1208 | * @param string $seplocation Location of the separator (left or right). |
| 1209 | 1209 | */ |
| 1210 | - $title = apply_filters( 'wp_title', $title, $sep, $seplocation ); |
|
| 1210 | + $title = apply_filters('wp_title', $title, $sep, $seplocation); |
|
| 1211 | 1211 | |
| 1212 | 1212 | // Send it out |
| 1213 | - if ( $display ) { |
|
| 1213 | + if ($display) { |
|
| 1214 | 1214 | echo $title; |
| 1215 | 1215 | } else { |
| 1216 | 1216 | return $title; |
@@ -1233,10 +1233,10 @@ discard block |
||
| 1233 | 1233 | * @param bool $display Optional, default is true. Whether to display or retrieve title. |
| 1234 | 1234 | * @return string|void Title when retrieving. |
| 1235 | 1235 | */ |
| 1236 | -function single_post_title( $prefix = '', $display = true ) { |
|
| 1236 | +function single_post_title($prefix = '', $display = true) { |
|
| 1237 | 1237 | $_post = get_queried_object(); |
| 1238 | 1238 | |
| 1239 | - if ( !isset($_post->post_title) ) |
|
| 1239 | + if ( ! isset($_post->post_title)) |
|
| 1240 | 1240 | return; |
| 1241 | 1241 | |
| 1242 | 1242 | /** |
@@ -1247,11 +1247,11 @@ discard block |
||
| 1247 | 1247 | * @param string $_post_title The single post page title. |
| 1248 | 1248 | * @param object $_post The current queried object as returned by get_queried_object(). |
| 1249 | 1249 | */ |
| 1250 | - $title = apply_filters( 'single_post_title', $_post->post_title, $_post ); |
|
| 1251 | - if ( $display ) |
|
| 1252 | - echo $prefix . $title; |
|
| 1250 | + $title = apply_filters('single_post_title', $_post->post_title, $_post); |
|
| 1251 | + if ($display) |
|
| 1252 | + echo $prefix.$title; |
|
| 1253 | 1253 | else |
| 1254 | - return $prefix . $title; |
|
| 1254 | + return $prefix.$title; |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | /** |
@@ -1266,15 +1266,15 @@ discard block |
||
| 1266 | 1266 | * @param bool $display Optional, default is true. Whether to display or retrieve title. |
| 1267 | 1267 | * @return string|void Title when retrieving, null when displaying or failure. |
| 1268 | 1268 | */ |
| 1269 | -function post_type_archive_title( $prefix = '', $display = true ) { |
|
| 1270 | - if ( ! is_post_type_archive() ) |
|
| 1269 | +function post_type_archive_title($prefix = '', $display = true) { |
|
| 1270 | + if ( ! is_post_type_archive()) |
|
| 1271 | 1271 | return; |
| 1272 | 1272 | |
| 1273 | - $post_type = get_query_var( 'post_type' ); |
|
| 1274 | - if ( is_array( $post_type ) ) |
|
| 1275 | - $post_type = reset( $post_type ); |
|
| 1273 | + $post_type = get_query_var('post_type'); |
|
| 1274 | + if (is_array($post_type)) |
|
| 1275 | + $post_type = reset($post_type); |
|
| 1276 | 1276 | |
| 1277 | - $post_type_obj = get_post_type_object( $post_type ); |
|
| 1277 | + $post_type_obj = get_post_type_object($post_type); |
|
| 1278 | 1278 | |
| 1279 | 1279 | /** |
| 1280 | 1280 | * Filters the post type archive title. |
@@ -1284,12 +1284,12 @@ discard block |
||
| 1284 | 1284 | * @param string $post_type_name Post type 'name' label. |
| 1285 | 1285 | * @param string $post_type Post type. |
| 1286 | 1286 | */ |
| 1287 | - $title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type ); |
|
| 1287 | + $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name, $post_type); |
|
| 1288 | 1288 | |
| 1289 | - if ( $display ) |
|
| 1290 | - echo $prefix . $title; |
|
| 1289 | + if ($display) |
|
| 1290 | + echo $prefix.$title; |
|
| 1291 | 1291 | else |
| 1292 | - return $prefix . $title; |
|
| 1292 | + return $prefix.$title; |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | /** |
@@ -1305,8 +1305,8 @@ discard block |
||
| 1305 | 1305 | * @param bool $display Optional, default is true. Whether to display or retrieve title. |
| 1306 | 1306 | * @return string|void Title when retrieving. |
| 1307 | 1307 | */ |
| 1308 | -function single_cat_title( $prefix = '', $display = true ) { |
|
| 1309 | - return single_term_title( $prefix, $display ); |
|
| 1308 | +function single_cat_title($prefix = '', $display = true) { |
|
| 1309 | + return single_term_title($prefix, $display); |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | /** |
@@ -1322,8 +1322,8 @@ discard block |
||
| 1322 | 1322 | * @param bool $display Optional, default is true. Whether to display or retrieve title. |
| 1323 | 1323 | * @return string|void Title when retrieving. |
| 1324 | 1324 | */ |
| 1325 | -function single_tag_title( $prefix = '', $display = true ) { |
|
| 1326 | - return single_term_title( $prefix, $display ); |
|
| 1325 | +function single_tag_title($prefix = '', $display = true) { |
|
| 1326 | + return single_term_title($prefix, $display); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | /** |
@@ -1339,13 +1339,13 @@ discard block |
||
| 1339 | 1339 | * @param bool $display Optional, default is true. Whether to display or retrieve title. |
| 1340 | 1340 | * @return string|void Title when retrieving. |
| 1341 | 1341 | */ |
| 1342 | -function single_term_title( $prefix = '', $display = true ) { |
|
| 1342 | +function single_term_title($prefix = '', $display = true) { |
|
| 1343 | 1343 | $term = get_queried_object(); |
| 1344 | 1344 | |
| 1345 | - if ( !$term ) |
|
| 1345 | + if ( ! $term) |
|
| 1346 | 1346 | return; |
| 1347 | 1347 | |
| 1348 | - if ( is_category() ) { |
|
| 1348 | + if (is_category()) { |
|
| 1349 | 1349 | /** |
| 1350 | 1350 | * Filters the category archive page title. |
| 1351 | 1351 | * |
@@ -1353,8 +1353,8 @@ discard block |
||
| 1353 | 1353 | * |
| 1354 | 1354 | * @param string $term_name Category name for archive being displayed. |
| 1355 | 1355 | */ |
| 1356 | - $term_name = apply_filters( 'single_cat_title', $term->name ); |
|
| 1357 | - } elseif ( is_tag() ) { |
|
| 1356 | + $term_name = apply_filters('single_cat_title', $term->name); |
|
| 1357 | + } elseif (is_tag()) { |
|
| 1358 | 1358 | /** |
| 1359 | 1359 | * Filters the tag archive page title. |
| 1360 | 1360 | * |
@@ -1362,8 +1362,8 @@ discard block |
||
| 1362 | 1362 | * |
| 1363 | 1363 | * @param string $term_name Tag name for archive being displayed. |
| 1364 | 1364 | */ |
| 1365 | - $term_name = apply_filters( 'single_tag_title', $term->name ); |
|
| 1366 | - } elseif ( is_tax() ) { |
|
| 1365 | + $term_name = apply_filters('single_tag_title', $term->name); |
|
| 1366 | + } elseif (is_tax()) { |
|
| 1367 | 1367 | /** |
| 1368 | 1368 | * Filters the custom taxonomy archive page title. |
| 1369 | 1369 | * |
@@ -1371,18 +1371,18 @@ discard block |
||
| 1371 | 1371 | * |
| 1372 | 1372 | * @param string $term_name Term name for archive being displayed. |
| 1373 | 1373 | */ |
| 1374 | - $term_name = apply_filters( 'single_term_title', $term->name ); |
|
| 1374 | + $term_name = apply_filters('single_term_title', $term->name); |
|
| 1375 | 1375 | } else { |
| 1376 | 1376 | return; |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | - if ( empty( $term_name ) ) |
|
| 1379 | + if (empty($term_name)) |
|
| 1380 | 1380 | return; |
| 1381 | 1381 | |
| 1382 | - if ( $display ) |
|
| 1383 | - echo $prefix . $term_name; |
|
| 1382 | + if ($display) |
|
| 1383 | + echo $prefix.$term_name; |
|
| 1384 | 1384 | else |
| 1385 | - return $prefix . $term_name; |
|
| 1385 | + return $prefix.$term_name; |
|
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | /** |
@@ -1401,27 +1401,27 @@ discard block |
||
| 1401 | 1401 | * @param bool $display Optional, default is true. Whether to display or retrieve title. |
| 1402 | 1402 | * @return string|void Title when retrieving. |
| 1403 | 1403 | */ |
| 1404 | -function single_month_title($prefix = '', $display = true ) { |
|
| 1404 | +function single_month_title($prefix = '', $display = true) { |
|
| 1405 | 1405 | global $wp_locale; |
| 1406 | 1406 | |
| 1407 | 1407 | $m = get_query_var('m'); |
| 1408 | 1408 | $year = get_query_var('year'); |
| 1409 | 1409 | $monthnum = get_query_var('monthnum'); |
| 1410 | 1410 | |
| 1411 | - if ( !empty($monthnum) && !empty($year) ) { |
|
| 1411 | + if ( ! empty($monthnum) && ! empty($year)) { |
|
| 1412 | 1412 | $my_year = $year; |
| 1413 | 1413 | $my_month = $wp_locale->get_month($monthnum); |
| 1414 | - } elseif ( !empty($m) ) { |
|
| 1414 | + } elseif ( ! empty($m)) { |
|
| 1415 | 1415 | $my_year = substr($m, 0, 4); |
| 1416 | 1416 | $my_month = $wp_locale->get_month(substr($m, 4, 2)); |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | - if ( empty($my_month) ) |
|
| 1419 | + if (empty($my_month)) |
|
| 1420 | 1420 | return false; |
| 1421 | 1421 | |
| 1422 | - $result = $prefix . $my_month . $prefix . $my_year; |
|
| 1422 | + $result = $prefix.$my_month.$prefix.$my_year; |
|
| 1423 | 1423 | |
| 1424 | - if ( !$display ) |
|
| 1424 | + if ( ! $display) |
|
| 1425 | 1425 | return $result; |
| 1426 | 1426 | echo $result; |
| 1427 | 1427 | } |
@@ -1436,11 +1436,11 @@ discard block |
||
| 1436 | 1436 | * @param string $before Optional. Content to prepend to the title. Default empty. |
| 1437 | 1437 | * @param string $after Optional. Content to append to the title. Default empty. |
| 1438 | 1438 | */ |
| 1439 | -function the_archive_title( $before = '', $after = '' ) { |
|
| 1439 | +function the_archive_title($before = '', $after = '') { |
|
| 1440 | 1440 | $title = get_the_archive_title(); |
| 1441 | 1441 | |
| 1442 | - if ( ! empty( $title ) ) { |
|
| 1443 | - echo $before . $title . $after; |
|
| 1442 | + if ( ! empty($title)) { |
|
| 1443 | + echo $before.$title.$after; |
|
| 1444 | 1444 | } |
| 1445 | 1445 | } |
| 1446 | 1446 | |
@@ -1452,46 +1452,46 @@ discard block |
||
| 1452 | 1452 | * @return string Archive title. |
| 1453 | 1453 | */ |
| 1454 | 1454 | function get_the_archive_title() { |
| 1455 | - if ( is_category() ) { |
|
| 1456 | - $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) ); |
|
| 1457 | - } elseif ( is_tag() ) { |
|
| 1458 | - $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) ); |
|
| 1459 | - } elseif ( is_author() ) { |
|
| 1460 | - $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' ); |
|
| 1461 | - } elseif ( is_year() ) { |
|
| 1462 | - $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) ); |
|
| 1463 | - } elseif ( is_month() ) { |
|
| 1464 | - $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) ); |
|
| 1465 | - } elseif ( is_day() ) { |
|
| 1466 | - $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) ); |
|
| 1467 | - } elseif ( is_tax( 'post_format' ) ) { |
|
| 1468 | - if ( is_tax( 'post_format', 'post-format-aside' ) ) { |
|
| 1469 | - $title = _x( 'Asides', 'post format archive title' ); |
|
| 1470 | - } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { |
|
| 1471 | - $title = _x( 'Galleries', 'post format archive title' ); |
|
| 1472 | - } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { |
|
| 1473 | - $title = _x( 'Images', 'post format archive title' ); |
|
| 1474 | - } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { |
|
| 1475 | - $title = _x( 'Videos', 'post format archive title' ); |
|
| 1476 | - } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { |
|
| 1477 | - $title = _x( 'Quotes', 'post format archive title' ); |
|
| 1478 | - } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { |
|
| 1479 | - $title = _x( 'Links', 'post format archive title' ); |
|
| 1480 | - } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { |
|
| 1481 | - $title = _x( 'Statuses', 'post format archive title' ); |
|
| 1482 | - } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { |
|
| 1483 | - $title = _x( 'Audio', 'post format archive title' ); |
|
| 1484 | - } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { |
|
| 1485 | - $title = _x( 'Chats', 'post format archive title' ); |
|
| 1455 | + if (is_category()) { |
|
| 1456 | + $title = sprintf(__('Category: %s'), single_cat_title('', false)); |
|
| 1457 | + } elseif (is_tag()) { |
|
| 1458 | + $title = sprintf(__('Tag: %s'), single_tag_title('', false)); |
|
| 1459 | + } elseif (is_author()) { |
|
| 1460 | + $title = sprintf(__('Author: %s'), '<span class="vcard">'.get_the_author().'</span>'); |
|
| 1461 | + } elseif (is_year()) { |
|
| 1462 | + $title = sprintf(__('Year: %s'), get_the_date(_x('Y', 'yearly archives date format'))); |
|
| 1463 | + } elseif (is_month()) { |
|
| 1464 | + $title = sprintf(__('Month: %s'), get_the_date(_x('F Y', 'monthly archives date format'))); |
|
| 1465 | + } elseif (is_day()) { |
|
| 1466 | + $title = sprintf(__('Day: %s'), get_the_date(_x('F j, Y', 'daily archives date format'))); |
|
| 1467 | + } elseif (is_tax('post_format')) { |
|
| 1468 | + if (is_tax('post_format', 'post-format-aside')) { |
|
| 1469 | + $title = _x('Asides', 'post format archive title'); |
|
| 1470 | + } elseif (is_tax('post_format', 'post-format-gallery')) { |
|
| 1471 | + $title = _x('Galleries', 'post format archive title'); |
|
| 1472 | + } elseif (is_tax('post_format', 'post-format-image')) { |
|
| 1473 | + $title = _x('Images', 'post format archive title'); |
|
| 1474 | + } elseif (is_tax('post_format', 'post-format-video')) { |
|
| 1475 | + $title = _x('Videos', 'post format archive title'); |
|
| 1476 | + } elseif (is_tax('post_format', 'post-format-quote')) { |
|
| 1477 | + $title = _x('Quotes', 'post format archive title'); |
|
| 1478 | + } elseif (is_tax('post_format', 'post-format-link')) { |
|
| 1479 | + $title = _x('Links', 'post format archive title'); |
|
| 1480 | + } elseif (is_tax('post_format', 'post-format-status')) { |
|
| 1481 | + $title = _x('Statuses', 'post format archive title'); |
|
| 1482 | + } elseif (is_tax('post_format', 'post-format-audio')) { |
|
| 1483 | + $title = _x('Audio', 'post format archive title'); |
|
| 1484 | + } elseif (is_tax('post_format', 'post-format-chat')) { |
|
| 1485 | + $title = _x('Chats', 'post format archive title'); |
|
| 1486 | 1486 | } |
| 1487 | - } elseif ( is_post_type_archive() ) { |
|
| 1488 | - $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) ); |
|
| 1489 | - } elseif ( is_tax() ) { |
|
| 1490 | - $tax = get_taxonomy( get_queried_object()->taxonomy ); |
|
| 1487 | + } elseif (is_post_type_archive()) { |
|
| 1488 | + $title = sprintf(__('Archives: %s'), post_type_archive_title('', false)); |
|
| 1489 | + } elseif (is_tax()) { |
|
| 1490 | + $tax = get_taxonomy(get_queried_object()->taxonomy); |
|
| 1491 | 1491 | /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ |
| 1492 | - $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) ); |
|
| 1492 | + $title = sprintf(__('%1$s: %2$s'), $tax->labels->singular_name, single_term_title('', false)); |
|
| 1493 | 1493 | } else { |
| 1494 | - $title = __( 'Archives' ); |
|
| 1494 | + $title = __('Archives'); |
|
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | /** |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | * |
| 1502 | 1502 | * @param string $title Archive title to be displayed. |
| 1503 | 1503 | */ |
| 1504 | - return apply_filters( 'get_the_archive_title', $title ); |
|
| 1504 | + return apply_filters('get_the_archive_title', $title); |
|
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | /** |
@@ -1514,10 +1514,10 @@ discard block |
||
| 1514 | 1514 | * @param string $before Optional. Content to prepend to the description. Default empty. |
| 1515 | 1515 | * @param string $after Optional. Content to append to the description. Default empty. |
| 1516 | 1516 | */ |
| 1517 | -function the_archive_description( $before = '', $after = '' ) { |
|
| 1517 | +function the_archive_description($before = '', $after = '') { |
|
| 1518 | 1518 | $description = get_the_archive_description(); |
| 1519 | - if ( $description ) { |
|
| 1520 | - echo $before . $description . $after; |
|
| 1519 | + if ($description) { |
|
| 1520 | + echo $before.$description.$after; |
|
| 1521 | 1521 | } |
| 1522 | 1522 | } |
| 1523 | 1523 | |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | * |
| 1539 | 1539 | * @param string $description Archive description to be displayed. |
| 1540 | 1540 | */ |
| 1541 | - return apply_filters( 'get_the_archive_description', term_description() ); |
|
| 1541 | + return apply_filters('get_the_archive_description', term_description()); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | /** |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | $url = esc_url($url); |
| 1580 | 1580 | |
| 1581 | 1581 | if ('link' == $format) |
| 1582 | - $link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n"; |
|
| 1582 | + $link_html = "\t<link rel='archives' title='".esc_attr($text)."' href='$url' />\n"; |
|
| 1583 | 1583 | elseif ('option' == $format) |
| 1584 | 1584 | $link_html = "\t<option value='$url'>$before $text $after</option>\n"; |
| 1585 | 1585 | elseif ('html' == $format) |
@@ -1600,7 +1600,7 @@ discard block |
||
| 1600 | 1600 | * @param string $before Content to prepend to the description. |
| 1601 | 1601 | * @param string $after Content to append to the description. |
| 1602 | 1602 | */ |
| 1603 | - return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after ); |
|
| 1603 | + return apply_filters('get_archives_link', $link_html, $url, $text, $format, $before, $after); |
|
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | 1606 | /** |
@@ -1638,7 +1638,7 @@ discard block |
||
| 1638 | 1638 | * } |
| 1639 | 1639 | * @return string|void String when retrieving. |
| 1640 | 1640 | */ |
| 1641 | -function wp_get_archives( $args = '' ) { |
|
| 1641 | +function wp_get_archives($args = '') { |
|
| 1642 | 1642 | global $wpdb, $wp_locale; |
| 1643 | 1643 | |
| 1644 | 1644 | $defaults = array( |
@@ -1649,32 +1649,32 @@ discard block |
||
| 1649 | 1649 | 'post_type' => 'post' |
| 1650 | 1650 | ); |
| 1651 | 1651 | |
| 1652 | - $r = wp_parse_args( $args, $defaults ); |
|
| 1652 | + $r = wp_parse_args($args, $defaults); |
|
| 1653 | 1653 | |
| 1654 | - $post_type_object = get_post_type_object( $r['post_type'] ); |
|
| 1655 | - if ( ! is_post_type_viewable( $post_type_object ) ) { |
|
| 1654 | + $post_type_object = get_post_type_object($r['post_type']); |
|
| 1655 | + if ( ! is_post_type_viewable($post_type_object)) { |
|
| 1656 | 1656 | return; |
| 1657 | 1657 | } |
| 1658 | 1658 | $r['post_type'] = $post_type_object->name; |
| 1659 | 1659 | |
| 1660 | - if ( '' == $r['type'] ) { |
|
| 1660 | + if ('' == $r['type']) { |
|
| 1661 | 1661 | $r['type'] = 'monthly'; |
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | - if ( ! empty( $r['limit'] ) ) { |
|
| 1665 | - $r['limit'] = absint( $r['limit'] ); |
|
| 1666 | - $r['limit'] = ' LIMIT ' . $r['limit']; |
|
| 1664 | + if ( ! empty($r['limit'])) { |
|
| 1665 | + $r['limit'] = absint($r['limit']); |
|
| 1666 | + $r['limit'] = ' LIMIT '.$r['limit']; |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | - $order = strtoupper( $r['order'] ); |
|
| 1670 | - if ( $order !== 'ASC' ) { |
|
| 1669 | + $order = strtoupper($r['order']); |
|
| 1670 | + if ($order !== 'ASC') { |
|
| 1671 | 1671 | $order = 'DESC'; |
| 1672 | 1672 | } |
| 1673 | 1673 | |
| 1674 | 1674 | // this is what will separate dates on weekly archive links |
| 1675 | 1675 | $archive_week_separator = '–'; |
| 1676 | 1676 | |
| 1677 | - $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $r['post_type'] ); |
|
| 1677 | + $sql_where = $wpdb->prepare("WHERE post_type = %s AND post_status = 'publish'", $r['post_type']); |
|
| 1678 | 1678 | |
| 1679 | 1679 | /** |
| 1680 | 1680 | * Filters the SQL WHERE clause for retrieving archives. |
@@ -1684,7 +1684,7 @@ discard block |
||
| 1684 | 1684 | * @param string $sql_where Portion of SQL query containing the WHERE clause. |
| 1685 | 1685 | * @param array $r An array of default arguments. |
| 1686 | 1686 | */ |
| 1687 | - $where = apply_filters( 'getarchives_where', $sql_where, $r ); |
|
| 1687 | + $where = apply_filters('getarchives_where', $sql_where, $r); |
|
| 1688 | 1688 | |
| 1689 | 1689 | /** |
| 1690 | 1690 | * Filters the SQL JOIN clause for retrieving archives. |
@@ -1694,142 +1694,142 @@ discard block |
||
| 1694 | 1694 | * @param string $sql_join Portion of SQL query containing JOIN clause. |
| 1695 | 1695 | * @param array $r An array of default arguments. |
| 1696 | 1696 | */ |
| 1697 | - $join = apply_filters( 'getarchives_join', '', $r ); |
|
| 1697 | + $join = apply_filters('getarchives_join', '', $r); |
|
| 1698 | 1698 | |
| 1699 | 1699 | $output = ''; |
| 1700 | 1700 | |
| 1701 | - $last_changed = wp_cache_get( 'last_changed', 'posts' ); |
|
| 1702 | - if ( ! $last_changed ) { |
|
| 1701 | + $last_changed = wp_cache_get('last_changed', 'posts'); |
|
| 1702 | + if ( ! $last_changed) { |
|
| 1703 | 1703 | $last_changed = microtime(); |
| 1704 | - wp_cache_set( 'last_changed', $last_changed, 'posts' ); |
|
| 1704 | + wp_cache_set('last_changed', $last_changed, 'posts'); |
|
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | $limit = $r['limit']; |
| 1708 | 1708 | |
| 1709 | - if ( 'monthly' == $r['type'] ) { |
|
| 1709 | + if ('monthly' == $r['type']) { |
|
| 1710 | 1710 | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; |
| 1711 | - $key = md5( $query ); |
|
| 1711 | + $key = md5($query); |
|
| 1712 | 1712 | $key = "wp_get_archives:$key:$last_changed"; |
| 1713 | - if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
|
| 1714 | - $results = $wpdb->get_results( $query ); |
|
| 1715 | - wp_cache_set( $key, $results, 'posts' ); |
|
| 1713 | + if ( ! $results = wp_cache_get($key, 'posts')) { |
|
| 1714 | + $results = $wpdb->get_results($query); |
|
| 1715 | + wp_cache_set($key, $results, 'posts'); |
|
| 1716 | 1716 | } |
| 1717 | - if ( $results ) { |
|
| 1717 | + if ($results) { |
|
| 1718 | 1718 | $after = $r['after']; |
| 1719 | - foreach ( (array) $results as $result ) { |
|
| 1720 | - $url = get_month_link( $result->year, $result->month ); |
|
| 1721 | - if ( 'post' !== $r['post_type'] ) { |
|
| 1722 | - $url = add_query_arg( 'post_type', $r['post_type'], $url ); |
|
| 1719 | + foreach ((array) $results as $result) { |
|
| 1720 | + $url = get_month_link($result->year, $result->month); |
|
| 1721 | + if ('post' !== $r['post_type']) { |
|
| 1722 | + $url = add_query_arg('post_type', $r['post_type'], $url); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | /* translators: 1: month name, 2: 4-digit year */ |
| 1725 | - $text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year ); |
|
| 1726 | - if ( $r['show_post_count'] ) { |
|
| 1727 | - $r['after'] = ' (' . $result->posts . ')' . $after; |
|
| 1725 | + $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year); |
|
| 1726 | + if ($r['show_post_count']) { |
|
| 1727 | + $r['after'] = ' ('.$result->posts.')'.$after; |
|
| 1728 | 1728 | } |
| 1729 | - $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); |
|
| 1729 | + $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']); |
|
| 1730 | 1730 | } |
| 1731 | 1731 | } |
| 1732 | - } elseif ( 'yearly' == $r['type'] ) { |
|
| 1732 | + } elseif ('yearly' == $r['type']) { |
|
| 1733 | 1733 | $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; |
| 1734 | - $key = md5( $query ); |
|
| 1734 | + $key = md5($query); |
|
| 1735 | 1735 | $key = "wp_get_archives:$key:$last_changed"; |
| 1736 | - if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
|
| 1737 | - $results = $wpdb->get_results( $query ); |
|
| 1738 | - wp_cache_set( $key, $results, 'posts' ); |
|
| 1736 | + if ( ! $results = wp_cache_get($key, 'posts')) { |
|
| 1737 | + $results = $wpdb->get_results($query); |
|
| 1738 | + wp_cache_set($key, $results, 'posts'); |
|
| 1739 | 1739 | } |
| 1740 | - if ( $results ) { |
|
| 1740 | + if ($results) { |
|
| 1741 | 1741 | $after = $r['after']; |
| 1742 | - foreach ( (array) $results as $result) { |
|
| 1743 | - $url = get_year_link( $result->year ); |
|
| 1744 | - if ( 'post' !== $r['post_type'] ) { |
|
| 1745 | - $url = add_query_arg( 'post_type', $r['post_type'], $url ); |
|
| 1742 | + foreach ((array) $results as $result) { |
|
| 1743 | + $url = get_year_link($result->year); |
|
| 1744 | + if ('post' !== $r['post_type']) { |
|
| 1745 | + $url = add_query_arg('post_type', $r['post_type'], $url); |
|
| 1746 | 1746 | } |
| 1747 | - $text = sprintf( '%d', $result->year ); |
|
| 1748 | - if ( $r['show_post_count'] ) { |
|
| 1749 | - $r['after'] = ' (' . $result->posts . ')' . $after; |
|
| 1747 | + $text = sprintf('%d', $result->year); |
|
| 1748 | + if ($r['show_post_count']) { |
|
| 1749 | + $r['after'] = ' ('.$result->posts.')'.$after; |
|
| 1750 | 1750 | } |
| 1751 | - $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); |
|
| 1751 | + $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']); |
|
| 1752 | 1752 | } |
| 1753 | 1753 | } |
| 1754 | - } elseif ( 'daily' == $r['type'] ) { |
|
| 1754 | + } elseif ('daily' == $r['type']) { |
|
| 1755 | 1755 | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; |
| 1756 | - $key = md5( $query ); |
|
| 1756 | + $key = md5($query); |
|
| 1757 | 1757 | $key = "wp_get_archives:$key:$last_changed"; |
| 1758 | - if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
|
| 1759 | - $results = $wpdb->get_results( $query ); |
|
| 1760 | - wp_cache_set( $key, $results, 'posts' ); |
|
| 1758 | + if ( ! $results = wp_cache_get($key, 'posts')) { |
|
| 1759 | + $results = $wpdb->get_results($query); |
|
| 1760 | + wp_cache_set($key, $results, 'posts'); |
|
| 1761 | 1761 | } |
| 1762 | - if ( $results ) { |
|
| 1762 | + if ($results) { |
|
| 1763 | 1763 | $after = $r['after']; |
| 1764 | - foreach ( (array) $results as $result ) { |
|
| 1765 | - $url = get_day_link( $result->year, $result->month, $result->dayofmonth ); |
|
| 1766 | - if ( 'post' !== $r['post_type'] ) { |
|
| 1767 | - $url = add_query_arg( 'post_type', $r['post_type'], $url ); |
|
| 1764 | + foreach ((array) $results as $result) { |
|
| 1765 | + $url = get_day_link($result->year, $result->month, $result->dayofmonth); |
|
| 1766 | + if ('post' !== $r['post_type']) { |
|
| 1767 | + $url = add_query_arg('post_type', $r['post_type'], $url); |
|
| 1768 | 1768 | } |
| 1769 | - $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth ); |
|
| 1770 | - $text = mysql2date( get_option( 'date_format' ), $date ); |
|
| 1771 | - if ( $r['show_post_count'] ) { |
|
| 1772 | - $r['after'] = ' (' . $result->posts . ')' . $after; |
|
| 1769 | + $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth); |
|
| 1770 | + $text = mysql2date(get_option('date_format'), $date); |
|
| 1771 | + if ($r['show_post_count']) { |
|
| 1772 | + $r['after'] = ' ('.$result->posts.')'.$after; |
|
| 1773 | 1773 | } |
| 1774 | - $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); |
|
| 1774 | + $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']); |
|
| 1775 | 1775 | } |
| 1776 | 1776 | } |
| 1777 | - } elseif ( 'weekly' == $r['type'] ) { |
|
| 1778 | - $week = _wp_mysql_week( '`post_date`' ); |
|
| 1777 | + } elseif ('weekly' == $r['type']) { |
|
| 1778 | + $week = _wp_mysql_week('`post_date`'); |
|
| 1779 | 1779 | $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; |
| 1780 | - $key = md5( $query ); |
|
| 1780 | + $key = md5($query); |
|
| 1781 | 1781 | $key = "wp_get_archives:$key:$last_changed"; |
| 1782 | - if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
|
| 1783 | - $results = $wpdb->get_results( $query ); |
|
| 1784 | - wp_cache_set( $key, $results, 'posts' ); |
|
| 1782 | + if ( ! $results = wp_cache_get($key, 'posts')) { |
|
| 1783 | + $results = $wpdb->get_results($query); |
|
| 1784 | + wp_cache_set($key, $results, 'posts'); |
|
| 1785 | 1785 | } |
| 1786 | 1786 | $arc_w_last = ''; |
| 1787 | - if ( $results ) { |
|
| 1787 | + if ($results) { |
|
| 1788 | 1788 | $after = $r['after']; |
| 1789 | - foreach ( (array) $results as $result ) { |
|
| 1790 | - if ( $result->week != $arc_w_last ) { |
|
| 1789 | + foreach ((array) $results as $result) { |
|
| 1790 | + if ($result->week != $arc_w_last) { |
|
| 1791 | 1791 | $arc_year = $result->yr; |
| 1792 | 1792 | $arc_w_last = $result->week; |
| 1793 | - $arc_week = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) ); |
|
| 1794 | - $arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] ); |
|
| 1795 | - $arc_week_end = date_i18n( get_option( 'date_format' ), $arc_week['end'] ); |
|
| 1796 | - $url = add_query_arg( array( 'm' => $arc_year, 'w' => $result->week, ), home_url( '/' ) ); |
|
| 1797 | - if ( 'post' !== $r['post_type'] ) { |
|
| 1798 | - $url = add_query_arg( 'post_type', $r['post_type'], $url ); |
|
| 1793 | + $arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week')); |
|
| 1794 | + $arc_week_start = date_i18n(get_option('date_format'), $arc_week['start']); |
|
| 1795 | + $arc_week_end = date_i18n(get_option('date_format'), $arc_week['end']); |
|
| 1796 | + $url = add_query_arg(array('m' => $arc_year, 'w' => $result->week,), home_url('/')); |
|
| 1797 | + if ('post' !== $r['post_type']) { |
|
| 1798 | + $url = add_query_arg('post_type', $r['post_type'], $url); |
|
| 1799 | 1799 | } |
| 1800 | - $text = $arc_week_start . $archive_week_separator . $arc_week_end; |
|
| 1801 | - if ( $r['show_post_count'] ) { |
|
| 1802 | - $r['after'] = ' (' . $result->posts . ')' . $after; |
|
| 1800 | + $text = $arc_week_start.$archive_week_separator.$arc_week_end; |
|
| 1801 | + if ($r['show_post_count']) { |
|
| 1802 | + $r['after'] = ' ('.$result->posts.')'.$after; |
|
| 1803 | 1803 | } |
| 1804 | - $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); |
|
| 1804 | + $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']); |
|
| 1805 | 1805 | } |
| 1806 | 1806 | } |
| 1807 | 1807 | } |
| 1808 | - } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) { |
|
| 1809 | - $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC '; |
|
| 1808 | + } elseif (('postbypost' == $r['type']) || ('alpha' == $r['type'])) { |
|
| 1809 | + $orderby = ('alpha' == $r['type']) ? 'post_title ASC ' : 'post_date DESC, ID DESC '; |
|
| 1810 | 1810 | $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; |
| 1811 | - $key = md5( $query ); |
|
| 1811 | + $key = md5($query); |
|
| 1812 | 1812 | $key = "wp_get_archives:$key:$last_changed"; |
| 1813 | - if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
|
| 1814 | - $results = $wpdb->get_results( $query ); |
|
| 1815 | - wp_cache_set( $key, $results, 'posts' ); |
|
| 1813 | + if ( ! $results = wp_cache_get($key, 'posts')) { |
|
| 1814 | + $results = $wpdb->get_results($query); |
|
| 1815 | + wp_cache_set($key, $results, 'posts'); |
|
| 1816 | 1816 | } |
| 1817 | - if ( $results ) { |
|
| 1818 | - foreach ( (array) $results as $result ) { |
|
| 1819 | - if ( $result->post_date != '0000-00-00 00:00:00' ) { |
|
| 1820 | - $url = get_permalink( $result ); |
|
| 1821 | - if ( $result->post_title ) { |
|
| 1817 | + if ($results) { |
|
| 1818 | + foreach ((array) $results as $result) { |
|
| 1819 | + if ($result->post_date != '0000-00-00 00:00:00') { |
|
| 1820 | + $url = get_permalink($result); |
|
| 1821 | + if ($result->post_title) { |
|
| 1822 | 1822 | /** This filter is documented in wp-includes/post-template.php */ |
| 1823 | - $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) ); |
|
| 1823 | + $text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID)); |
|
| 1824 | 1824 | } else { |
| 1825 | 1825 | $text = $result->ID; |
| 1826 | 1826 | } |
| 1827 | - $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); |
|
| 1827 | + $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']); |
|
| 1828 | 1828 | } |
| 1829 | 1829 | } |
| 1830 | 1830 | } |
| 1831 | 1831 | } |
| 1832 | - if ( $r['echo'] ) { |
|
| 1832 | + if ($r['echo']) { |
|
| 1833 | 1833 | echo $output; |
| 1834 | 1834 | } else { |
| 1835 | 1835 | return $output; |
@@ -1846,7 +1846,7 @@ discard block |
||
| 1846 | 1846 | */ |
| 1847 | 1847 | function calendar_week_mod($num) { |
| 1848 | 1848 | $base = 7; |
| 1849 | - return ($num - $base*floor($num/$base)); |
|
| 1849 | + return ($num - $base * floor($num / $base)); |
|
| 1850 | 1850 | } |
| 1851 | 1851 | |
| 1852 | 1852 | /** |
@@ -1868,17 +1868,17 @@ discard block |
||
| 1868 | 1868 | * @param bool $echo Optional, default is true. Set to false for return. |
| 1869 | 1869 | * @return string|void String when retrieving. |
| 1870 | 1870 | */ |
| 1871 | -function get_calendar( $initial = true, $echo = true ) { |
|
| 1871 | +function get_calendar($initial = true, $echo = true) { |
|
| 1872 | 1872 | global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; |
| 1873 | 1873 | |
| 1874 | - $key = md5( $m . $monthnum . $year ); |
|
| 1875 | - $cache = wp_cache_get( 'get_calendar', 'calendar' ); |
|
| 1874 | + $key = md5($m.$monthnum.$year); |
|
| 1875 | + $cache = wp_cache_get('get_calendar', 'calendar'); |
|
| 1876 | 1876 | |
| 1877 | - if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) { |
|
| 1877 | + if ($cache && is_array($cache) && isset($cache[$key])) { |
|
| 1878 | 1878 | /** This filter is documented in wp-includes/general-template.php */ |
| 1879 | - $output = apply_filters( 'get_calendar', $cache[ $key ] ); |
|
| 1879 | + $output = apply_filters('get_calendar', $cache[$key]); |
|
| 1880 | 1880 | |
| 1881 | - if ( $echo ) { |
|
| 1881 | + if ($echo) { |
|
| 1882 | 1882 | echo $output; |
| 1883 | 1883 | return; |
| 1884 | 1884 | } |
@@ -1886,51 +1886,51 @@ discard block |
||
| 1886 | 1886 | return $output; |
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | - if ( ! is_array( $cache ) ) { |
|
| 1889 | + if ( ! is_array($cache)) { |
|
| 1890 | 1890 | $cache = array(); |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | // Quick check. If we have no posts at all, abort! |
| 1894 | - if ( ! $posts ) { |
|
| 1894 | + if ( ! $posts) { |
|
| 1895 | 1895 | $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1"); |
| 1896 | - if ( ! $gotsome ) { |
|
| 1897 | - $cache[ $key ] = ''; |
|
| 1898 | - wp_cache_set( 'get_calendar', $cache, 'calendar' ); |
|
| 1896 | + if ( ! $gotsome) { |
|
| 1897 | + $cache[$key] = ''; |
|
| 1898 | + wp_cache_set('get_calendar', $cache, 'calendar'); |
|
| 1899 | 1899 | return; |
| 1900 | 1900 | } |
| 1901 | 1901 | } |
| 1902 | 1902 | |
| 1903 | - if ( isset( $_GET['w'] ) ) { |
|
| 1903 | + if (isset($_GET['w'])) { |
|
| 1904 | 1904 | $w = (int) $_GET['w']; |
| 1905 | 1905 | } |
| 1906 | 1906 | // week_begins = 0 stands for Sunday |
| 1907 | - $week_begins = (int) get_option( 'start_of_week' ); |
|
| 1908 | - $ts = current_time( 'timestamp' ); |
|
| 1907 | + $week_begins = (int) get_option('start_of_week'); |
|
| 1908 | + $ts = current_time('timestamp'); |
|
| 1909 | 1909 | |
| 1910 | 1910 | // Let's figure out when we are |
| 1911 | - if ( ! empty( $monthnum ) && ! empty( $year ) ) { |
|
| 1912 | - $thismonth = zeroise( intval( $monthnum ), 2 ); |
|
| 1911 | + if ( ! empty($monthnum) && ! empty($year)) { |
|
| 1912 | + $thismonth = zeroise(intval($monthnum), 2); |
|
| 1913 | 1913 | $thisyear = (int) $year; |
| 1914 | - } elseif ( ! empty( $w ) ) { |
|
| 1914 | + } elseif ( ! empty($w)) { |
|
| 1915 | 1915 | // We need to get the month from MySQL |
| 1916 | - $thisyear = (int) substr( $m, 0, 4 ); |
|
| 1916 | + $thisyear = (int) substr($m, 0, 4); |
|
| 1917 | 1917 | //it seems MySQL's weeks disagree with PHP's |
| 1918 | - $d = ( ( $w - 1 ) * 7 ) + 6; |
|
| 1918 | + $d = (($w - 1) * 7) + 6; |
|
| 1919 | 1919 | $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')"); |
| 1920 | - } elseif ( ! empty( $m ) ) { |
|
| 1921 | - $thisyear = (int) substr( $m, 0, 4 ); |
|
| 1922 | - if ( strlen( $m ) < 6 ) { |
|
| 1920 | + } elseif ( ! empty($m)) { |
|
| 1921 | + $thisyear = (int) substr($m, 0, 4); |
|
| 1922 | + if (strlen($m) < 6) { |
|
| 1923 | 1923 | $thismonth = '01'; |
| 1924 | 1924 | } else { |
| 1925 | - $thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 ); |
|
| 1925 | + $thismonth = zeroise((int) substr($m, 4, 2), 2); |
|
| 1926 | 1926 | } |
| 1927 | 1927 | } else { |
| 1928 | - $thisyear = gmdate( 'Y', $ts ); |
|
| 1929 | - $thismonth = gmdate( 'm', $ts ); |
|
| 1928 | + $thisyear = gmdate('Y', $ts); |
|
| 1929 | + $thismonth = gmdate('m', $ts); |
|
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | - $unixmonth = mktime( 0, 0 , 0, $thismonth, 1, $thisyear ); |
|
| 1933 | - $last_day = date( 't', $unixmonth ); |
|
| 1932 | + $unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear); |
|
| 1933 | + $last_day = date('t', $unixmonth); |
|
| 1934 | 1934 | |
| 1935 | 1935 | // Get the next and previous month and year with at least one post |
| 1936 | 1936 | $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year |
@@ -1951,21 +1951,21 @@ discard block |
||
| 1951 | 1951 | $calendar_output = '<table id="wp-calendar"> |
| 1952 | 1952 | <caption>' . sprintf( |
| 1953 | 1953 | $calendar_caption, |
| 1954 | - $wp_locale->get_month( $thismonth ), |
|
| 1955 | - date( 'Y', $unixmonth ) |
|
| 1956 | - ) . '</caption> |
|
| 1954 | + $wp_locale->get_month($thismonth), |
|
| 1955 | + date('Y', $unixmonth) |
|
| 1956 | + ).'</caption> |
|
| 1957 | 1957 | <thead> |
| 1958 | 1958 | <tr>'; |
| 1959 | 1959 | |
| 1960 | 1960 | $myweek = array(); |
| 1961 | 1961 | |
| 1962 | - for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) { |
|
| 1963 | - $myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 ); |
|
| 1962 | + for ($wdcount = 0; $wdcount <= 6; $wdcount++) { |
|
| 1963 | + $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7); |
|
| 1964 | 1964 | } |
| 1965 | 1965 | |
| 1966 | - foreach ( $myweek as $wd ) { |
|
| 1967 | - $day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd ); |
|
| 1968 | - $wd = esc_attr( $wd ); |
|
| 1966 | + foreach ($myweek as $wd) { |
|
| 1967 | + $day_name = $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); |
|
| 1968 | + $wd = esc_attr($wd); |
|
| 1969 | 1969 | $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>"; |
| 1970 | 1970 | } |
| 1971 | 1971 | |
@@ -1976,9 +1976,9 @@ discard block |
||
| 1976 | 1976 | <tfoot> |
| 1977 | 1977 | <tr>'; |
| 1978 | 1978 | |
| 1979 | - if ( $previous ) { |
|
| 1980 | - $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">« ' . |
|
| 1981 | - $wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) . |
|
| 1979 | + if ($previous) { |
|
| 1980 | + $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="'.get_month_link($previous->year, $previous->month).'">« '. |
|
| 1981 | + $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)). |
|
| 1982 | 1982 | '</a></td>'; |
| 1983 | 1983 | } else { |
| 1984 | 1984 | $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; |
@@ -1986,9 +1986,9 @@ discard block |
||
| 1986 | 1986 | |
| 1987 | 1987 | $calendar_output .= "\n\t\t".'<td class="pad"> </td>'; |
| 1988 | 1988 | |
| 1989 | - if ( $next ) { |
|
| 1990 | - $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' . |
|
| 1991 | - $wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) . |
|
| 1989 | + if ($next) { |
|
| 1990 | + $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="'.get_month_link($next->year, $next->month).'">'. |
|
| 1991 | + $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)). |
|
| 1992 | 1992 | ' »</a></td>'; |
| 1993 | 1993 | } else { |
| 1994 | 1994 | $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; |
@@ -2008,43 +2008,43 @@ discard block |
||
| 2008 | 2008 | FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' |
| 2009 | 2009 | AND post_type = 'post' AND post_status = 'publish' |
| 2010 | 2010 | AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); |
| 2011 | - if ( $dayswithposts ) { |
|
| 2012 | - foreach ( (array) $dayswithposts as $daywith ) { |
|
| 2011 | + if ($dayswithposts) { |
|
| 2012 | + foreach ((array) $dayswithposts as $daywith) { |
|
| 2013 | 2013 | $daywithpost[] = $daywith[0]; |
| 2014 | 2014 | } |
| 2015 | 2015 | } |
| 2016 | 2016 | |
| 2017 | 2017 | // See how much we should pad in the beginning |
| 2018 | - $pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins ); |
|
| 2019 | - if ( 0 != $pad ) { |
|
| 2020 | - $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr( $pad ) .'" class="pad"> </td>'; |
|
| 2018 | + $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins); |
|
| 2019 | + if (0 != $pad) { |
|
| 2020 | + $calendar_output .= "\n\t\t".'<td colspan="'.esc_attr($pad).'" class="pad"> </td>'; |
|
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | 2023 | $newrow = false; |
| 2024 | - $daysinmonth = (int) date( 't', $unixmonth ); |
|
| 2024 | + $daysinmonth = (int) date('t', $unixmonth); |
|
| 2025 | 2025 | |
| 2026 | - for ( $day = 1; $day <= $daysinmonth; ++$day ) { |
|
| 2027 | - if ( isset($newrow) && $newrow ) { |
|
| 2026 | + for ($day = 1; $day <= $daysinmonth; ++$day) { |
|
| 2027 | + if (isset($newrow) && $newrow) { |
|
| 2028 | 2028 | $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; |
| 2029 | 2029 | } |
| 2030 | 2030 | $newrow = false; |
| 2031 | 2031 | |
| 2032 | - if ( $day == gmdate( 'j', $ts ) && |
|
| 2033 | - $thismonth == gmdate( 'm', $ts ) && |
|
| 2034 | - $thisyear == gmdate( 'Y', $ts ) ) { |
|
| 2032 | + if ($day == gmdate('j', $ts) && |
|
| 2033 | + $thismonth == gmdate('m', $ts) && |
|
| 2034 | + $thisyear == gmdate('Y', $ts)) { |
|
| 2035 | 2035 | $calendar_output .= '<td id="today">'; |
| 2036 | 2036 | } else { |
| 2037 | 2037 | $calendar_output .= '<td>'; |
| 2038 | 2038 | } |
| 2039 | 2039 | |
| 2040 | - if ( in_array( $day, $daywithpost ) ) { |
|
| 2040 | + if (in_array($day, $daywithpost)) { |
|
| 2041 | 2041 | // any posts today? |
| 2042 | - $date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) ); |
|
| 2043 | - $label = sprintf( __( 'Posts published on %s' ), $date_format ); |
|
| 2042 | + $date_format = date(_x('F j, Y', 'daily archives date format'), strtotime("{$thisyear}-{$thismonth}-{$day}")); |
|
| 2043 | + $label = sprintf(__('Posts published on %s'), $date_format); |
|
| 2044 | 2044 | $calendar_output .= sprintf( |
| 2045 | 2045 | '<a href="%s" aria-label="%s">%s</a>', |
| 2046 | - get_day_link( $thisyear, $thismonth, $day ), |
|
| 2047 | - esc_attr( $label ), |
|
| 2046 | + get_day_link($thisyear, $thismonth, $day), |
|
| 2047 | + esc_attr($label), |
|
| 2048 | 2048 | $day |
| 2049 | 2049 | ); |
| 2050 | 2050 | } else { |
@@ -2052,21 +2052,21 @@ discard block |
||
| 2052 | 2052 | } |
| 2053 | 2053 | $calendar_output .= '</td>'; |
| 2054 | 2054 | |
| 2055 | - if ( 6 == calendar_week_mod( date( 'w', mktime(0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) { |
|
| 2055 | + if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) { |
|
| 2056 | 2056 | $newrow = true; |
| 2057 | 2057 | } |
| 2058 | 2058 | } |
| 2059 | 2059 | |
| 2060 | - $pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins ); |
|
| 2061 | - if ( $pad != 0 && $pad != 7 ) { |
|
| 2062 | - $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr( $pad ) .'"> </td>'; |
|
| 2060 | + $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins); |
|
| 2061 | + if ($pad != 0 && $pad != 7) { |
|
| 2062 | + $calendar_output .= "\n\t\t".'<td class="pad" colspan="'.esc_attr($pad).'"> </td>'; |
|
| 2063 | 2063 | } |
| 2064 | 2064 | $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; |
| 2065 | 2065 | |
| 2066 | - $cache[ $key ] = $calendar_output; |
|
| 2067 | - wp_cache_set( 'get_calendar', $cache, 'calendar' ); |
|
| 2066 | + $cache[$key] = $calendar_output; |
|
| 2067 | + wp_cache_set('get_calendar', $cache, 'calendar'); |
|
| 2068 | 2068 | |
| 2069 | - if ( $echo ) { |
|
| 2069 | + if ($echo) { |
|
| 2070 | 2070 | /** |
| 2071 | 2071 | * Filters the HTML calendar output. |
| 2072 | 2072 | * |
@@ -2074,11 +2074,11 @@ discard block |
||
| 2074 | 2074 | * |
| 2075 | 2075 | * @param string $calendar_output HTML output of the calendar. |
| 2076 | 2076 | */ |
| 2077 | - echo apply_filters( 'get_calendar', $calendar_output ); |
|
| 2077 | + echo apply_filters('get_calendar', $calendar_output); |
|
| 2078 | 2078 | return; |
| 2079 | 2079 | } |
| 2080 | 2080 | /** This filter is documented in wp-includes/general-template.php */ |
| 2081 | - return apply_filters( 'get_calendar', $calendar_output ); |
|
| 2081 | + return apply_filters('get_calendar', $calendar_output); |
|
| 2082 | 2082 | } |
| 2083 | 2083 | |
| 2084 | 2084 | /** |
@@ -2088,7 +2088,7 @@ discard block |
||
| 2088 | 2088 | * @since 2.1.0 |
| 2089 | 2089 | */ |
| 2090 | 2090 | function delete_get_calendar_cache() { |
| 2091 | - wp_cache_delete( 'get_calendar', 'calendar' ); |
|
| 2091 | + wp_cache_delete('get_calendar', 'calendar'); |
|
| 2092 | 2092 | } |
| 2093 | 2093 | |
| 2094 | 2094 | /** |
@@ -2106,16 +2106,16 @@ discard block |
||
| 2106 | 2106 | function allowed_tags() { |
| 2107 | 2107 | global $allowedtags; |
| 2108 | 2108 | $allowed = ''; |
| 2109 | - foreach ( (array) $allowedtags as $tag => $attributes ) { |
|
| 2109 | + foreach ((array) $allowedtags as $tag => $attributes) { |
|
| 2110 | 2110 | $allowed .= '<'.$tag; |
| 2111 | - if ( 0 < count($attributes) ) { |
|
| 2112 | - foreach ( $attributes as $attribute => $limits ) { |
|
| 2111 | + if (0 < count($attributes)) { |
|
| 2112 | + foreach ($attributes as $attribute => $limits) { |
|
| 2113 | 2113 | $allowed .= ' '.$attribute.'=""'; |
| 2114 | 2114 | } |
| 2115 | 2115 | } |
| 2116 | 2116 | $allowed .= '> '; |
| 2117 | 2117 | } |
| 2118 | - return htmlentities( $allowed ); |
|
| 2118 | + return htmlentities($allowed); |
|
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | 2121 | /***** Date/Time tags *****/ |
@@ -2126,7 +2126,7 @@ discard block |
||
| 2126 | 2126 | * @since 1.0.0 |
| 2127 | 2127 | */ |
| 2128 | 2128 | function the_date_xml() { |
| 2129 | - echo mysql2date( 'Y-m-d', get_post()->post_date, false ); |
|
| 2129 | + echo mysql2date('Y-m-d', get_post()->post_date, false); |
|
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | 2132 | /** |
@@ -2152,11 +2152,11 @@ discard block |
||
| 2152 | 2152 | * @param bool $echo Optional, default is display. Whether to echo the date or return it. |
| 2153 | 2153 | * @return string|void String if retrieving. |
| 2154 | 2154 | */ |
| 2155 | -function the_date( $d = '', $before = '', $after = '', $echo = true ) { |
|
| 2155 | +function the_date($d = '', $before = '', $after = '', $echo = true) { |
|
| 2156 | 2156 | global $currentday, $previousday; |
| 2157 | 2157 | |
| 2158 | - if ( is_new_day() ) { |
|
| 2159 | - $the_date = $before . get_the_date( $d ) . $after; |
|
| 2158 | + if (is_new_day()) { |
|
| 2159 | + $the_date = $before.get_the_date($d).$after; |
|
| 2160 | 2160 | $previousday = $currentday; |
| 2161 | 2161 | |
| 2162 | 2162 | /** |
@@ -2170,9 +2170,9 @@ discard block |
||
| 2170 | 2170 | * @param string $before HTML output before the date. |
| 2171 | 2171 | * @param string $after HTML output after the date. |
| 2172 | 2172 | */ |
| 2173 | - $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after ); |
|
| 2173 | + $the_date = apply_filters('the_date', $the_date, $d, $before, $after); |
|
| 2174 | 2174 | |
| 2175 | - if ( $echo ) |
|
| 2175 | + if ($echo) |
|
| 2176 | 2176 | echo $the_date; |
| 2177 | 2177 | else |
| 2178 | 2178 | return $the_date; |
@@ -2191,17 +2191,17 @@ discard block |
||
| 2191 | 2191 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. |
| 2192 | 2192 | * @return false|string Date the current post was written. False on failure. |
| 2193 | 2193 | */ |
| 2194 | -function get_the_date( $d = '', $post = null ) { |
|
| 2195 | - $post = get_post( $post ); |
|
| 2194 | +function get_the_date($d = '', $post = null) { |
|
| 2195 | + $post = get_post($post); |
|
| 2196 | 2196 | |
| 2197 | - if ( ! $post ) { |
|
| 2197 | + if ( ! $post) { |
|
| 2198 | 2198 | return false; |
| 2199 | 2199 | } |
| 2200 | 2200 | |
| 2201 | - if ( '' == $d ) { |
|
| 2202 | - $the_date = mysql2date( get_option( 'date_format' ), $post->post_date ); |
|
| 2201 | + if ('' == $d) { |
|
| 2202 | + $the_date = mysql2date(get_option('date_format'), $post->post_date); |
|
| 2203 | 2203 | } else { |
| 2204 | - $the_date = mysql2date( $d, $post->post_date ); |
|
| 2204 | + $the_date = mysql2date($d, $post->post_date); |
|
| 2205 | 2205 | } |
| 2206 | 2206 | |
| 2207 | 2207 | /** |
@@ -2214,7 +2214,7 @@ discard block |
||
| 2214 | 2214 | * if not specified. |
| 2215 | 2215 | * @param int|WP_Post $post The post object or ID. |
| 2216 | 2216 | */ |
| 2217 | - return apply_filters( 'get_the_date', $the_date, $d, $post ); |
|
| 2217 | + return apply_filters('get_the_date', $the_date, $d, $post); |
|
| 2218 | 2218 | } |
| 2219 | 2219 | |
| 2220 | 2220 | /** |
@@ -2228,8 +2228,8 @@ discard block |
||
| 2228 | 2228 | * @param bool $echo Optional, default is display. Whether to echo the date or return it. |
| 2229 | 2229 | * @return string|void String if retrieving. |
| 2230 | 2230 | */ |
| 2231 | -function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) { |
|
| 2232 | - $the_modified_date = $before . get_the_modified_date($d) . $after; |
|
| 2231 | +function the_modified_date($d = '', $before = '', $after = '', $echo = true) { |
|
| 2232 | + $the_modified_date = $before.get_the_modified_date($d).$after; |
|
| 2233 | 2233 | |
| 2234 | 2234 | /** |
| 2235 | 2235 | * Filters the date a post was last modified for display. |
@@ -2242,9 +2242,9 @@ discard block |
||
| 2242 | 2242 | * @param string $before HTML output before the date. |
| 2243 | 2243 | * @param string $after HTML output after the date. |
| 2244 | 2244 | */ |
| 2245 | - $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after ); |
|
| 2245 | + $the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after); |
|
| 2246 | 2246 | |
| 2247 | - if ( $echo ) |
|
| 2247 | + if ($echo) |
|
| 2248 | 2248 | echo $the_modified_date; |
| 2249 | 2249 | else |
| 2250 | 2250 | return $the_modified_date; |
@@ -2261,16 +2261,16 @@ discard block |
||
| 2261 | 2261 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. |
| 2262 | 2262 | * @return false|string Date the current post was modified. False on failure. |
| 2263 | 2263 | */ |
| 2264 | -function get_the_modified_date( $d = '', $post = null ) { |
|
| 2265 | - $post = get_post( $post ); |
|
| 2264 | +function get_the_modified_date($d = '', $post = null) { |
|
| 2265 | + $post = get_post($post); |
|
| 2266 | 2266 | |
| 2267 | - if ( ! $post ) { |
|
| 2267 | + if ( ! $post) { |
|
| 2268 | 2268 | // For backward compatibility, failures go through the filter below. |
| 2269 | 2269 | $the_time = false; |
| 2270 | - } elseif ( empty( $d ) ) { |
|
| 2271 | - $the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true ); |
|
| 2270 | + } elseif (empty($d)) { |
|
| 2271 | + $the_time = get_post_modified_time(get_option('date_format'), false, $post, true); |
|
| 2272 | 2272 | } else { |
| 2273 | - $the_time = get_post_modified_time( $d, false, $post, true ); |
|
| 2273 | + $the_time = get_post_modified_time($d, false, $post, true); |
|
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | 2276 | /** |
@@ -2284,7 +2284,7 @@ discard block |
||
| 2284 | 2284 | * 'date_format' option. |
| 2285 | 2285 | * @param WP_Post $post WP_Post object. |
| 2286 | 2286 | */ |
| 2287 | - return apply_filters( 'get_the_modified_date', $the_time, $d, $post ); |
|
| 2287 | + return apply_filters('get_the_modified_date', $the_time, $d, $post); |
|
| 2288 | 2288 | } |
| 2289 | 2289 | |
| 2290 | 2290 | /** |
@@ -2294,7 +2294,7 @@ discard block |
||
| 2294 | 2294 | * |
| 2295 | 2295 | * @param string $d Either 'G', 'U', or php date format. |
| 2296 | 2296 | */ |
| 2297 | -function the_time( $d = '' ) { |
|
| 2297 | +function the_time($d = '') { |
|
| 2298 | 2298 | /** |
| 2299 | 2299 | * Filters the time a post was written for display. |
| 2300 | 2300 | * |
@@ -2304,7 +2304,7 @@ discard block |
||
| 2304 | 2304 | * @param string $d The time format. Accepts 'G', 'U', |
| 2305 | 2305 | * or php date format. |
| 2306 | 2306 | */ |
| 2307 | - echo apply_filters( 'the_time', get_the_time( $d ), $d ); |
|
| 2307 | + echo apply_filters('the_time', get_the_time($d), $d); |
|
| 2308 | 2308 | } |
| 2309 | 2309 | |
| 2310 | 2310 | /** |
@@ -2318,14 +2318,14 @@ discard block |
||
| 2318 | 2318 | * @param int|WP_Post $post WP_Post object or ID. Default is global $post object. |
| 2319 | 2319 | * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure. |
| 2320 | 2320 | */ |
| 2321 | -function get_the_time( $d = '', $post = null ) { |
|
| 2321 | +function get_the_time($d = '', $post = null) { |
|
| 2322 | 2322 | $post = get_post($post); |
| 2323 | 2323 | |
| 2324 | - if ( ! $post ) { |
|
| 2324 | + if ( ! $post) { |
|
| 2325 | 2325 | return false; |
| 2326 | 2326 | } |
| 2327 | 2327 | |
| 2328 | - if ( '' == $d ) |
|
| 2328 | + if ('' == $d) |
|
| 2329 | 2329 | $the_time = get_post_time(get_option('time_format'), false, $post, true); |
| 2330 | 2330 | else |
| 2331 | 2331 | $the_time = get_post_time($d, false, $post, true); |
@@ -2341,7 +2341,7 @@ discard block |
||
| 2341 | 2341 | * in 'time_format' option. Default empty. |
| 2342 | 2342 | * @param int|WP_Post $post WP_Post object or ID. |
| 2343 | 2343 | */ |
| 2344 | - return apply_filters( 'get_the_time', $the_time, $d, $post ); |
|
| 2344 | + return apply_filters('get_the_time', $the_time, $d, $post); |
|
| 2345 | 2345 | } |
| 2346 | 2346 | |
| 2347 | 2347 | /** |
@@ -2356,14 +2356,14 @@ discard block |
||
| 2356 | 2356 | * @param bool $translate Whether to translate the time string. Default false. |
| 2357 | 2357 | * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure. |
| 2358 | 2358 | */ |
| 2359 | -function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { |
|
| 2359 | +function get_post_time($d = 'U', $gmt = false, $post = null, $translate = false) { |
|
| 2360 | 2360 | $post = get_post($post); |
| 2361 | 2361 | |
| 2362 | - if ( ! $post ) { |
|
| 2362 | + if ( ! $post) { |
|
| 2363 | 2363 | return false; |
| 2364 | 2364 | } |
| 2365 | 2365 | |
| 2366 | - if ( $gmt ) |
|
| 2366 | + if ($gmt) |
|
| 2367 | 2367 | $time = $post->post_date_gmt; |
| 2368 | 2368 | else |
| 2369 | 2369 | $time = $post->post_date; |
@@ -2380,7 +2380,7 @@ discard block |
||
| 2380 | 2380 | * Accepts 'G', 'U', or php date format. Default 'U'. |
| 2381 | 2381 | * @param bool $gmt Whether to retrieve the GMT time. Default false. |
| 2382 | 2382 | */ |
| 2383 | - return apply_filters( 'get_post_time', $time, $d, $gmt ); |
|
| 2383 | + return apply_filters('get_post_time', $time, $d, $gmt); |
|
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | 2386 | /** |
@@ -2401,7 +2401,7 @@ discard block |
||
| 2401 | 2401 | * or php date format. Defaults to value |
| 2402 | 2402 | * specified in 'time_format' option. |
| 2403 | 2403 | */ |
| 2404 | - echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d ); |
|
| 2404 | + echo apply_filters('the_modified_time', get_the_modified_time($d), $d); |
|
| 2405 | 2405 | } |
| 2406 | 2406 | |
| 2407 | 2407 | /** |
@@ -2416,16 +2416,16 @@ discard block |
||
| 2416 | 2416 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. |
| 2417 | 2417 | * @return false|string Formatted date string or Unix timestamp. False on failure. |
| 2418 | 2418 | */ |
| 2419 | -function get_the_modified_time( $d = '', $post = null ) { |
|
| 2420 | - $post = get_post( $post ); |
|
| 2419 | +function get_the_modified_time($d = '', $post = null) { |
|
| 2420 | + $post = get_post($post); |
|
| 2421 | 2421 | |
| 2422 | - if ( ! $post ) { |
|
| 2422 | + if ( ! $post) { |
|
| 2423 | 2423 | // For backward compatibility, failures go through the filter below. |
| 2424 | 2424 | $the_time = false; |
| 2425 | - } elseif ( empty( $d ) ) { |
|
| 2426 | - $the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true ); |
|
| 2425 | + } elseif (empty($d)) { |
|
| 2426 | + $the_time = get_post_modified_time(get_option('time_format'), false, $post, true); |
|
| 2427 | 2427 | } else { |
| 2428 | - $the_time = get_post_modified_time( $d, false, $post, true ); |
|
| 2428 | + $the_time = get_post_modified_time($d, false, $post, true); |
|
| 2429 | 2429 | } |
| 2430 | 2430 | |
| 2431 | 2431 | /** |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | * to value specified in 'time_format' option. |
| 2441 | 2441 | * @param WP_Post $post WP_Post object. |
| 2442 | 2442 | */ |
| 2443 | - return apply_filters( 'get_the_modified_time', $the_time, $d, $post ); |
|
| 2443 | + return apply_filters('get_the_modified_time', $the_time, $d, $post); |
|
| 2444 | 2444 | } |
| 2445 | 2445 | |
| 2446 | 2446 | /** |
@@ -2455,14 +2455,14 @@ discard block |
||
| 2455 | 2455 | * @param bool $translate Whether to translate the time string. Default false. |
| 2456 | 2456 | * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure. |
| 2457 | 2457 | */ |
| 2458 | -function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { |
|
| 2458 | +function get_post_modified_time($d = 'U', $gmt = false, $post = null, $translate = false) { |
|
| 2459 | 2459 | $post = get_post($post); |
| 2460 | 2460 | |
| 2461 | - if ( ! $post ) { |
|
| 2461 | + if ( ! $post) { |
|
| 2462 | 2462 | return false; |
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | - if ( $gmt ) |
|
| 2465 | + if ($gmt) |
|
| 2466 | 2466 | $time = $post->post_modified_gmt; |
| 2467 | 2467 | else |
| 2468 | 2468 | $time = $post->post_modified; |
@@ -2477,7 +2477,7 @@ discard block |
||
| 2477 | 2477 | * @param string $d The date format. Accepts 'G', 'U', or php date format. Default 'U'. |
| 2478 | 2478 | * @param bool $gmt Whether to return the GMT time. Default false. |
| 2479 | 2479 | */ |
| 2480 | - return apply_filters( 'get_post_modified_time', $time, $d, $gmt ); |
|
| 2480 | + return apply_filters('get_post_modified_time', $time, $d, $gmt); |
|
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | 2483 | /** |
@@ -2489,7 +2489,7 @@ discard block |
||
| 2489 | 2489 | */ |
| 2490 | 2490 | function the_weekday() { |
| 2491 | 2491 | global $wp_locale; |
| 2492 | - $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); |
|
| 2492 | + $the_weekday = $wp_locale->get_weekday(mysql2date('w', get_post()->post_date, false)); |
|
| 2493 | 2493 | |
| 2494 | 2494 | /** |
| 2495 | 2495 | * Filters the weekday on which the post was written, for display. |
@@ -2498,7 +2498,7 @@ discard block |
||
| 2498 | 2498 | * |
| 2499 | 2499 | * @param string $the_weekday |
| 2500 | 2500 | */ |
| 2501 | - echo apply_filters( 'the_weekday', $the_weekday ); |
|
| 2501 | + echo apply_filters('the_weekday', $the_weekday); |
|
| 2502 | 2502 | } |
| 2503 | 2503 | |
| 2504 | 2504 | /** |
@@ -2516,12 +2516,12 @@ discard block |
||
| 2516 | 2516 | * @param string $before Optional Output before the date. |
| 2517 | 2517 | * @param string $after Optional Output after the date. |
| 2518 | 2518 | */ |
| 2519 | -function the_weekday_date($before='',$after='') { |
|
| 2519 | +function the_weekday_date($before = '', $after = '') { |
|
| 2520 | 2520 | global $wp_locale, $currentday, $previousweekday; |
| 2521 | 2521 | $the_weekday_date = ''; |
| 2522 | - if ( $currentday != $previousweekday ) { |
|
| 2522 | + if ($currentday != $previousweekday) { |
|
| 2523 | 2523 | $the_weekday_date .= $before; |
| 2524 | - $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); |
|
| 2524 | + $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', get_post()->post_date, false)); |
|
| 2525 | 2525 | $the_weekday_date .= $after; |
| 2526 | 2526 | $previousweekday = $currentday; |
| 2527 | 2527 | } |
@@ -2535,7 +2535,7 @@ discard block |
||
| 2535 | 2535 | * @param string $before The HTML to output before the date. |
| 2536 | 2536 | * @param string $after The HTML to output after the date. |
| 2537 | 2537 | */ |
| 2538 | - $the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after ); |
|
| 2538 | + $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); |
|
| 2539 | 2539 | echo $the_weekday_date; |
| 2540 | 2540 | } |
| 2541 | 2541 | |
@@ -2552,7 +2552,7 @@ discard block |
||
| 2552 | 2552 | * |
| 2553 | 2553 | * @since 1.5.0 |
| 2554 | 2554 | */ |
| 2555 | - do_action( 'wp_head' ); |
|
| 2555 | + do_action('wp_head'); |
|
| 2556 | 2556 | } |
| 2557 | 2557 | |
| 2558 | 2558 | /** |
@@ -2568,7 +2568,7 @@ discard block |
||
| 2568 | 2568 | * |
| 2569 | 2569 | * @since 1.5.1 |
| 2570 | 2570 | */ |
| 2571 | - do_action( 'wp_footer' ); |
|
| 2571 | + do_action('wp_footer'); |
|
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | 2574 | /** |
@@ -2578,8 +2578,8 @@ discard block |
||
| 2578 | 2578 | * |
| 2579 | 2579 | * @param array $args Optional arguments. |
| 2580 | 2580 | */ |
| 2581 | -function feed_links( $args = array() ) { |
|
| 2582 | - if ( !current_theme_supports('automatic-feed-links') ) |
|
| 2581 | +function feed_links($args = array()) { |
|
| 2582 | + if ( ! current_theme_supports('automatic-feed-links')) |
|
| 2583 | 2583 | return; |
| 2584 | 2584 | |
| 2585 | 2585 | $defaults = array( |
@@ -2591,7 +2591,7 @@ discard block |
||
| 2591 | 2591 | 'comstitle' => __('%1$s %2$s Comments Feed'), |
| 2592 | 2592 | ); |
| 2593 | 2593 | |
| 2594 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2594 | + $args = wp_parse_args($args, $defaults); |
|
| 2595 | 2595 | |
| 2596 | 2596 | /** |
| 2597 | 2597 | * Filters whether to display the posts feed link. |
@@ -2600,8 +2600,8 @@ discard block |
||
| 2600 | 2600 | * |
| 2601 | 2601 | * @param bool $show Whether to display the posts feed link. Default true. |
| 2602 | 2602 | */ |
| 2603 | - if ( apply_filters( 'feed_links_show_posts_feed', true ) ) { |
|
| 2604 | - echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n"; |
|
| 2603 | + if (apply_filters('feed_links_show_posts_feed', true)) { |
|
| 2604 | + echo '<link rel="alternate" type="'.feed_content_type().'" title="'.esc_attr(sprintf($args['feedtitle'], get_bloginfo('name'), $args['separator'])).'" href="'.esc_url(get_feed_link())."\" />\n"; |
|
| 2605 | 2605 | } |
| 2606 | 2606 | |
| 2607 | 2607 | /** |
@@ -2611,8 +2611,8 @@ discard block |
||
| 2611 | 2611 | * |
| 2612 | 2612 | * @param bool $show Whether to display the comments feed link. Default true. |
| 2613 | 2613 | */ |
| 2614 | - if ( apply_filters( 'feed_links_show_comments_feed', true ) ) { |
|
| 2615 | - echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n"; |
|
| 2614 | + if (apply_filters('feed_links_show_comments_feed', true)) { |
|
| 2615 | + echo '<link rel="alternate" type="'.feed_content_type().'" title="'.esc_attr(sprintf($args['comstitle'], get_bloginfo('name'), $args['separator'])).'" href="'.esc_url(get_feed_link('comments_'.get_default_feed()))."\" />\n"; |
|
| 2616 | 2616 | } |
| 2617 | 2617 | } |
| 2618 | 2618 | |
@@ -2623,7 +2623,7 @@ discard block |
||
| 2623 | 2623 | * |
| 2624 | 2624 | * @param array $args Optional arguments. |
| 2625 | 2625 | */ |
| 2626 | -function feed_links_extra( $args = array() ) { |
|
| 2626 | +function feed_links_extra($args = array()) { |
|
| 2627 | 2627 | $defaults = array( |
| 2628 | 2628 | /* translators: Separator between blog name and feed type in feed links */ |
| 2629 | 2629 | 'separator' => _x('»', 'feed link'), |
@@ -2643,60 +2643,60 @@ discard block |
||
| 2643 | 2643 | 'posttypetitle' => __('%1$s %2$s %3$s Feed'), |
| 2644 | 2644 | ); |
| 2645 | 2645 | |
| 2646 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2646 | + $args = wp_parse_args($args, $defaults); |
|
| 2647 | 2647 | |
| 2648 | - if ( is_singular() ) { |
|
| 2648 | + if (is_singular()) { |
|
| 2649 | 2649 | $id = 0; |
| 2650 | - $post = get_post( $id ); |
|
| 2650 | + $post = get_post($id); |
|
| 2651 | 2651 | |
| 2652 | - if ( comments_open() || pings_open() || $post->comment_count > 0 ) { |
|
| 2653 | - $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) ); |
|
| 2654 | - $href = get_post_comments_feed_link( $post->ID ); |
|
| 2652 | + if (comments_open() || pings_open() || $post->comment_count > 0) { |
|
| 2653 | + $title = sprintf($args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute(array('echo' => false))); |
|
| 2654 | + $href = get_post_comments_feed_link($post->ID); |
|
| 2655 | 2655 | } |
| 2656 | - } elseif ( is_post_type_archive() ) { |
|
| 2657 | - $post_type = get_query_var( 'post_type' ); |
|
| 2658 | - if ( is_array( $post_type ) ) |
|
| 2659 | - $post_type = reset( $post_type ); |
|
| 2660 | - |
|
| 2661 | - $post_type_obj = get_post_type_object( $post_type ); |
|
| 2662 | - $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name ); |
|
| 2663 | - $href = get_post_type_archive_feed_link( $post_type_obj->name ); |
|
| 2664 | - } elseif ( is_category() ) { |
|
| 2656 | + } elseif (is_post_type_archive()) { |
|
| 2657 | + $post_type = get_query_var('post_type'); |
|
| 2658 | + if (is_array($post_type)) |
|
| 2659 | + $post_type = reset($post_type); |
|
| 2660 | + |
|
| 2661 | + $post_type_obj = get_post_type_object($post_type); |
|
| 2662 | + $title = sprintf($args['posttypetitle'], get_bloginfo('name'), $args['separator'], $post_type_obj->labels->name); |
|
| 2663 | + $href = get_post_type_archive_feed_link($post_type_obj->name); |
|
| 2664 | + } elseif (is_category()) { |
|
| 2665 | 2665 | $term = get_queried_object(); |
| 2666 | 2666 | |
| 2667 | - if ( $term ) { |
|
| 2668 | - $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); |
|
| 2669 | - $href = get_category_feed_link( $term->term_id ); |
|
| 2667 | + if ($term) { |
|
| 2668 | + $title = sprintf($args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name); |
|
| 2669 | + $href = get_category_feed_link($term->term_id); |
|
| 2670 | 2670 | } |
| 2671 | - } elseif ( is_tag() ) { |
|
| 2671 | + } elseif (is_tag()) { |
|
| 2672 | 2672 | $term = get_queried_object(); |
| 2673 | 2673 | |
| 2674 | - if ( $term ) { |
|
| 2675 | - $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); |
|
| 2676 | - $href = get_tag_feed_link( $term->term_id ); |
|
| 2674 | + if ($term) { |
|
| 2675 | + $title = sprintf($args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name); |
|
| 2676 | + $href = get_tag_feed_link($term->term_id); |
|
| 2677 | 2677 | } |
| 2678 | - } elseif ( is_tax() ) { |
|
| 2678 | + } elseif (is_tax()) { |
|
| 2679 | 2679 | $term = get_queried_object(); |
| 2680 | - $tax = get_taxonomy( $term->taxonomy ); |
|
| 2681 | - $title = sprintf( $args['taxtitle'], get_bloginfo('name'), $args['separator'], $term->name, $tax->labels->singular_name ); |
|
| 2682 | - $href = get_term_feed_link( $term->term_id, $term->taxonomy ); |
|
| 2683 | - } elseif ( is_author() ) { |
|
| 2684 | - $author_id = intval( get_query_var('author') ); |
|
| 2685 | - |
|
| 2686 | - $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ); |
|
| 2687 | - $href = get_author_feed_link( $author_id ); |
|
| 2688 | - } elseif ( is_search() ) { |
|
| 2689 | - $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ); |
|
| 2680 | + $tax = get_taxonomy($term->taxonomy); |
|
| 2681 | + $title = sprintf($args['taxtitle'], get_bloginfo('name'), $args['separator'], $term->name, $tax->labels->singular_name); |
|
| 2682 | + $href = get_term_feed_link($term->term_id, $term->taxonomy); |
|
| 2683 | + } elseif (is_author()) { |
|
| 2684 | + $author_id = intval(get_query_var('author')); |
|
| 2685 | + |
|
| 2686 | + $title = sprintf($args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta('display_name', $author_id)); |
|
| 2687 | + $href = get_author_feed_link($author_id); |
|
| 2688 | + } elseif (is_search()) { |
|
| 2689 | + $title = sprintf($args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query(false)); |
|
| 2690 | 2690 | $href = get_search_feed_link(); |
| 2691 | - } elseif ( is_post_type_archive() ) { |
|
| 2692 | - $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) ); |
|
| 2691 | + } elseif (is_post_type_archive()) { |
|
| 2692 | + $title = sprintf($args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title('', false)); |
|
| 2693 | 2693 | $post_type_obj = get_queried_object(); |
| 2694 | - if ( $post_type_obj ) |
|
| 2695 | - $href = get_post_type_archive_feed_link( $post_type_obj->name ); |
|
| 2694 | + if ($post_type_obj) |
|
| 2695 | + $href = get_post_type_archive_feed_link($post_type_obj->name); |
|
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | - if ( isset($title) && isset($href) ) |
|
| 2699 | - echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n"; |
|
| 2698 | + if (isset($title) && isset($href)) |
|
| 2699 | + echo '<link rel="alternate" type="'.feed_content_type().'" title="'.esc_attr($title).'" href="'.esc_url($href).'" />'."\n"; |
|
| 2700 | 2700 | } |
| 2701 | 2701 | |
| 2702 | 2702 | /** |
@@ -2706,7 +2706,7 @@ discard block |
||
| 2706 | 2706 | * @since 2.0.0 |
| 2707 | 2707 | */ |
| 2708 | 2708 | function rsd_link() { |
| 2709 | - echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) . '" />' . "\n"; |
|
| 2709 | + echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="'.esc_url(site_url('xmlrpc.php?rsd', 'rpc')).'" />'."\n"; |
|
| 2710 | 2710 | } |
| 2711 | 2711 | |
| 2712 | 2712 | /** |
@@ -2717,7 +2717,7 @@ discard block |
||
| 2717 | 2717 | */ |
| 2718 | 2718 | function wlwmanifest_link() { |
| 2719 | 2719 | echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="', |
| 2720 | - includes_url( 'wlwmanifest.xml' ), '" /> ', "\n"; |
|
| 2720 | + includes_url('wlwmanifest.xml'), '" /> ', "\n"; |
|
| 2721 | 2721 | } |
| 2722 | 2722 | |
| 2723 | 2723 | /** |
@@ -2737,7 +2737,7 @@ discard block |
||
| 2737 | 2737 | */ |
| 2738 | 2738 | function noindex() { |
| 2739 | 2739 | // If the blog is not public, tell robots to go away. |
| 2740 | - if ( '0' == get_option('blog_public') ) |
|
| 2740 | + if ('0' == get_option('blog_public')) |
|
| 2741 | 2741 | wp_no_robots(); |
| 2742 | 2742 | } |
| 2743 | 2743 | |
@@ -2761,15 +2761,15 @@ discard block |
||
| 2761 | 2761 | * @link https://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#rel-icon HTML5 specification link icon. |
| 2762 | 2762 | */ |
| 2763 | 2763 | function wp_site_icon() { |
| 2764 | - if ( ! has_site_icon() && ! is_customize_preview() ) { |
|
| 2764 | + if ( ! has_site_icon() && ! is_customize_preview()) { |
|
| 2765 | 2765 | return; |
| 2766 | 2766 | } |
| 2767 | 2767 | |
| 2768 | 2768 | $meta_tags = array( |
| 2769 | - sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( get_site_icon_url( 32 ) ) ), |
|
| 2770 | - sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( get_site_icon_url( 192 ) ) ), |
|
| 2771 | - sprintf( '<link rel="apple-touch-icon-precomposed" href="%s" />', esc_url( get_site_icon_url( 180 ) ) ), |
|
| 2772 | - sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( get_site_icon_url( 270 ) ) ), |
|
| 2769 | + sprintf('<link rel="icon" href="%s" sizes="32x32" />', esc_url(get_site_icon_url(32))), |
|
| 2770 | + sprintf('<link rel="icon" href="%s" sizes="192x192" />', esc_url(get_site_icon_url(192))), |
|
| 2771 | + sprintf('<link rel="apple-touch-icon-precomposed" href="%s" />', esc_url(get_site_icon_url(180))), |
|
| 2772 | + sprintf('<meta name="msapplication-TileImage" content="%s" />', esc_url(get_site_icon_url(270))), |
|
| 2773 | 2773 | ); |
| 2774 | 2774 | |
| 2775 | 2775 | /** |
@@ -2779,10 +2779,10 @@ discard block |
||
| 2779 | 2779 | * |
| 2780 | 2780 | * @param array $meta_tags Site Icon meta elements. |
| 2781 | 2781 | */ |
| 2782 | - $meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags ); |
|
| 2783 | - $meta_tags = array_filter( $meta_tags ); |
|
| 2782 | + $meta_tags = apply_filters('site_icon_meta_tags', $meta_tags); |
|
| 2783 | + $meta_tags = array_filter($meta_tags); |
|
| 2784 | 2784 | |
| 2785 | - foreach ( $meta_tags as $meta_tag ) { |
|
| 2785 | + foreach ($meta_tags as $meta_tag) { |
|
| 2786 | 2786 | echo "$meta_tag\n"; |
| 2787 | 2787 | } |
| 2788 | 2788 | } |
@@ -2812,9 +2812,9 @@ discard block |
||
| 2812 | 2812 | * The path is removed in the foreach loop below. |
| 2813 | 2813 | */ |
| 2814 | 2814 | /** This filter is documented in wp-includes/formatting.php */ |
| 2815 | - $hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' ); |
|
| 2815 | + $hints['dns-prefetch'][] = apply_filters('emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/'); |
|
| 2816 | 2816 | |
| 2817 | - foreach ( $hints as $relation_type => $urls ) { |
|
| 2817 | + foreach ($hints as $relation_type => $urls) { |
|
| 2818 | 2818 | /** |
| 2819 | 2819 | * Filters domains and URLs for resource hints of relation type. |
| 2820 | 2820 | * |
@@ -2823,38 +2823,38 @@ discard block |
||
| 2823 | 2823 | * @param array $urls URLs to print for resource hints. |
| 2824 | 2824 | * @param string $relation_type The relation type the URLs are printed for, e.g. 'preconnect' or 'prerender'. |
| 2825 | 2825 | */ |
| 2826 | - $urls = apply_filters( 'wp_resource_hints', $urls, $relation_type ); |
|
| 2826 | + $urls = apply_filters('wp_resource_hints', $urls, $relation_type); |
|
| 2827 | 2827 | |
| 2828 | - foreach ( $urls as $key => $url ) { |
|
| 2829 | - $url = esc_url( $url, array( 'http', 'https' ) ); |
|
| 2830 | - if ( ! $url ) { |
|
| 2831 | - unset( $urls[ $key ] ); |
|
| 2828 | + foreach ($urls as $key => $url) { |
|
| 2829 | + $url = esc_url($url, array('http', 'https')); |
|
| 2830 | + if ( ! $url) { |
|
| 2831 | + unset($urls[$key]); |
|
| 2832 | 2832 | continue; |
| 2833 | 2833 | } |
| 2834 | 2834 | |
| 2835 | - if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) { |
|
| 2836 | - $parsed = wp_parse_url( $url ); |
|
| 2837 | - if ( empty( $parsed['host'] ) ) { |
|
| 2838 | - unset( $urls[ $key ] ); |
|
| 2835 | + if (in_array($relation_type, array('preconnect', 'dns-prefetch'))) { |
|
| 2836 | + $parsed = wp_parse_url($url); |
|
| 2837 | + if (empty($parsed['host'])) { |
|
| 2838 | + unset($urls[$key]); |
|
| 2839 | 2839 | continue; |
| 2840 | 2840 | } |
| 2841 | 2841 | |
| 2842 | - if ( 'dns-prefetch' === $relation_type ) { |
|
| 2843 | - $url = '//' . $parsed['host']; |
|
| 2844 | - } else if ( ! empty( $parsed['scheme'] ) ) { |
|
| 2845 | - $url = $parsed['scheme'] . '://' . $parsed['host']; |
|
| 2842 | + if ('dns-prefetch' === $relation_type) { |
|
| 2843 | + $url = '//'.$parsed['host']; |
|
| 2844 | + } else if ( ! empty($parsed['scheme'])) { |
|
| 2845 | + $url = $parsed['scheme'].'://'.$parsed['host']; |
|
| 2846 | 2846 | } else { |
| 2847 | 2847 | $url = $parsed['host']; |
| 2848 | 2848 | } |
| 2849 | 2849 | } |
| 2850 | 2850 | |
| 2851 | - $urls[ $key ] = $url; |
|
| 2851 | + $urls[$key] = $url; |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | - $urls = array_unique( $urls ); |
|
| 2854 | + $urls = array_unique($urls); |
|
| 2855 | 2855 | |
| 2856 | - foreach ( $urls as $url ) { |
|
| 2857 | - printf( "<link rel='%s' href='%s'>\n", $relation_type, $url ); |
|
| 2856 | + foreach ($urls as $url) { |
|
| 2857 | + printf("<link rel='%s' href='%s'>\n", $relation_type, $url); |
|
| 2858 | 2858 | } |
| 2859 | 2859 | } |
| 2860 | 2860 | } |
@@ -2871,18 +2871,18 @@ discard block |
||
| 2871 | 2871 | |
| 2872 | 2872 | $unique_hosts = array(); |
| 2873 | 2873 | |
| 2874 | - foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) { |
|
| 2875 | - if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) { |
|
| 2876 | - foreach ( $dependencies->queue as $handle ) { |
|
| 2877 | - if ( ! isset( $dependencies->registered[ $handle ] ) ) { |
|
| 2874 | + foreach (array($wp_scripts, $wp_styles) as $dependencies) { |
|
| 2875 | + if ($dependencies instanceof WP_Dependencies && ! empty($dependencies->queue)) { |
|
| 2876 | + foreach ($dependencies->queue as $handle) { |
|
| 2877 | + if ( ! isset($dependencies->registered[$handle])) { |
|
| 2878 | 2878 | continue; |
| 2879 | 2879 | } |
| 2880 | 2880 | |
| 2881 | 2881 | /* @var _WP_Dependency $dependency */ |
| 2882 | - $dependency = $dependencies->registered[ $handle ]; |
|
| 2883 | - $parsed = wp_parse_url( $dependency->src ); |
|
| 2882 | + $dependency = $dependencies->registered[$handle]; |
|
| 2883 | + $parsed = wp_parse_url($dependency->src); |
|
| 2884 | 2884 | |
| 2885 | - if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { |
|
| 2885 | + if ( ! empty($parsed['host']) && ! in_array($parsed['host'], $unique_hosts) && $parsed['host'] !== $_SERVER['SERVER_NAME']) { |
|
| 2886 | 2886 | $unique_hosts[] = $parsed['host']; |
| 2887 | 2887 | } |
| 2888 | 2888 | } |
@@ -2912,13 +2912,13 @@ discard block |
||
| 2912 | 2912 | function user_can_richedit() { |
| 2913 | 2913 | global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge; |
| 2914 | 2914 | |
| 2915 | - if ( !isset($wp_rich_edit) ) { |
|
| 2915 | + if ( ! isset($wp_rich_edit)) { |
|
| 2916 | 2916 | $wp_rich_edit = false; |
| 2917 | 2917 | |
| 2918 | - if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users |
|
| 2919 | - if ( $is_safari ) { |
|
| 2920 | - $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); |
|
| 2921 | - } elseif ( $is_gecko || $is_chrome || $is_IE || $is_edge || ( $is_opera && !wp_is_mobile() ) ) { |
|
| 2918 | + if (get_user_option('rich_editing') == 'true' || ! is_user_logged_in()) { // default to 'true' for logged out users |
|
| 2919 | + if ($is_safari) { |
|
| 2920 | + $wp_rich_edit = ! wp_is_mobile() || (preg_match('!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match) && intval($match[1]) >= 534); |
|
| 2921 | + } elseif ($is_gecko || $is_chrome || $is_IE || $is_edge || ($is_opera && ! wp_is_mobile())) { |
|
| 2922 | 2922 | $wp_rich_edit = true; |
| 2923 | 2923 | } |
| 2924 | 2924 | } |
@@ -2931,7 +2931,7 @@ discard block |
||
| 2931 | 2931 | * |
| 2932 | 2932 | * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor. |
| 2933 | 2933 | */ |
| 2934 | - return apply_filters( 'user_can_richedit', $wp_rich_edit ); |
|
| 2934 | + return apply_filters('user_can_richedit', $wp_rich_edit); |
|
| 2935 | 2935 | } |
| 2936 | 2936 | |
| 2937 | 2937 | /** |
@@ -2946,9 +2946,9 @@ discard block |
||
| 2946 | 2946 | */ |
| 2947 | 2947 | function wp_default_editor() { |
| 2948 | 2948 | $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults |
| 2949 | - if ( wp_get_current_user() ) { // look for cookie |
|
| 2949 | + if (wp_get_current_user()) { // look for cookie |
|
| 2950 | 2950 | $ed = get_user_setting('editor', 'tinymce'); |
| 2951 | - $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; |
|
| 2951 | + $r = (in_array($ed, array('tinymce', 'html', 'test'))) ? $ed : $r; |
|
| 2952 | 2952 | } |
| 2953 | 2953 | |
| 2954 | 2954 | /** |
@@ -2958,7 +2958,7 @@ discard block |
||
| 2958 | 2958 | * |
| 2959 | 2959 | * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'. |
| 2960 | 2960 | */ |
| 2961 | - return apply_filters( 'wp_default_editor', $r ); |
|
| 2961 | + return apply_filters('wp_default_editor', $r); |
|
| 2962 | 2962 | } |
| 2963 | 2963 | |
| 2964 | 2964 | /** |
@@ -2980,9 +2980,9 @@ discard block |
||
| 2980 | 2980 | * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/. |
| 2981 | 2981 | * @param array $settings See _WP_Editors::editor(). |
| 2982 | 2982 | */ |
| 2983 | -function wp_editor( $content, $editor_id, $settings = array() ) { |
|
| 2984 | - if ( ! class_exists( '_WP_Editors', false ) ) |
|
| 2985 | - require( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|
| 2983 | +function wp_editor($content, $editor_id, $settings = array()) { |
|
| 2984 | + if ( ! class_exists('_WP_Editors', false)) |
|
| 2985 | + require(ABSPATH.WPINC.'/class-wp-editor.php'); |
|
| 2986 | 2986 | |
| 2987 | 2987 | _WP_Editors::editor($content, $editor_id, $settings); |
| 2988 | 2988 | } |
@@ -2999,7 +2999,7 @@ discard block |
||
| 2999 | 2999 | * Only use when you are later escaping it. Do not use unescaped. |
| 3000 | 3000 | * @return string |
| 3001 | 3001 | */ |
| 3002 | -function get_search_query( $escaped = true ) { |
|
| 3002 | +function get_search_query($escaped = true) { |
|
| 3003 | 3003 | /** |
| 3004 | 3004 | * Filters the contents of the search query variable. |
| 3005 | 3005 | * |
@@ -3007,10 +3007,10 @@ discard block |
||
| 3007 | 3007 | * |
| 3008 | 3008 | * @param mixed $search Contents of the search query variable. |
| 3009 | 3009 | */ |
| 3010 | - $query = apply_filters( 'get_search_query', get_query_var( 's' ) ); |
|
| 3010 | + $query = apply_filters('get_search_query', get_query_var('s')); |
|
| 3011 | 3011 | |
| 3012 | - if ( $escaped ) |
|
| 3013 | - $query = esc_attr( $query ); |
|
| 3012 | + if ($escaped) |
|
| 3013 | + $query = esc_attr($query); |
|
| 3014 | 3014 | return $query; |
| 3015 | 3015 | } |
| 3016 | 3016 | |
@@ -3030,7 +3030,7 @@ discard block |
||
| 3030 | 3030 | * |
| 3031 | 3031 | * @param mixed $search Contents of the search query variable. |
| 3032 | 3032 | */ |
| 3033 | - echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) ); |
|
| 3033 | + echo esc_attr(apply_filters('the_search_query', get_search_query(false))); |
|
| 3034 | 3034 | } |
| 3035 | 3035 | |
| 3036 | 3036 | /** |
@@ -3043,17 +3043,17 @@ discard block |
||
| 3043 | 3043 | * |
| 3044 | 3044 | * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'. |
| 3045 | 3045 | */ |
| 3046 | -function get_language_attributes( $doctype = 'html' ) { |
|
| 3046 | +function get_language_attributes($doctype = 'html') { |
|
| 3047 | 3047 | $attributes = array(); |
| 3048 | 3048 | |
| 3049 | - if ( function_exists( 'is_rtl' ) && is_rtl() ) |
|
| 3049 | + if (function_exists('is_rtl') && is_rtl()) |
|
| 3050 | 3050 | $attributes[] = 'dir="rtl"'; |
| 3051 | 3051 | |
| 3052 | - if ( $lang = get_bloginfo('language') ) { |
|
| 3053 | - if ( get_option('html_type') == 'text/html' || $doctype == 'html' ) |
|
| 3052 | + if ($lang = get_bloginfo('language')) { |
|
| 3053 | + if (get_option('html_type') == 'text/html' || $doctype == 'html') |
|
| 3054 | 3054 | $attributes[] = "lang=\"$lang\""; |
| 3055 | 3055 | |
| 3056 | - if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' ) |
|
| 3056 | + if (get_option('html_type') != 'text/html' || $doctype == 'xhtml') |
|
| 3057 | 3057 | $attributes[] = "xml:lang=\"$lang\""; |
| 3058 | 3058 | } |
| 3059 | 3059 | |
@@ -3068,7 +3068,7 @@ discard block |
||
| 3068 | 3068 | * @param string $output A space-separated list of language attributes. |
| 3069 | 3069 | * @param string $doctype The type of html document (xhtml|html). |
| 3070 | 3070 | */ |
| 3071 | - return apply_filters( 'language_attributes', $output, $doctype ); |
|
| 3071 | + return apply_filters('language_attributes', $output, $doctype); |
|
| 3072 | 3072 | } |
| 3073 | 3073 | |
| 3074 | 3074 | /** |
@@ -3082,8 +3082,8 @@ discard block |
||
| 3082 | 3082 | * |
| 3083 | 3083 | * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'. |
| 3084 | 3084 | */ |
| 3085 | -function language_attributes( $doctype = 'html' ) { |
|
| 3086 | - echo get_language_attributes( $doctype ); |
|
| 3085 | +function language_attributes($doctype = 'html') { |
|
| 3086 | + echo get_language_attributes($doctype); |
|
| 3087 | 3087 | } |
| 3088 | 3088 | |
| 3089 | 3089 | /** |
@@ -3161,23 +3161,23 @@ discard block |
||
| 3161 | 3161 | * } |
| 3162 | 3162 | * @return array|string|void String of page links or array of page links. |
| 3163 | 3163 | */ |
| 3164 | -function paginate_links( $args = '' ) { |
|
| 3164 | +function paginate_links($args = '') { |
|
| 3165 | 3165 | global $wp_query, $wp_rewrite; |
| 3166 | 3166 | |
| 3167 | 3167 | // Setting up default values based on the current URL. |
| 3168 | - $pagenum_link = html_entity_decode( get_pagenum_link() ); |
|
| 3169 | - $url_parts = explode( '?', $pagenum_link ); |
|
| 3168 | + $pagenum_link = html_entity_decode(get_pagenum_link()); |
|
| 3169 | + $url_parts = explode('?', $pagenum_link); |
|
| 3170 | 3170 | |
| 3171 | 3171 | // Get max pages and current page out of the current query, if available. |
| 3172 | - $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; |
|
| 3173 | - $current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; |
|
| 3172 | + $total = isset($wp_query->max_num_pages) ? $wp_query->max_num_pages : 1; |
|
| 3173 | + $current = get_query_var('paged') ? intval(get_query_var('paged')) : 1; |
|
| 3174 | 3174 | |
| 3175 | 3175 | // Append the format placeholder to the base URL. |
| 3176 | - $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%'; |
|
| 3176 | + $pagenum_link = trailingslashit($url_parts[0]).'%_%'; |
|
| 3177 | 3177 | |
| 3178 | 3178 | // URL base depends on permalink settings. |
| 3179 | - $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; |
|
| 3180 | - $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; |
|
| 3179 | + $format = $wp_rewrite->using_index_permalinks() && ! strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; |
|
| 3180 | + $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base.'/%#%', 'paged') : '?paged=%#%'; |
|
| 3181 | 3181 | |
| 3182 | 3182 | $defaults = array( |
| 3183 | 3183 | 'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below) |
@@ -3197,42 +3197,42 @@ discard block |
||
| 3197 | 3197 | 'after_page_number' => '' |
| 3198 | 3198 | ); |
| 3199 | 3199 | |
| 3200 | - $args = wp_parse_args( $args, $defaults ); |
|
| 3200 | + $args = wp_parse_args($args, $defaults); |
|
| 3201 | 3201 | |
| 3202 | - if ( ! is_array( $args['add_args'] ) ) { |
|
| 3202 | + if ( ! is_array($args['add_args'])) { |
|
| 3203 | 3203 | $args['add_args'] = array(); |
| 3204 | 3204 | } |
| 3205 | 3205 | |
| 3206 | 3206 | // Merge additional query vars found in the original URL into 'add_args' array. |
| 3207 | - if ( isset( $url_parts[1] ) ) { |
|
| 3207 | + if (isset($url_parts[1])) { |
|
| 3208 | 3208 | // Find the format argument. |
| 3209 | - $format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) ); |
|
| 3210 | - $format_query = isset( $format[1] ) ? $format[1] : ''; |
|
| 3211 | - wp_parse_str( $format_query, $format_args ); |
|
| 3209 | + $format = explode('?', str_replace('%_%', $args['format'], $args['base'])); |
|
| 3210 | + $format_query = isset($format[1]) ? $format[1] : ''; |
|
| 3211 | + wp_parse_str($format_query, $format_args); |
|
| 3212 | 3212 | |
| 3213 | 3213 | // Find the query args of the requested URL. |
| 3214 | - wp_parse_str( $url_parts[1], $url_query_args ); |
|
| 3214 | + wp_parse_str($url_parts[1], $url_query_args); |
|
| 3215 | 3215 | |
| 3216 | 3216 | // Remove the format argument from the array of query arguments, to avoid overwriting custom format. |
| 3217 | - foreach ( $format_args as $format_arg => $format_arg_value ) { |
|
| 3218 | - unset( $url_query_args[ $format_arg ] ); |
|
| 3217 | + foreach ($format_args as $format_arg => $format_arg_value) { |
|
| 3218 | + unset($url_query_args[$format_arg]); |
|
| 3219 | 3219 | } |
| 3220 | 3220 | |
| 3221 | - $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) ); |
|
| 3221 | + $args['add_args'] = array_merge($args['add_args'], urlencode_deep($url_query_args)); |
|
| 3222 | 3222 | } |
| 3223 | 3223 | |
| 3224 | 3224 | // Who knows what else people pass in $args |
| 3225 | 3225 | $total = (int) $args['total']; |
| 3226 | - if ( $total < 2 ) { |
|
| 3226 | + if ($total < 2) { |
|
| 3227 | 3227 | return; |
| 3228 | 3228 | } |
| 3229 | 3229 | $current = (int) $args['current']; |
| 3230 | 3230 | $end_size = (int) $args['end_size']; // Out of bounds? Make it the default. |
| 3231 | - if ( $end_size < 1 ) { |
|
| 3231 | + if ($end_size < 1) { |
|
| 3232 | 3232 | $end_size = 1; |
| 3233 | 3233 | } |
| 3234 | 3234 | $mid_size = (int) $args['mid_size']; |
| 3235 | - if ( $mid_size < 0 ) { |
|
| 3235 | + if ($mid_size < 0) { |
|
| 3236 | 3236 | $mid_size = 2; |
| 3237 | 3237 | } |
| 3238 | 3238 | $add_args = $args['add_args']; |
@@ -3240,11 +3240,11 @@ discard block |
||
| 3240 | 3240 | $page_links = array(); |
| 3241 | 3241 | $dots = false; |
| 3242 | 3242 | |
| 3243 | - if ( $args['prev_next'] && $current && 1 < $current ) : |
|
| 3244 | - $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] ); |
|
| 3245 | - $link = str_replace( '%#%', $current - 1, $link ); |
|
| 3246 | - if ( $add_args ) |
|
| 3247 | - $link = add_query_arg( $add_args, $link ); |
|
| 3243 | + if ($args['prev_next'] && $current && 1 < $current) : |
|
| 3244 | + $link = str_replace('%_%', 2 == $current ? '' : $args['format'], $args['base']); |
|
| 3245 | + $link = str_replace('%#%', $current - 1, $link); |
|
| 3246 | + if ($add_args) |
|
| 3247 | + $link = add_query_arg($add_args, $link); |
|
| 3248 | 3248 | $link .= $args['add_fragment']; |
| 3249 | 3249 | |
| 3250 | 3250 | /** |
@@ -3254,40 +3254,40 @@ discard block |
||
| 3254 | 3254 | * |
| 3255 | 3255 | * @param string $link The paginated link URL. |
| 3256 | 3256 | */ |
| 3257 | - $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>'; |
|
| 3257 | + $page_links[] = '<a class="prev page-numbers" href="'.esc_url(apply_filters('paginate_links', $link)).'">'.$args['prev_text'].'</a>'; |
|
| 3258 | 3258 | endif; |
| 3259 | - for ( $n = 1; $n <= $total; $n++ ) : |
|
| 3260 | - if ( $n == $current ) : |
|
| 3261 | - $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>"; |
|
| 3259 | + for ($n = 1; $n <= $total; $n++) : |
|
| 3260 | + if ($n == $current) : |
|
| 3261 | + $page_links[] = "<span class='page-numbers current'>".$args['before_page_number'].number_format_i18n($n).$args['after_page_number']."</span>"; |
|
| 3262 | 3262 | $dots = true; |
| 3263 | 3263 | else : |
| 3264 | - if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : |
|
| 3265 | - $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); |
|
| 3266 | - $link = str_replace( '%#%', $n, $link ); |
|
| 3267 | - if ( $add_args ) |
|
| 3268 | - $link = add_query_arg( $add_args, $link ); |
|
| 3264 | + if ($args['show_all'] || ($n <= $end_size || ($current && $n >= $current - $mid_size && $n <= $current + $mid_size) || $n > $total - $end_size)) : |
|
| 3265 | + $link = str_replace('%_%', 1 == $n ? '' : $args['format'], $args['base']); |
|
| 3266 | + $link = str_replace('%#%', $n, $link); |
|
| 3267 | + if ($add_args) |
|
| 3268 | + $link = add_query_arg($add_args, $link); |
|
| 3269 | 3269 | $link .= $args['add_fragment']; |
| 3270 | 3270 | |
| 3271 | 3271 | /** This filter is documented in wp-includes/general-template.php */ |
| 3272 | - $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</a>"; |
|
| 3272 | + $page_links[] = "<a class='page-numbers' href='".esc_url(apply_filters('paginate_links', $link))."'>".$args['before_page_number'].number_format_i18n($n).$args['after_page_number']."</a>"; |
|
| 3273 | 3273 | $dots = true; |
| 3274 | - elseif ( $dots && ! $args['show_all'] ) : |
|
| 3275 | - $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>'; |
|
| 3274 | + elseif ($dots && ! $args['show_all']) : |
|
| 3275 | + $page_links[] = '<span class="page-numbers dots">'.__('…').'</span>'; |
|
| 3276 | 3276 | $dots = false; |
| 3277 | 3277 | endif; |
| 3278 | 3278 | endif; |
| 3279 | 3279 | endfor; |
| 3280 | - if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) : |
|
| 3281 | - $link = str_replace( '%_%', $args['format'], $args['base'] ); |
|
| 3282 | - $link = str_replace( '%#%', $current + 1, $link ); |
|
| 3283 | - if ( $add_args ) |
|
| 3284 | - $link = add_query_arg( $add_args, $link ); |
|
| 3280 | + if ($args['prev_next'] && $current && ($current < $total || -1 == $total)) : |
|
| 3281 | + $link = str_replace('%_%', $args['format'], $args['base']); |
|
| 3282 | + $link = str_replace('%#%', $current + 1, $link); |
|
| 3283 | + if ($add_args) |
|
| 3284 | + $link = add_query_arg($add_args, $link); |
|
| 3285 | 3285 | $link .= $args['add_fragment']; |
| 3286 | 3286 | |
| 3287 | 3287 | /** This filter is documented in wp-includes/general-template.php */ |
| 3288 | - $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>'; |
|
| 3288 | + $page_links[] = '<a class="next page-numbers" href="'.esc_url(apply_filters('paginate_links', $link)).'">'.$args['next_text'].'</a>'; |
|
| 3289 | 3289 | endif; |
| 3290 | - switch ( $args['type'] ) { |
|
| 3290 | + switch ($args['type']) { |
|
| 3291 | 3291 | case 'array' : |
| 3292 | 3292 | return $page_links; |
| 3293 | 3293 | |
@@ -3330,10 +3330,10 @@ discard block |
||
| 3330 | 3330 | * @type string $current SVG icon color of current admin menu link. |
| 3331 | 3331 | * } |
| 3332 | 3332 | */ |
| 3333 | -function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) { |
|
| 3333 | +function wp_admin_css_color($key, $name, $url, $colors = array(), $icons = array()) { |
|
| 3334 | 3334 | global $_wp_admin_css_colors; |
| 3335 | 3335 | |
| 3336 | - if ( !isset($_wp_admin_css_colors) ) |
|
| 3336 | + if ( ! isset($_wp_admin_css_colors)) |
|
| 3337 | 3337 | $_wp_admin_css_colors = array(); |
| 3338 | 3338 | |
| 3339 | 3339 | $_wp_admin_css_colors[$key] = (object) array( |
@@ -3355,56 +3355,56 @@ discard block |
||
| 3355 | 3355 | $suffix = is_rtl() ? '-rtl' : ''; |
| 3356 | 3356 | $suffix .= SCRIPT_DEBUG ? '' : '.min'; |
| 3357 | 3357 | |
| 3358 | - wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ), |
|
| 3358 | + wp_admin_css_color('fresh', _x('Default', 'admin color scheme'), |
|
| 3359 | 3359 | false, |
| 3360 | - array( '#222', '#333', '#0073aa', '#00a0d2' ), |
|
| 3361 | - array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' ) |
|
| 3360 | + array('#222', '#333', '#0073aa', '#00a0d2'), |
|
| 3361 | + array('base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff') |
|
| 3362 | 3362 | ); |
| 3363 | 3363 | |
| 3364 | 3364 | // Other color schemes are not available when running out of src |
| 3365 | - if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) ) |
|
| 3365 | + if (false !== strpos($GLOBALS['wp_version'], '-src')) |
|
| 3366 | 3366 | return; |
| 3367 | 3367 | |
| 3368 | - wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ), |
|
| 3369 | - admin_url( "css/colors/light/colors$suffix.css" ), |
|
| 3370 | - array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ), |
|
| 3371 | - array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' ) |
|
| 3368 | + wp_admin_css_color('light', _x('Light', 'admin color scheme'), |
|
| 3369 | + admin_url("css/colors/light/colors$suffix.css"), |
|
| 3370 | + array('#e5e5e5', '#999', '#d64e07', '#04a4cc'), |
|
| 3371 | + array('base' => '#999', 'focus' => '#ccc', 'current' => '#ccc') |
|
| 3372 | 3372 | ); |
| 3373 | 3373 | |
| 3374 | - wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ), |
|
| 3375 | - admin_url( "css/colors/blue/colors$suffix.css" ), |
|
| 3376 | - array( '#096484', '#4796b3', '#52accc', '#74B6CE' ), |
|
| 3377 | - array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' ) |
|
| 3374 | + wp_admin_css_color('blue', _x('Blue', 'admin color scheme'), |
|
| 3375 | + admin_url("css/colors/blue/colors$suffix.css"), |
|
| 3376 | + array('#096484', '#4796b3', '#52accc', '#74B6CE'), |
|
| 3377 | + array('base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff') |
|
| 3378 | 3378 | ); |
| 3379 | 3379 | |
| 3380 | - wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ), |
|
| 3381 | - admin_url( "css/colors/midnight/colors$suffix.css" ), |
|
| 3382 | - array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ), |
|
| 3383 | - array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' ) |
|
| 3380 | + wp_admin_css_color('midnight', _x('Midnight', 'admin color scheme'), |
|
| 3381 | + admin_url("css/colors/midnight/colors$suffix.css"), |
|
| 3382 | + array('#25282b', '#363b3f', '#69a8bb', '#e14d43'), |
|
| 3383 | + array('base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff') |
|
| 3384 | 3384 | ); |
| 3385 | 3385 | |
| 3386 | - wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ), |
|
| 3387 | - admin_url( "css/colors/sunrise/colors$suffix.css" ), |
|
| 3388 | - array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ), |
|
| 3389 | - array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' ) |
|
| 3386 | + wp_admin_css_color('sunrise', _x('Sunrise', 'admin color scheme'), |
|
| 3387 | + admin_url("css/colors/sunrise/colors$suffix.css"), |
|
| 3388 | + array('#b43c38', '#cf4944', '#dd823b', '#ccaf0b'), |
|
| 3389 | + array('base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff') |
|
| 3390 | 3390 | ); |
| 3391 | 3391 | |
| 3392 | - wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ), |
|
| 3393 | - admin_url( "css/colors/ectoplasm/colors$suffix.css" ), |
|
| 3394 | - array( '#413256', '#523f6d', '#a3b745', '#d46f15' ), |
|
| 3395 | - array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' ) |
|
| 3392 | + wp_admin_css_color('ectoplasm', _x('Ectoplasm', 'admin color scheme'), |
|
| 3393 | + admin_url("css/colors/ectoplasm/colors$suffix.css"), |
|
| 3394 | + array('#413256', '#523f6d', '#a3b745', '#d46f15'), |
|
| 3395 | + array('base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff') |
|
| 3396 | 3396 | ); |
| 3397 | 3397 | |
| 3398 | - wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ), |
|
| 3399 | - admin_url( "css/colors/ocean/colors$suffix.css" ), |
|
| 3400 | - array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ), |
|
| 3401 | - array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' ) |
|
| 3398 | + wp_admin_css_color('ocean', _x('Ocean', 'admin color scheme'), |
|
| 3399 | + admin_url("css/colors/ocean/colors$suffix.css"), |
|
| 3400 | + array('#627c83', '#738e96', '#9ebaa0', '#aa9d88'), |
|
| 3401 | + array('base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff') |
|
| 3402 | 3402 | ); |
| 3403 | 3403 | |
| 3404 | - wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ), |
|
| 3405 | - admin_url( "css/colors/coffee/colors$suffix.css" ), |
|
| 3406 | - array( '#46403c', '#59524c', '#c7a589', '#9ea476' ), |
|
| 3407 | - array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' ) |
|
| 3404 | + wp_admin_css_color('coffee', _x('Coffee', 'admin color scheme'), |
|
| 3405 | + admin_url("css/colors/coffee/colors$suffix.css"), |
|
| 3406 | + array('#46403c', '#59524c', '#c7a589', '#9ea476'), |
|
| 3407 | + array('base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff') |
|
| 3408 | 3408 | ); |
| 3409 | 3409 | |
| 3410 | 3410 | } |
@@ -3419,13 +3419,13 @@ discard block |
||
| 3419 | 3419 | * @param string $file file relative to wp-admin/ without its ".css" extension. |
| 3420 | 3420 | * @return string |
| 3421 | 3421 | */ |
| 3422 | -function wp_admin_css_uri( $file = 'wp-admin' ) { |
|
| 3423 | - if ( defined('WP_INSTALLING') ) { |
|
| 3422 | +function wp_admin_css_uri($file = 'wp-admin') { |
|
| 3423 | + if (defined('WP_INSTALLING')) { |
|
| 3424 | 3424 | $_file = "./$file.css"; |
| 3425 | 3425 | } else { |
| 3426 | 3426 | $_file = admin_url("$file.css"); |
| 3427 | 3427 | } |
| 3428 | - $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); |
|
| 3428 | + $_file = add_query_arg('version', get_bloginfo('version'), $_file); |
|
| 3429 | 3429 | |
| 3430 | 3430 | /** |
| 3431 | 3431 | * Filters the URI of a WordPress admin CSS file. |
@@ -3435,7 +3435,7 @@ discard block |
||
| 3435 | 3435 | * @param string $_file Relative path to the file with query arguments attached. |
| 3436 | 3436 | * @param string $file Relative path to the file, minus its ".css" extension. |
| 3437 | 3437 | */ |
| 3438 | - return apply_filters( 'wp_admin_css_uri', $_file, $file ); |
|
| 3438 | + return apply_filters('wp_admin_css_uri', $_file, $file); |
|
| 3439 | 3439 | } |
| 3440 | 3440 | |
| 3441 | 3441 | /** |
@@ -3458,15 +3458,15 @@ discard block |
||
| 3458 | 3458 | * to wp-admin/. Defaults to 'wp-admin'. |
| 3459 | 3459 | * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. |
| 3460 | 3460 | */ |
| 3461 | -function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { |
|
| 3461 | +function wp_admin_css($file = 'wp-admin', $force_echo = false) { |
|
| 3462 | 3462 | // For backward compatibility |
| 3463 | - $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file; |
|
| 3463 | + $handle = 0 === strpos($file, 'css/') ? substr($file, 4) : $file; |
|
| 3464 | 3464 | |
| 3465 | - if ( wp_styles()->query( $handle ) ) { |
|
| 3466 | - if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately |
|
| 3467 | - wp_print_styles( $handle ); |
|
| 3465 | + if (wp_styles()->query($handle)) { |
|
| 3466 | + if ($force_echo || did_action('wp_print_styles')) // we already printed the style queue. Print this one immediately |
|
| 3467 | + wp_print_styles($handle); |
|
| 3468 | 3468 | else // Add to style queue |
| 3469 | - wp_enqueue_style( $handle ); |
|
| 3469 | + wp_enqueue_style($handle); |
|
| 3470 | 3470 | return; |
| 3471 | 3471 | } |
| 3472 | 3472 | |
@@ -3481,11 +3481,11 @@ discard block |
||
| 3481 | 3481 | * @param string $file Style handle name or filename (without ".css" extension) |
| 3482 | 3482 | * relative to wp-admin/. Defaults to 'wp-admin'. |
| 3483 | 3483 | */ |
| 3484 | - echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file ); |
|
| 3484 | + echo apply_filters('wp_admin_css', "<link rel='stylesheet' href='".esc_url(wp_admin_css_uri($file))."' type='text/css' />\n", $file); |
|
| 3485 | 3485 | |
| 3486 | - if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
| 3486 | + if (function_exists('is_rtl') && is_rtl()) { |
|
| 3487 | 3487 | /** This filter is documented in wp-includes/general-template.php */ |
| 3488 | - echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" ); |
|
| 3488 | + echo apply_filters('wp_admin_css', "<link rel='stylesheet' href='".esc_url(wp_admin_css_uri("$file-rtl"))."' type='text/css' />\n", "$file-rtl"); |
|
| 3489 | 3489 | } |
| 3490 | 3490 | } |
| 3491 | 3491 | |
@@ -3499,11 +3499,11 @@ discard block |
||
| 3499 | 3499 | * @since 2.5.0 |
| 3500 | 3500 | */ |
| 3501 | 3501 | function add_thickbox() { |
| 3502 | - wp_enqueue_script( 'thickbox' ); |
|
| 3503 | - wp_enqueue_style( 'thickbox' ); |
|
| 3502 | + wp_enqueue_script('thickbox'); |
|
| 3503 | + wp_enqueue_style('thickbox'); |
|
| 3504 | 3504 | |
| 3505 | - if ( is_network_admin() ) |
|
| 3506 | - add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); |
|
| 3505 | + if (is_network_admin()) |
|
| 3506 | + add_action('admin_head', '_thickbox_path_admin_subfolder'); |
|
| 3507 | 3507 | } |
| 3508 | 3508 | |
| 3509 | 3509 | /** |
@@ -3521,7 +3521,7 @@ discard block |
||
| 3521 | 3521 | * |
| 3522 | 3522 | * @param string $generator_type The XHTML generator. |
| 3523 | 3523 | */ |
| 3524 | - the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) ); |
|
| 3524 | + the_generator(apply_filters('wp_generator_type', 'xhtml')); |
|
| 3525 | 3525 | } |
| 3526 | 3526 | |
| 3527 | 3527 | /** |
@@ -3534,7 +3534,7 @@ discard block |
||
| 3534 | 3534 | * |
| 3535 | 3535 | * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export). |
| 3536 | 3536 | */ |
| 3537 | -function the_generator( $type ) { |
|
| 3537 | +function the_generator($type) { |
|
| 3538 | 3538 | /** |
| 3539 | 3539 | * Filters the output of the XHTML generator tag for display. |
| 3540 | 3540 | * |
@@ -3544,7 +3544,7 @@ discard block |
||
| 3544 | 3544 | * @param string $type The type of generator to output. Accepts 'html', |
| 3545 | 3545 | * 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'. |
| 3546 | 3546 | */ |
| 3547 | - echo apply_filters( 'the_generator', get_the_generator($type), $type ) . "\n"; |
|
| 3547 | + echo apply_filters('the_generator', get_the_generator($type), $type)."\n"; |
|
| 3548 | 3548 | } |
| 3549 | 3549 | |
| 3550 | 3550 | /** |
@@ -3559,14 +3559,14 @@ discard block |
||
| 3559 | 3559 | * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export). |
| 3560 | 3560 | * @return string|void The HTML content for the generator. |
| 3561 | 3561 | */ |
| 3562 | -function get_the_generator( $type = '' ) { |
|
| 3563 | - if ( empty( $type ) ) { |
|
| 3562 | +function get_the_generator($type = '') { |
|
| 3563 | + if (empty($type)) { |
|
| 3564 | 3564 | |
| 3565 | 3565 | $current_filter = current_filter(); |
| 3566 | - if ( empty( $current_filter ) ) |
|
| 3566 | + if (empty($current_filter)) |
|
| 3567 | 3567 | return; |
| 3568 | 3568 | |
| 3569 | - switch ( $current_filter ) { |
|
| 3569 | + switch ($current_filter) { |
|
| 3570 | 3570 | case 'rss2_head' : |
| 3571 | 3571 | case 'commentsrss2_head' : |
| 3572 | 3572 | $type = 'rss2'; |
@@ -3586,27 +3586,27 @@ discard block |
||
| 3586 | 3586 | } |
| 3587 | 3587 | } |
| 3588 | 3588 | |
| 3589 | - switch ( $type ) { |
|
| 3589 | + switch ($type) { |
|
| 3590 | 3590 | case 'html': |
| 3591 | - $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">'; |
|
| 3591 | + $gen = '<meta name="generator" content="WordPress '.get_bloginfo('version').'">'; |
|
| 3592 | 3592 | break; |
| 3593 | 3593 | case 'xhtml': |
| 3594 | - $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />'; |
|
| 3594 | + $gen = '<meta name="generator" content="WordPress '.get_bloginfo('version').'" />'; |
|
| 3595 | 3595 | break; |
| 3596 | 3596 | case 'atom': |
| 3597 | - $gen = '<generator uri="https://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>'; |
|
| 3597 | + $gen = '<generator uri="https://wordpress.org/" version="'.get_bloginfo_rss('version').'">WordPress</generator>'; |
|
| 3598 | 3598 | break; |
| 3599 | 3599 | case 'rss2': |
| 3600 | - $gen = '<generator>https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>'; |
|
| 3600 | + $gen = '<generator>https://wordpress.org/?v='.get_bloginfo_rss('version').'</generator>'; |
|
| 3601 | 3601 | break; |
| 3602 | 3602 | case 'rdf': |
| 3603 | - $gen = '<admin:generatorAgent rdf:resource="https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />'; |
|
| 3603 | + $gen = '<admin:generatorAgent rdf:resource="https://wordpress.org/?v='.get_bloginfo_rss('version').'" />'; |
|
| 3604 | 3604 | break; |
| 3605 | 3605 | case 'comment': |
| 3606 | - $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->'; |
|
| 3606 | + $gen = '<!-- generator="WordPress/'.get_bloginfo('version').'" -->'; |
|
| 3607 | 3607 | break; |
| 3608 | 3608 | case 'export': |
| 3609 | - $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->'; |
|
| 3609 | + $gen = '<!-- generator="WordPress/'.get_bloginfo_rss('version').'" created="'.date('Y-m-d H:i').'" -->'; |
|
| 3610 | 3610 | break; |
| 3611 | 3611 | } |
| 3612 | 3612 | |
@@ -3621,7 +3621,7 @@ discard block |
||
| 3621 | 3621 | * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom', |
| 3622 | 3622 | * 'rss2', 'rdf', 'comment', 'export'. |
| 3623 | 3623 | */ |
| 3624 | - return apply_filters( "get_the_generator_{$type}", $gen, $type ); |
|
| 3624 | + return apply_filters("get_the_generator_{$type}", $gen, $type); |
|
| 3625 | 3625 | } |
| 3626 | 3626 | |
| 3627 | 3627 | /** |
@@ -3636,8 +3636,8 @@ discard block |
||
| 3636 | 3636 | * @param bool $echo Whether to echo or just return the string |
| 3637 | 3637 | * @return string html attribute or empty string |
| 3638 | 3638 | */ |
| 3639 | -function checked( $checked, $current = true, $echo = true ) { |
|
| 3640 | - return __checked_selected_helper( $checked, $current, $echo, 'checked' ); |
|
| 3639 | +function checked($checked, $current = true, $echo = true) { |
|
| 3640 | + return __checked_selected_helper($checked, $current, $echo, 'checked'); |
|
| 3641 | 3641 | } |
| 3642 | 3642 | |
| 3643 | 3643 | /** |
@@ -3652,8 +3652,8 @@ discard block |
||
| 3652 | 3652 | * @param bool $echo Whether to echo or just return the string |
| 3653 | 3653 | * @return string html attribute or empty string |
| 3654 | 3654 | */ |
| 3655 | -function selected( $selected, $current = true, $echo = true ) { |
|
| 3656 | - return __checked_selected_helper( $selected, $current, $echo, 'selected' ); |
|
| 3655 | +function selected($selected, $current = true, $echo = true) { |
|
| 3656 | + return __checked_selected_helper($selected, $current, $echo, 'selected'); |
|
| 3657 | 3657 | } |
| 3658 | 3658 | |
| 3659 | 3659 | /** |
@@ -3668,8 +3668,8 @@ discard block |
||
| 3668 | 3668 | * @param bool $echo Whether to echo or just return the string |
| 3669 | 3669 | * @return string html attribute or empty string |
| 3670 | 3670 | */ |
| 3671 | -function disabled( $disabled, $current = true, $echo = true ) { |
|
| 3672 | - return __checked_selected_helper( $disabled, $current, $echo, 'disabled' ); |
|
| 3671 | +function disabled($disabled, $current = true, $echo = true) { |
|
| 3672 | + return __checked_selected_helper($disabled, $current, $echo, 'disabled'); |
|
| 3673 | 3673 | } |
| 3674 | 3674 | |
| 3675 | 3675 | /** |
@@ -3686,13 +3686,13 @@ discard block |
||
| 3686 | 3686 | * @param string $type The type of checked|selected|disabled we are doing |
| 3687 | 3687 | * @return string html attribute or empty string |
| 3688 | 3688 | */ |
| 3689 | -function __checked_selected_helper( $helper, $current, $echo, $type ) { |
|
| 3690 | - if ( (string) $helper === (string) $current ) |
|
| 3689 | +function __checked_selected_helper($helper, $current, $echo, $type) { |
|
| 3690 | + if ((string) $helper === (string) $current) |
|
| 3691 | 3691 | $result = " $type='$type'"; |
| 3692 | 3692 | else |
| 3693 | 3693 | $result = ''; |
| 3694 | 3694 | |
| 3695 | - if ( $echo ) |
|
| 3695 | + if ($echo) |
|
| 3696 | 3696 | echo $result; |
| 3697 | 3697 | |
| 3698 | 3698 | return $result; |
@@ -3708,12 +3708,12 @@ discard block |
||
| 3708 | 3708 | * @param array $settings |
| 3709 | 3709 | * @return array $settings |
| 3710 | 3710 | */ |
| 3711 | -function wp_heartbeat_settings( $settings ) { |
|
| 3712 | - if ( ! is_admin() ) |
|
| 3713 | - $settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' ); |
|
| 3711 | +function wp_heartbeat_settings($settings) { |
|
| 3712 | + if ( ! is_admin()) |
|
| 3713 | + $settings['ajaxurl'] = admin_url('admin-ajax.php', 'relative'); |
|
| 3714 | 3714 | |
| 3715 | - if ( is_user_logged_in() ) |
|
| 3716 | - $settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' ); |
|
| 3715 | + if (is_user_logged_in()) |
|
| 3716 | + $settings['nonce'] = wp_create_nonce('heartbeat-nonce'); |
|
| 3717 | 3717 | |
| 3718 | 3718 | return $settings; |
| 3719 | 3719 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * Deprecated functions come here to die. |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if ( !function_exists('set_current_user') ) : |
|
| 18 | +if ( ! function_exists('set_current_user')) : |
|
| 19 | 19 | /** |
| 20 | 20 | * Changes the current user by ID or name. |
| 21 | 21 | * |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | * @return WP_User returns wp_set_current_user() |
| 31 | 31 | */ |
| 32 | 32 | function set_current_user($id, $name = '') { |
| 33 | - _deprecated_function( __FUNCTION__, '3.0.0', 'wp_set_current_user()' ); |
|
| 33 | + _deprecated_function(__FUNCTION__, '3.0.0', 'wp_set_current_user()'); |
|
| 34 | 34 | return wp_set_current_user($id, $name); |
| 35 | 35 | } |
| 36 | 36 | endif; |
| 37 | 37 | |
| 38 | -if ( !function_exists('get_currentuserinfo') ) : |
|
| 38 | +if ( ! function_exists('get_currentuserinfo')) : |
|
| 39 | 39 | /** |
| 40 | 40 | * Populate global variables with information about the currently logged in user. |
| 41 | 41 | * |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise. |
| 47 | 47 | */ |
| 48 | 48 | function get_currentuserinfo() { |
| 49 | - _deprecated_function( __FUNCTION__, '4.5.0', 'wp_get_current_user()' ); |
|
| 49 | + _deprecated_function(__FUNCTION__, '4.5.0', 'wp_get_current_user()'); |
|
| 50 | 50 | |
| 51 | 51 | return _wp_get_current_user(); |
| 52 | 52 | } |
| 53 | 53 | endif; |
| 54 | 54 | |
| 55 | -if ( !function_exists('get_userdatabylogin') ) : |
|
| 55 | +if ( ! function_exists('get_userdatabylogin')) : |
|
| 56 | 56 | /** |
| 57 | 57 | * Retrieve user info by login name. |
| 58 | 58 | * |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | * @return bool|object False on failure, User DB row object |
| 65 | 65 | */ |
| 66 | 66 | function get_userdatabylogin($user_login) { |
| 67 | - _deprecated_function( __FUNCTION__, '3.3.0', "get_user_by('login')" ); |
|
| 67 | + _deprecated_function(__FUNCTION__, '3.3.0', "get_user_by('login')"); |
|
| 68 | 68 | return get_user_by('login', $user_login); |
| 69 | 69 | } |
| 70 | 70 | endif; |
| 71 | 71 | |
| 72 | -if ( !function_exists('get_user_by_email') ) : |
|
| 72 | +if ( ! function_exists('get_user_by_email')) : |
|
| 73 | 73 | /** |
| 74 | 74 | * Retrieve user info by email. |
| 75 | 75 | * |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | * @return bool|object False on failure, User DB row object |
| 82 | 82 | */ |
| 83 | 83 | function get_user_by_email($email) { |
| 84 | - _deprecated_function( __FUNCTION__, '3.3.0', "get_user_by('email')" ); |
|
| 84 | + _deprecated_function(__FUNCTION__, '3.3.0', "get_user_by('email')"); |
|
| 85 | 85 | return get_user_by('email', $email); |
| 86 | 86 | } |
| 87 | 87 | endif; |
| 88 | 88 | |
| 89 | -if ( !function_exists('wp_setcookie') ) : |
|
| 89 | +if ( ! function_exists('wp_setcookie')) : |
|
| 90 | 90 | /** |
| 91 | 91 | * Sets a cookie for a user who just logged in. This function is deprecated. |
| 92 | 92 | * |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | * @param bool $remember Optional. Remember that the user is logged in |
| 103 | 103 | */ |
| 104 | 104 | function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) { |
| 105 | - _deprecated_function( __FUNCTION__, '2.5.0', 'wp_set_auth_cookie()' ); |
|
| 105 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_set_auth_cookie()'); |
|
| 106 | 106 | $user = get_user_by('login', $username); |
| 107 | 107 | wp_set_auth_cookie($user->ID, $remember); |
| 108 | 108 | } |
| 109 | 109 | else : |
| 110 | - _deprecated_function( 'wp_setcookie', '2.5.0', 'wp_set_auth_cookie()' ); |
|
| 110 | + _deprecated_function('wp_setcookie', '2.5.0', 'wp_set_auth_cookie()'); |
|
| 111 | 111 | endif; |
| 112 | 112 | |
| 113 | -if ( !function_exists('wp_clearcookie') ) : |
|
| 113 | +if ( ! function_exists('wp_clearcookie')) : |
|
| 114 | 114 | /** |
| 115 | 115 | * Clears the authentication cookie, logging the user out. This function is deprecated. |
| 116 | 116 | * |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | * @see wp_clear_auth_cookie() |
| 120 | 120 | */ |
| 121 | 121 | function wp_clearcookie() { |
| 122 | - _deprecated_function( __FUNCTION__, '2.5.0', 'wp_clear_auth_cookie()' ); |
|
| 122 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_clear_auth_cookie()'); |
|
| 123 | 123 | wp_clear_auth_cookie(); |
| 124 | 124 | } |
| 125 | 125 | else : |
| 126 | - _deprecated_function( 'wp_clearcookie', '2.5.0', 'wp_clear_auth_cookie()' ); |
|
| 126 | + _deprecated_function('wp_clearcookie', '2.5.0', 'wp_clear_auth_cookie()'); |
|
| 127 | 127 | endif; |
| 128 | 128 | |
| 129 | -if ( !function_exists('wp_get_cookie_login') ): |
|
| 129 | +if ( ! function_exists('wp_get_cookie_login')): |
|
| 130 | 130 | /** |
| 131 | 131 | * Gets the user cookie login. This function is deprecated. |
| 132 | 132 | * |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | * @return bool Always returns false |
| 140 | 140 | */ |
| 141 | 141 | function wp_get_cookie_login() { |
| 142 | - _deprecated_function( __FUNCTION__, '2.5.0' ); |
|
| 142 | + _deprecated_function(__FUNCTION__, '2.5.0'); |
|
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | else : |
| 146 | - _deprecated_function( 'wp_get_cookie_login', '2.5.0' ); |
|
| 146 | + _deprecated_function('wp_get_cookie_login', '2.5.0'); |
|
| 147 | 147 | endif; |
| 148 | 148 | |
| 149 | -if ( !function_exists('wp_login') ) : |
|
| 149 | +if ( ! function_exists('wp_login')) : |
|
| 150 | 150 | /** |
| 151 | 151 | * Checks a users login information and logs them in if it checks out. This function is deprecated. |
| 152 | 152 | * |
@@ -169,19 +169,19 @@ discard block |
||
| 169 | 169 | * @return bool False on login failure, true on successful check |
| 170 | 170 | */ |
| 171 | 171 | function wp_login($username, $password, $deprecated = '') { |
| 172 | - _deprecated_function( __FUNCTION__, '2.5.0', 'wp_signon()' ); |
|
| 172 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_signon()'); |
|
| 173 | 173 | global $error; |
| 174 | 174 | |
| 175 | 175 | $user = wp_authenticate($username, $password); |
| 176 | 176 | |
| 177 | - if ( ! is_wp_error($user) ) |
|
| 177 | + if ( ! is_wp_error($user)) |
|
| 178 | 178 | return true; |
| 179 | 179 | |
| 180 | 180 | $error = $user->get_error_message(); |
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | else : |
| 184 | - _deprecated_function( 'wp_login', '2.5.0', 'wp_signon()' ); |
|
| 184 | + _deprecated_function('wp_login', '2.5.0', 'wp_signon()'); |
|
| 185 | 185 | endif; |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | * |
| 196 | 196 | * @link https://wordpress.org/plugins/atom-publishing-protocol/ |
| 197 | 197 | */ |
| 198 | -if ( ! class_exists( 'wp_atom_server', false ) ) { |
|
| 198 | +if ( ! class_exists('wp_atom_server', false)) { |
|
| 199 | 199 | class wp_atom_server { |
| 200 | - public function __call( $name, $arguments ) { |
|
| 201 | - _deprecated_function( __CLASS__ . '::' . $name, '3.5.0', 'the Atom Publishing Protocol plugin' ); |
|
| 200 | + public function __call($name, $arguments) { |
|
| 201 | + _deprecated_function(__CLASS__.'::'.$name, '3.5.0', 'the Atom Publishing Protocol plugin'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - public static function __callStatic( $name, $arguments ) { |
|
| 205 | - _deprecated_function( __CLASS__ . '::' . $name, '3.5.0', 'the Atom Publishing Protocol plugin' ); |
|
| 204 | + public static function __callStatic($name, $arguments) { |
|
| 205 | + _deprecated_function(__CLASS__.'::'.$name, '3.5.0', 'the Atom Publishing Protocol plugin'); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |