Plugin Directory

Changeset 1404409


Ignore:
Timestamp:
04/26/2016 09:58:05 AM (10 years ago)
Author:
Studiofreya
Message:

version 1.5

Location:
sf-category-menu/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sf-category-menu/trunk/readme.txt

    r1335051 r1404409  
    11=== SF Category Menu ===
    22Contributors: Studiofreya
    3 Donate link: https://studiofreya.com/wordpress/wordpress-plugins/sf-category-menu/
     3Donate link: https://studiofreya.com/sf-category-menu/
    44Tags: child, pages, posts, categories, menu, treeview, tree, list, widget
    55Requires at least: 3.8
    6 Tested up to: 4.4.1
     6Tested up to: 4.4.2
    77Stable tag: trunk
    88License: GPLv2
     
    1313== Description ==
    1414Plugin is based on jQuery Treeview Plugin and gives an easy Treeview Menu for WordPress categories. It will display the current page or category and all child pages.
    15 [Plugin website](https://studiofreya.com/wordpress/wordpress-plugins/sf-category-menu/)
     15[Plugin website](http://www.studiofreya.com/sf-category-menu/)
    1616
    1717= Features: =
     
    2020* Translation ready
    2121* Doesn't show empty categories
    22 * Caching of the menu
     22* Shortcode to list categories with thumbnails
    2323
    2424= Live demo: =
     
    31311. Use it as a Widget
    3232
    33 See [custom styling examples](https://studiofreya.com/wordpress/wordpress-plugins/sf-category-menu/styling/).
     33See custom [Styling examples](http://studiofreya.com/wordpress-plugins/sf-category-menu/styling/).
    3434
    3535== Frequently Asked Questions ==
    3636
    37 [SF Category Menu plugin FAQ](https://studiofreya.com/wordpress/wordpress-plugins/sf-category-menu/faq/)
     37[Plugin page](http://studiofreya.com/sf-category-menu/)
    3838
    3939== Screenshots ==
     
    4444== ChangeLog ==
    4545
    46 [SF Category Menu Changelog](https://studiofreya.com/wordpress/wordpress-plugins/sf-category-menu/changelog/).
     46SF Category Menu [change log](http://studiofreya.com/wordpress-plugins/sf-category-menu/changelog/).
    4747
    4848== Upgrade Notice ==
  • sf-category-menu/trunk/sf-category-menu.php

    r1326085 r1404409  
    33/**
    44 * Plugin Name: SF Category Menu Widget
    5  * Plugin URI: http://studiofreya.com/sf-category-menu/
     5 * Plugin URI: https://studiofreya.com/sf-category-menu/
    66 * Description: Easy treeview menu for WordPress categories, with catergory caching
    7  * Version: 1.4
     7 * Version: 1.5
    88 * Author: Studiofreya AS
    99 * Author URI: http://studiofreya.com
     
    246246add_action( 'plugins_loaded', 'sf_category_init' );
    247247
     248//show categories with thumbnails
     249function wpb_list_categories_with_thumbnails($attributes) {
     250    $categories = get_categories();
     251    $exclude_arr = array();
     252   
     253    extract( shortcode_atts( array(
     254        'exclude' => array()
     255    ), $attributes ) );
     256   
     257    if(!empty($exclude)) {
     258        $exclude_arr = explode(",", $exclude);
     259    }
     260   
     261    $sticky_posts_used = array();
     262   
     263    echo '<ul class="category_row">';
     264    foreach ($categories as $cat) {
     265   
     266        $continue = 1;
     267        foreach($exclude_arr as $exclude) {
     268   
     269            if($cat->cat_ID == $exclude)
     270            {
     271                $continue = 0;
     272                break;
     273            }
     274        }
     275       
     276        if($continue == 0) {
     277            continue;
     278        }
     279   
     280        if ($cat->category_parent == 0) {
     281            echo '<li>';
     282            $output = '<a href="'.get_category_link( $cat->term_id ).'">';
     283            echo trim($output, ' ');
     284           
     285            //try sticky first
     286            $args = array( 'category' => $cat->cat_ID, 'post__in' => get_option( 'sticky_posts') );
     287            $posts = get_posts($args);
     288            $sticky_found = false;
     289            if($posts) {
     290                foreach( $posts as $post ) {
     291               
     292                    $used = false;
     293                    //check if alreade in use
     294                    foreach($sticky_posts_used as $sticky) {
     295                        if($post->ID == $sticky) {
     296                            $used = true;
     297                            break;
     298                        }
     299                    }
     300                   
     301                    if(!$used) {
     302                        setup_postdata($post);
     303                        echo '<div class="category_thumb">';
     304                        echo get_the_post_thumbnail($post->ID, array(150,150));
     305                        echo '</div>';
     306                       
     307                        $sticky_found = true;
     308                        array_push($sticky_posts_used, $post->ID);
     309                        break;
     310                    }
     311                }
     312            }
     313
     314            if(!$sticky_found) {
     315                //show each 3 thumbnail in a category
     316                $post_number = $cat->count > 1 ? ($cat->count > 2 ? 3 : 2) : 1;
     317                $args = array( 'posts_per_page' => 3, 'category' => $cat->cat_ID );
     318                $posts = get_posts($args);
     319                if( $posts ) {
     320                    $counter = 1;
     321                    foreach( $posts as $post ) {
     322                        if($counter == $post_number) {
     323                            setup_postdata($post);
     324                            echo '<div class="category_thumb">';
     325                            echo get_the_post_thumbnail($post->ID, array(150,150));
     326                            echo '</div>';
     327                        }
     328                        $counter++;
     329                    }
     330                }
     331            }
     332            echo '<div class="category_name">';
     333            $cat_name = explode(' ',trim($cat->name));
     334            echo $cat_name[0];
     335            echo ' <span class="category_name_count">(';
     336            echo sf_getPostCount($cat->cat_ID);
     337            echo ')</span></div>';
     338            echo '</a></li>';
     339        }       
     340    }
     341   
     342    dynamic_sidebar( 'widget-area-frontpage-thumbnail' );
     343   
     344    echo '</ul>';
     345}
     346
     347add_shortcode('list_categories_thumbnails', 'wpb_list_categories_with_thumbnails');
     348
    248349
    249350?>
Note: See TracChangeset for help on using the changeset viewer.