Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Clean up scaffold #215

Draft
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions themes/10up-theme/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,3 @@
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}

if ( ! function_exists( 'wp_body_open' ) ) {

/**
* Shim for the new wp_body_open() function that was added in 5.2
*/
function wp_body_open() {
do_action( 'wp_body_open' );
}
}
42 changes: 0 additions & 42 deletions themes/10up-theme/includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,8 @@ function setup() {
};

add_action( 'enqueue_block_editor_assets', $n( 'blocks_editor_styles' ) );

add_action( 'init', $n( 'register_theme_blocks' ) );

add_action( 'init', $n( 'register_block_pattern_categories' ) );

/*
If you are using the block library, remove the blocks you don't need.

add_filter( 'tenup_available_blocks', function ( $blocks ) {
if ( ! empty( $blocks['integrated-hero'] ) ) {
unset( $blocks['integrated-hero'] );
}

return $blocks;
} );
*/
}

/**
Expand All @@ -44,15 +30,6 @@ function setup() {
* @return void
*/
function register_theme_blocks() {
global $wp_version;

$is_pre_wp_6 = version_compare( $wp_version, '6.0', '<' );

if ( $is_pre_wp_6 ) {
// Filter the plugins URL to allow us to have blocks in themes with linked assets. i.e editorScripts
add_filter( 'plugins_url', __NAMESPACE__ . '\filter_plugins_url', 10, 2 );
}

// Register all the blocks in the theme
if ( file_exists( TENUP_THEME_BLOCK_DIST_DIR ) ) {
$block_json_files = glob( TENUP_THEME_BLOCK_DIST_DIR . '*/block.json' );
Expand Down Expand Up @@ -83,27 +60,8 @@ function register_theme_blocks() {
register_block_type_from_metadata( $block_folder, $block_options );
};
};

if ( $is_pre_wp_6 ) {
// Remove the filter after we register the blocks
remove_filter( 'plugins_url', __NAMESPACE__ . '\filter_plugins_url', 10, 2 );
}
}

/**
* Filter the plugins_url to allow us to use assets from theme.
*
* @param string $url The plugins url
* @param string $path The path to the asset.
*
* @return string The overridden url to the block asset.
*/
function filter_plugins_url( $url, $path ) {
$file = preg_replace( '/\.\.\//', '', $path );
return trailingslashit( get_stylesheet_directory_uri() ) . $file;
}


/**
* Enqueue editor-only JavaScript/CSS for blocks.
*
Expand Down