| @@ -1,28 +1,33 @@ | ||
| 1 | -<?php | |
| 2 | - /** | |
| 3 | - * Database Result | |
| 4 | - * | |
| 5 | - * @package Wow Plugin | |
| 6 | - * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 7 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 8 | - * @since 1.0 | |
| 9 | - */ | |
| 10 | - | |
| 11 | - if ( ! defined( 'ABSPATH' ) ) exit; | |
| 12 | - global $wpdb; | |
| 13 | - $data = $wpdb->prefix . 'wow_' . $this->plugin_pref; | |
| 14 | - $info = ( isset( $_REQUEST['info'] ) ) ? sanitize_text_field( $_REQUEST['info'] ) : ''; | |
| 15 | - if ( $info == 'saved' ) { | |
| 16 | - echo '<div class="updated" id="message"><p><strong>' . __( 'Record Added', 'wpcoder' ) . '</strong>.</p></div>'; | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Database Result | |
| 4 | + * | |
| 5 | + * @package Wow Plugin | |
| 6 | + * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 7 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 8 | + * @since 1.0 | |
| 9 | + */ | |
| 10 | + | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | +global $wpdb; | |
| 15 | +$data = $wpdb->prefix . 'wow_' . $this->plugin_pref; | |
| 16 | +$info = ( isset( $_REQUEST['info'] ) ) ? sanitize_text_field( $_REQUEST['info'] ) : ''; | |
| 17 | +if ( $info === 'saved' ) { | |
| 18 | + echo '<div class="updated" id="message"><p><strong>' . esc_html__( 'Record Added', 'wpcoder' ) . '</strong>.</p></div>'; | |
| 19 | +} elseif ( $info === 'update' ) { | |
| 20 | + echo '<div class="updated" id="message"><p><strong>' . esc_html__( 'Record Updated', 'wpcoder' ) . '</strong>.</p></div>'; | |
| 21 | +} elseif ( $info === 'del' ) { | |
| 22 | + $del_id = absint( $_GET['did'] ); | |
| 23 | + $page = ( isset( $_REQUEST['page'] ) ) ? sanitize_text_field( $_REQUEST['page'] ) : ''; | |
| 24 | + $page_tool = explode( '-', $page ); | |
| 25 | + | |
| 26 | + if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'wp_coder_nonce' ) ) { | |
| 27 | + $delete = $wpdb->delete( $data, array( 'ID' => $del_id ), array( '%d' ) ); | |
| 28 | + if ( absint( $delete ) > 0 ) { | |
| 29 | + echo '<div class="updated" id="message"><p><strong>' . esc_html__( 'Record Deleted', 'wpcoder' ) . '</strong>.</p></div>'; | |
| 30 | + } | |
| 17 | 31 | } |
| 18 | - elseif ( $info == 'update' ) { | |
| 19 | - echo '<div class="updated" id="message"><p><strong>' . __( 'Record Updated', 'wpcoder' ) . '</strong>.</p></div>'; | |
| 20 | - } | |
| 21 | - elseif ( $info == 'del' ) { | |
| 22 | - $delid = absint( $_GET['did'] ); | |
| 23 | - $page = ( isset( $_REQUEST['page'] ) ) ? sanitize_text_field( $_REQUEST['page'] ) : ''; | |
| 24 | - $page_tool = explode('-', $page); | |
| 25 | - $wpdb->query( 'delete from ' . $data . ' where id=' . $delid ); | |
| 26 | - echo '<div class="updated" id="message"><p><strong>' . __( 'Record Deleted', 'wpcoder' ) . '</strong>.</p></div>'; | |
| 27 | - } | |
| 32 | +} | |
| 28 | 33 | $resultat = $wpdb->get_results( 'SELECT * FROM ' . $data . ' order by id asc' ); |