/**
  * Gets user relations
  *
  * @access public
  * @param mixed $ID
  * @param mixed $related
  * @param mixed $type
  * @param bool $single
  * @return array
  */
 public static function getUserRelations($ID, $related, $type, $single = false)
 {
     global $wpdb;
     $select = 'comment_content';
     $where['user_id'] = themex_implode($ID);
     $where['comment_post_ID'] = themex_implode($related);
     $where['comment_type'] = themex_implode($type, 'user_');
     if ($ID == 0) {
         $select = 'user_id';
         unset($where['user_id']);
     } else {
         if ($related == 0) {
             $select = 'comment_post_ID';
             unset($where['comment_post_ID']);
         }
     }
     return self::getRelations($select, $where, $wpdb->comments, $single);
 }
 /**
  * Gets plans
  *
  * @access public
  * @param int $ID
  * @return array
  */
 public static function getPlans($ID)
 {
     global $wpdb;
     $categories = wp_get_post_terms($ID, 'course_category', array('fields' => 'ids'));
     $plans = ThemexCore::getPostRelations(0, $categories, 'plan_category');
     $results = $wpdb->get_results("\r\n\t\t\tSELECT post_id FROM " . $wpdb->postmeta . " as meta \r\n\t\t\tINNER JOIN " . $wpdb->posts . " AS posts ON (posts.ID=meta.post_id) \r\n\t\t\tWHERE meta_key = '_plan_category' \r\n\t\t\tAND meta_value IN(" . themex_implode($categories) . ") \r\n\t\t\tORDER BY posts.menu_order \r\n\t\t");
     $results = wp_list_pluck($results, 'post_id');
     return $results;
 }
Example #3
0
 /**
  * Gets product relations
  *
  * @access public
  * @param int $ID
  * @param bool $extended
  * @return array
  */
 public static function getRelations($shops)
 {
     global $wpdb;
     $relations = array();
     if (!empty($shops)) {
         $shops = themex_implode($shops);
         $results = $wpdb->get_results("\r\n\t\t\t\tSELECT post_author FROM {$wpdb->posts} \r\n\t\t\t\tWHERE post_status = 'publish' \r\n\t\t\t\tAND post_type = 'shop' \r\n\t\t\t\tAND ID IN (" . $shops . ") \r\n\t\t\t");
         $authors = wp_list_pluck($results, 'post_author');
         $authors = themex_implode($authors);
         $results = $wpdb->get_results("\r\n\t\t\t\tSELECT ID FROM {$wpdb->posts} \r\n\t\t\t\tWHERE post_status = 'publish' \r\n\t\t\t\tAND post_type = 'product' \r\n\t\t\t\tAND post_author IN (" . $authors . ") \r\n\t\t\t\tORDER BY post_date DESC\r\n\t\t\t");
         $relations = wp_list_pluck($results, 'ID');
     }
     return $relations;
 }