Changeset 2502405
- Timestamp:
- 03/24/2021 10:00:45 AM (5 years ago)
- Location:
- request-io
- Files:
-
- 2 edited
-
tags/1.0/request-io.php (modified) (3 diffs)
-
trunk/request-io.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
request-io/tags/1.0/request-io.php
r2502362 r2502405 9 9 **/ 10 10 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 32 11 class WP_Request_IO 33 12 { 34 13 public function __construct() 35 14 { 36 // Setup background request37 add_action('init', array($this, 'create_background_request'));38 15 // Hook into the admin menu 39 16 add_action('admin_menu', array($this, 'create_plugin_settings_page')); … … 269 246 } 270 247 } 271 272 public function create_background_request() {273 $this->update_cache_request = new Request_IO_Background_Process();274 }275 248 276 249 public function getOptimizedHTML($url) { … … 302 275 ) { 303 276 304 // LOGGING277 $site_url = $this->siteURL(); 305 278 306 279 $pluginlog = plugin_dir_path(__FILE__).'debug.log'; 307 $message = 'ELIGABLE ';280 $message = 'ELIGABLE FOR OPTIMIZATION'; 308 281 error_log($message, 3, $pluginlog); 309 282 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); 313 291 314 $optimizedHTML = $this->getOptimizedHTML($api_url); 315 316 if ($optimizedHTML) { 317 return $optimizedHTML; 318 } 292 if ($optimizedHTML) { 293 return $optimizedHTML; 294 } 295 } 319 296 320 297 return $output; -
request-io/trunk/request-io.php
r2502362 r2502405 9 9 **/ 10 10 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 32 11 class WP_Request_IO 33 12 { 34 13 public function __construct() 35 14 { 36 // Setup background request37 add_action('init', array($this, 'create_background_request'));38 15 // Hook into the admin menu 39 16 add_action('admin_menu', array($this, 'create_plugin_settings_page')); … … 269 246 } 270 247 } 271 272 public function create_background_request() {273 $this->update_cache_request = new Request_IO_Background_Process();274 }275 248 276 249 public function getOptimizedHTML($url) { … … 302 275 ) { 303 276 304 // LOGGING277 $site_url = $this->siteURL(); 305 278 306 279 $pluginlog = plugin_dir_path(__FILE__).'debug.log'; 307 $message = 'ELIGABLE ';280 $message = 'ELIGABLE FOR OPTIMIZATION'; 308 281 error_log($message, 3, $pluginlog); 309 282 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); 313 291 314 $optimizedHTML = $this->getOptimizedHTML($api_url); 315 316 if ($optimizedHTML) { 317 return $optimizedHTML; 318 } 292 if ($optimizedHTML) { 293 return $optimizedHTML; 294 } 295 } 319 296 320 297 return $output;
Note: See TracChangeset
for help on using the changeset viewer.