| @@ -6,8 +6,9 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace RadiusTheme\SB\Controllers; |
| 9 | 9 | |
| 10 | +use Elementor\Plugin; | |
| 10 | 11 | use RadiusTheme\SB\Helpers\Fns; |
| 11 | 12 | use RadiusTheme\SB\Helpers\BuilderFns; |
| 12 | 13 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 13 | 14 | use RadiusTheme\SB\Controllers\Builder\BuilderCpt; |
| @@ -25,13 +26,8 @@ | ||
| 25 | 26 | * Builder Controller |
| 26 | 27 | */ |
| 27 | 28 | class BuilderController { |
| 28 | 29 | /** |
| 29 | - * @var array | |
| 30 | - */ | |
| 31 | - private static $cache = []; | |
| 32 | - | |
| 33 | - /** | |
| 34 | 30 | * Builder page id. |
| 35 | 31 | * |
| 36 | 32 | * @var integer |
| 37 | 33 | */ |
| @@ -61,14 +57,11 @@ | ||
| 61 | 57 | } |
| 62 | 58 | |
| 63 | 59 | BuilderCpt::instance(); |
| 64 | 60 | |
| 65 | - $this->elementor_init(); | |
| 66 | - $this->both_builder_frontend(); | |
| 67 | - | |
| 68 | - // add_action( 'elementor/init', [ $this, 'elementor_init' ] ); | |
| 61 | + add_action( 'elementor/init', [ $this, 'elementor_init' ] ); | |
| 69 | 62 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_scripts' ] ); |
| 70 | - // add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 ); | |
| 63 | + add_action( 'template_redirect', [ $this, 'both_builder_frontend' ], 99 ); | |
| 71 | 64 | |
| 72 | 65 | // RT Select2 Ajax. |
| 73 | 66 | add_action( 'wp_ajax_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); |
| 74 | 67 | add_action( 'wp_ajax_nopriv_rt_select2_object_search', [ $this, 'select2_ajax_posts_filter_autocomplete' ] ); |
| @@ -156,11 +149,16 @@ | ||
| 156 | 149 | * |
| 157 | 150 | * @since 1.0.0 |
| 158 | 151 | */ |
| 159 | 152 | public function init_widgets( $widgets_manager ) { |
| 153 | + $product = Fns::get_product(); | |
| 160 | 154 | |
| 161 | - $get_list = ElementList::instance()->get_list( true, 'active' ); | |
| 162 | - foreach ( $get_list as $element ) { | |
| 155 | + // TODO: Need to remove below condition and make compitability in each widgets. | |
| 156 | + if ( ! $product ) { | |
| 157 | + return; | |
| 158 | + } | |
| 159 | + | |
| 160 | + foreach ( ElementList::instance()->get_list( true, 'active' ) as $element ) { | |
| 163 | 161 | if ( isset( $element['active'] ) && 'on' !== $element['active'] ) { |
| 164 | 162 | continue; |
| 165 | 163 | } |
| 166 | 164 | |
| @@ -222,10 +220,23 @@ | ||
| 222 | 220 | * |
| 223 | 221 | * @return array |
| 224 | 222 | */ |
| 225 | 223 | public function rtsb_icons( $tabs = [] ) { |
| 226 | - $custom_icons = $this->get_icons(); | |
| 224 | + $fonts = rtsb()->get_assets_uri( 'fonts/rtsb-icons.json' ); | |
| 227 | 225 | |
| 226 | + $response = wp_remote_get( $fonts ); | |
| 227 | + | |
| 228 | + if ( is_wp_error( $response ) ) { | |
| 229 | + return $tabs; | |
| 230 | + } | |
| 231 | + | |
| 232 | + $icons_json = wp_remote_retrieve_body( $response ); | |
| 233 | + $custom_icons = json_decode( $icons_json, true ); | |
| 234 | + | |
| 235 | + if ( null === $custom_icons ) { | |
| 236 | + return $tabs; | |
| 237 | + } | |
| 238 | + | |
| 228 | 239 | $tabs['shopbuilder-icons'] = [ |
| 229 | 240 | 'name' => 'rtsb-fonts', |
| 230 | 241 | 'label' => esc_html__( 'ShopBuilder Icons', 'shopbuilder' ), |
| 231 | 242 | 'labelIcon' => 'fab fa-elementor', |
| @@ -568,49 +579,6 @@ | ||
| 568 | 579 | } |
| 569 | 580 | } |
| 570 | 581 | |
| 571 | 582 | return $config; |
| 572 | - } | |
| 573 | - | |
| 574 | - /** | |
| 575 | - * Get Icons. | |
| 576 | - * | |
| 577 | - * @return array | |
| 578 | - */ | |
| 579 | - public function get_icons() { | |
| 580 | - return [ | |
| 581 | - 'heart-empty', | |
| 582 | - 'heart', | |
| 583 | - 'eye', | |
| 584 | - 'exchange', | |
| 585 | - 'plus', | |
| 586 | - 'minus', | |
| 587 | - 'avatar', | |
| 588 | - 'pay', | |
| 589 | - 'share', | |
| 590 | - 'clock', | |
| 591 | - 'check-alt', | |
| 592 | - 'check', | |
| 593 | - 'delete', | |
| 594 | - 'marker', | |
| 595 | - 'list', | |
| 596 | - 'list-2', | |
| 597 | - 'power', | |
| 598 | - 'cart', | |
| 599 | - 'cart-2', | |
| 600 | - 'cart-3', | |
| 601 | - 'downloads', | |
| 602 | - 'zoom', | |
| 603 | - 'user-edit', | |
| 604 | - 'grid', | |
| 605 | - 'filter', | |
| 606 | - 'billing', | |
| 607 | - 'login', | |
| 608 | - 'payment', | |
| 609 | - 'search', | |
| 610 | - 'edit', | |
| 611 | - 'coupon', | |
| 612 | - 'arrows-cw', | |
| 613 | - 'trash-empty', | |
| 614 | - ]; | |
| 615 | 583 | } |
| 616 | 584 | } |