Plugin Directory

Changeset 1699501


Ignore:
Timestamp:
07/20/2017 09:49:33 AM (9 years ago)
Author:
pukhrajp
Message:

Fixed installation and wordpress bugs.
Updated chatbull files.

Location:
wp-chatbull
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • wp-chatbull/tags/1.0/admin/js/wpcbcp-settings.js

    r1688359 r1699501  
    9999
    100100            var data = {
    101                 action: 'install_plugin',
     101                action: 'wpcbcp_install_plugin',
    102102                settings: $scope.settings
    103103            }
     
    125125
    126126            var data = {
    127                 action: 'check_n_save',
     127                action: 'wpcbcp_check_n_save',
    128128                settings: $scope.settings
    129129            }
     
    149149           
    150150            var data = {
    151                 action: 'chack_status',
     151                action: 'wpcbcp_chack_status',
    152152                settings: $scope.settings
    153153            }
     
    179179
    180180            var data = {
    181                 action: 'save_settings',
     181                action: 'wpcbcp_save_settings',
    182182                settings: $scope.settings
    183183            }
  • wp-chatbull/tags/1.0/files/application/controllers/visitors/Chatbox.php

    r1693664 r1699501  
    7070        exit();
    7171    }
    72    
     72
    7373    /*
    7474     * To check plugin installed and validated.
    7575     */
     76
    7677    function is_installed() {
    7778        $response = array('result' => 'failed');
     
    8081        $return_token = ($this->input->get('token')) ? $this->input->get('token') : 'no';
    8182
    82         if ($this->config->item('installed') == 'yes' and $this->config->item('validated_code') == 'yes') {
    83             if (empty($domain_name)) {
    84                 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
     83        if ($this->config->item('installed') == 'yes') {
     84            if ($this->config->item('validated_code') == 'yes') {
     85                if (empty($domain_name)) {
     86                    $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
     87                } else {
     88                    $this->db->like('site_url', $domain_name);
     89                    $query = $this->db->get($this->token->table);
     90                    $token = $query->row();
     91
     92                    if ($token) {
     93                        $response['result'] = 'success';
     94                        $response['message'] = 'Plugin is configured and ready to use.';
     95                        if ($return_token == 'yes') {
     96                            $response['token'] = $token;
     97                        }
     98                    } else {
     99                        $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
     100                    }
     101                }
    85102            } else {
    86                 $this->db->like('site_url', $domain_name);
    87                 $query = $this->db->get($this->token->table);
    88                 $token = $query->row();
    89 
    90                 if ($token) {
    91                     $response['result'] = 'success';
    92                     $response['message'] = 'Plugin is configured and ready to use.';
    93                     if ($return_token == 'yes') {
    94                         $response['token'] = $token;
    95                     }
    96                 } else {
    97                     $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
    98                 }
     103                $response['errors']['not-validated'] = "Plugin is installed but not validated yet. To validate plugin <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
    99104            }
    100105        } else {
  • wp-chatbull/tags/1.0/includes/wpcbcp_settings.php

    r1688359 r1699501  
    1717    public function __construct() {
    1818        if (is_admin()) {
    19             add_action('wp_ajax_install_plugin', array($this, 'install_plugin'));
    20             add_action('wp_ajax_check_n_save', array($this, 'check_n_save'));
    21             add_action('wp_ajax_chack_status', array($this, 'chack_status'));
    22             add_action('wp_ajax_save_settings', array($this, 'save_settings'));
     19            add_action('wp_ajax_wpcbcp_install_plugin', array($this, 'install_plugin'));
     20            add_action('wp_ajax_wpcbcp_check_n_save', array($this, 'check_n_save'));
     21            add_action('wp_ajax_wpcbcp_chack_status', array($this, 'chack_status'));
     22            add_action('wp_ajax_wpcbcp_save_settings', array($this, 'save_settings'));
    2323        }
    2424    }
     
    123123        if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) {
    124124            if (empty($gaxon_wpcbcp_chatbull_dir)) {
    125                 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain);
    126             }
    127 
    128             if (is_dir($plugin_path)) {
     125                $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain);
     126            } elseif (is_dir($plugin_path)) {
    129127                $this->errors['dir-exists'] = __('A directory with name "' . $gaxon_wpcbcp_chatbull_dir . '" already exists. Please remove it or change name.', $this->plugin_domain);
    130128            } else {
     129                // Connecting to the filesystem.
     130                WP_Filesystem();
     131
     132                global $wp_filesystem;
     133
    131134                // creating directory       
    132                 $created = wp_mkdir_p($plugin_path);
     135                $created = $wp_filesystem->mkdir($plugin_path);
    133136                if ($created) {
    134                     // Connecting to the filesystem.
    135                     WP_Filesystem();
    136 
    137                     global $wp_filesystem;
    138 
    139137                    // Now copy all the files in the source directory to the target directory.
    140                     if (copy_dir($plugin_files, $plugin_path)) {
     138                    $copied = copy_dir($plugin_files, $plugin_path);
     139                    if (is_wp_error($copied)) {
     140                        $this->errors['gaxon_wpcbcp_chatbull_dir'] = $copied->get_error_message();
     141                    } else {
    141142                        $this->response['result'] = 'success';
    142143                        $this->response['message'] = __('Chatbull plugin files copied and redirecting you...', $this->plugin_domain);
     
    148149                        update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir);
    149150                    }
     151                } else {
     152                    $this->errors['directory_not_created'] = __('Unable to copy Chatbull files.', $this->plugin_domain);
    150153                }
    151154            }
     
    167170        if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) {
    168171            if (empty($gaxon_wpcbcp_chatbull_dir)) {
    169                 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain);
    170             }
    171 
    172             if (is_dir($plugin_path)) {
     172                $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain);
     173            } elseif (is_dir($plugin_path)) {
    173174                $request_url = site_url($gaxon_wpcbcp_chatbull_dir . '/index.php?d=visitors&c=chat&m=get_server_time');
    174175                $response = wp_remote_get($request_url);
     
    186187                        update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir);
    187188                    } else {
    188                         $this->errors['invalid-plugin'] = __('Invalid plugin directory.', $this->plugin_domain);
     189                        $this->errors['invalid-plugin'] = __('Invalid plugin directory or invalid response.', $this->plugin_domain);
    189190                    }
    190191                } else {
  • wp-chatbull/trunk/admin/js/wpcbcp-settings.js

    r1688359 r1699501  
    9999
    100100            var data = {
    101                 action: 'install_plugin',
     101                action: 'wpcbcp_install_plugin',
    102102                settings: $scope.settings
    103103            }
     
    125125
    126126            var data = {
    127                 action: 'check_n_save',
     127                action: 'wpcbcp_check_n_save',
    128128                settings: $scope.settings
    129129            }
     
    149149           
    150150            var data = {
    151                 action: 'chack_status',
     151                action: 'wpcbcp_chack_status',
    152152                settings: $scope.settings
    153153            }
     
    179179
    180180            var data = {
    181                 action: 'save_settings',
     181                action: 'wpcbcp_save_settings',
    182182                settings: $scope.settings
    183183            }
  • wp-chatbull/trunk/files/application/controllers/visitors/Chatbox.php

    r1693664 r1699501  
    7070        exit();
    7171    }
    72    
     72
    7373    /*
    7474     * To check plugin installed and validated.
    7575     */
     76
    7677    function is_installed() {
    7778        $response = array('result' => 'failed');
     
    8081        $return_token = ($this->input->get('token')) ? $this->input->get('token') : 'no';
    8182
    82         if ($this->config->item('installed') == 'yes' and $this->config->item('validated_code') == 'yes') {
    83             if (empty($domain_name)) {
    84                 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
     83        if ($this->config->item('installed') == 'yes') {
     84            if ($this->config->item('validated_code') == 'yes') {
     85                if (empty($domain_name)) {
     86                    $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
     87                } else {
     88                    $this->db->like('site_url', $domain_name);
     89                    $query = $this->db->get($this->token->table);
     90                    $token = $query->row();
     91
     92                    if ($token) {
     93                        $response['result'] = 'success';
     94                        $response['message'] = 'Plugin is configured and ready to use.';
     95                        if ($return_token == 'yes') {
     96                            $response['token'] = $token;
     97                        }
     98                    } else {
     99                        $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
     100                    }
     101                }
    85102            } else {
    86                 $this->db->like('site_url', $domain_name);
    87                 $query = $this->db->get($this->token->table);
    88                 $token = $query->row();
    89 
    90                 if ($token) {
    91                     $response['result'] = 'success';
    92                     $response['message'] = 'Plugin is configured and ready to use.';
    93                     if ($return_token == 'yes') {
    94                         $response['token'] = $token;
    95                     }
    96                 } else {
    97                     $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
    98                 }
     103                $response['errors']['not-validated'] = "Plugin is installed but not validated yet. To validate plugin <a target='_new' href='" . site_url('c=settings') . "'>click here</a>";
    99104            }
    100105        } else {
  • wp-chatbull/trunk/includes/wpcbcp_settings.php

    r1688359 r1699501  
    1717    public function __construct() {
    1818        if (is_admin()) {
    19             add_action('wp_ajax_install_plugin', array($this, 'install_plugin'));
    20             add_action('wp_ajax_check_n_save', array($this, 'check_n_save'));
    21             add_action('wp_ajax_chack_status', array($this, 'chack_status'));
    22             add_action('wp_ajax_save_settings', array($this, 'save_settings'));
     19            add_action('wp_ajax_wpcbcp_install_plugin', array($this, 'install_plugin'));
     20            add_action('wp_ajax_wpcbcp_check_n_save', array($this, 'check_n_save'));
     21            add_action('wp_ajax_wpcbcp_chack_status', array($this, 'chack_status'));
     22            add_action('wp_ajax_wpcbcp_save_settings', array($this, 'save_settings'));
    2323        }
    2424    }
     
    123123        if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) {
    124124            if (empty($gaxon_wpcbcp_chatbull_dir)) {
    125                 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain);
    126             }
    127 
    128             if (is_dir($plugin_path)) {
     125                $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain);
     126            } elseif (is_dir($plugin_path)) {
    129127                $this->errors['dir-exists'] = __('A directory with name "' . $gaxon_wpcbcp_chatbull_dir . '" already exists. Please remove it or change name.', $this->plugin_domain);
    130128            } else {
     129                // Connecting to the filesystem.
     130                WP_Filesystem();
     131
     132                global $wp_filesystem;
     133
    131134                // creating directory       
    132                 $created = wp_mkdir_p($plugin_path);
     135                $created = $wp_filesystem->mkdir($plugin_path);
    133136                if ($created) {
    134                     // Connecting to the filesystem.
    135                     WP_Filesystem();
    136 
    137                     global $wp_filesystem;
    138 
    139137                    // Now copy all the files in the source directory to the target directory.
    140                     if (copy_dir($plugin_files, $plugin_path)) {
     138                    $copied = copy_dir($plugin_files, $plugin_path);
     139                    if (is_wp_error($copied)) {
     140                        $this->errors['gaxon_wpcbcp_chatbull_dir'] = $copied->get_error_message();
     141                    } else {
    141142                        $this->response['result'] = 'success';
    142143                        $this->response['message'] = __('Chatbull plugin files copied and redirecting you...', $this->plugin_domain);
     
    148149                        update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir);
    149150                    }
     151                } else {
     152                    $this->errors['directory_not_created'] = __('Unable to copy Chatbull files.', $this->plugin_domain);
    150153                }
    151154            }
     
    167170        if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) {
    168171            if (empty($gaxon_wpcbcp_chatbull_dir)) {
    169                 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain);
    170             }
    171 
    172             if (is_dir($plugin_path)) {
     172                $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain);
     173            } elseif (is_dir($plugin_path)) {
    173174                $request_url = site_url($gaxon_wpcbcp_chatbull_dir . '/index.php?d=visitors&c=chat&m=get_server_time');
    174175                $response = wp_remote_get($request_url);
     
    186187                        update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir);
    187188                    } else {
    188                         $this->errors['invalid-plugin'] = __('Invalid plugin directory.', $this->plugin_domain);
     189                        $this->errors['invalid-plugin'] = __('Invalid plugin directory or invalid response.', $this->plugin_domain);
    189190                    }
    190191                } else {
Note: See TracChangeset for help on using the changeset viewer.