Esempio n. 1
0
function dw_special_category_menu_class($classes, $item)
{
    if ('category' == $item->object) {
        $options = dw_get_category_option($item->object_id);
        $classes[] = 'color-' . $options['style'];
    }
    return $classes;
}
Esempio n. 2
0
    function dw_focus_template_1col($args, $number, $category_id, $instance)
    {
        extract($args, EXTR_SKIP);
        $category = get_category($category_id);
        $category_link = get_category_link($category_id);
        $posts = new WP_Query(apply_filters('widget_dw_focus_categories_Widget', array('posts_per_page' => $number, 'cat' => $category_id, 'post_type' => 'post', 'post_status' => 'publish')));
        echo '<div class="span4">';
        $category_options = dw_get_category_option($category_id);
        $color_class = '';
        if ($category_options['style']) {
            $color_class .= ' color-' . $category_options['style'];
        }
        echo "<h3 class='category-title {$color_class}'><a class='tab_title active' data-catid='{$category_id}' href='{$category_link}'>{$category->name}</a></h3>";
        if ($posts->have_posts()) {
            $i = 0;
            if ($i == 0) {
                $posts->the_post();
                $i++;
                $class = 'first';
                if (has_post_thumbnail(get_the_ID())) {
                    $class .= ' has-thumbnail';
                }
                ?>
        <article <?php 
                post_class($class);
                ?>
>
            <?php 
                if (has_post_thumbnail(get_the_ID())) {
                    ?>
            <div class="entry-thumbnail">
                <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    echo esc_attr(sprintf(__('Permalink to %s', 'dw_focus'), the_title_attribute('echo=0')));
                    ?>
" rel="bookmark">
                    <?php 
                    the_post_thumbnail('medium');
                    ?>
                </a>
            </div>
            <?php 
                }
                ?>

            <?php 
                if (isset($instance['meta']) && $instance['meta']) {
                    ?>
                <div class="entry-meta">
                <?php 
                    if (isset($instance['date']) && $instance['date']) {
                        echo '<div>' . dw_human_time() . '</div>';
                    }
                    ?>

                <?php 
                    if (isset($instance['author']) && $instance['author']) {
                        _e('by', 'dw-focus');
                        ?>
                        <a href="<?php 
                        echo esc_url(get_author_posts_url(get_the_author_meta('ID')));
                        ?>
" rel="author"><?php 
                        echo get_the_author();
                        ?>
</a>
                        <?php 
                    }
                    ?>

                <?php 
                    if (isset($instance['cat']) && $instance['cat']) {
                        $categories_list = get_the_category_list(__(', ', 'dw_focus'));
                        if ($categories_list && dw_focus_categorized_blog()) {
                            ?>
                        <span class="cat-links">
                            <?php 
                            printf(__('<span> on </span>%1$s', 'dw_focus'), $categories_list);
                            ?>
                        </span>
                        <?php 
                        }
                    }
                    ?>
                </div>
            <?php 
                }
                ?>

            <h2 class="entry-title">
                <a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(sprintf(__('Permalink to %s', 'dw_focus'), the_title_attribute('echo=0')));
                ?>
" rel="bookmark"><?php 
                the_title();
                ?>
</a>
            </h2>
            
            <div class="entry-content"><?php 
                the_excerpt();
                ?>
</div>
        </article>
        <?php 
            }
            ?>

        <ul class="other-entry">
            <?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                ?>
            <li><h2 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(sprintf(__('Permalink to %s', 'dw_focus'), the_title_attribute('echo=0')));
                ?>
" rel="bookmark"><?php 
                the_title();
                ?>
</a></h2></li>
            <?php 
            }
            ?>
        </ul>

    <?php 
        } else {
            get_template_part('no-results');
        }
        echo '</div>';
        // Reset the global $the_post as this query will have stomped on it
        wp_reset_postdata();
    }
Esempio n. 3
0
 function dw_focus_scripts()
 {
     wp_enqueue_style('dw_focus_template', get_template_directory_uri() . '/assets/css/template.css');
     wp_enqueue_style('dw_focus_responsive', get_template_directory_uri() . '/assets/css/responsive.css');
     wp_enqueue_style('dw_focus_template', get_template_directory_uri() . '/assets/css/custom.css');
     if (is_archive()) {
         $style = '';
         $options = dw_get_category_option(get_query_var('cat'));
         $style = isset($options['style']) && $options['style'] != 'none' ? $options['style'] : false;
         // If have parent and not have style, get style of parent
         if (!$style) {
             $cat = get_category(get_query_var('cat'));
             if ($cat->parent) {
                 $options = dw_get_category_option($cat->parent);
                 $style = isset($options['style']) && $options['style'] != 'none' ? $options['style'] : false;
             }
         }
         if ($style) {
             $url = 'assets/colors/' . $style . '/style.css';
             if (file_exists(DW_TEMPLATE_PATH . $url)) {
                 wp_enqueue_style('dw_focus_category_style', DW_TEMPLATE_URI . $url);
             }
         }
     }
     wp_enqueue_style('style', get_stylesheet_uri());
     if (is_singular() && comments_open() && get_option('thread_comments')) {
         wp_enqueue_script('comment-reply');
     }
     wp_enqueue_script('bootstrap', DW_TEMPLATE_URI . 'assets/js/bootstrap.min.js', array('jquery'));
     wp_enqueue_script('infinitescroll', DW_TEMPLATE_URI . 'assets/js/jquery.infinitescroll.min.js', array('jquery'));
     wp_enqueue_script('dw_focus', DW_TEMPLATE_URI . 'assets/js/custom.js', array('jquery', 'bootstrap'));
     wp_localize_script('dw_focus', 'dw_focus', array('ajax_url' => admin_url('admin-ajax.php')));
     if (is_single()) {
         wp_enqueue_script('twitter-indent', '//platform.twitter.com/widgets.js');
         wp_enqueue_script('single-social', DW_TEMPLATE_URI . 'assets/js/single-socials.js', array('jquery', 'bootstrap'));
         wp_localize_script('single-social', 'dw_focus', array('ajax_url' => admin_url('admin-ajax.php')));
         //print
         wp_enqueue_style('print-style', get_template_directory_uri() . '/assets/css/print.css', array(), false, $media = 'print');
     }
     //Swipe event
     wp_enqueue_script('mouse-move', DW_TEMPLATE_URI . 'assets/js/jquery.mouse.move.js', array('jquery'));
     wp_enqueue_script('swipe', DW_TEMPLATE_URI . 'assets/js/jquery.swipe.js', array('jquery', 'mouse-move'));
 }
Esempio n. 4
0
 /**
  * Add color class for category meta tag of single page
  * @param  string $thelist   HTML of category list 
  * @param  string $separator seperator of each category 
  * @param  object $parents   
  * @return string          New html of category list 
  */
 function dw_focus_category_list_add_color_class($thelist)
 {
     if (is_single()) {
         preg_match_all('/(<li)><a[^>]*>(.*)<\\/a><\\/li>/i', $thelist, $matches, PREG_SET_ORDER);
         foreach ($matches as $tag) {
             // Get category by name
             $category = get_term_by('name', $tag[2], 'category');
             $options = dw_get_category_option($category->term_id);
             $class = '';
             if ($options['style'] && $options['style'] != 'none') {
                 $class = 'color-' . $options['style'];
                 $li = str_replace($tag[1], $tag[1] . ' class="' . $class . '"', $tag[0]);
                 $thelist = str_replace($tag[0], $li, $thelist);
             }
         }
     }
     return $thelist;
 }