Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from wp-cms/moving-away-from-wordpress
Browse files Browse the repository at this point in the history
Remove some blocks related code
  • Loading branch information
WP CMS authored Jan 15, 2023
2 parents ce6b6d0 + 009a0cb commit 05a2f92
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 146 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<ul></ul>
</div>
<div class="wp-full-overlay-sidebar-content" tabindex="-1">
<div id="customize-info" class="accordion-section customize-info" data-block-theme="<?php echo (int) wp_is_block_theme(); ?>">
<div id="customize-info" class="accordion-section customize-info">
<div class="accordion-section-title">
<span class="preview-notice">
<?php
Expand Down
1 change: 0 additions & 1 deletion src/wp-admin/includes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,6 @@ function wp_dashboard_empty() {}
function wp_welcome_panel() {
list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
$can_customize = current_user_can( 'customize' );
$is_block_theme = wp_is_block_theme();
?>
<div class="welcome-panel-content">
<div class="welcome-panel-header">
Expand Down
55 changes: 4 additions & 51 deletions src/wp-admin/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,34 +202,12 @@
/* translators: %s: Number of available theme updates. */
$submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_cap, 'themes.php' );

if ( wp_is_block_theme() ) {
$submenu['themes.php'][6] = array(
sprintf(
/* translators: %s: "beta" label */
__( 'Editor %s' ),
'<span class="awaiting-mod">' . __( 'beta' ) . '</span>'
),
'edit_theme_options',
'site-editor.php',
);
}

if ( ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ) ) {
$submenu['themes.php'][6] = array(
__( 'Template Parts' ),
'edit_theme_options',
'site-editor.php?postType=wp_template_part',
);
}

$customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );

// Hide Customize link on block themes unless a plugin or theme
// is using 'customize_register' to add a setting.
if ( ! wp_is_block_theme() || has_action( 'customize_register' ) ) {
$position = ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) ? 7 : 6;

$submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
if ( has_action( 'customize_register' ) ) {
$submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
}

if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
Expand Down Expand Up @@ -266,34 +244,14 @@
*/
function _add_themes_utility_last() {
add_submenu_page(
wp_is_block_theme() ? 'tools.php' : 'themes.php',
'themes.php',
__( 'Theme File Editor' ),
__( 'Theme File Editor' ),
'edit_themes',
'theme-editor.php'
);
}

/**
* Adds the 'Plugin File Editor' menu item after the 'Themes File Editor' in Tools
* for block themes.
*
* @access private
* @since 5.9.0
*/
function _add_plugin_file_editor_to_tools() {
if ( ! wp_is_block_theme() ) {
return;
}
add_submenu_page(
'tools.php',
__( 'Plugin File Editor' ),
__( 'Plugin File Editor' ),
'edit_plugins',
'plugin-editor.php'
);
}

$count = '';
if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) {
if ( ! isset( $update_data ) ) {
Expand All @@ -314,12 +272,7 @@ function _add_plugin_file_editor_to_tools() {
if ( ! is_multisite() ) {
/* translators: Add new plugin. */
$submenu['plugins.php'][10] = array( _x( 'Add New', 'plugin' ), 'install_plugins', 'plugin-install.php' );
if ( wp_is_block_theme() ) {
// Place the menu item below the Theme File Editor menu item.
add_action( 'admin_menu', '_add_plugin_file_editor_to_tools', 101 );
} else {
$submenu['plugins.php'][15] = array( __( 'Plugin File Editor' ), 'edit_plugins', 'plugin-editor.php' );
}
$submenu['plugins.php'][15] = array( __( 'Plugin File Editor' ), 'edit_plugins', 'plugin-editor.php' );
}

unset( $update_data );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/theme-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
</div>
<?php endif; ?>

<?php if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) : ?>
<?php if ( preg_match( '/\.css$/', $file ) && current_user_can( 'customize' ) ) : ?>
<div id="message" class="notice-info notice">
<p><strong><?php _e( 'Did you know?' ); ?></strong></p>
<p>
Expand Down
32 changes: 0 additions & 32 deletions src/wp-includes/admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,33 +408,6 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
}
}

/**
* Adds the "Edit site" link to the Toolbar.
*
* @since 5.9.0
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
// Don't show if a block theme is not activated.
if ( ! wp_is_block_theme() ) {
return;
}

// Don't show for users who can't edit theme options or when in the admin.
if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) {
return;
}

$wp_admin_bar->add_node(
array(
'id' => 'site-editor',
'title' => __( 'Edit site' ),
'href' => admin_url( 'site-editor.php' ),
)
);
}

/**
* Adds the "Customize" link to the Toolbar.
*
Expand All @@ -446,11 +419,6 @@ function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
function wp_admin_bar_customize_menu( $wp_admin_bar ) {
global $wp_customize;

// Don't show if a block theme is activated and no plugins use the customizer.
if ( wp_is_block_theme() && ! has_action( 'customize_register' ) ) {
return;
}

// Don't show for users who can't access the customizer or when in the admin.
if ( ! current_user_can( 'customize' ) || is_admin() ) {
return;
Expand Down
1 change: 0 additions & 1 deletion src/wp-includes/class-wp-admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ public function add_menus() {
add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
add_action( 'admin_bar_menu', 'wp_admin_bar_edit_site_menu', 40 );
add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 );
add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 );

Expand Down
1 change: 0 additions & 1 deletion src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@
*/
// Theme.
add_action( 'setup_theme', 'create_initial_theme_features', 0 );
add_action( 'setup_theme', '_add_default_theme_supports', 1 );
add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
add_action( 'wp_head', '_custom_logo_header_styles' );
add_action( 'plugins_loaded', '_wp_customize_include' );
Expand Down
6 changes: 1 addition & 5 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5260,11 +5260,7 @@ function wp_widgets_add_menu() {
}

$menu_name = __( 'Widgets' );
if ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) {
$submenu['themes.php'][] = array( $menu_name, 'edit_theme_options', 'widgets.php' );
} else {
$submenu['themes.php'][7] = array( $menu_name, 'edit_theme_options', 'widgets.php' );
}
$submenu['themes.php'][7] = array( $menu_name, 'edit_theme_options', 'widgets.php' );

ksort( $submenu['themes.php'], SORT_NUMERIC );
}
Expand Down
53 changes: 0 additions & 53 deletions src/wp-includes/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -4202,56 +4202,3 @@ function create_initial_theme_features() {
)
);
}

/**
* Returns whether the active theme is a block-based theme or not.
*
* @since 5.9.0
*
* @return boolean 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 'setup_theme' action fires.
*
* See {@see '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' );
}

0 comments on commit 05a2f92

Please sign in to comment.