Пример #1
0
 /**
  * Method to handle and parse request to PuSH Feed Hub Callbacks
  *
  * @param object $wp Pass WordPress Object by reference
  */
 public function tls_hub_callback_parser(&$wp)
 {
     $pushfeed_url = $_SERVER['REQUEST_URI'];
     // Check if pushfeed is in the URL
     if (strpos($pushfeed_url, 'pushfeed') || preg_match('/pushfeed/', $pushfeed_url)) {
         $pushfeed_url_array = explode('/', $pushfeed_url);
         // Get subscription_id from the URL
         $subscription_id = array_pop($pushfeed_url_array);
         if (empty($subscription_id)) {
             $subscription_id = array_pop($pushfeed_url_array);
         }
         //Make sure the subscription ID matches the one in the database otherwise service 404
         if ($this->current_options['subscription_id'] != $subscription_id) {
             header('HTTP/1.1 404 "Not Found"', null, 404);
             exit;
         }
         $this->hubSubscriber->handleRequest();
         exit;
     }
 }
Пример #2
0
 /**
  * Ajax Callback Function for the Settings Page
  */
 public function hub_action_callback()
 {
     $tls_hub_action = wp_strip_all_tags($_POST['tls_hub_action']);
     $message = '';
     if (strtolower($tls_hub_action) == 'subscribe') {
         $this->current_options['subscription_status'] = 'Subscribing';
         update_option(self::$option_name, $this->current_options);
         $HubSubscriber = new HubSubscriber(self::$option_name, $this->current_options);
         echo $HubSubscriber->subscribe();
     }
     wp_die();
     // this is required to terminate immediately and return a proper response
 }