/**
 * @param string $key The option key
 * @param string $default_url An absolute URL to be used as the default
 * @param string|array $extra_attr Extra HTML attributes for the <img> tag
 * @param bool $echo Wether to echo or return the result
 */
function editable_image($key, $default_url, $extra_attr = '', $echo = true)
{
    $attr = wp_parse_args($extra_attr, array('id' => $key));
    if (!($src = FEE_Field_Image::get(compact('key')))) {
        $src = $default_url;
    }
    $attr['src'] = $src;
    $img = apply_filters('editable_image', html('img', $attr), $key, $default_url);
    if ($echo) {
        echo $img;
    }
    return $img;
}
function _fee_init()
{
    load_plugin_textdomain('front-end-editor', '', basename(dirname(__FILE__)) . '/lang');
    $dir = dirname(__FILE__) . '/php';
    require_once $dir . '/template-tags.php';
    require_once $dir . '/core.php';
    foreach (array('base', 'post', 'widget', 'other') as $name) {
        require_once "{$dir}/fields/{$name}.php";
    }
    $options = new scbOptions('front-end-editor', __FILE__, array('disabled' => array('bloginfo'), 'rich' => true, 'group_post' => false, 'taxonomy_ui' => 'termselect'));
    FEE_Core::init($options);
    FEE_Field_Option::init(__FILE__);
    FEE_Field_Image::init(__FILE__);
    if (is_admin()) {
        require_once dirname(__FILE__) . '/admin/admin.php';
        scbAdminPage::register('FEE_Admin', __FILE__, $options);
    }
    add_action('front_end_editor_fields', 'fee_register_defaults', 0);
}
Beispiel #3
0
/**
 * @param string $key The option key
 * @param string $default_url An absolute URL to be used as the default
 * @param string|array $extra_attr Extra HTML attributes for the <img> tag
 * @param bool $echo Wether to echo or return the result
 */
function editable_image($key, $default_url, $extra_attr = '', $echo = true)
{
    $attr = wp_parse_args($extra_attr, array('id' => $key));
    if (!($src = FEE_Field_Image::get(compact('key')))) {
        $src = $default_url;
    }
    $attr['src'] = $src;
    $attr_str = '';
    foreach ($attr as $a_key => $a_value) {
        $a_key = trim(strip_tags($a_key));
        $a_value = trim(esc_attr($a_value));
        if (empty($a_key)) {
            continue;
        }
        $attr_str .= " {$a_key}='{$a_value}'";
    }
    $attr_str = ltrim($attr_str);
    $img = apply_filters('editable_image', "<img {$attr_str} />", $key, $default_url);
    if ($echo) {
        echo $img;
    }
    return $img;
}