Skip to content

Commit

Permalink
Merge pull request #166 from alleyinteractive/hotfix/fix-filter
Browse files Browse the repository at this point in the history
Hotfix/fix filter
  • Loading branch information
mogmarsh authored Jul 3, 2024
2 parents c143320 + da02a0a commit e1fdd2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Newsletter Builder
* Plugin URI: https://github.com/alleyinteractive/wp-newsletter-builder
* Description: Interface to manage email newsletters
* Version: 0.4.0
* Version: 0.4.1
* Author: Alley Interactive
* Author URI: https://github.com/alleyinteractive/wp-newsletter-builder
* Requires at least: 6.2
Expand Down
13 changes: 11 additions & 2 deletions src/class-block-modifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,22 @@ function () use ( $block ) {
* @return boolean
*/
public function filter_wp_newsletter_builder_register_block( bool $register ): bool {
$post_type = isset( $_GET['post'] ) ? get_post_type( intval( $_GET['post'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
global $pagenow;

$post_id = get_the_ID();
if ( empty( $post_id ) ) {
$post_id = isset( $_GET['post'] ) ? intval( $_GET['post'] ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
$post_type = isset( $_GET['post'] ) ? get_post_type( $post_id ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( empty( $post_type ) && isset( $_GET['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$post_type = sanitize_text_field( $_GET['post_type'] ) ?? 'post'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
if ( empty( $post_type ) ) {
if ( 'post-new.php' === $pagenow && empty( $post_type ) ) {
$post_type = 'post';
}
if ( empty( $post_type ) ) {
return $register;
}
if ( 'nb_newsletter' !== $post_type && 'nb_template' !== $post_type ) {
return false;
}
Expand Down

0 comments on commit e1fdd2e

Please sign in to comment.