$this->attributes(), 'render_callback' => [$this, 'render'] ) ); } function attributes(){ return array( 'align' => array( 'type' => 'string', 'default' => 'wide' ), 'cId' => array( 'type' => 'string', 'default' => '' ), 'layout' => array( 'type' => 'string', 'default' => 'grid' ), 'subLayout' => array( 'type' => 'string', 'default' => 'default' ), 'columns' => array( 'type' => 'object', 'default' => array( 'desktop' => 3, 'tablet' => 2, 'mobile' => 1 ) ), 'columnGap' => array( 'type' => 'number', 'default' => 15 ), 'rowGap' => array( 'type' => 'number', 'default' => 15 ), 'isContentEqualHight' => array( 'type' => 'boolean', 'default' => true ), 'postType' => array( 'type' => 'string', 'default' => 'post' ), 'selectedCategories' => array( 'type' => 'array', 'default' => array() ), 'isPostsPerPageAll' => array( 'type' => 'boolean', 'default' => false ), 'postsPerPage' => array( 'type' => 'number', 'default' => 12 ), 'postsOrderBy' => array( 'type' => 'string', 'default' => 'date' ), 'postsOrder' => array( 'type' => 'string', 'default' => 'desc' ), 'contentAlign' => array( 'type' => 'string', 'default' => 'left' ), 'contentBG' => array( 'type' => 'object', 'default' => array( 'color' => '#f4f2fc' ) ), 'contentPadding' => array( 'type' => 'object', 'default' => array( 'vertical' => '20px', 'horizontal' => '25px' ) ), 'border' => array( 'type' => 'object', 'default' => array( 'radius' => '5px' ) ), 'isFImg' => array( 'type' => 'boolean', 'default' => true ), 'isFImgLink' => array( 'type' => 'boolean', 'default' => false ), 'isTitle' => array( 'type' => 'boolean', 'default' => true ), 'isTitleLink' => array( 'type' => 'boolean', 'default' => true ), 'titleTypo' => array( 'type' => 'object', 'default' => array( 'fontFamily' => 'Roboto', 'fontSize' => 25, 'googleFontLink' => 'https://fonts.googleapis.com/css2?family=Roboto&display=swap' ) ), 'titleColor' => array( 'type' => 'string', 'default' => '#4527a4' ), 'titleMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '15px' ) ), 'isMeta' => array( 'type' => 'boolean', 'default' => true ), 'isMetaAuthor' => array( 'type' => 'boolean', 'default' => true ), 'isMetaDate' => array( 'type' => 'boolean', 'default' => true ), 'isMetaCategory' => array( 'type' => 'boolean', 'default' => true ), 'metaCategoryIn' => array( 'type' => 'string', 'default' => 'content' ), 'isMetaComment' => array( 'type' => 'boolean', 'default' => false ), 'metaTypo' => array( 'type' => 'object', 'default' => array( 'fontSize' => 13, 'textTransform' => 'uppercase' ) ), 'metaTextColor' => array( 'type' => 'string', 'default' => '#333' ), 'metaLinkColor' => array( 'type' => 'string', 'default' => '#8344c5' ), 'metaIconColor' => array( 'type' => 'string', 'default' => '#4527a4' ), 'metaMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '15px' ) ), 'isExcerpt' => array( 'type' => 'boolean', 'default' => true ), 'excerptLength' => array( 'type' => 'number', 'default' => 25 ), 'excerptAlign' => array( 'type' => 'string', 'default' => 'justify' ), 'excerptTypo' => array( 'type' => 'object', 'default' => array( 'fontSize' => 15 ) ), 'excerptColor' => array( 'type' => 'string', 'default' => '#333' ), 'excerptMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '10px' ) ), 'isReadMore' => array( 'type' => 'boolean', 'default' => true ), 'readMoreLabel' => array( 'type' => 'string', 'default' => 'Read More' ), 'isLinkNewTab' => array( 'type' => 'boolean', 'default' => false ), 'readMoreAlign' => array( 'type' => 'string', 'default' => 'left' ), 'readMoreTypo' => array( 'type' => 'object', 'default' => array( 'fontSize' => 14, 'textTransform' => 'uppercase', 'fontWeight' => 600 ) ), 'readMoreColors' => array( 'type' => 'object', 'default' => array( 'color' => '#fff', 'bg' => '#8344c5' ) ), 'readMoreHovColors' => array( 'type' => 'object', 'default' => array( 'color' => '#fff', 'bg' => '#4527a4' ) ), 'readMorePadding' => array( 'type' => 'object', 'default' => array( 'vertical' => '12px', 'horizontal' => '35px' ) ), 'readMoreBorder' => array( 'type' => 'object', 'default' => array( 'radius' => '3px' ) ) ); } function render( $attributes ){ extract( $attributes ); // $taxonomies = get_object_taxonomies( $postType, 'array' ); // foreach( $taxonomies as $tax ){ // if( $tax->hierarchical ){ // $terms = get_terms( $tax->name, array( // 'orderby' => 'term_id', // 'order' => 'ASC', // 'hide_empty' => true, // ) ); // } // } // Generate Styles $postsStyles = new BBlocksStyleGenerator(); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost", array( 'margin-bottom' => 'masonry' === $layout ? $rowGap.'px' : '0px', $border['styles'] ?? 'border-radius: 5px;' => '' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPostDefault, #bBlocksPosts-$cId .bBlocksPostSideImage", array( 'text-align' => $contentAlign, $contentBG['styles'] ?? 'background-color: #f4f2fc;' => '' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostText", array( 'padding' => $contentPadding['styles'] ?? '20px 25px' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPostOverlay .bBlocksPostText", array( $contentBG['styles'] ?? 'background-color: #f4f2fc;' => '', 'align-items' => 'left' === $contentAlign ? 'flex-start' : ( 'right' === $contentAlign ? 'flex-end' : ( 'center' === $contentAlign ? 'center' : 'stretch' ) ) ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostTitle", array( 'text-align' => $contentAlign, $titleTypo['styles'] ?? 'font-size: 25px;' => '', 'color' => $titleColor, 'margin' => $titleMargin['styles'] ?? '0 0 15px 0' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostTitle a", array( 'color' => $titleColor ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostMeta", array( 'text-align' => $contentAlign, $metaTypo['styles'] ?? 'font-size: 13px; text-transform: uppercase;' => '', 'color' => $metaTextColor, 'margin' => $metaMargin['styles'] ?? '0 0 15px 0' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostMeta a", array( 'color' => $metaLinkColor ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostMeta .dashicons", array( 'color' => $metaIconColor ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostFImgCats", array( $metaTypo['styles'] ?? 'font-size: 13px; text-transform: uppercase;' => '' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostExcerpt", array( 'text-align' => $excerptAlign, $excerptTypo['styles'] ?? 'font-size: 15px;' => '', 'color' => $excerptColor, 'margin' => $excerptMargin['styles'] ?? '0 0 10px 0' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostReadMore", array( 'text-align' => $readMoreAlign ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostReadMore a", array( $readMoreTypo['styles'] ?? 'font-size: 14px; text-transform: uppercase; font-weight: 600;' => '', $readMoreColors['styles'] ?? 'color: #fff; background: #8344c5;' => '', 'padding' => $readMorePadding['styles'] ?? '12px 35px', $readMoreBorder['styles'] ?? 'border-radius: 3px;' => '' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksPost .bBlocksPostReadMore a:hover", array( $readMoreHovColors['styles'] ?? 'color: #fff; background: #4527a4;' => '' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksGridPosts", array( 'grid-gap' => $rowGap .'px '. $columnGap .'px', 'align-items' => false === $isContentEqualHight ? 'start' : 'initial' ) ); $postsStyles::addStyle( "#bBlocksPosts-$cId .bBlocksMasonryPosts", array( 'gap' => $columnGap . 'px' ) ); // All Posts $posts = get_posts( [ 'post_type' => $postType, 'category' => $selectedCategories, 'posts_per_page' => $isPostsPerPageAll ? -1 : $postsPerPage, 'orderby' => $postsOrderBy, 'order' => $postsOrder ] ); ob_start(); ?>