Use pluggable functions only around functions which cannot be unhooked (#1480)

This commit is contained in:
Ismail El Korchi 2022-01-01 22:15:14 +01:00 committed by GitHub
parent d6ccb97e0b
commit 8852c27641
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 99 additions and 99 deletions

View file

@ -12,96 +12,94 @@ if ( ! defined( '_S_VERSION' ) ) {
define( '_S_VERSION', '1.0.0' ); define( '_S_VERSION', '1.0.0' );
} }
if ( ! function_exists( '_s_setup' ) ) : /**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function _s_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on _s, use a find and replace
* to change '_s' to the name of your theme in all the template files.
*/
load_theme_textdomain( '_s', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'menu-1' => esc_html__( 'Primary', '_s' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background',
apply_filters(
'_s_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/** /**
* Sets up theme defaults and registers support for various WordPress features. * Add support for core custom logo.
* *
* Note that this function is hooked into the after_setup_theme hook, which * @link https://codex.wordpress.org/Theme_Logo
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/ */
function _s_setup() { add_theme_support(
/* 'custom-logo',
* Make theme available for translation. array(
* Translations can be filed in the /languages/ directory. 'height' => 250,
* If you're building a theme based on _s, use a find and replace 'width' => 250,
* to change '_s' to the name of your theme in all the template files. 'flex-width' => true,
*/ 'flex-height' => true,
load_theme_textdomain( '_s', get_template_directory() . '/languages' ); )
);
// Add default posts and comments RSS feed links to head. }
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'menu-1' => esc_html__( 'Primary', '_s' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background',
apply_filters(
'_s_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support(
'custom-logo',
array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', '_s_setup' ); add_action( 'after_setup_theme', '_s_setup' );
/** /**

View file

@ -50,16 +50,18 @@ function _s_jetpack_setup() {
} }
add_action( 'after_setup_theme', '_s_jetpack_setup' ); add_action( 'after_setup_theme', '_s_jetpack_setup' );
/** if ( ! function_exists( '_s_infinite_scroll_render' ) ) :
* Custom render function for Infinite Scroll. /**
*/ * Custom render function for Infinite Scroll.
function _s_infinite_scroll_render() { */
while ( have_posts() ) { function _s_infinite_scroll_render() {
the_post(); while ( have_posts() ) {
if ( is_search() ) : the_post();
get_template_part( 'template-parts/content', 'search' ); if ( is_search() ) :
else : get_template_part( 'template-parts/content', 'search' );
get_template_part( 'template-parts/content', get_post_type() ); else :
endif; get_template_part( 'template-parts/content', get_post_type() );
endif;
}
} }
} endif;