'canvas/row', 'title' => esc_html__( 'Row', 'canvas' ), 'description' => esc_html__( '12-columns system for your content.', 'canvas' ), 'category' => 'canvas', 'keywords' => array( 'row', 'grid', 'columns' ), '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(), 'fields' => array( array( 'key' => 'verticalAlignment', 'type' => 'type-string', 'default' => '', ), array( 'key' => 'columns', 'type' => 'number', 'label' => esc_html__( 'Columns', 'canvas' ), 'min' => 1, 'max' => 6, 'default' => 2, ), array( 'key' => 'gap', 'type' => 'number', 'label' => esc_html__( 'Gap', 'canvas' ), 'min' => 0, 'max' => 100, 'default' => 30, 'responsive' => true, ), ), 'template' => dirname( __FILE__ ) . '/block-row/render.php', // enqueue registered scripts/styles. 'style' => is_admin() ? '' : 'canvas-block-row-style', 'editor_script' => 'canvas-block-row-editor-script', 'editor_style' => 'canvas-block-row-editor-style', ); $blocks[] = array( 'name' => 'canvas/column', 'title' => esc_html__( 'Column', '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/row', ), 'styles' => array(), 'location' => array(), 'sections' => array(), 'layouts' => array(), 'fields' => array( array( 'key' => 'size', 'label' => esc_html__( 'Size', 'canvas' ), 'type' => 'number', 'min' => 1, 'max' => 12, 'default' => '', 'default_notebook' => 12, 'default_laptop' => 12, 'default_tablet' => 12, 'default_mobile' => 12, 'responsive' => true, ), array( 'key' => 'order', 'label' => esc_html__( 'Order', 'canvas' ), 'type' => 'number', 'min' => 1, 'max' => 12, 'default' => '', 'responsive' => true, ), array( 'key' => 'minHeight', 'label' => esc_html__( 'Minimum Height', 'canvas' ), 'type' => 'dimension', 'default' => '', 'responsive' => true, ), array( 'key' => 'verticalAlign', 'label' => esc_html__( 'Vertical Align', 'canvas' ), 'type' => 'icon-buttons', 'choices' => array( 'top' => '', 'center' => '', 'bottom' => '', ), 'default' => '', 'responsive' => true, ), // Colors. array( 'key' => 'textColor', 'label' => esc_html__( 'Text Color', 'canvas' ), 'section' => esc_html__( 'Color Settings' ), 'type' => 'color', 'default' => '', 'output' => array( array( 'element' => '$ .cnvs-block-column-inner', 'property' => 'color', 'suffix' => '!important', ), ), ), array( 'key' => 'backgroundColor', 'label' => esc_html__( 'Background Color', 'canvas' ), 'section' => esc_html__( 'Color Settings' ), 'type' => 'color', 'default' => '', 'output' => array( array( 'element' => '$ .cnvs-block-column-inner', 'property' => 'background-color', 'suffix' => '!important', ), ), ), ), 'template' => dirname( __FILE__ ) . '/block-column/render.php', // enqueue registered scripts/styles. 'editor_script' => 'canvas-block-column-editor-script', ); return $blocks; } /** * Change row styles * * @param string $return Current return. * @param string $block Block data. * @return string */ public function row_dynamic_styles( $return, $block ) { $attributes = $block['attrs']; $registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered(); // prepare defaults. if ( isset( $registered_blocks['canvas/row'] ) && isset( $registered_blocks['canvas/row']->attributes ) ) { foreach ( $registered_blocks['canvas/row']->attributes as $k => $attrs ) { if ( isset( $attrs['default'] ) && ! isset( $attributes[ $k ] ) ) { $attributes[ $k ] = $attrs['default']; } } } if ( isset( $attributes['canvasClassName'] ) ) { $class_name = $attributes['canvasClassName']; ob_start(); require plugin_dir_path( __FILE__ ) . '/block-row/styles.php'; $return .= ob_get_clean(); } return $return; } /** * Change column styles * * @param string $return Current return. * @param string $block Block data. * @return string */ public function column_dynamic_styles( $return, $block ) { $attributes = $block['attrs']; $registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered(); // prepare defaults. if ( isset( $registered_blocks['canvas/column'] ) && isset( $registered_blocks['canvas/column']->attributes ) ) { foreach ( $registered_blocks['canvas/column']->attributes as $k => $attrs ) { if ( isset( $attrs['default'] ) && ! isset( $attributes[ $k ] ) ) { $attributes[ $k ] = $attrs['default']; } } } if ( isset( $attributes['canvasClassName'] ) ) { $class_name = $attributes['canvasClassName']; ob_start(); require plugin_dir_path( __FILE__ ) . '/block-column/styles.php'; $return .= ob_get_clean(); } return $return; } /** * Change spacings styles * * @param string $return Current return. * @param string $selector Current selector. * @param string $styles Current styles. * @param string $block Block data. * @return string */ public function spacings_dynamic_styles( $return, $selector, $styles, $block ) { $return = $selector . ' .cnvs-block-column-inner { ' . $styles . ' } '; return $return; } } new CNVS_Block_Row();