add_theme_support example

<?php /** * Register the block patterns and block patterns categories * * @package WordPress * @since 5.5.0 */

add_theme_support( 'core-block-patterns' );

/** * Registers the core block patterns and categories. * * @since 5.5.0 * @since 6.3.0 Added source to core block patterns. * @access private */
function _register_core_block_patterns_and_categories() {
    $should_register_core_patterns = get_theme_support( 'core-block-patterns' );

    

    function twenty_twenty_one_setup() {

        // Add default posts and comments RSS feed links to head.         add_theme_support( 'automatic-feed-links' );

        /* * Let WordPress manage the document title. * This theme does not use a hard-coded <title> tag in the document head, * WordPress will provide it for us. */
        add_theme_support( 'title-tag' );

        /** * Add post-formats support. */
        
__( 'No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.' ),
                '<code>id</code>',
                $sidebar['name'],
                $sidebar['id']
            ),
            '4.2.0'
        );
    }

    $wp_registered_sidebars[ $sidebar['id'] ] = $sidebar;

    add_theme_support( 'widgets' );

    /** * Fires once a sidebar has been registered. * * @since 3.0.0 * * @param array $sidebar Parsed arguments for the registered sidebar. */
    do_action( 'register_sidebar', $sidebar );

    return $sidebar['id'];
}
/** * Sets up theme defaults and registers support for various WordPress features. * * @since Twenty Twenty-Two 1.0 * * @return void */
    function twentytwentytwo_support() {

        // Add support for block styles.         add_theme_support( 'wp-block-styles' );

        // Enqueue editor styles.         add_editor_style( 'style.css' );

    }

endif;

add_action( 'after_setup_theme', 'twentytwentytwo_support' );

if ( ! function_exists( 'twentytwentytwo_styles' ) ) :

    

function automatic_feed_links( $add = true ) {
    _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" );

    if ( $add )
        add_theme_support( 'automatic-feed-links' );
    else
        remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+. }

/** * Retrieve user data based on field. * * @since 1.5.0 * @deprecated 3.0.0 Use get_the_author_meta() * @see get_the_author_meta() * * @param string $field User meta field. * @param false|int $user Optional. User ID to retrieve the field for. Default false (current user). * @return string The author's field from the current author's DB object. */

function register_nav_menus( $locations = array() ) {
    global $_wp_registered_nav_menus;

    add_theme_support( 'menus' );

    foreach ( $locations as $key => $value ) {
        if ( is_int( $key ) ) {
            _doing_it_wrong( __FUNCTION__, __( 'Nav menu locations must be strings.' ), '5.3.0' );
            break;
        }
    }

    $_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus$locations );
}

<?php }

/** * Enables the block templates (editor mode) for themes with theme.json by default. * * @access private * @since 5.8.0 */
function wp_enable_block_templates() {
    if ( wp_is_block_theme() || wp_theme_has_theme_json() ) {
        add_theme_support( 'block-templates' );
    }
}

function add_editor_style( $stylesheet = 'editor-style.css' ) {
    global $editor_styles;

    add_theme_support( 'editor-style' );

    $editor_styles = (array) $editor_styles;
    $stylesheet    = (array) $stylesheet;

    if ( is_rtl() ) {
        $rtl_stylesheet = str_replace( '.css', '-rtl.css', $stylesheet[0] );
        $stylesheet[]   = $rtl_stylesheet;
    }

    $editor_styles = array_merge( $editor_styles$stylesheet );
}

Home | Imprint | This part of the site doesn't use cookies.