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


PHP wp_get_split_term函数代码示例

本文整理汇总了PHP中wp_get_split_term函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_split_term函数的具体用法?PHP wp_get_split_term怎么用?PHP wp_get_split_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: upgrade_21

 /**
  * Detects if taxonomy terms were split and updates the corresponding taxonomy meta's accordingly.
  */
 private function upgrade_21()
 {
     $taxonomies = get_option('wpseo_taxonomy_meta', array());
     if (!empty($taxonomies)) {
         foreach ($taxonomies as $taxonomy => $tax_metas) {
             foreach ($tax_metas as $term_id => $tax_meta) {
                 if (function_exists('wp_get_split_term') && ($new_term_id = wp_get_split_term($term_id, $taxonomy))) {
                     $taxonomies[$taxonomy][$new_term_id] = $taxonomies[$taxonomy][$term_id];
                     unset($taxonomies[$taxonomy][$term_id]);
                 }
             }
         }
         update_option('wpseo_taxonomy_meta', $taxonomies);
     }
 }
开发者ID:Telemedellin,项目名称:feriadelasfloresmedellin,代码行数:18,代码来源:class-upgrade.php

示例2: action_links

 /**
  * Add action links to Stream drop row in admin list screen
  *
  * @filter wp_stream_action_links_{connector}
  *
  * @param array  $links  Previous links registered
  * @param Record $record Stream record
  *
  * @return array Action links
  */
 public function action_links($links, $record)
 {
     if ($record->object_id && 'deleted' !== $record->action && ($term = get_term_by('term_taxonomy_id', $record->object_id, $record->context))) {
         if (!is_wp_error($term)) {
             $tax_obj = get_taxonomy($term->taxonomy);
             $tax_label = isset($tax_obj->labels->singular_name) ? $tax_obj->labels->singular_name : null;
             if (function_exists('wp_get_split_term')) {
                 $term_id = wp_get_split_term($term->term_id, $term->taxonomy);
             }
             $term_id = empty($term_id) ? $term->term_id : $term_id;
             $links[sprintf(_x('Edit %s', 'Term singular name', 'stream'), $tax_label)] = get_edit_term_link($term_id, $term->taxonomy);
             $links[esc_html__('View', 'stream')] = wp_stream_is_vip() ? \wpcom_vip_get_term_link($term_id, $term->taxonomy) : get_term_link($term_id, $term->taxonomy);
         }
     }
     return $links;
 }
开发者ID:evgenykireev,项目名称:stream,代码行数:26,代码来源:class-connector-taxonomies.php

示例3: playlist_output

 /**
  * Create Flowplayer Playlist HTML Output
  *
  * Retrieves a media files and settings to display a video.
  *
  * @since    1.3.0
  *
  * @param    array $atts Shortcode attributes
  */
 private static function playlist_output($atts)
 {
     $playlist_id = $atts['playlist'];
     $playlist_options = get_option('playlist_' . absint($playlist_id));
     // Check if old id is being used in the shortcode
     if (!$playlist_options && function_exists('wp_get_split_term')) {
         $new_term_id = wp_get_split_term(absint($playlist_id), 'playlist');
         $playlist_options = get_option('playlist_' . absint($new_term_id));
         if ($playlist_options) {
             $playlist_id = $new_term_id;
         }
     }
     $atts = Flowplayer5_Playlist::get_videos_by_id($playlist_id);
     if (!$atts) {
         return;
     }
     if (!$playlist_options) {
         $playlist_options['fp5-select-skin'] = 'minimalist';
     }
     ob_start();
     require 'views/partials/playlist.php';
     $html = ob_get_clean();
     return $html;
 }
开发者ID:paolorossi,项目名称:wordpress-flowplayer,代码行数:33,代码来源:class-flowplayer5-output.php

示例4: acf_get_valid_terms

