Beispiel #1
0
 /**
  * remove unused shortcode feeds
  */
 public function cronRemove()
 {
     $oDaoJsonData = new JsonDataDao();
     $aFeeds = $oDaoJsonData->fetchAllFeedQueueIDs();
     $query = new \WP_Query(array('post_status' => 'any', 'posts_per_page' => -1));
     $aPosts = $query->get_posts();
     $pattern = get_shortcode_regex();
     ///get all used queues
     $aUsedQueues = array();
     foreach ($aPosts as $post) {
         if (preg_match_all('/' . $pattern . '/s', $post->post_content, $matches) && array_key_exists(2, $matches) && in_array(JD\Config::SHORTCODE_JSON_DATA, $matches[2])) {
             foreach ($matches[0] as $sShortcode) {
                 $aParams = shortcode_parse_atts($sShortcode);
                 if (array_key_exists('id', $aParams)) {
                     $aUsedQueues[] = $aParams['id'];
                 }
             }
         }
     }
     $aToBeDeleted = array_diff($aFeeds, $aUsedQueues);
     array_map(array(&$this, '_removeQueueFiles'), $aToBeDeleted);
 }