Newpost Catch - Version 1.3.5

Version Description

  • Compatibility check with WP 4.8.2
  • Fixed : Get widget checkbox value
  • Change : Default CSS style
  • Change : Default image no_thumb.png
Download this release

Release Info

Developer s56bouya
Plugin Icon wp plugin Newpost Catch
Version 1.3.5
Comparing to
See all releases

Code changes from version 1.3.8 to 1.3.5

Files changed (4) hide show
  1. class.php +113 -115
  2. newpost-catch.php +1 -1
  3. readme.txt +3 -9
  4. style.css +0 -2
class.php CHANGED
@@ -21,8 +21,7 @@ if ( !class_exists('NewpostCatch') ) {
21
  $this->default_thumbnail = apply_filters('npc_thumb', $this->pluginDir . '/no_thumb.png' );
22
 
23
  // print stylesheet
24
- // add_action( 'get_header', array( &$this, 'enqueue_stylesheet' ) );
25
- add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_stylesheet' ) );
26
 
27
  // activate textdomain for translations
28
  add_action( 'init', array( &$this, 'NewpostCatch_textdomain') );
@@ -41,9 +40,8 @@ if ( !class_exists('NewpostCatch') ) {
41
  foreach( $options as $key => $val ) {
42
  $options[$key] = $val['css']['active'];
43
  }
44
-
45
  if( in_array('1' , $options) ){
46
- $css_path = plugins_url(basename( rtrim(dirname(__FILE__), '/') ) . '/style.css');
47
  } else {
48
  $css_path = ( @file_exists( STYLESHEETPATH.'/css/newpost-catch.css' ) ) ? get_stylesheet_directory_uri() . '/css/newpost-catch.css' : '' ;
49
  }
@@ -92,49 +90,49 @@ if ( !class_exists('NewpostCatch') ) {
92
 
93
  $sticky_posts = get_option( 'sticky_posts' );
94
 
95
- $npc_args = array(
96
- 'post_type' => $post_type,
97
- 'post_status' => 'publish',
98
- 'cat' => $cat,
99
- 'posts_per_page' => $number,
100
- 'orderby' => 'date',
101
- 'order' => 'DESC'
102
- );
103
-
104
- //先頭に固定表示している場合
105
- if( ! empty( $sticky_posts ) ){
106
- $npc_args['ignore_sticky_posts'] = 0;
107
- if( empty( $ignore )){
108
- $npc_args['post__not_in'] = $sticky_posts;
 
109
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
 
 
 
 
 
 
 
 
 
111
 
112
- $npc_query = new WP_Query( $npc_args );
113
- ?>
114
- <ul id="npcatch">
115
- <?php
116
- if( $npc_query->have_posts() ) :
117
- while( $npc_query->have_posts() ) : $npc_query->the_post();
118
- $date = ( isset( $instance['date']['active'] ) && $instance['date']['active'] == 1 ) ? '<span class="date">' . get_the_time( get_option('date_format') ) . '</span>' : '';
119
-
120
- if( has_post_thumbnail() ) {
121
- $thumb_id = get_post_thumbnail_id();
122
- $thumb_url = wp_get_attachment_image_src($thumb_id);
123
- $thumb_url = $thumb_url[0];
124
- } else {
125
- $thumb_url = $this->no_thumb_image();
126
- }
127
- ?>
128
- <li><a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php esc_attr( the_title() ); ?>"><img src="<?php echo esc_url( $thumb_url ); ?>" width="<?php echo esc_attr( $width ); ?>" height="<?php echo esc_attr( $height ); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"/><span class="title"><?php the_title(); echo $date; ?></span></a></li>
129
- <?php
130
- endwhile;
131
- else :
132
- ?>
133
- <p>no post</p>
134
- <?php endif; wp_reset_postdata(); ?>
135
- </ul>
136
-
137
- <?php
138
  echo $after_widget;
139
  }
140
 
@@ -170,79 +168,79 @@ if ( !class_exists('NewpostCatch') ) {
170
 
171
  // define default value
172
  $defaults = array(
173
- 'title' => __('LatestPost(s)' , 'newpost-catch'),
174
- 'width' => 10,
175
- 'height' => 10,
176
- 'number' => 5,
177
- 'date' => array( 'active' => false ),
178
- 'ignore_check' => array( 'active' => false ),
179
- 'css' => array( 'active' => true ),
180
- 'cat' => NULL,
181
- 'post_type' => 'post',
182
- );
183
 
184
  $instance = wp_parse_args( (array) $instance, $defaults );
185
- ?>
186
- <p>
187
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title' , 'newpost-catch'); ?></label>
188
- <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" class="widefat" value="<?php echo esc_attr($instance['title']); ?>" />
189
- </p>
190
- <p>
191
- <?php _e('Thumbnail Size' , 'newpost-catch'); ?><br />
192
- <label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width' , 'newpost-catch'); ?></label>
193
- <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="text" style="width:50px" value="<?php echo esc_attr($instance['width']); ?>" /> px
194
- <br />
195
- <label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height' , 'newpost-catch'); ?></label>
196
- <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" style="width:50px;" value="<?php echo esc_attr($instance['height']); ?>" /> px
197
- </p>
198
- <p>
199
- <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Show post(s)' , 'newpost-catch'); ?></label>
200
- <input style="width:30px;" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($instance['number']); ?>" /> <?php _e('Post(s)', 'newpost-catch'); ?>
201
- </p>
202
- <p>
203
- <input type="checkbox" class="checkbox" value='1' <?php echo ($instance['date']['active']) ? 'checked="checked"' : ''; ?> id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" /> <label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e('Display date', 'newpost-catch'); ?></label>
204
- </p>
205
- <p>
206
- <input type="checkbox" class="checkbox" value='1' <?php echo ($instance['ignore_check']['active']) ? 'checked="checked"' : ''; ?> id="<?php echo $this->get_field_id( 'ignore_check' ); ?>" name="<?php echo $this->get_field_name( 'ignore_check' ); ?>" /> <label for="<?php echo $this->get_field_id( 'ignore_check' ); ?>"><?php _e('Display sticky post', 'newpost-catch'); ?></label>
207
- </p>
208
- <p>
209
- <input type="checkbox" class="checkbox" value='1' <?php if($instance['css']['active']){ echo 'checked="checked"'; } else { echo ''; } ?> id="<?php echo $this->get_field_id( 'css' ); ?>" name="<?php echo $this->get_field_name( 'css' ); ?>" /> <label for="<?php echo $this->get_field_id( 'css' ); ?>"><?php _e('Use default css', 'newpost-catch'); ?></label>
210
- </p>
211
  <?php _e('Post types' , 'newpost-catch'); ?><br />
212
- <?php
213
- $args = array(
214
- 'public' => true,
215
- );
216
-
217
- $output = 'objects';
218
- $operator = 'and';
219
-
220
- $post_types = get_post_types( $args, $output, $operator );
221
- foreach ( $post_types as $post_type ) {
222
- if( $post_type->name !== 'attachment' ){
223
- ?>
224
- <p><input type="radio" id="<?php echo $this->get_field_name($post_type->name); ?>" name="<?php echo $this->get_field_name('post_type'); ?>" value="<?php echo $post_type->name; ?>" <?php echo ( $instance['post_type'] == $post_type->name ) ? 'checked="checked"' : ''; ?> > <label for="<?php echo $this->get_field_name($post_type->name); ?>"><?php echo $post_type->labels->singular_name . '(' . $post_type->name . ')'; ?></label></p>
225
- <?php
226
- }
227
- }
228
- ?>
229
- <?php if( $instance['post_type'] == 'post' ){ ?>
230
- <p>
231
- <label for="<?php echo $this->get_field_id('cat'); ?>"><?php _e('Display category(ies)' , 'newpost-catch'); ?></label>
232
- <input id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>" type="text" class="widefat" value="<?php echo esc_attr($instance['cat']); ?>" />
233
- <span><a href="<?php echo get_bloginfo('url') . '/wp-admin/edit-tags.php?taxonomy=category'; ?>"><?php _e('Check the category ID' , 'newpost-catch'); ?></a></span>
234
- </p>
235
- <?php } ?>
236
- <p>
237
- <?php _e('Use shortcode' , 'newpost-catch'); ?>
238
- <?php _e('Can use the shortcode in a textwidget and theme files.' , 'newpost-catch'); ?> <a href="http://wordpress.org/plugins/newpost-catch/faq/" target="_blank">FAQ</a>
239
- </p>
240
- <p>
241
- <?php _e('Contact/Follow' , 'newpost-catch'); ?>
242
- <a href="https://twitter.com/NewpostCatch" target="_blank">Twitter</a>
243
- <a href="https://www.facebook.com/NewpostCatch" target="_blank">Facebook</a>
244
- </p>
245
- <?php
246
  }
247
  }
248
  }
@@ -332,4 +330,4 @@ if ( !class_exists( 'NewpostCatch_SC' ) ) {
332
  return $html;
333
  }
334
  }
335
- }
21
  $this->default_thumbnail = apply_filters('npc_thumb', $this->pluginDir . '/no_thumb.png' );
