Plugin Directory

Changeset 3215191


Ignore:
Timestamp:
12/31/2024 08:30:53 AM (15 months ago)
Author:
leopardhost
Message:

v1.3.9: Pass-through API Error to WP GUI

Location:
tnc-toolbox
Files:
21 added
4 edited

Legend:

Unmodified
Added
Removed
  • tnc-toolbox/trunk/core/includes/classes/class-tnc-wp-toolbox-run.php

    r3209621 r3215191  
    180180                $config[$item] = file_get_contents($file_path);
    181181            } else {
    182                 set_transient('tnc_wp_toolbox_cpanel_action_error', "Problemo! {$item} config seems to be empty - please update it in Settings > TNC Toolbox. Cheers!", 60);
     182                set_transient('tnc_wp_toolbox_cpanel_action_error', "TNC Toolbox: Problemo! {$item} config seems to be empty - please update it in Settings > TNC Toolbox. Cheers!", 60);
    183183                wp_safe_redirect(admin_url());
    184184                exit;
     
    193193        // Do the thing, prepare to handle
    194194        $response = wp_remote_post($url, ['headers' => $headers, 'body' => $body]);
     195        $response_body = wp_remote_retrieve_body($response);
    195196        $referer = wp_get_referer();
    196 
     197       
    197198        // Match up conditions/errors, relay
    198         if (is_wp_error($response)) {
    199             set_transient('tnc_wp_toolbox_cpanel_action_error', $response->get_error_message(), 60);
    200         } elseif (wp_remote_retrieve_response_code($response) == 200) {
     199        if (wp_remote_retrieve_response_code($response) == 200) {
    201200            set_transient('tnc_wp_toolbox_cpanel_action_success', $success_message, 60);
     201        } elseif (!empty($response_body)) {
     202            set_transient('tnc_wp_toolbox_cpanel_action_error', 'TNC Toolbox: ' . $endpoint . ' hit a snag. The error we received is: ' . $response_body, 60);
    202203        } else {
    203204            set_transient('tnc_wp_toolbox_cpanel_action_error', $error_message, 60);
     
    215216   
    216217    function nginx_cache_purge() {
    217         $this->cpanel_api_request('NginxCaching/clear_cache', 'NGINX Cache has been successfully purged!', 'TNC Toolbox hit a snag purging the NGINX Cache. If this continues, please contact your Hosting Support.');
     218        $this->cpanel_api_request('NginxCaching/clear_cache', 'TNC Toolbox: NGINX Cache has been Purged!', 'TNC Toolbox: NginxCaching/clear_cache hit an uncaught snag. If this continues, please contact your Hosting Support.');
    218219    }
    219220   
    220221    function nginx_cache_off() {
    221         $this->cpanel_api_request('NginxCaching/disable_cache', 'NGINX Cache has been disabled.', 'TNC Toolbox hit a snag disabling the NGINX Cache. If this continues, please contact your Hosting Support.');
     222        $this->cpanel_api_request('NginxCaching/disable_cache', 'TNC Toolbox: NGINX Cache has been Disabled.', 'TNC Toolbox: NginxCaching/disable_cache hit an uncaught snag. If this continues, please contact your Hosting Support.');
    222223    }
    223224   
    224225    function nginx_cache_on() {
    225         $this->cpanel_api_request('NginxCaching/enable_cache', 'NGINX Cache has been enabled!', 'TNC Toolbox hit a snag enabling the NGINX Cache. If this continues, please contact your Hosting Support.');
     226        $this->cpanel_api_request('NginxCaching/enable_cache', 'TNC Toolbox: NGINX Cache has been Enabled!', 'TNC Toolbox: NginxCaching/enable_cache hit an uncaught snag. If this continues, please contact your Hosting Support.');
    226227    }
    227228
  • tnc-toolbox/trunk/core/includes/classes/class-tnc-wp-toolbox-settings.php

    r3209621 r3215191  
    181181                    </tr>
    182182                    <tr>
    183                         <th scope="row"><label for="tnc_toolbox_username">cPanel Username</label><br><small>Plain-text user, as used to log-in.</small></th>
     183                        <th scope="row"><label for="tnc_toolbox_username">cPanel Username</label><br><small>Plain-text user. Not the API user.</small></th>
    184184                        <td><input type="text" id="tnc_toolbox_username" name="tnc_toolbox_username"  size="45" value="<?php echo esc_attr( $this->get_file_content( TNCWPTBOX_CONFIG_DIR . 'cpanel-username' ) ); ?>" /></td>
    185185                    </tr>
    186186                    <tr>
    187                         <th scope="row"><label for="tnc_toolbox_server_hostname">Server Hostname</label><br><small>FQDN of Server, no HTTPS etc.</small></th>
     187                        <th scope="row"><label for="tnc_toolbox_server_hostname">Server Hostname</label><br><small>FQDN of Server. No HTTPS etc.</small></th>
    188188                        <td><input type="text" id="tnc_toolbox_server_hostname" name="tnc_toolbox_server_hostname"  size="45" value="<?php echo esc_attr( $this->get_file_content( TNCWPTBOX_CONFIG_DIR . 'server-hostname' ) ); ?>" /></td>
    189189                    </tr>
  • tnc-toolbox/trunk/readme.txt

    r3209621 r3215191  
    88Tested up to: 6.7
    99Requires PHP:
    10 Stable tag: 1.3.8
     10Stable tag: 1.3.9
    1111License: GPLv3
    1212License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    8989== Changelog ==
    9090
     91= 1.3.9: Dec 31, 2024 =
     92* Pass-through error from cP API back to WP GUI (#22)
     93* Improve uncaught error wording, and clarify on user type
     94
    9195= 1.3.8: Dec 18, 2024 =
    9296* Update compatibility to WP 6.7.x sub-major (#20)
  • tnc-toolbox/trunk/tnc-wp-toolbox.php

    r3209621 r3215191  
    66 * @author        The Network Crew Pty Ltd (TNC)
    77 * @license       gplv3
    8  * @version       1.3.8
     8 * @version       1.3.9
    99 *
    1010 * @wordpress-plugin
     
    1212 * Plugin URI:    https://merlot.digital
    1313 * Description:   Adds functionality to WP - designed for NGINX-powered Servers on cPanel+WHM. Made to help you fly online!
    14  * Version:       1.3.8
     14 * Version:       1.3.9
    1515 * Author:        The Network Crew Pty Ltd (TNC)
    1616 * Author URI:    https://tnc.works
     
    4747
    4848// Plugin version
    49 define( 'TNCWPTBOX_VERSION',        '1.3.8' );
     49define( 'TNCWPTBOX_VERSION',        '1.3.9' );
    5050
    5151// Plugin Root File
Note: See TracChangeset for help on using the changeset viewer.