'', 'margin_right' => '', 'margin_bottom' => '', 'margin_left' => '', // Heading. 'show_tab_title' => 'yes', 'title_size' => 'h2', // Borders. 'border_size' => '', 'border_color' => '', // Text styling. 'text_color' => '', 'fusion_font_family_text_font' => '', 'fusion_font_variant_text_font' => '', 'text_font_size' => '', 'text_text_transform' => '', 'text_line_height' => '', 'text_letter_spacing' => '', 'stars_color' => '', 'rating_box_bg_color' => '', 'rating_box_active_bg_color' => '', // Button styles. 'button_style' => '', 'button_size' => '', 'button_stretch' => 'no', 'button_border_top' => '', 'button_border_right' => '', 'button_border_bottom' => '', 'button_border_left' => '', 'button_color' => '', 'button_gradient_top' => $fusion_settings->get( 'button_gradient_top_color' ), 'button_gradient_bottom' => $fusion_settings->get( 'button_gradient_bottom_color' ), 'button_border_color' => $fusion_settings->get( 'button_gradient_top_color_hover' ), 'button_color_hover' => $fusion_settings->get( 'button_gradient_bottom_color_hover' ), 'button_gradient_top_hover' => '', 'button_gradient_bottom_hover' => '', 'button_border_color_hover' => '', 'hide_on_mobile' => fusion_builder_default_visibility( 'string' ), 'class' => '', 'id' => '', 'animation_type' => '', 'animation_direction' => 'down', 'animation_speed' => '0.1', 'animation_delay' => '', 'animation_offset' => $fusion_settings->get( 'animation_offset' ), 'animation_color' => '', ]; } /** * Render for live editor. * * @static * @access public * @since 3.2 * @param array $defaults An array of defaults. * @return void */ public function ajax_render( $defaults ) { global $product, $post, $withcomments; check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' ); $live_request = false; // From Ajax Request. if ( isset( $_POST['model'] ) && isset( $_POST['model']['params'] ) && ! apply_filters( 'fusion_builder_live_request', false ) ) { // phpcs:ignore WordPress.Security.NonceVerification $defaults = $_POST['model']['params']; // phpcs:ignore WordPress.Security $return_data = []; $live_request = true; fusion_set_live_data(); add_filter( 'fusion_builder_live_request', '__return_true' ); } if ( class_exists( 'Fusion_App' ) && $live_request ) { $post_id = isset( $_POST['post_id'] ) ? $_POST['post_id'] : get_the_ID(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput if ( ( ! $post_id || -99 === $post_id ) || ( isset( $_POST['post_id'] ) && 'fusion_tb_section' === get_post_type( $_POST['post_id'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput echo wp_json_encode( [] ); wp_die(); } $this->emulate_product(); if ( ! $this->is_product() ) { echo wp_json_encode( $return_data ); wp_die(); } // Needed in order to bypass early exit in comments_template function. $withcomments = true; // We need to set global $post because Woo template expects it. $post = get_post( $product->get_id() ); $return_data['woo_reviews'] = $this->get_woo_reviews_content( $defaults, $post_id ); $this->restore_product(); // Restore global $post. $post = null; } echo wp_json_encode( $return_data ); wp_die(); } /** * Render the shortcode * * @access public * @since 3.2 * @param array $args Shortcode parameters. * @param string $content Content between shortcode. * @return string HTML output. */ public function render( $args, $content = '' ) { $this->params = $args; $this->defaults = self::get_element_defaults(); $this->args = FusionBuilder::set_shortcode_defaults( $this->defaults, $args, 'fusion_tb_woo_reviews' ); $this->emulate_product(); if ( ! $this->is_product() ) { return; } // Legacy single border width. if ( isset( $args['button_border_width'] ) && ! isset( $args['button_border_top'] ) ) { $this->args['button_border_top'] = $args['button_border_width']; $this->args['button_border_right'] = $this->args['button_border_top']; $this->args['button_border_bottom'] = $this->args['button_border_top']; $this->args['button_border_left'] = $this->args['button_border_top']; } $html = '
' . $this->get_woo_reviews_content( $this->args ) . '
'; $this->restore_product(); $this->counter++; // Remove inline script if in Live Editor. if ( function_exists( 'fusion_is_preview_frame' ) && fusion_is_preview_frame() ) { $html = str_replace( [ '' ], [ '' ], $html ); } $this->on_render(); return apply_filters( 'fusion_component_' . $this->shortcode_handle, $html, $args ); } /** * Builds HTML for Woo Rating element. * * @static * @access public * @since 3.2 * @param array $args The arguments. * @return string */ public function get_woo_reviews_content( $args ) { global $woocommerce, $product; $content = ''; if ( is_object( $product ) ) { ob_start(); comments_template(); $content = ob_get_clean(); } if ( 'yes' === $args['show_tab_title'] && ! $this->is_default( 'title_size' ) ) { $opening_tag = '<' . $this->args['title_size'] . ' class="woocommerce-Reviews-title'; $closing_tag = 'args['title_size'] . '>'; $count = 1; $content = str_replace( [ '