| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductDescription class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\Archive; |
| 9 |
|
| 10 |
use Elementor\Controls_Manager; |
| 11 |
use Elementor\Icons_Manager; |
| 12 |
use RadiusTheme\SB\Helpers\Fns; |
| 13 |
use RadiusTheme\SB\Abstracts\ElementorWidgetBase; |
| 14 |
use RadiusTheme\SB\Elementor\Widgets\Controls\ArchiveViewModeSettings; |
| 15 |
|
| 16 |
// Do not allow directly accessing this file. |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit( 'This script cannot be accessed directly.' ); |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
/** |
| 23 |
* Product Description class |
| 24 |
*/ |
| 25 |
class ArchiveProductMode extends ElementorWidgetBase { |
| 26 |
/** |
| 27 |
* Construct function |
| 28 |
* |
| 29 |
* @param array $data default array. |
| 30 |
* @param mixed $args default arg. |
| 31 |
*/ |
| 32 |
public function __construct( $data = [], $args = null ) { |
| 33 |
$this->rtsb_name = esc_html__( 'View Mode', 'shopbuilder' ); |
| 34 |
$this->rtsb_base = 'rtsb-archive-product-mode'; |
| 35 |
parent::__construct( $data, $args ); |
| 36 |
} |
| 37 |
/** |
| 38 |
* Keywords |
| 39 |
* |
| 40 |
* @return array |
| 41 |
*/ |
| 42 |
public function get_keywords() { |
| 43 |
return [ 'archive' ] + parent::get_keywords(); |
| 44 |
} |
| 45 |
/** |
| 46 |
* Widget Field |
| 47 |
* |
| 48 |
* @return array |
| 49 |
*/ |
| 50 |
public function widget_fields() { |
| 51 |
return ArchiveViewModeSettings::widget_fields( $this ); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Widget Field |
| 56 |
* |
| 57 |
* @param string $mode Mode. |
| 58 |
* |
| 59 |
* @return string |
| 60 |
*/ |
| 61 |
public function view_mode_url( $mode ) { |
| 62 |
global $wp; |
| 63 |
$url = home_url( |
| 64 |
add_query_arg( |
| 65 |
array_merge( $_GET, [ 'displayview' => $mode ] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 66 |
$wp->request |
| 67 |
) |
| 68 |
); |
| 69 |
return $url; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Render Function |
| 74 |
* |
| 75 |
* @return void |
| 76 |
*/ |
| 77 |
protected function render() { |
| 78 |
$controllers = $this->get_settings_for_display(); |
| 79 |
$this->theme_support(); |
| 80 |
|
| 81 |
$controllers['grid_icon'] = Fns::icons_manager( $controllers['mode_button_grid_icon'] ); |
| 82 |
$controllers['list_icon'] = Fns::icons_manager( $controllers['mode_button_list_icon'] ); |
| 83 |
|
| 84 |
$data = [ |
| 85 |
'template' => 'elementor/archive/view-mode', |
| 86 |
'grid' => $this->view_mode_url( 'grid' ), |
| 87 |
'list' => $this->view_mode_url( 'list' ), |
| 88 |
'controllers' => $controllers, |
| 89 |
]; |
| 90 |
Fns::load_template( $data['template'], $data ); |
| 91 |
$this->theme_support( 'render_reset' ); |
| 92 |
} |
| 93 |
|
| 94 |
} |
| 95 |
|