コード例 #1
0
ファイル: ultimate-fields.php プロジェクト: shesser/selenenw
/**
 * Includes core files and adds the init action.
 * 
 * This function is executed on after_setup_theme, so you can add all the hooks you need
 * in functions.php, which is included before the after_setup_theme action is performed.
 */
function uf_load()
{
    global $ultimatefields;
    # Register plugin textdomain
    $mofile = UF_DIR . "/languages/uf-" . get_locale() . ".mo";
    if (file_exists($mofile)) {
        load_textdomain('uf', $mofile);
    }
    # Most classes will somehow be saved to $ultimatefields
    $ultimatefields = new stdClass();
    # Common functionality that's used accross the framework
    include_once 'common/common.php';
    # Include classes and functions
    include_once 'includes.php';
    # Register additional fields, templates, etc.
    do_action('uf_extend');
    # Buffer certain exceptions, which are not fatal.
    UF_Exceptions::buffer('non_existing_field');
    # Add UF options pages which provide admin interface for fields
    include_once 'settings/settings.php';
    # Indicate that the plugin is present so themes could check it.
    define('UF', true);
    # Fields are set up on init, but only in the admin, with priority 12
    add_action('init', 'uf_init', 12);
}
コード例 #2
0
ファイル: setup-containers.php プロジェクト: shesser/selenenw
/**
 * Get an array of all registered containers
 */
function uf_setup_containers($data = null)
{
    static $added_containers;
    if (!isset($added_containers)) {
        $added_containers = array();
    }
    $containers = $data ? array($data) : get_option('uf_containers');
    $containers = apply_filters('uf_containers', $containers);
    if (!$containers || !is_array($containers)) {
        return;
    }
    # Prevent duplicate ID exits.
    UF_Exceptions::buffer('unavailable_field_key');
    UF_Exceptions::buffer('unavailable_container_key');
    foreach ($containers as $container) {
        extract($container);
        if (isset($added_containers[$meta['uf_title']])) {
            continue;
        }
        switch ($meta['uf_type']) {
            case 'options':
                uf_setup_options_page(uf_setup_fields($meta['fields'], 'UF_Datastore_Options'), $container);
                break;
            case 'post-meta':
                uf_setup_postmeta_box(uf_setup_fields($meta['fields'], 'UF_Datastore_Postmeta'), $container);
                break;
        }
        # Add underscores to the type
        $type = str_replace('-', '_', $meta['uf_type']);
        do_action("uf_setup_" . $type, $container);
        $added_containers[$meta['uf_title']] = 1;
    }
}