PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.1
Post Grid Gutenberg Blocks – PostX v5.1.1
5.1.1 5.1.0 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 All 240 releases
ultimate-post / addons / elementor / Elementor_Widget.php

Elementor_Widget.php in Post Grid Gutenberg Blocks – PostX 5.1.1, at addons/elementor/Elementor_Widget.php

84 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || exit;
3
4 class ULTP_Elementor_Post_Blocks_Widget extends \Elementor\Widget_Base {
5
6 public function get_name() {
7 return 'gutenberg-post-blocks';
8 }
9
10 public function get_title() {
11 return __( 'PostX Template', 'ultimate-post' );
12 }
13
14 public function get_icon() {
15 return 'eicon-posts-grid';
16 }
17
18 public function get_categories() {
19 return array( 'general' );
20 }
21
22 protected function register_controls() {
23 $this->start_controls_section(
24 'content_section',
25 array(
26 'label' => __( 'Settings', 'ultimate-post' ),
27 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
28 )
29 );
30 $this->add_control(
31 'saved_template',
32 array(
33 'label' => __( 'Saved Template', 'ultimate-post' ),
34 'type' => \Elementor\Controls_Manager::SELECT,
35 'options' => ultimate_post()->get_all_lists( 'ultp_templates' ),
36 )
37 );
38 $this->add_control(
39 'edit_template',
40 array(
41 'type' => \Elementor\Controls_Manager::RAW_HTML,
42 'raw' => '<a href="' . admin_url( 'edit.php?post_type=ultp_templates' ) . '" style="color:#fff; background-color:#0c0d0e; padding:10px 20px; border-radius:4px; display:inline-block;" target="_blank"><span style="color:#fff; font-size:12px; width:12px; height:12px;" class="dashicons dashicons-edit"></span> ' . __( 'Edit This Template', 'ultimate-post' ) . '</a>',
43 )
44 );
45 $this->add_control(
46 'add_new_template',
47 array(
48 'type' => \Elementor\Controls_Manager::RAW_HTML,
49 'raw' => '<a href="' . admin_url( 'post-new.php?post_type=ultp_templates' ) . '" style="color:#fff; background-color:#0c0d0e; padding:10px 20px; border-radius:4px; display:inline-block;" target="_blank"><span style="color:#fff; font-size:12px; width:12px; height:12px;" class="dashicons dashicons-plus-alt2"></span> ' . __( 'Add New Template', 'ultimate-post' ) . '</a>',
50 )
51 );
52 $this->end_controls_section();
53 }
54
55
56 protected function render() {
57 $settings = $this->get_settings_for_display();
58 $id = $settings['saved_template'];
59
60 if ( $id ) {
61 if ( isset( $_GET['action'] ) || isset( $_POST['action'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended
62 echo ultimate_post()->build_css_for_inline_print( $id, true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- <style> tag from build_css_for_inline_print(): integer post ID, CSS passed through wp_strip_all_tags().
63 }
64 echo '<div class="ultp-shortcode" data-postid="' . esc_attr( $id ) . '">';
65 $args = array(
66 'p' => $id,
67 'post_type' => 'ultp_templates',
68 );
69 $the_query = new \WP_Query( $args );
70 if ( $the_query->have_posts() ) {
71 while ( $the_query->have_posts() ) {
72 $the_query->the_post();
73 the_content();
74 }
75 wp_reset_postdata();
76 }
77 echo '</div>';
78 } elseif ( isset( $_GET['action'] ) && $_GET['action'] == 'elementor' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only check for the Elementor editor screen.
79 /* translators: %s: Menu path to the Saved Templates screen. */
80 echo '<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>';
81 }
82 }
83 }
84