PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.3
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.3
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 5.5.43 All 159 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.3, at WPDataAccess/Dashboard/WPDA_Widget_Code.php

109 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:ignore Standard.Category.SniffName.ErrorCode
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 // phpcs:ignore WordPress.Security.NonceVerification
76 $panel_code_id = ( isset( $_REQUEST['wpda_panel_code_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_panel_code_id'] ) ) : '' );
77 // phpcs:ignore WordPress.Security.NonceVerification
78 $panel_column = ( isset( $_REQUEST['wpda_panel_column'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_panel_column'] ) ) : '1' );
79 // phpcs:ignore WordPress.Security.NonceVerification
80 $column_position = ( isset( $_REQUEST['wpda_column_position'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_column_position'] ) ) : 'prepend' );
81 // phpcs:ignore WordPress.Security.NonceVerification
82 $widget_sequence_nr = ( isset( $_REQUEST['wpda_widget_sequence_nr'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpda_widget_sequence_nr'] ) ) : '1' );
83 // phpcs:ignore WordPress.Security.NonceVerification
84 $wdg = new WPDA_Widget_Code(array(
85 'name' => $panel_name,
86 'code_id' => $panel_code_id,
87 'column' => $panel_column,
88 'position' => $column_position,
89 'widget_id' => $widget_sequence_nr,
90 ));
91 WPDA::sent_header( 'text/html; charset=UTF-8' );
92 echo $wdg->container();
93 // phpcs:ignore WordPress.Security.EscapeOutput
94 wp_die();
95 }
96
97 /**
98 * Refresh code widget
99 *
100 * @return void
101 */
102 public static function refresh() {
103 echo static::msg( 'ERROR', 'Method not available for this panel type' );
104 // phpcs:ignore WordPress.Security.EscapeOutput
105 wp_die();
106 }
107
108 }
109