Plugin Directory

Changeset 1136619


Ignore:
Timestamp:
04/16/2015 08:50:53 PM (11 years ago)
Author:
stur
Message:

Update 1.1.0

Location:
whale-kit/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • whale-kit/trunk/readme.txt

    r962303 r1136619  
    22Contributors: stur, Yuri Stepanov
    33Donate link: http://www.wp.od.ua/en/
    4 Tags: widgets, categories, taxonomies, posts, pages, shortcodes, get_terms, WP_Query
     4Tags: widgets, categories, taxonomies, posts, pages, shortcodes, get_terms, WP_Query, get_pages
    55Requires at least: 3.0.1
    6 Tested up to: 3.9
     6Tested up to: 4.1.1
    77Stable tag: trunk
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Two advanced widgets: WK_trem working with categories, post_tag or any taxonomies;  WK_posts works with posts, pages and any other type of records.
    12 
     11Three alternative to standard widget Categories, Recent Posts and Pages. These widgets can be used as short tags.
    1312== Description ==
    1413
    15 Two widgets and two shortcodes, alternative for standart widgets Categories and Pages:
    16 
    17 1.  WK_terms works with categories, tags (post_tag) and other taxonomies. Initial data, we obtain the function get_terms(), all options this function - available for change.
    18 2.  WK_posts - working with posts, pages, and any other type of records. For data used WP_Query, a huge number of input parameters available to change.
     14Three alternative to standard widget Categories, Recent Posts and Pages. These widgets can be used as short tags.
     151.  WK_trem working with categories, post_tag or any taxonomies. Settings from function get_terms().
     162.  WK_posts works with posts, pages and any other type of records. Settings from class WP_Query.
     173.  WK_pages – working pages, posts, and any other type of records. The data received through the function get_pages(). Unlike WK_posts working with tree hierarchical data.
    1918
    2019Collapse - hide inactive branches of a tree - can significantly reduce the list categories or pages, Javascript is not used - hide html code.
     
    2726Description and examples eXtra optsy see plugin page:
    2827
    29 [WK_terms](http://wp.od.ua/en/?p=76 "categories, tags and other taxonomic")  - categories, tags and other taxonomic
     28[wk_terms](http://www.wp.od.ua/en/?page_id=333 "categories, tags and other taxonomic")  - categories, tags and other taxonomic
    3029
    31 [WK_posts](http://wp.od.ua/en/?p=80 "posts, page and  any type of records")  - posts, page
     30[wk_posts] adn [wk_pages] (http://www.wp.od.ua/en/?page_id=366 "posts, page and  any type of records")  - posts, page
     31
    3232== Installation ==
    3333
     
    35352. Activate the plugin through the 'Plugins' menu in WordPress
    36363. Go to `Apperance->Widgets` add a widget in the sidebar and configure it.
    37 4. You can use short tags [wk_posts ...] and [wk_terms ...]  in the text post or page.
     374. You can use short tags [wk_posts ...] or [wk_terms ...] or [wk_pages ...] in the text post or page.
     38
     39== Frequently Asked Questions ==
     40=Show child categories from the category My_Category id:34=
     41`[wk_terms child_of=34]`
     42
     43=Show all categories and empty too=
     44`[wk_terms hide_empty=0]`
     45
     46= Exclude a category 32 and all childs =
     47`[wk_terms exclude_tree=array(32)]`
     48
     49=Sort categories by count of records=
     50`[wk_terms orderby=count order=ASC]`
     51for the widget:
     52orderby=count&order=ASC
     53
     54= Ñollapse categories =
     55`[wk_terms collapse=1 hierarchical=1]`
     56The collapse of the inactive branches of the tree of categories.
     57
     58=Display tags and specify the number of records=
     59`[wk_terms taxonomy=post_tag show_count=1]`
     60
     61=Show category and set the font size depending on the number of entries in the category=
     62`[wk_terms show_count=1 size_of_count=1 smallest=8 largest=22 unit=px]`
     63
     64=show 5 records out of category id:56, exclude category id:23=
     65`[wk_posts cat=56,-23 posts_per_page=5]`
     66for the widget:
     67`cat=56,-23&posts_per_page=5`
     68
     69
     70=Show entries with thumbnail=
     71`[wk_posts meta_key=_thumbnail_id show_thumbnail=60?60 /]`
     72for the widget:
     73`meta_key=_thumbnail_id&show_thumbnail=60?60`
     74*none_thumbnai - plug, if the record does not have a thumbnail, then specify the id attachment
     75
     76=Custom Field Query=
     77for the widget write all in one line:
     78`meta_key=color&meta_value=blue&meta_compare=<=&posts_per_page=5`
     79or per line of name = value pairs:
     80`
     81meta_key=color
     82meta_value=blue
     83meta_compare=<=
     84posts_per_page=5
     85`
     86=Multiple Custom Field Handling=
     87`
     88[wk_posts
     89tax_query='array(
     90    "relation"=>"AND",
     91     array(
     92       "taxonomy" => "category",
     93       "field" => "id",
     94       "terms" => array(16)
     95     ),
     96     array(
     97        "taxonomy" => "post_tag",
     98        "field" => "slug",
     99        "terms" => array("test_wk")
     100     )
     101)'
     102/]
     103`
     104for the widget write all in one line !newline is not allowed here:
     105`tax_query=array(  "relation"=>"AND",  array(  "taxonomy" => "category",  "field" => "id",  "terms" => array(16)  ),  array(  "taxonomy" => "post_tag",   "field" => "slug",   "terms" => array("test_wk") ) )`
     106
     107
     108=Show child pages to 567 pages=
     109`[wk_pages child_of=567]`
     110
     111
     112=Collapse and sorting pages=
     113`[wk_pages collapse=1 sort_column=menu_order sort_order=ASC]`
     114for the widget:
     115`
     116collapse=1
     117sort_column=menu_order
     118sort_order=ASC
     119`
     120
    38121
    39122== Screenshots ==
     
    54137= 1.0.1 =
    55138 * Fixed bug `division by zero`  in the calculation of the font size.
     139= 1.1.0 =
     140 WK_Pages added to work with hierarchical structures. Added ability to display thumbnails of records.
  • whale-kit/trunk/whale-kit.php

    r955386 r1136619  
    22/*
    33Plugin Name: Whale-Kit
    4 Plugin URI: http://www.wp.od.ua/en/?p=33
    5 Description: Two advanced widgets and two shortcodes. 1) WK_trem working with categories, post_tag or any taxonomies. Settings from function get_terms(). 2) WK_posts works with posts, pages and any other type of records. Settings from class WP_Query. Advanced Settings to display data and rules for constructing micro-patterns, see <a href="http://www.wp.od.ua/en/?p=33">page plugin</a>. Russian page plugin <a href="http://wp.od.ua/?p=1261">Whale-Kit</a>
     4Plugin URI: http://www.wp.od.ua/en/?page_id=242
     5Description: Three advanced widgets and three shortcodes. 1) WK_trem working with categories, post_tag or any taxonomies. Settings from function get_terms(). 2) WK_posts works with posts, pages and any other type of records. Settings from class WP_Query. 3) WK_pages – working pages, posts. The data received through the function get_pages(). Unlike WK_posts working with tree hierarchical data. Advanced Settings to display data and rules for constructing micro-patterns, see <a href="http://www.wp.od.ua/en/?page_id=242">page plugin</a>. Russian page plugin <a href="http://wp.od.ua/?p=1261">Whale-Kit</a>
    66Author: Yuriy Stepanov (stur)
    7 Version: 1.0.1
     7Version: 1.1.0
    88Author URI: http://wp.od.ua/
    99*/
    1010define("WHALE_KIT_ENABLE", 1);
    11 remove_filter( 'the_content', 'wpautop' );
    12 add_filter( 'the_content', 'wpautop' , 12);
     11remove_filter( 'the_content', 'do_shortcode' );
     12add_filter( 'the_content', 'do_shortcode' ,1);
    1313
    1414require_once ( dirname(__FILE__).'/wk-terms.php' );
     
    2828        $title = apply_filters('widget_title', $instance['title']);
    2929        $wk_terms = new WK_terms;
    30         $out = $wk_terms->w($instance['args']);
     30        $args = str_replace("\r\n", '&', $instance['args']);
     31        $args = str_replace('&&', '&', $args);
     32        $out = $wk_terms->w($args);
    3133        extract($all_wd_options);
    3234        if ($out) {
     
    4244        $instance = array();
    4345        $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
    44         $instance['args']  = $new_instance['args'];
     46        $instance['args']  = trim($new_instance['args']);
    4547        return $instance;
    4648    }
     
    5961        <p>
    6062        <label for="<?php echo $this->get_field_id( 'args' ); ?>"><?php _e( 'Function arguments:' ); ?></label>
    61         <input class="widefat" id="<?php echo $this->get_field_id( 'args' ); ?>" name="<?php echo $this->get_field_name( 'args' ); ?>" type="text" value="<?php echo esc_attr( $args ); ?>">
     63        <textarea class="widefat" id="<?php echo $this->get_field_id( 'args' ); ?>" name="<?php echo $this->get_field_name( 'args' ); ?>" rows="10"><?php echo esc_attr( $args ); ?></textarea>
    6264        </p>
    6365        <br />
     
    8688add_shortcode('wk_posts', 'wk_posts');
    8789
    88 
     90function wk_pages($atts) {
     91    $wk_pages = new WK_pages;
     92    return $wk_pages->w($atts);
     93}
     94add_shortcode('wk_pages', 'wk_pages');
    8995
    9096class WK_Post_Widget extends WP_Widget{
     
    101107        $title = apply_filters('widget_title', $instance['title']);
    102108        $wk_post = new WK_posts;
    103         $out = $wk_post->w($instance['args']);
    104 
     109        $args = str_replace("\r\n", '&', $instance['args']);
     110        $args = str_replace('&&', '&', $args);
     111        $out = $wk_post->w($args);
    105112        extract($all_wd_options);
    106113        if ($out) {
     
    116123        $instance = array();
    117124        $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
    118         $instance['args']  = $new_instance['args'];
     125        $instance['args']  = trim($new_instance['args']);
    119126        return $instance;
    120127    }
     
    123130        extract($instance);
    124131        if(!$title) $title =  __( 'New title');
    125         if(!$args) $args = 'post_type=page&show_count=1&posts_per_page=10';
     132        if(!$args) $args = 'post_type=post&show_count=1';
    126133
    127134?>
     
    133140        <p>
    134141        <label for="<?php echo $this->get_field_id( 'args' ); ?>"><?php _e( 'Function arguments:' ); ?></label>
    135         <input class="widefat" id="<?php echo $this->get_field_id( 'args' ); ?>" name="<?php echo $this->get_field_name( 'args' ); ?>" type="text" value="<?php echo esc_attr( $args ); ?>">
     142        <textarea class="widefat" rows="10" id="<?php echo $this->get_field_id( 'args' ); ?>" name="<?php echo $this->get_field_name( 'args' ); ?>" ><?php echo esc_attr( $args ); ?></textarea>
    136143        </p>
    137144        Help function arguments:  basic parameters <a href="http://codex.wordpress.org/Class_Reference/WP_Query">WP_Query</a>,  additional settings <a href="http://www.wp.od.ua/en/?p=80">WK_posts</a><br>
     
    145152
    146153
     154class WK_Pages_Widget extends WP_Widget{
     155
     156    function __construct() {
     157        parent::__construct(
     158            'WK_Pages_Widget', // Base ID
     159            __('WK Pages Widget', 'whalekit'), // Name
     160            array( 'description' => __( 'WK Pages Widget', 'whalekit' ), ) // Args
     161        );
     162    }
     163
     164    function widget($all_wd_options, $instance) {
     165        $title = apply_filters('widget_title', $instance['title']);
     166        $wk_pages = new WK_pages;
     167        $args = str_replace("\r\n", '&', $instance['args']);
     168        $args = str_replace('&&', '&', $args);
     169        $out = $wk_pages->w($args);
     170        extract($all_wd_options);
     171        if ($out) {
     172            $title = apply_filters('widget_title', $instance['title']);
     173            if ($title)
     174                $title = "$before_title$title$after_title";
     175            $out = "\n$before_widget\n$title\n$out\n$after_widget\n";
     176        }
     177        echo $out;
     178    }
     179
     180    function update($new_instance, $old_instance) {
     181        $instance = array();
     182        $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
     183        $instance['args']  = trim($new_instance['args']);
     184        return $instance;
     185    }
     186
     187    function form($instance) {
     188        extract($instance);
     189        if(!$title) $title =  __( 'New title');
     190        if(!$args) $args = 'post_type=post&show_count=1';
     191
     192?>
     193       <div style="width: 640px; margin-left:-300px; margin-top: 60px; z-index:10; position: absolute;  padding:2em;   background-color: #FFFFFF; border: solid 1px #6A6A6A">
     194        <p>
     195        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
     196        <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
     197        </p>
     198        <p>
     199        <label for="<?php echo $this->get_field_id( 'args' ); ?>"><?php _e( 'Function arguments:' ); ?></label>
     200        <textarea class="widefat" rows="10" id="<?php echo $this->get_field_id( 'args' ); ?>" name="<?php echo $this->get_field_name( 'args' ); ?>" ><?php echo esc_attr( $args ); ?></textarea>
     201        </p>
     202        Help function arguments:  basic parameters <a href="https://codex.wordpress.org/Function_Reference/get_pages">get_pages( );</a>,  additional settings <a href="http://www.wp.od.ua/en/?page_id=242">Whale-Kit</a><br>
     203        <a href="http://wp.od.ua/?p=1272">Wahle-Kit ru</a>
     204      </div>
     205<?php
     206      }
     207}
     208add_action('widgets_init', create_function('', 'return register_widget("WK_Pages_Widget");'));
     209
    147210
    148211
     
    158221function eval_array(& $atts){
    159222    foreach ($atts as $key => $value) {
     223
    160224        if( strpos ($value, 'array') === 0  ){
    161225            eval('$atts[$key] = '.$value.';');
  • whale-kit/trunk/wk-posts.php

    r955386 r1136619  
    11<?php
    22/*
     3http://www.wp.od.ua/en/?page_id=366
     4
    35используем микро-шаблоны
    46для вывода элементов       &apos; &quot;      &lt;    &gt;
     
    1517truncate_content - обрезать основной текст
    1618show_author - вычислить автора, в шаблонах станет доступна переменная $author
     19show_thumbnail - показывать миниатюру записи, в шаблонах станет доступна переменая картинка $img
     20none_thumbnai - заглушка, если запись не имеет миниатюру,  тут указать id загрузки
    1721
    1822***МИКРО ШАБЛОНЫ***
     
    3337[wk_posts post_type="post" lv_tmpl='<h2>Таблица</h2><table>$elements</table> пример таблицы' show_author=1 el_tmpl='<tr><td>$id<td><a href="$href"> $title</a><td>$a_tmpl<td>$date</tr>' date_format='d-m-Y H ч.'/]
    3438
    35 description of the parameters is available at http://www.wp.od.ua/en/?p=80
    3639*/
    3740class WK_posts extends WK_tree{
     41
    3842public function w($args=null){
     43/*   установка опций  installation options */
     44    $r = $this->set_args($args);
     45
     46/* получение данных   data acquisition  */
     47    $query = new WP_Query($r);
     48    if(!sizeof($query->posts))
     49        return '';
     50    $posts  = $query->posts;
     51
     52/*
     53установка текущего элемента
     54также есть возможность устанавливать ткущий элемент через массив аргументов
     55на этом этапе нам просто нужно отметить элемент полем 'current'
     56Set the current element
     57also have the opportunity to establish weaving element in an array of arguments
     58at this stage we just need to mark an item field 'current'
     59*/
     60   $this->set_current($posts, $r);
     61
     62/*
     63если установлен size_of_count расчитаем размер шрифта в зависимости от кол-ва
     64записей которое содержит каждая таксономия
     65размер шрифта запоминаем в свойстве ->font_size
     66
     67if installed size_of_count will calculate the font size depending on the number of
     68record that contains each taxonomy
     69font size is stored in the property -> font_size
     70*/
     71    if($r['size_of_count']) {
     72        $this->cal_font_size($posts, $r);
     73
     74    }
     75
     76/*
     77
     78 */
     79    if ($r['hierarchical']){
     80        $posts = $this->tree( $posts , $r);
     81        //echo '<pre>'; print_r($posts); echo '</pre>';
     82        $out = $this->level( $posts, 0, $r);
     83    } else {
     84       $out = $this->level( $posts, 0, $r);
     85    }
     86
     87    return  $out;
     88}
     89
     90
     91function set_args($args){
    3992    $defaults = array(
    40     'authors' => '',  'post_type' => 'post', 'posts_per_page'=>10,
     93    'authors' => '',  'post_type' => 'post', 'posts_per_page'=>-1,
    4194    'hierarchical' => 0,
    4295    'smallest' => 8, 'largest' => 22, 'unit' => 'pt',
     
    4598    'lv_tmpl'=>'\n$ind<$lv_tag  class="$class">\n$elements\n$ind</$lv_tag>',
    4699    'с_tmpl'=>'<$count_tag>$count</$count_tag>',
    47     'el_tmpl'=>'<$el_tag class="$class" title="$hint"><a href="$href" style="$style">$title</a>$с_tmpl$cnt_tmpl$childs</$el_tag>',
     100    'el_tmpl'=>'<$el_tag class="$class" title="$hint">$img<a href="$href" style="$style">$title</a>$с_tmpl$cnt_tmpl$childs</$el_tag>',
    48101    );
    49102
     103
    50104    $r = wp_parse_args($args, $defaults);
     105
     106    if(is_singular() ){
     107        if( $r['post_parent'] == '$this' )
     108            $r['post_parent'] = get_the_ID();
     109
     110        if($r['post_parent__in'])
     111            $r['post_parent__in'] = str_replace('$this', get_the_ID(), $r['post_parent__in']);
     112
     113        if($r['post__in'])
     114            $r['post__in'] = str_replace('$this', get_the_ID(), $r['post__in']);
     115
     116        if($r['post__not_in'])
     117            $r['post__not_in'] = str_replace('$this', get_the_ID(), $r['post__not_in']);
     118    }
     119
     120    if( $r['show_thumbnail'] ){
     121        if( $r['show_thumbnail'] == 'thumbnail' OR $r['show_thumbnail'] == 'medium'
     122            OR $r['show_thumbnail'] == 'large' OR $r['show_thumbnail'] == 'full' )
     123            $r['img_size'] = $r['show_thumbnail'];
     124        elseif( preg_match('~^(\d+)[x,X](\d+)~',$r['show_thumbnail'], $match) ) {
     125            $r['img_size'] = array($match[1],$match[2]);
     126        }
     127    }
    51128    $this->eval_array($r);
    52 
    53129    if($r['collapse'])
    54130        $r['hierarchical'] = 1;
    55131    if(!$r['css_prefix'])
    56132        $r['css_prefix'] = $r['post_type'];
    57 
    58     $query = new WP_Query($r);
    59     if(!sizeof($query->posts))
    60         return '';
    61     $posts  = $query->posts;
    62 
    63 /*
    64 установка текущего элемента
    65 также есть возможность устанавливать ткущий элемент через массив аргументов
    66 на этом этапе нам просто нужно отметить элемент полем 'current'
    67 Set the current element
    68 also have the opportunity to establish weaving element in an array of arguments
    69 at this stage we just need to mark an item field 'current'
    70 */  global $wp_query;
     133    return $r;
     134}
     135
     136function set_current(& $posts, & $r){
     137    global $wp_query;
    71138    if (is_single() || is_page() || is_attachment() || $wp_query->is_posts_page )
    72139        $r['current']  = $wp_query->get_queried_object_id();
     
    79146        else
    80147           $counts[] =  0;
    81 
    82     }
    83 
    84 
    85 /*
    86 если установлен size_of_count расчитаем размер шрифта в зависимости от кол-ва
    87 записей которое содержит каждая таксономия
    88 размер шрифта запоминаем в свойстве ->font_size
    89 
    90 if installed size_of_count will calculate the font size depending on the number of
    91 record that contains each taxonomy
    92 font size is stored in the property -> font_size
    93 */
    94     if($r['size_of_count']) {
    95         $min_count =  min($counts);
    96         $spread_count = max($counts) - $min_count;
     148    }
     149    $r['counts'] = $counts;
     150}
     151
     152
     153function cal_font_size(& $posts, & $r){
     154        $min_count =  min($r['counts']);
     155        $spread_count = max($r['counts']) - $min_count;
    97156        $spread_font =$r['largest'] - $r['smallest'];
    98157        if($spread_count>0){
     
    102161            }
    103162        }
    104 
    105     }
    106 
    107 /*
    108 
    109  */
    110     if ($r['hierarchical']){
    111         $posts = $this->tree( $posts , $r);
    112         //echo '<pre>'; print_r($posts); echo '</pre>';
    113         $out = $this->level( $posts, 0, $r);
    114     } else {
    115        $out = $this->level( $posts, 0, $r);
    116     }
    117 
    118     return  $out;
    119 }
    120 
    121 
    122 
    123 
    124  function element($p, $depth, & $r, $num){
    125         $arr['id'] = $id = $p->ID;
     163}
     164
     165function element($p, $depth, & $r, $num){
     166    $arr['id'] = $id = $p->ID;
    126167    $arr['css_prefix'] = $pr = $r['css_prefix'];
    127168    $arr['count_tag'] = $r['count_tag'];
     
    162203    }
    163204
     205    if( $r['show_thumbnail'] ){
     206        if(has_post_thumbnail( $id )){
     207            if($r['img_size'])
     208                $arr['img'] = get_the_post_thumbnail( $id,  $r['img_size'] );
     209            else
     210                 $arr['img'] = get_the_post_thumbnail( $id );
     211        }elseif($r['none_thumbnai']){
     212            if($r['img_size'])
     213                $arr['img'] = wp_get_attachment_image( $r['none_thumbnai'],  $r['img_size'] );
     214            else
     215                 $arr['img'] = wp_get_attachment_image( $r['none_thumbnai'] );
     216        }
     217    }else{
     218            $arr['img'] = '';
     219    }
     220
    164221//  hint
    165222    if( $r['hint_none'] && $p->comment_count == 0 )
     
    200257        $arr['с_tmpl'] =  '';
    201258
     259
     260
    202261    if ($p->childs)
    203262        $arr['childs'] = $this->level($p->childs, $depth + 1, $r);
     
    205264        $arr['childs'] = '';
    206265
     266
    207267    $out = $this->str_replace_var($arr, $r['el_tmpl']);
    208268    return $out;
     
    211271} // end class WK_posts
    212272
    213 /*
    214 
    215     [ID] => 147
    216     [post_author] => 1
    217     [post_date] => 2014-04-13 02:29:53
    218     [post_date_gmt] => 2014-04-12 22:29:53
    219     [post_content] => жил я как-то в общаге и среди всех остальных соседей были (м)ама
    220     [post_title] => жил я как-то в общаге и среди всех остальных соседей были
    221     [post_excerpt] =>
    222     [post_status] => publish
    223     [comment_status] => open
    224     [ping_status] => open
    225     [post_password] =>
    226     [post_name] => %d0%b6%d0%b8%d0%bb-%d1%8f-%d0%ba%d0%b0%d0%ba-%d1%82%d0%be-%d0%b2-%d0%be%d0%b1%d1%89%d0%b0%d0%b3%d0%b5-%d0%b8-%d1%81%d1%80%d0%b5%d0%b4%d0%b8-%d0%b2%d1%81%d0%b5%d1%85-%d0%be%d1%81%d1%82%d0%b0%d0%bb
    227     [to_ping] =>
    228     [pinged] =>
    229     [post_modified] => 2014-04-13 02:29:53
    230     [post_modified_gmt] => 2014-04-12 22:29:53
    231     [post_content_filtered] =>
    232     [post_parent] => 127
    233     [guid] => http://wp38/?page_id=147
    234     [menu_order] => 0
    235     [post_type] => page
    236     [post_mime_type] =>
    237     [comment_count] => 0
    238     [filter] => raw
    239 
    240 */
     273
     274
     275/*
     276отличается от WK_постс источником данных - данные получаем с помощью функции  get_pages
     277differs from the WK post to a data source - data is obtained using the  get_pages()
     278*/
     279class WK_pages extends WK_posts{
     280public function w($args=null){
     281/*   установка опций  installation options */
     282    $r = $this->set_args($args);
     283
     284/* получение данных   data acquisition  */
     285    $posts = get_pages($r);
     286    if(!sizeof($posts))
     287        return '';
     288
     289/*
     290установка текущего элемента
     291также есть возможность устанавливать ткущий элемент через массив аргументов
     292на этом этапе нам просто нужно отметить элемент полем 'current'
     293Set the current element
     294also have the opportunity to establish weaving element in an array of arguments
     295at this stage we just need to mark an item field 'current'
     296*/
     297   $this->set_current($posts, $r);
     298
     299/*
     300если установлен size_of_count расчитаем размер шрифта в зависимости от кол-ва
     301записей которое содержит каждая таксономия
     302размер шрифта запоминаем в свойстве ->font_size
     303
     304if installed size_of_count will calculate the font size depending on the number of
     305record that contains each taxonomy
     306font size is stored in the property -> font_size
     307*/
     308    if($r['size_of_count']) {
     309        $this->cal_font_size($posts, $r);
     310
     311    }
     312
     313/*
     314
     315 */
     316    if ($r['hierarchical']){
     317        $posts = $this->tree( $posts , $r);
     318        //echo '<pre>'; print_r($posts); echo '</pre>';
     319        $out = $this->level( $posts, 0, $r);
     320    } else {
     321       $out = $this->level( $posts, 0, $r);
     322    }
     323
     324    return  $out;
     325}
     326
     327function set_args($args){
     328    $defaults = array(
     329    'authors' => '',  'post_type' => 'page',
     330    'hierarchical' => 1,
     331    'smallest' => 8, 'largest' => 22, 'unit' => 'pt',
     332    'date_format' => get_option('date_format'),
     333    'lv_tag' => 'ul', 'el_tag' => 'li', 'count_tag' => 'sup',  'indent'=>"\t",
     334    'lv_tmpl'=>'\n$ind<$lv_tag  class="$class">\n$elements\n$ind</$lv_tag>',
     335    'с_tmpl'=>'<$count_tag>$count</$count_tag>',
     336    'el_tmpl'=>'<$el_tag class="$class" title="$hint">$img<a href="$href" style="$style">$title</a>$с_tmpl$cnt_tmpl$childs</$el_tag>',
     337    );
     338
     339
     340    $r = wp_parse_args($args, $defaults);
     341
     342    if(is_singular() ){
     343        if( $r['post_parent'] == '$this' )
     344            $r['post_parent'] = get_the_ID();
     345
     346        if($r['post_parent__in'])
     347            $r['post_parent__in'] = str_replace('$this', get_the_ID(), $r['post_parent__in']);
     348
     349        if($r['post__in'])
     350            $r['post__in'] = str_replace('$this', get_the_ID(), $r['post__in']);
     351
     352        if($r['post__not_in'])
     353            $r['post__not_in'] = str_replace('$this', get_the_ID(), $r['post__not_in']);
     354    }
     355
     356    if( $r['show_thumbnail'] ){
     357        if( $r['show_thumbnail'] == 'thumbnail' OR $r['show_thumbnail'] == 'medium'
     358            OR $r['show_thumbnail'] == 'large' OR $r['show_thumbnail'] == 'full' )
     359            $r['img_size'] = $r['show_thumbnail'];
     360        elseif( preg_match('~^(\d+)[x,X](\d+)~',$r['show_thumbnail'], $match) ) {
     361            $r['img_size'] = array($match[1],$match[2]);
     362        }
     363    }
     364    $this->eval_array($r);
     365    if($r['collapse'])
     366        $r['hierarchical'] = 1;
     367    if(!$r['css_prefix'])
     368        $r['css_prefix'] = $r['post_type'];
     369    return $r;
     370}
     371
     372}
  • whale-kit/trunk/wk-terms.php

    r955386 r1136619  
    22class WK_terms extends WK_tree{
    33/*
     4description of the parameters is available at http://www.wp.od.ua/en/?page_id=333
    45основной метод вывода    &apos; &quot;      &lt;    &gt;  #171792 &amp;
    56подготовка установка значений по умолчанию
     
    4849taxonomy=category&show_count=1&hierarchical=1&size_of_count=1&smallest=9&largest=20&hint=в рубрике $name - $count записей&hint_single=одна запись в рубрике $name&hint_fiw=$count записи в рубрик $name
    4950
    50 description of the parameters is available at http://www.wp.od.ua/en/?p=76
     51
    5152
    5253*/
Note: See TracChangeset for help on using the changeset viewer.