Page-list - Version 3.0

Version Description

  • added "show_first_image" parameter for showing first image from content if there is no featured image;
Download this release

Release Info

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

Code changes from version 2.9 to 3.0

Files changed (2) hide show
  1. page-list.php +34 -3
  2. readme.txt +5 -1
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.9
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, '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 ) {
@@ -208,6 +208,7 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
208
  $return = '';
209
  extract( shortcode_atts( array(
210
  'show_image' => 1,
 
211
  'show_title' => 1,
212
  'show_content' => 1,
213
  'limit_content' => 250,
@@ -244,6 +245,7 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
244
 
245
  $page_list_ext_args = array(
246
  'show_image' => $show_image,
 
247
  'show_title' => $show_title,
248
  'show_content' => $show_content,
249
  'limit_content' => $limit_content,
@@ -293,9 +295,26 @@ if ( !function_exists('pagelist_ext_shortcode') ) {
293
  $list_pages_html .= '<div class="page-list-ext-image"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">';
294
  $list_pages_html .= get_the_post_thumbnail($page->ID, array($image_width,$image_height));
295
  $list_pages_html .= '</a></div> ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  }
297
  }
298
  }
 
 
 
299
  if( $show_title == 1 ){
300
  $list_pages_html .= '<h3 class="page-list-ext-title"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">'.esc_attr($page->post_title).'</a></h3>';
301
  }
@@ -409,3 +428,15 @@ if ( !function_exists('page_list_parse_content') ) {
409
  return $output;
410
  }
411
  }
 
 
 
 
 
 
 
 
 
 
 
 
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
 
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 ) {
208
  $return = '';
209
  extract( shortcode_atts( array(
210
  'show_image' => 1,
211
+ 'show_first_image' => 0,
212
  'show_title' => 1,
213
  'show_content' => 1,
214
  'limit_content' => 250,
245
 
246
  $page_list_ext_args = array(
247
  'show_image' => $show_image,
248
+ 'show_first_image' => $show_first_image,
249
  'show_title' => $show_title,
250
  'show_content' => $show_content,
251
  'limit_content' => $limit_content,
295
  $list_pages_html .= '<div class="page-list-ext-image"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">';
296
  $list_pages_html .= get_the_post_thumbnail($page->ID, array($image_width,$image_height));
297
  $list_pages_html .= '</a></div> ';
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
  }
315
+
316
+ // get_first_image()
317
+
318
  if( $show_title == 1 ){
319
  $list_pages_html .= '<h3 class="page-list-ext-title"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">'.esc_attr($page->post_title).'</a></h3>';
320
  }
428
  return $output;
429
  }
430
  }
431
+
432
+ function get_first_image( $content='' ) {
433
+ $first_img = '';
434
+ //ob_start();
435
+ //ob_end_clean();
436
+ $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
437
+ $first_img = $matches[1][0];
438
+ if(empty($first_img)){ // no image found
439
+ $first_img = '';
440
+ }
441
+ return $first_img;
442
+ }
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: 2.9
9
 
10
  "Page-list" plugin helps you to show list of pages with [pagelist], [subpages], [siblings] and [pagelist_ext] shortcodes.
11
 
@@ -51,6 +51,7 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
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_title** - show or hide title `[pagelist_ext show_title="0"]`; by default: show_title="1";
55
  * **show_content** - show or hide content `[pagelist_ext show_content="0"]`; by default: show_content="1";
56
  * **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";
@@ -86,6 +87,9 @@ You can use aditional parameters: **`[pagelist_ext child_of="4" exclude="6,7,8"
86
 
87
  == Changelog ==
88
 
 
 
 
89
  = 2.9 =
90
  * added "more_tag" parameter and more tag support;
91
  * hiding password protected content of the pages;
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
 
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";
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
+
93
  = 2.9 =
94
  * added "more_tag" parameter and more tag support;
95
  * hiding password protected content of the pages;