PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.41
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.41
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 / Simple_Form / WPDA_Simple_Form_Item_Hyperlink.php

WPDA_Simple_Form_Item_Hyperlink.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.41, at WPDataAccess/Simple_Form/WPDA_Simple_Form_Item_Hyperlink.php

143 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataAccess\Simple_Form
7 */
8
9 namespace WPDataAccess\Simple_Form {
10
11 /**
12 * Class WPDA_Simple_Form_Item_Hyperlink
13 *
14 * Database column is handled as a hyperlink: allow to enter a valid hyperlink in data entry form (shown as
15 * hyperlink in list table)
16 *
17 * @author Peter Schulz
18 * @since 2.5.0
19 */
20 class WPDA_Simple_Form_Item_Hyperlink extends WPDA_Simple_Form_Item {
21
22 protected $hyperlink_label = '';
23 protected $hyperlink_url = '';
24 protected $hyperlink_target = '';
25
26 /**
27 * WPDA_Simple_Form_Item_Hyperlink constructor.
28 *
29 * @param array $args
30 */
31 public function __construct( $args = array() ) {
32 parent::__construct( $args );
33
34 if ( '' !== $this->item_value ) {
35 $hyperlink = json_decode( $this->item_value, true );
36 if ( isset( $hyperlink['label'] ) ) {
37 $this->hyperlink_label = $hyperlink['label'];
38 }
39 if ( isset( $hyperlink['url'] ) ) {
40 $this->hyperlink_url = $hyperlink['url'];
41 }
42 if ( isset( $hyperlink['target'] ) ) {
43 $this->hyperlink_target = $hyperlink['target'];
44 }
45 }
46
47 $this->item_icon_type = 'hyperlink';
48 }
49
50 /**
51 * Overwrite method
52 *
53 * @param string $action
54 * @param string $update_keys_allowed
55 */
56 public function show( $action, $update_keys_allowed ) {
57 parent::show( $action, $update_keys_allowed );
58
59 ?>
60 <tr id="<?php echo esc_attr( $this->item_name ); ?>_hyperlink" style="display:none;">
61 <td></td>
62 <td>
63 <table cellpadding="0" cellspacing="0"
64 style="width:100%;border-spacing:0;border-collapse: collapse;">
65 <tr>
66 <td style="width:1%;white-space:nowrap;">
67 <label for="<?php echo esc_attr( $this->item_name ); ?>_label">Link Text&nbsp;</label>
68 </td>
69 <td style="width:100%;">
70 <input type="text"
71 id="<?php echo esc_attr( $this->item_name ); ?>_label"
72 name="<?php echo esc_attr( $this->item_name ); ?>_label"
73 value="<?php echo esc_attr( $this->hyperlink_label ); ?>"
74 style="width:100%;"
75 />
76 </td>
77 </tr>
78 <tr>
79 <td>
80 <label for="<?php echo esc_attr( $this->item_name ); ?>_url">URL</label>
81 </td>
82 <td>
83 <input type="text"
84 id="<?php echo esc_attr( $this->item_name ); ?>_url"
85 name="<?php echo esc_attr( $this->item_name ); ?>_url"
86 value="<?php echo esc_attr( $this->hyperlink_url ); ?>"
87 style="width:100%;"
88 />
89 </td>
90 </tr>
91 <tr>
92 <td></td>
93 <td>
94 <label>
95 <input type="checkbox"
96 id="<?php echo esc_attr( $this->item_name ); ?>_target"
97 name="<?php echo esc_attr( $this->item_name ); ?>_target"
98 <?php echo '_blank' === $this->hyperlink_target ? 'checked' : ''; ?>
99 />
100 Open link in a new tab
101 </label>
102 </td>
103 </tr>
104 </table>
105 </td>
106 <td></td>
107 </tr>
108 <?php
109 }
110
111 /**
112 * Overwrite method
113 */
114 protected function show_item() {
115 ?>
116 <span id="<?php echo esc_attr( $this->item_name ); ?>_textlink"
117 style="vertical-align:middle;font-weight:bold;cursor:pointer;">
118 <?php echo esc_attr( $this->hyperlink_label ); ?>
119 </span>
120
121 <script type='text/javascript'>
122 jQuery(function () {
123 jQuery('#<?php echo esc_attr( $this->item_name ); ?>_textlink').on('click', function () {
124 jQuery('#<?php echo esc_attr( $this->item_name ); ?>_hyperlink').toggle();
125 });
126 jQuery('#<?php echo esc_attr( $this->item_name ); ?>_icon').on('click', function () {
127 jQuery('#<?php echo esc_attr( $this->item_name ); ?>_hyperlink').toggle();
128 });
129 });
130 </script>
131
132 <input type="hidden"
133 name="<?php echo esc_attr( $this->item_name ); ?>"
134 value="<?php echo $this->show_context_column_value; // phpcs:ignore WordPress.Security.EscapeOutput ?>"
135 class="wpda_hyperlink"
136 />
137 <?php
138 }
139
140 }
141
142 }
143