PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 1.0.6
Gutenify – Visual Site Builder Blocks & Starter Templates v1.0.6
1.9.0 1.8.0 1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 74 releases
gutenify / inc / get-dynamic-blocks.php

get-dynamic-blocks.php in Gutenify – Visual Site Builder Blocks & Starter Templates 1.0.6, at inc/get-dynamic-blocks.php

76 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Loads dynamic blocks for server-side rendering.
4 *
5 * @package Gutenify
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 // Register server-side code for individual blocks.
14 foreach ( glob( dirname( dirname( __FILE__ ) ) . '/src/blocks/*/index.php' ) as $gutenify_block_logic ) {
15 require_once $gutenify_block_logic;
16 }
17
18 /**
19 * Register meta field.
20 *
21 * @return void
22 */
23 function gutenify_register_meta_fields() {
24 $post_types = apply_filters( 'gutenify_active_post_types', array( 'post', 'page', 'wp_template', 'wp_template_part', 'template-kits' ) );
25 if ( ! empty( $post_types ) ) {
26 $meta_fields['gutenify_custom_css'] = array(
27 'show_in_rest' => true,
28 'single' => true,
29 'type' => 'string',
30 "default" => "",
31 // 'auth_callback' => function () {
32 // return current_user_can( 'edit_posts' );
33 // },
34 'auth_callback' => '__return_true',
35 );
36
37 $meta_fields['gutenify_custom_css_data'] = array(
38 'show_in_rest' => true,
39 'single' => true,
40 'type' => 'string',
41 'auth_callback' => function () {
42 return current_user_can( 'edit_posts' );
43 },
44 );
45
46 foreach ( $post_types as $post_type ) {
47 if ( ! empty( $meta_fields ) ) {
48 foreach ( $meta_fields as $meta_key => $meta_args ) {
49 register_post_meta( $post_type, $meta_key, $meta_args );
50 }
51 }
52 }
53 }
54 }
55 add_action( 'init', 'gutenify_register_meta_fields' );
56
57 /**
58 * Add block category
59 *
60 * @param array $categories Block categories.
61 * @return array
62 */
63 function gutenify_block_categories( $categories ) {
64 // error_log( print_r( $categories, true ));
65 return array_merge(
66 array(
67 array(
68 'slug' => 'gutenify',
69 'title' => __( 'Gutenify Blocks', 'gutenify' ),
70 ),
71 ),
72 $categories
73 );
74 }
75 add_filter( 'block_categories_all', 'gutenify_block_categories', 100, 2 );
76