PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 4.3
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v4.3
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / includes / class-db.php

class-db.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 4.3, at includes/class-db.php

80 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * DataBase Update
4 *
5 * @package Wow_Plugin
6 * @subpackage Includes/Database
7 * @author Dmytro Lobov <i@lobov.dev>
8 * @copyright 2019 Wow-Company
9 * @license GNU Public License
10 * @version 2.0
11
12 */
13
14 namespace floatingbutton;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Creates and updates a record in the database
22 *
23 * @since 1.0
24 *
25 * @property string plugin_dir - filesystem directory path for the plugin
26 * @property string basedir - URL to the file which saving CSS and JS files
27 */
28 class Wow_DB_Update {
29
30 /**
31 * Create a new Item in the database
32 *
33 * @param string $table name of the datatable
34 * @param string $info array of parameters to save to the database
35 *
36 * @since 1.0
37 */
38 function create_item( $table, $info ) {
39 global $wpdb;
40 $fields = $wpdb->get_col( "DESC " . $table, 0 );
41 // Collect all passed parameters
42 $data = array();
43 foreach ( $fields as $key ) {
44 if ( is_array( $info[ $key ] ) == true ) {
45 $data[ $key ] = serialize( $info[ $key ] );
46 } else {
47 $data[ $key ] = $info[ $key ];
48 }
49 }
50 // Insert in database
51 $wpdb->insert( $table, $data );
52 }
53
54 /**
55 * Update an existing item in the database
56 *
57 * @param string $table name of the datatable
58 * @param string $info array of parameters to save to the database
59 *
60 * @since 1.0
61 */
62 function update_item( $table, $info ) {
63 global $wpdb;
64 $fields = $wpdb->get_col( "DESC " . $table, 0 );
65 // Collect all passed parameters
66 $data = array();
67 foreach ( $fields as $key ) {
68 if ( is_array( $info[ $key ] ) == true ) {
69 $data[ $key ] = serialize( $info[ $key ] );
70 } else {
71 $data[ $key ] = $info[ $key ];
72 }
73 }
74
75 $id = absint( $info["id"] );
76 $wpdb->update( $table, $data, array( 'id' => $id ), $format = null, $where_format = null );
77
78 }
79 }
80