示例#1
0
 /**
  * @param string|int $postId Either post ID or permalink
  * @return array|null|object
  */
 public static function pingCrawler($postId, $delete = false)
 {
     if (!wp_is_post_revision($postId) && !wp_is_post_autosave($postId)) {
         $contentUrl = is_numeric($postId) ? get_permalink($postId) : $postId;
         $apiPath = $delete || !Post::is_published($postId) ? self::CXENSE_PROFILE_DELETE : self::CXENSE_PROFILE_PUSH;
         try {
             return self::request($apiPath, ['url' => $contentUrl]);
         } catch (Exception $e) {
             if ($e instanceof HttpException) {
                 error_log('WP cXense: Failed calling cXense api: ' . $apiPath . ' response code: ' . $e->getCode() . ' error: ' . $e->getMessage());
             }
             if ($e->getCode() == self::EXCEPTION_USER_NOT_DEFINED) {
                 error_log('PHP Warning: To use CXense push you must define constants CXENSE_USER_NAME and CXENSE_API_KEY');
             } elseif ($e->getCode() == self::EXCEPTION_UNAUTHORIZED) {
                 error_log('PHP Warning: Could not authorize with defined CXENSE_USER_NAME and CXENSE_API_KEY');
             }
         }
     }
     return null;
 }
示例#2
0
 private function bootstrap()
 {
     Post::watch_post_changes($this->settings);
     Scripts::bootstrap($this->settings);
     CxenseApi::bootstrap($this->settings);
 }