当前位置: 首页>>代码示例>>PHP>>正文


PHP Essential_Grid_Base::getCatAndTaxData方法代码示例

本文整理汇总了PHP中Essential_Grid_Base::getCatAndTaxData方法的典型用法代码示例。如果您正苦于以下问题:PHP Essential_Grid_Base::getCatAndTaxData方法的具体用法?PHP Essential_Grid_Base::getCatAndTaxData怎么用?PHP Essential_Grid_Base::getCatAndTaxData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Essential_Grid_Base的用法示例。


在下文中一共展示了Essential_Grid_Base::getCatAndTaxData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 /**
  * Search all Grids and change the term IDs set in the selected terms if needed
  * @since: 2.1.0
  **/
 static function split_terms_fix($old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy)
 {
     $base = new Essential_Grid_Base();
     $lang = array();
     if (Essential_Grid_Wpml::is_wpml_exists()) {
         $lang = icl_get_languages();
     }
     $grids = Essential_Grid::get_essential_grids();
     if (!empty($grids)) {
         foreach ($grids as $grid) {
             $selected = json_decode($grid->postparams, true);
             $post_category = $base->getVar($selected, 'post_category');
             $cat_tax = $base->getCatAndTaxData($post_category);
             $cats = array();
             if (!empty($cat_tax['cats'])) {
                 $cats = explode(',', $cat_tax['cats']);
             }
             $taxes = array('post_tag');
             if (!empty($cat_tax['tax'])) {
                 $taxes = explode(',', $cat_tax['tax']);
             }
             $cont = false;
             if (!empty($cats)) {
                 foreach ($cats as $cat) {
                     if ($old_term_id == $cat && in_array($taxonomy, $taxes)) {
                         //ID needs to be changed
                         foreach ($taxes as $t) {
                             //replace all occuring old term id with the new term id and then Save the Grid
                             $post_category = str_replace($t . '_' . $old_term_id, $t . '_' . $new_term_id, $post_category);
                         }
                         $selected['post_category'] = $post_category;
                         $grid->postparams = $selected;
                         $grid->params = json_decode($grid->params, true);
                         $grid->layers = json_decode($grid->layers, true);
                         $new_grid = (array) $grid;
                         //cast to array as update_create_grid expects an array
                         Essential_Grid_Admin::update_create_grid($new_grid);
                         //now delete cache of the Grid so that changes take effect immediately
                         if (!empty($lang)) {
                             foreach ($lang as $code => $val) {
                                 delete_transient('ess_grid_trans_query_' . $grid->id . $val['language_code']);
                                 delete_transient('ess_grid_trans_full_grid_' . $grid->id . $val['language_code']);
                             }
                         } else {
                             delete_transient('ess_grid_trans_query_' . $grid->id);
                             delete_transient('ess_grid_trans_full_grid_' . $grid->id);
                         }
                         $cont = true;
                     }
                     if ($cont == true) {
                         break;
                     }
                 }
             }
         }
     }
 }
开发者ID:Lumbe,项目名称:dev_servus,代码行数:61,代码来源:wordpress-update-fix.class.php

示例2: output_search_result_ids

 /** 
  * return search result ID's
  * @since: 2.0
  */
 public static function output_search_result_ids($search, $grid_id = 0)
 {
     $grid_id = intval($grid_id);
     if ($search == '' || $grid_id === 0) {
         return __('Not found', EG_TEXTDOMAIN);
     }
     $grid = new Essential_Grid();
     if ($grid->init_by_id($grid_id) === false) {
         return __('Not found', EG_TEXTDOMAIN);
     }
     $base = new Essential_Grid_Base();
     $post_category = $grid->get_postparam_by_handle('post_category');
     $post_types = $grid->get_postparam_by_handle('post_types');
     $page_ids = explode(',', $grid->get_postparam_by_handle('selected_pages', '-1'));
     $start_sortby = $grid->get_param_by_handle('sorting-order-by-start', 'none');
     $start_sortby_type = $grid->get_param_by_handle('sorting-order-type', 'ASC');
     $max_entries = $grid->get_maximum_entries($grid);
     $cat_tax = Essential_Grid_Base::getCatAndTaxData($post_category);
     $additional_query = $grid->get_postparam_by_handle('additional-query', '');
     if ($additional_query !== '') {
         $additional_query .= '&s=' . $search;
     } else {
         $additional_query .= 's=' . $search;
     }
     $additional_query = wp_parse_args($additional_query);
     ob_start();
     $posts = Essential_Grid_Base::getPostsByCategory($grid_id, $cat_tax['cats'], $post_types, $cat_tax['tax'], $page_ids, $start_sortby, $start_sortby_type, $max_entries, $additional_query, false);
     ob_clean();
     ob_end_clean();
     if (empty($posts) || count($posts) === 0) {
         return __('Not found', EG_TEXTDOMAIN);
     }
     $ids = array();
     foreach ($posts as $post) {
         $ids[] = $post['ID'];
     }
     return $ids;
 }
