PluginProbe
Statify / 1.6.3
Statify v1.6.3
2.0.2 2.0.1 trunk 0.7 0.8 0.9 1.0 1.2.8 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 All 32 releases
statify / inc / class-statify-table.php

class-statify-table.php in Statify 1.6.3, at inc/class-statify-table.php

91 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Statify: Statify_Table class
4 *
5 * This file contains class for the plugin's DB table handling.
6 *
7 * @package Statify
8 * @since 0.6
9 */
10
11 // Quit if accessed outside WP context.
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Statify Table
16 *
17 * @since 0.6
18 */
19 class Statify_Table {
20
21 /**
22 * Definition of the custom table.
23 *
24 * @since 0.6.0
25 * @version 1.2.4
26 */
27 public static function init() {
28
29 // Global.
30 global $wpdb;
31
32 // Name.
33 $table = 'statify';
34
35 // As array.
36 $wpdb->tables[] = $table;
37
38 // With prefix.
39 $wpdb->$table = $wpdb->get_blog_prefix() . $table;
40 }
41
42
43 /**
44 * Create the table.
45 *
46 * @since 0.6.0
47 * @version 1.2.4
48 */
49 public static function create() {
50
51 global $wpdb;
52
53 // If existent.
54 if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->statify'" ) === $wpdb->statify ) {
55 return;
56 }
57
58 // Include.
59 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
60
61 // Create.
62 dbDelta(
63 "CREATE TABLE `$wpdb->statify` (
64 `id` bigint(20) unsigned NOT NULL auto_increment,
65 `created` date NOT NULL default '0000-00-00',
66 `referrer` varchar(255) NOT NULL default '',
67 `target` varchar(255) NOT NULL default '',
68 PRIMARY KEY (`id`),
69 KEY `referrer` (`referrer`),
70 KEY `target` (`target`),
71 KEY `created` (`created`)
72 );"
73 );
74 }
75
76
77 /**
78 * Remove the custom table.
79 *
80 * @since 0.6.0
81 * @version 1.2.4
82 */
83 public static function drop() {
84
85 global $wpdb;
86
87 // Remove.
88 $wpdb->query( "DROP TABLE IF EXISTS `$wpdb->statify`" );
89 }
90 }
91