PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.4
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.4
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 4.0.4, at admin/ElementAddons/Shortcode_Widget.php

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