Page-list - Version 3.1

Version Description

  • fixed bug with empty image in "show_first_image" parameter;
  • added "more_tag" higher priority than "limit_content" (thanks to BobyDimitrov);
Download this release

Release Info

Developer webvitaly
Plugin Icon wp plugin Page-list
Version 3.1
Comparing to
See all releases

Code changes from version 3.0 to 3.1

Files changed (2) hide show
  1. page-list.php +55 -28
  2. readme.txt +7 -3
page-list.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Page-list
4
  Plugin URI: http://web-profile.com.ua/wordpress/plugins/page-list/
5
  Description: Show list of pages with [pagelist], [subpages], [siblings] and [pagelist_ext] shortcodes.
6
- Version: 3.0
7
  Author: webvitaly
8
  Author Email: webvitaly(at)gmail.com
9
  Author URI: http://web-profile.com.ua/wordpress/
@@ -16,10 +16,10 @@ Future features:
16
 
17
  add_action('wp_print_styles', 'pagelist_add_stylesheet');
18
  function pagelist_add_stylesheet() {
19
- wp_enqueue_style( 'page-list-style', plugins_url( '/css/page-list.css', __FILE__ ), false, '3.0', 'all' );
20
  }
21
 
22
- $pagelist_powered_line = "\n".'<!-- Page-list plugin v.3.0 (wordpress.org/extend/plugins/page-list/) -->'."\n";
23
 
24
  if ( !function_exists('pagelist_shortcode') ) {
25
  function pagelist_shortcode( $atts ) {
@@ -211,6 +211,7 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
211
  'show_first_image' => 0,
212
  'show_title' => 1,
213
  'show_content' => 1,
 
214
  'limit_content' => 250,
215
  'image_width' => '50',
216
  'image_height' => '50',
@@ -232,7 +233,6 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
232
  'class' => '',
233
  'strip_tags' => 1,
234
  'strip_shortcodes' => 1,
235
- 'more_tag' => 1,
236
  'show_child_count' => 0,
237
  'child_count_template' => 'Subpages: %child_count%',
238
  'show_meta_key' => '',
@@ -248,6 +248,7 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
248
  'show_first_image' => $show_first_image,
249
  'show_title' => $show_title,
250
  'show_content' => $show_content,
 
251
  'limit_content' => $limit_content,
252
  'image_width' => $image_width,
253
  'image_height' => $image_height,
@@ -269,7 +270,6 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
269
  'class' => $class,
270
  'strip_tags' => $strip_tags,
271
  'strip_shortcodes' => $strip_shortcodes,
272
- 'more_tag' => $more_tag,
273
  'show_child_count' => $show_child_count,
274
  'child_count_template' => $child_count_template,
275
  'show_meta_key' => $show_meta_key,
@@ -298,17 +298,21 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
298
  }else{
299
  if( $show_first_image == 1 ){
300
  $img_scr = get_first_image( $page->post_content );
301
- $list_pages_html .= '<div class="page-list-ext-image"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">';
302
- $list_pages_html .= '<img src="'.$img_scr.'" width="'.$image_width.'" />'; // not using height="'.$image_height.'" because images could be not square shaped and they will be stretched
303
- $list_pages_html .= '</a></div> ';
 
 
304
  }
305
  }
306
  }else{
307
  if( $show_first_image == 1 ){
308
  $img_scr = get_first_image( $page->post_content );
309
- $list_pages_html .= '<div class="page-list-ext-image"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">';
310
- $list_pages_html .= '<img src="'.$img_scr.'" width="'.$image_width.'" />'; // not using height="'.$image_height.'" because images could be not square shaped and they will be stretched
311
- $list_pages_html .= '</a></div> ';
 
 
312
  }
313
  }
314
  }
