Skip to content

Commit

Permalink
Merge pull request #91 from alleyinteractive/fix/fix-supported-post-t…
Browse files Browse the repository at this point in the history
…ypes

fix supported post types
  • Loading branch information
mogmarsh authored Nov 1, 2023
2 parents ce2e532 + 04c57cf commit 157e5a3
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `WP Curate` will be documented in this file.

## 1.4.1 - 2023-11-01

- Bug fix: allow blocks when no post type is defined.

## 1.4.0 - 2023-10-30

- Bug fix: prevents error if `termRelations` attribute is not set.
Expand Down
2 changes: 1 addition & 1 deletion blocks/post/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
function wp_curate_post_block_init(): void {
$supported_post_types = new Supported_Post_Types();
if ( ! in_array( $supported_post_types->get_current_post_type(), $supported_post_types->get_supported_post_types(), true ) ) {
if ( ! $supported_post_types->should_register_block() ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion blocks/query/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
function wp_curate_query_block_init(): void {
$supported_post_types = new Supported_Post_Types();

if ( ! in_array( $supported_post_types->get_current_post_type(), $supported_post_types->get_supported_post_types(), true ) ) {
if ( ! $supported_post_types->should_register_block() ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion entries/slotfills/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function register_slotfills_scripts(): void {
$allowed_post_types = apply_filters( 'wp_curate_duduplication_slotfill_post_types', [ 'page', 'post' ] );

$supported_post_types = new Supported_Post_Types();
if ( ! in_array( $supported_post_types->get_current_post_type(), $allowed_post_types, true ) ) {
if ( ! $supported_post_types->should_register_block() ) {
return;
}

Expand Down
27 changes: 0 additions & 27 deletions src/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ function action_wp_enqueue_scripts(): void {
| https://github.com/alleyinteractive/wp-asset-manager
|
*/

// wp_enqueue_script(
// 'wp-curate-example-entry',
// get_entry_asset_url( 'example-entry' ),
// get_asset_dependency_array( 'example-entry' ),
// get_asset_version( 'example-entry' ),
// true
// );
// wp_set_script_translations( 'wp-curate-example-entry', 'wp-curate' );
}

/**
Expand All @@ -55,15 +46,6 @@ function action_admin_enqueue_scripts(): void {
| assets that are loaded only in the WordPress admin.
|
*/

// wp_enqueue_script(
// 'wp-curate-admin-handle',
// get_entry_asset_url( 'admin-handle' ),
// get_asset_dependency_array( 'admin-handle' ),
// get_asset_version( 'admin-handle' ),
// true
// );
// wp_set_script_translations( 'wp-curate-admin-handle', 'wp-curate' );
}

/**
Expand All @@ -79,15 +61,6 @@ function action_enqueue_block_editor_assets(): void {
| enqueue assets that are loaded in the block editor.
|
*/

// wp_enqueue_script(
// 'wp-curate-slotfills',
// get_entry_asset_url( 'slotfills' ),
// get_asset_dependency_array( 'slotfills' ),
// get_asset_version( 'slotfills' ),
// true
// );
// wp_set_script_translations( 'wp-curate-slotfills', 'wp-curate' );
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/class-supported-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@ public function register_post_meta(): void {
]
);
}

/**
* Should we register the block in the current context.
*
* @return boolean
*/
public function should_register_block(): bool {
return empty( $this->get_current_post_type() ) || in_array( $this->get_current_post_type(), $this->get_supported_post_types(), true );
}
}
2 changes: 1 addition & 1 deletion wp-curate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Curate
* Plugin URI: https://github.com/alleyinteractive/wp-curate
* Description: Plugin to curate homepages and other landing pages
* Version: 1.4.0
* Version: 1.4.1
* Author: Alley Interactive
* Author URI: https://github.com/alleyinteractive/wp-curate
* Requires at least: 6.3
Expand Down

0 comments on commit 157e5a3

Please sign in to comment.