get_icon(); $added_button_icon = $this->get_icon('added_'); if( !empty( $button_text ) ){ $button_text = ''.$button_text.''; } if( !empty( $button_added_text ) ){ $button_added_text = ''.$button_added_text.''; } // Shortcode atts $default_atts = array( 'product_id' => $product->get_id(), 'button_url' => Manage_Compare::instance()->get_compare_page_url(), 'button_class' => implode(' ', $button_class ), 'button_text' => $button_icon.$button_text, 'button_added_text' => $added_button_icon.$button_added_text, 'template_name' => 'add', ); $atts = shortcode_atts( $default_atts, $atts, $content ); return Manage_Compare::instance()->button_html( $atts ); } /** * [table_shortcode] Compare table shortcode callable function * @param [type] $atts * @param string $content * @return [HTML] */ public function table_shortcode( $atts, $content = '' ){ wp_enqueue_style( 'evercompare-frontend' ); wp_enqueue_script( 'evercompare-frontend' ); /* Fetch From option data */ $empty_compare_text = ever_compare_get_option('empty_table_text','ever_compare_table_settings_tabs'); $return_shop_button = ever_compare_get_option('shop_button_text','ever_compare_table_settings_tabs','Return to shop'); /* Product and Field */ $products = Manage_Compare::instance()->get_compared_products_data(); $fields = Manage_Compare::instance()->get_compare_fields(); $custom_heading = !empty( ever_compare_get_option( 'table_heading', 'ever_compare_table_settings_tabs' ) ) ? ever_compare_get_option( 'table_heading', 'ever_compare_table_settings_tabs' ) : array(); $default_atts = array( 'evercompare' => Manage_Compare::instance(), 'products' => $products, 'fields' => $fields, 'return_shop_button'=> $return_shop_button, 'heading_txt' => $custom_heading, 'empty_compare_text'=> $empty_compare_text, ); $atts = shortcode_atts( $default_atts, $atts, $content ); return Manage_Compare::instance()->table_html( $atts ); } /** * [get_icon] * @param string $type * @return [HTML] */ public function get_icon( $type = '' ){ $arrContextOptions = [ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, ] ]; $default_icon = file_get_contents( EVERCOMPARE_ASSETS .'/images/icon.svg', false, stream_context_create($arrContextOptions) ); $default_loader = ''.file_get_contents( EVERCOMPARE_ASSETS .'/images/loading.svg', false, stream_context_create($arrContextOptions) ).''; $button_text = ( $type === 'added' ) ? ever_compare_get_option( 'added_button_text','ever_compare_settings_tabs', 'Added' ) : ever_compare_get_option( 'button_text','ever_compare_settings_tabs', 'Compare' ); $button_icon_type = ever_compare_get_option( $type.'button_icon_type', 'ever_compare_settings_tabs', 'default' ); if( $button_icon_type === 'custom' ){ $button_icon = ever_compare_get_option( $type.'button_custom_icon','ever_compare_settings_tabs', '' ); }elseif( $button_icon_type === 'default' ){ return $default_icon; }else{ $button_icon = ''; } if( !empty( $button_icon ) ){ $button_icon = ''.esc_attr( $button_text ).''; } return $default_loader.$button_icon; } }