@@ -396,34 +400,57 @@ if ( !function_exists('pagelist_norm_params') ) {
396
 
397
  if ( !function_exists('page_list_parse_content') ) {
398
  function page_list_parse_content($content, $limit_content = 250, $strip_tags = 1, $strip_shortcodes = 1, $more_tag = 1) {
399
-
400
- if( $more_tag ){
 
 
 
401
  if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {
 
402
  $more_tag = $matches[0];
403
- $content = explode($matches[0], $content);
404
- $content = $content[0];
 
 
405
  }
406
  }
407
 
408
- if( $strip_shortcodes ){
409
- $content = strip_shortcodes( $content );
410
- }
411
-
 
412
  if( $strip_tags ){
413
  $content = str_replace('</', ' </', $content); // <p>line1</p><p>line2</p> - adding space between lines
414
  $content = strip_tags($content); // ,'<p>'
415
  }
416
-
417
- if( strlen($content) > $limit_content ){
418
- $pos = strpos($content, ' ', $limit_content); // find first space position
419
- if ($pos !== false) {
420
- $first_space_pos = $pos;
421
- }else{
422
- $first_space_pos = $limit_content;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
  }
424
- $content = mb_substr($content, 0, $first_space_pos, 'UTF-8') . '...';
425
  }
426
-
427
  $output = force_balance_tags($content);
428
  return $output;
429
  }
3
  Plugin Name: Page-list
4
  Plugin URI: http://web-profile.com.ua/wordpress/plugins/page-list/
5
  Description: Show list of pages with [pagelist], [subpages], [siblings] and [pagelist_ext] shortcodes.
6
+ Version: 3.1
7
  Author: webvitaly
8
  Author Email: webvitaly(at)gmail.com
9
  Author URI: http://web-profile.com.ua/wordpress/
16
 
17
  add_action('wp_print_styles', 'pagelist_add_stylesheet');
18
  function pagelist_add_stylesheet() {
19
+ wp_enqueue_style( 'page-list-style', plugins_url( '/css/page-list.css', __FILE__ ), false, '3.1', 'all' );
20
  }
21
 
22
+ $pagelist_powered_line = "\n".'<!-- Page-list plugin v.3.1 (wordpress.org/extend/plugins/page-list/) -->'."\n";
23
 
24
  if ( !function_exists('pagelist_shortcode') ) {
25
  function pagelist_shortcode( $atts ) {
211
  'show_first_image' => 0,
212
  'show_title' => 1,
213
  'show_content' => 1,
214
+ 'more_tag' => 1,
215
  'limit_content' => 250,
216
  'image_width' => '50',
217
  'image_height' => '50',
233
  'class' => '',
234
  'strip_tags' => 1,
235
  'strip_shortcodes' => 1,
 
236
  'show_child_count' => 0,
237
  'child_count_template' => 'Subpages: %child_count%',
238
  'show_meta_key' => '',
248
  'show_first_image' => $show_first_image,
249
  'show_title' => $show_title,
250
  'show_content' => $show_content,
251
+ 'more_tag' => $more_tag,
252
  'limit_content' => $limit_content,
253
  'image_width' => $image_width,
254
  'image_height' => $image_height,
270
  'class' => $class,
271
  'strip_tags' => $strip_tags,
272
  'strip_shortcodes' => $strip_shortcodes,
 
273
  'show_child_count' => $show_child_count,
274
  'child_count_template' => $child_count_template,
275
  'show_meta_key' => $show_meta_key,
298
  }else{
299
  if( $show_first_image == 1 ){
300
  $img_scr = get_first_image( $page->post_content );
301
+ if( !empty( $img_scr ) ){
302
+ $list_pages_html .= '<div class="page-list-ext-image"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">';
303
+ $list_pages_html .= '<img src="'.$img_scr.'" width="'.$image_width.'" />'; // not using height="'.$image_height.'" because images could be not square shaped and they will be stretched
304
+ $list_pages_html .= '</a></div> ';
305
+ }
306
  }
307
  }
308
  }else{
309
  if( $show_first_image == 1 ){
310
  $img_scr = get_first_image( $page->post_content );
311
+ if( !empty( $img_scr ) ){
312
+ $list_pages_html .= '<div class="page-list-ext-image"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">';
313
+ $list_pages_html .= '<img src="'.$img_scr.'" width="'.$image_width.'" />'; // not using height="'.$image_height.'" because images could be not square shaped and they will be stretched
314
+ $list_pages_html .= '</a></div> ';
315
+ }
316
  }
317
  }
318
  }
400
 
401
  if ( !function_exists('page_list_parse_content') ) {
402
  function page_list_parse_content($content, $limit_content = 250, $strip_tags = 1, $strip_shortcodes = 1, $more_tag = 1) {
403
+
404
+ $more_tag_found = 0;
405
+ $content_before_more_tag_length = 0;
406
+
407
+ if( $more_tag ){ // "more_tag" have higher priority than "limit_content"
408
  if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {
409
+ $more_tag_found = 1;
410
  $more_tag = $matches[0];
411
+ $content_temp = explode($matches[0], $content);
412
+ $content_temp = $content_temp[0];
413
+ $content_before_more_tag_length = strlen($content_temp);
414
+ $content = substr_replace($content, '###more###', $content_before_more_tag_length, 0);
415
  }
416
  }
417
 
418
+ // replace php and comments tags so they do not get stripped
419
+ //$content = preg_replace("@<\?@", "#?#", $content);
420
+ //$content = preg_replace("@<!--@", "#!--#", $content); // save html comments
421
+ // strip tags normally
422
+ //$content = strip_tags($content);
423
  if( $strip_tags ){
424
  $content = str_replace('</', ' </', $content); // <p>line1</p><p>line2</p> - adding space between lines
425
  $content = strip_tags($content); // ,'<p>'
426
  }
427
+ // return php and comments tags to their origial form
428
+ //$content = preg_replace("@#\?#@", "<?", $content);
429
+ //$content = preg_replace("@#!--#@", "<!--", $content);
430
+
431
+ if( $strip_shortcodes ){
432
+ $content = strip_shortcodes( $content );
433
+ }
434
+
435
+ if( $more_tag && $more_tag_found ){ // "more_tag" have higher priority than "limit_content"
436
+ $fake_more_pos = strpos($content, '###more###');
437
+ if( $fake_more_pos === false ) {
438
+ // substring not found in string and this is strange :)
439
+ } else {
440
+ $content = mb_substr($content, 0, $fake_more_pos, 'UTF-8');
441
+ }
442
+ }else{
443
+ if( strlen($content) > $limit_content ){ // limiting content
444
+ $pos = strpos($content, ' ', $limit_content); // find first space position
445
+ if ($pos !== false) {
446
+ $first_space_pos = $pos;
447
+ }else{
448
+ $first_space_pos = $limit_content;
449
+ }
450
+ $content = mb_substr($content, 0, $first_space_pos, 'UTF-8') . '...';
451
  }
 
452
  }
453
+
454
  $output = force_balance_tags($content);
455
  return $output;
456
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: page, page-list, pagelist, sitemap, subpages, siblings
5
  Author URI: http://web-profile.com.ua/wordpress/
6
  Requires at least: 3.0
7
  Tested up to: 3.3.1
8
- Stable tag: 3.0
9
 
10
  "Page-list" plugin helps you to show list of pages with [pagelist], [subpages], [siblings] and [pagelist_ext] shortcodes.
11
 
@@ -50,10 +50,11 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
50
  * **class** - if you want to specify the CSS class for list of pages you can use this shortcode: `[pagelist class="listclass"]`; by default the class is empty (class="");
51
 
52
  = Parameters for [pagelist_ext]: =
53
- * **show_image** - show or hide featured image `[pagelist_ext show_image="0"]`; by default: show_image="1";
54
  * **show_first_image** - show or hide first image from content if there is no featured image `[pagelist_ext show_first_image="1"]`; by default: show_first_image="0";
55
  * **show_title** - show or hide title `[pagelist_ext show_title="0"]`; by default: show_title="1";
56
  * **show_content** - show or hide content `[pagelist_ext show_content="0"]`; by default: show_content="1";
 
57
  * **limit_content** - content is limited by "more-tag" if it is exist or by "limit_content" parameter `[pagelist_ext limit_content="100"]`; by default: limit_content="250";
58
  * **image_width** - width of the image `[pagelist_ext image_width="80"]`; by default: image_width="50";
59
  * **image_height** - height of the image `[pagelist_ext image_height="80"]`; by default: image_height="50";
@@ -74,7 +75,6 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
74
  * **class** - if you want to specify the CSS class for list of pages you can use this shortcode: `[pagelist_ext class="listclass"]`; by default the class is empty (class="");
75
  * **strip_tags** - if you want to output the content with tags use this shortcode: `[pagelist_ext strip_tags="0"]`; by default the strip_tags is enabled (strip_tags="1");
76
  * **strip_shortcodes** - if you want to output the content with shortcode use this shortcode: `[pagelist_ext strip_shortcodes="0"]`; by default the strip_shortcodes is enabled (strip_shortcodes="1") and all registered shortcodes are removed;
77
- * **more_tag** - if you want to output all content before and after more tag use this shortcode: `[pagelist_ext more_tag="0"]`; by default the more_tag is enabled (more_tag="1") and showing only content before more tag;
78
  * **show_child_count** - if you want to show child count you can use this shortcode: `[pagelist_ext show_child_count="1"]`; by default the child_count is disabled (show_child_count="0"); If show_child_count="1", but count of subpages=0, than child count is not showing;
79
  * **child_count_template** - if you want to specify the template of child_count you can use this shortcode: `[pagelist_ext show_child_count="1" child_count_template="Subpages: %child_count%"]`; by default child_count_template="Subpages: %child_count%";
80
  * **show_meta_key** - if you want to show meta key you can use this shortcode: `[pagelist_ext show_meta_key="your_meta_key"]`; by default the show_meta_key is empty (show_meta_key=""); If show_meta_key is enabled, but meta_value is empty, than meta_key is not showing;
@@ -87,6 +87,10 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
87
 
88
  == Changelog ==
89
 
 
 
 
 
90
  = 3.0 =
91
  * added "show_first_image" parameter for showing first image from content if there is no featured image;
92
 
5
  Author URI: http://web-profile.com.ua/wordpress/
6
  Requires at least: 3.0
7
  Tested up to: 3.3.1
8
+ Stable tag: 3.1
9
 
10
  "Page-list" plugin helps you to show list of pages with [pagelist], [subpages], [siblings] and [pagelist_ext] shortcodes.
11
 
50
  * **class** - if you want to specify the CSS class for list of pages you can use this shortcode: `[pagelist class="listclass"]`; by default the class is empty (class="");
51
 
52
  = Parameters for [pagelist_ext]: =
53
+ * **show_image** - show or hide featured image `[pagelist_ext show_image="0"]`; "show_image" have higher priority than "show_first_image"; by default: show_image="1";
54
  * **show_first_image** - show or hide first image from content if there is no featured image `[pagelist_ext show_first_image="1"]`; by default: show_first_image="0";
55
  * **show_title** - show or hide title `[pagelist_ext show_title="0"]`; by default: show_title="1";
56
  * **show_content** - show or hide content `[pagelist_ext show_content="0"]`; by default: show_content="1";
57
+ * **more_tag** - if you want to output all content before and after more tag use this shortcode: `[pagelist_ext more_tag="0"]`; this parameter does not add "more-link" to the end of content, it just cut content before more-tag; "more_tag" parameter have higher priority than "limit_content"; by default the more_tag is enabled (more_tag="1") and showing only content before more tag;
58
  * **limit_content** - content is limited by "more-tag" if it is exist or by "limit_content" parameter `[pagelist_ext limit_content="100"]`; by default: limit_content="250";
59
  * **image_width** - width of the image `[pagelist_ext image_width="80"]`; by default: image_width="50";
60
  * **image_height** - height of the image `[pagelist_ext image_height="80"]`; by default: image_height="50";
75
  * **class** - if you want to specify the CSS class for list of pages you can use this shortcode: `[pagelist_ext class="listclass"]`; by default the class is empty (class="");
76
  * **strip_tags** - if you want to output the content with tags use this shortcode: `[pagelist_ext strip_tags="0"]`; by default the strip_tags is enabled (strip_tags="1");
77
  * **strip_shortcodes** - if you want to output the content with shortcode use this shortcode: `[pagelist_ext strip_shortcodes="0"]`; by default the strip_shortcodes is enabled (strip_shortcodes="1") and all registered shortcodes are removed;
 
78
  * **show_child_count** - if you want to show child count you can use this shortcode: `[pagelist_ext show_child_count="1"]`; by default the child_count is disabled (show_child_count="0"); If show_child_count="1", but count of subpages=0, than child count is not showing;
79
  * **child_count_template** - if you want to specify the template of child_count you can use this shortcode: `[pagelist_ext show_child_count="1" child_count_template="Subpages: %child_count%"]`; by default child_count_template="Subpages: %child_count%";
80
  * **show_meta_key** - if you want to show meta key you can use this shortcode: `[pagelist_ext show_meta_key="your_meta_key"]`; by default the show_meta_key is empty (show_meta_key=""); If show_meta_key is enabled, but meta_value is empty, than meta_key is not showing;
87
 
88
  == Changelog ==
89
 
90
+ = 3.1 =
91
+ * fixed bug with empty image in "show_first_image" parameter;
92
+ * added "more_tag" higher priority than "limit_content" (thanks to BobyDimitrov);
93
+
94
  = 3.0 =
95
  * added "show_first_image" parameter for showing first image from content if there is no featured image;
96