Making WordPress.org


Ignore:
Timestamp:
06/20/2024 10:36:16 PM (2 years ago)
Author:
adamwood
Message:

Learn: Sync with git WordPress/learn@dc47db7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/functions.php

    r13834 r13843  
    1919add_action( 'after_setup_theme', __NAMESPACE__ . '\setup' );
    2020add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' );
    21 add_filter( 'wporg_block_site_breadcrumbs', __NAMESPACE__ . '\set_site_breadcrumbs' );
    22 add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' );
    23 add_filter( 'single_template_hierarchy', __NAMESPACE__ . '\modify_single_template' );
    24 remove_filter( 'template_include', array( 'Sensei_Templates', 'template_loader' ), 10, 1 );
     21
     22add_filter( 'post_thumbnail_html', __NAMESPACE__ . '\set_default_featured_image', 10, 5 );
     23add_filter( 'sensei_register_post_type_course', function( $args ) {
     24        $args['has_archive'] = 'courses';
     25        return $args;
     26} );
    2527add_filter( 'sensei_register_post_type_lesson', function( $args ) {
    2628        $args['has_archive'] = 'lessons';
    2729        return $args;
    2830} );
    29 add_filter( 'sensei_register_post_type_course', function( $args ) {
    30         $args['has_archive'] = 'courses';
    31         return $args;
    32 } );
     31add_filter( 'single_template_hierarchy', __NAMESPACE__ . '\modify_single_template' );
     32add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' );
     33add_filter( 'wporg_block_site_breadcrumbs', __NAMESPACE__ . '\set_site_breadcrumbs' );
     34
     35remove_filter( 'template_include', array( 'Sensei_Templates', 'template_loader' ), 10, 1 );
    3336
    3437/**
    … …  
    280283        return $breadcrumbs;
    281284}
     285
     286/**
     287 * Set the default featured image.
     288 *
     289 * @param string       $html The HTML for the featured image.
     290 * @param int          $post_id The post ID.
     291 * @param int          $post_thumbnail_id The post thumbnail ID.
     292 * @param string|array $size The image size.
     293 * @param string|array $attr The image attributes.
     294 * @return string The modified HTML for the featured image.
     295 */
     296function set_default_featured_image( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
     297        if ( ! $html ) {
     298                return '<img src="https://s.w.org/images/learn-thumbnail-fallback.jpg?v=4" alt="" />';
     299        }
     300
     301        return $html;
     302}
Note: See TracChangeset for help on using the changeset viewer.