Page-list - Version 2.9

Version Description

  • added "more_tag" parameter and more tag support;
  • hiding password protected content of the pages;
Download this release

Release Info

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

Code changes from version 2.7 to 2.9

Files changed (2) hide show
  1. page-list.php +56 -41
  2. readme.txt +13 -4
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: 2.7
7
  Author: webvitaly
8
  Author Email: webvitaly(at)gmail.com
9
  Author URI: http://web-profile.com.ua/wordpress/
@@ -14,14 +14,16 @@ Future features:
14
  - exclude_post_page;
15
  */
16
 
17
- add_action('wp_print_styles', 'page_list_add_stylesheet');
18
- function page_list_add_stylesheet() {
19
- wp_enqueue_style( 'page-list-style', plugins_url( '/css/page-list.css', __FILE__ ), false, '2.7', 'all' );
20
  }
21
 
 
 
22
  if ( !function_exists('pagelist_shortcode') ) {
23
  function pagelist_shortcode( $atts ) {
24
- global $post;
25
  $return = '';
26
  extract( shortcode_atts( array(
27
  'depth' => '0',
@@ -66,7 +68,7 @@ if ( !function_exists('pagelist_shortcode') ) {
66
  $list_pages = wp_list_pages( $page_list_args );
67
 
68
  if ($list_pages) {
69
- $return = "\n".'<!-- powered by Page-list plugin ver.2.7 (wordpress.org/extend/plugins/page-list/) -->'."\n";
70
  $return .= '<ul class="page-list '.$class.'">'."\n".$list_pages."\n".'</ul>';
71
  }else{
72
  $return = '';
@@ -81,7 +83,7 @@ if ( !function_exists('pagelist_shortcode') ) {
81
 
82
  if ( !function_exists('subpages_shortcode') ) {
83
  function subpages_shortcode( $atts ) {
84
- global $post;
85
  $return = '';
86
  extract( shortcode_atts( array(
87
  'depth' => '0',
@@ -126,7 +128,7 @@ if ( !function_exists('subpages_shortcode') ) {
126
  $list_pages = wp_list_pages( $page_list_args );
127
 
128
  if ($list_pages) {
129
- $return = "\n".'<!-- powered by Page-list plugin ver.2.7 (wordpress.org/extend/plugins/page-list/) -->'."\n";
130
  $return .= '<ul class="page-list subpages-page-list '.$class.'">'."\n".$list_pages."\n".'</ul>';
131
  }else{
132
  $return = '';
@@ -141,7 +143,7 @@ if ( !function_exists('subpages_shortcode') ) {
141
 
142
  if ( !function_exists('siblings_shortcode') ) {
143
  function siblings_shortcode( $atts ) {
144
- global $post;
145
  $return = '';
146
  extract( shortcode_atts( array(
147
  'depth' => '0',
@@ -190,7 +192,7 @@ if ( !function_exists('siblings_shortcode') ) {
190
  $list_pages = wp_list_pages( $page_list_args );
191
 
192
  if ($list_pages) {
193
- $return = "\n".'<!-- powered by Page-list plugin ver.2.7 (wordpress.org/extend/plugins/page-list/) -->'."\n";
194
  $return .= '<ul class="page-list siblings-page-list '.$class.'">'."\n".$list_pages."\n".'</ul>';
195
  }else{
196
  $return = '';
@@ -202,7 +204,7 @@ if ( !function_exists('siblings_shortcode') ) {
202
 
203
  if ( !function_exists('pagelist_ext_shortcode') ) {
204
  function pagelist_ext_shortcode( $atts ) {
205
- global $post;
206
  $return = '';
207
  extract( shortcode_atts( array(
208
  'show_image' => 1,
@@ -228,6 +230,8 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
228
  'post_status' => 'publish',
229
  'class' => '',
230
  'strip_tags' => 1,
 
 
231
  'show_child_count' => 0,
232
  'child_count_template' => 'Subpages: %child_count%',
233
  'show_meta_key' => '',
@@ -262,6 +266,8 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
262
  'post_status' => $post_status,
263
  'class' => $class,
264
  'strip_tags' => $strip_tags,
 
 
265
  'show_child_count' => $show_child_count,
266
  'child_count_template' => $child_count_template,
267
  'show_meta_key' => $show_meta_key,
@@ -295,16 +301,24 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
295
  }
296
  if( $show_content == 1 ){
297
  //$content = apply_filters('the_content', $page->post_content);
298
- //$content = str_replace(']]>', ']]&gt;', $content);
 
299
  if( !empty( $page->post_excerpt ) ){
300
  $text_content = $page->post_excerpt;
301
  }else{
302
  $text_content = $page->post_content;
303
  }
304
- $content = page_list_parse_content( $text_content, $limit_content, $strip_tags );
305
- if( $show_title == 0 ){ // make excerpt link if there is no title
306
- $content = '<a href="'.$link.'">'.$content.'</a>';
 
 
 
 
 
 
307
  }
 
308
  $list_pages_html .= '<div class="page-list-ext-item-content">'.$content.'</div>';
309
 
310
  }
@@ -339,7 +353,7 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
339
  }
340
  }
341
  if ($list_pages_html) {
342
- $return = "\n".'<!-- powered by Page-list plugin ver.2.7 (wordpress.org/extend/plugins/page-list/) -->'."\n";
343
  $return .= '<div class="page-list page-list-ext '.$class.'">'."\n".$list_pages_html."\n".'</div>';
344
  }else{
345
  $return = '';
@@ -362,35 +376,36 @@ if ( !function_exists('pagelist_norm_params') ) {
362
  }
363
 
364
  if ( !function_exists('page_list_parse_content') ) {
365
- function page_list_parse_content($content, $limit_content = 250, $strip_tags = 1) {
366
- $output = '';
367
- if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {
368
- $content = explode($matches[0], $content, 2);
369
-
370
- } else {
371
- if( $strip_tags ){
372
- $content = str_replace('</', ' </', $content);
373
- $content_stripped = strip_tags($content); // ,'<p>'
374
- }else{
375
- $content_stripped = $content;
376
  }
377
-
378
- if( strlen($content_stripped) > $limit_content ){
379
- $pos = strpos($content_stripped, ' ', $limit_content);
380
- if ($pos !== false) {
381
- $first_space_pos = $pos;
382
- }else{
383
- $first_space_pos = $limit_content;
384
- }
385
- $content_cut = mb_substr($content_stripped, 0, $first_space_pos,'UTF-8');
386
- $content = $content_cut.'...';
 
 
 
 
 
387
  }else{
388
- $content = $content_stripped;
389
  }
390
- $content = array($content);
391
  }
392
- $output .= $content[0];
393
- $output = force_balance_tags($output);
394
  return $output;
395
  }
396
  }
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: 2.9
7
  Author: webvitaly
8
  Author Email: webvitaly(at)gmail.com
9
  Author URI: http://web-profile.com.ua/wordpress/
14
  - exclude_post_page;
15
  */
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, '2.9', 'all' );
20
  }
21
 
22
+ $pagelist_powered_line = "\n".'<!-- Page-list plugin v.2.9 (wordpress.org/extend/plugins/page-list/) -->'."\n";
23
+
24
  if ( !function_exists('pagelist_shortcode') ) {
25
  function pagelist_shortcode( $atts ) {
26
+ global $post, $pagelist_powered_line;
27
  $return = '';
28
  extract( shortcode_atts( array(
29
  'depth' => '0',
68
  $list_pages = wp_list_pages( $page_list_args );
69
 
70
  if ($list_pages) {
71
+ $return = $pagelist_powered_line;
72
  $return .= '<ul class="page-list '.$class.'">'."\n".$list_pages."\n".'</ul>';
73
  }else{
74
  $return = '';
83
 
84
  if ( !function_exists('subpages_shortcode') ) {
85
  function subpages_shortcode( $atts ) {
86
+ global $post, $pagelist_powered_line;
87
  $return = '';
88
  extract( shortcode_atts( array(
89
  'depth' => '0',
128
  $list_pages = wp_list_pages( $page_list_args );
129
 
130
  if ($list_pages) {
131
+ $return = $pagelist_powered_line;
132
  $return .= '<ul class="page-list subpages-page-list '.$class.'">'."\n".$list_pages."\n".'</ul>';
133
  }else{
134
  $return = '';
143
 
144
  if ( !function_exists('siblings_shortcode') ) {
145
  function siblings_shortcode( $atts ) {
146
+ global $post, $pagelist_powered_line;
147
  $return = '';
148
  extract( shortcode_atts( array(
149
  'depth' => '0',
192
  $list_pages = wp_list_pages( $page_list_args );
193
 
194
  if ($list_pages) {
195
+ $return = $pagelist_powered_line;
196
  $return .= '<ul class="page-list siblings-page-list '.$class.'">'."\n".$list_pages."\n".'</ul>';
197
  }else{
198
  $return = '';
204
 
205
  if ( !function_exists('pagelist_ext_shortcode') ) {
206
  function pagelist_ext_shortcode( $atts ) {
207
+ global $post, $pagelist_powered_line;
208
  $return = '';
209
  extract( shortcode_atts( array(
210
  'show_image' => 1,
230
  'post_status' => 'publish',
231
  'class' => '',
232
  'strip_tags' => 1,
233
+ 'strip_shortcodes' => 1,
234
+ 'more_tag' => 1,
235
  'show_child_count' => 0,
236
  'child_count_template' => 'Subpages: %child_count%',
237
  'show_meta_key' => '',
266
  'post_status' => $post_status,
267
  'class' => $class,
268
  'strip_tags' => $strip_tags,
269
+ 'strip_shortcodes' => $strip_shortcodes,
270
+ 'more_tag' => $more_tag,
271
  'show_child_count' => $show_child_count,
272
  'child_count_template' => $child_count_template,
273
  'show_meta_key' => $show_meta_key,
301
  }
302
  if( $show_content == 1 ){
303
  //$content = apply_filters('the_content', $page->post_content);
304
+ //$content = str_replace(']]>', ']]&gt;', $content); // both used in default the_content() function
305
+
306
  if( !empty( $page->post_excerpt ) ){
307
  $text_content = $page->post_excerpt;
308
  }else{
309
  $text_content = $page->post_content;
310
  }
311
+
312
+ if ( post_password_required($page) ) {
313
+ $content = '<!-- password protected -->';
314
+ }else{
315
+ $content = page_list_parse_content( $text_content, $limit_content, $strip_tags, $strip_shortcodes, $more_tag );
316
+
317
+ if( $show_title == 0 ){ // make content as a link if there is no title
318
+ $content = '<a href="'.$link.'">'.$content.'</a>';
319
+ }
320
  }
321
+
322
  $list_pages_html .= '<div class="page-list-ext-item-content">'.$content.'</div>';
323
 
324
  }
353
  }
354
  }
355
  if ($list_pages_html) {
356
+ $return = $pagelist_powered_line;
357
  $return .= '<div class="page-list page-list-ext '.$class.'">'."\n".$list_pages_html."\n".'</div>';
358
  }else{
359
  $return = '';
376
  }
377
 
378
  if ( !function_exists('page_list_parse_content') ) {
379
+ function page_list_parse_content($content, $limit_content = 250, $strip_tags = 1, $strip_shortcodes = 1, $more_tag = 1) {
380
+
381
+ if( $more_tag ){
382
+ if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {
383
+ $more_tag = $matches[0];
384
+ $content = explode($matches[0], $content);
385
+ $content = $content[0];
 
 
 
 
386
  }
387
+ }
388
+
389
+ if( $strip_shortcodes ){
390
+ $content = strip_shortcodes( $content );
391
+ }
392
+
393
+ if( $strip_tags ){
394
+ $content = str_replace('</', ' </', $content); // <p>line1</p><p>line2</p> - adding space between lines
395
+ $content = strip_tags($content); // ,'<p>'
396
+ }
397
+
398
+ if( strlen($content) > $limit_content ){
399
+ $pos = strpos($content, ' ', $limit_content); // find first space position
400
+ if ($pos !== false) {
401
+ $first_space_pos = $pos;
402
  }else{
403
+ $first_space_pos = $limit_content;
404
  }
405
+ $content = mb_substr($content, 0, $first_space_pos, 'UTF-8') . '...';
406
  }
407
+
408
+ $output = force_balance_tags($content);
409
  return $output;
410
  }
411
  }
readme.txt CHANGED
@@ -4,8 +4,8 @@ Plugin URI: http://web-profile.com.ua/wordpress/plugins/page-list/
4
  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
8
- Stable tag: 2.7
9
 
10
  "Page-list" plugin helps you to show list of pages with [pagelist], [subpages], [siblings] and [pagelist_ext] shortcodes.
11
 
@@ -72,6 +72,8 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
72
  * **post_status** - `[pagelist_ext post_status="publish"]`;
73
  * **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="");
74
  * **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");
 
 
75
  * **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;
76
  * **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%";
77
  * **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;
@@ -84,6 +86,13 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
84
 
85
  == Changelog ==
86
 
 
 
 
 
 
 
 
87
  = 2.7 =
88
  * make excerpt link if there is no title;
89
 
@@ -140,5 +149,5 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
140
 
141
  == Installation ==
142
 
143
- 1. Install plugin and activate it on the Plugins page;
144
- 2. Add shortcode `[pagelist]`, `[subpages]`, `[siblings]` or `[pagelist_ext]` to page content;
4
  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: 2.9
9
 
10
  "Page-list" plugin helps you to show list of pages with [pagelist], [subpages], [siblings] and [pagelist_ext] shortcodes.
11
 
72
  * **post_status** - `[pagelist_ext post_status="publish"]`;
73
  * **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="");
74
  * **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");
75
+ * **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;
76
+ * **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;
77
  * **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;
78
  * **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%";
79
  * **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;
86
 
87
  == Changelog ==
88
 
89
+ = 2.9 =
90
+ * added "more_tag" parameter and more tag support;
91
+ * hiding password protected content of the pages;
92
+
93
+ = 2.8 =
94
+ * added "strip_shortcodes" parameter;
95
+
96
  = 2.7 =
97
  * make excerpt link if there is no title;
98
 
149
 
150
  == Installation ==
151
 
152
+ 1. Install and activate the plugin on the Plugins page;
153
+ 2. Add shortcodes to pages: `[pagelist]`, `[subpages]`, `[siblings]`, `[pagelist_ext]`;