22
 
23
  // print stylesheet
24
+ add_action( 'get_header', array( &$this, 'enqueue_stylesheet' ) );
 
25
 
26
  // activate textdomain for translations
27
  add_action( 'init', array( &$this, 'NewpostCatch_textdomain') );
40
  foreach( $options as $key => $val ) {
41
  $options[$key] = $val['css']['active'];
42
  }
 
43
  if( in_array('1' , $options) ){
44
+ $css_path = plugins_url('newpost-catch/style.css');
45
  } else {
46
  $css_path = ( @file_exists( STYLESHEETPATH.'/css/newpost-catch.css' ) ) ? get_stylesheet_directory_uri() . '/css/newpost-catch.css' : '' ;
47
  }
90
 
91
  $sticky_posts = get_option( 'sticky_posts' );
92
 
93
+ $npc_args = array(
94
+ 'post_type' => $post_type,
95
+ 'post_status' => 'publish',
96
+ 'cat' => $cat,
97
+ 'posts_per_page' => $number,
98
+ 'orderby' => 'date',
99
+ 'order' => 'DESC'
100
+ );
101
+
102
+ //先頭に固定表示している場合
103
+ if( ! empty( $sticky_posts ) ){
104
+ $npc_args['ignore_sticky_posts'] = 0;
105
+ if( empty( $ignore )){
106
+ $npc_args['post__not_in'] = $sticky_posts;
107
+ }
108
  }
