| @@ -1,49 +1,49 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Include data param for Wow Plugin | |
| 5 | - * | |
| 6 | - * @package Wow_Plugin | |
| 7 | - * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 9 | - * @since 1.0 | |
| 10 | - */ | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | - exit; | |
| 13 | -} | |
| 14 | - | |
| 15 | -$act = ( isset( $_REQUEST["act"] ) ) ? sanitize_text_field( $_REQUEST["act"] ) : ''; | |
| 16 | -if ( $act === "update" ) { | |
| 17 | - $recid = absint( $_REQUEST["id"] ); | |
| 18 | - $sSQL = $wpdb->prepare( "select * from $data WHERE id = %d", $recid ); | |
| 19 | - $result = $wpdb->get_row( $sSQL ); | |
| 20 | - if ( $result ) { | |
| 21 | - $id = $result->id; | |
| 22 | - $title = $result->title; | |
| 23 | - $param = unserialize( $result->param ); | |
| 24 | - $tool_id = $id; | |
| 25 | - $hidval = 2; | |
| 26 | - $btn = __( 'Update', 'wpcoder' ); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | + /** | |
| 4 | + * Include data param for Wow Plugin | |
| 5 | + * | |
| 6 | + * @package Wow_Plugin | |
| 7 | + * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 9 | + * @since 1.0 | |
| 10 | + */ | |
| 11 | + if ( ! defined( 'ABSPATH' ) ) exit; | |
| 12 | + | |
| 13 | + $act = ( isset( $_REQUEST["act"] ) ) ? sanitize_text_field( $_REQUEST["act"] ) : ''; | |
| 14 | + if ($act == "update") { | |
| 15 | + $recid = absint( $_REQUEST["id"] ); | |
| 16 | + $result = $wpdb->get_row("SELECT * FROM $data WHERE id=$recid"); | |
| 17 | + if ($result){ | |
| 18 | + $id = $result->id; | |
| 19 | + $title = $result->title; | |
| 20 | + $param = unserialize( $result->param ); | |
| 21 | + $tool_id = $id; | |
| 22 | + $hidval = 2; | |
| 23 | + $btn = __( 'Update', 'wpcoder' ); | |
| 24 | + } | |
| 27 | 25 | } |
| 28 | -} elseif ( $act === "duplicate" ) { | |
| 29 | - $recid = absint( $_REQUEST["id"] ); | |
| 30 | - $sSQL = $wpdb->prepare( "select * from $data WHERE id = %d", $recid ); | |
| 31 | - $result = $wpdb->get_row( $sSQL ); | |
| 32 | - if ( $result ) { | |
| 33 | - $id = ""; | |
| 34 | - $title = ""; | |
| 35 | - $param = unserialize( $result->param ); | |
| 26 | + else if ($act == "duplicate") { | |
| 27 | + $recid = $_REQUEST["id"]; | |
| 28 | + $result = $wpdb->get_row("SELECT * FROM $data WHERE id=$recid"); | |
| 29 | + if ($result){ | |
| 30 | + $id = ""; | |
| 31 | + $title = ""; | |
| 32 | + $param = unserialize($result->param); | |
| 33 | + $last = $wpdb->get_col( "SELECT id FROM $data" );; | |
| 34 | + $tool_id = max( $last ) + 1; | |
| 35 | + $hidval = 1; | |
| 36 | + $btn = __( 'Save', 'wpcoder' ); | |
| 37 | + } | |
| 38 | + } | |
| 39 | + else { | |
| 40 | + $id = ""; | |
| 41 | + $title = ""; | |
| 36 | 42 | $last = $wpdb->get_col( "SELECT id FROM $data" ); |
| 37 | - $tool_id = max( $last ) + 1; | |
| 38 | - $hidval = 1; | |
| 39 | - $btn = __( 'Save', 'wpcoder' ); | |
| 43 | + $tool_id = !empty($last) ? max( $last ) + 1 : 1; | |
| 44 | + $param = ''; | |
| 45 | + $hidval = 1; | |
| 46 | + $btn = __( 'Save', 'wpcoder' ); | |
| 40 | 47 | } |
| 41 | -} else { | |
| 42 | - $id = ""; | |
| 43 | - $title = ""; | |
| 44 | - $last = $wpdb->get_col( "SELECT id FROM $data" ); | |
| 45 | - $tool_id = ! empty( $last ) ? max( $last ) + 1 : 1; | |
| 46 | - $param = ''; | |
| 47 | - $hidval = 1; | |
| 48 | - $btn = __( 'Save', 'wpcoder' ); | |
| 49 | -} | |
| 48 | + | |
| 49 | +?> | |