-
-
Save zzramesses/66c1b6d5afcb851a9fb780cc77f34492 to your computer and use it in GitHub Desktop.
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 | |
namespace SAFCA\SAFCA\Blocks; | |
/** | |
* Set up theme defaults and register supported WordPress features. | |
* | |
* @since 0.1.0 | |
* | |
* @uses add_action() | |
* | |
* @return void | |
*/ | |
function setup() { | |
$n = function( $function ) { | |
return __NAMESPACE__ . "\\$function"; | |
}; | |
add_filter( 'allowed_block_types', $n( 'allowed_block_types' ) ); | |
/* add_action( 'init', $n( 'about_blocks_template' ) ); */ | |
/* add_action( 'wp_footer', $n( 'display_post_blocks' ) ); */ | |
} | |
function allowed_block_types( $allowed_blocks ) { | |
return array( | |
'core/paragraph', | |
'core/image', | |
'core/heading', | |
'core/list', | |
'core/file', | |
'core/video', | |
'core/freeform', | |
'core/html', | |
'core/pullquote', | |
'core/button', | |
'core/columns', | |
'core/media-text', | |
'core/more', | |
'core/separator', | |
'core/spacer', | |
'core/shortcode', | |
'core/embed', | |
'core-embed/youtube', | |
'core/embed/vimeo', | |
'acf/accordion', | |
'acf/photo-video-gallery', | |
'acf/suggested-content', | |
'acf/related-projects', | |
'acf/related-news', | |
'acf/related-resources', | |
'acf/about-hero', | |
'gravityforms/block', | |
'gravityforms/form' | |
); | |
} | |
function about_blocks_template() { | |
$post_id = $_GET['post']; | |
if( 'templates/about.php' !== get_page_template_slug( $post_id ) ) { | |
return false; | |
} | |
$page_type_object = get_post_type_object( 'page' ); | |
$post_type_object->template = array( | |
array( 'core/paragraph', array( | |
'placeholder' => 'Add Description...', | |
) ), | |
array( 'core/heading', array( | |
'placeholder' => 'Add Description...', | |
) ), | |
); | |
$post_type_object->template_lock = 'all'; | |
} | |
function display_post_blocks() { | |
global $post; | |
wp_send_json( esc_html( $post->post_content ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment