Plugin Directory

Changeset 2502405


Ignore:
Timestamp:
03/24/2021 10:00:45 AM (5 years ago)
Author:
homanp
Message:

Remove Wordpress Async package.

Location:
request-io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • request-io/tags/1.0/request-io.php

    r2502362 r2502405  
    99 **/
    1010
    11 require_once plugin_dir_path( __FILE__ ) . "vendor/autoload.php";
    12 
    13 class Request_IO_Background_Process extends WP_Async_Request {
    14     protected $action = 'update_cache_request';
    15 
    16     protected function handle() {
    17        
    18         $url = esc_url_raw($_POST['api_url']);
    19         $home_url = esc_url_raw($_POST['home_url']);
    20 
    21         $pluginlog = plugin_dir_path(__FILE__).'debug.log';
    22         $message = 'API URL:'.$url;
    23         error_log($message, 3, $pluginlog);
    24 
    25         $message2 = 'HOME URL:'.$home_url;
    26         error_log($message2, 3, $pluginlog);
    27 
    28         wp_remote_get("{$home_url}/wp-json/requestio/v1/update-cache?api_url={$url}");
    29     }
    30 }
    31 
    3211class WP_Request_IO
    3312{
    3413    public function __construct()
    3514    {
    36         // Setup background request
    37         add_action('init', array($this, 'create_background_request'));
    3815        // Hook into the admin menu
    3916        add_action('admin_menu', array($this, 'create_plugin_settings_page'));
     
    269246        }   
    270247    }
    271 
    272     public function create_background_request() {
    273         $this->update_cache_request = new Request_IO_Background_Process();
    274     }
    275248   
    276249    public function getOptimizedHTML($url) {
     
    302275        ) {
    303276
    304             // LOGGING
     277            $site_url = $this->siteURL();
    305278
    306279            $pluginlog = plugin_dir_path(__FILE__).'debug.log';
    307             $message = 'ELIGABLE';
     280            $message = 'ELIGABLE FOR OPTIMIZATION';
    308281            error_log($message, 3, $pluginlog);
    309282
    310             $this->update_cache_request->data(array('api_url' => $api_url, 'home_url' => $this->siteUrl()));
    311             $this->update_cache_request->dispatch();
    312         }
     283            $args = array(
     284                'blocking' => false,
     285                'timeout' => 0.01
     286            );
     287
     288            wp_remote_get("{$site_url}/wp-json/requestio/v1/update-cache?api_url={$api_url}", $args);
     289
     290            $optimizedHTML = $this->getOptimizedHTML($api_url);
    313291       
    314         $optimizedHTML = $this->getOptimizedHTML($api_url);
    315        
    316         if ($optimizedHTML) {
    317             return $optimizedHTML;
    318         }
     292            if ($optimizedHTML) {
     293                return $optimizedHTML;
     294            }
     295        }
    319296
    320297        return $output;
  • request-io/trunk/request-io.php

    r2502362 r2502405  
    99 **/
    1010
    11 require_once plugin_dir_path( __FILE__ ) . "vendor/autoload.php";
    12 
    13 class Request_IO_Background_Process extends WP_Async_Request {
    14     protected $action = 'update_cache_request';
    15 
    16     protected function handle() {
    17        
    18         $url = esc_url_raw($_POST['api_url']);
    19         $home_url = esc_url_raw($_POST['home_url']);
    20 
    21         $pluginlog = plugin_dir_path(__FILE__).'debug.log';
    22         $message = 'API URL:'.$url;
    23         error_log($message, 3, $pluginlog);
    24 
    25         $message2 = 'HOME URL:'.$home_url;
    26         error_log($message2, 3, $pluginlog);
    27 
    28         wp_remote_get("{$home_url}/wp-json/requestio/v1/update-cache?api_url={$url}");
    29     }
    30 }
    31 
    3211class WP_Request_IO
    3312{
    3413    public function __construct()
    3514    {
    36         // Setup background request
    37         add_action('init', array($this, 'create_background_request'));
    3815        // Hook into the admin menu
    3916        add_action('admin_menu', array($this, 'create_plugin_settings_page'));
     
    269246        }   
    270247    }
    271 
    272     public function create_background_request() {
    273         $this->update_cache_request = new Request_IO_Background_Process();
    274     }
    275248   
    276249    public function getOptimizedHTML($url) {
     
    302275        ) {
    303276
    304             // LOGGING
     277            $site_url = $this->siteURL();
    305278
    306279            $pluginlog = plugin_dir_path(__FILE__).'debug.log';
    307             $message = 'ELIGABLE';
     280            $message = 'ELIGABLE FOR OPTIMIZATION';
    308281            error_log($message, 3, $pluginlog);
    309282
    310             $this->update_cache_request->data(array('api_url' => $api_url, 'home_url' => $this->siteUrl()));
    311             $this->update_cache_request->dispatch();
    312         }
     283            $args = array(
     284                'blocking' => false,
     285                'timeout' => 0.01
     286            );
     287
     288            wp_remote_get("{$site_url}/wp-json/requestio/v1/update-cache?api_url={$api_url}", $args);
     289
     290            $optimizedHTML = $this->getOptimizedHTML($api_url);
    313291       
    314         $optimizedHTML = $this->getOptimizedHTML($api_url);
    315        
    316         if ($optimizedHTML) {
    317             return $optimizedHTML;
    318         }
     292            if ($optimizedHTML) {
     293                return $optimizedHTML;
     294            }
     295        }
    319296
    320297        return $output;
Note: See TracChangeset for help on using the changeset viewer.