Last active
August 16, 2019 20:33
-
-
Save BinaryMoon/f5094960f888b16d29696dcca63e54c5 to your computer and use it in GitHub Desktop.
Set the classic editor block as the default block when creating a new post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Classic Editor First | |
* Plugin URI: https://prothemedesign.com | |
* Description: Set the default post block to use the classic editor block. | |
* Author: Ben Gillbanks | |
* Version: 1.0 | |
* Author URI: https://prothemedesign.com | |
*/ | |
/** | |
* Modify post type arguments to add default post type templates. | |
* | |
* @param array $args The default post type arguments. | |
* @param string $post_type The post type for the current request. | |
* @return array Modified arguments including the new template properties. | |
*/ | |
function my_theme_post_type_arguments( $args, $post_type ) { | |
// Only apply changes to the specified post type. | |
// You could remove this to apply the change to all post types, or change it | |
// to filter selected post types. | |
if ( 'post' !== $post_type ) { | |
return $args; | |
} | |
/** | |
* Adds a template property to the specified post type arguments. | |
* | |
* You can get a list of available blocks by entering the following js | |
* command in the console window in your browser. | |
* wp.blocks.getBlockTypes() | |
* | |
* The output of this command also shows the available attributes for setting defaults. | |
* | |
* @var array | |
*/ | |
$args['template'] = array( | |
array( 'core/freeform' ), | |
); | |
return $args; | |
} | |
add_filter( 'register_post_type_args', 'my_theme_post_type_arguments', 20, 2 ); |
Ah ha - good catch. Thanks for pointing that out. I've updated the code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, simple code. Thanks!
Though I think there is
$args
missing in firstreturn
. Line23
should probably be: