From c4cf5124cad234a299e6f26adfd6e19438955da8 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 10 Dec 2015 03:05:34 +0000 Subject: [PATCH] Comments: The year is 2003. Permalinks are a new thing and everyone's using Blogger. It's a time when opening a modal window in JavaScript to view a section of a website is not a completely weird thing, although many users get annoyed by it. b2 has recently become WordPress, and with it comes a bunch of functionality that will become stale over the next decade, remnants of simpler times. Twelve years later, after no fewer than three themes have intentionally implemented popup comments in their functionality, before being abandoned for at least the last six years, we've reached a time where we can put this era behind us. A time when we can remove comment popup functionality from WordPress. If this breaks the internet, I'll eat my hat. Fixes #28617 git-svn-id: https://develop.svn.wordpress.org/trunk@35848 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/file.php | 2 +- src/wp-admin/includes/update-core.php | 2 + src/wp-includes/canonical.php | 4 +- src/wp-includes/class-wp.php | 2 +- src/wp-includes/comment-template.php | 82 +++-------- src/wp-includes/deprecated.php | 53 +++++++ src/wp-includes/formatting.php | 17 --- src/wp-includes/query.php | 48 ++----- src/wp-includes/template-loader.php | 1 - src/wp-includes/template.php | 25 ---- .../theme-compat/comments-popup.php | 133 ------------------ 11 files changed, 83 insertions(+), 286 deletions(-) delete mode 100644 src/wp-includes/theme-compat/comments-popup.php diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index b4a58a40a3..b8052ebe56 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -19,7 +19,6 @@ $wp_file_descriptions = array( 'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ), 'rtl.css' => __( 'RTL Stylesheet' ), 'comments.php' => __( 'Comments' ), - 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Theme Footer' ), 'header.php' => __( 'Theme Header' ), 'sidebar.php' => __( 'Sidebar' ), @@ -45,6 +44,7 @@ $wp_file_descriptions = array( 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' ), + 'comments-popup.php' => __( 'Popup Comments' ), ); /** diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 9f17a086d9..4408376990 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -700,6 +700,8 @@ $_old_files = array( 'wp-admin/js/wp-fullscreen.min.js', 'wp-includes/js/tinymce/wp-mce-help.php', 'wp-includes/js/tinymce/plugins/wpfullscreen', +// 4.5 +'wp-includes/theme-compat/comments-popup.php', ); /** diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php index cacbdaadfe..34bb774d45 100644 --- a/src/wp-includes/canonical.php +++ b/src/wp-includes/canonical.php @@ -17,7 +17,7 @@ * prevents penalty for duplicate content by redirecting all incoming links to * one or the other. * - * Prevents redirection for feeds, trackbacks, searches, comment popup, and + * Prevents redirection for feeds, trackbacks, searches, and * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+, * page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST * requests. @@ -55,7 +55,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } } - if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) { + if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) { return; } diff --git a/src/wp-includes/class-wp.php b/src/wp-includes/class-wp.php index 555167b1ea..06c59bd7b7 100644 --- a/src/wp-includes/class-wp.php +++ b/src/wp-includes/class-wp.php @@ -15,7 +15,7 @@ class WP { * @access public * @var array */ - public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'title', 'embed' ); + public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'title', 'embed' ); /** * Private query variables. diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index ada53c8997..a972963f4e 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -1388,45 +1388,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false } /** - * Display the JS popup script to show a comment. - * - * If the $file parameter is empty, then the home page is assumed. The defaults - * for the window are 400px by 400px. - * - * For the comment link popup to work, this function has to be called or the - * normal comment link will be assumed. - * - * @global string $wpcommentspopupfile The URL to use for the popup window. - * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called. - * - * @since 0.71 - * - * @param int $width Optional. The width of the popup window. Default 400. - * @param int $height Optional. The height of the popup window. Default 400. - * @param string $file Optional. Sets the location of the popup window. - */ -function comments_popup_script( $width = 400, $height = 400, $file = '' ) { - global $wpcommentspopupfile, $wpcommentsjavascript; - - if (empty ($file)) { - $wpcommentspopupfile = ''; // Use the index. - } else { - $wpcommentspopupfile = $file; - } - - $wpcommentsjavascript = 1; - $javascript = "\n"; - echo $javascript; -} - -/** - * Displays the link to the comments popup window for the current post ID. - * - * Is not meant to be displayed on single posts and pages. Should be used - * on the lists of posts - * - * @global string $wpcommentspopupfile The URL to use for the popup window. - * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called. + * Displays the link to the comments for the current post ID. * * @since 0.71 * @@ -1440,8 +1402,6 @@ function comments_popup_script( $width = 400, $height = 400, $file = '' ) { * Default false. */ function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { - global $wpcommentspopupfile, $wpcommentsjavascript; - $id = get_the_ID(); $title = get_the_title(); $number = get_comments_number( $id ); @@ -1478,31 +1438,21 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c } echo '/i', "", $text); + return $text; +} diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index e1d0de749d..b9383f5028 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -2691,23 +2691,6 @@ function iso8601_to_datetime( $date_string, $timezone = 'user' ) { } } -/** - * Adds a element attributes to open links in new windows. - * - * Comment text in popup windows should be filtered through this. Right now it's - * a moderately dumb function, ideally it would detect whether a target or rel - * attribute was already there and adjust its actions accordingly. - * - * @since 0.71 - * - * @param string $text Content to replace links to open in a new window. - * @return string Content that has filtered links. - */ -function popuplinks( $text ) { - $text = preg_replace('//i', "", $text); - return $text; -} - /** * Strips out all characters that are not allowable in an email. * diff --git a/src/wp-includes/query.php b/src/wp-includes/query.php index a2b236540e..55f617219e 100644 --- a/src/wp-includes/query.php +++ b/src/wp-includes/query.php @@ -296,26 +296,6 @@ function is_tax( $taxonomy = '', $term = '' ) { return $wp_query->is_tax( $taxonomy, $term ); } -/** - * Whether the current URL is within the comments popup window. - * - * @since 1.5.0 - * - * @global WP_Query $wp_query Global WP_Query instance. - * - * @return bool - */ -function is_comments_popup() { - global $wp_query; - - if ( ! isset( $wp_query ) ) { - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); - return false; - } - - return $wp_query->is_comments_popup(); -} - /** * Is the query for an existing date archive? * @@ -862,6 +842,7 @@ function the_comment() { * @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page. * * @since 1.5.0 + * @since 4.5.0 Removed the `$comments_popup` property. */ class WP_Query { @@ -1229,15 +1210,6 @@ class WP_Query { */ public $is_embed = false; - /** - * Set if query is within comments popup window. - * - * @since 1.5.0 - * @access public - * @var bool - */ - public $is_comments_popup = false; - /** * Set if query is paged * @@ -1389,7 +1361,6 @@ class WP_Query { $this->is_trackback = false; $this->is_home = false; $this->is_404 = false; - $this->is_comments_popup = false; $this->is_paged = false; $this->is_admin = false; $this->is_attachment = false; @@ -1441,6 +1412,7 @@ class WP_Query { * Fills in the query variables, which do not exist within the parameter. * * @since 2.1.0 + * @since 4.4.0 Removed the `comments_popup` public query variable. * @access public * * @param array $array Defined query variables. @@ -1476,7 +1448,6 @@ class WP_Query { , 'feed' , 'tb' , 'paged' - , 'comments_popup' , 'meta_key' , 'meta_value' , 'preview' @@ -1511,6 +1482,7 @@ class WP_Query { * array key to `$orderby`. * @since 4.4.0 Introduced `$post_name__in` and `$title` parameters. `$s` was updated to support excluded * search terms, by prepending a hyphen. + * @since 4.5.0 Removed the `$comments_popup` parameter. * @access public * * @param string|array $query { @@ -1529,7 +1501,6 @@ class WP_Query { * @type string $category_name Use category slug (not name, this or any children). * @type int $comments_per_page The number of comments to return per page. * Default 'comments_per_page' option. - * @type int|string $comments_popup Whether the query is within the comments popup. Default empty. * @type array $date_query An associative array of WP_Date_Query arguments. * {@see WP_Date_Query::__construct()} * @type int $day Day of the month. Default empty. Accepts numbers 1-31. @@ -1791,9 +1762,6 @@ class WP_Query { if ( '' != $qv['paged'] && ( intval($qv['paged']) > 1 ) ) $this->is_paged = true; - if ( '' != $qv['comments_popup'] ) - $this->is_comments_popup = true; - // if we're previewing inside the write screen if ( '' != $qv['preview'] ) $this->is_preview = true; @@ -1811,7 +1779,7 @@ class WP_Query { if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) $this->is_comment_feed = true; - if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup || $this->is_robots ) ) + if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) $this->is_home = true; // Correct is_* for page_on_front and page_for_posts @@ -2771,9 +2739,6 @@ class WP_Query { $where .= " AND $wpdb->posts.post_name IN ('" . implode( "' ,'", $q['post_name__in'] ) . "')"; } - if ( intval($q['comments_popup']) ) - $q['p'] = absint($q['comments_popup']); - // If an attachment is requested by number, let it supersede any post number. if ( $q['attachment_id'] ) $q['p'] = absint($q['attachment_id']); @@ -4384,11 +4349,14 @@ class WP_Query { * Whether the current URL is within the comments popup window. * * @since 3.1.0 + * @deprecated 4.5.0 * * @return bool */ public function is_comments_popup() { - return (bool) $this->is_comments_popup; + _deprecated_function( __FUNCTION__, '4.5' ); + + return false; } /** diff --git a/src/wp-includes/template-loader.php b/src/wp-includes/template-loader.php index d3eebe93ed..297b9704ff 100644 --- a/src/wp-includes/template-loader.php +++ b/src/wp-includes/template-loader.php @@ -73,7 +73,6 @@ if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) : elseif ( is_author() && $template = get_author_template() ) : elseif ( is_date() && $template = get_date_template() ) : elseif ( is_archive() && $template = get_archive_template() ) : - elseif ( is_comments_popup() && $template = get_comments_popup_template() ) : elseif ( is_paged() && $template = get_paged_template() ) : else : $template = get_index_template(); diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index 45d1db0c0f..b304e31a72 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -465,31 +465,6 @@ function get_attachment_template() { return get_query_template( 'attachment', $templates ); } -/** - * Retrieve path of comment popup template in current or parent template. - * - * Checks for comment popup template in current template, if it exists or in the - * parent template. - * - * The template path is filterable via the dynamic {@see '$type_template'} hook, - * e.g. 'commentspopup_template'. - * - * @since 1.5.0 - * - * @see get_query_template() - * - * @return string Full path to comments popup template file. - */ -function get_comments_popup_template() { - $template = get_query_template( 'comments_popup', array( 'comments-popup.php' ) ); - - // Backward compat code will be removed in a future release. - if ('' == $template) - $template = ABSPATH . WPINC . '/theme-compat/comments-popup.php'; - - return $template; -} - /** * Retrieve the name of the highest priority template file that exists. * diff --git a/src/wp-includes/theme-compat/comments-popup.php b/src/wp-includes/theme-compat/comments-popup.php deleted file mode 100644 index 3d56b45c0f..0000000000 --- a/src/wp-includes/theme-compat/comments-popup.php +++ /dev/null @@ -1,133 +0,0 @@ - - - - <?php printf(__('%1$s - Comments on %2$s'), get_option('blogname'), the_title('','',false)); ?> - - - - - - - -

- - -

- -

RSS feed for comments on this post.'); ?>

- - - - -
    - -
  1. - -

    %4$s'), get_comment_author_link( $comment ), get_comment_date( '', $comment ), get_comment_ID(), get_comment_time()); ?>

    -
  2. - - -
- -

- - - -

- -
- -

%2$s. Log out »'), get_edit_user_link(), $user_identity, wp_logout_url(get_permalink())); ?>

- -

- - -

- -

- - -

- -

- - -

- - -

- -
- -

- -

- - " /> - -

- ID ); - ?> -
- -

- - -
- - -

- - - -

WordPress'), 'https://wordpress.org/'); ?>

- - - -