| 1 |
<?php |
| 2 |
/** |
| 3 |
* Include data param for Wow Plugin |
| 4 |
* |
| 5 |
* @package Wow_Plugin |
| 6 |
* @subpackage Admin/Data_Item |
| 7 |
* @author Dmytro Lobov <d@dayes.dev> |
| 8 |
* @copyright 2019 Wow-Company |
| 9 |
* @license GNU Public License |
| 10 |
* @version 1.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
$act = ( isset( $_REQUEST["act"] ) ) ? sanitize_text_field( $_REQUEST["act"] ) : ''; |
| 18 |
|
| 19 |
|
| 20 |
if ( $act === "update" ) { |
| 21 |
$rec_id = absint( $_REQUEST["id"] ); |
| 22 |
$query = $wpdb->prepare( "SELECT * FROM {$data} WHERE id=%d", absint( $rec_id ) ); |
| 23 |
$result = $wpdb->get_row( $query ); |
| 24 |
if ( $result ) { |
| 25 |
$id = $result->id; |
| 26 |
$title = $result->title; |
| 27 |
$param = unserialize( $result->param ); |
| 28 |
$tool_id = $id; |
| 29 |
$add_action = 2; |
| 30 |
$btn = esc_attr__( 'Update', $this->plugin['text'] ); |
| 31 |
} |
| 32 |
} elseif ( $act === "duplicate" ) { |
| 33 |
$rec_id = absint( $_REQUEST["id"] ); |
| 34 |
$query = $wpdb->prepare( "SELECT * FROM {$data} WHERE id=%d", absint( $rec_id ) ); |
| 35 |
$result = $wpdb->get_row( $query ); |
| 36 |
$id = ""; |
| 37 |
$title = ""; |
| 38 |
$add_action = 1; |
| 39 |
$btn = esc_attr__( 'Save', $this->plugin['text'] ); |
| 40 |
$last = $wpdb->get_col( "SELECT id FROM {$data}" ); |
| 41 |
$tool_id = ! empty( $last ) ? max( $last ) + 1 : 1; |
| 42 |
$param = ( $result ) ? unserialize( $result->param ) : ''; |
| 43 |
|
| 44 |
} else { |
| 45 |
$id = ""; |
| 46 |
$title = ""; |
| 47 |
$last = $wpdb->get_col( "SELECT id FROM {$data}" ); |
| 48 |
$tool_id = ! empty( $last ) ? max( $last ) + 1 : 1; |
| 49 |
$param = ''; |
| 50 |
$add_action = 1; |
| 51 |
$btn = esc_attr__( 'Save', $this->plugin['text'] ); |
| 52 |
} |
| 53 |
|