109
+
110
+ $npc_query = new WP_Query( $npc_args );
111
+ ?>
112
+ <ul id="npcatch">
113
+ <?php
114
+ if( $npc_query->have_posts() ) :
115
+ while( $npc_query->have_posts() ) : $npc_query->the_post();
116
+ $date = ( isset( $instance['date']['active'] ) && $instance['date']['active'] == 1 ) ? '<span class="date">' . get_the_time( get_option('date_format') ) . '</span>' : '';
117
+
118
+ if( has_post_thumbnail() ) {
119
+ $thumb_id = get_post_thumbnail_id();
120
+ $thumb_url = wp_get_attachment_image_src($thumb_id);
121
+ $thumb_url = $thumb_url[0];
122
+ } else {
123
+ $thumb_url = $this->no_thumb_image();
124
  }
125
+ ?>
126
+ <li><a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php esc_attr( the_title() ); ?>"><img src="<?php echo esc_url( $thumb_url ); ?>" width="<?php echo esc_attr( $width ); ?>" height="<?php echo esc_attr( $height ); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"/><span class="title"><?php the_title(); echo $date; ?></span></a></li>
127
+ <?php
128
+ endwhile;
129
+ else :
130
+ ?>
131
+ <p>no post</p>
132
+ <?php endif; wp_reset_postdata(); ?>
133
+ </ul>
134
 
135
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  echo $after_widget;
137
  }
138
 
168
 
169
  // define default value
170
  $defaults = array(
171
+ 'title' => __('LatestPost(s)' , 'newpost-catch'),
172
+ 'width' => 10,
173
+ 'height' => 10,
174
+ 'number' => 5,
175
+ 'date' => array( 'active' => false ),
176
+ 'ignore_check' => array( 'active' => false ),
177
+ 'css' => array( 'active' => true ),
178
+ 'cat' => NULL,
179
+ 'post_type' => 'post',
180
+ );
181
 
182
  $instance = wp_parse_args( (array) $instance, $defaults );
183
+ ?>
184
+ <p>
185
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title' , 'newpost-catch'); ?></label>
186
+ <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" class="widefat" value="<?php echo esc_attr($instance['title']); ?>" />
187
+ </p>
188
+ <p>
189
+ <?php _e('Thumbnail Size' , 'newpost-catch'); ?><br />
190
+ <label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width' , 'newpost-catch'); ?></label>
191
+ <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="text" style="width:50px" value="<?php echo esc_attr($instance['width']); ?>" /> px
192
+ <br />
193
+ <label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height' , 'newpost-catch'); ?></label>
194
+ <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" style="width:50px;" value="<?php echo esc_attr($instance['height']); ?>" /> px
195
+ </p>
196
+ <p>
197
+ <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Show post(s)' , 'newpost-catch'); ?></label>
198
+ <input style="width:30px;" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($instance['number']); ?>" /> <?php _e('Post(s)', 'newpost-catch'); ?>
199
+ </p>
200
+ <p>
201
+ <input type="checkbox" class="checkbox" value='1' <?php echo ($instance['date']['active']) ? 'checked="checked"' : ''; ?> id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" /> <label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e('Display date', 'newpost-catch'); ?></label>
202
+ </p>
203
+ <p>
204
+ <input type="checkbox" class="checkbox" value='1' <?php echo ($instance['ignore_check']['active']) ? 'checked="checked"' : ''; ?> id="<?php echo $this->get_field_id( 'ignore_check' ); ?>" name="<?php echo $this->get_field_name( 'ignore_check' ); ?>" /> <label for="<?php echo $this->get_field_id( 'ignore_check' ); ?>"><?php _e('Display sticky post', 'newpost-catch'); ?></label>
205
+ </p>
206
+ <p>
207
+ <input type="checkbox" class="checkbox" value='1' <?php if($instance['css']['active']){ echo 'checked="checked"'; } else { echo ''; } ?> id="<?php echo $this->get_field_id( 'css' ); ?>" name="<?php echo $this->get_field_name( 'css' ); ?>" /> <label for="<?php echo $this->get_field_id( 'css' ); ?>"><?php _e('Use default css', 'newpost-catch'); ?></label>
208
+ </p>
209
  <?php _e('Post types' , 'newpost-catch'); ?><br />
210
+ <?php
211
+ $args = array(
212
+ 'public' => true,
213
+ );
214
+
215
+ $output = 'objects';
216
+ $operator = 'and';
217
+
218
+ $post_types = get_post_types( $args, $output, $operator );
219
+ foreach ( $post_types as $post_type ) {
220
+ if( $post_type->name !== 'attachment' ){
221
+ ?>
222
+ <p><input type="radio" id="<?php echo $this->get_field_name($post_type->name); ?>" name="<?php echo $this->get_field_name('post_type'); ?>" value="<?php echo $post_type->name; ?>" <?php echo ( $instance['post_type'] == $post_type->name ) ? 'checked="checked"' : ''; ?> > <label for="<?php echo $this->get_field_name($post_type->name); ?>"><?php echo $post_type->labels->singular_name . '(' . $post_type->name . ')'; ?></label></p>
223
+ <?php
224
+ }
225
+ }
226
+ ?>
227
+ <?php if( $instance['post_type'] == 'post' ){ ?>
228
+ <p>
229
+ <label for="<?php echo $this->get_field_id('cat'); ?>"><?php _e('Display category(ies)' , 'newpost-catch'); ?></label>
230
+ <input id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>" type="text" class="widefat" value="<?php echo esc_attr($instance['cat']); ?>" />
231
+ <span><a href="<?php echo get_bloginfo('url') . '/wp-admin/edit-tags.php?taxonomy=category'; ?>"><?php _e('Check the category ID' , 'newpost-catch'); ?></a></span>
232
+ </p>
233
+ <?php } ?>
234
+ <p>
235
+ <?php _e('Use shortcode' , 'newpost-catch'); ?>
236
+ <?php _e('Can use the shortcode in a textwidget and theme files.' , 'newpost-catch'); ?> <a href="http://wordpress.org/plugins/newpost-catch/faq/" target="_blank">FAQ</a>
237
+ </p>
238
+ <p>
239
+ <?php _e('Contact/Follow' , 'newpost-catch'); ?>
240
+ <a href="https://twitter.com/NewpostCatch" target="_blank">Twitter</a>
241
+ <a href="https://www.facebook.com/NewpostCatch" target="_blank">Facebook</a>
242
+ </p>
243
+ <?php
244
  }
