golden hour
/home/godaofbq/dev.hyperredbed.com/wp-content/plugins/essential-blocks/includes/Blocks
⬆️ Go Up
Upload
File/Folder
Size
Actions
Accordion.php
1.01 KB
Del
OK
AccordionItem.php
335 B
Del
OK
AddToCart.php
3.43 KB
Del
OK
AdvancedHeading.php
4.59 KB
Del
OK
AdvancedImage.php
1.94 KB
Del
OK
AdvancedNavigation.php
703 B
Del
OK
AdvancedTabs.php
886 B
Del
OK
AdvancedVideo.php
1021 B
Del
OK
Breadcrumbs.php
11.35 KB
Del
OK
Button.php
351 B
Del
OK
CallToAction.php
365 B
Del
OK
Column.php
220 B
Del
OK
CountDown.php
605 B
Del
OK
DualButton.php
666 B
Del
OK
FeatureList.php
332 B
Del
OK
FlipBox.php
648 B
Del
OK
FluentForms.php
3.77 KB
Del
OK
Form.php
5.4 KB
Del
OK
FormTextField.php
246 B
Del
OK
GoogleMap.php
2.55 KB
Del
OK
Icon.php
323 B
Del
OK
ImageComparison.php
620 B
Del
OK
ImageGallery.php
2.26 KB
Del
OK
InfoBox.php
374 B
Del
OK
InstagramFeed.php
6.05 KB
Del
OK
InteractivePromo.php
321 B
Del
OK
NftGallery.php
649 B
Del
OK
Notice.php
580 B
Del
OK
NumberCounter.php
598 B
Del
OK
Openverse.php
480 B
Del
OK
ParallaxSlider.php
664 B
Del
OK
PopUp.php
625 B
Del
OK
PostBlock.php
1.57 KB
Del
OK
PostCarousel.php
4.42 KB
Del
OK
PostGrid.php
5.75 KB
Del
OK
PostMeta.php
3.51 KB
Del
OK
PricingTable.php
333 B
Del
OK
ProductDetails.php
3.51 KB
Del
OK
ProductImages.php
2.8 KB
Del
OK
ProductPrice.php
4.75 KB
Del
OK
ProductRating.php
2.97 KB
Del
OK
ProgressBar.php
604 B
Del
OK
Row.php
455 B
Del
OK
ShapeDivider.php
602 B
Del
OK
Slider.php
996 B
Del
OK
Social.php
352 B
Del
OK
SocialShare.php
3.89 KB
Del
OK
Tab.php
214 B
Del
OK
TableOfContents.php
17.3 KB
Del
OK
Taxonomy.php
4.9 KB
Del
OK
TeamMember.php
361 B
Del
OK
Testimonial.php
373 B
Del
OK
Text.php
2.48 KB
Del
OK
ToggleContent.php
613 B
Del
OK
TypingText.php
594 B
Del
OK
WPForms.php
2.92 KB
Del
OK
WooProductGrid.php
8.3 KB
Del
OK
Wrapper.php
359 B
Del
OK
price.php
239 B
Del
OK
Edit: WooProductGrid.php
<?php namespace EssentialBlocks\Blocks; use WP_Query; use EssentialBlocks\Core\Block; use EssentialBlocks\API\Product; use EssentialBlocks\Utils\Helper; class WooProductGrid extends Block { protected $frontend_scripts = [ 'essential-blocks-woo-product-grid-frontend' ]; protected $frontend_styles = [ 'essential-blocks-fontawesome' ]; /** * Unique name of the block. * * @return string */ public function get_name() { return 'woo-product-grid'; } /** * Register all other scripts * * @return void */ public function register_scripts() { $this->assets_manager->register( 'woo-product-grid-frontend', $this->path() . '/frontend.js' ); } public function get_array_column( $data, $handle ) { $_no_error = true; if ( ! is_array( $data ) ) { $data = json_decode( $data, true ); $_no_error = json_last_error() === JSON_ERROR_NONE; } return $_no_error ? array_column( $data, $handle ) : $data; } /** * Render Callback * * @param mixed $attributes * @param mixed $content * @return void|string */ private $sampleData = [ ]; public function render_callback( $attributes, $content ) { if ( ! function_exists( '\WC' ) || is_admin() ) { return; } $_essential_attributes = [ 'layout' => 'grid', 'gridPreset' => 'grid-preset-1', 'listPreset' => 'list-preset-1', 'saleBadgeAlign' => 'align-left', 'saleText' => 'sale', 'showRating' => true, 'ratingStyle' => 'star', 'showSoldCount' => false, 'showSoldCountBar' => false, "soldCountPrefix" => __( "Sold ", "essential-blocks" ), "soldCountSuffix" => "+", "stockPercent" => 50, "showTaxonomyFilter" => false, "selectedTaxonomy" => "", "selectedTaxonomyItems" => '[{"value":"all","label":"All"}]', 'showPrice' => true, 'showSaleBadge' => true, 'productDescLength' => 5, 'isCustomCartBtn' => false, 'simpleCartText' => __( "Buy Now", "essential-blocks" ), 'variableCartText' => __( "Select Options", "essential-blocks" ), 'groupedCartText' => __( "View Products", "essential-blocks" ), 'externalCartText' => __( "Buy Now", "essential-blocks" ), 'defaultCartText' => __( "Read More", "essential-blocks" ), 'showDetailBtn' => true, 'detailBtnText' => isset( $attributes[ 'detailBtnText' ] ) ? $attributes[ 'detailBtnText' ] : __( "Visit Product", "essential-blocks" ) ]; foreach ( $_essential_attributes as $key => $value ) { if ( isset( $attributes[ $key ] ) && is_bool( $attributes[ $key ] ) ) { $_essential_attributes[ $key ] = $attributes[ $key ]; } elseif ( ! empty( $attributes[ $key ] ) ) { $_essential_attributes[ $key ] = $attributes[ $key ]; } else { $_essential_attributes[ $key ] = $value; } } if ( isset( $_essential_attributes[ 'showBlockContent' ] ) && $_essential_attributes[ 'showBlockContent' ] === false ) { return; } $args = isset( $attributes[ 'queryData' ] ) ? $attributes[ 'queryData' ] : [ ]; $query_type = isset( $args[ 'query_type' ] ) ? $args[ 'query_type' ] : 'custom_query'; $_normalize = [ 'orderby' => 'date', 'order' => 'desc', 'category' => [ ], 'tag' => [ ], 'include' => [ ], 'exclude' => [ ], 'excludeCategory' => [ ], 'excludeTag' => [ ] ]; // var_dump($args); foreach ( $_normalize as $key => $value ) { $args[ $key ] = ! empty( $args[ $key ] ) ? implode( ',', $this->get_array_column( $args[ $key ], 'value' ) ) : $value; } // Set Orderby to Default if Pro Orderby is selected and Pro isn't active $proOrderby = [ 'rand' ]; if ( isset( $args[ 'orderby' ] ) && ! ESSENTIAL_BLOCKS_IS_PRO_ACTIVE && in_array( $args[ 'orderby' ], $proOrderby ) ) { $args[ 'orderby' ] = 'date'; } $args = wp_parse_args( $args, [ 'per_page' => 10, 'offset' => 0 ] ); if ( "related_products" === $query_type ) { $product = json_decode( $args[ "product" ], true ); $product_id = isset( $product[ "value" ] ) && "current" !== $product[ "value" ] ? $product[ "value" ] : get_the_ID(); $per_page = $args[ 'per_page' ]; $exclude_products = isset( $args[ 'exclude_products' ] ) ? Helper::get_value_from_json_array( json_decode( $args[ 'exclude_products' ], true ) ) : [ ]; $related_products = wc_get_related_products( $product_id, $args[ 'per_page' ], $exclude_products ); unset( $args ); $args[ 'post__in' ] = is_array( $related_products ) && count( $related_products ) > 0 ? $related_products : [ ]; $args[ 'per_page' ] = $per_page; } $isCustomCartBtn = $_essential_attributes[ 'isCustomCartBtn' ]; $simpleCartText = $_essential_attributes[ 'simpleCartText' ]; $variableCartText = $_essential_attributes[ 'variableCartText' ]; $groupedCartText = $_essential_attributes[ 'groupedCartText' ]; $externalCartText = $_essential_attributes[ 'externalCartText' ]; $defaultCartText = $_essential_attributes[ 'defaultCartText' ]; $this->sampleData = [ $simpleCartText, $variableCartText, $groupedCartText, $externalCartText, $defaultCartText ]; if ( $isCustomCartBtn ) { // change the cart button text according to editor change add_filter( 'woocommerce_product_add_to_cart_text', [ $this, 'eb_change_cart_button_text' ], 10, 1 ); } $query = new WP_Query( Product::query_builder( $args ) ); $blockId = isset( $attributes[ 'blockId' ] ) ? $attributes[ 'blockId' ] : ''; $classHook = isset( $attributes[ 'classHook' ] ) ? $attributes[ 'classHook' ] : ''; //Handle loadMoreOptions $loadMoreOptions = [ ]; if ( isset( $attributes[ 'loadMoreOptions' ] ) ) { $loadMoreOptions = $attributes[ 'loadMoreOptions' ]; $loadMoreOptions[ 'totalPosts' ] = $query->found_posts ?? 0; } $_essential_attributes[ 'loadMoreOptions' ] = $loadMoreOptions; ob_start(); Helper::views( 'product-grid', array_merge( $_essential_attributes, [ 'blockId' => $blockId, 'classHook' => $classHook, 'query' => isset( $query ) ? $query : '', 'essentialAttr' => $_essential_attributes, 'loadMoreOptions' => $loadMoreOptions, 'queryData' => $args ] ) ); if ( $isCustomCartBtn ) { // remove our own callback from filter remove_filter( 'woocommerce_product_add_to_cart_text', [ $this, 'eb_change_cart_button_text' ], 10 ); } return ob_get_clean(); } public function eb_change_cart_button_text( $text ) { global $product; list( $simpleCartText, $variableCartText, $groupedCartText, $externalCartText, $defaultCartText ) = $this->sampleData; $product_type = $product->get_type(); $product_types = [ 'external' => $externalCartText, 'grouped' => $groupedCartText, 'simple' => $simpleCartText, 'variable' => $variableCartText ]; return isset( $product_types[ $product_type ] ) ? esc_html( $product_types[ $product_type ] ) : esc_html( $defaultCartText ); } }
Save