PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
wp-data-access / WPDataAccess / Dashboard / WPDA_Widget_Code.php

WPDA_Widget_Code.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.84, at WPDataAccess/Dashboard/WPDA_Widget_Code.php

107 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- verified on page
4 namespace WPDataAccess\Dashboard;
5
6 use WPDataAccess\WPDA;
7 /**
8 * Implements code widget
9 */
10 class WPDA_Widget_Code extends WPDA_Widget {
11 /**
12 * Code id
13 *
14 * @var mixed
15 */
16 protected $code_id;
17
18 /**
19 * Constructor
20 *
21 * @param array $args Arguments.
22 */
23 public function __construct( $args = array() ) {
24 parent::__construct( $args );
25 $this->can_share = true;
26 if ( isset( $args['code_id'] ) ) {
27 $this->code_id = $args['code_id'];
28 if ( class_exists( 'Code_Manager\\Code_Manager' ) ) {
29 $cm = new \Code_Manager\Code_Manager();
30 $this->content = $cm->add_shortcode( array(
31 'id' => $this->code_id,
32 ) );
33 } else {
34 $this->content = 'Code Manager not installed or not activated';
35 }
36 }
37 }
38
39 /**
40 * Not implemented
41 *
42 * @param WPDA_Widget $widget Widget.
43 * @return void
44 */
45 public function do_shortcode( $widget ) {
46 // Not implemented (use Code Manager short code).
47 }
48
49 /**
50 * Embed widget
51 *
52 * @param WPDA_Widget $widget Widget.
53 * @param string $target_element HTML element is.
54 * @return void
55 */
56 public function do_embed( $widget, $target_element ) {
57 }
58
59 /**
60 * Javascript section
61 *
62 * @param boolean $is_backend Back-end indicator.
63 * @return void
64 */
65 protected function js( $is_backend = true ) {
66 }
67
68 /**
69 * Add widget via ajax
70 *
71 * @return void
72 */
73 public static function widget() {
74 $panel_name = ( isset( $_REQUEST['wpda_panel_name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_panel_name'] ) ) : '' );
75 $panel_code_id = ( isset( $_REQUEST['wpda_panel_code_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_panel_code_id'] ) ) : '' );
76 $panel_column = ( isset( $_REQUEST['wpda_panel_column'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_panel_column'] ) ) : '1' );
77 $column_position = ( isset( $_REQUEST['wpda_column_position'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_column_position'] ) ) : 'prepend' );
78 $widget_sequence_nr = ( isset( $_REQUEST['wpda_widget_sequence_nr'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_widget_sequence_nr'] ) ) : '1' );
79 $wdg = new WPDA_Widget_Code(array(
80 'name' => $panel_name,
81 'code_id' => $panel_code_id,
82 'column' => $panel_column,
83 'position' => $column_position,
84 'widget_id' => $widget_sequence_nr,
85 ));
86 WPDA::sent_header( 'text/html; charset=UTF-8' );
87 // phpcs:disable WordPress.Security.EscapeOutput
88 echo $wdg->container();
89 // phpcs:enable WordPress.Security.EscapeOutput
90 wp_die();
91 }
92
93 /**
94 * Refresh code widget
95 *
96 * @return void
97 */
98 public static function refresh() {
99 // phpcs:disable WordPress.Security.EscapeOutput
100 echo static::msg( 'ERROR', 'Method not available for this panel type' );
101 // phpcs:enable WordPress.Security.EscapeOutput
102 wp_die();
103 }
104
105 }
106
107 // phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing