• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP update_meta_cache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: set_dfi_meta_key

 /**
  * Mostly the same as `get_metadata()` makes sure any postthumbnail function gets checked at
  * the deepest level possible.
  *
  * @see /wp-includes/meta.php get_metadata()
  *
  * @param null $null
  * @param int $object_id ID of the object metadata is for
  * @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for
  *   the specified object.
  * @param bool $single Optional, default is false. If true, return only the first value of the
  *   specified meta_key. This parameter has no effect if meta_key is not specified.
  * @return string|array Single metadata value, or array of values
  */
 function set_dfi_meta_key($null = null, $object_id, $meta_key, $single)
 {
     // only affect thumbnails on the frontend, do allow ajax calls
     if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX) || '_thumbnail_id' != $meta_key) {
         return $null;
     }
     $meta_type = 'post';
     $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
     if (!$meta_cache) {
         $meta_cache = update_meta_cache($meta_type, array($object_id));
         $meta_cache = $meta_cache[$object_id];
     }
     if (!$meta_key) {
         return $meta_cache;
     }
     if (isset($meta_cache[$meta_key])) {
         if ($single) {
             return maybe_unserialize($meta_cache[$meta_key][0]);
         } else {
             return array_map('maybe_unserialize', $meta_cache[$meta_key]);
         }
     }
     if ($single) {
         // allow to set an other ID see the readme.txt for details
         return apply_filters('dfi_thumbnail_id', get_option('dfi_image_id'), $object_id);
     } else {
         return array();
     }
 }
开发者ID:shazadmaved,项目名称:vizblog,代码行数:43,代码来源:set-default-featured-image.php


示例2: cache_p2p_meta

 /**
  * Pre-populates the p2p meta cache to decrease the number of queries.
  */
 static function cache_p2p_meta($the_posts, $wp_query)
 {
     if (isset($wp_query->_p2p_query) && !empty($the_posts)) {
         update_meta_cache('p2p', wp_list_pluck($the_posts, 'p2p_id'));
     }
     return $the_posts;
 }
开发者ID:TyRichards,项目名称:ty_the_band,代码行数:10,代码来源:query-post.php


示例3: get_meta_cache

 private static function get_meta_cache($object_id, $meta_type)
 {
     $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
     if (!$meta_cache) {
         $meta_cache = update_meta_cache($meta_type, array($object_id));
         $meta_cache = $meta_cache[$object_id];
     }
     return $meta_cache;
 }
开发者ID:jsmoriss,项目名称:inherit-featured-image,代码行数:9,代码来源:inherit-featured-image.php


示例4: register_member_type

 /**
  * Register all active member types
  * 
  */
 public function register_member_type()
 {
     //$this->register_post_type();
     $is_root_blog = bp_is_root_blog();
     //if we are not on the main bp site, switch to it before registering member type
     if (!$is_root_blog) {
         switch_to_blog(bp_get_root_blog_id());
     }
     //get all posts in memeber type post type
     $post_ids = $this->get_active_member_types();
     // get_posts( array( 'post_type'=> bp_member_type_generator()->get_post_type(), 'posts_per_page'=> -1, 'post_status'=> 'publish' ) );
     //update meta cache to avoid multiple db calls
     update_meta_cache('post', $post_ids);
     //build to register the memebr type
     $member_types = array();
     foreach ($post_ids as $post_id) {
         $is_active = get_post_meta($post_id, '_bp_member_type_is_active', true);
         $name = get_post_meta($post_id, '_bp_member_type_name', true);
         if (!$is_active || !$name) {
             continue;
             //if not active or no unique key, do not register
         }
         $enable_directory = get_post_meta($post_id, '_bp_member_type_enable_directory', true);
         $directory_slug = get_post_meta($post_id, '_bp_member_type_directory_slug', true);
         $has_dir = false;
         if ($enable_directory) {
             if ($directory_slug) {
                 $has_dir = $directory_slug;
             } else {
                 $has_dir = true;
             }
         }
         $member_types[$name] = array('labels' => array('name' => get_post_meta($post_id, '_bp_member_type_label_name', true), 'singular_name' => get_post_meta($post_id, '_bp_member_type_label_singular_name', true)), 'has_directory' => $has_dir);
     }
     foreach ($member_types as $member_type => $args) {
         bp_register_member_type($member_type, $args);
     }
     if (!$is_root_blog) {
         restore_current_blog();
     }
 }