245
  }
246
  }
330
  return $html;
331
  }
332
  }
333
+ }
newpost-catch.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Newpost Catch
4
  Plugin URI: http://www.imamura.biz/blog/newpost-catch/
5
  Description: Thumbnails in new articles setting widget.
6
- Version: 1.3.7
7
  Author: Tetsuya Imamura
8
  Text Domain: newpost-catch
9
  Author URI: http://www.imamura.biz/blog/
3
  Plugin Name: Newpost Catch
4
  Plugin URI: http://www.imamura.biz/blog/newpost-catch/
5
  Description: Thumbnails in new articles setting widget.
6
+ Version: 1.3.5
7
  Author: Tetsuya Imamura
8
  Text Domain: newpost-catch
9
  Author URI: http://www.imamura.biz/blog/
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: s56bouya
3
  Donate link: http://www.imamura.biz/blog/newpost-catch
4
  Tags: widget, plugin, posts, sidebar, image, images, thumb, thumbnail
5
  Requires at least: 3.3.1
6
- Tested up to: 5.1.1
7
- Stable tag: 1.3.7
8
 
9
  Thumbnails in new articles setting widget.
10
 
@@ -21,7 +21,7 @@ Thumbnails in new articles setting widget.
21
  3. Activate the plugin through the 'Plugins' menu in WordPress
22
  4. Add the widget to your sidebar from Appearance->Widgets and configure the widget options.
23
 
24
- Required PHP5.6+
25
 
26
  ### Apply your own css style
27
 
@@ -93,12 +93,6 @@ When the post other than, post_type of the current page is the value of the prio
93
 
94
  == Changelog ==
95
 
96
- = 1.3.7 =
97
- * Compatibility check with WP 5.1.1
98
-
99
- = 1.3.6 =
100
- * Compatibility check with WP 4.9.7
101
-
102
  = 1.3.5 =
103
  * Compatibility check with WP 4.8.2
104
  * Fixed : Get widget checkbox value
3
  Donate link: http://www.imamura.biz/blog/newpost-catch
4
  Tags: widget, plugin, posts, sidebar, image, images, thumb, thumbnail
5
  Requires at least: 3.3.1
6
+ Tested up to: 4.8.2
7
+ Stable tag: 1.3.5
8
 
9
  Thumbnails in new articles setting widget.
10
 
21
  3. Activate the plugin through the 'Plugins' menu in WordPress
22
  4. Add the widget to your sidebar from Appearance->Widgets and configure the widget options.
23
 
24
+ Required PHP5.3+
25
 
26
  ### Apply your own css style
27
 
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
 
96
  = 1.3.5 =
97
  * Compatibility check with WP 4.8.2
98
  * Fixed : Get widget checkbox value
style.css CHANGED
@@ -25,8 +25,6 @@ Please the name of the file to create and "newpost-catch.css". The other is the
25
  #npcatch img {
26
  float: left;
27
  padding: 0 .5rem 0 0;
28
- max-width: 100%;
29
- height: auto;
30
  }
31
 
32
  #npcatch .title {
25
  #npcatch img {
26
  float: left;
27
  padding: 0 .5rem 0 0;
 
 
28
  }
29
 
30
  #npcatch .title {