Version Description
Download this release
Release Info
Developer | s56bouya |
Plugin | Newpost Catch |
Version | 1.3.8 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.3.8
- class.php +145 -139
- newpost-catch.php +2 -3
- no_thumb.png +0 -0
- readme.txt +31 -10
- style.css +17 -20
- uninstall.php +1 -2
class.php
CHANGED
@@ -19,9 +19,10 @@ if ( !class_exists('NewpostCatch') ) {
|
|
19 |
|
20 |
// default thumbnail
|
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,8 +41,9 @@ if ( !class_exists('NewpostCatch') ) {
|
|
40 |
foreach( $options as $key => $val ) {
|
41 |
$options[$key] = $val['css']['active'];
|
42 |
}
|
43 |
-
|
44 |
-
|
|
|
45 |
} else {
|
46 |
$css_path = ( @file_exists( STYLESHEETPATH.'/css/newpost-catch.css' ) ) ? get_stylesheet_directory_uri() . '/css/newpost-catch.css' : '' ;
|
47 |
}
|
@@ -65,19 +67,20 @@ if ( !class_exists('NewpostCatch') ) {
|
|
65 |
}
|
66 |
return $set_img;
|
67 |
}
|
68 |
-
|
69 |
// create widget
|
70 |
function widget($args, $instance) {
|
71 |
extract( $args );
|
72 |
|
73 |
-
$title = apply_filters( 'NewpostCatch_widget_title', $instance['title'] );
|
74 |
-
$width = apply_filters( 'NewpostCatch_widget_width', $instance['width'] );
|
75 |
-
$height
|
76 |
-
$number
|
77 |
-
$ignore
|
78 |
-
$css
|
79 |
-
$cat
|
80 |
-
|
|
|
81 |
$post_type = apply_filters( 'NewpostCatch_widget_post_type', $instance['post_type'] );
|
82 |
} else {
|
83 |
$post_type = apply_filters( 'NewpostCatch_widget_post_type', 'post' );
|
@@ -86,52 +89,52 @@ if ( !class_exists('NewpostCatch') ) {
|
|
86 |
echo $before_widget;
|
87 |
|
88 |
if ( $title ) echo $before_title . $title . $after_title;
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
'
|
106 |
-
|
107 |
-
'order' => 'DESC'
|
108 |
-
));
|
109 |
-
}
|
110 |
-
?>
|
111 |
-
<ul id="npcatch">
|
112 |
-
<?php
|
113 |
-
if( $npc_query->have_posts() ) :
|
114 |
-
while( $npc_query->have_posts() ) : $npc_query->the_post();
|
115 |
-
$date = ( $instance['date']['active'] == true ) ? '<span class="date">' . get_the_time( get_option('date_format') ) . '</span>' : '';
|
116 |
-
|
117 |
-
if( has_post_thumbnail() ) {
|
118 |
-
$thumb_id = get_post_thumbnail_id();
|
119 |
-
$thumb_url = wp_get_attachment_image_src($thumb_id);
|
120 |
-
$thumb_url = $thumb_url[0];
|
121 |
-
} else {
|
122 |
-
$thumb_url = $this->no_thumb_image();
|
123 |
}
|
124 |
-
?>
|
125 |
-
<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>
|
126 |
-
<?php
|
127 |
-
endwhile;
|
128 |
-
else :
|
129 |
-
?>
|
130 |
-
<p>no post</p>
|
131 |
-
<?php endif; wp_reset_postdata(); ?>
|
132 |
-
</ul>
|
133 |
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
echo $after_widget;
|
136 |
}
|
137 |
|
@@ -152,9 +155,9 @@ if ( !class_exists('NewpostCatch') ) {
|
|
152 |
$instance['cat'] = "";
|
153 |
}
|
154 |
|
155 |
-
$instance['date']['active'] = $new_instance['date'];
|
156 |
$instance['ignore_check']['active'] = $new_instance['ignore_check']['active'];
|
157 |
-
$instance['css']['active'] = $new_instance['css'];
|
158 |
$instance['post_type'] = !empty($new_instance['post_type']) ? $new_instance['post_type'] : 'post';
|
159 |
|
160 |
update_option('newpost_catch', $instance);
|
@@ -167,79 +170,79 @@ if ( !class_exists('NewpostCatch') ) {
|
|
167 |
|
168 |
// define default value
|
169 |
$defaults = array(
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
|
181 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
182 |
-
?>
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
<?php _e('Post types' , 'newpost-catch'); ?><br />
|
209 |
-
<?php
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
?>
|
221 |
-
|
222 |
-
<?php
|
223 |
-
|
224 |
-
|
225 |
-
?>
|
226 |
-
<?php if( $instance['post_type'] == 'post' ){ ?>
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
<?php } ?>
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
<?php
|
243 |
}
|
244 |
}
|
245 |
}
|
@@ -249,14 +252,15 @@ if ( !class_exists( 'NewpostCatch_SC' ) ) {
|
|
249 |
function __construct() {
|
250 |
add_shortcode( 'npc', array( &$this, 'npc_sc' ) );
|
251 |
}
|
252 |
-
|
253 |
function npc_sc($atts) {
|
254 |
$npc_construct = new NewpostCatch();
|
255 |
-
|
256 |
// default value
|
257 |
extract( shortcode_atts( array(
|
258 |
'id' => 'npcatch',
|
259 |
'post_type' => 'post',
|
|
|
260 |
'cat' => NULL,
|
261 |
'width' => 10,
|
262 |
'height' => 10,
|
@@ -266,6 +270,7 @@ if ( !class_exists( 'NewpostCatch_SC' ) ) {
|
|
266 |
'orderby' => 'date',
|
267 |
'order' => 'DESC',
|
268 |
'date' => 0,
|
|
|
269 |
'dynamic' => 0,
|
270 |
), $atts ) );
|
271 |
|
@@ -288,12 +293,14 @@ if ( !class_exists( 'NewpostCatch_SC' ) ) {
|
|
288 |
// query
|
289 |
$npc_sc_query = new WP_Query( array(
|
290 |
'post_type' => $post_type,
|
|
|
291 |
'cat' => $cat,
|
292 |
'offset' => $offset,
|
293 |
'posts_per_page' => $posts_per_page,
|
294 |
'ignore_sticky_posts' => $sticky,
|
295 |
'orderby' => $orderby,
|
296 |
-
'order' => $order
|
|
|
297 |
));
|
298 |
|
299 |
$html = '';
|
@@ -301,18 +308,18 @@ if ( !class_exists( 'NewpostCatch_SC' ) ) {
|
|
301 |
$html .= '<ul id="' . $id . '">';
|
302 |
while( $npc_sc_query->have_posts() ) :
|
303 |
$npc_sc_query->the_post();
|
304 |
-
|
305 |
$get_date = ( $date == true ) ? '<span class="date">' . esc_html( get_the_time( get_option('date_format') ) ) . '</span>' : '';
|
306 |
|
307 |
$thumb_url = '';
|
308 |
-
if( has_post_thumbnail() ) {
|
309 |
-
$thumb_id = get_post_thumbnail_id();
|
310 |
$thumb_url = wp_get_attachment_image_src($thumb_id);
|
311 |
$thumb_url = $thumb_url[0];
|
312 |
} else {
|
313 |
-
$thumb_url = $npc_construct->
|
314 |
}
|
315 |
-
|
316 |
$html .= '<li><a href="' . esc_url( get_permalink() ) . '" title="' . get_the_title() . '">';
|
317 |
$html .= '<img src="' . esc_url( $thumb_url ) . '" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" alt="' . get_the_title() . '" title="' . get_the_title() . '" /></a>';
|
318 |
$html .= '<span class="title"><a href="' . esc_url( get_permalink() ) . '" title="' . get_the_title() . '">' . get_the_title() . $get_date;
|
@@ -321,9 +328,8 @@ if ( !class_exists( 'NewpostCatch_SC' ) ) {
|
|
321 |
$html .= '</ul>';
|
322 |
endif;
|
323 |
wp_reset_postdata();
|
324 |
-
|
325 |
return $html;
|
326 |
}
|
327 |
}
|
328 |
}
|
329 |
-
?>
|
19 |
|
20 |
// default thumbnail
|
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 |
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 |
}
|
67 |
}
|
68 |
return $set_img;
|
69 |
}
|
70 |
+
|
71 |
// create widget
|
72 |
function widget($args, $instance) {
|
73 |
extract( $args );
|
74 |
|
75 |
+
$title = ( isset( $instance['title'] ) ) ? apply_filters( 'NewpostCatch_widget_title', $instance['title'] ) : '';
|
76 |
+
$width = ( isset( $instance['width'] ) ) ? apply_filters( 'NewpostCatch_widget_width', $instance['width'] ) : 10;
|
77 |
+
$height = ( isset( $instance['height'] ) ) ? apply_filters( 'NewpostCatch_widget_height', $instance['height'] ) : 10;
|
78 |
+
$number = ( isset( $instance['number'] ) ) ? apply_filters( 'NewpostCatch_widget_number', $instance['number'] ) : '';
|
79 |
+
$ignore = ( isset( $instance['ignore_check']['active'] ) ) ? apply_filters( 'NewpostCatch_widget_ignore', $instance['ignore_check']['active'] ) : null;
|
80 |
+
$css = ( isset( $instance['css']['active'] ) ) ? apply_filters( 'NewpostCatch_widget_css', $instance['css']['active'] ) : '';
|
81 |
+
$cat = ( isset( $instance['cat'] ) ) ? apply_filters( 'NewpostCatch_widget_cat', $instance['cat'] ) : '';
|
82 |
+
|
83 |
+
if( ! empty( $instance['post_type'] ) ){
|
84 |
$post_type = apply_filters( 'NewpostCatch_widget_post_type', $instance['post_type'] );
|
85 |
} else {
|
86 |
$post_type = apply_filters( 'NewpostCatch_widget_post_type', 'post' );
|
89 |
echo $before_widget;
|
90 |
|
91 |
if ( $title ) echo $before_title . $title . $after_title;
|
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 |
|
155 |
$instance['cat'] = "";
|
156 |
}
|
157 |
|
158 |
+
$instance['date']['active'] = $new_instance['date']['active'];
|
159 |
$instance['ignore_check']['active'] = $new_instance['ignore_check']['active'];
|
160 |
+
$instance['css']['active'] = $new_instance['css']['active'];
|
161 |
$instance['post_type'] = !empty($new_instance['post_type']) ? $new_instance['post_type'] : 'post';
|
162 |
|
163 |
update_option('newpost_catch', $instance);
|
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 |
}
|
252 |
function __construct() {
|
253 |
add_shortcode( 'npc', array( &$this, 'npc_sc' ) );
|
254 |
}
|
255 |
+
|
256 |
function npc_sc($atts) {
|
257 |
$npc_construct = new NewpostCatch();
|
258 |
+
|
259 |
// default value
|
260 |
extract( shortcode_atts( array(
|
261 |
'id' => 'npcatch',
|
262 |
'post_type' => 'post',
|
263 |
+
'post_status' => 'publish',
|
264 |
'cat' => NULL,
|
265 |
'width' => 10,
|
266 |
'height' => 10,
|
270 |
'orderby' => 'date',
|
271 |
'order' => 'DESC',
|
272 |
'date' => 0,
|
273 |
+
'meta_key' => '',
|
274 |
'dynamic' => 0,
|
275 |
), $atts ) );
|
276 |
|
293 |
// query
|
294 |
$npc_sc_query = new WP_Query( array(
|
295 |
'post_type' => $post_type,
|
296 |
+
'post_status' => $post_status,
|
297 |
'cat' => $cat,
|
298 |
'offset' => $offset,
|
299 |
'posts_per_page' => $posts_per_page,
|
300 |
'ignore_sticky_posts' => $sticky,
|
301 |
'orderby' => $orderby,
|
302 |
+
'order' => $order,
|
303 |
+
'meta_key' => $meta_key
|
304 |
));
|
305 |
|
306 |
$html = '';
|
308 |
$html .= '<ul id="' . $id . '">';
|
309 |
while( $npc_sc_query->have_posts() ) :
|
310 |
$npc_sc_query->the_post();
|
311 |
+
|
312 |
$get_date = ( $date == true ) ? '<span class="date">' . esc_html( get_the_time( get_option('date_format') ) ) . '</span>' : '';
|
313 |
|
314 |
$thumb_url = '';
|
315 |
+
if( has_post_thumbnail( get_the_ID() ) ) {
|
316 |
+
$thumb_id = get_post_thumbnail_id( get_the_ID() );
|
317 |
$thumb_url = wp_get_attachment_image_src($thumb_id);
|
318 |
$thumb_url = $thumb_url[0];
|
319 |
} else {
|
320 |
+
$thumb_url = $npc_construct->no_thumb_image();
|
321 |
}
|
322 |
+
|
323 |
$html .= '<li><a href="' . esc_url( get_permalink() ) . '" title="' . get_the_title() . '">';
|
324 |
$html .= '<img src="' . esc_url( $thumb_url ) . '" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" alt="' . get_the_title() . '" title="' . get_the_title() . '" /></a>';
|
325 |
$html .= '<span class="title"><a href="' . esc_url( get_permalink() ) . '" title="' . get_the_title() . '">' . get_the_title() . $get_date;
|
328 |
$html .= '</ul>';
|
329 |
endif;
|
330 |
wp_reset_postdata();
|
331 |
+
|
332 |
return $html;
|
333 |
}
|
334 |
}
|
335 |
}
|
|
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 |
Author: Tetsuya Imamura
|
8 |
Text Domain: newpost-catch
|
9 |
Author URI: http://www.imamura.biz/blog/
|
@@ -33,5 +33,4 @@ new NewpostCatch_SC();
|
|
33 |
You should have received a copy of the GNU General Public License
|
34 |
along with this program; if not, write to the Free Software
|
35 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
36 |
-
*/
|
37 |
-
?>
|
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/
|
33 |
You should have received a copy of the GNU General Public License
|
34 |
along with this program; if not, write to the Free Software
|
35 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
36 |
+
*/
|
|
no_thumb.png
CHANGED
Binary file
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
=== Plugin Name ===
|
2 |
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:
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
Thumbnails in new articles setting widget.
|
10 |
|
@@ -12,18 +12,18 @@ Thumbnails in new articles setting widget.
|
|
12 |
|
13 |
Thumbnails in new articles setting widget.
|
14 |
|
15 |
-
==
|
16 |
|
17 |
-
###
|
18 |
|
19 |
1. Unzip "Newpost Catch" archive.
|
20 |
2. Upload folder 'newpost-catch' to the `/wp-content/plugins/` directory
|
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 |
-
|
25 |
|
26 |
-
###
|
27 |
|
28 |
(Located in the plug-in directory) CSS "style.css" file the default
|
29 |
|
@@ -40,7 +40,7 @@ With regard to CSS will either use the default CSS,
|
|
40 |
I used the CSS that you created in your own, please change to your liking.
|
41 |
|
42 |
|
43 |
-
###
|
44 |
|
45 |
With the version up of the plugin, so will be overwritten "style.css" file each time,
|
46 |
|
@@ -53,13 +53,13 @@ In the "/wp-content/themes/theme directory/css/" as you please create a "newpost
|
|
53 |
Please the name of the file to create and "newpost-catch.css". The other is the file name, does not apply.
|
54 |
|
55 |
|
56 |
-
###
|
57 |
|
58 |
Can use the shortcode in a textwidget and theme files.
|
59 |
|
60 |
> \[npc\]
|
61 |
|
62 |
-
####
|
63 |
|
64 |
* **id**(string) - Name of the id attribute "ul" element(default:npcatch)
|
65 |
* **post_type**(string) - Use post types. Retrieves posts by Post Types(default:post)
|
@@ -93,6 +93,27 @@ When the post other than, post_type of the current page is the value of the prio
|
|
93 |
|
94 |
== Changelog ==
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
= 1.3.2 =
|
97 |
* Compatibility check with WP 4.6.1.
|
98 |
|
1 |
+
=== Plugin Name ===
|
2 |
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 |
|
12 |
|
13 |
Thumbnails in new articles setting widget.
|
14 |
|
15 |
+
== Frequently Asked Questions ==
|
16 |
|
17 |
+
### Installation
|
18 |
|
19 |
1. Unzip "Newpost Catch" archive.
|
20 |
2. Upload folder 'newpost-catch' to the `/wp-content/plugins/` directory
|
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 |
|
28 |
(Located in the plug-in directory) CSS "style.css" file the default
|
29 |
|
40 |
I used the CSS that you created in your own, please change to your liking.
|
41 |
|
42 |
|
43 |
+
### notice
|
44 |
|
45 |
With the version up of the plugin, so will be overwritten "style.css" file each time,
|
46 |
|
53 |
Please the name of the file to create and "newpost-catch.css". The other is the file name, does not apply.
|
54 |
|
55 |
|
56 |
+
### Shortcode
|
57 |
|
58 |
Can use the shortcode in a textwidget and theme files.
|
59 |
|
60 |
> \[npc\]
|
61 |
|
62 |
+
#### parameter
|
63 |
|
64 |
* **id**(string) - Name of the id attribute "ul" element(default:npcatch)
|
65 |
* **post_type**(string) - Use post types. Retrieves posts by Post Types(default:post)
|
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
|
105 |
+
* Change : Default CSS style
|
106 |
+
* Change : Default image no_thumb.png
|
107 |
+
|
108 |
+
= 1.3.4 =
|
109 |
+
* Compatibility check with WP 4.7.3.
|
110 |
+
* Change post_status only shows publish.
|
111 |
+
* Meta_key parameter is available with shortcode.
|
112 |
+
|
113 |
+
= 1.3.3 =
|
114 |
+
* Compatibility check with WP 4.7.2.
|
115 |
+
* Bugfix(thumbnail indication when shortcode was used).
|
116 |
+
|
117 |
= 1.3.2 =
|
118 |
* Compatibility check with WP 4.6.1.
|
119 |
|
style.css
CHANGED
@@ -9,31 +9,28 @@ Please the name of the file to create and "newpost-catch.css". The other is the
|
|
9 |
|
10 |
*/
|
11 |
|
12 |
-
#npcatch li{
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
}
|
17 |
|
18 |
-
#npcatch
|
19 |
-
|
20 |
-
padding:
|
|
|
21 |
}
|
22 |
|
23 |
-
#npcatch
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
}
|
28 |
|
29 |
-
#npcatch
|
|
|
|
|
30 |
}
|
31 |
|
32 |
-
#npcatch li:hover .title{
|
33 |
-
}
|
34 |
-
|
35 |
-
#npcatch li:hover .title a{
|
36 |
-
}
|
37 |
-
|
38 |
-
#npcatch li:hover .date{
|
39 |
-
}
|
9 |
|
10 |
*/
|
11 |
|
12 |
+
#npcatch li {
|
13 |
+
margin: 0;
|
14 |
+
overflow: hidden;
|
15 |
+
clear: both;
|
16 |
+
vertical-align: top;
|
17 |
}
|
18 |
|
19 |
+
#npcatch li a {
|
20 |
+
display: table;
|
21 |
+
padding: .5rem 0;
|
22 |
+
width: 100%;
|
23 |
}
|
24 |
|
25 |
+
#npcatch img {
|
26 |
+
float: left;
|
27 |
+
padding: 0 .5rem 0 0;
|
28 |
+
max-width: 100%;
|
29 |
+
height: auto;
|
30 |
}
|
31 |
|
32 |
+
#npcatch .title {
|
33 |
+
overflow: hidden;
|
34 |
+
display: block;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uninstall.php
CHANGED
@@ -6,5 +6,4 @@ Author URI: http://www.imamura.biz/blog/newpost-catch
|
|
6 |
*/
|
7 |
if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) { exit(); }
|
8 |
delete_option('widget_newpostcatch');
|
9 |
-
delete_option('npc_search_posts');
|
10 |
-
?>
|
6 |
*/
|
7 |
if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) { exit(); }
|
8 |
delete_option('widget_newpostcatch');
|
9 |
+
delete_option('npc_search_posts');
|
|