Plugin Directory

Changeset 2520894


Ignore:
Timestamp:
04/24/2021 10:57:30 PM (5 years ago)
Author:
kunalnagar
Message:

Update to version 3.3.0 from GitHub

Location:
custom-404-pro
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • custom-404-pro/tags/3.3.0/admin/AdminClass.php

    r2126034 r2520894  
    140140        global $wpdb;
    141141        if ( is_404() ) {
    142             $sql                     = 'SELECT * FROM ' . $this->helpers->table_options;
     142            $sql                     = 'SELECT * FROM ' . $wpdb->prefix . $this->helpers->table_options;
    143143            $sql_result              = $wpdb->get_results( $sql );
    144144            $row_mode                = $sql_result[0];
     
    182182        }
    183183        $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')";
    185185        $wpdb->query( $sql_save );
    186186        if ( ! empty( $is_email ) ) {
  • custom-404-pro/tags/3.3.0/admin/Helpers.php

    r2113409 r2520894  
    1515    public function __construct() {
    1616        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';
    1919        $this->options_defaults = array();
    2020        $options_defaults_temp  = array(
     
    3535    }
    3636
    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 
    4337    public function print_pretty( $result ) {
    4438        echo '<pre>';
     
    5953        if(current_user_can('administrator')) {
    6054            $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 ';
    6256            foreach ( $this->options_defaults as $key => $option ) {
    6357                if ( $key !== ( $count - 1 ) ) {
     
    7468        global $wpdb;
    7569        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 . "'";
    7771            $result = $wpdb->get_results( $query );
    7872            if ( empty( $result ) ) {
     
    8781        global $wpdb;
    8882        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 . "'";
    9084            $result = $wpdb->get_var( $query );
    9185            return $result;
     
    9791        if(current_user_can('administrator')) {
    9892            $result = $wpdb->insert(
    99                 $this->table_options,
     93                $wpdb->prefix . $this->table_options,
    10094                array(
    10195                    'name'  => $option_name,
     
    111105        if(current_user_can('administrator')) {
    112106            $result = $wpdb->update(
    113                 $this->table_options,
     107                $wpdb->prefix . $this->table_options,
    114108                array( 'value' => $option_value ),
    115109                array( 'name' => $option_name )
     
    134128        global $wpdb;
    135129        if(current_user_can('administrator')) {
    136             $query  = 'SHOW COLUMNS FROM ' . $this->table_logs;
     130            $query  = 'SHOW COLUMNS FROM ' . $wpdb->prefix . $this->table_logs;
    137131            $result = $wpdb->get_results( $query );
    138132            return $result;
     
    163157            $count  = count( $logsData );
    164158            $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';
    166160            foreach ( $logsData as $key => $log ) {
    167161                if ( ! empty( $log->id ) ) {
     
    186180        global $wpdb;
    187181        if(current_user_can('administrator')) {
    188             $query  = 'SELECT * from ' . $this->table_logs;
     182            $query  = 'SELECT * from ' . $wpdb->prefix . $this->table_logs;
    189183            $result = $wpdb->get_results( $query, ARRAY_A );
    190184            return $result;
     
    196190        if(current_user_can('administrator')) {
    197191            if ( $path === 'all' ) {
    198                 $query = 'TRUNCATE TABLE ' . $this->table_logs;
     192                $query = 'TRUNCATE TABLE ' . $wpdb->prefix . $this->table_logs;
    199193            } 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 ) . ')';
    201195            } else {
    202                 $query = 'DELETE FROM ' . $this->table_logs . ' WHERE id=' . $path . '';
     196                $query = 'DELETE FROM ' . $wpdb->prefix . $this->table_logs . ' WHERE id=' . $path . '';
    203197            }
    204198            $result = $wpdb->query( $query );
  • custom-404-pro/tags/3.3.0/admin/LogsClass.php

    r2112484 r2520894  
    3838        $this->_column_headers = array( $columns, $hidden, $sortable );
    3939        $helpers               = Helpers::singleton();
    40         $sql                   = 'SELECT * FROM ' . $helpers->table_logs;
     40        $sql                   = 'SELECT * FROM ' . $wpdb->prefix . $helpers->table_logs;
    4141
    4242        if ( array_key_exists( 'orderby', $_GET ) ) {
  • custom-404-pro/tags/3.3.0/custom-404-pro.php

    r2496450 r2520894  
    55Plugin URI: https://wordpress.org/plugins/custom-404-pro/
    66Description: Override the default 404 page with any page or a custom URL from the Admin Panel.
    7 Version: 3.2.21
     7Version: 3.3.0
    88Author: Kunal Nagar
    99Author URI: https://www.kunalnagar.in
  • custom-404-pro/tags/3.3.0/includes/ActivateClass.php

    r2113409 r2520894  
    33class ActivateClass {
    44
     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
    518    public static function activate() {
    619        global $wpdb;
    720        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            }
    1731        }
    1832    }
     
    2034    public static function create_tables() {
    2135        global $wpdb;
     36        $helpers                = Helpers::singleton();
     37        $table_options = $wpdb->prefix . $helpers->table_options;
     38        $table_logs = $wpdb->prefix . $helpers->table_logs;
    2239        if(current_user_can('administrator')) {
    2340            $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 (
    2642                id mediumint(9) NOT NULL AUTO_INCREMENT,
    2743                ip text,
     
    3349                PRIMARY KEY (id)
    3450            ) $charset_collate;";
    35             $sql_options     = "CREATE TABLE $helpers->table_options (
     51            $sql_options     = "CREATE TABLE $table_options (
    3652                id mediumint(9) NOT NULL AUTO_INCREMENT,
    3753                name text,
  • custom-404-pro/tags/3.3.0/readme.txt

    r2496450 r2520894  
    55Requires at least: 3.0.1
    66Tested up to: 5.7
    7 Stable tag: 3.2.21
     7Stable tag: 3.3.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57
     58= 3.3.0 =
     59* Add Multisite Support
    5760
    5861= 3.2.21 =
  • custom-404-pro/trunk/admin/AdminClass.php

    r2126034 r2520894  
    140140        global $wpdb;
    141141        if ( is_404() ) {
    142             $sql                     = 'SELECT * FROM ' . $this->helpers->table_options;
     142            $sql                     = 'SELECT * FROM ' . $wpdb->prefix . $this->helpers->table_options;
    143143            $sql_result              = $wpdb->get_results( $sql );
    144144            $row_mode                = $sql_result[0];
     
    182182        }
    183183        $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')";
    185185        $wpdb->query( $sql_save );
    186186        if ( ! empty( $is_email ) ) {
  • custom-404-pro/trunk/admin/Helpers.php

    r2113409 r2520894  
    1515    public function __construct() {
    1616        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';
    1919        $this->options_defaults = array();
    2020        $options_defaults_temp  = array(
     
    3535    }
    3636
    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 
    4337    public function print_pretty( $result ) {
    4438        echo '<pre>';
     
    5953        if(current_user_can('administrator')) {
    6054            $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 ';
    6256            foreach ( $this->options_defaults as $key => $option ) {
    6357                if ( $key !== ( $count - 1 ) ) {
     
    7468        global $wpdb;
    7569        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 . "'";
    7771            $result = $wpdb->get_results( $query );
    7872            if ( empty( $result ) ) {
     
    8781        global $wpdb;
    8882        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 . "'";
    9084            $result = $wpdb->get_var( $query );
    9185            return $result;
     
    9791        if(current_user_can('administrator')) {
    9892            $result = $wpdb->insert(
    99                 $this->table_options,
     93                $wpdb->prefix . $this->table_options,
    10094                array(
    10195                    'name'  => $option_name,
     
    111105        if(current_user_can('administrator')) {
    112106            $result = $wpdb->update(
    113                 $this->table_options,
     107                $wpdb->prefix . $this->table_options,
    114108                array( 'value' => $option_value ),
    115109                array( 'name' => $option_name )
     
    134128        global $wpdb;
    135129        if(current_user_can('administrator')) {
    136             $query  = 'SHOW COLUMNS FROM ' . $this->table_logs;
     130            $query  = 'SHOW COLUMNS FROM ' . $wpdb->prefix . $this->table_logs;
    137131            $result = $wpdb->get_results( $query );
    138132            return $result;
     
    163157            $count  = count( $logsData );
    164158            $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';
    166160            foreach ( $logsData as $key => $log ) {
    167161                if ( ! empty( $log->id ) ) {
     
    186180        global $wpdb;
    187181        if(current_user_can('administrator')) {
    188             $query  = 'SELECT * from ' . $this->table_logs;
     182            $query  = 'SELECT * from ' . $wpdb->prefix . $this->table_logs;
    189183            $result = $wpdb->get_results( $query, ARRAY_A );
    190184            return $result;
     
    196190        if(current_user_can('administrator')) {
    197191            if ( $path === 'all' ) {
    198                 $query = 'TRUNCATE TABLE ' . $this->table_logs;
     192                $query = 'TRUNCATE TABLE ' . $wpdb->prefix . $this->table_logs;
    199193            } 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 ) . ')';
    201195            } else {
    202                 $query = 'DELETE FROM ' . $this->table_logs . ' WHERE id=' . $path . '';
     196                $query = 'DELETE FROM ' . $wpdb->prefix . $this->table_logs . ' WHERE id=' . $path . '';
    203197            }
    204198            $result = $wpdb->query( $query );
  • custom-404-pro/trunk/admin/LogsClass.php

    r2112484 r2520894  
    3838        $this->_column_headers = array( $columns, $hidden, $sortable );
    3939        $helpers               = Helpers::singleton();
    40         $sql                   = 'SELECT * FROM ' . $helpers->table_logs;
     40        $sql                   = 'SELECT * FROM ' . $wpdb->prefix . $helpers->table_logs;
    4141
    4242        if ( array_key_exists( 'orderby', $_GET ) ) {
  • custom-404-pro/trunk/custom-404-pro.php

    r2496450 r2520894  
    55Plugin URI: https://wordpress.org/plugins/custom-404-pro/
    66Description: Override the default 404 page with any page or a custom URL from the Admin Panel.
    7 Version: 3.2.21
     7Version: 3.3.0
    88Author: Kunal Nagar
    99Author URI: https://www.kunalnagar.in
  • custom-404-pro/trunk/includes/ActivateClass.php

    r2113409 r2520894  
    33class ActivateClass {
    44
     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
    518    public static function activate() {
    619        global $wpdb;
    720        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            }
    1731        }
    1832    }
     
    2034    public static function create_tables() {
    2135        global $wpdb;
     36        $helpers                = Helpers::singleton();
     37        $table_options = $wpdb->prefix . $helpers->table_options;
     38        $table_logs = $wpdb->prefix . $helpers->table_logs;
    2239        if(current_user_can('administrator')) {
    2340            $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 (
    2642                id mediumint(9) NOT NULL AUTO_INCREMENT,
    2743                ip text,
     
    3349                PRIMARY KEY (id)
    3450            ) $charset_collate;";
    35             $sql_options     = "CREATE TABLE $helpers->table_options (
     51            $sql_options     = "CREATE TABLE $table_options (
    3652                id mediumint(9) NOT NULL AUTO_INCREMENT,
    3753                name text,
  • custom-404-pro/trunk/readme.txt

    r2496450 r2520894  
    55Requires at least: 3.0.1
    66Tested up to: 5.7
    7 Stable tag: 3.2.21
     7Stable tag: 3.3.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57
     58= 3.3.0 =
     59* Add Multisite Support
    5760
    5861= 3.2.21 =
Note: See TracChangeset for help on using the changeset viewer.