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

Issue-122: Disable editor styles on nb_newsletter edit screen #123

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion src/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function action_enqueue_block_editor_assets(): void {

/**
* Allow filtering of allowed post types available in the post picker.
*
*
* @param array<string> $allowed_post_types The allowed post types. Defaults to `post`.
* @return array<string> The filtered array of allowed post types.
*/
Expand Down Expand Up @@ -274,3 +274,20 @@ function load_scripts(): void {
}

load_scripts();

/**
* Remove the editor styles on the post edit screen for nb_newsletter post types.
*
* @param string $path The path to the file.
* @param string $file The file name.
* @return string|null The path to the file or null if we're on the post edit screen for a nb_newsletter post type.
*/
function remove_editor_styles_on_newsletters( $path, $file ) {
// If we're on the post edit screen for a nb_newsletter post type, remove the editor styles.
if ( is_admin() && 'nb_newsletter' === get_post_type() && 'theme.json' === $file ) {
return null;
}
return $path;
}

add_filter( 'theme_file_path', __NAMESPACE__ . '\remove_editor_styles_on_newsletters', 10, 2 );