tomize;
return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
}
/**
* Makes sure that auto-draft posts get their post_date bumped or status changed
* to draft to prevent premature garbage-collection.
*
* When a changeset is updated but remains an auto-draft, ensure the post_date
* for the auto-draft posts remains the same so that it will be
* garbage-collected at the same time by `wp_delete_auto_drafts()`. Otherwise,
* if the changeset is updated to be a draft then update the posts
* to have a far-future post_date so that they will never be garbage collected
* unless the changeset post itself is deleted.
*
* When a changeset is updated to be a persistent draft or to be scheduled for
* publishing, then transition any dependent auto-drafts to a draft status so
* that they likewise will not be garbage-collected but also so that they can
* be edited in the admin before publishing since there is not yet a post/page
* editing flow in the Customizer. See #39752.
*
* @link https://core.trac.wordpress.org/ticket/39752
*
* @since 4.8.0
* @access private
* @see wp_delete_auto_drafts()
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $new_status Transition to this post status.
* @param string $old_status Previous post status.
* @param \WP_Post $post Post data.
*/
function _wp_keep_alive_customize_changeset_dependent_auto_drafts( $new_status, $old_status, $post ) {
global $wpdb;
unset( $old_status );
// Short-circuit if not a changeset or if the changeset was published.
if ( 'customize_changeset' !== $post->post_type || 'publish' === $new_status ) {
return;
}
$data = json_decode( $post->post_content, true );
if ( empty( $data['nav_menus_created_posts']['value'] ) ) {
return;
}
/*
* Actually, in lieu of keeping alive, trash any customization drafts here if the changeset itself is
* getting trashed. This is needed because when a changeset transitions to a draft, then any of the
* dependent auto-draft post/page stubs will also get transitioned to customization drafts which
* are then visible in the WP Admin. We cannot wait for the deletion of the changeset in which
* _wp_delete_customize_changeset_dependent_auto_drafts() will be called, since they need to be
* trashed to remove from visibility immediately.
*/
if ( 'trash' === $new_status ) {
foreach ( $data['nav_menus_created_posts']['value'] as $post_id ) {
if ( ! empty( $post_id ) && 'draft' === get_post_status( $post_id ) ) {
wp_trash_post( $post_id );
}
}
return;
}
$post_args = array();
if ( 'auto-draft' === $new_status ) {
/*
* Keep the post date for the post matching the changeset
* so that it will not be garbage-collected before the changeset.
*/
$post_args['post_date'] = $post->post_date; // Note wp_delete_auto_drafts() only looks at this date.
} else {
/*
* Since the changeset no longer has an auto-draft (and it is not published)
* it is now a persistent changeset, a long-lived draft, and so any
* associated auto-draft posts should likewise transition into having a draft
* status. These drafts will be treated differently than regular drafts in
* that they will be tied to the given changeset. The publish meta box is
* replaced with a notice about how the post is part of a set of customized changes
* which will be published when the changeset is published.
*/
$post_args['post_status'] = 'draft';
}
foreach ( $data['nav_menus_created_posts']['value'] as $post_id ) {
if ( empty( $post_id ) || 'auto-draft' !== get_post_status( $post_id ) ) {
continue;
}
$wpdb->update(
$wpdb->posts,
$post_args,
array( 'ID' => $post_id )
);
clean_post_cache( $post_id );
}
}
/**
* Creates the initial theme features when the 'setup_theme' action is fired.
*
* See {@see 'setup_theme'}.
*
* @since 5.5.0
* @since 6.0.1 The `block-templates` feature was added.
*/
function create_initial_theme_features() {
register_theme_feature(
'align-wide',
array(
'description' => __( 'Whether theme opts in to wide alignment CSS class.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'automatic-feed-links',
array(
'description' => __( 'Whether posts and comments RSS feed links are added to head.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'block-templates',
array(
'description' => __( 'Whether a theme uses block-based templates.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'block-template-parts',
array(
'description' => __( 'Whether a theme uses block-based template parts.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'custom-background',
array(
'description' => __( 'Custom background if defined by the theme.' ),
'type' => 'object',
'show_in_rest' => array(
'schema' => array(
'properties' => array(
'default-image' => array(
'type' => 'string',
'format' => 'uri',
),
'default-preset' => array(
'type' => 'string',
'enum' => array(
'default',
'fill',
'fit',
'repeat',
'custom',
),
),
'default-position-x' => array(
'type' => 'string',
'enum' => array(
'left',
'center',
'right',
),
),
'default-position-y' => array(
'type' => 'string',
'enum' => array(
'left',
'center',
'right',
),
),
'default-size' => array(
'type' => 'string',
'enum' => array(
'auto',
'contain',
'cover',
),
),
'default-repeat' => array(
'type' => 'string',
'enum' => array(
'repeat-x',
'repeat-y',
'repeat',
'no-repeat',
),
),
'default-attachment' => array(
'type' => 'string',
'enum' => array(
'scroll',
'fixed',
),
),
'default-color' => array(
'type' => 'string',
),
),
),
),
)
);
register_theme_feature(
'custom-header',
array(
'description' => __( 'Custom header if defined by the theme.' ),
'type' => 'object',
'show_in_rest' => array(
'schema' => array(
'properties' => array(
'default-image' => array(
'type' => 'string',
'format' => 'uri',
),
'random-default' => array(
'type' => 'boolean',
),
'width' => array(
'type' => 'integer',
),
'height' => array(
'type' => 'integer',
),
'flex-height' => array(
'type' => 'boolean',
),
'flex-width' => array(
'type' => 'boolean',
),
'default-text-color' => array(
'type' => 'string',
),
'header-text' => array(
'type' => 'boolean',
),
'uploads' => array(
'type' => 'boolean',
),
'video' => array(
'type' => 'boolean',
),
),
),
),
)
);
register_theme_feature(
'custom-logo',
array(
'type' => 'object',
'description' => __( 'Custom logo if defined by the theme.' ),
'show_in_rest' => array(
'schema' => array(
'properties' => array(
'width' => array(
'type' => 'integer',
),
'height' => array(
'type' => 'integer',
),
'flex-width' => array(
'type' => 'boolean',
),
'flex-height' => array(
'type' => 'boolean',
),
'header-text' => array(
'type' => 'array',
'items' => array(
'type' => 'string',
),
),
'unlink-homepage-logo' => array(
'type' => 'boolean',
),
),
),
),
)
);
register_theme_feature(
'customize-selective-refresh-widgets',
array(
'description' => __( 'Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'dark-editor-style',
array(
'description' => __( 'Whether theme opts in to the dark editor style UI.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'disable-custom-colors',
array(
'description' => __( 'Whether the theme disables custom colors.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'disable-custom-font-sizes',
array(
'description' => __( 'Whether the theme disables custom font sizes.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'disable-custom-gradients',
array(
'description' => __( 'Whether the theme disables custom gradients.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'disable-layout-styles',
array(
'description' => __( 'Whether the theme disables generated layout styles.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'editor-color-palette',
array(
'type' => 'array',
'description' => __( 'Custom color palette if defined by the theme.' ),
'show_in_rest' => array(
'schema' => array(
'items' => array(
'type' => 'object',
'properties' => array(
'name' => array(
'type' => 'string',
),
'slug' => array(
'type' => 'string',
),
'color' => array(
'type' => 'string',
),
),
),
),
),
)
);
register_theme_feature(
'editor-font-sizes',
array(
'type' => 'array',
'description' => __( 'Custom font sizes if defined by the theme.' ),
'show_in_rest' => array(
'schema' => array(
'items' => array(
'type' => 'object',
'properties' => array(
'name' => array(
'type' => 'string',
),
'size' => array(
'type' => 'number',
),
'slug' => array(
'type' => 'string',
),
),
),
),
),
)
);
register_theme_feature(
'editor-gradient-presets',
array(
'type' => 'array',
'description' => __( 'Custom gradient presets if defined by the theme.' ),
'show_in_rest' => array(
'schema' => array(
'items' => array(
'type' => 'object',
'properties' => array(
'name' => array(
'type' => 'string',
),
'gradient' => array(
'type' => 'string',
),
'slug' => array(
'type' => 'string',
),
),
),
),
),
)
);
register_theme_feature(
'editor-spacing-sizes',
array(
'type' => 'array',
'description' => __( 'Custom spacing sizes if defined by the theme.' ),
'show_in_rest' => array(
'schema' => array(
'items' => array(
'type' => 'object',
'properties' => array(
'name' => array(
'type' => 'string',
),
'size' => array(
'type' => 'string',
),
'slug' => array(
'type' => 'string',
),
),
),
),
),
)
);
register_theme_feature(
'editor-styles',
array(
'description' => __( 'Whether theme opts in to the editor styles CSS wrapper.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'html5',
array(
'type' => 'array',
'description' => __( 'Allows use of HTML5 markup for search forms, comment forms, comment lists, gallery, and caption.' ),
'show_in_rest' => array(
'schema' => array(
'items' => array(
'type' => 'string',
'enum' => array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'script',
'style',
),
),
),
),
)
);
register_theme_feature(
'post-formats',
array(
'type' => 'array',
'description' => __( 'Post formats supported.' ),
'show_in_rest' => array(
'name' => 'formats',
'schema' => array(
'items' => array(
'type' => 'string',
'enum' => get_post_format_slugs(),
),
'default' => array( 'standard' ),
),
'prepare_callback' => static function ( $formats ) {
$formats = is_array( $formats ) ? array_values( $formats[0] ) : array();
$formats = array_merge( array( 'standard' ), $formats );
return $formats;
},
),
)
);
register_theme_feature(
'post-thumbnails',
array(
'type' => 'array',
'description' => __( 'The post types that support thumbnails or true if all post types are supported.' ),
'show_in_rest' => array(
'type' => array( 'boolean', 'array' ),
'schema' => array(
'items' => array(
'type' => 'string',
),
),
),
)
);
register_theme_feature(
'responsive-embeds',
array(
'description' => __( 'Whether the theme supports responsive embedded content.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'title-tag',
array(
'description' => __( 'Whether the theme can manage the document title tag.' ),
'show_in_rest' => true,
)
);
register_theme_feature(
'wp-block-styles',
array(
'description' => __( 'Whether theme opts in to default WordPress block styles for viewing.' ),
'show_in_rest' => true,
)
);
}
/**
* Returns whether the active theme is a block-based theme or not.
*
* @since 5.9.0
*
* @return bool Whether the active theme is a block-based theme or not.
*/
function wp_is_block_theme() {
return wp_get_theme()->is_block_theme();
}
/**
* Given an element name, returns a class name.
*
* Alias of WP_Theme_JSON::get_element_class_name.
*
* @since 6.1.0
*
* @param string $element The name of the element.
*
* @return string The name of the class.
*/
function wp_theme_get_element_class_name( $element ) {
return WP_Theme_JSON::get_element_class_name( $element );
}
/**
* Adds default theme supports for block themes when the 'after_setup_theme' action fires.
*
* See {@see 'after_setup_theme'}.
*
* @since 5.9.0
* @access private
*/
function _add_default_theme_supports() {
if ( ! wp_is_block_theme() ) {
return;
}
add_theme_support( 'post-thumbnails' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'editor-styles' );
/*
* Makes block themes support HTML5 by default for the comment block and search form
* (which use default template functions) and `[caption]` and `[gallery]` shortcodes.
* Other blocks contain their own HTML5 markup.
*/
add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'search-form', 'gallery', 'caption', 'style', 'script' ) );
add_theme_support( 'automatic-feed-links' );
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
/*
* Remove the Customizer's Menus panel when block theme is active.
*/
add_filter(
'customize_panel_active',
static function ( $active, WP_Customize_Panel $panel ) {
if (
'nav_menus' === $panel->id &&
! current_theme_supports( 'menus' ) &&
! current_theme_supports( 'widgets' )
) {
$active = false;
}
return $active;
},
10,
2
);
}
Fatal error: Uncaught Error: Call to undefined function add_theme_support() in /home/ocb/public_html/wp-includes/block-patterns.php:9
Stack trace:
#0 /home/ocb/public_html/wp-settings.php(370): require()
#1 /home/ocb/public_html/wp-config.php(77): require_once('/home/ocb/publi...')
#2 /home/ocb/public_html/wp-load.php(50): require_once('/home/ocb/publi...')
#3 /home/ocb/public_html/wp-blog-header.php(13): require_once('/home/ocb/publi...')
#4 /home/ocb/public_html/index.php(17): require('/home/ocb/publi...')
#5 {main}
thrown in /home/ocb/public_html/wp-includes/block-patterns.php on line 9
Fatal error: Uncaught Error: Call to a member function set() on null in /home/ocb/public_html/wp-includes/l10n.php:856
Stack trace:
#0 /home/ocb/public_html/wp-includes/l10n.php(959): load_textdomain('default', '/home/ocb/publi...', 'lv')
#1 /home/ocb/public_html/wp-includes/class-wp-fatal-error-handler.php(49): load_default_textdomain()
#2 [internal function]: WP_Fatal_Error_Handler->handle()
#3 {main}
thrown in /home/ocb/public_html/wp-includes/l10n.php on line 856