Author: Mikael Mattsson (mikael@wallmanderco.se)
Inheritance: extends Client
 public static function argPostType(Query $query, $value, &$q)
 {
     if ($value == 'any' || isset($value[0]) && $value[0] == 'any') {
         $pt = Indexer::getSearchablePostTypes();
         $query->where('post_type', array_values($pt));
     } else {
         $query->where('post_type', $value);
     }
 }
示例#2
0
 /**
  * Admin reindex, requested by the index page.
  */
 public static function ajaxReindex()
 {
     if (!isset($_POST['site']) || !isset($_POST['from']) || empty($_POST['size'])) {
         die('invalid request');
     }
     $site = (int) $_POST['site'];
     $from = (int) $_POST['from'];
     $size = (int) $_POST['size'];
     try {
         $indexer = new Indexer();
         list($indexed, $total) = $indexer->reindex($site, $from, $size);
         $data = (object) ['success' => false, 'indexed' => $indexed, 'total' => $total];
         $data->success = true;
         header('Content-Type: application/json');
         echo json_encode($data);
     } catch (Exception $e) {
         $data = (object) ['success' => false, 'message' => $e->getMessage()];
         header('Content-Type: application/json');
         echo json_encode($data);
     }
     die;
 }
 /**
  * Hooked on added_post_meta, updated_post_meta and deleted_post_meta. Called when post meta data is modified.
  *
  * @param int    $incrementID
  * @param int    $postID
  * @param string $metaKey
  * @param        $metaValue
  */
 public static function actionUpdatedPostMeta($incrementID, $postID, $metaKey, $metaValue)
 {
     $data = ['post_meta' => [$metaKey => get_post_meta($postID, $metaKey)]];
     $indexer = new Indexer();
     $indexer->updatePost($postID, $data);
 }