data = $data; } public function get_block() { $atts = $this->data['ct_options']; $query_attrs = [ 'type' => 'post', 'post_type' => 'post', 'limit' => 5, 'term_ids' => [], 'order' => 'desc', 'limit' => blocksy_akg('posts_number', $atts, 5), 'post_type' => blocksy_akg('post_type_source', $atts, 'post'), ]; $orderby_map = [ 'default' => 'post_date', 'random' => 'rand', 'recent' => 'post_date', 'commented' => 'comment_count' ]; $proper_orderby = 'post_date'; $current_type = blocksy_akg('type', $atts, 'default'); if (isset($orderby_map[$current_type])) { $query_attrs['orderby'] = $orderby_map[$current_type]; } $post_template_blocks = [ [ "blockName" => "blocksy/dynamic-data", "attrs" => [ "tagName" => "h2", "field" => "wp:title", 'has_field_link' => 'yes', "style" => [ "spacing" => [ "margin" => [ "bottom" => "var:preset|spacing|20" ] ], 'typography' => [ 'fontSize' => '15px', 'fontWeight' => '500' ] ] ], "innerBlocks" => [], "innerHTML" => "", "innerContent" => [] ], ]; if (blocksy_akg('display_excerpt', $atts, 'no') === 'yes') { $post_template_blocks[] = [ "blockName" => "blocksy/dynamic-data", "attrs" => [ "field" => "wp:excerpt", 'excerpt_length' => blocksy_akg('excerpt_lenght', $atts, 10), 'style' => [ 'typography' => [ 'fontSize' => '13px' ], 'spacing' => [ 'margin' => [ 'bottom' => 'var:preset|spacing|30' ] ] ] ], "innerBlocks" => [], "innerHTML" => "", "innerContent" => [] ]; } if (blocksy_akg('display_date', $atts, 'no') === 'yes') { $post_template_blocks[] = [ "blockName" => "blocksy/dynamic-data", "attrs" => [ "field" => "wp:date", 'style' => [ 'typography' => ['fontSize' => '13px'] ] ], "innerBlocks" => [], "innerHTML" => "", "innerContent" => [] ]; } $posts_type = blocksy_akg('posts_type', $atts, 'small-thumbs'); if ( $posts_type === 'small-thumbs' || $posts_type === 'large-thumbs' || $posts_type === 'large-small' || $posts_type === 'rounded' ) { $featured_image_block = [ "blockName" => "blocksy/dynamic-data", "attrs" => [ "field" => "wp:featured_image", "aspectRatio" => "1", 'has_field_link' => 'yes' ], "innerBlocks" => [], "innerHTML" => "", "innerContent" => [] ]; $sizeSlug = 'thumbnail'; if (blocksy_akg('post_widget_thumb_size', $atts, 'default') !== 'default') { $sizeSlug = blocksy_akg('post_widget_thumb_size', $atts, 'default'); } $featured_image_block['attrs']['sizeSlug'] = $sizeSlug; if ($posts_type === 'rounded') { $featured_image_block['attrs']['style'] = [ 'border' => [ 'radius' => '100%' ] ]; } $columns_layout = [ "blockName" => "core/columns", "attrs" => [ 'style' => [ 'spacing' => [ 'blockGap' => [ 'left' => '20px' ] ] ] ], "innerBlocks" => [ [ "blockName" => "core/column", "attrs" => [ "width" => "25%" ], "innerBlocks" => [ $featured_image_block ], "innerHTML" => '
', "innerContent" => [ '