コード例 #1
0
function theme_get_dynamic_sidebar_data($sidebar_id)
{
    global $theme_widget_args, $theme_sidebars;
    $sidebar_style = theme_get_option('theme_sidebars_style_' . $theme_sidebars[$sidebar_id]['group']);
    theme_ob_start();
    $success = dynamic_sidebar($sidebar_id);
    $content = theme_ob_get_clean();
    if (!$success) {
        return false;
    }
    extract($theme_widget_args);
    $data = explode($after_widget, $content);
    $widgets = array();
    $heading = theme_get_option('theme_' . (is_home() ? 'posts' : 'single') . '_widget_title_tag');
    for ($i = 0; $i < count($data); $i++) {
        $widget = $data[$i];
        if (theme_is_empty_html($widget)) {
            continue;
        }
        $id = null;
        $name = null;
        $class = null;
        $style = $sidebar_style;
        $title = null;
        if (preg_match('/<widget(.*?)>/', $widget, $matches)) {
            if (preg_match('/id="(.*?)"/', $matches[1], $ids)) {
                $id = $ids[1];
            }
            if (preg_match('/name="(.*?)"/', $matches[1], $names)) {
                $name = $names[1];
            }
            if (preg_match('/class="(.*?)"/', $matches[1], $classes)) {
                $class = $classes[1];
            }
            if ($name) {
                $style = theme_get_widget_style($name, $style);
            }
            $widget = preg_replace('/<widget[^>]+>/', '', $widget);
            if (preg_match('/<title>(.*)<\\/title>/', $widget, $matches)) {
                $title = $matches[1];
                $widget = preg_replace('/<title>.*?<\\/title>/', '', $widget);
            }
        }
        $widgets[] = array('id' => $id, 'name' => $name, 'class' => $class, 'style' => $style, 'title' => $title, 'heading' => $heading, 'content' => $widget);
    }
    return array_filter($widgets, 'theme_is_displayed_widget');
}
コード例 #2
0
ファイル: sidebars.php プロジェクト: uniquegel/Feminnova
function theme_get_dynamic_sidebar_data($name)
{
    global $theme_widget_args, $theme_sidebars;
    if (!function_exists('dynamic_sidebar')) {
        return false;
    }
    ob_start();
    $success = dynamic_sidebar($theme_sidebars[$name]['id']);
    $content = ob_get_clean();
    if (!$success) {
        return false;
    }
    extract($theme_widget_args);
    $data = explode($after_widget, $content);
    $widgets = array();
    for ($i = 0; $i < count($data); $i++) {
        $widget = $data[$i];
        if (theme_is_empty_html($widget)) {
            continue;
        }
        $id = null;
        $class = null;
        $title = null;
        if (preg_match('/<widget(.*?)>/', $widget, $matches)) {
            if (preg_match('/id="(.*?)"/', $matches[1], $ids)) {
                $id = $ids[1];
            }
            if (preg_match('/class="(.*?)"/', $matches[1], $classes)) {
                $class = $classes[1];
            }
            $widget = preg_replace('/<widget[^>]+>/', '', $widget);
            if (preg_match('/<title>(.*)<\\/title>/', $widget, $matches)) {
                $title = $matches[1];
                $widget = preg_replace('/<title>.*?<\\/title>/', '', $widget);
            }
        }
        $widgets[] = array('id' => $id, 'class' => $class, 'title' => $title, 'content' => $widget);
    }
    return $widgets;
}
コード例 #3
0
function theme_vmenu_wrapper($args)
{
    $args = wp_parse_args($args, array('id' => '', 'class' => '', 'title' => '', 'heading' => 'div', 'content' => ''));
    extract($args);
    if (theme_is_empty_html($title) && theme_is_empty_html($content)) {
        return;
    }
    if ($id) {
        $id = ' id="' . $id . '" ';
    }
    if ($class) {
        $class = ' ' . $class;
    }
    $begin = <<<EOL
<div {$id}class="cleantheme-vmenublock clearfix">
        
EOL;
    $begin_title = <<<EOL
EOL;
    $end_title = <<<EOL
EOL;
    $begin_content = <<<EOL
<div class="cleantheme-vmenublockcontent">
EOL;
    $end_content = <<<EOL
</div>
EOL;
    $end = <<<EOL

</div>
EOL;
    echo $begin;
    if ($begin_title && $end_title && !theme_is_empty_html($title)) {
        echo $begin_title . $title . $end_title;
    }
    echo $begin_content;
    echo $content;
    echo $end_content;
    echo $end;
}
コード例 #4
0
ファイル: functions.php プロジェクト: bexandy/ninacleaning
 function theme_get_excerpt($args = array())
 {
     global $post;
     $more_tag = theme_get_array_value($args, 'more_tag', __('Continue reading <span class="meta-nav">&rarr;</span>', THEME_NS));
     $auto = theme_get_array_value($args, 'auto', theme_get_option('theme_metadata_excerpt_auto'));
     $all_words = theme_get_array_value($args, 'all_words', theme_get_option('theme_metadata_excerpt_words'));
     $min_remainder = theme_get_array_value($args, 'min_remainder', theme_get_option('theme_metadata_excerpt_min_remainder'));
     $allowed_tags = theme_get_array_value($args, 'allowed_tags', theme_get_option('theme_metadata_excerpt_use_tag_filter') ? explode(',', str_replace(' ', '', theme_get_option('theme_metadata_excerpt_allowed_tags'))) : null);
     $perma_link = get_permalink($post->ID);
     $more_token = '%%theme_more%%';
     $show_more_tag = false;
     $tag_disbalance = false;
     if (function_exists('post_password_required') && post_password_required($post)) {
         return get_the_excerpt();
     }
     if ($auto && has_excerpt($post->ID)) {
         $excerpt = get_the_excerpt();
         $show_more_tag = mb_strlen($post->post_content) > 0;
     } else {
         $excerpt = get_the_content($more_token);
         // hack for badly written plugins
         ob_start();
         echo apply_filters('get_the_excerpt', $excerpt);
         $excerpt = ob_get_clean();
         ob_start();
         echo apply_filters('the_excerpt', $excerpt);
         $excerpt = ob_get_clean();
         if (theme_is_empty_html($excerpt)) {
             return $excerpt;
         }
         if ($allowed_tags !== null) {
             $allowed_tags = '<' . implode('><', $allowed_tags) . '>';
             $excerpt = strip_tags($excerpt, $allowed_tags);
         }
         $excerpt = strip_shortcodes($excerpt);
         if (strpos($excerpt, $more_token) !== false) {
             $excerpt = str_replace($more_token, $more_tag, $excerpt);
         } elseif ($auto && is_numeric($all_words)) {
             $token = "%theme_tag_token%";
             $content_parts = explode($token, str_replace(array('<', '>'), array($token . '<', '>' . $token), $excerpt));
             $content = array();
             $word_count = 0;
             foreach ($content_parts as $part) {
                 if (strpos($part, '<') !== false || strpos($part, '>') !== false) {
                     $content[] = array('type' => 'tag', 'content' => $part);
                 } else {
                     $all_chunks = preg_split('/([\\s])/u', $part, -1, PREG_SPLIT_DELIM_CAPTURE);
                     foreach ($all_chunks as $chunk) {
                         if ('' != trim($chunk)) {
                             $content[] = array('type' => 'word', 'content' => $chunk);
                             $word_count += 1;
                         } elseif ($chunk != '') {
                             $content[] = array('type' => 'space', 'content' => $chunk);
                         }
                     }
                 }
             }
             if ($all_words < $word_count && $all_words + $min_remainder <= $word_count) {
                 $show_more_tag = true;
                 $tag_disbalance = true;
                 $current_count = 0;
                 $excerpt = '';
                 foreach ($content as $node) {
                     if ($node['type'] == 'word') {
                         $current_count++;
                     }
                     $excerpt .= $node['content'];
                     if ($current_count == $all_words) {
                         break;
                     }
                 }
                 $excerpt .= '&hellip;';
                 // ...
             }
         }
     }
     if ($show_more_tag) {
         $excerpt = $excerpt . ' <a class="more-link" href="' . $perma_link . '">' . $more_tag . '</a>';
     }
     if ($tag_disbalance) {
         $excerpt = force_balance_tags($excerpt);
     }
     return $excerpt;
 }
コード例 #5
0
ファイル: navigation.php プロジェクト: JordiCruells/mwt
 function walk($items = array(), $args = '')
 {
     $args = wp_parse_args($args, array('depth' => 0, 'class' => ''));
     $this->items =& $items;
     $this->depth = (int) $args['depth'];
     $this->class = $args['class'];
     foreach ($items as $key => $item) {
         $this->IdToKey[$item->id] = $key;
         if (!isset($this->child_Ids[$item->parent])) {
             $this->child_Ids[$item->parent] = array();
         }
         $parent = $item->parent;
         if (!$parent) {
             $parent = 0;
         }
         $this->child_Ids[$parent][] = $item->id;
     }
     $output = '';
     if (isset($this->child_Ids[0])) {
         $this->display($output, $this->child_Ids[0]);
     }
     $output = apply_filters('wp_list_pages', $output, $args);
     if (theme_is_empty_html($output)) {
         return '';
     }
     return "\n" . '<ul' . theme_prepare_attr(array('class' => $this->class)) . '>' . "\n" . $output . '</ul>' . "\n";
 }
コード例 #6
0
function theme_block_wrapper($args)
{
    $args = wp_parse_args($args, array('id' => '', 'class' => '', 'title' => '', 'heading' => 'div', 'content' => ''));
    extract($args);
    if (theme_is_empty_html($title) && theme_is_empty_html($content)) {
        return;
    }
    if ($id !== '') {
        $id = ' id="' . $id . '" ';
    }
    if ($class !== '') {
        $class = ' ' . $class . ' ';
    }
    $begin = <<<EOL
<div {$id}class="bdls-block{$class} clearfix">
        
EOL;
    $begin_title = <<<EOL
<div class="bdls-blockheader">
            <{$heading} class="t">
EOL;
    $end_title = <<<EOL
</{$heading}>
        </div>
EOL;
    $begin_content = <<<EOL
<div class="bdls-blockcontent">
EOL;
    $end_content = <<<EOL
</div>
EOL;
    $end = <<<EOL

</div>
EOL;
    echo $begin;
    if ($begin_title && $end_title && !theme_is_empty_html($title)) {
        echo $begin_title . $title . $end_title;
    }
    echo $begin_content;
    echo $content;
    echo $end_content;
    echo $end;
}
コード例 #7
0
ファイル: functions.php プロジェクト: JordiCruells/mwt
function theme_get_metadata_icons($icons = '', $class = '')
{
    global $post;
    if (!is_string($icons) || theme_strlen($icons) == 0) {
        return;
    }
    $icons = explode(",", str_replace(' ', '', $icons));
    if (!is_array($icons) || count($icons) == 0) {
        return;
    }
    $result = array();
    for ($i = 0; $i < count($icons); $i++) {
        $icon = $icons[$i];
        switch ($icon) {
            case 'date':
                $result[] = '<span class="mmb-postdateicon">' . sprintf(__('<span class="%1$s"></span> %2$s', THEME_NS), 'date', sprintf('<span class="entry-date" title="%1$s">%2$s</span>', esc_attr(get_the_time()), get_the_date())) . '</span>';
                break;
            case 'author':
                $result[] = '<span class="mmb-postauthoricon">' . sprintf(__('<span class="%1$s">By</span> %2$s', THEME_NS), 'author', sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', get_author_posts_url(get_the_author_meta('ID')), sprintf(esc_attr(__('View all posts by %s', THEME_NS)), get_the_author()), get_the_author())) . '</span>';
                break;
            case 'category':
                $categories = get_the_category_list(', ');
                if (theme_strlen($categories) == 0) {
                    break;
                }
                $result[] = '<span class="mmb-postcategoryicon">' . sprintf(__('<span class="%1$s">Posted in</span> %2$s', THEME_NS), 'categories', get_the_category_list(', ')) . '</span>';
                break;
            case 'tag':
                $tags_list = get_the_tag_list('', ', ');
                if (!$tags_list) {
                    break;
                }
                $result[] = '<span class="mmb-posttagicon">' . sprintf(__('<span class="%1$s">Tagged</span> %2$s', THEME_NS), 'tags', $tags_list) . '</span>';
                break;
            case 'comments':
                if (!comments_open() || !theme_get_option('theme_allow_comments')) {
                    break;
                }
                theme_ob_start();
                comments_popup_link(__('Leave a comment', THEME_NS), __('1 Comment', THEME_NS), __('% Comments', THEME_NS));
                $result[] = '<span class="mmb-postcommentsicon">' . theme_ob_get_clean() . '</span>';
                break;
            case 'edit':
                if (!current_user_can('edit_post', $post->ID)) {
                    break;
                }
                theme_ob_start();
                edit_post_link(__('Edit', THEME_NS), '');
                $result[] = '<span class="mmb-postediticon">' . theme_ob_get_clean() . '</span>';
                break;
        }
    }
    $result = implode(theme_get_option('theme_metadata_separator'), $result);
    if (theme_is_empty_html($result)) {
        return;
    }
    return "<div class=\"mmb-post{$class}icons mmb-metadata-icons\">{$result}</div>";
}