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


PHP td_util::get_ctp_option方法代码示例

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


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

示例1: get_custom_post_type_breadcrumbs

 /**
  * here we generate the breadcrumbs for custom post types
  *  - we favor terms that have a parent so: parent > child will always show up instead of single terms that don't have parents
  * @return string
  */
 private static function get_custom_post_type_breadcrumbs()
 {
     global $post;
     // use the global breadcrumb setting to show or hide them
     if (td_util::get_option('tds_breadcrumbs_show') == 'hide') {
         return '';
     }
     $breadcrumbs_array = array();
     // get the taxonomy that was set for breadcrumbs
     $breadcrumbs_taxonomy = td_util::get_ctp_option($post->post_type, 'tds_breadcrumbs_taxonomy');
     // get terms (alphabetically)
     $terms = wp_get_post_terms($post->ID, $breadcrumbs_taxonomy);
     if (!empty($terms)) {
         // add the first term by default
         // this default will be overwritten ! - if in foreach we find a term that has a parent
         if (isset($terms[0])) {
             $first_term_url = get_term_link($terms[0], $breadcrumbs_taxonomy);
             if (!is_wp_error($first_term_url)) {
                 $breadcrumbs_array[0] = array('title_attribute' => '', 'url' => $first_term_url, 'display_name' => $terms[0]->name);
             }
         }
         // start the search for terms that have parents BUT only if the global settings allow us
         if (td_util::get_option('tds_breadcrumbs_show_parent') != 'hide') {
             foreach ($terms as $term) {
                 // check if the term has a parent
                 if ($term->parent != 0) {
                     $parent_term_in_category_spot = get_term($term->parent, $breadcrumbs_taxonomy);
                     // add the parent
                     $parent_url = get_term_link($parent_term_in_category_spot, $breadcrumbs_taxonomy);
                     if (!is_wp_error($parent_url)) {
                         $breadcrumbs_array[0] = array('title_attribute' => '', 'url' => $parent_url, 'display_name' => $parent_term_in_category_spot->name);
                     }
                     // add the child
                     $child_url = get_term_link($term, $breadcrumbs_taxonomy);
                     if (!is_wp_error($child_url)) {
                         $breadcrumbs_array[] = array('title_attribute' => '', 'url' => $child_url, 'display_name' => $term->name);
                     }
                     break;
                     //we found a parent > child
                 }
             }
             // end foreach
         }
     }
     //article title
     if (td_util::get_option('tds_breadcrumbs_show_article') != 'hide') {
         //child category
         $breadcrumbs_array[] = array('title_attribute' => $post->post_title, 'url' => '', 'display_name' => td_util::excerpt($post->post_title, 13));
     }
     return self::get_breadcrumbs($breadcrumbs_array);
 }
开发者ID:ryandong82,项目名称:colorfulladysite,代码行数:56,代码来源:td_page_generator.php

示例2: get_the_tags

 /**
  * get the tags spot of the single post or single custom post type
  * @return string
  */
 function get_the_tags()
 {
     if (td_util::get_option('tds_show_tags') == 'hide') {
         return '';
     }
     $buffy = '';
     $terms_ui_array = array();
     $tags_spot_text = __td('TAGS', TD_THEME_NAME);
     // the default text for tags - on CPT we can overwrite this via the panel
     if ($this->post->post_type != 'post') {
         // on custom post types we need to read what to show in the tag spot from the panel
         $tag_spot_taxonomy = td_util::get_ctp_option($this->post->post_type, 'tds_tag_spot_taxonomy');
         $terms_for_tag_spot = wp_get_post_terms($this->post->ID, $tag_spot_taxonomy);
         foreach ($terms_for_tag_spot as $term_for_tag_spot) {
             $term_for_tag_spot_url = get_term_link($term_for_tag_spot, $tag_spot_taxonomy);
             if (!is_wp_error($term_for_tag_spot_url)) {
                 $terms_ui_array[$term_for_tag_spot->name] = array('url' => $term_for_tag_spot_url);
             }
         }
         // also update the default tag spot text if it's set in the theme's panel
         $new_tag_spot_text = td_util::get_ctp_option($this->post->post_type, 'tds_tag_spot_text');
         if (!empty($new_tag_spot_text)) {
             $tags_spot_text = $new_tag_spot_text;
         }
     } else {
         // on single posts we deal with tags
         $td_post_tags = get_the_tags();
         if (!empty($td_post_tags)) {
             foreach ($td_post_tags as $tag) {
                 $terms_ui_array[$tag->name] = array('url' => get_tag_link($tag->term_id));
             }
         }
     }
     /**
      * output stage
      *  we go in with an array of
      *   array (
      *       $terms_ui_array[tag_name] = array (
      *              'url' => '',
      *       )
      *   )
      */
     if (!empty($terms_ui_array)) {
         $buffy .= '<ul class="td-tags td-post-small-box clearfix">';
         $buffy .= '<li><span>' . $tags_spot_text . '</span></li>';
         foreach ($terms_ui_array as $term_name => $term_params) {
             $buffy .= '<li><a href="' . $term_params['url'] . '">' . $term_name . '</a></li>';
         }
         $buffy .= '</ul>';
     }
     return $buffy;
 }
开发者ID:ryandong82,项目名称:colorfulladysite,代码行数:56,代码来源:td_module_single_base.php

示例3: read

 /**
 * Reads an individual setting - only one setting!
 * @param $read_array -
 * 'ds' => 'data source ID',
  'item_id' = > 'the category id for example', - OPTIONAL category id or author id or page id
 * 'option_id' => 'the option id ex: background'
 * @return returns the value of the setting
 */
 static function read($read_array)
 {
     switch ($read_array['ds']) {
         case 'td_taxonomy':
             return td_util::get_taxonomy_option($read_array['item_id'], $read_array['option_id']);
             break;
         case 'td_cpt':
             return td_util::get_ctp_option($read_array['item_id'], $read_array['option_id']);
             break;
         case 'td_category':
             return td_util::get_category_option($read_array['item_id'], $read_array['option_id']);
             break;
         case 'td_option':
             return td_util::get_option($read_array['option_id']);
             //htmlspecialchars()
             break;
         case 'wp_option':
             return htmlspecialchars(get_option($read_array['option_id']));
             break;
         case 'td_homepage':
             // here we get all the options for the homepage (including widgets?)
             break;
         case 'td_page_option':
             break;
         case 'td_widget':
             break;
             //author metadata
         //author metadata
         case 'td_author':
             return get_the_author_meta($read_array['option_id'], $read_array['item_id']);
             break;
             //wordpress theme mod datasource
         //wordpress theme mod datasource
         case 'wp_theme_mod':
             return htmlspecialchars(get_theme_mod($read_array['option_id']));
             break;
             //wordpress usermenu to menu spot datasource
         //wordpress usermenu to menu spot datasource
         case 'wp_theme_menu_spot':
             $menu_spots_array = get_theme_mod('nav_menu_locations');
             //check to see if there is a menu assigned to that particular option_id (menu id)
             if (isset($menu_spots_array[$read_array['option_id']])) {
                 return $menu_spots_array[$read_array['option_id']];
             } else {
                 return '';
             }
             break;
             //translation data source
         //translation data source
         case 'td_translate':
             //get all the translations (they are stored in the td_008 variable)
             $translations = td_util::get_option('td_translation_map_user');
             if (!empty($translations[$read_array['option_id']])) {
                 return $translations[$read_array['option_id']];
                 //htmlspecialchars()
             } else {
                 return '';
             }
             //return td_util::get_option($read_array['option_id']);
             break;
             //read the ads parameters
             //[ds] => td_ads [option_id] => current_ad_type [item_id] => header - has to become [item_id][option_id]
         //read the ads parameters
         //[ds] => td_ads [option_id] => current_ad_type [item_id] => header - has to become [item_id][option_id]
         case 'td_ads':
             //get all the ad spots (they are stored in the td_008 variable)
             $ads = td_util::get_option('td_ads');
             if (!empty($ads[$read_array['item_id']]) and !empty($ads[$read_array['item_id']][$read_array['option_id']])) {
                 return htmlspecialchars($ads[$read_array['item_id']][$read_array['option_id']]);
             } else {
                 return '';
             }
             break;
             //social networks
         //social networks
         case 'td_social_networks':
             $social_array = td_util::get_option('td_social_networks');
             if (!empty($social_array[$read_array['option_id']])) {
                 return $social_array[$read_array['option_id']];
             } else {
                 return '';
             }
             break;
         case 'td_fonts_user_insert':
             $fonts_user_inserted = td_util::get_option('td_fonts_user_inserted');
             if (!empty($fonts_user_inserted[$read_array['option_id']])) {
                 return $fonts_user_inserted[$read_array['option_id']];
             }
             break;
         case 'td_fonts':
             $fonts_user_inserted = td_util::get_option('td_fonts');
             if (!empty($fonts_user_inserted[$read_array['item_id']][$read_array['option_id']])) {
//.........这里部分代码省略.........
开发者ID:luxifel,项目名称:Bionerd,代码行数:101,代码来源:td_panel_data_source.php


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