PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.22
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.22
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / ElementAddons / Shortcode_Widget.php

Shortcode_Widget.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 2.4.22, at admin/ElementAddons/Shortcode_Widget.php

159 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The plugin elementor addons Initializer.
4 *
5 * @link https://shapedplugin.com/
6 * @since 2.4.2
7 *
8 * @package Smart_Post_Show
9 * @subpackage Smart_Post_Show/Admin
10 * @author ShapedPlugin <support@shapedplugin.com>
11 */
12
13 /**
14 * Elementor smart post show free shortcode Widget.
15 *
16 * @since 2.4.1
17 */
18 class Shortcode_Widget extends \Elementor\Widget_Base {
19 /**
20 * Get widget name.
21 *
22 * @since 2.4.1
23 * @access public
24 *
25 * @return string Widget name.
26 */
27 public function get_name() {
28 return 'smart_post_show_pro_shortcode';
29 }
30
31 /**
32 * Get widget title.
33 *
34 * @since 2.4.1
35 * @access public
36 *
37 * @return string Widget title.
38 */
39 public function get_title() {
40 return __( 'Smart Post Show', 'post-carousel' );
41 }
42
43 /**
44 * Get widget icon.
45 *
46 * @since 2.2.5
47 * @access public
48 *
49 * @return string Widget icon.
50 */
51 public function get_icon() {
52 return 'sps-icon-icon';
53 }
54
55 /**
56 * Get widget categories.
57 *
58 * @since 2.2.5
59 * @access public
60 *
61 * @return array Widget categories.
62 */
63 public function get_categories() {
64 return array( 'basic' );
65 }
66
67 /**
68 * Get all post list.
69 *
70 * @since 2.2.5
71 * @return array
72 */
73 public function sp_pcp_post_list() {
74 $post_list = array();
75 $sp_pcp_posts = new \WP_Query(
76 array(
77 'post_type' => 'sp_post_carousel',
78 'post_status' => 'publish',
79 'posts_per_page' => 10000,
80 )
81 );
82 $posts = $sp_pcp_posts->posts;
83 foreach ( $posts as $post ) {
84 $post_list[ $post->ID ] = $post->post_title;
85 }
86 krsort( $post_list );
87 return $post_list;
88 }
89
90 /**
91 * Controls register.
92 *
93 * @return void
94 */
95 protected function register_controls() {
96 $this->start_controls_section(
97 'content_section',
98 array(
99 'label' => __( 'Content', 'post-carousel' ),
100 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
101 )
102 );
103
104 $this->add_control(
105 'sp_smart_post_show_pro_shortcode',
106 array(
107 'label' => __( 'Smart Post Show Shortcode(s)', 'post-carousel' ),
108 'type' => \Elementor\Controls_Manager::SELECT2,
109 'label_block' => true,
110 'default' => '',
111 'options' => $this->sp_pcp_post_list(),
112 )
113 );
114
115 $this->end_controls_section();
116
117 }
118
119 /**
120 * Render smart post show free shortcode widget output on the frontend.
121 *
122 * @since 2.4.1
123 * @access protected
124 */
125 protected function render() {
126
127 $settings = $this->get_settings_for_display();
128 $sp_pcp_shortcode = $settings['sp_smart_post_show_pro_shortcode'];
129
130 if ( '' === $sp_pcp_shortcode ) {
131 echo '<div style="text-align: center; margin-top: 0; padding: 10px" class="elementor-add-section-drag-title">Select a shortcode</div>';
132 return;
133 }
134
135 $generator_id = $sp_pcp_shortcode;
136
137 if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
138 $shortcode_id = $generator_id; // Smart Post Show global ID for Shortcode metaboxes.
139 // Preset Layouts.
140 $layout = get_post_meta( $shortcode_id, 'sp_pcp_layouts', true );
141 // All the visible options for the Shortcode like – Global, Filter, Display, Popup, Typography etc.
142 $view_options = get_post_meta( $shortcode_id, 'sp_pcp_view_options', true );
143 $section_title = get_the_title( $shortcode_id );
144 // Load dynamic style for the backend preview.
145 $dynamic_style = Smart_Post_Show_Public::load_dynamic_style( $shortcode_id, $view_options, $layout );
146 echo '<style id="sps_dynamic_style' . esc_attr( $shortcode_id ) . '">' . $dynamic_style['dynamic_css'] . '</style>';
147 // Markup of the plugin.
148 SP_PC_Output::pc_html_show( $view_options, $layout, $shortcode_id, $section_title );
149 ?>
150 <script src="<?php echo esc_url( SP_PC_URL . 'public/assets/js/scripts.min.js' ); ?>" ></script>
151 <?php
152 } else {
153 echo do_shortcode( '[smart_post_show id="' . $generator_id . '"]' );
154 }
155
156 }
157
158 }
159