Changeset 1136619
- Timestamp:
- 04/16/2015 08:50:53 PM (11 years ago)
- Location:
- whale-kit/trunk
- Files:
-
- 5 edited
-
readme.txt (modified) (4 diffs)
-
screenshot-1.png (modified) (previous)
-
whale-kit.php (modified) (11 diffs)
-
wk-posts.php (modified) (10 diffs)
-
wk-terms.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
whale-kit/trunk/readme.txt
r962303 r1136619 2 2 Contributors: stur, Yuri Stepanov 3 3 Donate link: http://www.wp.od.ua/en/ 4 Tags: widgets, categories, taxonomies, posts, pages, shortcodes, get_terms, WP_Query 4 Tags: widgets, categories, taxonomies, posts, pages, shortcodes, get_terms, WP_Query, get_pages 5 5 Requires at least: 3.0.1 6 Tested up to: 3.96 Tested up to: 4.1.1 7 7 Stable tag: trunk 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 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 11 Three alternative to standard widget Categories, Recent Posts and Pages. These widgets can be used as short tags. 13 12 == Description == 14 13 15 T wo 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.14 Three alternative to standard widget Categories, Recent Posts and Pages. These widgets can be used as short tags. 15 1. WK_trem working with categories, post_tag or any taxonomies. Settings from function get_terms(). 16 2. WK_posts works with posts, pages and any other type of records. Settings from class WP_Query. 17 3. 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. 19 18 20 19 Collapse - hide inactive branches of a tree - can significantly reduce the list categories or pages, Javascript is not used - hide html code. … … 27 26 Description and examples eXtra optsy see plugin page: 28 27 29 [ WK_terms](http://wp.od.ua/en/?p=76"categories, tags and other taxonomic") - categories, tags and other taxonomic28 [wk_terms](http://www.wp.od.ua/en/?page_id=333 "categories, tags and other taxonomic") - categories, tags and other taxonomic 30 29 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 32 32 == Installation == 33 33 … … 35 35 2. Activate the plugin through the 'Plugins' menu in WordPress 36 36 3. 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. 37 4. 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]` 51 for the widget: 52 orderby=count&order=ASC 53 54 = Ñollapse categories = 55 `[wk_terms collapse=1 hierarchical=1]` 56 The 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]` 66 for 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 /]` 72 for 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= 77 for the widget write all in one line: 78 `meta_key=color&meta_value=blue&meta_compare=<=&posts_per_page=5` 79 or per line of name = value pairs: 80 ` 81 meta_key=color 82 meta_value=blue 83 meta_compare=<= 84 posts_per_page=5 85 ` 86 =Multiple Custom Field Handling= 87 ` 88 [wk_posts 89 tax_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 ` 104 for 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]` 114 for the widget: 115 ` 116 collapse=1 117 sort_column=menu_order 118 sort_order=ASC 119 ` 120 38 121 39 122 == Screenshots == … … 54 137 = 1.0.1 = 55 138 * 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 2 2 /* 3 3 Plugin Name: Whale-Kit 4 Plugin URI: http://www.wp.od.ua/en/?p =335 Description: T wo 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>4 Plugin URI: http://www.wp.od.ua/en/?page_id=242 5 Description: 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> 6 6 Author: Yuriy Stepanov (stur) 7 Version: 1. 0.17 Version: 1.1.0 8 8 Author URI: http://wp.od.ua/ 9 9 */ 10 10 define("WHALE_KIT_ENABLE", 1); 11 remove_filter( 'the_content', ' wpautop' );12 add_filter( 'the_content', ' wpautop' , 12);11 remove_filter( 'the_content', 'do_shortcode' ); 12 add_filter( 'the_content', 'do_shortcode' ,1); 13 13 14 14 require_once ( dirname(__FILE__).'/wk-terms.php' ); … … 28 28 $title = apply_filters('widget_title', $instance['title']); 29 29 $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); 31 33 extract($all_wd_options); 32 34 if ($out) { … … 42 44 $instance = array(); 43 45 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 44 $instance['args'] = $new_instance['args'];46 $instance['args'] = trim($new_instance['args']); 45 47 return $instance; 46 48 } … … 59 61 <p> 60 62 <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> 62 64 </p> 63 65 <br /> … … 86 88 add_shortcode('wk_posts', 'wk_posts'); 87 89 88 90 function wk_pages($atts) { 91 $wk_pages = new WK_pages; 92 return $wk_pages->w($atts); 93 } 94 add_shortcode('wk_pages', 'wk_pages'); 89 95 90 96 class WK_Post_Widget extends WP_Widget{ … … 101 107 $title = apply_filters('widget_title', $instance['title']); 102 108 $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); 105 112 extract($all_wd_options); 106 113 if ($out) { … … 116 123 $instance = array(); 117 124 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 118 $instance['args'] = $new_instance['args'];125 $instance['args'] = trim($new_instance['args']); 119 126 return $instance; 120 127 } … … 123 130 extract($instance); 124 131 if(!$title) $title = __( 'New title'); 125 if(!$args) $args = 'post_type=p age&show_count=1&posts_per_page=10';132 if(!$args) $args = 'post_type=post&show_count=1'; 126 133 127 134 ?> … … 133 140 <p> 134 141 <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> 136 143 </p> 137 144 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> … … 145 152 146 153 154 class 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 } 208 add_action('widgets_init', create_function('', 'return register_widget("WK_Pages_Widget");')); 209 147 210 148 211 … … 158 221 function eval_array(& $atts){ 159 222 foreach ($atts as $key => $value) { 223 160 224 if( strpos ($value, 'array') === 0 ){ 161 225 eval('$atts[$key] = '.$value.';'); -
whale-kit/trunk/wk-posts.php
r955386 r1136619 1 1 <?php 2 2 /* 3 http://www.wp.od.ua/en/?page_id=366 4 3 5 используем микро-шаблоны 4 6 для вывода элементов ' " < > … … 15 17 truncate_content - обрезать основной текст 16 18 show_author - вычислить автора, в шаблонах станет доступна переменная $author 19 show_thumbnail - показывать миниатюру записи, в шаблонах станет доступна переменая картинка $img 20 none_thumbnai - заглушка, если запись не имеет миниатюру, тут указать id загрузки 17 21 18 22 ***МИКРО ШАБЛОНЫ*** … … 33 37 [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 ч.'/] 34 38 35 description of the parameters is available at http://www.wp.od.ua/en/?p=8036 39 */ 37 40 class WK_posts extends WK_tree{ 41 38 42 public 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' 56 Set the current element 57 also have the opportunity to establish weaving element in an array of arguments 58 at 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 67 if installed size_of_count will calculate the font size depending on the number of 68 record that contains each taxonomy 69 font 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 91 function set_args($args){ 39 92 $defaults = array( 40 'authors' => '', 'post_type' => 'post', 'posts_per_page'=> 10,93 'authors' => '', 'post_type' => 'post', 'posts_per_page'=>-1, 41 94 'hierarchical' => 0, 42 95 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', … … 45 98 'lv_tmpl'=>'\n$ind<$lv_tag class="$class">\n$elements\n$ind</$lv_tag>', 46 99 'с_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>', 48 101 ); 49 102 103 50 104 $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 } 51 128 $this->eval_array($r); 52 53 129 if($r['collapse']) 54 130 $r['hierarchical'] = 1; 55 131 if(!$r['css_prefix']) 56 132 $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 136 function set_current(& $posts, & $r){ 137 global $wp_query; 71 138 if (is_single() || is_page() || is_attachment() || $wp_query->is_posts_page ) 72 139 $r['current'] = $wp_query->get_queried_object_id(); … … 79 146 else 80 147 $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 153 function cal_font_size(& $posts, & $r){ 154 $min_count = min($r['counts']); 155 $spread_count = max($r['counts']) - $min_count; 97 156 $spread_font =$r['largest'] - $r['smallest']; 98 157 if($spread_count>0){ … … 102 161 } 103 162 } 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 165 function element($p, $depth, & $r, $num){ 166 $arr['id'] = $id = $p->ID; 126 167 $arr['css_prefix'] = $pr = $r['css_prefix']; 127 168 $arr['count_tag'] = $r['count_tag']; … … 162 203 } 163 204 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 164 221 // hint 165 222 if( $r['hint_none'] && $p->comment_count == 0 ) … … 200 257 $arr['с_tmpl'] = ''; 201 258 259 260 202 261 if ($p->childs) 203 262 $arr['childs'] = $this->level($p->childs, $depth + 1, $r); … … 205 264 $arr['childs'] = ''; 206 265 266 207 267 $out = $this->str_replace_var($arr, $r['el_tmpl']); 208 268 return $out; … … 211 271 } // end class WK_posts 212 272 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 277 differs from the WK post to a data source - data is obtained using the get_pages() 278 */ 279 class WK_pages extends WK_posts{ 280 public 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' 293 Set the current element 294 also have the opportunity to establish weaving element in an array of arguments 295 at 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 304 if installed size_of_count will calculate the font size depending on the number of 305 record that contains each taxonomy 306 font 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 327 function 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 2 2 class WK_terms extends WK_tree{ 3 3 /* 4 description of the parameters is available at http://www.wp.od.ua/en/?page_id=333 4 5 основной метод вывода ' " < > #171792 & 5 6 подготовка установка значений по умолчанию … … 48 49 taxonomy=category&show_count=1&hierarchical=1&size_of_count=1&smallest=9&largest=20&hint=в рубрике $name - $count записей&hint_single=одна запись в рубрике $name&hint_fiw=$count записи в рубрик $name 49 50 50 description of the parameters is available at http://www.wp.od.ua/en/?p=76 51 51 52 52 53 */
Note: See TracChangeset
for help on using the changeset viewer.