Пример #1
0
 /**
  * Initialize required classes and add them to the container
  *
  * @throws Exceptions\ContainerOverrideException
  * @throws Exceptions\NotStringException
  */
 public function boot()
 {
     $container = Container::get_instance();
     if (apply_filters($this->filter_base . 'core/register/prepare/post', true)) {
         $container->add('Xeeeveee\\Core\\WordPress\\Prepare\\Post', Post::get_instance());
     }
     if (apply_filters($this->filter_base . 'core/register/prepare/post', true)) {
         $container->add('Xeeeveee\\Core\\WordPress\\Prepare\\Term', Term::get_instance());
     }
     if (apply_filters($this->filter_base . 'core/register/prepare/post', true)) {
         $container->add('Xeeeveee\\Core\\WordPress\\Register\\Decorators\\PostDecorator', PostDecorator::get_instance());
     }
     if (apply_filters($this->filter_base . 'core/register/enqueue/admin_scripts', true)) {
         $container->add('Xeeeveee\\Core\\WordPress\\Enqueue\\Script\\AdminScripts', AdminMain::get_instance());
     }
     if (apply_filters($this->filter_base . 'core/register/enqueue/color_picker_styles', true)) {
         $container->add('Xeeeveee\\Core\\WordPress\\Enqueue\\Style\\ColorPicker', ColorPicker::get_instance());
     }
     if (apply_filters($this->filter_base . 'core/register/enqueue/jquery_ui_styles', true)) {
         $container->add('Xeeeveee\\Core\\WordPress\\Enqueue\\Style\\JQueryUi', JQueryUi::get_instance());
     }
 }
Пример #2
0
 /**
  * Gets all the posts terms
  *
  * @param array $posts
  *
  * @return array|null|object
  */
 protected function get_terms(array $posts = [])
 {
     if (empty($posts)) {
         return [];
     }
     global $wpdb;
     $ids = [];
     $placeholders = [];
     $cast_terms = [];
     $sql = "SELECT ";
     $sql .= "{$wpdb->term_relationships}.object_id as post_id, ";
     $sql .= "{$wpdb->term_taxonomy}.taxonomy, ";
     $sql .= "{$wpdb->terms}.term_id, ";
     $sql .= "{$wpdb->terms}.name, ";
     $sql .= "{$wpdb->terms}.slug, ";
     $sql .= "{$wpdb->term_taxonomy}.description, ";
     $sql .= "{$wpdb->term_taxonomy}.parent, ";
     $sql .= "{$wpdb->term_taxonomy}.count, ";
     $sql .= "{$wpdb->terms}.term_group, ";
     $sql .= "{$wpdb->term_relationships}.term_order ";
     $sql .= "FROM {$wpdb->term_relationships} ";
     $sql .= "JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id ";
     $sql .= "JOIN {$wpdb->terms} ON {$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id ";
     $sql .= "WHERE {$wpdb->term_relationships}.object_id IN (";
     foreach ($posts as $post) {
         if ($post instanceof WP_Post) {
             $placeholders[] = "%d";
             $ids[] = $post->ID;
         }
     }
     $sql .= join($placeholders, ', ') . ") ";
     $terms = $wpdb->get_results($wpdb->prepare($sql, $ids));
     foreach ($terms as $term) {
         $cast_terms[] = new WP_Term($term);
     }
     return $this->term_transformer->prepare_collection($cast_terms);
 }