1 ) { foreach ( $colors as $name => $scheme ) { $styles[] = array( 'name' => 'pk-share-buttons-' . $name, 'label' => $scheme['name'], ); } } // Layouts. if ( count( (array) $layouts ) > 1 ) { $layouts_array = array(); foreach ( $layouts as $name => $layout ) { $layouts_array[ $name ] = $layout['name']; } $additional_fields[] = array( 'key' => 'layout', 'label' => esc_html__( 'Layout', 'powerkit' ), 'section' => 'general', 'type' => 'select', 'default' => 'default', 'choices' => $layouts_array, ); } $accounts = apply_filters( 'powerkit_share_buttons_accounts', array(), null, null ); $accounts_choices = array(); foreach ( $accounts as $key => $account ) { $accounts_choices[ $key ] = esc_html( $account['name'] ); } $blocks[] = array( 'name' => 'canvas/share-buttons', 'title' => esc_html__( 'Share Buttons', 'powerkit' ), 'category' => 'canvas', 'keywords' => array(), 'icon' => '', 'supports' => array( 'className' => true, 'anchor' => true, 'html' => false, 'canvasSpacings' => true, 'canvasBorder' => true, 'canvasResponsive' => true, ), 'styles' => $styles, 'location' => array(), 'sections' => array( 'general' => array( 'title' => esc_html__( 'Block Settings', 'powerkit' ), 'priority' => 5, 'open' => true, ), ), 'layouts' => array(), 'fields' => array_merge( $additional_fields, array( array( 'key' => 'accounts', 'label' => esc_html__( 'Accounts', 'powerkit' ), 'section' => 'general', 'type' => 'react-select', 'multiple' => true, 'choices' => $accounts_choices, 'default' => array( 'facebook', 'twitter', 'pinterest', ), 'items' => array( 'type' => 'string', ), ), array( 'key' => 'showTotal', 'label' => esc_html__( 'Display Total Shares', 'powerkit' ), 'section' => 'general', 'type' => 'toggle', 'default' => false, ), array( 'key' => 'showIcons', 'label' => esc_html__( 'Display Icons', 'powerkit' ), 'section' => 'general', 'type' => 'toggle', 'default' => true, ), array( 'key' => 'showLabels', 'label' => esc_html__( 'Display Labels', 'powerkit' ), 'section' => 'general', 'type' => 'toggle', 'default' => true, ), array( 'key' => 'showTitles', 'label' => esc_html__( 'Display Titles', 'powerkit' ), 'section' => 'general', 'type' => 'toggle', 'default' => true, ), array( 'key' => 'showCounts', 'label' => esc_html__( 'Display Counts', 'powerkit' ), 'section' => 'general', 'type' => 'toggle', 'default' => true, ), ) ), 'template' => dirname( __FILE__ ) . '/block/render.php', // enqueue registered scripts/styles. 'editor_style' => 'powerkit-share-buttons-block-editor-style', ); return $blocks; } } new Powerkit_Share_Buttons_Block();