| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Suppress "error - 0 - No summary was found for this file" on phpdoc generation |
| 5 |
* |
| 6 |
* @package WPDataAccess\Utilities |
| 7 |
*/ |
| 8 |
namespace WPDataAccess\Utilities; |
| 9 |
|
| 10 |
use WPDataAccess\API\WPDA_API; |
| 11 |
use WPDataAccess\Connection\WPDADB; |
| 12 |
use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists; |
| 13 |
use WPDataAccess\Plugin_Table_Models\WPDA_Media_Model; |
| 14 |
use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model; |
| 15 |
use WPDataAccess\Plugin_Table_Models\WPDA_User_Menus_Model; |
| 16 |
use WPDataAccess\WPDA; |
| 17 |
use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Exist; |
| 18 |
use WPDataAccess\Data_Dictionary\WPDA_List_Columns_Cache; |
| 19 |
use WPDataAccess\Data_Dictionary\WPDA_List_Columns; |
| 20 |
/** |
| 21 |
* Class WPDA_Table_Actions |
| 22 |
* |
| 23 |
* @author Peter Schulz |
| 24 |
* @since 2.0.13 |
| 25 |
*/ |
| 26 |
class WPDA_Table_Actions { |
| 27 |
/** |
| 28 |
* Database schema name |
| 29 |
* |
| 30 |
* @var string |
| 31 |
*/ |
| 32 |
protected $schema_name; |
| 33 |
|
| 34 |
/** |
| 35 |
* Database table name |
| 36 |
* |
| 37 |
* @var string |
| 38 |
*/ |
| 39 |
protected $table_name; |
| 40 |
|
| 41 |
/** |
| 42 |
* Database table structure |
| 43 |
* |
| 44 |
* @var array |
| 45 |
*/ |
| 46 |
protected $table_structure; |
| 47 |
|
| 48 |
/** |
| 49 |
* Handle to instance of WPDA_List_Columns |
| 50 |
* |
| 51 |
* @var WPDA_List_Columns |
| 52 |
*/ |
| 53 |
protected $wpda_list_columns; |
| 54 |
|
| 55 |
/** |
| 56 |
* Engine |
| 57 |
* |
| 58 |
* @var string |
| 59 |
*/ |
| 60 |
protected $engine; |
| 61 |
|
| 62 |
/** |
| 63 |
* Configure table or view settings |
| 64 |
* |
| 65 |
* @since 2.0.13 |
| 66 |
*/ |
| 67 |
public function show( $schema_name = '', $table_name = '' ) { |
| 68 |
$this->schema_name = $schema_name; |
| 69 |
$this->table_name = $table_name; |
| 70 |
$wpda_data_dictionary = new WPDA_Dictionary_Exist($this->schema_name, $this->table_name); |
| 71 |
if ( !$wpda_data_dictionary->table_exists() ) { |
| 72 |
echo '<div>' . esc_attr__( 'ERROR: Invalid table name or not authorized', 'wp-data-access' ) . '</div>'; |
| 73 |
return; |
| 74 |
} |
| 75 |
$this->engine = WPDA_Dictionary_Lists::get_engine( $this->schema_name, $this->table_name ); |
| 76 |
$wpdadb = WPDADB::get_db_connection( $this->schema_name ); |
| 77 |
if ( null === $wpdadb ) { |
| 78 |
/* translators: %s = database name */ |
| 79 |
wp_die( sprintf( esc_attr__( 'ERROR - Remote database %s not available', 'wp-data-access' ), esc_attr( $this->schema_name ) ) ); |
| 80 |
} |
| 81 |
$query = "show full columns from `{$wpdadb->dbname}`.`{$this->table_name}`"; |
| 82 |
$this->table_structure = $wpdadb->get_results( $query, 'ARRAY_A' ); |
| 83 |
$this->wpda_list_columns = WPDA_List_Columns_Cache::get_list_columns( $this->schema_name, $this->table_name ); |
| 84 |
?> |
| 85 |
<div id="legacy-tabs"> |
| 86 |
<div class="nav-tab-wrapper" style="padding-top: 0 !important;"> |
| 87 |
<a class="nav-tab wpda-manage-nav-tab" href="javascript:void(0)" style="font-size:inherit;"> |
| 88 |
<span class="dashicons dashicons-admin-generic wpda_settings_icon"></span> |
| 89 |
<span class="wpda_settings_label" style="font-weight: 900;">Settings for `<?php |
| 90 |
echo esc_attr( $schema_name ); |
| 91 |
?>`.`<?php |
| 92 |
echo esc_attr( $table_name ); |
| 93 |
?>`</span> |
| 94 |
</a> |
| 95 |
</div> |
| 96 |
<div id="legacy-tab-1" style="padding:3px;"> |
| 97 |
<?php |
| 98 |
$this->tab_settings(); |
| 99 |
?> |
| 100 |
</div> |
| 101 |
</div> |
| 102 |
<?php |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Provides content for table settings |
| 107 |
*/ |
| 108 |
public function tab_settings() { |
| 109 |
$settings_db = WPDA_Table_Settings_Model::query( $this->table_name, $this->schema_name ); |
| 110 |
if ( isset( $settings_db[0]['wpda_table_settings'] ) ) { |
| 111 |
$settings_db_custom = json_decode( $settings_db[0]['wpda_table_settings'] ); |
| 112 |
$sql_dml = 'UPDATE'; |
| 113 |
} else { |
| 114 |
$settings_db_custom = (object) null; |
| 115 |
$sql_dml = 'INSERT'; |
| 116 |
} |
| 117 |
if ( has_filter( 'wpda_add_column_settings' ) ) { |
| 118 |
// Use filter |
| 119 |
$column_settings_add_column = apply_filters( 'wpda_add_column_settings', null ); |
| 120 |
} |
| 121 |
if ( isset( $column_settings_add_column ) && is_array( $column_settings_add_column ) ) { |
| 122 |
$array_valid = true; |
| 123 |
foreach ( $column_settings_add_column as $add_column ) { |
| 124 |
if ( !isset( $add_column['label'] ) || !isset( $add_column['hint'] ) || !isset( $add_column['name_prefix'] ) || !isset( $add_column['type'] ) || !isset( $add_column['default'] ) || !isset( $add_column['disable'] ) ) { |
| 125 |
$array_valid = false; |
| 126 |
break; |
| 127 |
} |
| 128 |
} |
| 129 |
if ( !$array_valid ) { |
| 130 |
$column_settings_add_column = array(); |
| 131 |
} |
| 132 |
} else { |
| 133 |
$column_settings_add_column = array(); |
| 134 |
} |
| 135 |
$row_count_is_configurable = 'innodb' === strtolower( $this->engine ) || 'federated' === strtolower( $this->engine ) || 'connect' === strtolower( $this->engine ) || $this->engine === null; |
| 136 |
?> |
| 137 |
<style> |
| 138 |
.wpda_table_settings_nested { |
| 139 |
padding-top: 5px; |
| 140 |
padding-left: 20px; |
| 141 |
padding-bottom: 20px; |
| 142 |
display: none; |
| 143 |
margin-right: 20px; |
| 144 |
} |
| 145 |
|
| 146 |
.wpda_table_settings_nested table { |
| 147 |
width: 100%; |
| 148 |
} |
| 149 |
|
| 150 |
.wpda_table_settings { |
| 151 |
border-collapse: collapse; |
| 152 |
} |
| 153 |
|
| 154 |
.wpda_table_settings thead { |
| 155 |
background-color: white; |
| 156 |
border-bottom: 1px solid #c3c4c7; |
| 157 |
} |
| 158 |
|
| 159 |
.wpda_table_settings thead th { |
| 160 |
text-align: left; |
| 161 |
font-weight: bold; |
| 162 |
padding: 16px 12px; |
| 163 |
} |
| 164 |
|
| 165 |
.wpda_table_settings thead th span { |
| 166 |
vertical-align: middle; |
| 167 |
} |
| 168 |
|
| 169 |
.wpda_table_settings td { |
| 170 |
vertical-align: top; |
| 171 |
padding: 8px 12px; |
| 172 |
margin: 0; |
| 173 |
} |
| 174 |
|
| 175 |
.wpda_table_settings tr:nth-child(even) { |
| 176 |
background: #fff; |
| 177 |
} |
| 178 |
|
| 179 |
.wpda_table_settings_menu { |
| 180 |
display: grid; |
| 181 |
grid-template-columns: min(30%, 290px) auto; |
| 182 |
padding: 10px; |
| 183 |
} |
| 184 |
|
| 185 |
.wpda_table_settings_panel { |
| 186 |
border: 1px solid #c3c4c7; |
| 187 |
margin: 9px 5px 10px 0; |
| 188 |
padding: 10px; |
| 189 |
} |
| 190 |
|
| 191 |
.wpda_table_settings_nav_vertical { |
| 192 |
display: grid; |
| 193 |
grid-template-columns: auto; |
| 194 |
margin-left: 5px; |
| 195 |
margin-right: 3px; |
| 196 |
padding-top: 0; |
| 197 |
} |
| 198 |
|
| 199 |
.wpda_table_settings_nav_vertical a { |
| 200 |
margin: 0; |
| 201 |
display: grid; |
| 202 |
grid-template-columns: 24px auto; |
| 203 |
align-items: center; |
| 204 |
padding: 8px 12px; |
| 205 |
} |
| 206 |
|
| 207 |
.wpda_table_settings_nav_vertical a.nav-tab-active { |
| 208 |
border-right: none; |
| 209 |
background-color: transparent; |
| 210 |
} |
| 211 |
|
| 212 |
.wpda_table_settings_nav_vertical a.nav-tab:focus { |
| 213 |
box-shadow: none; |
| 214 |
} |
| 215 |
|
| 216 |
ul.wpda_table_settings_panel h4 { |
| 217 |
margin-top: 2em; |
| 218 |
} |
| 219 |
|
| 220 |
.wpda_table_settings_menu_content { |
| 221 |
display: flex; |
| 222 |
flex-direction: column; |
| 223 |
align-items: stretch; |
| 224 |
} |
| 225 |
|
| 226 |
.wpda_table_settings_menu_content .wpda_table_settings_vertical_border { |
| 227 |
height: 10px; |
| 228 |
border-right: 1px solid #c3c4c7; |
| 229 |
padding: 0; |
| 230 |
margin: 9px 3px 0 0; |
| 231 |
} |
| 232 |
|
| 233 |
.wpda_table_settings_menu_content .wpda_table_settings_vertical_border.wpda_table_settings_vertical_border_end { |
| 234 |
flex: 2; |
| 235 |
margin-top: 0; |
| 236 |
margin-bottom: 10px; |
| 237 |
} |
| 238 |
|
| 239 |
.nav-tab-active { |
| 240 |
background-color: transparent; |
| 241 |
} |
| 242 |
|
| 243 |
.nav-tab-active:focus { |
| 244 |
box-shadow: none; |
| 245 |
background-color: transparent; |
| 246 |
} |
| 247 |
|
| 248 |
ul.wpda_geolocation_settings .wpda_fieldset { |
| 249 |
background-color: #efefef; |
| 250 |
} |
| 251 |
|
| 252 |
.wpda_table_setting_item { |
| 253 |
width: 100%; |
| 254 |
} |
| 255 |
</style> |
| 256 |
<script> |
| 257 |
function settingsNav(elem, className, setActive = true) { |
| 258 |
if (setActive) { |
| 259 |
jQuery(elem).closest(".wpda_table_settings_menu").find("a.nav-tab").removeClass("nav-tab-active"); |
| 260 |
jQuery(elem).addClass("nav-tab-active"); |
| 261 |
} |
| 262 |
|
| 263 |
jQuery(elem).closest(".wpda_table_settings_menu").find("ul.wpda_table_settings_nested").hide(); |
| 264 |
jQuery(elem).closest(".wpda_table_settings_menu").find("ul.wpda_table_settings_nested." + className).show(); |
| 265 |
} |
| 266 |
</script> |
| 267 |
<table class="widefat striped rows wpda-structure-table"> |
| 268 |
<tr> |
| 269 |
<td> |
| 270 |
<div id="wpda_table_settings_legacy" class="wpda_table_settings_menu"> |
| 271 |
<div class="wpda_table_settings_menu_content"> |
| 272 |
<div class="wpda_table_settings_vertical_border"></div> |
| 273 |
<nav class="nav-tab-wrapper wpda_table_settings_nav_vertical"> |
| 274 |
<a href="javascript:void(0)" onclick="settingsNav(this, 'wpda_table_table_settings')" class="nav-tab"> |
| 275 |
<i class="fa-solid fa-table wpda_settings_icon"></i> |
| 276 |
<span> |
| 277 |
Table Settings |
| 278 |
</span> |
| 279 |
</a> |
| 280 |
<a href="javascript:void(0)" onclick="settingsNav(this, 'wpda_table_column_settings')" class="nav-tab"> |
| 281 |
<i class="fa-solid fa-table-columns wpda_settings_icon"></i> |
| 282 |
<span> |
| 283 |
Column Settings |
| 284 |
</span> |
| 285 |
</a> |
| 286 |
<?php |
| 287 |
?> |
| 288 |
<a href="javascript:void(0)" onclick="settingsNav(this, 'wpda_table_dynamic_hyperlinks_settings')" class="nav-tab"> |
| 289 |
<i class="fa-solid fa-link wpda_settings_icon"></i> |
| 290 |
<span> |
| 291 |
Dynamic Hyperlinks |
| 292 |
</span> |
| 293 |
</a> |
| 294 |
</nav> |
| 295 |
<div class="wpda_table_settings_vertical_border wpda_table_settings_vertical_border_end"></div> |
| 296 |
</div> |
| 297 |
<ul class="wpda_table_settings_panel"> |
| 298 |
<?php |
| 299 |
do_action( |
| 300 |
'wpda_prepend_table_settings', |
| 301 |
$this->schema_name, |
| 302 |
$this->table_name, |
| 303 |
$this->table_structure |
| 304 |
); |
| 305 |
?> |
| 306 |
<li> |
| 307 |
<ul class="wpda_table_settings_nested wpda_table_table_settings"> |
| 308 |
<h2> |
| 309 |
<?php |
| 310 |
esc_html_e( 'Table Settings', 'wp-data-access' ); |
| 311 |
?> |
| 312 |
<a href="https://docs.legacy.wpdataaccess.com/docs/manage-table-settings/" target="_blank"> |
| 313 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 314 |
title="<?php |
| 315 |
esc_html_e( 'Help opens in a new tab or window', 'wp-data-access' ); |
| 316 |
?>" |
| 317 |
style="cursor:pointer"></span> |
| 318 |
</a> |
| 319 |
</h2> |
| 320 |
|
| 321 |
<h4> |
| 322 |
<?php |
| 323 |
esc_html_e( 'Row count (configurable for InnoDB tables, federated tables and views only)', 'wp-data-access' ); |
| 324 |
?> |
| 325 |
</h4> |
| 326 |
|
| 327 |
<div style="font-size:90%;"> |
| 328 |
<label class="wpda_action_font"> |
| 329 |
<input type="radio" |
| 330 |
name="<?php |
| 331 |
echo esc_attr( $this->table_name ); |
| 332 |
?>_row_count_estimate" |
| 333 |
value="true" |
| 334 |
<?php |
| 335 |
echo ( !$row_count_is_configurable ? ' disabled ' : '' ); |
| 336 |
if ( isset( $settings_db_custom->table_settings->row_count_estimate ) && $settings_db_custom->table_settings->row_count_estimate ) { |
| 337 |
echo ' checked '; |
| 338 |
} |
| 339 |
?> |
| 340 |
> |
| 341 |
Show estimated row count (faster but less accurate) |
| 342 |
</label> |
| 343 |
<?php |
| 344 |
$row_count_estimate_value = 'plugin'; |
| 345 |
if ( isset( $settings_db_custom->table_settings->row_count_estimate_value ) ) { |
| 346 |
$row_count_estimate_value = $settings_db_custom->table_settings->row_count_estimate_value; |
| 347 |
} |
| 348 |
?> |
| 349 |
<div style="padding: 5px 0 5px 25px"> |
| 350 |
<label class="wpda_action_font"> |
| 351 |
<input type="radio" |
| 352 |
name="<?php |
| 353 |
echo esc_attr( $this->table_name ); |
| 354 |
?>_row_count_estimated_value" |
| 355 |
value="plugin" |
| 356 |
<?php |
| 357 |
echo ( 'plugin' === $row_count_estimate_value ? 'checked' : '' ); |
| 358 |
echo ( !$row_count_is_configurable ? ' disabled ' : '' ); |
| 359 |
?> |
| 360 |
/> |
| 361 |
Use plugin estimate calculation |
| 362 |
</label> |
| 363 |
<br/> |
| 364 |
<label class="wpda_action_font"> |
| 365 |
<?php |
| 366 |
$row_count = 0; |
| 367 |
if ( isset( $settings_db_custom->table_settings->row_count_estimate_value_hard ) ) { |
| 368 |
$row_count = $settings_db_custom->table_settings->row_count_estimate_value_hard; |
| 369 |
} else { |
| 370 |
if ( 'connect' === strtolower( $this->engine ) ) { |
| 371 |
$row_count = ''; |
| 372 |
} else { |
| 373 |
$wpdadb = WPDADB::get_db_connection( $this->schema_name ); |
| 374 |
$explain = $wpdadb->get_results( 'explain select count(*) from `' . str_replace( '`', '', $this->table_name ) . '`', 'ARRAY_A' ); |
| 375 |
if ( isset( $explain[0]['rows'] ) ) { |
| 376 |
$row_count = $explain[0]['rows']; |
| 377 |
} elseif ( isset( $explain[0]['ROWS'] ) ) { |
| 378 |
$row_count = $explain[0]['ROWS']; |
| 379 |
} |
| 380 |
} |
| 381 |
} |
| 382 |
?> |
| 383 |
<input type="radio" |
| 384 |
name="<?php |
| 385 |
echo esc_attr( $this->table_name ); |
| 386 |
?>_row_count_estimated_value" |
| 387 |
value="hard" |
| 388 |
<?php |
| 389 |
echo ( 'hard' === $row_count_estimate_value ? 'checked' : '' ); |
| 390 |
echo ( !$row_count_is_configurable ? ' disabled ' : '' ); |
| 391 |
?> |
| 392 |
/> |
| 393 |
Use hard estimate: |
| 394 |
<input type="number" |
| 395 |
id="<?php |
| 396 |
echo esc_attr( $this->table_name ); |
| 397 |
?>_row_count_estimated_value_hard" |
| 398 |
value="<?php |
| 399 |
echo esc_attr( $row_count ); |
| 400 |
?>" |
| 401 |
echo ! $row_count_is_configurable ? 'disabled ' : ''; |
| 402 |
/> |
| 403 |
<a href="javascript:void(0)" |
| 404 |
onclick="get_table_row_count('<?php |
| 405 |
echo esc_attr( wp_create_nonce( "wpda-get-row-count-{$this->table_name}" ) ); |
| 406 |
?>', '<?php |
| 407 |
echo esc_attr( $this->schema_name ); |
| 408 |
?>', '<?php |
| 409 |
echo esc_attr( $this->table_name ); |
| 410 |
?>')" |
| 411 |
title="Get real row count" |
| 412 |
class="wpda_tooltip" |
| 413 |
style="font-weight: bold; font-size: 140%;" |
| 414 |
>Σ</a> |
| 415 |
</label> |
| 416 |
</div> |
| 417 |
<label class="wpda_action_font"> |
| 418 |
<input type="radio" |
| 419 |
name="<?php |
| 420 |
echo esc_attr( $this->table_name ); |
| 421 |
?>_row_count_estimate" |
| 422 |
value="false" |
| 423 |
<?php |
| 424 |
echo ( !$row_count_is_configurable ? ' disabled ' : '' ); |
| 425 |
if ( isset( $settings_db_custom->table_settings->row_count_estimate ) && !$settings_db_custom->table_settings->row_count_estimate ) { |
| 426 |
echo ' checked '; |
| 427 |
} else { |
| 428 |
if ( !$row_count_is_configurable ) { |
| 429 |
echo ' checked '; |
| 430 |
} |
| 431 |
} |
| 432 |
?> |
| 433 |
> |
| 434 |
Show real row count |
| 435 |
</label> |
| 436 |
<br/> |
| 437 |
<label class="wpda_action_font" style="display: inline-block; margin-top: 10px"> |
| 438 |
<input type="radio" |
| 439 |
name="<?php |
| 440 |
echo esc_attr( $this->table_name ); |
| 441 |
?>_row_count_estimate" |
| 442 |
value="" |
| 443 |
<?php |
| 444 |
echo ( !$row_count_is_configurable ? ' disabled ' : '' ); |
| 445 |
if ( isset( $settings_db_custom->table_settings->row_count_estimate ) ) { |
| 446 |
if ( null === $settings_db_custom->table_settings->row_count_estimate ) { |
| 447 |
echo ' checked '; |
| 448 |
} |
| 449 |
} else { |
| 450 |
if ( $row_count_is_configurable ) { |
| 451 |
echo ' checked '; |
| 452 |
} |
| 453 |
} |
| 454 |
?> |
| 455 |
> |
| 456 |
Use plugin default (current value=<?php |
| 457 |
echo esc_attr( WPDA::get_option( WPDA::OPTION_BE_INNODB_COUNT ) ); |
| 458 |
?>) |
| 459 |
[<a href="<?php |
| 460 |
echo esc_url( admin_url( 'options-general.php' ) ); |
| 461 |
?>?page=wpdataaccess&tab=backend">change plugin default</a>] |
| 462 |
</label> |
| 463 |
<div style="margin-top: 5px; padding-left: 24px"> |
| 464 |
Performs real row count if estimate <= <?php |
| 465 |
echo esc_attr( WPDA::get_option( WPDA::OPTION_BE_INNODB_COUNT ) ); |
| 466 |
?>. |
| 467 |
Uses estimated row count if estimate > <?php |
| 468 |
echo esc_attr( WPDA::get_option( WPDA::OPTION_BE_INNODB_COUNT ) ); |
| 469 |
?>. |
| 470 |
</div> |
| 471 |
</div> |
| 472 |
<h4> |
| 473 |
<?php |
| 474 |
esc_html_e( 'Query buffer size', 'wp-data-access' ); |
| 475 |
?> |
| 476 |
</h4> |
| 477 |
<div style="font-size:90%;"> |
| 478 |
<label class="wpda_action_font"> |
| 479 |
<?php |
| 480 |
esc_html_e( 'Max rows per fetch', 'wp-data-access' ); |
| 481 |
?> |
| 482 |
</label> |
| 483 |
<input type="text" |
| 484 |
id="<?php |
| 485 |
echo esc_attr( $this->table_name ); |
| 486 |
?>_query_buffer_size" |
| 487 |
<?php |
| 488 |
if ( isset( $settings_db_custom->table_settings->query_buffer_size ) ) { |
| 489 |
echo 'value="' . esc_attr( $settings_db_custom->table_settings->query_buffer_size ) . '"'; |
| 490 |
} |
| 491 |
?> |
| 492 |
/> |
| 493 |
<span class="dashicons dashicons-editor-help wpda_tooltip" title="Large exports to other databases can result in an 'allowed memory size exhausted' error. Reduce the query buffer size to prevent this fatal error. |
| 494 |
|
| 495 |
Start with high values and work down until the error disappears." style="cursor:pointer;vertical-align:middle"></span> |
| 496 |
</div> |
| 497 |
<h4> |
| 498 |
<?php |
| 499 |
esc_html_e( 'Access control', 'wp-data-access' ); |
| 500 |
?> |
| 501 |
</h4> |
| 502 |
<div style="font-size:90%;"> |
| 503 |
<label class="wpda_action_font"> |
| 504 |
<input type="checkbox" |
| 505 |
id="<?php |
| 506 |
echo esc_attr( $this->table_name ); |
| 507 |
?>_row_level_security" |
| 508 |
<?php |
| 509 |
if ( isset( $settings_db_custom->table_settings->row_level_security ) ) { |
| 510 |
echo ( 'true' === $settings_db_custom->table_settings->row_level_security ? 'checked' : '' ); |
| 511 |
} |
| 512 |
?> |
| 513 |
/> |
| 514 |
<?php |
| 515 |
esc_html_e( 'Enable row level access control (adds token to row actions)', 'wp-data-access' ); |
| 516 |
?> |
| 517 |
</label> |
| 518 |
</div> |
| 519 |
<h4> |
| 520 |
<?php |
| 521 |
esc_html_e( 'Process hyperlink columns as', 'wp-data-access' ); |
| 522 |
?> |
| 523 |
</h4> |
| 524 |
<div style="font-size:90%;"> |
| 525 |
<label for="<?php |
| 526 |
echo esc_attr( $this->table_name ); |
| 527 |
?>table_top_setting_hyperlink_definition_json"> |
| 528 |
<input type="radio" |
| 529 |
id="<?php |
| 530 |
echo esc_attr( $this->table_name ); |
| 531 |
?>table_top_setting_hyperlink_definition_json" |
| 532 |
name="<?php |
| 533 |
echo esc_attr( $this->table_name ); |
| 534 |
?>table_top_setting_hyperlink_definition" |
| 535 |
value="json" |
| 536 |
class="wpda_table_top_setting_item wpda_action_font" |
| 537 |
<?php |
| 538 |
if ( isset( $settings_db_custom->table_settings->hyperlink_definition ) ) { |
| 539 |
echo ( 'json' === $settings_db_custom->table_settings->hyperlink_definition ? 'checked' : '' ); |
| 540 |
} else { |
| 541 |
echo 'checked'; |
| 542 |
} |
| 543 |
?> |
| 544 |
/> |
| 545 |
<?php |
| 546 |
esc_html_e( 'Preformatted JSON (allows individual label and target setting)', 'wp-data-access' ); |
| 547 |
?> |
| 548 |
</label> |
| 549 |
<br/> |
| 550 |
<label for="<?php |
| 551 |
echo esc_attr( $this->table_name ); |
| 552 |
?>table_top_setting_hyperlink_definition_text" style="display: inline-block; margin-top: 10px"> |
| 553 |
<input type="radio" |
| 554 |
id="<?php |
| 555 |
echo esc_attr( $this->table_name ); |
| 556 |
?>table_top_setting_hyperlink_definition_text" |
| 557 |
name="<?php |
| 558 |
echo esc_attr( $this->table_name ); |
| 559 |
?>table_top_setting_hyperlink_definition" |
| 560 |
value="text" |
| 561 |
class="wpda_table_top_setting_item wpda_action_font" |
| 562 |
<?php |
| 563 |
if ( isset( $settings_db_custom->table_settings->hyperlink_definition ) ) { |
| 564 |
echo ( 'text' === $settings_db_custom->table_settings->hyperlink_definition ? 'checked' : '' ); |
| 565 |
} |
| 566 |
?> |
| 567 |
/> |
| 568 |
<?php |
| 569 |
esc_html_e( 'Plain text (column name used as link, opens a new tab or window)', 'wp-data-access' ); |
| 570 |
?> |
| 571 |
</label> |
| 572 |
</div> |
| 573 |
<br/> |
| 574 |
<div> |
| 575 |
<button type="button" |
| 576 |
id="wpda_legacy_save_table_settings" |
| 577 |
class="button button-primary" |
| 578 |
> |
| 579 |
<i class="fas fa-check wpda_icon_on_button"></i> |
| 580 |
<?php |
| 581 |
esc_html_e( 'Save Table Settings', 'wp-data-access' ); |
| 582 |
?> |
| 583 |
</button> |
| 584 |
</div> |
| 585 |
</ul> |
| 586 |
</li> |
| 587 |
<li> |
| 588 |
<ul class="wpda_table_settings_nested wpda_table_column_settings"> |
| 589 |
<h2> |
| 590 |
<?php |
| 591 |
esc_html_e( 'Column Settings', 'wp-data-access' ); |
| 592 |
?> |
| 593 |
<a href="https://docs.legacy.wpdataaccess.com/docs/column-settings/" target="_blank"> |
| 594 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 595 |
title="<?php |
| 596 |
esc_html_e( 'Help opens in a new tab or window', 'wp-data-access' ); |
| 597 |
?>" |
| 598 |
style="cursor:pointer"></span> |
| 599 |
</a> |
| 600 |
</h2> |
| 601 |
<table class="wpda_table_settings"> |
| 602 |
<thead> |
| 603 |
<tr> |
| 604 |
<th> |
| 605 |
<span> |
| 606 |
<?php |
| 607 |
esc_html_e( 'Column', 'wp-data-access' ); |
| 608 |
?> |
| 609 |
</span> |
| 610 |
</th> |
| 611 |
<th> |
| 612 |
<span> |
| 613 |
<?php |
| 614 |
esc_html_e( 'Label on List Table', 'wp-data-access' ); |
| 615 |
?> |
| 616 |
</span> |
| 617 |
<span |
| 618 |
class="dashicons dashicons-editor-help wpda_tooltip" |
| 619 |
title="<?php |
| 620 |
esc_html_e( 'Define column labels for list tables', 'wp-data-access' ); |
| 621 |
?>" |
| 622 |
></span> |
| 623 |
</th> |
| 624 |
<th> |
| 625 |
<span> |
| 626 |
<?php |
| 627 |
esc_html_e( 'Label on Data Entry Form', 'wp-data-access' ); |
| 628 |
?> |
| 629 |
</span> |
| 630 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 631 |
title="<?php |
| 632 |
esc_html_e( 'Define column labels for data entry forms', 'wp-data-access' ); |
| 633 |
?>" |
| 634 |
></span> |
| 635 |
</th> |
| 636 |
<th> |
| 637 |
<span> |
| 638 |
<?php |
| 639 |
esc_html_e( 'Column Type', 'wp-data-access' ); |
| 640 |
?> |
| 641 |
</span> |
| 642 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 643 |
title="<?php |
| 644 |
esc_html_e( 'Featured plugin column types', 'wp-data-access' ); |
| 645 |
?>" |
| 646 |
></span> |
| 647 |
</th> |
| 648 |
<?php |
| 649 |
foreach ( $column_settings_add_column as $add_column ) { |
| 650 |
?> |
| 651 |
<th> |
| 652 |
<span> |
| 653 |
<?php |
| 654 |
echo esc_attr( $add_column['label'] ); |
| 655 |
?> |
| 656 |
</span> |
| 657 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 658 |
title="<?php |
| 659 |
echo esc_attr( $add_column['hint'] ); |
| 660 |
?>" |
| 661 |
></span> |
| 662 |
</th> |
| 663 |
<?php |
| 664 |
} |
| 665 |
?> |
| 666 |
</tr> |
| 667 |
</thead> |
| 668 |
<tbody> |
| 669 |
<?php |
| 670 |
$columns = $this->wpda_list_columns->get_table_column_headers(); |
| 671 |
$media_pool = WPDA_Media_Model::get_pool(); |
| 672 |
$media_cols = array(); |
| 673 |
if ( isset( $media_pool[$this->schema_name][$this->table_name] ) ) { |
| 674 |
$media_cols = $media_pool[$this->schema_name][$this->table_name]; |
| 675 |
} |
| 676 |
foreach ( $this->table_structure as $column ) { |
| 677 |
$label_list_table = $this->wpda_list_columns->get_column_label( $column['Field'] ); |
| 678 |
$label_data_entry = ( isset( $columns[$column['Field']] ) ? $columns[$column['Field']] : '' ); |
| 679 |
$option = ( isset( $media_cols[$column['Field']] ) ? $media_cols[$column['Field']] : '' ); |
| 680 |
?> |
| 681 |
<tr> |
| 682 |
<td> |
| 683 |
<?php |
| 684 |
echo esc_attr( $column['Field'] ); |
| 685 |
?> |
| 686 |
</td> |
| 687 |
<td> |
| 688 |
<input |
| 689 |
id="list_label_<?php |
| 690 |
echo esc_attr( $column['Field'] ); |
| 691 |
?>" |
| 692 |
class="wpda_table_setting_item wpda_action_font" |
| 693 |
type="text" |
| 694 |
value="<?php |
| 695 |
echo esc_attr( $label_list_table ); |
| 696 |
?>" |
| 697 |
style="font-size: 90%;" |
| 698 |
> |
| 699 |
</td> |
| 700 |
<td> |
| 701 |
<input |
| 702 |
id="form_label_<?php |
| 703 |
echo esc_attr( $column['Field'] ); |
| 704 |
?>" |
| 705 |
class="wpda_table_setting_item wpda_action_font" |
| 706 |
type="text" |
| 707 |
value="<?php |
| 708 |
echo esc_attr( $label_data_entry ); |
| 709 |
?>" |
| 710 |
style="font-size: 90%;" |
| 711 |
> |
| 712 |
</td> |
| 713 |
<td style="text-align:center;"> |
| 714 |
<select id="column_media_<?php |
| 715 |
echo esc_attr( $column['Field'] ); |
| 716 |
?>" |
| 717 |
class="wpda_table_setting_item wpda_action_font" |
| 718 |
style="font-size: 90%; height: 30px;" |
| 719 |
> |
| 720 |
<option value="" <?php |
| 721 |
echo ( '' === $option ? 'selected' : '' ); |
| 722 |
?>> |
| 723 |
</option> |
| 724 |
<option value="Attachment" <?php |
| 725 |
echo ( 'Attachment' === $option ? 'selected' : '' ); |
| 726 |
?>> |
| 727 |
Attachment |
| 728 |
</option> |
| 729 |
<option value="Audio" <?php |
| 730 |
echo ( 'Audio' === $option ? 'selected' : '' ); |
| 731 |
?>> |
| 732 |
Audio |
| 733 |
</option> |
| 734 |
<option value="Hyperlink" <?php |
| 735 |
echo ( 'Hyperlink' === $option ? 'selected' : '' ); |
| 736 |
?>> |
| 737 |
Hyperlink |
| 738 |
</option> |
| 739 |
<option value="Image" <?php |
| 740 |
echo ( 'Image' === $option ? 'selected' : '' ); |
| 741 |
?>> |
| 742 |
Image |
| 743 |
</option> |
| 744 |
<option value="ImageURL" <?php |
| 745 |
echo ( 'ImageURL' === $option ? 'selected' : '' ); |
| 746 |
?>> |
| 747 |
Image URL |
| 748 |
</option> |
| 749 |
<option value="Video" <?php |
| 750 |
echo ( 'Video' === $option ? 'selected' : '' ); |
| 751 |
?>> |
| 752 |
Video |
| 753 |
</option> |
| 754 |
</select> |
| 755 |
<input type="hidden" |
| 756 |
id="column_media_<?php |
| 757 |
echo esc_attr( $column['Field'] ); |
| 758 |
?>_dml" |
| 759 |
value="<?php |
| 760 |
echo ( isset( $media_cols[$column['Field']] ) ? 'UPDATE' : 'INSERT' ); |
| 761 |
?>" |
| 762 |
/> |
| 763 |
<input type="hidden" |
| 764 |
id="column_media_<?php |
| 765 |
echo esc_attr( $column['Field'] ); |
| 766 |
?>_old" |
| 767 |
value="<?php |
| 768 |
echo esc_attr( $option ); |
| 769 |
?>" |
| 770 |
/> |
| 771 |
</td> |
| 772 |
<?php |
| 773 |
foreach ( $column_settings_add_column as $add_column ) { |
| 774 |
?> |
| 775 |
<td> |
| 776 |
<?php |
| 777 |
if ( 'Edit' === $add_column['label'] ) { |
| 778 |
echo '<label>'; |
| 779 |
} |
| 780 |
?> |
| 781 |
<input |
| 782 |
type="<?php |
| 783 |
echo esc_attr( $add_column['type'] ); |
| 784 |
?>" |
| 785 |
id="<?php |
| 786 |
echo esc_attr( $add_column['name_prefix'] ) . esc_attr( $column['Field'] ); |
| 787 |
?>" |
| 788 |
class="wpda_table_setting_item wpda_action_font wpda_tooltip" |
| 789 |
<?php |
| 790 |
if ( 'keys' === $add_column['disable'] ) { |
| 791 |
$primary_key = $this->wpda_list_columns->get_table_primary_key(); |
| 792 |
if ( in_array( $column['Field'], $primary_key ) ) { |
| 793 |
// phpcs:ignore -- 8.1 proof |
| 794 |
echo 'disabled="disabled" title="Not available for key columns"'; |
| 795 |
} |
| 796 |
} |
| 797 |
if ( 'checkbox' === $add_column['type'] ) { |
| 798 |
$column_name = $add_column['name_prefix'] . esc_attr( $column['Field'] ); |
| 799 |
if ( isset( $settings_db_custom->custom_settings->{$column_name} ) ) { |
| 800 |
echo ( $settings_db_custom->custom_settings->{$column_name} ? 'checked' : '' ); |
| 801 |
} else { |
| 802 |
echo esc_attr( $add_column['default'] ); |
| 803 |
} |
| 804 |
} |
| 805 |
?> |
| 806 |
><?php |
| 807 |
if ( 'Edit' === $add_column['label'] ) { |
| 808 |
echo '</label>'; |
| 809 |
} |
| 810 |
?> |
| 811 |
</td> |
| 812 |
<?php |
| 813 |
} |
| 814 |
?> |
| 815 |
</tr> |
| 816 |
<?php |
| 817 |
} |
| 818 |
?> |
| 819 |
</tbody></table> |
| 820 |
<br/> |
| 821 |
<div> |
| 822 |
<button type="button" |
| 823 |
id="wpda_legacy_save_column_settings" |
| 824 |
class="button button-primary" |
| 825 |
> |
| 826 |
<i class="fas fa-check wpda_icon_on_button"></i> |
| 827 |
<?php |
| 828 |
esc_html_e( 'Save Column Settings', 'wp-data-access' ); |
| 829 |
?> |
| 830 |
</button> |
| 831 |
</div> |
| 832 |
</ul> |
| 833 |
</li> |
| 834 |
<?php |
| 835 |
$this->settings_tab_dynamic_hyperlinks( $settings_db_custom ); |
| 836 |
do_action( 'wpda_append_table_settings' ); |
| 837 |
?> |
| 838 |
</ul> |
| 839 |
<input class="wpda_table_setting_item" type="hidden" id="wpda_legacy_sql_dml" |
| 840 |
value="<?php |
| 841 |
echo esc_attr( $sql_dml ); |
| 842 |
?>" |
| 843 |
/> |
| 844 |
</div> |
| 845 |
</td> |
| 846 |
</tr> |
| 847 |
</table> |
| 848 |
<script type='text/javascript'> |
| 849 |
jQuery(function () { |
| 850 |
// Show table settings menu on startup |
| 851 |
settingsNav("#wpda_table_settings_legacy", "wpda_table_table_settings", false); |
| 852 |
jQuery("#wpda_table_settings_legacy").find("a.nav-tab").removeClass("nav-tab-active"); |
| 853 |
jQuery("#wpda_table_settings_legacy").find("a.nav-tab:first-child").addClass("nav-tab-active"); |
| 854 |
|
| 855 |
// Table settings |
| 856 |
jQuery('#wpda_legacy_save_table_settings').click( function() { |
| 857 |
return submit_table_settings( |
| 858 |
'legacy', |
| 859 |
'<?php |
| 860 |
echo esc_attr( $this->schema_name ); |
| 861 |
?>', |
| 862 |
'<?php |
| 863 |
echo esc_attr( $this->table_name ); |
| 864 |
?>' |
| 865 |
); |
| 866 |
}); |
| 867 |
jQuery('#wpda_legacy_cancel_table_settings').click( function() { |
| 868 |
jQuery('#wpda_admin_menu_actions_legacy').toggle(); |
| 869 |
wpda_toggle_row_actions('legacy'); |
| 870 |
}); |
| 871 |
|
| 872 |
// Column settings |
| 873 |
jQuery('#wpda_legacy_save_column_settings').click( function() { |
| 874 |
return submit_column_settings( |
| 875 |
'legacy', |
| 876 |
'<?php |
| 877 |
echo esc_attr( $this->schema_name ); |
| 878 |
?>', |
| 879 |
'<?php |
| 880 |
echo esc_attr( $this->table_name ); |
| 881 |
?>' |
| 882 |
); |
| 883 |
}); |
| 884 |
jQuery('#wpda_legacy_cancel_column_settings').click( function() { |
| 885 |
jQuery('#wpda_admin_menu_actions_legacy').toggle(); |
| 886 |
wpda_toggle_row_actions('legacy'); |
| 887 |
}); |
| 888 |
|
| 889 |
jQuery('.wpda_tooltip').tooltip(); |
| 890 |
}); |
| 891 |
|
| 892 |
var custom_column_settings = []; |
| 893 |
<?php |
| 894 |
foreach ( $column_settings_add_column as $add_column ) { |
| 895 |
// phpcs:disable WordPress.Security.EscapeOutput |
| 896 |
echo 'custom_column_settings.push("' . $add_column['name_prefix'] . '");'; |
| 897 |
// phpcs:enable WordPress.Security.EscapeOutput |
| 898 |
} |
| 899 |
?> |
| 900 |
</script> |
| 901 |
<?php |
| 902 |
} |
| 903 |
|
| 904 |
private function settings_tab_dynamic_hyperlinks( $settings_db_custom ) { |
| 905 |
?> |
| 906 |
<li> |
| 907 |
<ul class="wpda_table_settings_nested wpda_table_dynamic_hyperlinks_settings"> |
| 908 |
<h2> |
| 909 |
<?php |
| 910 |
esc_html_e( 'Dynamic Hyperlinks', 'wp-data-access' ); |
| 911 |
?> |
| 912 |
<a href="https://docs.legacy.wpdataaccess.com/docs/dynamic-hyperlinks/" target="_blank"> |
| 913 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 914 |
title="<?php |
| 915 |
echo sprintf( esc_attr__( 'Help opens in a new tab or window', 'wp-data-access' ), esc_attr( $this->table_name ) ); |
| 916 |
?>" |
| 917 |
style="cursor:pointer"></span> |
| 918 |
</a> |
| 919 |
</h2> |
| 920 |
<table class="wpda_table_settings"> |
| 921 |
<thead> |
| 922 |
<tr> |
| 923 |
<th> |
| 924 |
<span> |
| 925 |
<?php |
| 926 |
esc_html_e( 'Hyperlink Label', 'wp-data-access' ); |
| 927 |
?> |
| 928 |
</span> |
| 929 |
</th> |
| 930 |
<th style="text-align:center"> |
| 931 |
<span> |
| 932 |
<?php |
| 933 |
esc_html_e( '+List?', 'wp-data-access' ); |
| 934 |
?> |
| 935 |
</span> |
| 936 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 937 |
title="<?php |
| 938 |
esc_html_e( 'Add hyperlink to list', 'wp-data-access' ); |
| 939 |
?>" |
| 940 |
style="cursor:pointer;"></span> |
| 941 |
</th> |
| 942 |
<th style="text-align:center"> |
| 943 |
<span> |
| 944 |
<?php |
| 945 |
esc_html_e( '+Form?', 'wp-data-access' ); |
| 946 |
?> |
| 947 |
</span> |
| 948 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 949 |
title="<?php |
| 950 |
esc_html_e( 'Add hyperlink to form', 'wp-data-access' ); |
| 951 |
?>" |
| 952 |
style="cursor:pointer;"></span> |
| 953 |
</th> |
| 954 |
<th style="text-align:center"> |
| 955 |
<span> |
| 956 |
<?php |
| 957 |
esc_html_e( '+Window?', 'wp-data-access' ); |
| 958 |
?> |
| 959 |
</span> |
| 960 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 961 |
title="<?php |
| 962 |
esc_html_e( 'Opens URL in a new tab or window', 'wp-data-access' ); |
| 963 |
?>" |
| 964 |
style="cursor:pointer;"></span> |
| 965 |
</th> |
| 966 |
<th> |
| 967 |
<span> |
| 968 |
<?php |
| 969 |
// phpcs:disable WordPress.Security.EscapeOutput |
| 970 |
esc_html_e( 'HTML', 'wp-data-access' ); |
| 971 |
?> |
| 972 |
</span> |
| 973 |
<span class="dashicons dashicons-editor-help wpda_tooltip" |
| 974 |
title="<?php |
| 975 |
esc_html_e( 'Just the URL! For example: |
| 976 |
|
| 977 |
https://yoursite.com/services.php?name=$$column_name$$ |
| 978 |
|
| 979 |
Variable $$column_name$$ will be replaced with the value of column $$column_name$$ in table `', 'wp-data-access' ) . esc_attr( $this->table_name ) . '`.'; |
| 980 |
// phpcs:enable WordPress.Security.EscapeOutput |
| 981 |
?>" |
| 982 |
style="cursor:pointer;"></span> |
| 983 |
</th> |
| 984 |
<th></th> |
| 985 |
</tr> |
| 986 |
<thead> |
| 987 |
<tbody id="wpda_legacy_add_hyperlink_body"> |
| 988 |
<?php |
| 989 |
if ( isset( $settings_db_custom->hyperlinks ) && is_array( $settings_db_custom->hyperlinks ) ) { |
| 990 |
foreach ( $settings_db_custom->hyperlinks as $hyperlink ) { |
| 991 |
$hyperlink_label = ( isset( $hyperlink->hyperlink_label ) ? $hyperlink->hyperlink_label : '' ); |
| 992 |
$hyperlink_list = ( isset( $hyperlink->hyperlink_list ) && true === $hyperlink->hyperlink_list ? 'checked' : '' ); |
| 993 |
$hyperlink_form = ( isset( $hyperlink->hyperlink_form ) && true === $hyperlink->hyperlink_form ? 'checked' : '' ); |
| 994 |
$hyperlink_target = ( isset( $hyperlink->hyperlink_target ) && true === $hyperlink->hyperlink_target ? 'checked' : '' ); |
| 995 |
$hyperlink_html = ( isset( $hyperlink->hyperlink_html ) ? $hyperlink->hyperlink_html : '' ); |
| 996 |
?> |
| 997 |
<tr> |
| 998 |
<td> |
| 999 |
<input data-id="hyperlink_label" |
| 1000 |
class="wpda_action_font" |
| 1001 |
type="text" |
| 1002 |
value="<?php |
| 1003 |
echo esc_attr( $hyperlink_label ); |
| 1004 |
?>" |
| 1005 |
style="width:100%" |
| 1006 |
/> |
| 1007 |
</td> |
| 1008 |
<td style="text-align:center"> |
| 1009 |
<input data-id="hyperlink_list" |
| 1010 |
class="wpda_action_font" |
| 1011 |
type="checkbox" |
| 1012 |
style="margin-top:7px;" |
| 1013 |
<?php |
| 1014 |
echo esc_attr( $hyperlink_list ); |
| 1015 |
?> |
| 1016 |
/> |
| 1017 |
</td> |
| 1018 |
<td style="text-align:center"> |
| 1019 |
<input data-id="hyperlink_form" |
| 1020 |
class="wpda_action_font" |
| 1021 |
type="checkbox" |
| 1022 |
style="margin-top:7px;" |
| 1023 |
<?php |
| 1024 |
echo esc_attr( $hyperlink_form ); |
| 1025 |
?> |
| 1026 |
/> |
| 1027 |
</td> |
| 1028 |
<td style="text-align:center"> |
| 1029 |
<input data-id="hyperlink_target" |
| 1030 |
class="wpda_action_font" |
| 1031 |
type="checkbox" |
| 1032 |
style="margin-top:7px;" |
| 1033 |
<?php |
| 1034 |
echo esc_attr( $hyperlink_target ); |
| 1035 |
?> |
| 1036 |
/> |
| 1037 |
</td> |
| 1038 |
<td> |
| 1039 |
<textarea data-id="hyperlink_html" |
| 1040 |
rows="5" |
| 1041 |
class="wpda_action_font" |
| 1042 |
style="width:100%;resize:both;" |
| 1043 |
><?php |
| 1044 |
// phpcs:disable WordPress.Security.EscapeOutput |
| 1045 |
echo urldecode( $hyperlink_html ); |
| 1046 |
// phpcs:enable WordPress.Security.EscapeOutput |
| 1047 |
?></textarea> |
| 1048 |
</td> |
| 1049 |
<td> |
| 1050 |
<a href="javascript:void(0)" |
| 1051 |
class="dashicons dashicons-trash" |
| 1052 |
style="margin-top:4px;" |
| 1053 |
onclick="if (confirm('<?php |
| 1054 |
esc_html_e( 'Delete hyperlink?', 'wp-data-access' ); |
| 1055 |
?>')) { jQuery(this).closest('tr').remove() }" |
| 1056 |
></a> |
| 1057 |
</td> |
| 1058 |
</tr> |
| 1059 |
<?php |
| 1060 |
} |
| 1061 |
} |
| 1062 |
?> |
| 1063 |
</tbody> |
| 1064 |
</table> |
| 1065 |
<br/> |
| 1066 |
<div> |
| 1067 |
<button type="button" |
| 1068 |
id="wpda_legacy_save_hyperlinks" |
| 1069 |
class="button button-primary" |
| 1070 |
> |
| 1071 |
<i class="fas fa-check wpda_icon_on_button"></i> |
| 1072 |
<?php |
| 1073 |
esc_html_e( 'Save Dynamic Hyperlinks', 'wp-data-access' ); |
| 1074 |
?> |
| 1075 |
</button> |
| 1076 |
<button type="button" |
| 1077 |
id="wpda_legacy_add_hyperlink_link" |
| 1078 |
class="button button-secondary" |
| 1079 |
> |
| 1080 |
<i class="fas fa-add wpda_icon_on_button"></i> |
| 1081 |
Add Hyperlink |
| 1082 |
</button> |
| 1083 |
<script> |
| 1084 |
jQuery(function() { |
| 1085 |
jQuery('#wpda_legacy_save_hyperlinks').click( function() { |
| 1086 |
return submit_hyperlinks( |
| 1087 |
'legacy', |
| 1088 |
'<?php |
| 1089 |
echo esc_attr( $this->schema_name ); |
| 1090 |
?>', |
| 1091 |
'<?php |
| 1092 |
echo esc_attr( $this->table_name ); |
| 1093 |
?>' |
| 1094 |
); |
| 1095 |
}); |
| 1096 |
|
| 1097 |
jQuery('#wpda_legacy_add_hyperlink_link').click( function() { |
| 1098 |
// Add new row to table |
| 1099 |
jQuery("#wpda_legacy_add_hyperlink_body").append(` |
| 1100 |
<tr> |
| 1101 |
<td> |
| 1102 |
<input data-id="hyperlink_label" |
| 1103 |
class="wpda_action_font" |
| 1104 |
type="text" |
| 1105 |
value="" |
| 1106 |
style="width:100%" |
| 1107 |
/> |
| 1108 |
</td> |
| 1109 |
<td style="text-align:center"> |
| 1110 |
<input data-id="hyperlink_link" |
| 1111 |
class="wpda_action_font" |
| 1112 |
type="checkbox" |
| 1113 |
style="margin-top:7px;" |
| 1114 |
/> |
| 1115 |
</td> |
| 1116 |
<td style="text-align:center"> |
| 1117 |
<input data-id="hyperlink_form" |
| 1118 |
class="wpda_action_font" |
| 1119 |
type="checkbox" |
| 1120 |
style="margin-top:7px;" |
| 1121 |
/> |
| 1122 |
</td> |
| 1123 |
<td style="text-align:center"> |
| 1124 |
<input data-id="hyperlink_target" |
| 1125 |
class="wpda_action_font" |
| 1126 |
type="checkbox" |
| 1127 |
style="margin-top:7px;" |
| 1128 |
/> |
| 1129 |
</td> |
| 1130 |
<td> |
| 1131 |
<textarea data-id="hyperlink_html" |
| 1132 |
rows="5" |
| 1133 |
class="wpda_action_font" |
| 1134 |
style="width:100%;resize:both;" |
| 1135 |
></textarea> |
| 1136 |
</td> |
| 1137 |
<td> |
| 1138 |
<a href="javascript:void(0)" |
| 1139 |
class="dashicons dashicons-trash" |
| 1140 |
style="margin-top:4px;" |
| 1141 |
onclick="if (confirm('<?php |
| 1142 |
/* translators: %s = row containing the hyperlink */ |
| 1143 |
esc_html_e( 'Delete hyperlink %s?', 'wp-data-access' ); |
| 1144 |
?>')) { jQuery(this).closest('tr').remove() }" |
| 1145 |
></a> |
| 1146 |
</td> |
| 1147 |
</tr> |
| 1148 |
`); |
| 1149 |
}); |
| 1150 |
}); |
| 1151 |
</script> |
| 1152 |
</div> |
| 1153 |
</ul> |
| 1154 |
</li> |
| 1155 |
<?php |
| 1156 |
} |
| 1157 |
|
| 1158 |
} |
| 1159 |
|