PluginProbe ʕ •ᴥ•ʔ
Advanced 301 and 302 Redirect / 1.7.0
Advanced 301 and 302 Redirect v1.7.0
1.7.0 trunk 1.0.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.9 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.6.7 1.6.8 1.6.9
advanced-301-and-302-redirect / include / install.php
advanced-301-and-302-redirect / include Last commit date
functions.php 4 weeks ago install.php 4 weeks ago main-page.php 4 weeks ago redirect-page.php 4 weeks ago script.php 4 weeks ago secondary-page.php 4 weeks ago settings.php 4 weeks ago style.php 4 weeks ago
install.php
98 lines
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <?php
3
4 global $wpdb;
5
6 $charset_collate = $wpdb->get_charset_collate();
7 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); // Require to use dbDelta
8 include('settings.php'); // Load the files to get the databse info
9
10 if( $wpdb->get_var("SHOW TABLES LIKE '{$yydev_redirect_table_name}' ") != $yydev_redirect_table_name ) {
11 // The table we want to create doesn't exists
12
13 $sql = "CREATE TABLE " . $yydev_redirect_table_name . "(
14 id INTEGER(11) UNSIGNED AUTO_INCREMENT,
15 name VARCHAR (500),
16 slug VARCHAR (500),
17 PRIMARY KEY (id)
18 ) $charset_collate;";
19
20 dbDelta($sql);
21
22
23 } // if( $wpdb->get_var("SHOW TABLES LIKE '{$yydev_redirect_table_name}' ") != $yydev_redirect_table_name ) {
24
25
26
27 // Creating the secondary database table
28
29 if( $wpdb->get_var("SHOW TABLES LIKE '{$yydev_secondary_table_name}' ") != $yydev_secondary_table_name ) {
30 // The table we want to create doesn't exists
31
32 $sql = "CREATE TABLE " . $yydev_secondary_table_name . "(
33 id INTEGER(11) UNSIGNED AUTO_INCREMENT,
34 secondary_id INTEGER (11),
35 position FLOAT,
36 request_url TEXT,
37 destination_url TEXT,
38 redirect_type INTEGER,
39 advertising_platform TEXT,
40 redirects_amount INTEGER NOT NULL,
41 strtotime INTEGER (10),
42 redirect_query TEXT,
43 get_parameters TINYINT(1),
44 PRIMARY KEY (id)
45 ) $charset_collate;";
46
47 dbDelta($sql);
48
49
50 } // if( $wpdb->get_var("SHOW TABLES LIKE '{$yydev_secondary_table_name}' ") != $yydev_secondary_table_name ) {
51
52
53 // if the plugin change version and require to add database fields
54 if( isset($yydev_redirect_database_update ) ) {
55
56 // ============================================================
57 // Dealing with the plugin database updates for new versions
58 // ============================================================
59
60 // creating an array with all the columns from the database
61 $existing_columns = $wpdb->get_col("DESC {$yydev_secondary_table_name}", 0);
62
63
64 if($existing_columns) {
65
66 // -------------------------------------------------------------
67 // update the database for plugin version 1.1
68 // -------------------------------------------------------------
69
70 $new_db_column = 'strtotime';
71 if( !in_array($new_db_column, $existing_columns) ) {
72 // create the date column on the database
73 $wpdb->query("ALTER TABLE $yydev_secondary_table_name ADD $new_db_column INTEGER (10) NOT NULL");
74 } // if( in_array($new_db_column, $existing_columns) ) {
75
76 // -------------------------------------------------------------
77 // update the database for plugin version 1.2
78 // -------------------------------------------------------------
79
80 $new_db_column = 'redirect_query';
81 if( !in_array($new_db_column, $existing_columns) ) {
82 // create the date column on the database
83 $wpdb->query("ALTER TABLE $yydev_secondary_table_name ADD $new_db_column TEXT NOT NULL");
84 } // if( in_array($new_db_column, $existing_columns) ) {
85
86 // -------------------------------------------------------------
87 // update the database for plugin version 1.5
88 // -------------------------------------------------------------
89
90 $new_db_column = 'get_parameters';
91 if( !in_array($new_db_column, $existing_columns) ) {
92 // create the date column on the database
93 $wpdb->query("ALTER TABLE $yydev_secondary_table_name ADD $new_db_column TINYINT(1) NOT NULL");
94 } // if( in_array($new_db_column, $existing_columns) ) {
95
96 } // if($existing_columns) {
97
98 } // if( isset($yydev_redirect_database_update ) ) {