WordPress.org

Make WordPress Core

Ticket #20194: 20194.2.diff

File 20194.2.diff, 5.1 KB (added by Otto42, 2 years ago)

Adds automatic use of excerpt for the description on singulars.

  • wp-admin/options-general.php

     
    112112<span class="description"><?php _e('Enter the address here if you want your site homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></span></td> 
    113113</tr> 
    114114<tr valign="top"> 
     115<th scope="row"><label for="home"><?php _e('Site Description') ?></label></th> 
     116<td><textarea name="site_description" rows="5" cols="50" id="site_description" class="regular-text code"><?php echo esc_textarea( get_option( 'site_description' ) ); ?></textarea> 
     117<span class="description"><?php _e('Enter a longer description of what the site is about. This will be seen by search engines looking at your site.'); ?></span></td> 
     118</tr> 
     119<tr valign="top"> 
    115120<th scope="row"><label for="admin_email"><?php _e('E-mail Address') ?> </label></th> 
    116121<td><input name="admin_email" type="text" id="admin_email" value="<?php form_option('admin_email'); ?>" class="regular-text ltr" /> 
    117122<span class="description"><?php _e('This address is used for admin purposes, like new user notification.') ?></span></td> 
  • wp-admin/options.php

     
    5959        wp_die(__('Cheatin&#8217; uh?')); 
    6060 
    6161$whitelist_options = array( 
    62         'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ), 
     62        'general' => array( 'blogname', 'blogdescription', 'site_description', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ), 
    6363        'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ), 
    6464        'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ), 
    6565        'privacy' => array( 'blog_public' ), 
  • wp-includes/default-filters.php

     
    199199add_action( 'wp_head',             'wp_enqueue_scripts',              1     ); 
    200200add_action( 'wp_head',             'feed_links',                      2     ); 
    201201add_action( 'wp_head',             'feed_links_extra',                3     ); 
     202add_action( 'wp_head',             'the_description'                        ); 
    202203add_action( 'wp_head',             'rsd_link'                               ); 
    203204add_action( 'wp_head',             'wlwmanifest_link'                       ); 
    204205add_action( 'wp_head',             'adjacent_posts_rel_link_wp_head', 10, 0 ); 
  • wp-includes/general-template.php

     
    22122212} 
    22132213 
    22142214/** 
     2215 * Display the site description. 
     2216 * 
     2217 * Outputs the site description from the Settings->General field. 
     2218 * 
     2219 * @since 3.4.0 
     2220 * @uses apply_filters() Calls 'the_description' hook. 
     2221 * 
     2222 * @param string $type The type of description to output - (html|meta) 
     2223 */ 
     2224function the_description( $type = 'meta' ) { 
     2225        echo apply_filters('the_description', get_the_description($type), $type) . "\n"; 
     2226} 
     2227 
     2228/** 
     2229 * Creates the description output 
     2230 * 
     2231 * Returns the correct site description type for the requested output format. Allows 
     2232 * for a plugin to filter descriptions on an individual basis using the 
     2233 * 'get_the_description_{$type}' filter. 
     2234 * 
     2235 * @since 3.4.0 
     2236 * @uses apply_filters() Calls 'get_the_description_$type' hook. 
     2237 * 
     2238 * @param string $type The type of description to return - (html|meta) defaults to meta 
     2239 * @return string The HTML content for the description. 
     2240 */ 
     2241function get_the_description( $type = 'meta' ) { 
     2242        global $post; 
     2243         
     2244        if ( is_singular() ) { 
     2245                setup_postdata($post); 
     2246                $description = get_the_excerpt(); 
     2247        } else { 
     2248                $description = get_option('site_description'); 
     2249        } 
     2250 
     2251        switch ( $type ) { 
     2252                case 'html': 
     2253                        $des = $description; 
     2254                        break; 
     2255                case 'meta': 
     2256                default: 
     2257                        $des = '<meta name="description" content="' . esc_attr( $description ) . '" />'; 
     2258                        break; 
     2259        } 
     2260        return apply_filters( 'get_the_description_{$type}', $des, $type ); 
     2261} 
     2262 
     2263 
     2264/** 
    22152265 * Outputs the html checked attribute. 
    22162266 * 
    22172267 * Compares the first two arguments and if identical marks as checked