开发者ID:Lumbe,项目名称:dev_servus,代码行数:42,代码来源:search.class.php

示例3: check_for_transient_deletion

 /**
  * This function deletes transient of certain grids where the Post is included in
  * @since: 1.2.0
  */
 public static function check_for_transient_deletion($post_id)
 {
     $base = new Essential_Grid_Base();
     $categories = $base->get_custom_taxonomies_by_post_id($post_id);
     $tags = get_the_tags($post_id);
     $lang = array();
     if (Essential_Grid_Wpml::is_wpml_exists()) {
         $lang = icl_get_languages();
     }
     $cat = array();
     if (!empty($categories) || !empty($tags)) {
         if (!empty($categories)) {
             foreach ($categories as $c) {
                 $cat[$c->taxonomy][$c->term_id] = true;
             }
         }
         if (!empty($tags)) {
             foreach ($categories as $c) {
                 $cat[$c->taxonomy][$c->term_id] = true;
             }
         }
         //get all grids, then check all grids
         $grids = Essential_Grid::get_essential_grids();
         if (!empty($grids)) {
             foreach ($grids as $grid) {
                 $selected = json_decode($grid->postparams, true);
                 $post_category = $base->getVar($selected, 'post_category');
                 $cat_tax = $base->getCatAndTaxData($post_category);
                 $cats = array();
                 if (!empty($cat_tax['cats'])) {
                     $cats = explode(',', $cat_tax['cats']);
                 }
                 $taxes = array('post_tag');
                 if (!empty($cat_tax['tax'])) {
                     $taxes = explode(',', $cat_tax['tax']);
                 }
                 $cont = false;
                 if (!empty($cats)) {
                     foreach ($taxes as $tax) {
                         foreach ($cats as $c) {
                             if (isset($cat[$tax][$c])) {
                                 //if set, cache of grid needs to be killed
                                 if (!empty($lang)) {
                                     foreach ($lang as $code => $val) {
                                         delete_transient('ess_grid_trans_query_' . $grid->id . $val['language_code']);
                                         delete_transient('ess_grid_trans_full_grid_' . $grid->id . $val['language_code']);
                                     }
                                 } else {
                                     delete_transient('ess_grid_trans_query_' . $grid->id);
                                     delete_transient('ess_grid_trans_full_grid_' . $grid->id);
                                 }
                                 $cont = true;
                             }
                             if ($cont == true) {
                                 break;
                             }
                         }
                         if ($cont == true) {
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:hhgr,项目名称:EveryonePlay,代码行数:70,代码来源:essential-grid-admin.class.php

示例4: output_filter_by_posts

 /**
  * Output Filter from post based
  * @since 1.0.6
  */
 public function output_filter_by_posts()
 {
     $base = new Essential_Grid_Base();
     $nav = new Essential_Grid_Navigation();
     $filter_allow = $base->getVar($this->grid_params, 'filter-arrows', 'single');
     $filter_start = $grid->getVar($this->grid_params, 'filter-start', '');
     $filter_all_text = $base->getVar($this->grid_params, 'filter-all-text', __('Filter - All', EG_TEXTDOMAIN));
     $filter_dropdown_text = $base->getVar($this->grid_params, 'filter-dropdown-text', __('Filter Categories', EG_TEXTDOMAIN));
     $show_count = $base->getVar($this->grid_params, 'filter-counter', 'off');
     $nav->set_filter_text($filter_all_text);
     $nav->set_dropdown_text($filter_dropdown_text);
     $nav->set_show_count($show_count);
     $start_sortby = $base->getVar($this->grid_params, 'sorting-order-by-start', 'none');
     $start_sortby_type = $base->getVar($this->grid_params, 'sorting-order-type', 'ASC');
     $post_category = $base->getVar($this->grid_postparams, 'post_category');
     $post_types = $base->getVar($this->grid_postparams, 'post_types');
     $page_ids = explode(',', $base->getVar($this->grid_postparams, 'selected_pages', '-1'));
     $cat_relation = $base->getVar($this->grid_postparams, 'category-relation', 'OR');
     $additional_query = $base->getVar($this->grid_postparams, 'additional-query', '');
     if ($additional_query !== '') {
         $additional_query = wp_parse_args($additional_query);
     }
     $cat_tax = Essential_Grid_Base::getCatAndTaxData($post_category);
     $posts = Essential_Grid_Base::getPostsByCategory($this->grid_id, $cat_tax['cats'], $post_types, $cat_tax['tax'], $page_ids, $start_sortby, $start_sortby_type, -1, $additional_query, true, $cat_relation);
     $nav_filters = array();
     $taxes = array('post_tag');
     if (!empty($cat_tax['tax'])) {
         $taxes = explode(',', $cat_tax['tax']);
     }
     if (!empty($cat_tax['cats'])) {
         $cats = explode(',', $cat_tax['cats']);
         foreach ($cats as $key => $id) {
             $cat = get_category($id);
             if (is_object($cat)) {
                 $nav_filters[$id] = array('name' => $cat->cat_name, 'slug' => sanitize_key($cat->slug));
             }
             foreach ($taxes as $custom_tax) {
                 $term = get_term_by('id', $id, $custom_tax);
                 if (is_object($term)) {
                     $nav_filters[$id] = array('name' => $term->name, 'slug' => sanitize_key($term->slug));
                 }
             }
         }
         asort($nav_filters);
     }
     $found_filter = array();
     if (!empty($posts) && count($posts) > 0) {
         foreach ($posts as $key => $post) {
             //check if post should be visible or if its invisible on current grid settings
             $is_visible = $this->check_if_visible($post['ID'], $this->grid_id);
             if ($is_visible == false) {
                 continue;
             }
             // continue if invisible
             $filters = array();
             //$categories = get_the_category($post['ID']);
             $categories = $base->get_custom_taxonomies_by_post_id($post['ID']);
             //$tags = wp_get_post_terms($post['ID']);
             $tags = get_the_tags($post['ID']);
             if (!empty($categories)) {
                 foreach ($categories as $key => $category) {
                     $filters[$category->term_id] = array('name' => $category->name, 'slug' => sanitize_key($category->slug));
                 }
             }
             if (!empty($tags)) {
                 foreach ($tags as $key => $taxonomie) {
                     $filters[$taxonomie->term_id] = array('name' => $taxonomie->name, 'slug' => sanitize_key($taxonomie->slug));
                 }
             }
             $found_filter = $found_filter + $filters;
             //these are the found filters, only show filter that the posts have
         }
     }
     $remove_filter = array_diff_key($nav_filters, $found_filter);
     //check if we have filter that no post has (comes through multilanguage)
     if (!empty($remove_filter)) {
         foreach ($remove_filter as $key => $rem) {
             //we have, so remove them from the filter list before setting the filter list
             unset($nav_filters[$key]);
         }
     }
     $nav->set_filter($nav_filters);
     //set filters $nav_filters $found_filter
     $nav->set_filter_type($filter_allow);
     $nav->set_filter_start_select($filter_start);
     $nav->output_filter();
 }
开发者ID:kfwebdev,项目名称:wp-atd,代码行数:91,代码来源:essential-grid.class.php


注:本文中的Essential_Grid_Base::getCatAndTaxData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。