Changeset 2520894
- Timestamp:
- 04/24/2021 10:57:30 PM (5 years ago)
- Location:
- custom-404-pro
- Files:
-
- 12 edited
- 1 copied
-
tags/3.3.0 (copied) (copied from custom-404-pro/trunk)
-
tags/3.3.0/admin/AdminClass.php (modified) (2 diffs)
-
tags/3.3.0/admin/Helpers.php (modified) (11 diffs)
-
tags/3.3.0/admin/LogsClass.php (modified) (1 diff)
-
tags/3.3.0/custom-404-pro.php (modified) (1 diff)
-
tags/3.3.0/includes/ActivateClass.php (modified) (3 diffs)
-
tags/3.3.0/readme.txt (modified) (2 diffs)
-
trunk/admin/AdminClass.php (modified) (2 diffs)
-
trunk/admin/Helpers.php (modified) (11 diffs)
-
trunk/admin/LogsClass.php (modified) (1 diff)
-
trunk/custom-404-pro.php (modified) (1 diff)
-
trunk/includes/ActivateClass.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-404-pro/tags/3.3.0/admin/AdminClass.php
r2126034 r2520894 140 140 global $wpdb; 141 141 if ( is_404() ) { 142 $sql = 'SELECT * FROM ' . $ this->helpers->table_options;142 $sql = 'SELECT * FROM ' . $wpdb->prefix . $this->helpers->table_options; 143 143 $sql_result = $wpdb->get_results( $sql ); 144 144 $row_mode = $sql_result[0]; … … 182 182 } 183 183 $user_agent = $_SERVER['HTTP_USER_AGENT']; 184 $sql_save = 'INSERT INTO ' . $ this->helpers->table_logs . " (ip, path, referer, user_agent) VALUES ('$ip', '$path', '$referer', '$user_agent')";184 $sql_save = 'INSERT INTO ' . $wpdb->prefix . $this->helpers->table_logs . " (ip, path, referer, user_agent) VALUES ('$ip', '$path', '$referer', '$user_agent')"; 185 185 $wpdb->query( $sql_save ); 186 186 if ( ! empty( $is_email ) ) { -
custom-404-pro/tags/3.3.0/admin/Helpers.php
r2113409 r2520894 15 15 public function __construct() { 16 16 global $wpdb; 17 $this->table_options = $wpdb->prefix .'custom_404_pro_options';18 $this->table_logs = $wpdb->prefix .'custom_404_pro_logs';17 $this->table_options = 'custom_404_pro_options'; 18 $this->table_logs = 'custom_404_pro_logs'; 19 19 $this->options_defaults = array(); 20 20 $options_defaults_temp = array( … … 35 35 } 36 36 37 // public function plugin_data() {38 // $plugin_main_file = dirname(__FILE__) . '/custom-404-pro/custom-404-pro.php';39 // $plugin_data = get_plugin_data($plugin_main_file);40 // return $plugin_data;41 // }42 43 37 public function print_pretty( $result ) { 44 38 echo '<pre>'; … … 59 53 if(current_user_can('administrator')) { 60 54 $count = count( $this->options_defaults ); 61 $sql = 'INSERT INTO ' . $ this->table_options . ' (name, value) VALUES ';55 $sql = 'INSERT INTO ' . $wpdb->prefix . $this->table_options . ' (name, value) VALUES '; 62 56 foreach ( $this->options_defaults as $key => $option ) { 63 57 if ( $key !== ( $count - 1 ) ) { … … 74 68 global $wpdb; 75 69 if(current_user_can('administrator')) { 76 $query = 'SELECT * FROM ' . $ this->table_options . " WHERE name='" . $option_name . "'";70 $query = 'SELECT * FROM ' . $wpdb->prefix . $this->table_options . " WHERE name='" . $option_name . "'"; 77 71 $result = $wpdb->get_results( $query ); 78 72 if ( empty( $result ) ) { … … 87 81 global $wpdb; 88 82 if(current_user_can('administrator')) { 89 $query = 'SELECT value FROM ' . $ this->table_options . " WHERE name='" . $option_name . "'";83 $query = 'SELECT value FROM ' . $wpdb->prefix . $this->table_options . " WHERE name='" . $option_name . "'"; 90 84 $result = $wpdb->get_var( $query ); 91 85 return $result; … … 97 91 if(current_user_can('administrator')) { 98 92 $result = $wpdb->insert( 99 $ this->table_options,93 $wpdb->prefix . $this->table_options, 100 94 array( 101 95 'name' => $option_name, … … 111 105 if(current_user_can('administrator')) { 112 106 $result = $wpdb->update( 113 $ this->table_options,107 $wpdb->prefix . $this->table_options, 114 108 array( 'value' => $option_value ), 115 109 array( 'name' => $option_name ) … … 134 128 global $wpdb; 135 129 if(current_user_can('administrator')) { 136 $query = 'SHOW COLUMNS FROM ' . $ this->table_logs;130 $query = 'SHOW COLUMNS FROM ' . $wpdb->prefix . $this->table_logs; 137 131 $result = $wpdb->get_results( $query ); 138 132 return $result; … … 163 157 $count = count( $logsData ); 164 158 $logIDs = []; 165 $query = 'INSERT INTO ' . $ this->table_logs . ' (ip, path, referer, user_agent) VALUES';159 $query = 'INSERT INTO ' . $wpdb->prefix . $this->table_logs . ' (ip, path, referer, user_agent) VALUES'; 166 160 foreach ( $logsData as $key => $log ) { 167 161 if ( ! empty( $log->id ) ) { … … 186 180 global $wpdb; 187 181 if(current_user_can('administrator')) { 188 $query = 'SELECT * from ' . $ this->table_logs;182 $query = 'SELECT * from ' . $wpdb->prefix . $this->table_logs; 189 183 $result = $wpdb->get_results( $query, ARRAY_A ); 190 184 return $result; … … 196 190 if(current_user_can('administrator')) { 197 191 if ( $path === 'all' ) { 198 $query = 'TRUNCATE TABLE ' . $ this->table_logs;192 $query = 'TRUNCATE TABLE ' . $wpdb->prefix . $this->table_logs; 199 193 } elseif ( is_array( $path ) ) { 200 $query = 'DELETE FROM ' . $ this->table_logs . ' WHERE id in (' . implode( ',', $path ) . ')';194 $query = 'DELETE FROM ' . $wpdb->prefix . $this->table_logs . ' WHERE id in (' . implode( ',', $path ) . ')'; 201 195 } else { 202 $query = 'DELETE FROM ' . $ this->table_logs . ' WHERE id=' . $path . '';196 $query = 'DELETE FROM ' . $wpdb->prefix . $this->table_logs . ' WHERE id=' . $path . ''; 203 197 } 204 198 $result = $wpdb->query( $query ); -
custom-404-pro/tags/3.3.0/admin/LogsClass.php
r2112484 r2520894 38 38 $this->_column_headers = array( $columns, $hidden, $sortable ); 39 39 $helpers = Helpers::singleton(); 40 $sql = 'SELECT * FROM ' . $ helpers->table_logs;40 $sql = 'SELECT * FROM ' . $wpdb->prefix . $helpers->table_logs; 41 41 42 42 if ( array_key_exists( 'orderby', $_GET ) ) { -
custom-404-pro/tags/3.3.0/custom-404-pro.php
r2496450 r2520894 5 5 Plugin URI: https://wordpress.org/plugins/custom-404-pro/ 6 6 Description: Override the default 404 page with any page or a custom URL from the Admin Panel. 7 Version: 3. 2.217 Version: 3.3.0 8 8 Author: Kunal Nagar 9 9 Author URI: https://www.kunalnagar.in -
custom-404-pro/tags/3.3.0/includes/ActivateClass.php
r2113409 r2520894 3 3 class ActivateClass { 4 4 5 static function _activate() { 6 global $wpdb; 7 $helpers = Helpers::singleton(); 8 $is_table_options_query = "SHOW TABLES LIKE '" . $wpdb->prefix . $helpers->table_options . "';"; 9 $is_table_logs_query = "SHOW TABLES LIKE '" . $wpdb->prefix . $helpers->table_logs . "';"; 10 $is_table_options = $wpdb->query( $is_table_options_query ); 11 $is_table_logs = $wpdb->query( $is_table_logs_query ); 12 if ( empty( $is_table_options ) && empty( $is_table_logs ) ) { 13 self::create_tables(); 14 self::initialize_options(); 15 } 16 } 17 5 18 public static function activate() { 6 19 global $wpdb; 7 20 if(current_user_can('administrator')) { 8 $helpers = Helpers::singleton(); 9 $is_table_options_query = "SHOW TABLES LIKE '" . $helpers->table_options . "';"; 10 $is_table_logs_query = "SHOW TABLES LIKE '" . $helpers->table_logs . "';"; 11 $is_table_options = $wpdb->query( $is_table_options_query ); 12 $is_table_logs = $wpdb->query( $is_table_logs_query ); 13 if ( empty( $is_table_options ) && empty( $is_table_logs ) ) { 14 self::create_tables(); 15 self::initialize_options(); 16 } 21 if(is_multisite()) { 22 $sites = get_sites(['fields'=>'ids']); 23 foreach ($sites as $blog_id) { 24 switch_to_blog($blog_id); 25 self::_activate(); 26 restore_current_blog(); 27 } 28 } else { 29 self::_activate(); 30 } 17 31 } 18 32 } … … 20 34 public static function create_tables() { 21 35 global $wpdb; 36 $helpers = Helpers::singleton(); 37 $table_options = $wpdb->prefix . $helpers->table_options; 38 $table_logs = $wpdb->prefix . $helpers->table_logs; 22 39 if(current_user_can('administrator')) { 23 40 $charset_collate = $wpdb->get_charset_collate(); 24 $helpers = Helpers::singleton(); 25 $sql_logs = "CREATE TABLE $helpers->table_logs ( 41 $sql_logs = "CREATE TABLE $table_logs ( 26 42 id mediumint(9) NOT NULL AUTO_INCREMENT, 27 43 ip text, … … 33 49 PRIMARY KEY (id) 34 50 ) $charset_collate;"; 35 $sql_options = "CREATE TABLE $ helpers->table_options (51 $sql_options = "CREATE TABLE $table_options ( 36 52 id mediumint(9) NOT NULL AUTO_INCREMENT, 37 53 name text, -
custom-404-pro/tags/3.3.0/readme.txt
r2496450 r2520894 5 5 Requires at least: 3.0.1 6 6 Tested up to: 5.7 7 Stable tag: 3. 2.217 Stable tag: 3.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 55 55 56 56 == Changelog == 57 58 = 3.3.0 = 59 * Add Multisite Support 57 60 58 61 = 3.2.21 = -
custom-404-pro/trunk/admin/AdminClass.php
r2126034 r2520894 140 140 global $wpdb; 141 141 if ( is_404() ) { 142 $sql = 'SELECT * FROM ' . $ this->helpers->table_options;142 $sql = 'SELECT * FROM ' . $wpdb->prefix . $this->helpers->table_options; 143 143 $sql_result = $wpdb->get_results( $sql ); 144 144 $row_mode = $sql_result[0]; … … 182 182 } 183 183 $user_agent = $_SERVER['HTTP_USER_AGENT']; 184 $sql_save = 'INSERT INTO ' . $ this->helpers->table_logs . " (ip, path, referer, user_agent) VALUES ('$ip', '$path', '$referer', '$user_agent')";184 $sql_save = 'INSERT INTO ' . $wpdb->prefix . $this->helpers->table_logs . " (ip, path, referer, user_agent) VALUES ('$ip', '$path', '$referer', '$user_agent')"; 185 185 $wpdb->query( $sql_save ); 186 186 if ( ! empty( $is_email ) ) { -
custom-404-pro/trunk/admin/Helpers.php
r2113409 r2520894 15 15 public function __construct() { 16 16 global $wpdb; 17 $this->table_options = $wpdb->prefix .'custom_404_pro_options';18 $this->table_logs = $wpdb->prefix .'custom_404_pro_logs';17 $this->table_options = 'custom_404_pro_options'; 18 $this->table_logs = 'custom_404_pro_logs'; 19 19 $this->options_defaults = array(); 20 20 $options_defaults_temp = array( … … 35 35 } 36 36 37 // public function plugin_data() {38 // $plugin_main_file = dirname(__FILE__) . '/custom-404-pro/custom-404-pro.php';39 // $plugin_data = get_plugin_data($plugin_main_file);40 // return $plugin_data;41 // }42 43 37 public function print_pretty( $result ) { 44 38 echo '<pre>'; … … 59 53 if(current_user_can('administrator')) { 60 54 $count = count( $this->options_defaults ); 61 $sql = 'INSERT INTO ' . $ this->table_options . ' (name, value) VALUES ';55 $sql = 'INSERT INTO ' . $wpdb->prefix . $this->table_options . ' (name, value) VALUES '; 62 56 foreach ( $this->options_defaults as $key => $option ) { 63 57 if ( $key !== ( $count - 1 ) ) { … … 74 68 global $wpdb; 75 69 if(current_user_can('administrator')) { 76 $query = 'SELECT * FROM ' . $ this->table_options . " WHERE name='" . $option_name . "'";70 $query = 'SELECT * FROM ' . $wpdb->prefix . $this->table_options . " WHERE name='" . $option_name . "'"; 77 71 $result = $wpdb->get_results( $query ); 78 72 if ( empty( $result ) ) { … … 87 81 global $wpdb; 88 82 if(current_user_can('administrator')) { 89 $query = 'SELECT value FROM ' . $ this->table_options . " WHERE name='" . $option_name . "'";83 $query = 'SELECT value FROM ' . $wpdb->prefix . $this->table_options . " WHERE name='" . $option_name . "'"; 90 84 $result = $wpdb->get_var( $query ); 91 85 return $result; … … 97 91 if(current_user_can('administrator')) { 98 92 $result = $wpdb->insert( 99 $ this->table_options,93 $wpdb->prefix . $this->table_options, 100 94 array( 101 95 'name' => $option_name, … … 111 105 if(current_user_can('administrator')) { 112 106 $result = $wpdb->update( 113 $ this->table_options,107 $wpdb->prefix . $this->table_options, 114 108 array( 'value' => $option_value ), 115 109 array( 'name' => $option_name ) … … 134 128 global $wpdb; 135 129 if(current_user_can('administrator')) { 136 $query = 'SHOW COLUMNS FROM ' . $ this->table_logs;130 $query = 'SHOW COLUMNS FROM ' . $wpdb->prefix . $this->table_logs; 137 131 $result = $wpdb->get_results( $query ); 138 132 return $result; … … 163 157 $count = count( $logsData ); 164 158 $logIDs = []; 165 $query = 'INSERT INTO ' . $ this->table_logs . ' (ip, path, referer, user_agent) VALUES';159 $query = 'INSERT INTO ' . $wpdb->prefix . $this->table_logs . ' (ip, path, referer, user_agent) VALUES'; 166 160 foreach ( $logsData as $key => $log ) { 167 161 if ( ! empty( $log->id ) ) { … … 186 180 global $wpdb; 187 181 if(current_user_can('administrator')) { 188 $query = 'SELECT * from ' . $ this->table_logs;182 $query = 'SELECT * from ' . $wpdb->prefix . $this->table_logs; 189 183 $result = $wpdb->get_results( $query, ARRAY_A ); 190 184 return $result; … … 196 190 if(current_user_can('administrator')) { 197 191 if ( $path === 'all' ) { 198 $query = 'TRUNCATE TABLE ' . $ this->table_logs;192 $query = 'TRUNCATE TABLE ' . $wpdb->prefix . $this->table_logs; 199 193 } elseif ( is_array( $path ) ) { 200 $query = 'DELETE FROM ' . $ this->table_logs . ' WHERE id in (' . implode( ',', $path ) . ')';194 $query = 'DELETE FROM ' . $wpdb->prefix . $this->table_logs . ' WHERE id in (' . implode( ',', $path ) . ')'; 201 195 } else { 202 $query = 'DELETE FROM ' . $ this->table_logs . ' WHERE id=' . $path . '';196 $query = 'DELETE FROM ' . $wpdb->prefix . $this->table_logs . ' WHERE id=' . $path . ''; 203 197 } 204 198 $result = $wpdb->query( $query ); -
custom-404-pro/trunk/admin/LogsClass.php
r2112484 r2520894 38 38 $this->_column_headers = array( $columns, $hidden, $sortable ); 39 39 $helpers = Helpers::singleton(); 40 $sql = 'SELECT * FROM ' . $ helpers->table_logs;40 $sql = 'SELECT * FROM ' . $wpdb->prefix . $helpers->table_logs; 41 41 42 42 if ( array_key_exists( 'orderby', $_GET ) ) { -
custom-404-pro/trunk/custom-404-pro.php
r2496450 r2520894 5 5 Plugin URI: https://wordpress.org/plugins/custom-404-pro/ 6 6 Description: Override the default 404 page with any page or a custom URL from the Admin Panel. 7 Version: 3. 2.217 Version: 3.3.0 8 8 Author: Kunal Nagar 9 9 Author URI: https://www.kunalnagar.in -
custom-404-pro/trunk/includes/ActivateClass.php
r2113409 r2520894 3 3 class ActivateClass { 4 4 5 static function _activate() { 6 global $wpdb; 7 $helpers = Helpers::singleton(); 8 $is_table_options_query = "SHOW TABLES LIKE '" . $wpdb->prefix . $helpers->table_options . "';"; 9 $is_table_logs_query = "SHOW TABLES LIKE '" . $wpdb->prefix . $helpers->table_logs . "';"; 10 $is_table_options = $wpdb->query( $is_table_options_query ); 11 $is_table_logs = $wpdb->query( $is_table_logs_query ); 12 if ( empty( $is_table_options ) && empty( $is_table_logs ) ) { 13 self::create_tables(); 14 self::initialize_options(); 15 } 16 } 17 5 18 public static function activate() { 6 19 global $wpdb; 7 20 if(current_user_can('administrator')) { 8 $helpers = Helpers::singleton(); 9 $is_table_options_query = "SHOW TABLES LIKE '" . $helpers->table_options . "';"; 10 $is_table_logs_query = "SHOW TABLES LIKE '" . $helpers->table_logs . "';"; 11 $is_table_options = $wpdb->query( $is_table_options_query ); 12 $is_table_logs = $wpdb->query( $is_table_logs_query ); 13 if ( empty( $is_table_options ) && empty( $is_table_logs ) ) { 14 self::create_tables(); 15 self::initialize_options(); 16 } 21 if(is_multisite()) { 22 $sites = get_sites(['fields'=>'ids']); 23 foreach ($sites as $blog_id) { 24 switch_to_blog($blog_id); 25 self::_activate(); 26 restore_current_blog(); 27 } 28 } else { 29 self::_activate(); 30 } 17 31 } 18 32 } … … 20 34 public static function create_tables() { 21 35 global $wpdb; 36 $helpers = Helpers::singleton(); 37 $table_options = $wpdb->prefix . $helpers->table_options; 38 $table_logs = $wpdb->prefix . $helpers->table_logs; 22 39 if(current_user_can('administrator')) { 23 40 $charset_collate = $wpdb->get_charset_collate(); 24 $helpers = Helpers::singleton(); 25 $sql_logs = "CREATE TABLE $helpers->table_logs ( 41 $sql_logs = "CREATE TABLE $table_logs ( 26 42 id mediumint(9) NOT NULL AUTO_INCREMENT, 27 43 ip text, … … 33 49 PRIMARY KEY (id) 34 50 ) $charset_collate;"; 35 $sql_options = "CREATE TABLE $ helpers->table_options (51 $sql_options = "CREATE TABLE $table_options ( 36 52 id mediumint(9) NOT NULL AUTO_INCREMENT, 37 53 name text, -
custom-404-pro/trunk/readme.txt
r2496450 r2520894 5 5 Requires at least: 3.0.1 6 6 Tested up to: 5.7 7 Stable tag: 3. 2.217 Stable tag: 3.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 55 55 56 56 == Changelog == 57 58 = 3.3.0 = 59 * Add Multisite Support 57 60 58 61 = 3.2.21 =
Note: See TracChangeset
for help on using the changeset viewer.