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

Hotfix/fix filter #166

Merged
merged 2 commits into from
Jul 3, 2024
Merged
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
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