PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.41
Post Grid Gutenberg Blocks – PostX v5.0.41
5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 All 238 releases
ultimate-post / addons / wpbakery / wpbakery.php

wpbakery.php in Post Grid Gutenberg Blocks – PostX 5.0.41, at addons/wpbakery/wpbakery.php

78 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 if ( ! class_exists( 'PostX_WPBakery_Widget' ) ) {
4
5 class PostX_WPBakery_Widget {
6
7 /**
8 * Main constructor
9 */
10 public function __construct() {
11 add_shortcode( 'postx_wpbakery_widget', __CLASS__ . '::output' );
12 if ( function_exists( 'vc_lean_map' ) ) {
13 vc_lean_map( 'postx_wpbakery_widget', __CLASS__ . '::map' );
14 }
15 }
16
17 /**
18 * Shortcode output
19 */
20 public static function output( $atts, $content = null ) {
21 $output = '';
22 $atts = vc_map_get_attributes( 'postx_wpbakery_widget', $atts );
23 $templates = $atts['saved_template'];
24
25 if ( $templates && $templates != 'empty' ) {
26 if (isset($_GET['vc_editable'])) { // @codingStandardsIgnoreLine
27 $output .= ultimate_post()->build_css_for_inline_print( $templates, true );
28 }
29
30 $args = array(
31 'p' => $templates,
32 'post_type' => 'ultp_templates',
33 );
34 $the_query = new \WP_Query( $args );
35
36 if ( $the_query->have_posts() ) {
37 while ( $the_query->have_posts() ) {
38 $the_query->the_post();
39 ob_start();
40 the_content();
41 $output .= ob_get_clean();
42 }
43 wp_reset_postdata();
44 }
45 } elseif ( isset( $_GET['vc_editable'] ) ) {
46 // @codingStandardsIgnoreLine
47 $output .= '<p style="text-align:center;">' . sprintf( esc_html__( 'Pick a Template from your saved ones. Or create a template from: %s.', 'ultimate-post' ) . ' ', '<strong><i>' . esc_html__( 'Dashboard > PostX > Saved Templates', 'ultimate-post' ) . '</i></strong>' ) . '</p>';
48 }
49
50 return $output;
51 }
52
53
54
55
56 public static function map() {
57 return array(
58 'name' => esc_html__( 'PostX Template', 'ultimate-post' ),
59 'description' => esc_html__( 'PostX Templates for WPBakery.', 'ultimate-post' ),
60 'base' => 'postx_wpbakery_widget',
61 'icon' => ULTP_URL . '/addons/wpbakery/wpbakery.png',
62 'params' => array(
63 array(
64 'type' => 'dropdown',
65 'heading' => esc_html__( 'Select Your Template', 'ultimate-post' ),
66 'param_name' => 'saved_template',
67 'value' => array_flip( ultimate_post()->get_all_lists( 'ultp_templates', 'empty' ) ),
68 'description' => esc_html__( 'Pick a Template from your saved ones. Or create a template from: "Dashboard > PostX > Saved Templates"', 'ultimate-post' ),
69 ),
70 ),
71 );
72 }
73 }
74
75 }
76
77 new PostX_WPBakery_Widget();
78