Пример #1
0
function acf_update_550()
{
    //acf_log('acf_update_550');
    // action for 3rd party
    do_action('acf/update_550');
    // bail early if no table
    if (!acf_isset_termmeta()) {
        update_option('acf_update_550_termmeta', 1);
        echo __('Term meta upgrade not possible (termmeta table does not exist)', 'acf');
        return;
    }
    // termmeta
    acf_update_550_termmeta();
    // version
    acf_update_db_version('5.5.0');
}
Пример #2
0
 function delete_term($term, $tt_id, $taxonomy, $deleted_term)
 {
     // bail early if termmeta table exists
     if (acf_isset_termmeta()) {
         return $term;
     }
     // globals
     global $wpdb;
     // vars
     $search = $taxonomy . '_' . $term . '_%';
     $_search = '_' . $search;
     // escape '_'
     // http://stackoverflow.com/questions/2300285/how-do-i-escape-in-sql-server
     $search = str_replace('_', '\\_', $search);
     $_search = str_replace('_', '\\_', $_search);
     // delete
     $result = $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", $search, $_search));
 }
Пример #3
0
function acf_get_post_id_info($post_id = 0)
{
    // vars
    $info = array('type' => 'post', 'id' => 0);
    // bail early if no $post_id
    if (!$post_id) {
        return $info;
    }
    // check cache
    // - this function will most likely be called multiple times (saving loading fields from post)
    //$cache_key = "get_post_id_info/post_id={$post_id}";
    //if( acf_isset_cache($cache_key) ) return acf_get_cache($cache_key);
    // numeric
    if (is_numeric($post_id)) {
        $info['id'] = (int) $post_id;
        // string
    } elseif (is_string($post_id)) {
        // vars
        $glue = '_';
        $type = explode($glue, $post_id);
        $id = array_pop($type);
        $type = implode($glue, $type);
        $meta = array('post', 'user', 'comment', 'term');
        // add in 'term'
        // check if is taxonomy (ACF < 5.5)
        // - avoid scenario where taxonomy exists with name of meta type
        if (!in_array($type, $meta) && acf_isset_termmeta($type)) {
            $type = 'term';
        }
        // meta
        if (is_numeric($id) && in_array($type, $meta)) {
            $info['type'] = $type;
            $info['id'] = (int) $id;
            // option
        } else {
            $info['type'] = 'option';
            $info['id'] = $post_id;
        }
    }
    // update cache
    //acf_set_cache($cache_key, $info);
    // return
    return $info;
}