Ejemplo n.º 1
0
function synved_shortcode_item_prepare_text($name, $text)
{
    global $synved_shortcode;
    $name_list = array();
    foreach ($synved_shortcode['list'] as $item_name => $item) {
        $name_list[$item_name] = $item['name_alt'];
        if ($name == $item_name) {
            $name_list[null] = $item['name_alt'];
        }
    }
    $list = array('_synved' => array('name' => $name_list));
    return synved_shortcode_item_template_expand($text, $list, null, true);
}
Ejemplo n.º 2
0
function synved_shortcode_do_link($atts, $content = null, $code = '', $type = null)
{
    $atts_def = array('template' => null, 'display' => null);
    $link_atts = shortcode_atts($atts_def, $atts);
    $template = $link_atts['template'];
    $display = $link_atts['display'];
    $item = synved_shortcode_data_get_display_item($atts, $type);
    $link = $item['link'];
    $tip = $item['tip'];
    $class = $item['class'];
    $object = $item['object'];
    $body = trim($content);
    if ($link != null || $body != null) {
        if ($link == null) {
            $link = '#';
        }
        if ($class != null) {
            $class = ' ' . $class;
        }
        $class = 'synved-link synved-link-type-' . $type . $class;
        if ($template != null) {
            $class .= ' synved-link-template-' . $template;
        }
        if ($body == null) {
            if (isset($item['title'])) {
                $body = $item['title'];
            } else {
                $body = 'Link';
            }
        }
        if ($tip == $body) {
            $tip = null;
        }
        $template_markup = null;
        switch ($template) {
            case null:
            case 'default':
                $template_markup = '<a class="synved-link-anchor %%class%%" href="%%link%%"%%tip_attribute%%>%%body%%</a>';
                break;
            case 'url':
                $template_markup = '%%link%%';
                break;
            case 'linked-image':
                $template_markup = '<a class="synved-link-anchor %%class%%" href="%%link%%"%%tip_attribute%%>%%thumbnail%%</a>';
                break;
            case 'card':
            case 'card-full':
                $template_abstract = null;
                if ($template == 'card-full') {
                    $class .= ' synved-link-template-card';
                    $template_abstract = '%%abstract_markup%%';
                }
                $template_markup = '<a class="synved-link-anchor %%class%%" href="%%link%%"%%tip_attribute%%>%%item_thumbnail%%<div class="synved-link-body" style="height:%%item_thumbnail_height%%px;overflow:hidden;">%%body%%' . $template_abstract . '</div></a>';
                break;
            case 'custom':
                $template_markup = $body;
                $body = null;
                break;
        }
        $item['link'] = $link;
        $item['tip'] = $tip;
        $item['class'] = $class;
        $item['body'] = $body;
        // XXX backward compatibility
        $item['item'] = $item;
        $template_markup = synved_shortcode_item_template_expand($template_markup, $item);
        $template_markup = synved_shortcode_do_shortcode($template_markup, 'link_' . $type, $object->ID);
        $out = $template_markup;
        return '<span class="snvdshc">' . $out . '</span>';
    }
    return null;
}