diff --git a/includes/class-pattern-builder-abstract-pattern.php b/includes/class-pattern-builder-abstract-pattern.php index 1ec09a7..dcc4099 100644 --- a/includes/class-pattern-builder-abstract-pattern.php +++ b/includes/class-pattern-builder-abstract-pattern.php @@ -132,7 +132,7 @@ function ( $category ) { 'title' => $post->post_title, 'description' => $post->post_excerpt, 'content' => $post->post_content, - 'source' => ( $post->post_type === 'pb_block' ) ? 'theme' : 'user', + 'source' => ( $post->post_type === 'tbell_pattern_block' ) ? 'theme' : 'user', 'synced' => ( $metadata['wp_pattern_sync_status'][0] ?? 'synced' ) !== 'unsynced', 'blockTypes' => isset( $metadata['wp_pattern_block_types'][0] ) ? explode( ',', $metadata['wp_pattern_block_types'][0] ) : array(), diff --git a/includes/class-pattern-builder-api.php b/includes/class-pattern-builder-api.php index 6be9813..103dc99 100644 --- a/includes/class-pattern-builder-api.php +++ b/includes/class-pattern-builder-api.php @@ -176,7 +176,7 @@ public function get_patterns( WP_REST_Request $request ): WP_REST_Response { $theme_patterns = $this->controller->get_block_patterns_from_theme_files(); $theme_patterns = array_map( function ( $pattern ) { - $pattern_post = $this->controller->get_pb_block_post_for_pattern( $pattern ); + $pattern_post = $this->controller->get_tbell_pattern_block_post_for_pattern( $pattern ); $pattern_from_post = Abstract_Pattern::from_post( $pattern_post ); // TODO: The slug doesn't survive the trip to post and back since it has to be normalized. // so we just pull it form the original pattern and reset it here. Not sure if that is the best way to do this. @@ -200,15 +200,15 @@ public function inject_theme_patterns( $response, $server, $request ) { // Requesting a single pattern. Inject the synced theme pattern. if ( preg_match( '#/wp/v2/blocks/(?P\d+)#', $request->get_route(), $matches ) ) { $block_id = intval( $matches['id'] ); - $pb_block = get_post( $block_id ); - if ( $pb_block && $pb_block->post_type === 'pb_block' ) { + $tbell_pattern_block = get_post( $block_id ); + if ( $tbell_pattern_block && $tbell_pattern_block->post_type === 'tbell_pattern_block' ) { // make sure the pattern has a pattern file - $pattern_file_path = $this->controller->get_pattern_filepath( Abstract_Pattern::from_post( $pb_block ) ); + $pattern_file_path = $this->controller->get_pattern_filepath( Abstract_Pattern::from_post( $tbell_pattern_block ) ); if ( ! $pattern_file_path ) { return $response; // No pattern file found, return the original response } - $pb_block->post_name = $this->controller->format_pattern_slug_from_post( $pb_block->post_name ); - $data = $this->format_pb_block_response( $pb_block, $request ); + $tbell_pattern_block->post_name = $this->controller->format_pattern_slug_from_post( $tbell_pattern_block->post_name ); + $data = $this->format_tbell_pattern_block_response( $tbell_pattern_block, $request ); $response = new WP_REST_Response( $data ); } } @@ -228,8 +228,8 @@ function ( $pattern ) { ); foreach ( $patterns as $pattern ) { - $post = $this->controller->get_pb_block_post_for_pattern( $pattern ); - $data[] = $this->format_pb_block_response( $post, $request ); + $post = $this->controller->get_tbell_pattern_block_post_for_pattern( $pattern ); + $data[] = $this->format_tbell_pattern_block_response( $post, $request ); } $response->set_data( $data ); @@ -238,7 +238,7 @@ function ( $pattern ) { return $response; } - public function format_pb_block_response( $post, $request ) { + public function format_tbell_pattern_block_response( $post, $request ) { $post->post_type = 'wp_block'; // Create a mock request to pass to the controller @@ -277,7 +277,7 @@ public function format_pb_block_response( $post, $request ) { * * If the patterns are ALREADY registered, unregister them first. * Synced patterns are registered with a reference to the post ID of their pattern. - * Unsynced patterns are registered with the content from the pb_block post. + * Unsynced patterns are registered with the content from the tbell_pattern_block post. */ public function register_patterns() { @@ -287,7 +287,7 @@ public function register_patterns() { foreach ( $patterns as $pattern ) { - $post = $this->controller->create_pb_block_post_for_pattern( $pattern ); + $post = $this->controller->create_tbell_pattern_block_post_for_pattern( $pattern ); if ( $pattern_registry->is_registered( $pattern->name ) ) { $pattern_registry->unregister( $pattern->name ); @@ -324,7 +324,7 @@ public function register_patterns() { /** * - * Filters delete calls and if the item being deleted is a 'pb_block' (theme pattern) + * Filters delete calls and if the item being deleted is a 'tbell_pattern_block' (theme pattern) * delete the related pattern php file as well. * */ @@ -337,7 +337,7 @@ function handle_hijack_block_delete( $response, $server, $request ) { $id = intval( $matches[1] ); $post = get_post( $id ); - if ( $post && $post->post_type === 'pb_block' && $request->get_method() === 'DELETE' ) { + if ( $post && $post->post_type === 'tbell_pattern_block' && $request->get_method() === 'DELETE' ) { $deleted = wp_delete_post( $id, true ); @@ -369,7 +369,7 @@ function handle_hijack_block_delete( $response, $server, $request ) { /** * - * This filter handles additional logic when a pb_block (theme pattern) is updated. + * This filter handles additional logic when a tbell_pattern_block (theme pattern) is updated. * It updates the pattern file as well as associated metadata for the pattern. * Additionally it will optionally localize the content as well as import any media * referenced by the pattern into the theme. @@ -398,7 +398,7 @@ function handle_hijack_block_update($response, $handler, $request) } } - if ($post->post_type === 'pb_block' || $convert_user_pattern_to_theme_pattern) { + if ($post->post_type === 'tbell_pattern_block' || $convert_user_pattern_to_theme_pattern) { // Check write permissions before allowing update if (! current_user_can('edit_others_posts')) { @@ -422,7 +422,7 @@ function handle_hijack_block_update($response, $handler, $request) $pattern = Abstract_Pattern::from_post($post); if (isset($updated_pattern['content'])) { - // remap pb_blocks to patterns + // remap tbell_pattern_blocks to patterns $blocks = parse_blocks($updated_pattern['content']); $blocks = $this->convert_blocks_to_patterns($blocks); $pattern->content = serialize_blocks($blocks); @@ -481,7 +481,7 @@ function handle_hijack_block_update($response, $handler, $request) } $post = get_post($pattern->id); - $formatted_response = $this->format_pb_block_response($post, $request); + $formatted_response = $this->format_tbell_pattern_block_response($post, $request); $response = new WP_REST_Response($formatted_response, 200); } } @@ -511,7 +511,7 @@ private function convert_blocks_to_patterns( $blocks ) { foreach ( $blocks as &$block ) { if ( isset( $block['blockName'] ) && $block['blockName'] === 'core/block' ) { $post = get_post( $block['attrs']['ref'] ); - if ( $post->post_type === 'pb_block' ) { + if ( $post->post_type === 'tbell_pattern_block' ) { $slug = Pattern_Builder_Controller::format_pattern_slug_from_post( $post->post_name ); $block['blockName'] = 'core/pattern'; $block['attrs'] = isset( $block['attrs'] ) ? $block['attrs'] : array(); diff --git a/includes/class-pattern-builder-controller.php b/includes/class-pattern-builder-controller.php index 2871604..d812a77 100644 --- a/includes/class-pattern-builder-controller.php +++ b/includes/class-pattern-builder-controller.php @@ -21,13 +21,13 @@ public static function format_pattern_slug_from_post( $slug ) { return $new_slug; } - public function get_pb_block_post_for_pattern( $pattern ) { + public function get_tbell_pattern_block_post_for_pattern( $pattern ) { $path = $this->format_pattern_slug_for_post( $pattern->name ); $posts = get_posts( array( 'name' => $path, - 'post_type' => 'pb_block', + 'post_type' => 'tbell_pattern_block', ) ); @@ -38,11 +38,11 @@ public function get_pb_block_post_for_pattern( $pattern ) { return $pattern_post; } - return $this->create_pb_block_post_for_pattern( $pattern ); + return $this->create_tbell_pattern_block_post_for_pattern( $pattern ); } - public function create_pb_block_post_for_pattern( $pattern ) { - $existing_post = get_page_by_path( $this->format_pattern_slug_for_post( $pattern->name ), OBJECT, array( 'pb_block' ) ); + public function create_tbell_pattern_block_post_for_pattern( $pattern ) { + $existing_post = get_page_by_path( $this->format_pattern_slug_for_post( $pattern->name ), OBJECT, array( 'tbell_pattern_block' ) ); $post_id = $existing_post ? $existing_post->ID : null; @@ -83,6 +83,23 @@ public function create_pb_block_post_for_pattern( $pattern ) { } else { delete_post_meta( $post_id, 'wp_pattern_inserter' ); } + if (!$post_id) { + + $post_id = wp_insert_post( + array( + 'post_title' => $pattern->title, + 'post_name' => $this->format_pattern_slug_for_post( $pattern->name ), + 'post_content' => $pattern->content, + 'post_excerpt' => $pattern->description, + 'post_type' => 'tbell_pattern_block', + 'post_status' => 'publish', + 'ping_status' => 'closed', + 'comment_status' => 'closed', + 'meta_input' => $meta, + ), true + ); + + } else { $post_id = wp_insert_post( array( @@ -91,14 +108,16 @@ public function create_pb_block_post_for_pattern( $pattern ) { 'post_name' => $this->format_pattern_slug_for_post( $pattern->name ), 'post_content' => $pattern->content, 'post_excerpt' => $pattern->description, - 'post_type' => 'pb_block', + 'post_type' => 'tbell_pattern_block', 'post_status' => 'publish', 'ping_status' => 'closed', 'comment_status' => 'closed', 'meta_input' => $meta, - ) + ), true ); + } + // store categories wp_set_object_terms( $post_id, $pattern->categories, 'wp_pattern_category', false ); @@ -111,8 +130,8 @@ public function create_pb_block_post_for_pattern( $pattern ) { public function update_theme_pattern(Abstract_Pattern $pattern, $options = array()) { - // get the pb_block post if it already exists - $post = get_page_by_path($this->format_pattern_slug_for_post($pattern->name), OBJECT, array('pb_block', 'wp_block')); + // get the tbell_pattern_block post if it already exists + $post = get_page_by_path($this->format_pattern_slug_for_post($pattern->name), OBJECT, array('tbell_pattern_block', 'wp_block')); if ($post && $post->post_type === 'wp_block') { // this is being converted to theme patterns, change the slug to include the theme domain @@ -142,7 +161,7 @@ public function update_theme_pattern(Abstract_Pattern $pattern, $options = array 'post_name' => $this->format_pattern_slug_for_post($pattern->name), 'post_excerpt' => $pattern->description, 'post_content' => $pattern->content, - 'post_type' => 'pb_block', + 'post_type' => 'tbell_pattern_block', ) ); @@ -389,11 +408,11 @@ public function update_user_pattern( Abstract_Pattern $pattern ) { $convert_from_theme_pattern = false; if ( empty( $post ) ) { - // check if the pattern exists in the database as a pb_block post + // check if the pattern exists in the database as a tbell_pattern_block post // this is for any user patterns that are being converted from theme patterns // It will be converted to a wp_block post when it is updated $slug = $this->format_pattern_slug_for_post( $pattern->name ); - $post = get_page_by_path( $slug, OBJECT, 'pb_block' ); + $post = get_page_by_path( $slug, OBJECT, 'tbell_pattern_block' ); $convert_from_theme_pattern = true; } @@ -520,8 +539,8 @@ public function delete_theme_pattern( Abstract_Pattern $pattern ) { return new WP_Error( 'pattern_delete_failed', 'Failed to delete pattern', array( 'status' => 500 ) ); } - $pb_block_post = $this->get_pb_block_post_for_pattern( $pattern ); - $deleted = wp_delete_post( $pb_block_post->ID, true ); + $tbell_pattern_block_post = $this->get_tbell_pattern_block_post_for_pattern( $pattern ); + $deleted = wp_delete_post( $tbell_pattern_block_post->ID, true ); if ( ! $deleted ) { return new WP_Error( 'pattern_delete_failed', 'Failed to delete pattern', array( 'status' => 500 ) ); @@ -598,8 +617,8 @@ function ( $matches ) use ( $pattern ) { // get the post of the pattern $pattern_post = get_post( $attributes['ref'], OBJECT ); - // if the post is a pb_block post, we can convert it to a wp:pattern block - if ( $pattern_post && $pattern_post->post_type === 'pb_block' ) { + // if the post is a tbell_pattern_block post, we can convert it to a wp:pattern block + if ( $pattern_post && $pattern_post->post_type === 'tbell_pattern_block' ) { $pattern_slug = $pattern_post->post_name; diff --git a/includes/class-pattern-builder-post-type.php b/includes/class-pattern-builder-post-type.php index 1dfaf84..c1b827b 100644 --- a/includes/class-pattern-builder-post-type.php +++ b/includes/class-pattern-builder-post-type.php @@ -5,8 +5,8 @@ class Pattern_Builder_Post_Type { public function __construct() { - add_action( 'init', array( $this, 'register_pb_block_post_type' ) ); - add_filter( 'render_block', array( $this, 'render_pb_blocks' ), 10, 2 ); + add_action( 'init', array( $this, 'register_tbell_pattern_block_post_type' ) ); + add_filter( 'render_block', array( $this, 'render_tbell_pattern_blocks' ), 10, 2 ); add_filter( 'register_block_type_args', array( $this, 'add_content_attribute_to_core_pattern_block' ), 10, 2 ); } @@ -31,12 +31,12 @@ public function add_content_attribute_to_core_pattern_block( $args, $block_type } /** - * Registers the pb_block custom post type. + * Registers the tbell_pattern_block custom post type. */ - public function register_pb_block_post_type() { + public function register_tbell_pattern_block_post_type() { $labels = array( - 'name' => __( 'PB Blocks', 'pattern-builder' ), - 'singular_name' => __( 'PB Block', 'pattern-builder' ), + 'name' => __( 'Pattern Builder Blocks', 'pattern-builder' ), + 'singular_name' => __( 'Pattern Builder Block', 'pattern-builder' ), ); $args = array( @@ -46,17 +46,17 @@ public function register_pb_block_post_type() { 'show_ui' => true, 'show_in_menu' => false, 'show_in_rest' => true, - 'rest_base' => 'pb_blocks', + 'rest_base' => 'tbell_pattern_blocks', 'supports' => array( 'title', 'editor', 'revisions' ), 'hierarchical' => false, - 'capability_type' => 'pb_block', + 'capability_type' => 'tbell_pattern_block', 'map_meta_cap' => true, ); - register_post_type( 'pb_block', $args ); + $result = register_post_type( 'tbell_pattern_block', $args ); register_post_meta( - 'pb_block', + 'tbell_pattern_block', 'wp_pattern_sync_status', array( 'show_in_rest' => true, @@ -66,7 +66,7 @@ public function register_pb_block_post_type() { ); register_post_meta( - 'pb_block', + 'tbell_pattern_block', 'wp_pattern_block_types', array( 'show_in_rest' => true, @@ -76,7 +76,7 @@ public function register_pb_block_post_type() { ); register_post_meta( - 'pb_block', + 'tbell_pattern_block', 'wp_pattern_template_types', array( 'show_in_rest' => true, @@ -86,7 +86,7 @@ public function register_pb_block_post_type() { ); register_post_meta( - 'pb_block', + 'tbell_pattern_block', 'wp_pattern_inserter', array( 'show_in_rest' => true, @@ -96,7 +96,7 @@ public function register_pb_block_post_type() { ); register_post_meta( - 'pb_block', + 'tbell_pattern_block', 'wp_pattern_post_types', array( 'show_in_rest' => true, @@ -106,25 +106,25 @@ public function register_pb_block_post_type() { ); /** - * Add custom capabilities for the pb_block post type. + * Add custom capabilities for the tbell_pattern_block post type. */ $roles = array( 'administrator', 'editor' ); $capabilities = array( - 'edit_pb_block', - 'read_pb_block', - 'delete_pb_block', - 'edit_pb_blocks', - 'edit_others_pb_blocks', - 'publish_pb_blocks', - 'read_private_pb_blocks', - 'delete_pb_blocks', - 'delete_private_pb_blocks', - 'delete_published_pb_blocks', - 'delete_others_pb_blocks', - 'edit_private_pb_blocks', - 'edit_published_pb_blocks', + 'edit_tbell_pattern_block', + 'read_tbell_pattern_block', + 'delete_tbell_pattern_block', + 'edit_tbell_pattern_blocks', + 'edit_others_tbell_pattern_blocks', + 'publish_tbell_pattern_blocks', + 'read_private_tbell_pattern_blocks', + 'delete_tbell_pattern_blocks', + 'delete_private_tbell_pattern_blocks', + 'delete_published_tbell_pattern_blocks', + 'delete_others_tbell_pattern_blocks', + 'edit_private_tbell_pattern_blocks', + 'edit_published_tbell_pattern_blocks', ); // Assign capabilities to each role @@ -139,8 +139,8 @@ public function register_pb_block_post_type() { } /** - * Renders a "pb_block" block pattern. - * This is a block pattern stored as a pb_block post type instead of a wp_block post type. + * Renders a "tbell_pattern_block" block pattern. + * This is a block pattern stored as a tbell_pattern_block post type instead of a wp_block post type. * Which means that it is a "theme pattern" instead of a "user pattern". * * This borrows heavily from the core block rendering function. @@ -149,12 +149,12 @@ public function register_pb_block_post_type() { * @param array $block The block data. * @return string */ - public function render_pb_blocks( $block_content, $block ) { + public function render_tbell_pattern_blocks( $block_content, $block ) { // store a reference to the block to prevent infinite recursion static $seen_refs = array(); // if we have a block pattern with no content we PROBABLY are trying to render - // a pb_block (theme pattern) + // a tbell_pattern_block (theme pattern) if ( $block['blockName'] === 'core/block' && $block_content === '' ) { $attributes = $block['attrs'] ?? array(); @@ -164,7 +164,7 @@ public function render_pb_blocks( $block_content, $block ) { } $post = get_post( $attributes['ref'] ); - if ( ! $post || 'pb_block' !== $post->post_type ) { + if ( ! $post || 'tbell_pattern_block' !== $post->post_type ) { return ''; } diff --git a/package.json b/package.json index 19ed6bf..60b2324 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pattern-builder", - "version": "1.0.1", + "version": "1.0.2", "description": "Manage patterns in WordPress", "author": "twentybellows", "main": "build/index.js", diff --git a/pattern-builder.php b/pattern-builder.php index 0e05a90..d6033ec 100644 --- a/pattern-builder.php +++ b/pattern-builder.php @@ -6,7 +6,7 @@ * Description: Manage Patterns in the WordPress Editor. * Requires at least: 6.6 * Requires PHP: 7.2 - * Version: 1.0.1 + * Version: 1.0.2 * Author: Twenty Bellows * Author URI: https://twentybellows.com * License: GPL-2.0-or-later diff --git a/readme.txt b/readme.txt index d6753ad..49ed59e 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: twentybellows, pbking Tags: block-patterns, patterns, block-editor, gutenberg, design Requires at least: 6.6 Tested up to: 6.8 -Stable tag: 1.0.1 +Stable tag: 1.0.2 Requires PHP: 7.2 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -53,12 +53,6 @@ Pattern Builder transforms how you work with WordPress block patterns, providing * Speed up development workflow * Maintain brand consistency -= Support = - -* Email: support@twentybellows.com -* Issues: [GitHub Issues](https://github.com/Twenty-Bellows/pattern-builder/issues) -* Documentation: [GitHub Wiki](https://github.com/Twenty-Bellows/pattern-builder/wiki) - == Installation == = From WordPress Admin = diff --git a/src/utils/patternSaveMonitor.js b/src/utils/patternSaveMonitor.js index 4515138..5f8e85e 100644 --- a/src/utils/patternSaveMonitor.js +++ b/src/utils/patternSaveMonitor.js @@ -32,7 +32,7 @@ export const PatternSaveMonitor = () => { if ( options.path && ( options.path.includes( '/wp/v2/blocks/' ) || options.path.includes( '/pattern-builder/v1/' ) || - ( options.path.includes( '/wp/v2/posts/' ) && options.data?.type === 'pb_block' ) + ( options.path.includes( '/wp/v2/posts/' ) && options.data?.type === 'tbell_pattern_block' ) ) ) { // Check settings const shouldLocalize = getLocalizePatternsSetting(); @@ -40,11 +40,11 @@ export const PatternSaveMonitor = () => { // Build query parameters const params = []; - + if ( shouldLocalize ) { params.push( 'patternBuilderLocalize=true' ); } - + if ( ! shouldImportImages ) { // Only add parameter if disabled (since default is true) params.push( 'patternBuilderImportImages=false' ); @@ -73,14 +73,14 @@ export const PatternSaveMonitor = () => { // Also monitor the saving state for logging/debugging useEffect( () => { - if ( isSavingPost && postType === 'pb_block' ) { + if ( isSavingPost && postType === 'tbell_pattern_block' ) { const shouldLocalize = getLocalizePatternsSetting(); const shouldImportImages = getImportImagesSetting(); - + const settings = []; if ( shouldLocalize ) settings.push( 'localize=true' ); if ( ! shouldImportImages ) settings.push( 'importImages=false' ); - + if ( settings.length > 0 ) { console.log( `Saving theme pattern with settings (${settings.join(', ')}):`, currentPost?.title ); } diff --git a/src/utils/store.js b/src/utils/store.js index 544d87d..43c0deb 100644 --- a/src/utils/store.js +++ b/src/utils/store.js @@ -132,7 +132,7 @@ const actions = { .dispatch( 'core' ) .invalidateResolution( 'getEntityRecord', [ 'postType', - 'pb_block', + 'tbell_pattern_block', savedPattern.id, ] ); wp.data @@ -146,7 +146,7 @@ const actions = { .dispatch( 'core' ) .invalidateResolution( 'getEntityRecords', [ 'postType', - 'pb_block', + 'tbell_pattern_block', ] ); wp.data .dispatch( 'core' ) diff --git a/tests/php/test-pattern-builder-api.php b/tests/php/test-pattern-builder-api.php index 8b02644..09684b7 100644 --- a/tests/php/test-pattern-builder-api.php +++ b/tests/php/test-pattern-builder-api.php @@ -138,7 +138,7 @@ public function test_core_get_blocks_api_with_synced_theme_pattern() { /** * Test that a theme synced pattern is registered and returned in this route: /wp/v2/block-patterns/patterns. - * It should be hidden from the inserter and reference the corresponding pb_block. + * It should be hidden from the inserter and reference the corresponding tbell_pattern_block. */ public function test_core_get_pattern_api_with_synced_theme_pattern() { @@ -304,14 +304,14 @@ public function test_convert_theme_pattern_to_user_pattern() { $this->assertArrayNotHasKey('source', $pattern); $this->assertEquals('theme-synced-pattern', $pattern['slug']); - //Ensure there is not a pb_block post for this pattern - // get app 'pb_block' posts - $all_pb_block_posts = get_posts([ - 'post_type' => 'pb_block', + //Ensure there is not a tbell_pattern_block post for this pattern + // get app 'tbell_pattern_block' posts + $all_tbell_pattern_block_posts = get_posts([ + 'post_type' => 'tbell_pattern_block', 'numberposts' => -1, 'post_status' => 'any', ]); - $this->assertEmpty($all_pb_block_posts, 'There should be no pb_block posts after converting the theme pattern to a user pattern.'); + $this->assertEmpty($all_tbell_pattern_block_posts, 'There should be no tbell_pattern_block posts after converting the theme pattern to a user pattern.'); // Make sure the pattern file has been removed $pattern_file = $this->test_dir . '/patterns/theme_synced_pattern.php'; @@ -355,13 +355,13 @@ public function test_convert_user_pattern_to_theme_pattern() { $this->assertEquals('theme', $pattern['source']); $this->assertCount(1, $data); - //fetch all of the pb_block posts - $all_pb_block_posts = get_posts([ - 'post_type' => 'pb_block', + //fetch all of the tbell_pattern_block posts + $all_tbell_pattern_block_posts = get_posts([ + 'post_type' => 'tbell_pattern_block', 'numberposts' => -1, 'post_status' => 'any', ]); - $this->assertCount(1, $all_pb_block_posts, 'There should be one pb_block post after converting the user pattern to a theme pattern.'); + $this->assertCount(1, $all_tbell_pattern_block_posts, 'There should be one tbell_pattern_block post after converting the user pattern to a theme pattern.'); // Make sure the pattern file has been created $pattern_file = $this->test_dir . '/patterns/test-user-pattern.php'; @@ -403,14 +403,14 @@ public function test_convert_theme_pattern_to_user_pattern_and_back() { $this->assertArrayNotHasKey('source', $pattern); $this->assertCount(1, $data); - //Ensure there is not a pb_block post for this pattern - // get app 'pb_block' posts - $all_pb_block_posts = get_posts([ - 'post_type' => 'pb_block', + //Ensure there is not a tbell_pattern_block post for this pattern + // get app 'tbell_pattern_block' posts + $all_tbell_pattern_block_posts = get_posts([ + 'post_type' => 'tbell_pattern_block', 'numberposts' => -1, 'post_status' => 'any', ]); - $this->assertEmpty($all_pb_block_posts, 'There should be no pb_block posts after converting the theme pattern to a user pattern.'); + $this->assertEmpty($all_tbell_pattern_block_posts, 'There should be no tbell_pattern_block posts after converting the theme pattern to a user pattern.'); // Make sure the pattern file has been removed $pattern_file = $this->test_dir . '/patterns/theme_synced_pattern.php'; @@ -519,13 +519,13 @@ public function test_delete_theme_pattern() { $this->assertEquals(200, $response->get_status()); - // confirm that there are no pb_block posts - $all_pb_block_posts = get_posts([ - 'post_type' => 'pb_block', + // confirm that there are no tbell_pattern_block posts + $all_tbell_pattern_block_posts = get_posts([ + 'post_type' => 'tbell_pattern_block', 'numberposts' => -1, 'post_status' => 'any', ]); - $this->assertEmpty($all_pb_block_posts, 'There should be no pb_block posts after deleting the theme pattern.'); + $this->assertEmpty($all_tbell_pattern_block_posts, 'There should be no tbell_pattern_block posts after deleting the theme pattern.'); //confirm that the pattern file has been deleted $pattern_file = $this->test_dir . '/patterns/theme_synced_pattern.php';