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_Deprecated / Shortcode_Widget_Deprecated.php

Shortcode_Widget_Deprecated.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.4, at admin/ElementAddons_Deprecated/Shortcode_Widget_Deprecated.php

170 lines 4.1 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_Deprecated 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_free_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 Deprecated', '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-icon-3';
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( 'deprecated' );
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_free_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->add_control(
120 'deprecated_notice',
121 array(
122 'type' => \Elementor\Controls_Manager::DEPRECATED_NOTICE,
123 'widget' => 'Smart Post Show Deprecated',
124 'since' => '2.4.13',
125 'last' => '2.6.0',
126 'plugin' => 'Smart Post Show',
127 'replacement' => 'Smart Post Show',
128 'content_classes' => 'sp-post-carousel-elementor-widget-deprecated',
129 )
130 );
131
132 $this->end_controls_section();
133 }
134
135 /**
136 * Render smart post show free shortcode widget output on the frontend.
137 *
138 * @since 2.4.1
139 * @access protected
140 */
141 protected function render() {
142
143 $settings = $this->get_settings_for_display();
144 $sp_pcp_shortcode = $settings['sp_smart_post_show_free_shortcode'];
145
146 if ( '' === $sp_pcp_shortcode ) {
147 echo '<div style="text-align: center; margin-top: 0; padding: 10px" class="elementor-add-section-drag-title">Select a shortcode</div>';
148 return;
149 }
150
151 $generator_id = $sp_pcp_shortcode;
152
153 if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
154 $shortcode_id = esc_attr( $generator_id ); // Smart Post Show global ID for Shortcode metaboxes.
155
156 // Preset Layouts.
157 $layout = get_post_meta( $shortcode_id, 'sp_pcp_layouts', true );
158 // All the visible options for the Shortcode like – Global, Filter, Display, Popup, Typography etc.
159 $view_options = get_post_meta( $shortcode_id, 'sp_pcp_view_options', true );
160 $section_title = get_the_title( $shortcode_id );
161 // Load dynamic style for the backend preview.
162 $dynamic_style = Smart_Post_Show_Public::load_dynamic_style( $shortcode_id, $view_options, $layout );
163 echo '<style id="sps_dynamic_' . esc_attr( $shortcode_id ) . '">' . $dynamic_style['dynamic_css'] . '</style>'; // phpcs:ignore
164 SP_PC_Output::pc_html_show( $view_options, $layout, $shortcode_id, $section_title );
165 } else {
166 echo do_shortcode( '[smart_post_show id="' . $generator_id . '"]' );
167 }
168 }
169 }
170