| 1 |
<?php |
| 2 |
/** |
| 3 |
* AdvancedHeading class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\General\PostGrid; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
use RadiusTheme\SB\Abstracts\ElementorWidgetBase; |
| 12 |
|
| 13 |
// Do not allow directly accessing this file. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit( 'This script cannot be accessed directly.' ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Dropcaps class. |
| 20 |
* |
| 21 |
* @package RadiusTheme\SB |
| 22 |
*/ |
| 23 |
class PostGrid extends ElementorWidgetBase { |
| 24 |
/** |
| 25 |
* Construct function |
| 26 |
* |
| 27 |
* @param array $data default array. |
| 28 |
* @param mixed $args default arg. |
| 29 |
*/ |
| 30 |
public function __construct( $data = [], $args = null ) { |
| 31 |
$this->rtsb_name = esc_html__( 'Post Grid', 'shopbuilder' ); |
| 32 |
$this->rtsb_base = 'rtsb-post-grid'; |
| 33 |
|
| 34 |
parent::__construct( $data, $args ); |
| 35 |
|
| 36 |
$this->rtsb_category = 'rtsb-shopbuilder-general'; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Widget Field |
| 41 |
* |
| 42 |
* @return array |
| 43 |
*/ |
| 44 |
public function widget_fields() { |
| 45 |
return array_merge( |
| 46 |
Controls::content( $this ), |
| 47 |
Controls::style( $this ) |
| 48 |
); |
| 49 |
} |
| 50 |
/** |
| 51 |
* Style dependencies. |
| 52 |
* |
| 53 |
* @return array |
| 54 |
*/ |
| 55 |
public function get_style_depends(): array { |
| 56 |
if ( ! $this->is_edit_mode() ) { |
| 57 |
return [ |
| 58 |
'rtsb-general-addons', |
| 59 |
]; |
| 60 |
} |
| 61 |
|
| 62 |
return [ |
| 63 |
'rtsb-general-addons', |
| 64 |
'elementor-icons-shared-0', |
| 65 |
'elementor-icons-fa-solid', |
| 66 |
]; |
| 67 |
} |
| 68 |
/** |
| 69 |
* Set Widget Keyword. |
| 70 |
* |
| 71 |
* @return array |
| 72 |
*/ |
| 73 |
public function get_keywords() { |
| 74 |
return [ 'Post Grid','Blog Post','Post' ] + parent::get_keywords(); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
/** |
| 80 |
* Addon Render. |
| 81 |
* |
| 82 |
* @return void |
| 83 |
*/ |
| 84 |
protected function render() { |
| 85 |
$settings = $this->get_settings_for_display(); |
| 86 |
switch ( $settings['layout_style'] ) { |
| 87 |
case 'rtsb-post-grid-layout3': |
| 88 |
$template = 'layout3'; |
| 89 |
break; |
| 90 |
case 'rtsb-post-grid-layout2': |
| 91 |
$template = 'layout2'; |
| 92 |
break; |
| 93 |
default: |
| 94 |
$template = 'layout1'; |
| 95 |
break; |
| 96 |
} |
| 97 |
$template = apply_filters( 'rtsb/general_widget/post_grid/template', $template, $settings ); |
| 98 |
$data = [ |
| 99 |
'template' => 'elementor/general/post-grid/' . $template, |
| 100 |
'id' => $this->get_id(), |
| 101 |
'unique_name' => $this->get_unique_name(), |
| 102 |
'layout' => $settings['layout_style'], |
| 103 |
'settings' => $settings, |
| 104 |
'is_carousel' => false, |
| 105 |
'is_post_query' => true, |
| 106 |
'is_grid' => true, |
| 107 |
'is_post_pagination' => ! empty( $settings['show_pagination'] ), |
| 108 |
'container_class' => 'rtsb-blog-post', |
| 109 |
'content_class' => 'rtsb-post-grid', |
| 110 |
]; |
| 111 |
|
| 112 |
// Render initialization. |
| 113 |
$this->theme_support(); |
| 114 |
|
| 115 |
// Call the template rendering method. |
| 116 |
Fns::print_html( ( new Render() )->display_content( $data, $settings ), true ); |
| 117 |
$this->edit_mode_script(); |
| 118 |
$this->theme_support( 'render_reset' ); |
| 119 |
} |
| 120 |
} |
| 121 |
|