PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.20
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.20
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 / preview / class-spsp-preview.php

class-spsp-preview.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 2.4.20, at admin/preview/class-spsp-preview.php

85 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin preview.
4 *
5 * @link http://smartpostshow.com/
6 * @since 2.1.4
7 *
8 * @package Smart_Post_Show
9 * @subpackage Smart_Post_Show/admin
10 */
11
12 /**
13 * The admin preview.
14 *
15 * @package Smart_Post_Show
16 * @subpackage Smart_Post_Show/admin
17 * @author ShapedPlugin <[email protected]>
18 */
19 class Class_SPSPS_Preview {
20
21 /**
22 * Script and style suffix
23 *
24 * @since 2.1.4
25 * @access protected
26 * @var string
27 */
28 protected $suffix;
29
30 /**
31 * Initialize the class and set its properties.
32 *
33 * @since 2.1.4
34 */
35 public function __construct() {
36 $this->pcp_preview_action();
37 }
38
39 /**
40 * Public Action
41 *
42 * @return void
43 */
44 private function pcp_preview_action() {
45 // admin Preview.
46 add_action( 'wp_ajax_spf_preview_meta_box', array( $this, 'pcp_backend_preview' ) );
47 }
48
49 /**
50 * Function Backed preview.
51 *
52 * @since 2.2.5
53 */
54 public function pcp_backend_preview() {
55 $nonce = ! empty( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
56 if ( ! wp_verify_nonce( $nonce, 'spf_pcp_metabox_nonce' ) ) {
57 return false;
58 }
59 $capability = apply_filters( 'spf_chosen_ajax_capability', 'manage_options' );
60 if ( ! current_user_can( $capability ) ) {
61 return esc_html__( 'You do not have required permissions to access.', 'post-carousel' );
62 }
63 $settings = array();
64 $data = ! empty( $_POST['data'] ) ?
65 wp_unslash( $_POST['data'] ) // phpcs:ignore
66 : '';
67 parse_str( $data, $settings );
68 $settings = array_map( 'wp_kses_post_deep', $settings );
69 // Shortcode id.
70 $shortcode_id = $settings['post_ID'];
71 // Preset Layouts.
72 $layout = $settings['sp_pcp_layouts'];
73 // All the visible options for the Shortcode like – Global, Filter, Display, Popup, Typography etc.
74 $view_options = $settings['sp_pcp_view_options'];
75 $section_title = $settings['post_title'];
76 // Load dynamic style for the backend preview.
77 $dynamic_style = Smart_Post_Show_Public::load_dynamic_style( $shortcode_id, $view_options, $layout );
78 echo '<style id="sps_dynamic_css">' . $dynamic_style['dynamic_css'] . '</style>';
79
80 SP_PC_Output::pc_html_show( $view_options, $layout, $shortcode_id, $section_title );
81 die();
82 }
83 }
84 new Class_SPSPS_Preview();
85