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

Built from https://develop.svn.wordpress.org/trunk@35848


git-svn-id: http://core.svn.wordpress.org/trunk@35812 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-12-10 03:06:30 +00:00
parent 8826804952
commit a027edc277
12 changed files with 84 additions and 287 deletions

View File

@ -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' ),
);
/**

View File

@ -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',
);
/**

View File

@ -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;
}

View File

@ -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.

View File

@ -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 = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\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 '<a href="';
if ( $wpcommentsjavascript ) {
if ( empty( $wpcommentspopupfile ) )
$home = home_url();
else
$home = get_option('siteurl');
echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
echo '" onclick="wpopen(this.href); return false"';
if ( 0 == $number ) {
$respond_link = get_permalink() . '#respond';
/**
* Filter the respond link when a post has no comments.
*
* @since 4.4.0
*
* @param string $respond_link The default response link.
* @param integer $id The post ID.
*/
echo apply_filters( 'respond_link', $respond_link, $id );
} else {
// if comments_popup_script() is not in the template, display simple comment link
if ( 0 == $number ) {
$respond_link = get_permalink() . '#respond';
/**
* Filter the respond link when a post has no comments.
*
* @since 4.4.0
*
* @param string $respond_link The default response link.
* @param integer $id The post ID.
*/
echo apply_filters( 'respond_link', $respond_link, $id );
} else {
comments_link();
}
echo '"';
comments_link();
}
echo '"';
if ( !empty( $css_class ) ) {
echo ' class="'.$css_class.'" ';
@ -1510,11 +1460,11 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c
$attributes = '';
/**
* Filter the comments popup link attributes for display.
* Filter the comments link attributes for display.
*
* @since 2.5.0
*
* @param string $attributes The comments popup link attributes. Default empty.
* @param string $attributes The comments link attributes. Default empty.
*/
echo apply_filters( 'comments_popup_link_attributes', $attributes );

View File

@ -3635,3 +3635,56 @@ function force_ssl_login( $force = null ) {
_deprecated_function( __FUNCTION__, '4.4', 'force_ssl_admin()' );
return force_ssl_admin( $force );
}
/**
* Retrieve path of comment popup template in current or parent template.
*
* @since 1.5.0
* @deprecated 4.5.0
*
* @return string Full path to comments popup template file.
*/
function get_comments_popup_template() {
_deprecated_function( __FUNCTION__, '4.5' );
return '';
}
/**
* Whether the current URL is within the comments popup window.
*
* @since 1.5.0
* @deprecated 4.5.0
*
* @return bool
*/
function is_comments_popup() {
_deprecated_function( __FUNCTION__, '4.5' );
return false;
}
/**
* Display the JS popup script to show a comment.
*
* @since 0.71
* @deprecated 4.5.0
*/
function comments_popup_script() {
_deprecated_function( __FUNCTION__, '4.5' );
}
/**
* Adds element attributes to open links in new windows.
*
* @since 0.71
* @deprecated 4.5.0
*
* @param string $text Content to replace links to open in a new window.
* @return string Content that has filtered links.
*/
function popuplinks( $text ) {
_deprecated_function( __FUNCTION__, '4.5' );
$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
return $text;
}

View File

@ -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('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
return $text;
}
/**
* Strips out all characters that are not allowable in an email.
*

View File

@ -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;
}
/**

View File

@ -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();

View File

@ -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.
*

View File

@ -1,133 +0,0 @@
<?php
/**
* @package WordPress
* @subpackage Theme_Compat
* @deprecated 3.0
*
* This file is here for Backwards compatibility with old themes and will be removed in a future version
*
*/
_deprecated_file(
/* translators: %s: template name */
sprintf( __( 'Theme without %s' ), basename( __FILE__ ) ),
'3.0',
null,
/* translators: %s: template name */
sprintf( __( 'Please include a %s template in your theme.' ), basename( __FILE__ ) )
);
?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php printf(__('%1$s - Comments on %2$s'), get_option('blogname'), the_title('','',false)); ?></title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<style type="text/css" media="screen">
@import url( <?php bloginfo('stylesheet_url'); ?> );
body { margin: 3px; }
</style>
</head>
<body id="commentspopup">
<h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1>
<?php
/* Don't remove these lines. */
add_filter('comment_text', 'popuplinks');
if ( have_posts() ) :
while( have_posts()) : the_post();
?>
<h2 id="comments"><?php _e('Comments'); ?></h2>
<p><a href="<?php echo esc_url( get_post_comments_feed_link($post->ID) ); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.'); ?></a></p>
<?php
// this line is WordPress' motor, do not delete it.
$commenter = wp_get_current_commenter();
$comments = get_approved_comments($id);
$post = get_post($id);
if ( post_password_required($post) ) { // and it doesn't match the cookie
echo(get_the_password_form());
} else { ?>
<?php if ($comments) { ?>
<ol id="commentlist">
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
<p><cite><?php comment_type(); ?> <?php printf(__('by %1$s &#8212; %2$s @ <a href="#comment-%3$s">%4$s</a>'), get_comment_author_link( $comment ), get_comment_date( '', $comment ), get_comment_ID(), get_comment_time()); ?></cite></p>
</li>
<?php } // end for each comment ?>
</ol>
<?php } else { // this is displayed if there are no comments so far ?>
<p><?php _e('No comments yet.'); ?></p>
<?php } ?>
<?php if ( comments_open() ) { ?>
<h2><?php _e('Leave a comment'); ?></h2>
<form action="<?php echo site_url(); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out &raquo;</a>'), get_edit_user_link(), $user_identity, wp_logout_url(get_permalink())); ?></p>
<?php else : ?>
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo esc_attr( $commenter['comment_author'] ); ?>" size="28" tabindex="1" />
<label for="author"><?php _e('Name'); ?></label>
</p>
<p>
<input type="text" name="email" id="email" value="<?php echo esc_attr( $commenter['comment_author_email'] ); ?>" size="28" tabindex="2" />
<label for="email"><?php _e('Email'); ?></label>
</p>
<p>
<input type="text" name="url" id="url" value="<?php echo esc_attr( $commenter['comment_author_url'] ); ?>" size="28" tabindex="3" />
<label for="url"><?php _e('<abbr title="Universal Resource Locator">URL</abbr>'); ?></label>
</p>
<?php endif; ?>
<p>
<label for="comment"><?php _e('Your Comment'); ?></label>
<br />
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
</p>
<p>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<input type="hidden" name="redirect_to" value="<?php echo esc_attr($_SERVER["REQUEST_URI"]); ?>" />
<input name="submit" type="submit" tabindex="5" value="<?php esc_attr_e('Say It!' ); ?>" />
</p>
<?php
/** This filter is documented in wp-includes/comment-template.php */
do_action( 'comment_form', $post->ID );
?>
</form>
<?php } else { // comments are closed ?>
<p><?php _e('Sorry, the comment form is closed at this time.'); ?></p>
<?php }
} // end password check
?>
<div><strong><a href="javascript:window.close()"><?php _e('Close this window.'); ?></a></strong></div>
<?php // if you delete this the sky will fall on your head
endwhile; // have_posts()
else: // have_posts()
?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<!-- // this is just the end of the motor - don't touch that line either :) -->
<?php //} ?>
<p class="credit"><?php timer_stop(1); ?> <cite><?php printf(__('Powered by <a href="%s" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>WordPress</strong></a>'), 'https://wordpress.org/'); ?></cite></p>
<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
<script type="text/javascript">
<!--
document.onkeypress = function esc(e) {
if(typeof(e) == "undefined") { e=event; }
if (e.keyCode == 27) { self.close(); }
}
// -->
</script>
</body>
</html>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-35847';
$wp_version = '4.5-alpha-35848';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.