wp/wp-admin/includes/dashboard.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
   724 			'trash'     => '',
   724 			'trash'     => '',
   725 			'delete'    => '',
   725 			'delete'    => '',
   726 			'view'      => '',
   726 			'view'      => '',
   727 		);
   727 		);
   728 
   728 
   729 		$del_nonce     = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
   729 		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'approve-comment_' . $comment->comment_ID ) );
   730 		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
   730 		$del_nonce     = esc_html( '_wpnonce=' . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) );
   731 
   731 
   732 		$approve_url   = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
   732 		$action_string = 'comment.php?action=%s&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . '&%s';
   733 		$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
   733 
   734 		$spam_url      = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   734 		$approve_url   = sprintf( $action_string, 'approvecomment', $approve_nonce );
   735 		$trash_url     = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   735 		$unapprove_url = sprintf( $action_string, 'unapprovecomment', $approve_nonce );
   736 		$delete_url    = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   736 		$spam_url      = sprintf( $action_string, 'spamcomment', $del_nonce );
       
   737 		$trash_url     = sprintf( $action_string, 'trashcomment', $del_nonce );
       
   738 		$delete_url    = sprintf( $action_string, 'deletecomment', $del_nonce );
   737 
   739 
   738 		$actions['approve'] = sprintf(
   740 		$actions['approve'] = sprintf(
   739 			'<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',
   741 			'<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',
   740 			$approve_url,
   742 			esc_url( $approve_url ),
   741 			"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",
   743 			"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",
   742 			esc_attr__( 'Approve this comment' ),
   744 			esc_attr__( 'Approve this comment' ),
   743 			__( 'Approve' )
   745 			__( 'Approve' )
   744 		);
   746 		);
   745 
   747 
   746 		$actions['unapprove'] = sprintf(
   748 		$actions['unapprove'] = sprintf(
   747 			'<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>',
   749 			'<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>',
   748 			$unapprove_url,
   750 			esc_url( $unapprove_url ),
   749 			"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",
   751 			"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",
   750 			esc_attr__( 'Unapprove this comment' ),
   752 			esc_attr__( 'Unapprove this comment' ),
   751 			__( 'Unapprove' )
   753 			__( 'Unapprove' )
   752 		);
   754 		);
   753 
   755 
   766 			__( 'Reply' )
   768 			__( 'Reply' )
   767 		);
   769 		);
   768 
   770 
   769 		$actions['spam'] = sprintf(
   771 		$actions['spam'] = sprintf(
   770 			'<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
   772 			'<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
   771 			$spam_url,
   773 			esc_url( $spam_url ),
   772 			"delete:the-comment-list:comment-{$comment->comment_ID}::spam=1",
   774 			"delete:the-comment-list:comment-{$comment->comment_ID}::spam=1",
   773 			esc_attr__( 'Mark this comment as spam' ),
   775 			esc_attr__( 'Mark this comment as spam' ),
   774 			/* translators: "Mark as spam" link. */
   776 			/* translators: "Mark as spam" link. */
   775 			_x( 'Spam', 'verb' )
   777 			_x( 'Spam', 'verb' )
   776 		);
   778 		);
   777 
   779 
   778 		if ( ! EMPTY_TRASH_DAYS ) {
   780 		if ( ! EMPTY_TRASH_DAYS ) {
   779 			$actions['delete'] = sprintf(
   781 			$actions['delete'] = sprintf(
   780 				'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
   782 				'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
   781 				$delete_url,
   783 				esc_url( $delete_url ),
   782 				"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
   784 				"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
   783 				esc_attr__( 'Delete this comment permanently' ),
   785 				esc_attr__( 'Delete this comment permanently' ),
   784 				__( 'Delete Permanently' )
   786 				__( 'Delete Permanently' )
   785 			);
   787 			);
   786 		} else {
   788 		} else {
   787 			$actions['trash'] = sprintf(
   789 			$actions['trash'] = sprintf(
   788 				'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
   790 				'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
   789 				$trash_url,
   791 				esc_url( $trash_url ),
   790 				"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
   792 				"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
   791 				esc_attr__( 'Move this comment to the Trash' ),
   793 				esc_attr__( 'Move this comment to the Trash' ),
   792 				_x( 'Trash', 'verb' )
   794 				_x( 'Trash', 'verb' )
   793 			);
   795 			);
   794 		}
   796 		}
   798 			esc_url( get_comment_link( $comment ) ),
   800 			esc_url( get_comment_link( $comment ) ),
   799 			esc_attr__( 'View this comment' ),
   801 			esc_attr__( 'View this comment' ),
   800 			__( 'View' )
   802 			__( 'View' )
   801 		);
   803 		);
   802 
   804 
   803 		/**
   805 		/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
   804 		 * Filters the action links displayed for each comment in the 'Recent Comments'
       
   805 		 * dashboard widget.
       
   806 		 *
       
   807 		 * @since 2.6.0
       
   808 		 *
       
   809 		 * @param string[]   $actions An array of comment actions. Default actions include:
       
   810 		 *                            'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
       
   811 		 *                            'Delete', and 'Trash'.
       
   812 		 * @param WP_Comment $comment The comment object.
       
   813 		 */
       
   814 		$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
   806 		$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
   815 
   807 
   816 		$i = 0;
   808 		$i = 0;
   817 
   809 
   818 		foreach ( $actions as $action => $link ) {
   810 		foreach ( $actions as $action => $link ) {
  1285 				$rss->__destruct();
  1277 				$rss->__destruct();
  1286 				unset( $rss );
  1278 				unset( $rss );
  1287 			}
  1279 			}
  1288 		}
  1280 		}
  1289 
  1281 
  1290 		update_option( 'dashboard_widget_options', $widget_options );
  1282 		update_option( 'dashboard_widget_options', $widget_options, false );
  1291 
  1283 
  1292 		$locale    = get_user_locale();
  1284 		$locale    = get_user_locale();
  1293 		$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
  1285 		$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
  1294 		delete_transient( $cache_key );
  1286 		delete_transient( $cache_key );
  1295 	}
  1287 	}
  1817 	$key = md5( $_SERVER['HTTP_USER_AGENT'] );
  1809 	$key = md5( $_SERVER['HTTP_USER_AGENT'] );
  1818 
  1810 
  1819 	$response = get_site_transient( 'browser_' . $key );
  1811 	$response = get_site_transient( 'browser_' . $key );
  1820 
  1812 
  1821 	if ( false === $response ) {
  1813 	if ( false === $response ) {
  1822 		// Include an unmodified $wp_version.
       
  1823 		require ABSPATH . WPINC . '/version.php';
       
  1824 
       
  1825 		$url     = 'http://api.wordpress.org/core/browse-happy/1.1/';
  1814 		$url     = 'http://api.wordpress.org/core/browse-happy/1.1/';
  1826 		$options = array(
  1815 		$options = array(
  1827 			'body'       => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
  1816 			'body'       => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
  1828 			'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
  1817 			'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
  1829 		);
  1818 		);
  1830 
  1819 
  1831 		if ( wp_http_supports( array( 'ssl' ) ) ) {
  1820 		if ( wp_http_supports( array( 'ssl' ) ) ) {
  1832 			$url = set_url_scheme( $url, 'https' );
  1821 			$url = set_url_scheme( $url, 'https' );
  1833 		}
  1822 		}
  1921 	</p>
  1910 	</p>
  1922 
  1911 
  1923 	<p class="button-container">
  1912 	<p class="button-container">
  1924 		<?php
  1913 		<?php
  1925 		printf(
  1914 		printf(
  1926 			'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1915 			'<a class="button button-primary" href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
  1927 			esc_url( wp_get_update_php_url() ),
  1916 			esc_url( wp_get_update_php_url() ),
  1928 			__( 'Learn more about updating PHP' ),
  1917 			__( 'Learn more about updating PHP' ),
  1929 			/* translators: Hidden accessibility text. */
  1918 			/* translators: Hidden accessibility text. */
  1930 			__( '(opens in a new tab)' )
  1919 			__( '(opens in a new tab)' )
  1931 		);
  1920 		);
  2065  *
  2054  *
  2066  * @since 3.3.0
  2055  * @since 3.3.0
  2067  * @since 5.9.0 Send users to the Site Editor if the active theme is block-based.
  2056  * @since 5.9.0 Send users to the Site Editor if the active theme is block-based.
  2068  */
  2057  */
  2069 function wp_welcome_panel() {
  2058 function wp_welcome_panel() {
  2070 	list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
  2059 	list( $display_version ) = explode( '-', wp_get_wp_version() );
  2071 	$can_customize           = current_user_can( 'customize' );
  2060 	$can_customize           = current_user_can( 'customize' );
  2072 	$is_block_theme          = wp_is_block_theme();
  2061 	$is_block_theme          = wp_is_block_theme();
  2073 	?>
  2062 	?>
  2074 	<div class="welcome-panel-content">
  2063 	<div class="welcome-panel-content">
  2075 	<div class="welcome-panel-header">
  2064 	<div class="welcome-panel-header">
  2079 		<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
  2068 		<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
  2080 		<p>
  2069 		<p>
  2081 			<a href="<?php echo esc_url( admin_url( 'about.php' ) ); ?>">
  2070 			<a href="<?php echo esc_url( admin_url( 'about.php' ) ); ?>">
  2082 			<?php
  2071 			<?php
  2083 				/* translators: %s: Current WordPress version. */
  2072 				/* translators: %s: Current WordPress version. */
  2084 				printf( __( 'Learn more about the %s version.' ), $display_version );
  2073 				printf( __( 'Learn more about the %s version.' ), esc_html( $display_version ) );
  2085 			?>
  2074 			?>
  2086 			</a>
  2075 			</a>
  2087 		</p>
  2076 		</p>
  2088 	</div>
  2077 	</div>
  2089 	<div class="welcome-panel-column-container">
  2078 	<div class="welcome-panel-column-container">