apply_filters( 'canvas_section_responsive_max_width', 1200 ), 'disableSectionResponsive' => get_theme_support( 'canvas-disable-section-responsive' ), ) ); } /** * Register block * * @param array $blocks all registered blocks. * @return array */ public function register_block_type( $blocks ) { $blocks[] = array( 'name' => 'canvas/section', 'title' => esc_html__( 'Section', 'canvas' ), 'description' => esc_html__( 'Section block with optional sidebar.', 'canvas' ), 'category' => 'canvas', 'keywords' => array( 'section', 'sidebar', 'widgets' ), 'icon' => ' ', 'supports' => array( 'className' => true, 'anchor' => true, 'html' => false, 'canvasBackgroundImage' => true, 'canvasSpacings' => true, 'canvasBorder' => true, 'canvasResponsive' => true, ), 'styles' => array(), 'location' => array(), 'sections' => array(), 'layouts' => array(), // Set fields just for add block attributes. // Editor render for this block is custom JSX // so we don't need to render fields automatically. 'fields' => array( array( 'key' => 'layout', 'type' => 'type-string', 'default' => '', ), array( 'key' => 'layoutAlign', 'type' => 'type-string', 'default' => '', ), array( 'key' => 'contentWidth', 'type' => 'type-number', 'default' => apply_filters( 'canvas_section_responsive_max_width', 1200 ), ), array( 'key' => 'sidebarPosition', 'type' => 'type-string', 'default' => 'right', ), array( 'key' => 'sidebarSticky', 'type' => 'type-boolean', 'default' => false, ), array( 'key' => 'sidebarStickyMethod', 'type' => 'type-string', 'default' => 'top', ), array( 'key' => 'textColor', 'label' => esc_html__( 'Text Color', 'canvas' ), 'section' => esc_html__( 'Color Settings' ), 'type' => 'color', 'default' => '', 'output' => array( array( 'property' => 'color', 'suffix' => '!important', ), ), ), array( 'key' => 'backgroundColor', 'label' => esc_html__( 'Background Color', 'canvas' ), 'section' => esc_html__( 'Color Settings' ), 'type' => 'color', 'default' => '', 'output' => array( array( 'property' => 'background-color', 'suffix' => '!important', ), ), ), ), 'template' => dirname( __FILE__ ) . '/block-section/render.php', // enqueue registered scripts/styles. 'style' => is_admin() ? '' : 'canvas-block-section-style', 'editor_script' => 'canvas-block-section-editor-script', 'editor_style' => 'canvas-block-section-editor-style', ); $blocks[] = array( 'name' => 'canvas/section-content', 'title' => esc_html__( 'Section Content', 'canvas' ), 'description' => '', 'category' => 'canvas', 'keywords' => array(), 'icon' => ' ', 'supports' => array( 'inserter' => false, 'reusable' => false, 'className' => true, 'anchor' => true, 'canvasBackgroundImage' => true, 'canvasSpacings' => true, 'canvasBorder' => true, 'canvasResponsive' => true, ), 'parent' => array( 'canvas/section', ), 'styles' => array(), 'location' => array(), 'sections' => array(), 'layouts' => array(), 'fields' => array(), 'template' => dirname( __FILE__ ) . '/block-section-content/render.php', // enqueue registered scripts/styles. 'editor_script' => 'canvas-block-section-content-editor-script', ); $blocks[] = array( 'name' => 'canvas/section-sidebar', 'title' => esc_html__( 'Section Sidebar', 'canvas' ), 'description' => '', 'category' => 'canvas', 'keywords' => array(), 'icon' => ' ', 'supports' => array( 'inserter' => false, 'reusable' => false, 'className' => true, 'anchor' => true, 'canvasBackgroundImage' => true, 'canvasSpacings' => true, 'canvasBorder' => true, 'canvasResponsive' => true, ), 'parent' => array( 'canvas/section', ), 'styles' => array(), 'location' => array(), 'sections' => array(), 'layouts' => array(), 'fields' => array(), 'template' => dirname( __FILE__ ) . '/block-section-sidebar/render.php', // enqueue registered scripts/styles. 'editor_script' => 'canvas-block-section-sidebar-editor-script', ); return $blocks; } } new CNVS_Block_Section();