开发者ID:buddydev,项目名称:bp-member-type-generator,代码行数:45,代码来源:actions.php


示例5: metadata_exists

function metadata_exists($meta_type, $object_id, $meta_key)
{
    if (!$meta_type || !is_numeric($object_id)) {
        return false;
    }
    $object_id = absint($object_id);
    if (!$object_id) {
        return false;
    }
    /** This filter is documented in wp-includes/meta.php */
    $check = apply_filters("get_{$meta_type}_metadata", null, $object_id, $meta_key, true);
    if (null !== $check) {
        return (bool) $check;
    }
    $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
    if (!$meta_cache) {
        $meta_cache = update_meta_cache($meta_type, array($object_id));
        $meta_cache = $meta_cache[$object_id];
    }
    if (isset($meta_cache[$meta_key])) {
        return true;
    }
    return false;
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:24,代码来源:meta.php


示例6: get_user_metavalues

/**
 * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
 *
 * @since 3.0.0
 * @deprecated 3.3.0
 *
 * @param array $ids User ID numbers list.
 * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
 */
function get_user_metavalues($ids)
{
    _deprecated_function(__FUNCTION__, '3.3');
    $objects = array();
    $ids = array_map('intval', $ids);
    foreach ($ids as $id) {
        $objects[$id] = array();
    }
    $metas = update_meta_cache('user', $ids);
    foreach ($metas as $id => $meta) {
        foreach ($meta as $key => $metavalues) {
            foreach ($metavalues as $value) {
                $objects[$id][] = (object) array('user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
            }
        }
    }
    return $objects;
}
开发者ID:rkglug,项目名称:WordPress,代码行数:27,代码来源:deprecated.php


示例7: update_termmeta_cache

/**
 * Updates metadata cache for list of term IDs.
 *
 * Performs SQL query to retrieve all metadata for the terms matching `$term_ids` and stores them in the cache.
 * Subsequent calls to `get_term_meta()` will not need to query the database.
 *
 * @since 4.4.0
 *
 * @param array $term_ids List of term IDs.
 * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success.
 */
function update_termmeta_cache($term_ids)
{
    // Bail if term meta table is not installed.
    if (get_option('db_version') < 34370) {
        return;
    }
    return update_meta_cache('term', $term_ids);
}
开发者ID:n8maninger,项目名称:WordPress,代码行数:19,代码来源:taxonomy-functions.php


示例8: get_events_between

 /**
  * get_events_between function
  *
  * Return all events starting after the given start time and before the
  * given end time that the currently logged in user has permission to view.
  * If $spanning is true, then also include events that span this
  * period. All-day events are returned first.
  *
  * @param int $start_time   limit to events starting after this (local) UNIX time
  * @param int $end_time     limit to events starting before this (local) UNIX time
  * @param array $filter     Array of filters for the events returned:
  *                          ['cat_ids']   => non-associatative array of category IDs
  *                          ['tag_ids']   => non-associatative array of tag IDs
  *                          ['post_ids']  => non-associatative array of post IDs
  *                          ['auth_ids']  => non-associatative array of author IDs
  * @param bool $spanning    also include events that span this period
  *
  * @return array            list of matching event objects
  */
 function get_events_between($start_time, $end_time, $filter, $spanning = false)
 {
     global $wpdb, $ai1ec_events_helper, $ai1ec_localization_helper;
     // Convert timestamps to MySQL format in GMT time
     $start_time = $ai1ec_events_helper->local_to_gmt($start_time);
     $end_time = $ai1ec_events_helper->local_to_gmt($end_time);
     // Query arguments
     $args = array($start_time, $end_time);
     // Get post status Where snippet and associated SQL arguments
     $this->_get_post_status_sql($post_status_where, $args);
     // Get the Join (filter_join) and Where (filter_where) statements based on
     // $filter elements specified
     $this->_get_filter_sql($filter);
     $wpml_join_particle = $ai1ec_localization_helper->get_wpml_table_join('p.ID');
     $wpml_where_particle = $ai1ec_localization_helper->get_wpml_table_where();
     $query = $wpdb->prepare("SELECT p.*, e.post_id, i.id AS instance_id, " . "i.start AS start, " . "i.end AS end, " . 'e.allday AS event_allday, ' . "e.recurrence_rules, e.exception_rules, e.recurrence_dates, e.exception_dates, " . "e.venue, e.country, e.address, e.city, e.province, e.postal_code, e.instant_event, " . "e.show_map, e.contact_name, e.contact_phone, e.contact_email, e.cost, e.ticket_url, " . "e.ical_feed_url, e.ical_source_url, e.ical_organizer, e.ical_contact, e.ical_uid " . "FROM {$wpdb->prefix}ai1ec_events e " . "INNER JOIN {$wpdb->posts} p ON p.ID = e.post_id " . $wpml_join_particle . "INNER JOIN {$wpdb->prefix}ai1ec_event_instances i ON e.post_id = i.post_id " . $filter['filter_join'] . "WHERE post_type = '" . AI1EC_POST_TYPE . "' " . $wpml_where_particle . "AND " . ($spanning ? "i.end > %d AND i.start < %d " : "i.start BETWEEN %d AND %d ") . $filter['filter_where'] . $post_status_where . 'GROUP BY i.id ' . 'ORDER BY allday DESC, i.start ASC, post_title ASC', $args);
     $events = $wpdb->get_results($query, ARRAY_A);
     $id_list = array();
     foreach ($events as $event) {
         $id_list[] = $event['post_id'];
     }
     if (!empty($id_list)) {
         update_meta_cache('post', $id_list);
     }
     foreach ($events as &$event) {
         $event['start'] = $event['start'];
         $event['end'] = $event['end'];
         $event['allday'] = $this->_is_all_day($event);
         $event = new Ai1ec_Event($event);
     }
     return $events;
 }
开发者ID:briancompton,项目名称:knightsplaza,代码行数:51,代码来源:class-ai1ec-calendar-helper.php


示例9: update_termmeta_cache

 function update_termmeta_cache($term_ids)
 {
     return update_meta_cache('term', $term_ids);
 }
开发者ID:WildDadlaga,项目名称:wildpress,代码行数:4,代码来源:termmeta-core.php


示例10: wp_make_content_images_responsive

/**
 * Filters 'img' elements in post content to add 'srcset' and 'sizes' attributes.
 *
 * @since 4.4.0
 *
 * @see wp_image_add_srcset_and_sizes()
 *
 * @param string $content The raw post content to be filtered.
 * @return string Converted content with 'srcset' and 'sizes' attributes added to images.
 */
function wp_make_content_images_responsive($content)
{
    if (!preg_match_all('/<img [^>]+>/', $content, $matches)) {
        return $content;
    }
    $selected_images = $attachment_ids = array();
    foreach ($matches[0] as $image) {
        if (false === strpos($image, ' srcset=') && preg_match('/wp-image-([0-9]+)/i', $image, $class_id) && ($attachment_id = absint($class_id[1]))) {
            /*
             * If exactly the same image tag is used more than once, overwrite it.
             * All identical tags will be replaced later with 'str_replace()'.
             */
            $selected_images[$image] = $attachment_id;
            // Overwrite the ID when the same image is included more than once.
            $attachment_ids[$attachment_id] = true;
        }
    }
    if (count($attachment_ids) > 1) {
        /*
         * Warm object cache for use with 'get_post_meta()'.
         *
         * To avoid making a database call for each image, a single query
         * warms the object cache with the meta information for all images.
         */
        update_meta_cache('post', array_keys($attachment_ids));
    }
    foreach ($selected_images as $image => $attachment_id) {
        $image_meta = get_post_meta($attachment_id, '_wp_attachment_metadata', true);
        $content = str_replace($image, wp_image_add_srcset_and_sizes($image, $image_meta, $attachment_id), $content);
    }
    return $content;
}
开发者ID:nakamuraagatha,项目名称:reseptest,代码行数:42,代码来源:media.php


示例11: dsq_clear_pending_post_ids

function dsq_clear_pending_post_ids($post_ids)
{
    if (count($post_ids) < 1) {
        return;
    }
    global $wpdb;
    $posts_query = implode(', ', array_fill(0, count($post_ids), '%s'));
    // add as many placeholders as needed
    $sql = "\r\n        DELETE FROM {$wpdb->postmeta} \r\n        WHERE meta_key = 'dsq_needs_sync' AND post_id IN (" . $posts_query . ")\r\n    ";
    // Call $wpdb->prepare passing the values of the array as separate arguments
    $query = call_user_func_array(array($wpdb, 'prepare'), array_merge(array($sql), $post_ids));
    $wpdb->query($query);
    update_meta_cache('dsq_needs_sync', $post_ids);
}
开发者ID:VizualAbstract,项目名称:Marilyn,代码行数:14,代码来源:disqus.php


示例12: get_metadata

/**
 * Retrieve metadata for the specified object.
 *
 * @since 2.9.0
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
 * @param int $object_id ID of the object metadata is for
 * @param string $meta_key Optional.  Metadata key.  If not specified, retrieve all metadata for
 * 		the specified object.
 * @param bool $single Optional, default is false.  If true, return only the first value of the
 * 		specified meta_key.  This parameter has no effect if meta_key is not specified.
 * @return string|array Single metadata value, or array of values
 */
function get_metadata($meta_type, $object_id, $meta_key = '', $single = false)
{
    if (!$meta_type) {
        return false;
    }
    if (!($object_id = absint($object_id))) {
        return false;
    }
    $check = apply_filters("get_{$meta_type}_metadata", null, $object_id, $meta_key, $single);
    if (null !== $check) {
        if ($single && is_array($check)) {
            return $check[0];
        } else {
            return $check;
        }
    }
    $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
    if (!$meta_cache) {
        $meta_cache = update_meta_cache($meta_type, array($object_id));
        $meta_cache = $meta_cache[$object_id];
    }
    if (!$meta_key) {
        return $meta_cache;
    }
    if (isset($meta_cache[$meta_key])) {
        if ($single) {
            return maybe_unserialize($meta_cache[$meta_key][0]);
        } else {
            return array_map('maybe_unserialize', $meta_cache[$meta_key]);
        }
    }
    if ($single) {
        return '';
    } else {
        return array();
    }
}
开发者ID:fka2004,项目名称:webkit,代码行数:50,代码来源:meta.php


示例13: get_meta

 /**
  * @param $object_type
  * @param null $_null
  * @param int $object_id
  * @param string $meta_key
  * @param bool $single
  *
  * @return array|bool|int|mixed|null|string|void
  */
 public function get_meta($object_type, $_null = null, $object_id = 0, $meta_key = '', $single = false)
 {
     $meta_type = $object_type;
     if ('post_type' == $meta_type) {
         $meta_type = 'post';
     }
     if (empty($meta_key)) {
         $single = false;
     }
     $object = $this->get_object($object_type, $object_id);
     if (empty($object_id) || empty($object)) {
         return $_null;
     }
     $no_conflict = pods_no_conflict_check($meta_type);
     if (!$no_conflict) {
         pods_no_conflict_on($meta_type);
     }
     $meta_cache = array();
     if (!$single && isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
         $meta_cache = wp_cache_get($object_id, 'pods_' . $meta_type . '_meta');
         if (empty($meta_cache)) {
             $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
             if (empty($meta_cache)) {
                 $meta_cache = update_meta_cache($meta_type, array($object_id));
                 $meta_cache = $meta_cache[$object_id];
             }
         }
     }
     if (empty($meta_cache) || !is_array($meta_cache)) {
         $meta_cache = array();
     }
     $pod = pods($object['name']);
     $meta_keys = array($meta_key);
     if (empty($meta_key)) {
         $meta_keys = array_keys($meta_cache);
     }
     $key_found = false;
     foreach ($meta_keys as $meta_k) {
         if (!empty($pod)) {
             if (isset($pod->fields[$meta_k])) {
                 if (empty($pod->id)) {
                     $pod->fetch($object_id);
                     $pod->id = $object_id;
                 }
                 $key_found = true;
                 $meta_cache[$meta_k] = $pod->field(array('name' => $meta_k, 'single' => $single, 'get_meta' => true));
                 if (!is_array($meta_cache[$meta_k]) || !isset($meta_cache[$meta_k][0])) {
                     if (empty($meta_cache[$meta_k]) && !is_array($meta_cache[$meta_k]) && $single) {
                         $meta_cache[$meta_k] = array();
                     } else {
                         $meta_cache[$meta_k] = array($meta_cache[$meta_k]);
                     }
                 }
                 if (in_array($pod->fields[$meta_k]['type'], PodsForm::tableless_field_types()) && isset($meta_cache['_pods_' . $meta_k])) {
                     unset($meta_cache['_pods_' . $meta_k]);
                 }
             } elseif (false !== strpos($meta_k, '.')) {
                 if (empty($pod->id)) {
                     $pod->fetch($object_id);
                     $pod->id = $object_id;
                 }
                 $key_found = true;
                 $first = current(explode('.', $meta_k));
                 if (isset($pod->fields[$first])) {
                     $meta_cache[$meta_k] = $pod->field(array('name' => $meta_k, 'single' => $single, 'get_meta' => true));
                     if ((!is_array($meta_cache[$meta_k]) || !isset($meta_cache[$meta_k][0])) && $single) {
                         if (empty($meta_cache[$meta_k]) && !is_array($meta_cache[$meta_k]) && $single) {
                             $meta_cache[$meta_k] = array();
                         } else {
                             $meta_cache[$meta_k] = array($meta_cache[$meta_k]);
                         }
                     }
                     if (in_array($pod->fields[$first]['type'], PodsForm::tableless_field_types()) && isset($meta_cache['_pods_' . $first])) {
                         unset($meta_cache['_pods_' . $first]);
                     }
                 }
             }
         }
     }
     if (!$no_conflict) {
         pods_no_conflict_off($meta_type);
     }
     unset($pod);
     // memory clear
     if (!$key_found) {
         return $_null;
     }
     if (!$single && isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
         wp_cache_set($object_id, $meta_cache, 'pods_' . $meta_type . '_meta');
     }
     if (empty($meta_key)) {
//.........这里部分代码省略.........
开发者ID:centaurustech,项目名称:chipin,代码行数:101,代码来源:PodsMeta.php


示例14: convert_datatables_parameter_names_tp15

 /**
  * Convert old parameter names to new ones in DataTables "Custom Commands".
  * DataTables 1.9 used Hungarian notation, while DataTables 1.10+ (used since TablePress 1.5) uses camelCase notation.
  *
  * @since 1.5.0
  */
 public function convert_datatables_parameter_names_tp15()
 {
     $table_post = $this->tables->get('table_post');
     if (empty($table_post)) {
         return;
     }
     // Prime the meta cache with the table options of all tables.
     update_meta_cache('post', array_values($table_post));
     foreach ($table_post as $table_id => $post_id) {
         $table_options = $this->_get_table_options($post_id);
         // Nothing to do if there are no "Custom Commands".
         if (empty($table_options['datatables_custom_commands'])) {
             continue;
         }
         // Run search/replace.
         $old_custom_commands = $table_options['datatables_custom_commands'];
         $table_options['datatables_custom_commands'] = strtr($table_options['datatables_custom_commands'], $this->datatables_parameter_mappings);
         // No need to save (which runs a DB query) if nothing was replaced in the "Custom Commands".
         if ($old_custom_commands === $table_options['datatables_custom_commands']) {
             continue;
         }
         $this->_update_table_options($post_id, $table_options);
     }
 }
开发者ID:akumanu,项目名称:wordpress-gk,代码行数:30,代码来源:model-table.php


示例15: dsq_clear_pending_post_ids

function dsq_clear_pending_post_ids($post_ids)
{
    global $wpdb;
    $post_ids_query = "'" . implode("', '", $post_ids) . "'";
    $wpdb->query($wpdb->prepare("\r\n        DELETE FROM {$wpdb->postmeta} \r\n        WHERE meta_key = 'dsq_needs_sync' AND post_id IN (%s)\r\n    ", $post_ids_query));
    update_meta_cache('dsq_needs_sync', $post_ids);
}
开发者ID:RagnarDanneskjold,项目名称:goodbyeloans.com,代码行数:7,代码来源:disqus.php


示例16: mp_core_get_post_meta_or_never_been_saved

/**
 * Get a post meta or, if it's never been saved, return false. This function is based on the "get_metadata" function in WP core.
 *
 * @param int $object_id ID of the object metadata is for
 * @param string $meta_key Metadata key. 
 * @return string If never been saved return: 'never_been_saved_73698363746983746' otherwise return the value saved for this meta. 
 */
function mp_core_get_post_meta_or_never_been_saved($object_id, $meta_key)
{
    if (!is_numeric($object_id)) {
        return false;
    }
    $object_id = absint($object_id);
    if (!$object_id) {
        return false;
    }
    /**
     * Filter whether to retrieve metadata of a specific type.
     *
     * The dynamic portion of the hook, $meta_type, refers to the meta
     * object type (comment, post, or user). Returning a non-null value
     * will effectively short-circuit the function.
     *
     * @since 3.1.0
     *
     * @param null|array|string $value     The value get_metadata() should
     *                                     return - a single metadata value,
     *                                     or an array of values.
     * @param int               $object_id Object ID.
     * @param string            $meta_key  Meta key.
     * @param string|array      $single    Meta value, or an array of values.
     */
    $check = apply_filters("get_post_metadata", null, $object_id, $meta_key, true);
    if (null !== $check) {
        if ($single && is_array($check)) {
            return $check[0];
        } else {
            return $check;
        }
    }
    $meta_cache = wp_cache_get($object_id, 'post' . '_meta');
    if (!$meta_cache) {
        $meta_cache = update_meta_cache('post', array($object_id));
        $meta_cache = $meta_cache[$object_id];
    }
    if (!$meta_key) {
        return $meta_cache;
    }
    if (isset($meta_cache[$meta_key])) {
        return maybe_unserialize($meta_cache[$meta_key][0]);
    }
    //Return string if this field has never been saved before (with the number added just to make it extremely unlikely that a field would save this exact value for another purpose. Don't hate the playa, hate the game).
    return 'never_been_saved_73698363746983746';
}
开发者ID:arrezende,项目名称:promillus,代码行数:54,代码来源:misc-functions.php


示例17: qtranxf_translate_metadata

/**
 * @since 3.2.3 translation of meta data
 * @since 3.4.6.4 improved caching algorithm
 */
function qtranxf_translate_metadata($meta_type, $original_value, $object_id, $meta_key = '', $single = false)
{
    global $q_config;
    static $meta_cache_unserialized = array();
    if (!isset($q_config['url_info'])) {
        //qtranxf_dbg_log('qtranxf_filter_postmeta: too early: $object_id='.$object_id.'; $meta_key',$meta_key,true);
        return $original_value;
    }
    //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_key=',$meta_key);
    //$meta_type = 'post';
    $lang = $q_config['language'];
    $cache_key = $meta_type . '_meta';
    $cache_key_lang = $cache_key . $lang;
    $meta_cache_wp = wp_cache_get($object_id, $cache_key);
    if ($meta_cache_wp) {
        //if there is wp cache, then we check if there is qtx cache
        $meta_cache = wp_cache_get($object_id, $cache_key_lang);
    } else {
        //reset qtx cache, since it would not be valid in the absence of wp cache
        qtranxf_cache_delete_metadata($meta_type, $object_id);
        $meta_cache = null;
    }
    if (!isset($meta_cache_unserialized[$meta_type])) {
        $meta_cache_unserialized[$meta_type] = array();
    }
    if (!isset($meta_cache_unserialized[$meta_type][$object_id])) {
        $meta_cache_unserialized[$meta_type][$object_id] = array();
    }
    $meta_unserialized =& $meta_cache_unserialized[$meta_type][$object_id];
    if (!$meta_cache) {
        if ($meta_cache_wp) {
            $meta_cache = $meta_cache_wp;
        } else {
            $meta_cache = update_meta_cache($meta_type, array($object_id));
            $meta_cache = $meta_cache[$object_id];
        }
        $meta_unserialized = array();
        //clear this cache if we are re-doing meta_cache
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache before:',$meta_cache);
        foreach ($meta_cache as $mkey => $mval) {
            $meta_unserialized[$mkey] = array();
            if (strpos($mkey, '_url') !== false) {
                switch ($mkey) {
                    case '_menu_item_url':
                        break;
                        // function qtranxf_wp_get_nav_menu_items takes care of this later
                    // function qtranxf_wp_get_nav_menu_items takes care of this later
                    default:
                        foreach ($mval as $k => $v) {
                            $s = is_serialized($v);
                            if ($s) {
                                $v = unserialize($v);
                            }
                            $v = qtranxf_convertURLs($v, $lang);
                            $meta_unserialized[$mkey][$k] = $v;
                            if ($s) {
                                $v = serialize($v);
                            }
                            $meta_cache[$mkey][$k] = $v;
                        }
                        break;
                }
            } else {
                foreach ($mval as $k => $v) {
                    if (!qtranxf_isMultilingual($v)) {
                        continue;
                    }
                    $s = is_serialized($v);
                    if ($s) {
                        $v = unserialize($v);
                    }
                    $v = qtranxf_use($lang, $v, false, false);
                    $meta_unserialized[$mkey][$k] = $v;
                    if ($s) {
                        $v = serialize($v);
                    }
                    $meta_cache[$mkey][$k] = $v;
                }
            }
        }
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache  after:',$meta_cache);
        wp_cache_set($object_id, $meta_cache, $cache_key_lang);
    }
    if (!$meta_key) {
        if ($single) {
            /**
             @since 3.2.9.9.7
             The code executed after a call to this filter in /wp-includes/meta.php,
             in function get_metadata, is apparently designed having non-empty $meta_key in mind:
            
             	if ( $single && is_array( $check ) ){
             		return $check[0];
             	}else
             		return $check;
            
             Following the logic of the code "if ( !$meta_key ) return $meta_cache;",
//.........这里部分代码省略.........
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:101,代码来源:qtranslate_frontend.php


示例18: get_post_metadata

 /**
  * Filters Post metadata being retrieved before it's returned to caller.
  *
  * @param mixed metadata The original metadata.
  * @param int object_id The post ID.
  * @param meta_key The metadata to be retrieved.
  * @return mixed The metadata value.
  */
 public function get_post_metadata($metadata, $object_id, $meta_key)
 {
     if (version_compare($this->wc()->version, '2.1', '>=')) {
         return $metadata;
     }
     // WooCommerce 2.0.x only
     // This method is only called during generation of "Sales overview" report
     // page. Order totals in base currency should be used for reporting.
     // NOTE: this method of returning the order totals in base currency is a hack,
     // but there is no other way to do it, because the "Sales overview" reports
     // don't call a hook that allows to alter the values, or the fields retrieved,
     // but they just call get_post_meta() for every order.
     // See file woocommerce-admin-reports.php, method woocommerce_sales_overview(),
     // line ~472.
     if ($meta_key == '_order_total') {
         $meta_cache = update_meta_cache('post', array($object_id));
         $obj_cache = $meta_cache[$object_id];
         $order = new Aelia_Order($object_id);
         return $order->get_total_in_base_currency();
     }
     return $metadata;
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:30,代码来源:woocommerce-aelia-currencyswitcher.php


示例19: eventorganiser_update_venue_meta_cache

/**
 * Updates venue meta cache when event venues are retrieved.
 *
 * For backwards compatibility it adds the venue details to the taxonomy terms.
 * Hooked onto get_terms and get_event-venue
 *
 * @ignore
 * @access private
 * @since 1.5
 *
 * @param array $terms Array of terms,
 * @param string $tax Should be (an array containing) 'event-venue'.
 * @param array  Array of event-venue terms,
 */
function eventorganiser_update_venue_meta_cache($terms, $tax)
{
    if (is_array($tax) && !in_array('event-venue', $tax)) {
        return $terms;
    }
    if (!is_array($tax) && $tax != 'event-venue') {
        return $terms;
    }
    $single = false;
    if (!is_array($terms)) {
        $single = true;
        $terms = array($terms);
    }
    if (empty($terms)) {
        return $terms;
    }
    //Check if its array of terms or term IDs
    $first_element = reset($terms);
    if (is_object($first_element)) {
        $term_ids = wp_list_pluck($terms, 'term_id');
    } else {
        $term_ids = $terms;
    }
    update_meta_cache('eo_venue', $term_ids);
    //Backwards compatible. Depreciated - use the functions, not properties.
    foreach ($terms as $term) {
        if (!is_object($term)) {
            continue;
        }
        $term_id = (int) $term->term_id;
        if (!isset($term->venue_address)) {
            $address = eo_get_venue_address($term_id);
            foreach ($address as $key => $value) {
                $term->{'venue_' . $key} = $value;
            }
        }
        if (!isset($term->venue_lat) || !isset($term->venue_lng)) {
            $term->venue_lat = number_format(floatval(eo_get_venue_lat($term_id)), 6);
            $term->venue_lng = number_format(floatval(eo_get_venue_lng($term_id)), 6);
        }
    }
    if ($single) {
        return $terms[0];
    }
    return $terms;
}
开发者ID:windyjonas,项目名称:fredrika,代码行数:60,代码来源:event-organiser-cpt.php


示例20: qtranxf_filter_postmeta

/**
 * @since 3.2.3 translation of postmeta
 */
function qtranxf_filter_postmeta($original_value, $object_id, $meta_key = '', $single = false)
{
    global $q_config;
    if (!isset($q_config['url_info'])) {
        //qtranxf_dbg_log('qtranxf_filter_postmeta: too early: $object_id='.$object_id.'; $meta_key',$meta_key,true);
        return $original_value;
    }
    //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_key=',$meta_key);
    $meta_type = 'post';
    $lang = $q_config['language'];
    $cache_key = $meta_type . '_meta';
    $cache_key_lang = $cache_key . $lang;
    $meta_cache_wp = wp_cache_get($object_id, $cache_key);
    if ($meta_cache_wp) {
        //if there is wp cache, then we check if there is qtx cache
        $meta_cache = wp_cache_get($object_id, $cache_key_lang);
    } else {
        //reset qtx cache, since it would not be valid in the absence of wp cache
        qtranxf_cache_delete_postmeta($object_id);
        $meta_cache = null;
    }
    if (!$meta_cache) {
        if ($meta_cache_wp) {
            $meta_cache = $meta_cache_wp;
        } else {
            $meta_cache = update_meta_cache($meta_type, array($object_id));
            $meta_cache = $meta_cache[$object_id];
        }
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache before:',$meta_cache);
        foreach ($meta_cache as $mkey => $mval) {
            if (strpos($mkey, '_url') !== false) {
                $val = array_map('maybe_unserialize', $mval);
                switch ($mkey) {
                    case '_menu_item_url':
                        break;
                        // function qtranxf_wp_get_nav_menu_items takes care of this later
                    // function qtranxf_wp_get_nav_menu_items takes care of this later
                    default:
                        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache['.$mkey.'] url before:',$val);
                        $val = qtranxf_convertURLs($val, $lang);
                        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache['.$mkey.'] url  after:',$val);
                        break;
                }
            } else {
                $val = array();
                foreach ($mval as $k => $v) {
                    $ml = qtranxf_isMultilingual($v);
                    $v = maybe_unserialize($v);
                    if ($ml) {
                        $v = qtranxf_use($lang, $v, false, false);
                    }
                    $val[$k] = $v;
                }
            }
            $meta_cache[$mkey] = $val;
        }
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache  after:',$meta_cache);
        wp_cache_set($object_id, $meta_cache, $cache_key_lang);
    }
    if (!$meta_key) {
        if ($single) {
            /**
             @since 3.2.9.9.7
             The code executed after a call to this filter in /wp-includes/meta.php,
             in function get_metadata, is apparently designed having non-empty $meta_key in mind:
            
             	if ( $single && is_array( $check ) ){
             		return $check[0];
             	}else
             		return $check;
            
             Following the logic of the code "if ( !$meta_key ) return $meta_cache;",
            		a few lines below in the same function, the code above rather have to be:
            
             	if ( $meta_key && $single && is_array( $check ) ){
             		return $check[0];
             	}else
             		return $check;
            
             The line below offsets this imperfection.
             If WP ever fixes that place, this block of code will have to be removed.
            */
            return array($meta_cache);
        }
        return $meta_cache;
    }
    if (isset($meta_cache[$meta_key])) {
        return $meta_cache[$meta_key];
    }
    if ($single) {
        return '';
    } else {
        return array();
    }
}
开发者ID:ycms,项目名称:framework,代码行数:98,代码来源:qtranslate_frontend.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP update_metadata函数代码示例发布时间:2022-05-23
下一篇:
PHP update_meta函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap