PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.7
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.7
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 4.0.7, at admin/preview/class-spsp-preview.php

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