add_meta() public method

public add_meta ( $id = false, $key = false, $value = false, $duplicate = false )
コード例 #1
0
/**
 *
 * Add multiple meta key and value for media.
 *
 * @param $media_id
 * @param $meta_key_val
 *
 * @return array
 */
function rtmedia_add_multiple_meta($media_id, $meta_key_val)
{
    $meta_ids = array();
    if (!empty($media_id) && !empty($meta_key_val)) {
        $media_meta = new RTMediaMeta();
        foreach ($meta_key_val as $meta_key => $meta_val) {
            $meta_ids[] = $media_meta->add_meta($media_id, $meta_key, $meta_val);
        }
    }
    return $meta_ids;
}
コード例 #2
0
function add_rtmedia_meta($id = false, $key = false, $value = false, $duplicate = false)
{
    if (apply_filters('rtmedia_use_legacy_meta_function', false)) {
        $rtmediameta = new RTMediaMeta($id, $key, $value, $duplicate);
        return $rtmediameta->add_meta($id, $key, $value, $duplicate);
    } else {
        // use WP's default get_metadata function replace column name from "media_id" to "id" in query
        add_filter('query', 'rtm_filter_metaid_column_name');
        $meta = add_metadata('media', $id, $key, $value, !$duplicate);
        remove_filter('query', 'rtm_filter_metaid_column_name');
        return $meta;
    }
}
コード例 #3
0
function add_rtmedia_meta($id = false, $key = false, $value = false, $duplicate = false)
{
    $rtmediameta = new RTMediaMeta($id, $key, $value, $duplicate);
    return $rtmediameta->add_meta($id, $key, $value, $duplicate);
}