function acf_get_valid_terms($terms = false, $taxonomy = 'category')
{
    // bail early if function does not yet exist or
    if (!function_exists('wp_get_split_term') || empty($terms)) {
        return $terms;
    }
    // vars
    $is_array = is_array($terms);
    // force into array
    $terms = acf_force_type_array($terms);
    // force ints
    $terms = array_map('intval', $terms);
    // attempt to find new terms
    foreach ($terms as $i => $term_id) {
        $new_term_id = wp_get_split_term($term_id, $taxonomy);
        if ($new_term_id) {
            $terms[$i] = $new_term_id;
        }
    }
    // revert array if needed
    if (!$is_array) {
        $terms = $terms[0];
    }
    // return
    return $terms;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:26,代码来源:api-helpers.php

示例5: maybe_get_split_term

 public static function maybe_get_split_term($old_term_id = '', $taxonomy = '')
 {
     $term_id = $old_term_id;
     if ('tag' == $taxonomy) {
         $taxonomy = 'post_tag';
     }
     if (function_exists('wp_get_split_term') && ($new_term_id = wp_get_split_term($old_term_id, $taxonomy))) {
         $term_id = $new_term_id;
     }
     return $term_id;
 }
开发者ID:originallurch,项目名称:elderfinlayson.com,代码行数:11,代码来源:widget-conditions.php

示例6: db_update

 public function db_update()
 {
     $current_db_version = get_option('o2o_db_version');
     if (version_compare($current_db_version, '1.1', '<')) {
         //convert all o2o_term_id meta_keys to be taxonomy specific to adjust for term splitting
         //and fix any previously split terms
         $connections = $this->get_connection_factory()->get_connections();
         $taxonomy_map = array();
         foreach ($connections as $connection) {
             if (method_exists($connection, 'get_taxonomy')) {
                 foreach ($connection->to() as $post_type) {
                     if (!isset($taxonomy_map[$post_type])) {
                         $taxonomy_map[$post_type] = array();
                     }
                     $taxonomy_map[$post_type][] = $connection->get_taxonomy();
                 }
             }
         }
         $wp_query = new WP_Query(array('fields' => 'ids', 'meta_query' => array(array('key' => 'o2o_term_id', 'compare' => 'EXISTS')), 'post_status' => 'any', 'post_type' => array_keys($taxonomy_map), 'posts_per_page' => 100, 'update_post_term_cache' => false, 'cache_results' => false, 'orderby' => 'ID'));
         foreach ($wp_query->posts as $post_id) {
             $term_id = get_post_meta($post_id, 'o2o_term_id', true);
             $post_type = get_post_type($post_id);
             if (isset($taxonomy_map[$post_type])) {
                 foreach ($taxonomy_map[$post_type] as $taxonomy) {
                     if (function_exists('wp_get_split_term') && false !== ($new_term_id = wp_get_split_term($term_id, $taxonomy))) {
                         add_post_meta($post_id, 'o2o_term_id_' . $taxonomy, $new_term_id, true);
                     } else {
                         add_post_meta($post_id, 'o2o_term_id_' . $taxonomy, $term_id, true);
                     }
                 }
             }
             delete_post_meta($post_id, 'o2o_term_id');
         }
         if ($wp_query->found_posts < 100) {
             update_option('o2o_db_version', '1.1');
         }
     }
 }
开发者ID:TimeMagazine,项目名称:objects-to-objects,代码行数:38,代码来源:o2o.php

示例7: wpv_compat_get_split_term

/**
* wpv_compat_get_split_term
*
* In WordPress 4.2, wp_get_split_term() was introduced to get the new term_id for a term that had been splitted 
* because its term_id was shared across several taxonomies
*
* @since 1.8.0
*
* @param int $term_id The term_id to check
* @param string $taxonomy The taxonomy to get the term_id from
-*
* @return bool|int The new term_id if it has changed and the function is available, false otherwise
*/

function wpv_compat_get_split_term( $term_id, $taxonomy ) {
	if ( function_exists( 'wp_get_split_term' ) ) {
		return wp_get_split_term( $term_id, $taxonomy );
	} else {
		return false;
	}
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:21,代码来源:functions-core-embedded.php

示例8: update_1_4_4

 public function update_1_4_4()
 {
     if (!function_exists('wp_get_split_term')) {
         return;
     }
     // Update term ids for memberships (due to term splitting since WP 4.2).
     $memberships = get_posts(array('post_type' => 'ib_edu_membership', 'posts_per_page' => -1));
     if (!empty($memberships)) {
         foreach ($memberships as $post) {
             $meta = get_post_meta($post->ID, '_ib_educator_membership', true);
             if (is_array($meta) && isset($meta['categories']) && is_array($meta['categories'])) {
                 $update = false;
                 foreach ($meta['categories'] as $key => $term_id) {
                     $new_term_id = wp_get_split_term($term_id, 'ib_educator_category');
                     if ($new_term_id) {
                         $meta['categories'][$key] = $new_term_id;
                         $update = true;
                     }
                 }
                 if ($update) {
                     update_post_meta($post->ID, '_ib_educator_membership', $meta);
                 }
             }
         }
     }
 }
开发者ID:zaro,项目名称:ibeducator,代码行数:26,代码来源:Install.php

示例9: split_taxonomies

 /**
  * Split todocategories taxonomy options
  *
  * @static
  * @since 3.4
  */
 public static function split_taxonomies()
 {
     // update dashboard options
     $dashboard = get_option('CTDL_dashboard_settings', array());
     if (is_array($dashboard['category'])) {
         foreach ($dashboard['category'] as $key => $value) {
             $new_term_id = wp_get_split_term($value, 'todocategories');
             if ($new_term_id) {
                 $dashboard['category'][$key] = $new_term_id;
                 update_option('CTDL_dashboard_settings', $dashboard);
             }
         }
     } else {
         $new_term_id = wp_get_split_term($dashboard['category'], 'todocategories');
         if ($new_term_id) {
             $dashboard['category'] = $new_term_id;
             update_option('CTDL_dashboard_settings', $dashboard);
         }
     }
     // update category options
     $visibility = get_option('CTDL_categories', array());
     foreach ($visibility as $key => $value) {
         $key = substr($key, 9);
         $new_term_id = wp_get_split_term($key, 'todocategories');
         if ($new_term_id) {
             $visibility['category_' . $new_term_id] = $value;
             update_option('CTDL_categories', $visibility);
         }
     }
     // update widget options
     $widgets = get_option('widget_cleverness-to-do-widget', array());
     foreach ($widgets as &$widget) {
         $new_term_id = wp_get_split_term($widget['category'], 'todocategories');
         if ($new_term_id) {
             $widget['category'] = $new_term_id;
         }
     }
     update_option('widget_cleverness-to-do-widget', $widgets);
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:45,代码来源:cleverness-to-do-list-library.class.php

示例10: test_wp_get_split_term

 public function test_wp_get_split_term()
 {
     $found = wp_get_split_term($this->terms['t1']['term_id'], 'wptests_tax_3');
     $this->assertEquals($this->terms['t3']['term_id'], $found);
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:5,代码来源:splitSharedTerm.php

示例11: upgrade_check

 private static function upgrade_check()
 {
     $db_version = get_option('VSEO_Version', '0.0');
     if ($db_version < 0.1) {
         Voce_Settings_API::GetInstance()->set_setting('robots-nodp', 'vseo-general', true);
         Voce_Settings_API::GetInstance()->set_setting('robots-noydir', 'vseo-general', true);
     }
     if ($db_version < 0.2 && function_exists('wp_get_split_term')) {
         $term_meta = $updated_term_meta = get_option('vseo_term_meta');
         if (is_array($term_meta)) {
             foreach ($term_meta as $taxonomy_term => $term_data) {
                 $tax_term_arr = explode('_', $taxonomy_term);
                 if (is_array($tax_term_arr) && !empty($tax_term_arr)) {
                     $term_id = array_pop($tax_term_arr);
                     $taxonomy = implode('_', $tax_term_arr);
                     $new_term_id = wp_get_split_term($term_id, $taxonomy);
                     if ($new_term_id !== false) {
                         unset($updated_term_meta[$taxonomy_term]);
                         $updated_term_meta[sprintf('%s_%s', $taxonomy, $new_term_id)] = $term_data;
                     }
                 }
             }
             update_option('vseo_term_meta', $updated_term_meta);
         }
     }
     update_option('VSEO_Version', self::DB_VERSION);
 }
开发者ID:voceconnect,项目名称:voce-seo,代码行数:27,代码来源:voce-seo.php

示例12: process_term_split

 /**
  * Use this function to update BD references of a pre-split term ID to use the new term ID.
  * @since 3.6.4
  */
 public function process_term_split($old_id = 0)
 {
     global $wpdb;
     if (!$old_id) {
         return;
     }
     $new_id = wp_get_split_term($old_id, WPBDP_CATEGORY_TAX);
     if (!$new_id) {
         return;
     }
     // Fees.
     $fees = $wpdb->get_results("SELECT id, categories FROM {$wpdb->prefix}wpbdp_fees");
     foreach ($fees as &$f) {
         $categories = unserialize($f->categories);
         if (isset($categories['all']) && $categories['all'] || empty($categories['categories'])) {
             continue;
         }
         $index = array_search($old_id, $categories['categories']);
         if ($index === false) {
             continue;
         }
         $categories['categories'][$index] = $new_id;
         $wpdb->update($wpdb->prefix . 'wpbdp_fees', array('categories' => serialize($categories)), array('id' => $f->id));
     }
     // Listing fees.
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}wpbdp_listing_fees SET category_id = %d WHERE category_id = %d", $new_id, $old_id));
     // Payments.
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}wpbdp_payments_items SET rel_id_1 = %d WHERE ( rel_id_1 = %d AND ( item_type = %s OR item_type = %s ) )", $new_id, $old_id, 'fee', 'recurring_fee'));
     // Category images.
     $imgs = get_option('wpbdp[category_images]', false);
     if (empty($imgs) || !is_array($imgs)) {
         return;
     }
     if (!empty($imgs['images']) && isset($imgs['images'][$old_id])) {
         $imgs['images'][$new_id] = $imgs['images'][$old_id];
         unset($imgs['images'][$old_id]);
     }
     if (!empty($imgs['temp']) && isset($imgs['temp'][$old_id])) {
         $imgs['temp'][$new_id] = $imgs['temp'][$old_id];
         unset($imgs['temp'][$old_id]);
     }
     update_option('wpbdp[category_images]', $imgs);
 }
开发者ID:Nedick,项目名称:stzagora-website,代码行数:47,代码来源:installer.php

示例13: _handle_split_term_ids

 /**
  * If the data was exported PRE-4.2, but then imported POST-4.2, then the term_id
  * this term-taxonomy refers to may be out-of-date so we need to update it.
  * see https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/
  * @param type $model_object_data
  * @return array new model object data
  */
 protected function _handle_split_term_ids($model_object_data)
 {
     if (isset($model_object_data['term_id']) && isset($model_object_data['taxonomy']) && apply_filters('FHEE__EE_Import__handle_split_term_ids__function_exists', function_exists('wp_get_split_term'), $model_object_data)) {
         $new_term_id = wp_get_split_term($model_object_data['term_id'], $model_object_data['taxonomy']);
         if ($new_term_id) {
             $model_object_data['term_id'] = $new_term_id;
         }
     }
     return $model_object_data;
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:17,代码来源:EE_Import.class.php


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