Making WordPress.org

Changeset 10351


Ignore:
Timestamp:
10/06/2020 05:00:31 AM (5 years ago)
Author:
dd32
Message:

Theme Directory: Since WordPress 4.5 WordPress has supported embed.php as a template without the need for filters, remove our custom filtering and use a simplified embed.php for the theme post type only.

Fixes embeds for pages and stops a bunch of annoying notices.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/embed-repopackage.php

    r10350 r10351  
    2727<body <?php body_class(); ?>>
    2828<?php
    29 if ( have_posts() ) :
    30     while ( have_posts() ) : the_post();
    31         // setup the theme variable
    32         // note, $theme contains things like active installs and other data to be added eventually
    33         $theme = wporg_themes_theme_information( $post->post_name );
     29the_post();
     30// setup the theme variable
     31// note, $theme contains things like active installs and other data to be added eventually
     32$theme = wporg_themes_theme_information( $post->post_name );
     33?>
     34<div <?php post_class( 'wp-embed' ); ?>>
     35    <div class="wp-embed-featured-image rectangular">
     36        <a href="<?php the_permalink(); ?>" target="_top">
     37            <img src='<?php echo $theme->screenshot_url; ?>'>
     38        </a>
     39    </div>
    3440
     41    <p class="wp-embed-heading">
     42        <a href="<?php the_permalink(); ?>" target="_top">
     43            <?php echo esc_html( $theme->name ); ?>
     44        </a>
     45    </p>
     46
     47    <div class="wp-embed-excerpt"><?php echo wp_trim_words( $theme->description, 55 ); ?></div>
     48
     49    <?php
     50    /**
     51     * Print additional content after the embed excerpt.
     52     *
     53     * @since 4.4.0
     54     */
     55    do_action( 'embed_content' );
    3556    ?>
    36         <div <?php post_class( 'wp-embed' ); ?>>
    37                 <div class="wp-embed-featured-image rectangular">
    38                     <a href="<?php the_permalink(); ?>" target="_top">
    39                         <img src='<?php echo $theme->screenshot_url; ?>'>
    40                     </a>
    41                 </div>
    4257
    43             <p class="wp-embed-heading">
    44                 <a href="<?php the_permalink(); ?>" target="_top">
    45                     <?php echo esc_html( $theme->name ); ?>
    46                 </a>
    47             </p>
     58    <div class="wp-embed-footer">
     59        <div class="wp-embed-site-title">
     60            <?php
     61            $site_title = sprintf(
     62                '<a href="%s" target="_top"><img src="%s" srcset="%s 2x" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>',
     63                esc_url( home_url() ),
     64                esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
     65                esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
     66                esc_html( get_bloginfo( 'name' ) )
     67            );
    4868
    49             <div class="wp-embed-excerpt"><?php echo wp_trim_words( $theme->description, 55 ); ?></div>
     69            /**
     70             * Filter the site title HTML in the embed footer.
     71             *
     72             * @since 4.4.0
     73             *
     74             * @param string $site_title The site title HTML.
     75             */
     76            echo apply_filters( 'embed_site_title_html', $site_title );
     77            ?>
     78        </div>
    5079
     80        <div class="wp-embed-meta">
    5181            <?php
    5282            /**
    53              * Print additional content after the embed excerpt.
     83             * Print additional meta content in the embed template.
    5484             *
    5585             * @since 4.4.0
    5686             */
    57             do_action( 'embed_content' );
     87            do_action( 'embed_content_meta');
    5888            ?>
    59 
    60             <div class="wp-embed-footer">
    61                 <div class="wp-embed-site-title">
    62                     <?php
    63                     $site_title = sprintf(
    64                         '<a href="%s" target="_top"><img src="%s" srcset="%s 2x" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>',
    65                         esc_url( home_url() ),
    66                         esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
    67                         esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
    68                         esc_html( get_bloginfo( 'name' ) )
    69                     );
    70 
    71                     /**
    72                      * Filter the site title HTML in the embed footer.
    73                      *
    74                      * @since 4.4.0
    75                      *
    76                      * @param string $site_title The site title HTML.
    77                      */
    78                     echo apply_filters( 'embed_site_title_html', $site_title );
    79                     ?>
    80                 </div>
    81 
    82                 <div class="wp-embed-meta">
    83                     <?php
    84                     /**
    85                      * Print additional meta content in the embed template.
    86                      *
    87                      * @since 4.4.0
    88                      */
    89                     do_action( 'embed_content_meta');
    90                     ?>
    91                 </div>
    92             </div>
    93         </div>
    94         <?php
    95     endwhile;
    96 else :
    97     ?>
    98     <div class="wp-embed">
    99         <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    100 
    101         <div class="wp-embed-excerpt">
    102             <p>
    103                 <?php
    104                 printf(
    105                     /* translators: %s: a link to the embedded site */
    106                     __( 'It looks like nothing was found at this location. Maybe try visiting %s directly?' ),
    107                     '<strong><a href="' . esc_url( home_url() ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a></strong>'
    108                 );
    109                 ?>
    110             </p>
    111         </div>
    112 
    113         <div class="wp-embed-footer">
    114             <div class="wp-embed-site-title">
    115                 <?php
    116                 $site_title = sprintf(
    117                     '<a href="%s" target="_top"><img src="%s" srcset="%s 2x" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>',
    118                     esc_url( home_url() ),
    119                     esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
    120                     esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
    121                     esc_html( get_bloginfo( 'name' ) )
    122                 );
    123 
    124                 /** This filter is documented in wp-includes/embed-template.php */
    125                 echo apply_filters( 'embed_site_title_html', $site_title );
    126                 ?>
    127             </div>
    12889        </div>
    12990    </div>
    130     <?php
    131 endif;
     91</div>
     92<?php
    13293
    13394/**
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php

    r10330 r10351  
    432432}
    433433
    434 /**
    435  * Override the embed template with our own for themes
    436  */
    437 function wporg_themes_embed_template( $template ) {
    438     if ( 'repopackage' === get_post_type() ) {
    439         $theme_embed_template = locate_template( 'embed.php' );
    440         if ( $theme_embed_template ) {
    441             $template = $theme_embed_template;
    442         }
    443     }
    444 
    445     return $template;
    446 }
    447 add_filter( 'embed_template', 'wporg_themes_embed_template' );
    448 
    449434include_once WP_CONTENT_DIR . '/plugins/jetpack/modules/seo-tools/jetpack-seo.php';
    450435include_once WP_CONTENT_DIR . '/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php';
Note: See TracChangeset for help on using the changeset viewer.