get_post_attributes(); register_block_type( 'uagb/post-grid', array( 'attributes' => array_merge( $common_attributes, array( 'blockName' => array( 'type' => 'string', 'default' => 'post-grid', ), 'equalHeight' => array( 'type' => 'boolean', 'default' => true, ), 'postPagination' => array( 'type' => 'boolean', 'default' => false, ), 'pageLimit' => array( 'type' => 'number', 'default' => 10, ), 'paginationBgActiveColor' => array( 'type' => 'string', 'default' => '#e4e4e4', ), 'paginationActiveColor' => array( 'type' => 'string', 'default' => '#333333', ), 'paginationBgColor' => array( 'type' => 'string', 'default' => '#e4e4e4', ), 'paginationColor' => array( 'type' => 'string', 'default' => '#777777', ), 'paginationMarkup' => array( 'type' => 'string', 'default' => '', ), 'paginationLayout' => array( 'type' => 'string', 'default' => 'filled', ), 'paginationBorderActiveColor' => array( 'type' => 'string', ), 'paginationBorderColor' => array( 'type' => 'string', 'default' => '#888686', ), 'paginationBorderRadius' => array( 'type' => 'number', ), 'paginationBorderSize' => array( 'type' => 'number', 'default' => 1, ), 'paginationSpacing' => array( 'type' => 'number', 'default' => 20, ), 'paginationAlignment' => array( 'type' => 'string', 'default' => 'left', ), 'paginationPrevText' => array( 'type' => 'string', 'default' => '« Previous', ), 'paginationNextText' => array( 'type' => 'string', 'default' => 'Next »', ), 'layoutConfig' => array( 'type' => 'array', 'default' => array( array( 'uagb/post-image' ), array( 'uagb/post-taxonomy' ), array( 'uagb/post-title' ), array( 'uagb/post-meta' ), array( 'uagb/post-excerpt' ), array( 'uagb/post-button' ), ), ), 'post_type' => array( 'type' => 'string', 'default' => 'grid', ), 'equalHeightInlineButtons' => array( 'type' => 'boolean', 'default' => false, ), 'imageRatio' => array( 'type' => 'string', 'default' => 'inherit', ), 'imgEqualHeight' => array( 'type' => 'boolean', 'default' => false, ), 'paginationType' => array( 'type' => 'string', 'default' => 'ajax', ), ) ), 'render_callback' => array( $this, 'post_grid_callback' ), ) ); register_block_type( 'uagb/post-carousel', array( 'attributes' => array_merge( $common_attributes, array( 'blockName' => array( 'type' => 'string', 'default' => 'post-carousel', ), 'pauseOnHover' => array( 'type' => 'boolean', 'default' => true, ), 'infiniteLoop' => array( 'type' => 'boolean', 'default' => true, ), 'transitionSpeed' => array( 'type' => 'number', 'default' => 500, ), 'arrowDots' => array( 'type' => 'string', 'default' => 'arrows_dots', ), 'autoplay' => array( 'type' => 'boolean', 'default' => true, ), 'autoplaySpeed' => array( 'type' => 'number', 'default' => 2000, ), 'arrowSize' => array( 'type' => 'number', 'default' => 24, ), 'arrowBorderSize' => array( 'type' => 'number', 'default' => 0, ), 'arrowBorderRadius' => array( 'type' => 'number', 'default' => 0, ), 'arrowColor' => array( 'type' => 'string', 'default' => '#000', ), 'arrowDistance' => array( 'type' => 'number', ), 'arrowDistanceTablet' => array( 'type' => 'number', ), 'arrowDistanceMobile' => array( 'type' => 'number', ), 'equalHeight' => array( 'type' => 'boolean', 'default' => false, ), 'layoutConfig' => array( 'type' => 'array', 'default' => array( array( 'uagb/post-image' ), array( 'uagb/post-taxonomy' ), array( 'uagb/post-title' ), array( 'uagb/post-meta' ), array( 'uagb/post-excerpt' ), array( 'uagb/post-button' ), ), ), 'post_type' => array( 'type' => 'string', 'default' => 'carousel', ), 'dotsMarginTop' => array( 'type' => 'number', 'default' => '20', ), 'dotsMarginTopTablet' => array( 'type' => 'number', 'default' => '20', ), 'dotsMarginTopMobile' => array( 'type' => 'number', 'default' => '20', ), 'dotsMarginTopUnit' => array( 'type' => 'string', 'default' => 'px', ), ) ), 'render_callback' => array( $this, 'post_carousel_callback' ), ) ); $enable_legacy_blocks = UAGB_Admin_Helper::get_admin_settings_option( 'uag_enable_legacy_blocks', ( 'yes' === get_option( 'uagb-old-user-less-than-2' ) ) ? 'yes' : 'no' ); if ( 'yes' === get_option( 'uagb-old-user-less-than-2' ) || 'yes' === $enable_legacy_blocks ) { register_block_type( 'uagb/post-masonry', array( 'attributes' => array_merge( $common_attributes, array( 'blockName' => array( 'type' => 'string', 'default' => 'post-masonry', ), 'paginationType' => array( 'type' => 'string', 'default' => 'none', ), 'paginationEventType' => array( 'type' => 'string', 'default' => 'button', ), 'buttonText' => array( 'type' => 'string', 'default' => 'Load More', ), 'paginationAlign' => array( 'type' => 'string', 'default' => 'center', ), 'paginationTextColor' => array( 'type' => 'string', 'default' => '', ), 'paginationMasonryBgColor' => array( 'type' => 'string', 'default' => '', ), 'paginationBgHoverColor' => array( 'type' => 'string', ), 'paginationTextHoverColor' => array( 'type' => 'string', ), 'paginationMasonryBorderHColor' => array( 'type' => 'string', 'default' => '', ), 'paginationFontSize' => array( 'type' => 'number', 'default' => 13, ), 'loaderColor' => array( 'type' => 'string', 'default' => '#0085ba', ), 'loaderSize' => array( 'type' => 'number', 'default' => 18, ), 'paginationButtonPaddingType' => array( 'type' => 'string', 'default' => 'px', ), 'vpaginationButtonPaddingMobile' => array( 'type' => 'number', 'default' => 8, ), 'vpaginationButtonPaddingTablet' => array( 'type' => 'number', 'default' => 8, ), 'vpaginationButtonPaddingDesktop' => array( 'type' => 'number', 'default' => 8, ), 'hpaginationButtonPaddingMobile' => array( 'type' => 'number', 'default' => 12, ), 'hpaginationButtonPaddingTablet' => array( 'type' => 'number', 'default' => 12, ), 'hpaginationButtonPaddingDesktop' => array( 'type' => 'number', 'default' => 12, ), 'layoutConfig' => array( 'type' => 'array', 'default' => array( array( 'uagb/post-image' ), array( 'uagb/post-taxonomy' ), array( 'uagb/post-title' ), array( 'uagb/post-meta' ), array( 'uagb/post-excerpt' ), array( 'uagb/post-button' ), ), ), 'post_type' => array( 'type' => 'string', 'default' => 'masonry', ), 'mobilepaginationButtonPaddingType' => array( 'type' => 'string', 'default' => 'px', ), 'tabletpaginationButtonPaddingType' => array( 'type' => 'string', 'default' => 'px', ), ), $pagination_masonry_border_attribute ), 'render_callback' => array( $this, 'post_masonry_callback' ), ) ); } } /** * Get Post common attributes for all Post Grid, Masonry and Carousel. * * @since 0.0.1 */ public function get_post_attributes() { $btn_border_attribute = array(); $overall_border_attribute = array(); if ( method_exists( 'UAGB_Block_Helper', 'uag_generate_php_border_attribute' ) ) { $btn_border_attribute = UAGB_Block_Helper::uag_generate_php_border_attribute( 'btn' ); $overall_border_attribute = UAGB_Block_Helper::uag_generate_php_border_attribute( 'overall' ); } return array_merge( $btn_border_attribute, $overall_border_attribute, array( 'inheritFromTheme' => array( 'type' => 'boolean', 'default' => true, ), 'block_id' => array( 'type' => 'string', 'default' => 'not_set', ), 'categories' => array( 'type' => 'string', ), 'postType' => array( 'type' => 'string', 'default' => 'post', ), 'postDisplaytext' => array( 'type' => 'string', 'default' => 'No post found!', ), 'taxonomyType' => array( 'type' => 'string', 'default' => 'category', ), 'postsToShow' => array( 'type' => 'number', 'default' => 6, ), 'enableOffset' => array( 'type' => 'boolean', 'default' => false, ), 'postsOffset' => array( 'type' => 'number', 'default' => 0, ), 'displayPostDate' => array( 'type' => 'boolean', 'default' => true, ), 'displayPostExcerpt' => array( 'type' => 'boolean', 'default' => true, ), 'excerptLength' => array( 'type' => 'number', 'default' => 15, ), 'displayPostAuthor' => array( 'type' => 'boolean', 'default' => false, ), 'displayPostTitle' => array( 'type' => 'boolean', 'default' => true, ), 'displayPostComment' => array( 'type' => 'boolean', 'default' => true, ), 'displayPostTaxonomy' => array( 'type' => 'boolean', 'default' => false, ), 'hideTaxonomyIcon' => array( 'type' => 'boolean', 'default' => true, ), 'taxStyle' => array( 'type' => 'string', 'default' => 'default', ), 'displayPostTaxonomyAboveTitle' => array( 'type' => 'string', 'default' => 'withMeta', ), 'displayPostImage' => array( 'type' => 'boolean', 'default' => true, ), 'imgSize' => array( 'type' => 'string', 'default' => 'large', ), 'imgPosition' => array( 'type' => 'string', 'default' => 'top', ), 'linkBox' => array( 'type' => 'boolean', ), 'bgOverlayColor' => array( 'type' => 'string', 'default' => '#000000', ), 'overlayOpacity' => array( 'type' => 'number', 'default' => '50', ), 'displayPostLink' => array( 'type' => 'boolean', 'default' => true, ), 'newTab' => array( 'type' => 'boolean', 'default' => false, ), 'ctaText' => array( 'type' => 'string', 'default' => __( 'Read More', 'ultimate-addons-for-gutenberg' ), ), 'btnHPadding' => array( 'type' => 'number', 'default' => '', ), 'btnVPadding' => array( 'type' => 'number', 'default' => '', ), 'columns' => array( 'type' => 'number', 'default' => 3, ), 'tcolumns' => array( 'type' => 'number', 'default' => 2, ), 'mcolumns' => array( 'type' => 'number', 'default' => 1, ), 'align' => array( 'type' => 'string', 'default' => 'left', ), 'width' => array( 'type' => 'string', 'default' => 'wide', ), 'order' => array( 'type' => 'string', 'default' => 'desc', ), 'orderBy' => array( 'type' => 'string', 'default' => 'date', ), 'rowGap' => array( 'type' => 'number', 'default' => 20, ), 'rowGapTablet' => array( 'type' => 'number', 'default' => 20, ), 'rowGapMobile' => array( 'type' => 'number', 'default' => 20, ), 'columnGap' => array( 'type' => 'number', 'default' => 20, ), 'columnGapTablet' => array( 'type' => 'number', ), 'columnGapMobile' => array( 'type' => 'number', ), 'bgType' => array( 'type' => 'string', 'default' => 'color', ), 'bgColor' => array( 'type' => 'string', 'default' => '#f6f6f6', ), // Title Attributes. 'titleColor' => array( 'type' => 'string', ), 'titleTag' => array( 'type' => 'string', 'default' => 'h4', ), 'titleFontSize' => array( 'type' => 'number', 'default' => '', ), 'titleFontSizeType' => array( 'type' => 'string', 'default' => 'px', ), 'titleFontSizeMobile' => array( 'type' => 'number', ), 'titleFontSizeTablet' => array( 'type' => 'number', ), 'titleFontFamily' => array( 'type' => 'string', 'default' => '', ), 'titleFontWeight' => array( 'type' => 'string', ), 'titleFontStyle' => array( 'type' => 'string', ), 'titleLineHeightType' => array( 'type' => 'string', 'default' => 'em', ), 'titleLineHeight' => array( 'type' => 'number', ), 'titleLineHeightTablet' => array( 'type' => 'number', ), 'titleLineHeightMobile' => array( 'type' => 'number', ), 'titleLoadGoogleFonts' => array( 'type' => 'boolean', 'default' => false, ), // Meta attributes. 'metaColor' => array( 'type' => 'string', 'default' => '', ), 'highlightedTextColor' => array( 'type' => 'string', 'default' => '#fff', ), 'highlightedTextBgColor' => array( 'type' => 'string', 'default' => '#3182ce', ), 'metaFontSize' => array( 'type' => 'number', 'default' => '', ), 'metaFontSizeType' => array( 'type' => 'string', 'default' => 'px', ), 'metaFontSizeMobile' => array( 'type' => 'number', ), 'metaFontSizeTablet' => array( 'type' => 'number', ), 'metaFontFamily' => array( 'type' => 'string', 'default' => '', ), 'metaFontWeight' => array( 'type' => 'string', ), 'metaFontStyle' => array( 'type' => 'string', ), 'metaLineHeightType' => array( 'type' => 'string', 'default' => 'em', ), 'metaLineHeight' => array( 'type' => 'number', ), 'metaLineHeightTablet' => array( 'type' => 'number', ), 'metaLineHeightMobile' => array( 'type' => 'number', ), 'metaLoadGoogleFonts' => array( 'type' => 'boolean', 'default' => false, ), // Excerpt Attributes. 'excerptColor' => array( 'type' => 'string', 'default' => '', ), 'excerptFontSize' => array( 'type' => 'number', 'default' => '', ), 'excerptFontSizeType' => array( 'type' => 'string', 'default' => 'px', ), 'excerptFontSizeMobile' => array( 'type' => 'number', ), 'excerptFontSizeTablet' => array( 'type' => 'number', ), 'excerptFontFamily' => array( 'type' => 'string', 'default' => '', ), 'excerptFontWeight' => array( 'type' => 'string', ), 'excerptFontStyle' => array( 'type' => 'string', ), 'excerptLineHeightType' => array( 'type' => 'string', 'default' => 'em', ), 'excerptLineHeight' => array( 'type' => 'number', ), 'excerptLineHeightTablet' => array( 'type' => 'number', ), 'excerptLineHeightMobile' => array( 'type' => 'number', ), 'excerptLoadGoogleFonts' => array( 'type' => 'boolean', 'default' => false, ), 'displayPostContentRadio' => array( 'type' => 'string', 'default' => 'excerpt', ), // CTA attributes. 'ctaColor' => array( 'type' => 'string', ), 'ctaBgType' => array( 'type' => 'string', 'default' => 'color', ), 'ctaBgHType' => array( 'type' => 'string', 'default' => 'color', ), 'ctaBgColor' => array( 'type' => 'string', ), 'ctaHColor' => array( 'type' => 'string', ), 'ctaBgHColor' => array( 'type' => 'string', ), 'ctaFontSize' => array( 'type' => 'number', 'default' => '', ), 'ctaFontSizeType' => array( 'type' => 'string', 'default' => 'px', ), 'ctaFontSizeMobile' => array( 'type' => 'number', ), 'ctaFontSizeTablet' => array( 'type' => 'number', ), 'ctaFontFamily' => array( 'type' => 'string', 'default' => '', ), 'ctaFontWeight' => array( 'type' => 'string', ), 'ctaFontStyle' => array( 'type' => 'string', ), 'ctaLineHeightType' => array( 'type' => 'string', 'default' => 'em', ), 'ctaLineHeight' => array( 'type' => 'number', ), 'ctaLineHeightTablet' => array( 'type' => 'number', ), 'ctaLineHeightMobile' => array( 'type' => 'number', ), 'ctaLoadGoogleFonts' => array( 'type' => 'boolean', 'default' => false, ), // Spacing Attributes. 'paddingTop' => array( 'type' => 'number', 'default' => 20, ), 'paddingBottom' => array( 'type' => 'number', 'default' => 20, ), 'paddingRight' => array( 'type' => 'number', 'default' => 20, ), 'paddingLeft' => array( 'type' => 'number', 'default' => 20, ), 'paddingTopMobile' => array( 'type' => 'number', ), 'paddingBottomMobile' => array( 'type' => 'number', ), 'paddingRightMobile' => array( 'type' => 'number', ), 'paddingLeftMobile' => array( 'type' => 'number', ), 'paddingTopTablet' => array( 'type' => 'number', ), 'paddingBottomTablet' => array( 'type' => 'number', ), 'paddingRightTablet' => array( 'type' => 'number', ), 'paddingLeftTablet' => array( 'type' => 'number', ), 'paddingBtnTop' => array( 'type' => 'number', ), 'paddingBtnBottom' => array( 'type' => 'number', ), 'paddingBtnRight' => array( 'type' => 'number', ), 'paddingBtnLeft' => array( 'type' => 'number', ), 'contentPadding' => array( 'type' => 'number', 'default' => 20, ), 'contentPaddingMobile' => array( 'type' => 'number', ), 'ctaBottomSpace' => array( 'type' => 'number', 'default' => 0, ), 'ctaBottomSpaceTablet' => array( 'type' => 'number', 'default' => 0, ), 'ctaBottomSpaceMobile' => array( 'type' => 'number', 'default' => 0, ), 'imageBottomSpace' => array( 'type' => 'number', 'default' => 15, ), 'imageBottomSpaceTablet' => array( 'type' => 'number', ), 'imageBottomSpaceMobiile' => array( 'type' => 'number', ), 'titleBottomSpace' => array( 'type' => 'number', 'default' => 15, ), 'titleBottomSpaceTablet' => array( 'type' => 'number', ), 'titleBottomSpaceMobile' => array( 'type' => 'number', ), 'metaBottomSpace' => array( 'type' => 'number', 'default' => 15, ), 'metaBottomSpaceTablet' => array( 'type' => 'number', ), 'metaBottomSpaceMobile' => array( 'type' => 'number', ), 'excerptBottomSpace' => array( 'type' => 'number', 'default' => 25, ), 'excerptBottomSpaceTablet' => array( 'type' => 'number', ), 'excerptBottomSpaceMobile' => array( 'type' => 'number', ), // Exclude Current Post. 'excludeCurrentPost' => array( 'type' => 'boolean', 'default' => false, ), 'titleTransform' => array( 'type' => 'string', ), 'metaTransform' => array( 'type' => 'string', ), 'excerptTransform' => array( 'type' => 'string', ), 'ctaTransform' => array( 'type' => 'string', ), 'titleDecoration' => array( 'type' => 'string', ), 'metaDecoration' => array( 'type' => 'string', ), 'excerptDecoration' => array( 'type' => 'string', ), 'ctaDecoration' => array( 'type' => 'string', ), 'contentPaddingUnit' => array( 'type' => 'string', 'default' => 'px', ), 'rowGapUnit' => array( 'type' => 'string', 'default' => 'px', ), 'columnGapUnit' => array( 'type' => 'string', 'default' => 'px', ), 'excerptBottomSpaceUnit' => array( 'type' => 'string', 'default' => 'px', ), 'paginationSpacingUnit' => array( 'type' => 'string', 'default' => 'px', ), 'imageBottomSpaceUnit' => array( 'type' => 'string', 'default' => 'px', ), 'titleBottomSpaceUnit' => array( 'type' => 'string', 'default' => 'px', ), 'metaBottomSpaceUnit' => array( 'type' => 'string', 'default' => 'px', ), 'ctaBottomSpaceUnit' => array( 'type' => 'string', 'default' => 'px', ), 'paddingBtnUnit' => array( 'type' => 'string', 'default' => 'px', ), 'mobilePaddingBtnUnit' => array( 'type' => 'string', 'default' => 'px', ), 'tabletPaddingBtnUnit' => array( 'type' => 'string', 'default' => 'px', ), 'paddingUnit' => array( 'type' => 'string', 'default' => 'px', ), 'mobilePaddingUnit' => array( 'type' => 'string', 'default' => 'px', ), 'tabletPaddingUnit' => array( 'type' => 'string', 'default' => 'px', ), 'isPreview' => array( 'type' => 'boolean', 'default' => false, ), 'taxDivider' => array( 'type' => 'string', 'default' => ', ', ), 'titleLetterSpacing' => array( 'type' => 'number', 'default' => '', ), 'titleLetterSpacingType' => array( 'type' => 'string', 'default' => 'px', ), 'titleLetterSpacingMobile' => array( 'type' => 'number', ), 'titleLetterSpacingTablet' => array( 'type' => 'number', ), 'metaLetterSpacing' => array( 'type' => 'number', 'default' => '', ), 'metaLetterSpacingType' => array( 'type' => 'string', 'default' => 'px', ), 'metaLetterSpacingMobile' => array( 'type' => 'number', ), 'metaLetterSpacingTablet' => array( 'type' => 'number', ), 'ctaLetterSpacing' => array( 'type' => 'number', 'default' => '', ), 'ctaLetterSpacingType' => array( 'type' => 'string', 'default' => 'px', ), 'ctaLetterSpacingMobile' => array( 'type' => 'number', ), 'ctaLetterSpacingTablet' => array( 'type' => 'number', ), 'excerptLetterSpacing' => array( 'type' => 'number', 'default' => '', ), 'excerptLetterSpacingType' => array( 'type' => 'string', 'default' => 'px', ), 'excerptLetterSpacingMobile' => array( 'type' => 'number', ), 'excerptLetterSpacingTablet' => array( 'type' => 'number', ), 'useSeparateBoxShadows' => array( 'type' => 'boolean', 'default' => true, ), 'boxShadowColor' => array( 'type' => 'string', 'default' => '#00000070', ), 'boxShadowHOffset' => array( 'type' => 'number', 'default' => 0, ), 'boxShadowVOffset' => array( 'type' => 'number', 'default' => 0, ), 'boxShadowBlur' => array( 'type' => 'number', 'default' => '', ), 'boxShadowSpread' => array( 'type' => 'number', 'default' => '', ), 'boxShadowPosition' => array( 'type' => 'string', 'default' => 'outset', ), 'boxShadowColorHover' => array( 'type' => 'string', 'default' => '', ), 'boxShadowHOffsetHover' => array( 'type' => 'number', 'default' => 0, ), 'boxShadowVOffsetHover' => array( 'type' => 'number', 'default' => 0, ), 'boxShadowBlurHover' => array( 'type' => 'number', 'default' => '', ), 'boxShadowSpreadHover' => array( 'type' => 'number', 'default' => '', ), 'boxShadowPositionHover' => array( 'type' => 'string', 'default' => 'outset', ), 'overallBorderHColor' => array( 'type' => 'string', ), 'borderWidth' => array( 'type' => 'number', 'default' => '', ), 'borderStyle' => array( 'type' => 'string', 'default' => 'none', ), 'borderColor' => array( 'type' => 'string', 'default' => '', ), 'borderHColor' => array( 'type' => 'string', ), 'borderRadius' => array( 'type' => 'number', 'default' => '', ), ) ); } /** * Renders the post grid block on server. * * @param array $attributes Array of block attributes. * * @since 0.0.1 */ public function post_grid_callback( $attributes ) { // Render query. $query = UAGB_Helper::get_query( $attributes, 'grid' ); // Cache the settings. self::$settings['grid'][ $attributes['block_id'] ] = $attributes; ob_start(); $this->get_post_html( $attributes, $query, 'grid' ); // Output the post markup. return ob_get_clean(); } /** * Renders the post grid block on pagination clicks. * * @since 2.6.0 * * @return void */ public function post_grid_pagination_ajax_callback() { check_ajax_referer( 'uagb_grid_ajax_nonce', 'nonce' ); if ( isset( $_POST['attr'] ) ) { $attr = json_decode( stripslashes( sanitize_text_field( $_POST['attr'] ) ), true ); $attr['paged'] = isset( $_POST['page_number'] ) ? sanitize_text_field( $_POST['page_number'] ) : ''; $html = $this->post_grid_callback( $attr ); wp_send_json_success( $html ); } wp_send_json_error( ' Something went wrong, failed to load pagination data! ' ); } /** * Renders the post carousel block on server. * * @param array $attributes Array of block attributes. * * @since 0.0.1 */ public function post_carousel_callback( $attributes ) { // Render query. $query = UAGB_Helper::get_query( $attributes, 'carousel' ); // Cache the settings. self::$settings['carousel'][ $attributes['block_id'] ] = $attributes; ob_start(); $this->get_post_html( $attributes, $query, 'carousel' ); // Output the post markup. return ob_get_clean(); } /** * Renders the post masonry block on server. * * @param array $attributes Array of block attributes. * * @since 0.0.1 */ public function post_masonry_callback( $attributes ) { // Render query. $query = UAGB_Helper::get_query( $attributes, 'masonry' ); // Cache the settings. self::$settings['masonry'][ $attributes['block_id'] ] = $attributes; ob_start(); $this->get_post_html( $attributes, $query, 'masonry' ); // Output the post markup. return ob_get_clean(); } /** * Renders the post grid block on server. * * @param array $attributes Array of block attributes. * * @param object $query WP_Query object. * @param string $layout post grid/masonry/carousel layout. * @since 0.0.1 */ public function get_post_html( $attributes, $query, $layout ) { // Common Post Attributes. $attributes['post_type'] = $layout; $attributes['postsToShow'] = UAGB_Block_Helper::get_fallback_number( $attributes['postsToShow'], 'postsToShow', $attributes['blockName'] ); $attributes['postsOffset'] = UAGB_Block_Helper::get_fallback_number( $attributes['postsOffset'], 'postsOffset', $attributes['blockName'] ); $attributes['columns'] = UAGB_Block_Helper::get_fallback_number( $attributes['columns'], 'columns', $attributes['blockName'] ); $attributes['tcolumns'] = UAGB_Block_Helper::get_fallback_number( $attributes['tcolumns'], 'columns', $attributes['blockName'] ); $attributes['mcolumns'] = UAGB_Block_Helper::get_fallback_number( $attributes['mcolumns'], 'mcolumns', $attributes['blockName'] ); $attributes['excerptLength'] = UAGB_Block_Helper::get_fallback_number( $attributes['excerptLength'], 'excerptLength', $attributes['blockName'] ); $attributes['overlayOpacity'] = UAGB_Block_Helper::get_fallback_number( $attributes['overlayOpacity'], 'overlayOpacity', $attributes['blockName'] ); $attributes['columnGap'] = UAGB_Block_Helper::get_fallback_number( $attributes['columnGap'], 'columnGap', $attributes['blockName'] ); $attributes['rowGap'] = UAGB_Block_Helper::get_fallback_number( $attributes['rowGap'], 'rowGap', $attributes['blockName'] ); $attributes['imageBottomSpace'] = UAGB_Block_Helper::get_fallback_number( $attributes['imageBottomSpace'], 'imageBottomSpace', $attributes['blockName'] ); $attributes['titleBottomSpace'] = UAGB_Block_Helper::get_fallback_number( $attributes['titleBottomSpace'], 'titleBottomSpace', $attributes['blockName'] ); $attributes['metaBottomSpace'] = UAGB_Block_Helper::get_fallback_number( $attributes['metaBottomSpace'], 'metaBottomSpace', $attributes['blockName'] ); $attributes['excerptBottomSpace'] = UAGB_Block_Helper::get_fallback_number( $attributes['excerptBottomSpace'], 'excerptBottomSpace', $attributes['blockName'] ); $attributes['ctaBottomSpace'] = UAGB_Block_Helper::get_fallback_number( $attributes['ctaBottomSpace'], 'ctaBottomSpace', $attributes['blockName'] ); // Unique Responsive Attributes. $attributes['rowGapTablet'] = is_numeric( $attributes['rowGapTablet'] ) ? $attributes['rowGapTablet'] : $attributes['rowGap']; $attributes['rowGapMobile'] = is_numeric( $attributes['rowGapMobile'] ) ? $attributes['rowGapMobile'] : $attributes['rowGapTablet']; // Grid / Carousel / Masonry Specific Attributes. if ( isset( $attributes['autoplaySpeed'] ) ) { $attributes['autoplaySpeed'] = UAGB_Block_Helper::get_fallback_number( $attributes['autoplaySpeed'], 'autoplaySpeed', $attributes['blockName'] ); } if ( isset( $attributes['transitionSpeed'] ) ) { $attributes['transitionSpeed'] = UAGB_Block_Helper::get_fallback_number( $attributes['transitionSpeed'], 'transitionSpeed', $attributes['blockName'] ); } if ( isset( $attributes['arrowSize'] ) ) { $attributes['arrowSize'] = UAGB_Block_Helper::get_fallback_number( $attributes['arrowSize'], 'arrowSize', $attributes['blockName'] ); } if ( isset( $attributes['arrowDistance'] ) ) { $attributes['arrowDistance'] = UAGB_Block_Helper::get_fallback_number( $attributes['arrowDistance'], 'arrowDistance', $attributes['blockName'] ); } if ( isset( $attributes['arrowDistanceTablet'] ) ) { $attributes['arrowDistanceTablet'] = UAGB_Block_Helper::get_fallback_number( $attributes['arrowDistanceTablet'], 'arrowDistanceTablet', $attributes['blockName'] ); } if ( isset( $attributes['arrowDistanceMobile'] ) ) { $attributes['arrowDistanceMobile'] = UAGB_Block_Helper::get_fallback_number( $attributes['arrowDistanceMobile'], 'arrowDistanceMobile', $attributes['blockName'] ); } if ( isset( $attributes['arrowBorderSize'] ) ) { $attributes['arrowBorderSize'] = UAGB_Block_Helper::get_fallback_number( $attributes['arrowBorderSize'], 'arrowBorderSize', $attributes['blockName'] ); } if ( isset( $attributes['paginationSpacing'] ) ) { $attributes['paginationSpacing'] = UAGB_Block_Helper::get_fallback_number( $attributes['paginationSpacing'], 'paginationSpacing', $attributes['blockName'] ); } if ( isset( $attributes['paginationBorderRadius'] ) ) { $attributes['paginationBorderRadius'] = UAGB_Block_Helper::get_fallback_number( $attributes['paginationBorderRadius'], 'paginationBorderRadius', $attributes['blockName'] ); } if ( isset( $attributes['paginationBorderSize'] ) ) { $attributes['paginationBorderSize'] = UAGB_Block_Helper::get_fallback_number( $attributes['paginationBorderSize'], 'paginationBorderSize', $attributes['blockName'] ); } if ( isset( $attributes['paginationFontSize'] ) ) { $attributes['paginationFontSize'] = UAGB_Block_Helper::get_fallback_number( $attributes['paginationFontSize'], 'paginationFontSize', $attributes['blockName'] ); } if ( isset( $attributes['loaderSize'] ) ) { $attributes['loaderSize'] = UAGB_Block_Helper::get_fallback_number( $attributes['loaderSize'], 'loaderSize', $attributes['blockName'] ); } $wrap = array( 'uagb-post__items uagb-post__columns-' . $attributes['columns'], 'is-' . $layout, 'uagb-post__columns-tablet-' . $attributes['tcolumns'], 'uagb-post__columns-mobile-' . $attributes['mcolumns'], ); $block_id = 'uagb-block-' . $attributes['block_id']; $desktop_class = ''; $tab_class = ''; $mob_class = ''; if ( array_key_exists( 'UAGHideDesktop', $attributes ) || array_key_exists( 'UAGHideTab', $attributes ) || array_key_exists( 'UAGHideMob', $attributes ) ) { $desktop_class = ( isset( $attributes['UAGHideDesktop'] ) ) ? 'uag-hide-desktop' : ''; $tab_class = ( isset( $attributes['UAGHideTab'] ) ) ? 'uag-hide-tab' : ''; $mob_class = ( isset( $attributes['UAGHideMob'] ) ) ? 'uag-hide-mob' : ''; } $zindex_desktop = ''; $zindex_tablet = ''; $zindex_mobile = ''; $zindex_wrap = array(); $zindex_extention_enabled = ( isset( $attributes['zIndex'] ) || isset( $attributes['zIndexTablet'] ) || isset( $attributes['zIndexMobile'] ) ); if ( $zindex_extention_enabled ) { $zindex_desktop = ( isset( $attributes['zIndex'] ) ) ? '--z-index-desktop:' . $attributes['zIndex'] . ';' : false; $zindex_tablet = ( isset( $attributes['zIndexTablet'] ) ) ? '--z-index-tablet:' . $attributes['zIndexTablet'] . ';' : false; $zindex_mobile = ( isset( $attributes['zIndexMobile'] ) ) ? '--z-index-mobile:' . $attributes['zIndexMobile'] . ';' : false; if ( $zindex_desktop ) { array_push( $zindex_wrap, $zindex_desktop ); } if ( $zindex_tablet ) { array_push( $zindex_wrap, $zindex_tablet ); } if ( $zindex_mobile ) { array_push( $zindex_wrap, $zindex_mobile ); } } $is_image_enabled = ( true === $attributes['displayPostImage'] ) ? 'uagb-post__image-enabled' : 'uagb-post__image-disabled'; $outerwrap = array( 'wp-block-uagb-post-' . $layout, 'uagb-post-grid', ( isset( $attributes['className'] ) ) ? $attributes['className'] : '', 'uagb-post__image-position-' . $attributes['imgPosition'], $is_image_enabled, $block_id, $desktop_class, $tab_class, $mob_class, $zindex_extention_enabled ? 'uag-blocks-common-selector' : '', ); switch ( $layout ) { case 'masonry': break; case 'grid': if ( $attributes['equalHeight'] ) { array_push( $wrap, 'uagb-post__equal-height' ); } if ( $attributes['equalHeightInlineButtons'] ) { array_push( $wrap, 'uagb-equal_height_inline-read-more-buttons' ); } break; case 'carousel': array_push( $outerwrap, 'uagb-post__arrow-outside' ); if ( $attributes['equalHeight'] ) { array_push( $wrap, 'uagb-post__carousel_equal-height' ); } if ( $query->post_count > $attributes['columns'] ) { array_push( $outerwrap, 'uagb-slick-carousel' ); } break; default: // Nothing to do here. break; } $common_classes = array_merge( $outerwrap, $wrap ); $total = $query->max_num_pages; ?>