Newpost Catch - Version 1.2.2

Version Description

  • Bugfix(Link to the Setting Thumbnails in the widget).
Download this release

Release Info

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

Code changes from version 1.1.2 to 1.2.2

class.php CHANGED
@@ -4,11 +4,11 @@
4
  **/
5
  if ( !class_exists('NewpostCatch') ) {
6
  class NewpostCatch extends WP_Widget {
7
- /*** plugin variables ***/
8
- var $version = "1.1.2";
9
  var $pluginDir = "";
10
 
11
- /*** plugin structure ***/
12
  function NewpostCatch() {
13
  /** widget settings **/
14
  $widget_ops = array( 'description' => 'Thumbnails in new articles.' );
@@ -43,20 +43,17 @@ if ( !class_exists('NewpostCatch') ) {
43
  $options = array_filter( get_option( 'widget_newpostcatch' ) );
44
  unset( $options['_multiwidget'] );
45
  foreach( $options as $key => $val ) {
46
- $options = $options[$key];
47
  }
48
- if( $options['css']['active'] ){
49
  $css_path = plugin_dir_url( __FILE__ ) . 'style.css';
50
  } else {
51
- $css_path = ( @file_exists(TEMPLATEPATH.'/css/newpost-catch.css') ) ? get_stylesheet_directory_uri().'/css/newpost-catch.css' : "" ;
52
  }
53
  if( $css_path ){
54
  echo "\n"."<!-- Newpost Catch ver".$this->version." -->"."\n".'<link rel="stylesheet" href="' . $css_path . '" type="text/css" media="screen" />'."\n"."<!-- End Newpost Catch ver".$this->version." -->"."\n";
55
  }
56
  }
57
-
58
- // $css_path = ( @file_exists(TEMPLATEPATH.'/css/newpost-catch.css') ) ? get_stylesheet_directory_uri().'/css/newpost-catch.css' : plugin_dir_url( __FILE__ ).'style.css';
59
- // echo "\n"."<!-- Newpost Catch ver".$this->version." -->"."\n".'<link rel="stylesheet" href="' . $css_path . '" type="text/css" media="screen" />'."\n"."<!-- End Newpost Catch ver".$this->version." -->"."\n";
60
  }
61
 
62
  /**▼ create widget ▼**/
@@ -76,11 +73,11 @@ if ( !class_exists('NewpostCatch') ) {
76
  function no_thumb_image() {
77
  ob_start();
78
  ob_end_clean();
79
- $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches );
80
- $set_img = $output[1][0];
81
 
82
- /* if not exist images */
83
- if( empty( $set_img ) ){
 
84
  $set_img = WP_PLUGIN_URL . '/newpost-catch' . '/no_thumb.png';
85
  }
86
  return $set_img;
@@ -90,20 +87,10 @@ if ( !class_exists('NewpostCatch') ) {
90
  echo $before_widget;
91
 
92
  if ( $title ) echo $before_title . $title . $after_title;
93
- /*
94
- query_posts("showposts=" . $number .
95
- "&ignore_sticky_posts=" . $ignore .
96
- "&cat=" . $cat
97
- );
98
- */
99
  $sticky = get_option( 'sticky_posts' );
100
  if( $ignore == !false ){
101
- /*
102
- if( ($number - count($sticky)) > 0 ){
103
- $number = ($number - count($sticky));
104
- }
105
- */
106
  $npc_query = new WP_Query( array(
 
107
  'cat' => $cat,
108
  'posts_per_page' => $number,
109
  'ignore_sticky_posts' => 0,
@@ -112,6 +99,7 @@ if ( !class_exists('NewpostCatch') ) {
112
  ));
113
  } else {
114
  $npc_query = new WP_Query( array(
 
115
  'cat' => $cat,
116
  'posts_per_page' => $number,
117
  'post_not_in' => $sticky,
@@ -123,11 +111,11 @@ if ( !class_exists('NewpostCatch') ) {
123
  ?>
124
  <ul id="npcatch" >
125
  <?php if( $npc_query->have_posts() ) : ?>
 
126
  <?php while( $npc_query->have_posts() ) : $npc_query->the_post(); ?>
127
  <li>
128
  <a href="<?php echo esc_html( get_permalink() ); ?>" title="<?php esc_attr( the_title() ); ?>" >
129
  <?php if( has_post_thumbnail() ) { ?>
130
- <?php /*\n . the_post_thumbnail( array( $width , $height ),array( 'alt' => $title_attr , 'title' => $title_attr ));*/ ?>
131
  <?php
132
  $thumb_id = get_post_thumbnail_id();
133
  $thumb_url = wp_get_attachment_image_src($thumb_id);
@@ -144,11 +132,13 @@ $thumb_url = $thumb_url[0];
144
  <?php } ?>
145
  </a></span>
146
  </li>
 
147
  <?php endwhile; ?>
148
  <?php else : ?>
149
  <p>no post</p>
150
  <?php endif; wp_reset_postdata(); ?>
151
  </ul>
 
152
  <?php
153
  echo $after_widget;
154
  }
@@ -165,11 +155,11 @@ $thumb_url = $thumb_url[0];
165
  $instance['height'] = is_numeric($new_instance['height']) ? $new_instance['height'] : 10;
166
  $instance['number'] = is_numeric($new_instance['number']) ? $new_instance['number'] : 5;
167
 
168
- if( preg_match("/^[0-9]|,|-/", $new_instance['cat']) ){
169
- $instance['cat'] = $new_instance['cat'];
170
- } else {
171
- $instance['cat'] = "";
172
- }
173
 
174
  $instance['date']['active'] = $new_instance['date'];
175
  $instance['ignore_check']['active'] = $new_instance['ignore_check']['active'];
@@ -228,13 +218,112 @@ if( preg_match("/^[0-9]|,|-/", $new_instance['cat']) ){
228
  <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>
229
  </p>
230
  <p>
231
- <label><?php _e('Contact/Follow' , 'newpost-catch'); ?></label>
232
- <a href="https://twitter.com/s56bouya" target="_blank">Twitter</a>
233
- <a href="http://www.facebook.com/imamura.tetsuya" target="_blank">Facebook</a>
234
- <a href="https://plus.google.com/b/103773364658434530979/" target="_blank">Google+</a>
 
 
 
 
 
 
235
  </p>
236
  <?php
237
  }
238
  }
239
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  ?>
4
  **/
5
  if ( !class_exists('NewpostCatch') ) {
6
  class NewpostCatch extends WP_Widget {
7
+ /*** variables ***/
8
+ var $version = "1.2.2";
9
  var $pluginDir = "";
10
 
11
+ /*** structure ***/
12
  function NewpostCatch() {
13
  /** widget settings **/
14
  $widget_ops = array( 'description' => 'Thumbnails in new articles.' );
43
  $options = array_filter( get_option( 'widget_newpostcatch' ) );
44
  unset( $options['_multiwidget'] );
45
  foreach( $options as $key => $val ) {
46
+ $options[$key] = $val['css']['active'];
47
  }
48
+ if( in_array('on' , $options) ){
49
  $css_path = plugin_dir_url( __FILE__ ) . 'style.css';
50
  } else {
51
+ $css_path = ( @file_exists(STYLESHEETPATH.'/css/newpost-catch.css') ) ? get_stylesheet_directory_uri().'/css/newpost-catch.css' : "" ;
52
  }
53
  if( $css_path ){
54
  echo "\n"."<!-- Newpost Catch ver".$this->version." -->"."\n".'<link rel="stylesheet" href="' . $css_path . '" type="text/css" media="screen" />'."\n"."<!-- End Newpost Catch ver".$this->version." -->"."\n";
55
  }
56
  }
 
 
 
57
  }
58
 
59
  /**▼ create widget ▼**/
73
  function no_thumb_image() {
74
  ob_start();
75
  ob_end_clean();
76
+ preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches );
 
77
 
78
+ if( isset($matches[1][0]) && !is_wp_error($matches[1][0]) ){
79
+ $set_img = $matches[1][0];
80
+ } else {
81
  $set_img = WP_PLUGIN_URL . '/newpost-catch' . '/no_thumb.png';
82
  }
83
  return $set_img;
87
  echo $before_widget;
88
 
89
  if ( $title ) echo $before_title . $title . $after_title;
 
 
 
 
 
 
90
  $sticky = get_option( 'sticky_posts' );
91
  if( $ignore == !false ){
 
 
 
 
 
92
  $npc_query = new WP_Query( array(
93
+ 'post_type' => 'post',
94
  'cat' => $cat,
95
  'posts_per_page' => $number,
96
  'ignore_sticky_posts' => 0,
99
  ));
100
  } else {
101
  $npc_query = new WP_Query( array(
102
+ 'post_type' => 'post',
103
  'cat' => $cat,
104
  'posts_per_page' => $number,
105
  'post_not_in' => $sticky,
111
  ?>
112
  <ul id="npcatch" >
113
  <?php if( $npc_query->have_posts() ) : ?>
114
+ <?php $i = 0; ?>
115
  <?php while( $npc_query->have_posts() ) : $npc_query->the_post(); ?>
116
  <li>
117
  <a href="<?php echo esc_html( get_permalink() ); ?>" title="<?php esc_attr( the_title() ); ?>" >
118
  <?php if( has_post_thumbnail() ) { ?>
 
119
  <?php
120
  $thumb_id = get_post_thumbnail_id();
121
  $thumb_url = wp_get_attachment_image_src($thumb_id);
132
  <?php } ?>
133
  </a></span>
134
  </li>
135
+ <?php $i++; ?>
136
  <?php endwhile; ?>
137
  <?php else : ?>
138
  <p>no post</p>
139
  <?php endif; wp_reset_postdata(); ?>
140
  </ul>
141
+
142
  <?php
143
  echo $after_widget;
144
  }
155
  $instance['height'] = is_numeric($new_instance['height']) ? $new_instance['height'] : 10;
156
  $instance['number'] = is_numeric($new_instance['number']) ? $new_instance['number'] : 5;
157
 
158
+ if( preg_match("/^[0-9]|,|-/", $new_instance['cat']) ){
159
+ $instance['cat'] = $new_instance['cat'];
160
+ } else {
161
+ $instance['cat'] = "";
162
+ }
163
 
164
  $instance['date']['active'] = $new_instance['date'];
165
  $instance['ignore_check']['active'] = $new_instance['ignore_check']['active'];
218
  <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>
219
  </p>
220
  <p>
221
+ <?php _e('Use shortcode' , 'newpost-catch'); ?>
222
+ <?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>
223
+ </p>
224
+ <p>
225
+ <span><a href="<?php echo get_site_url() . '/wp-admin/options-general.php?page=Newpost-Catch.php'; ?>"><?php _e('Setting Thumbnails' , 'newpost-catch'); ?></a></span>
226
+ </p>
227
+ <p>
228
+ <?php _e('Contact/Follow' , 'newpost-catch'); ?>
229
+ <a href="https://twitter.com/NewpostCatch" target="_blank">Twitter</a>
230
+ <a href="https://www.facebook.com/NewpostCatch" target="_blank">Facebook</a>
231
  </p>
232
  <?php
233
  }
234
  }
235
  }
236
+
237
+ if ( !class_exists('NewpostCatch_SC') ) {
238
+ class NewpostCatch_SC {
239
+ function __construct(){
240
+ add_shortcode('npc', array(&$this, 'npc_sc'));
241
+
242
+ function no_thumb_image() {
243
+ ob_start();
244
+ ob_end_clean();
245
+ preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches );
246
+ if( isset( $matches[1][0]) ){
247
+ $set_img = $matches[1][0];
248
+ } else {
249
+ $set_img = WP_PLUGIN_URL . '/newpost-catch' . '/no_thumb.png';
250
+ }
251
+ return $set_img;
252
+ }
253
+ }
254
+
255
+ function npc_sc($atts) {
256
+
257
+ /** default value **/
258
+ extract( shortcode_atts( array(
259
+ 'id' => "npcatch",
260
+ 'cat' => NULL,
261
+ 'width' => 10,
262
+ 'height' => 10,
263
+ 'posts_per_page' => 5,
264
+ 'sticky' => 0,
265
+ 'offset' => 0,
266
+ 'orderby' => "date",
267
+ 'order' => "DESC",
268
+ 'date' => 0,
269
+ 'dynamic' => 0,
270
+ ), $atts ) );
271
+
272
+ if( is_array($atts) && array_key_exists('dynamic',$atts) && $atts['dynamic'] == 1 && get_post_type() == "post" && is_single() ){
273
+ $cat = get_the_category();
274
+ $cat = $cat[0];
275
+ $cat = $cat->cat_ID;
276
+ } else {
277
+ if( is_null($cat) ){
278
+ $cat = NULL;
279
+ }
280
+ }
281
+
282
+ if( is_array($atts) && array_key_exists('sticky',$atts) && $atts['sticky'] == 1 ){
283
+ $sticky = 0;
284
+ } else {
285
+ $sticky = 1;
286
+ }
287
+
288
+ /** query **/
289
+ $npc_sc_query = new WP_Query( array(
290
+ 'cat' => $cat,
291
+ 'offset' => $offset,
292
+ 'posts_per_page' => $posts_per_page,
293
+ 'ignore_sticky_posts' => $sticky,
294
+ 'orderby' => $orderby,
295
+ 'order' => $order
296
+ ));
297
+
298
+ $html = "";
299
+ if( $npc_sc_query->have_posts() ) :
300
+ $html .= "<ul id=\"$id\">\n";
301
+ while( $npc_sc_query->have_posts() ) :
302
+ $npc_sc_query->the_post();
303
+
304
+ $html .= "<li>";
305
+ $html .= "<a href=\"" . esc_html( get_permalink() ) . "\" title=\"" . esc_attr( get_the_title() ) . "\" >\n";
306
+ $thumb_url = "";
307
+ if( has_post_thumbnail() ) {
308
+ $thumb_id = get_post_thumbnail_id();
309
+ $thumb_url = wp_get_attachment_image_src($thumb_id);
310
+ $thumb_url = $thumb_url[0];
311
+ $html .= "<img src=\"" . esc_attr( $thumb_url ) . "\" width=\"" . esc_attr( $width ) . "\" height=\"" . esc_attr( $height ) . "\" alt=\"" . esc_attr( get_the_title() ) . "\" title=\"" . esc_attr( get_the_title() ) . "\" /></a>\n";
312
+ } else {
313
+ $html .= "<img src=\"" . esc_attr( no_thumb_image() ) . "\" width=\"" . esc_attr( $width ) . "\" height=\"" . esc_attr( $height ) . "\" alt=\"" . esc_attr( get_the_title() ) . "\" title=\"" . esc_attr( get_the_title() ) . "\" /></a>\n";
314
+ }
315
+ $html .= "<span class=\"title\"><a href=\"" . esc_html( get_permalink() ) . "\" title=\"" . esc_attr( get_the_title() ) . "\" >" . esc_html( get_the_title() );
316
+ if ( $date == true ) {
317
+ $html .= "<span class=\"date\">" . esc_html( get_the_time( get_option('date_format') ) ) . "</span>\n";
318
+ }
319
+ $html .= "</a></span></li>\n";
320
+ endwhile;
321
+ $html .= "</ul>";
322
+ endif;
323
+ wp_reset_postdata();
324
+
325
+ return $html;
326
+ }
327
+ }
328
+ }
329
  ?>
languages/newpost-catch-ja.mo CHANGED
Binary file
languages/newpost-catch-ja.po CHANGED
@@ -1,16 +1,15 @@
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Newpost Catch\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2013-05-11 +900\n"
6
  "PO-Revision-Date: \n"
7
- "Last-Translator: Tetsuya Imamura <wpdev@imamura.biz>\n"
8
- "Language-Team: Tetsuya Imamura <wpdev@imamura.biz>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-SourceCharset: utf-8\n"
13
- "Language: ja_JP\n"
14
  "X-Generator: Poedit 1.5.5\n"
15
 
16
  msgid "LatestPost(s)"
@@ -20,7 +19,7 @@ msgid "Title"
20
  msgstr "タイトル"
21
 
22
  msgid "Thumbnail Size"
23
- msgstr "サムネイルのサイズ"
24
 
25
  msgid "Width"
26
  msgstr "幅"
@@ -44,12 +43,70 @@ msgid "Use default css"
44
  msgstr "プラグインフォルダ内のデフォルトCSS(チェックすると適用)"
45
 
46
  msgid "Display category(ies)"
47
- msgstr ""
48
- "特定のカテゴリを指定して表示(ID指定、カンマで複数指定、IDにマイナス値「-」付"
49
- "与で除外 例:1,-2,17 などお好みで)"
50
 
51
  msgid "Check the category ID"
52
  msgstr "カテゴリのIDを確認"
53
 
 
 
 
 
 
 
54
  msgid "Contact/Follow"
55
- msgstr "その辺に居ますので、どこかで見かけましたらよろしくです。"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2012-2013 Newpost Catch
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: Newpost Catch\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2012-05-11 +900\n"
7
  "PO-Revision-Date: \n"
8
+ "Last-Translator: \n"
9
+ "Language-Team: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
 
 
13
  "X-Generator: Poedit 1.5.5\n"
14
 
15
  msgid "LatestPost(s)"
19
  msgstr "タイトル"
20
 
21
  msgid "Thumbnail Size"
22
+ msgstr "サムネイルの設定"
23
 
24
  msgid "Width"
25
  msgstr "幅"
43
  msgstr "プラグインフォルダ内のデフォルトCSS(チェックすると適用)"
44
 
45
  msgid "Display category(ies)"
46
+ msgstr "特定のカテゴリを指定して表示(ID指定、カンマで複数指定、IDにマイナス値「-」付与で除外 例:1,-2,17 などお好みで)"
 
 
47
 
48
  msgid "Check the category ID"
49
  msgstr "カテゴリのIDを確認"
50
 
51
+ msgid "Use shortcode"
52
+ msgstr "【新機能】ショートコードが使えるようになりました。"
53
+
54
+ msgid "Can use the shortcode in a textwidget and theme files."
55
+ msgstr "テーマファイル,投稿本文中など 様々な箇所に表示できます。"
56
+
57
  msgid "Contact/Follow"
58
+ msgstr "【専用アカウント作りました】プラグインに関する新機能追加や最新情報などのお知らせを配信します。是非ともフォローください。"
59
+
60
+ msgid "completed."
61
+ msgstr "設定完了しました。"
62
+
63
+ msgid "Setting Thumbnails"
64
+ msgstr "サムネイル設定"
65
+
66
+ msgid "Eyecatch image batch setting"
67
+ msgstr "アイキャッチ画像を一括で設定できます。"
68
+
69
+ msgid "I can set the eyecatch image, [the first image] found in the body of the post. (※ image does not exist, invalid image of (dead link) can not be set the URL."
70
+ msgstr "投稿の本文内に見つかった「最初の画像」をアイキャッチ画像に設定できます。(※画像が存在しない、URLが無効(リンク切れ)の画像は設定できません。)"
71
+
72
+ msgid "Search the post."
73
+ msgstr "投稿を検索"
74
+
75
+ msgid "Search"
76
+ msgstr "検索"
77
+
78
+ msgid "Search Result"
79
+ msgstr "検索結果"
80
+
81
+ msgid "Can be edited post in the [Edit] button. Please confirm the image displayed in the text and, whether or not broken links."
82
+ msgstr "「編集」ボタンで投稿の編集可能です。本文中に画像があるのに「検索結果に表示されない!」という場合は「画像がリンク切れになっていないか」など、ご確認ください。"
83
+
84
+ msgid "Edit"
85
+ msgstr "編集"
86
+
87
+ msgid "Image"
88
+ msgstr "画像"
89
+
90
+ msgid "Image URL"
91
+ msgstr "画像URL"
92
+
93
+ msgid "Not found."
94
+ msgstr "みつかりませんでした。"
95
+
96
+ msgid "Image(s) found."
97
+ msgstr "件みつかりました。"
98
+
99
+ msgid "Setting start in the [Generate] button"
100
+ msgstr "「作成」ボタンを押すと一括設定開始します。"
101
+
102
+ msgid "Generate"
103
+ msgstr "作成"
104
+
105
+ msgid "Thumbnail"
106
+ msgstr "サムネイルのサイズ"
107
+
108
+ msgid "Configuration"
109
+ msgstr "サムネイルのサイズ変更"
110
+
111
+ msgid "Media Settings"
112
+ msgstr "メディア設定"
languages/newpost-catch.pot CHANGED
@@ -47,6 +47,68 @@ msgstr ""
47
  msgid "Check the category ID"
48
  msgstr ""
49
 
 
 
 
 
 
 
50
  msgid "Contact/Follow"
51
  msgstr ""
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  msgid "Check the category ID"
48
  msgstr ""
49
 
50
+ msgid "Use shortcode"
51
+ msgstr ""
52
+
53
+ msgid "Can use the shortcode in a textwidget and theme files."
54
+ msgstr ""
55
+
56
  msgid "Contact/Follow"
57
  msgstr ""
58
 
59
+ msgid "completed."
60
+ msgstr ""
61
+
62
+ msgid "Setting Thumbnails"
63
+ msgstr ""
64
+
65
+ msgid "Eyecatch image batch setting"
66
+ msgstr ""
67
+
68
+ msgid "I can set the eyecatch image, [the first image] found in the body of the post. (※ image does not exist, invalid image of (dead link) can not be set the URL."
69
+ msgstr ""
70
+
71
+ msgid "Search the post."
72
+ msgstr ""
73
+
74
+ msgid "Search"
75
+ msgstr ""
76
+
77
+ msgid "Search Result"
78
+ msgstr ""
79
+
80
+ msgid "Can be edited post in the [Edit] button. Please confirm the image displayed in the text and, whether or not broken links."
81
+ msgstr ""
82
+
83
+ msgid "Edit"
84
+ msgstr ""
85
+
86
+ msgid "Image"
87
+ msgstr ""
88
+
89
+ msgid "Image URL"
90
+ msgstr ""
91
+
92
+ msgid "Not found."
93
+ msgstr ""
94
+
95
+ msgid "Image(s) found."
96
+ msgstr ""
97
+
98
+ msgid "Setting start in the [Generate] button"
99
+ msgstr ""
100
+
101
+ msgid "Generate"
102
+ msgstr ""
103
+
104
+ msgid "Not Found."
105
+ msgstr ""
106
+
107
+ msgid "Thumbnail"
108
+ msgstr ""
109
+
110
+ msgid "Configuration"
111
+ msgstr ""
112
+
113
+ msgid "Media Settings"
114
+ msgstr ""
newpost-catch.php CHANGED
@@ -3,20 +3,38 @@
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.1.2
7
  Author: Tetsuya Imamura
8
  Text Domain: newpost-catch
9
  Author URI: http://www.imamura.biz/blog/
10
  License: GPL2
11
  */
12
 
13
- //Includes
14
  include "class.php";
15
 
16
  //Hook
17
  add_action('widgets_init', create_function('', 'return register_widget("NewpostCatch");'));
18
 
19
- /* Copyright 2012 Tetsuya Imamura (email : wpdev@imamura.biz)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  This program is free software; you can redistribute it and/or modify
22
  it under the terms of the GNU General Public License, version 2, as
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.2.2
7
  Author: Tetsuya Imamura
8
  Text Domain: newpost-catch
9
  Author URI: http://www.imamura.biz/blog/
10
  License: GPL2
11
  */
12
 
13
+ //Include
14
  include "class.php";
15
 
16
  //Hook
17
  add_action('widgets_init', create_function('', 'return register_widget("NewpostCatch");'));
18
 
19
+ //Instance
20
+ new NewpostCatch_SC();
21
+
22
+ //Hook npc_filter
23
+ add_action( 'admin_menu', 'npc_plugin_menu' );
24
+
25
+ //Add Admin Menu
26
+ function npc_plugin_menu() {
27
+ add_options_page( 'Newpost-Catch', 'Newpost Catch', 'manage_options', "Newpost-Catch.php" , 'npc_options_page' );
28
+ }
29
+
30
+ //Define Option Page
31
+ function npc_options_page() {
32
+ require('npc_admin.php');
33
+ }
34
+
35
+
36
+
37
+ /* Copyright 2012-2014 Tetsuya Imamura (@s56bouya)
38
 
39
  This program is free software; you can redistribute it and/or modify
40
  it under the terms of the GNU General Public License, version 2, as
npc_admin.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //Init
3
+ if( isset($_POST['number']) && preg_match("/^[0-9]+$/", $_POST['number']) ){
4
+ $number = $_POST['number'];
5
+ } else {
6
+ $number = 5;
7
+ }
8
+ if( isset($set_array) ){
9
+ $set_array = array();
10
+ }
11
+
12
+ //Send to Submit Button
13
+ if ( !empty($_POST) && isset( $_POST['npc_submit'] ) ) {
14
+ //Check Adminn Referer
15
+ check_admin_referer("npc_options" , "npc_submit_wpnonce" );
16
+
17
+ //Get Option
18
+ $set_array = get_option('npc_search_posts');
19
+
20
+ //Generate Thumbnails
21
+ foreach( $set_array as $set ){
22
+ //Up Dir
23
+ $upload_dir = wp_upload_dir();
24
+ $image_data = file_get_contents($set['img_url']);
25
+ $filename = basename($set['img_url']);
26
+ if(wp_mkdir_p($upload_dir['path']))
27
+ $file = $upload_dir['path'] . '/' . $filename;
28
+ else
29
+ $file = $upload_dir['basedir'] . '/' . $filename;
30
+
31
+ file_put_contents($file, $image_data);
32
+
33
+ $wp_filetype = wp_check_filetype($filename, null );
34
+ $attachment = array(
35
+ 'post_mime_type' => $wp_filetype['type'],
36
+ 'post_title' => sanitize_file_name($filename),
37
+ 'post_content' => '',
38
+ 'post_status' => 'inherit'
39
+ );
40
+ $attach_id = wp_insert_attachment( $attachment, $file, $set['ID'] );
41
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
42
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $file );
43
+ wp_update_attachment_metadata( $attach_id, $attach_data );
44
+
45
+ //Set Thumbnail
46
+ set_post_thumbnail( $set['ID'], $attach_id );
47
+ delete_option('npc_search_posts');
48
+ }
49
+ //Display Messages
50
+ echo "<div class=\"updated\"><p><strong>" . __('completed.','newpost-catch') . "</strong></p></div>";
51
+ }
52
+ ?>
53
+
54
+ <form name="form1" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
55
+ <?php wp_nonce_field( "npc_options" , "npc_submit_wpnonce" ); ?>
56
+ <div class="wrap">
57
+ <h2>Newpost Catch <?php _e('Setting Thumbnails','newpost-catch'); ?></h2>
58
+ <h3><?php _e('Eyecatch image batch setting','newpost-catch'); ?></h3>
59
+ <h4><?php _e('I can set the eyecatch image, [the first image] found in the body of the post. (※ image does not exist, invalid image of (dead link) can not be set the URL.','newpost-catch'); ?></h4>
60
+ <div class="postbox">
61
+ <div class="inside">
62
+ <strong><?php _e('Search the post.','newpost-catch'); ?></strong>
63
+ <p><?php _e('LatestPost(s)','newpost-catch'); ?> <input type="text" name="number" value="<?php echo intval($number); ?>" size="4"> <?php _e('Post(s)','newpost-catch'); ?> <input type="submit" class="button" name="search_posts" value="<?php _e('Search','newpost-catch'); ?>" /></p>
64
+ </div>
65
+ </div>
66
+ <?php
67
+ if ( !empty($_POST) && isset( $_POST['search_posts'] ) ) {
68
+ //Check Adminn Referer
69
+ check_admin_referer("npc_options" , "npc_submit_wpnonce" );
70
+
71
+ global $wpdb;
72
+ $data = $wpdb->get_results("SELECT ID,post_title,post_content FROM {$wpdb->posts} p where p.post_status = 'publish' AND p.post_content REGEXP '<img[^>]+src=\"([^\">]+)\"' AND p.post_type IN('post') AND p.ID NOT IN ( SELECT DISTINCT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ('_thumbnail_id')) ORDER BY p.ID DESC LIMIT $number");
73
+
74
+ // var_dump($data);
75
+
76
+ if( $data ){
77
+ $set_array = array();
78
+ $set_count = 1;
79
+ ?>
80
+ <hr />
81
+ <h3><?php _e('Search Result','newpost-catch'); ?></h3>
82
+ <h4><?php _e('Can be edited post in the [Edit] button. Please confirm the image displayed in the text and, whether or not broken links.','newpost-catch'); ?></h4>
83
+ <table class="wp-list-table widefat fixed">
84
+ <thead>
85
+ <tr>
86
+ <th width="10%"><?php _e('Edit','newpost-catch'); ?></th>
87
+ <th width="30%"><?php _e('Title','newpost-catch'); ?></th>
88
+ <th width="30%"><?php _e('Image','newpost-catch'); ?></th>
89
+ <th width="30%"><?php _e('Image URL','newpost-catch'); ?></th>
90
+ </tr>
91
+ </thead>
92
+ <tbody id="the-list">
93
+ <?php foreach( $data as $result ){ ?>
94
+ <tr <?php if( $set_count % 2 == 1 ){ echo 'class="alternate"'; } ?>>
95
+ <?php
96
+ $set_img = "";
97
+ preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $result->post_content, $matches );
98
+ if( isset($matches[1][0]) && !is_wp_error($matches[1][0]) ){
99
+ $file_check = @get_headers($matches[1][0]);
100
+ if( preg_match('#^HTTP/.*\s+[200|302]+\s#i', $file_check[0]) ) {
101
+ $set_img = $matches[1][0];
102
+ $set_array[] = array('ID'=>$result->ID,'img_url'=>$matches[1][0]);
103
+ }
104
+ } else {
105
+ $set_img = WP_PLUGIN_URL . '/newpost-catch' . '/no_thumb.png';
106
+ }
107
+ echo "<td><a class=\"button\" href=\"" . get_edit_post_link($result->ID) . "\">" . __('Edit','newpost-catch') . "</a></td>";
108
+ echo "<td>" . $result->post_title . "</td>";
109
+ echo "<td>";
110
+ if( $set_img != "" ){
111
+ echo "<img src=\"" . $set_img . "\" width=\"" . 80 . "\" >";
112
+ }
113
+ echo "</td>";
114
+ echo "<td>" . $set_img . "</td>";
115
+ ?>
116
+ </tr>
117
+ <?php
118
+ $set_count++;
119
+ }
120
+ ?>
121
+ </tbody>
122
+ <tfoot>
123
+ <tr>
124
+ <th width="10%"><?php _e('Edit','newpost-catch'); ?></th>
125
+ <th width="30%"><?php _e('Title','newpost-catch'); ?></th>
126
+ <th width="30%"><?php _e('Image','newpost-catch'); ?></th>
127
+ <th width="30%"><?php _e('Image URL','newpost-catch'); ?></th>
128
+ </tr>
129
+ </tfoot>
130
+ </tbody>
131
+ </table>
132
+ <?php if( count($set_array) > 0 ){ ?>
133
+ <h3><span style="color:#4AA21A; font-weight:bold; font-size:16px;"><?php echo count($set_array); ?></span> <?php _e('Image(s) found.','newpost-catch'); ?></h3>
134
+ <h4><?php _e('Setting start in the [Generate] button','newpost-catch'); ?></h4>
135
+ <p class="submit"><input type="submit" class="button-primary" name="npc_submit" value="<?php echo _e('Generate','newpost-catch'); ?>" /></p>
136
+ <?php } else { ?>
137
+ <h3><?php _e('Not found.','newpost-catch'); ?></h3>
138
+ <?php } ?>
139
+ <hr />
140
+ <h3><?php _e('Thumbnail','newpost-catch'); ?></h3>
141
+ <p><?php _e('Width'); ?><?php echo get_option('thumbnail_size_w'); ?>px</p>
142
+ <p><?php _e('Height'); ?><?php echo get_option('thumbnail_size_h'); ?>px</p>
143
+ <p><?php if( get_option('thumbnail_crop') == 1 ) { _e('Crop thumbnail to exact dimensions (normally thumbnails are proportional)'); } ?></p>
144
+ <p><?php _e('Configuration','newpost-catch'); ?> <a href="<?php echo get_bloginfo('url') . '/wp-admin/options-media.php'; ?>"><?php _e('Media Settings','newpost-catch'); ?></a></p>
145
+ <?php
146
+ //var_dump($set_array);
147
+ update_option('npc_search_posts', $set_array);
148
+ }
149
+ }
150
+ ?>
151
+ </form>
152
+ </div>
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
5
  Requires at least: 3.3.1
6
- Tested up to: 3.5.2
7
- Stable tag: 1.1.2
8
 
9
  Thumbnails in new articles setting widget.
10
 
@@ -14,7 +14,7 @@ Thumbnails in new articles setting widget.
14
 
15
  == Installation ==
16
 
17
- **Required PHP5.**
18
 
19
  1. Unzip "Newpost Catch" archive.
20
  2. Upload folder 'newpost-catch' to the `/wp-content/plugins/` directory
@@ -23,15 +23,15 @@ Thumbnails in new articles setting widget.
23
 
24
  == Frequently Asked Questions ==
25
 
26
- **Apply your own css style**
27
 
28
  (Located in the plug-in directory) CSS "style.css" file the default
29
 
30
  (Please create a directory under the "/wp-content/themes/theme directory/css/") CSS file for customization "newpost-catch.css"
31
 
32
- Priority
33
 
34
- newpost-catch.css > style.css
35
 
36
  Will be applied at.
37
 
@@ -40,9 +40,9 @@ 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
- **notice**
44
 
45
- With the version up of the plug-in, so will be overwritten "style.css" file each time,
46
 
47
  I think how to directly edit the "style.css" file and how would you or declined.
48
 
@@ -53,6 +53,37 @@ 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
  == Screenshots ==
57
 
58
  1. To display the eye-catching(Thumbnail) set to Latest Post.
@@ -61,6 +92,37 @@ Please the name of the file to create and "newpost-catch.css". The other is the
61
 
62
  == Changelog ==
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  = 1.1.2 =
65
  * Compatibility check with WP 3.5.2.
66
  * Bugfix.
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: 3.8.1
7
+ Stable tag: 1.2.2
8
 
9
  Thumbnails in new articles setting widget.
10
 
14
 
15
  == Installation ==
16
 
17
+ ### **Required PHP5.**
18
 
19
  1. Unzip "Newpost Catch" archive.
20
  2. Upload folder 'newpost-catch' to the `/wp-content/plugins/` directory
23
 
24
  == Frequently Asked Questions ==
25
 
26
+ ### **Apply your own css style**
27
 
28
  (Located in the plug-in directory) CSS "style.css" file the default
29
 
30
  (Please create a directory under the "/wp-content/themes/theme directory/css/") CSS file for customization "newpost-catch.css"
31
 
32
+ **Priority**
33
 
34
+ > newpost-catch.css > style.css
35
 
36
  Will be applied at.
37
 
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
 
47
  I think how to directly edit the "style.css" file and how would you or declined.
48
 
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
+ * **cat**(int) - Use category id(default:NULL)
66
+ * **width**(int) - Thumbnail width px(default:10)
67
+ * **height**(int) - Thumbnail height px(default:10)
68
+ * **posts_per_page**(int) - Number of post to show per page(default:5)
69
+ * **sticky**(boolean) - Sticky posts or not(on:1 off:0 default:0)
70
+ * **offset**(int) - Number of post to displace or pass over(default:0)
71
+ * **orderby**(string) - Sort retrieved posts by parameter(default:date)
72
+ * **order**(string) - Designates the ascending or descending order of the 'orderby' parameter(default:DESC)
73
+ * **date**(boolean) - Display date(on:1 off:0 default:0)
74
+ * **dynamic**(boolean) - Show only articles in the same category as the article being displayed. If you specify both "cat" parameters, "dynamic" priority(on:1 off:0 default:0)
75
+
76
+ **Example1. Want change id name of ul element.**
77
+
78
+ > \[npc id="test"\]
79
+
80
+ **Example2. Show only articles in the same category as the article being displayed.(post_type is "post" only. and is_single() == true )**
81
+
82
+ When the post other than, post_type of the current page is the value of the priority parameter cat
83
+
84
+ > \[npc dynamic="1"\]
85
+
86
+
87
  == Screenshots ==
88
 
89
  1. To display the eye-catching(Thumbnail) set to Latest Post.
92
 
93
  == Changelog ==
94
 
95
+ = 1.2.2 =
96
+ * Bugfix(Link to the Setting Thumbnails in the widget).
97
+
98
+ = 1.2.1 =
99
+ * The translation file modification.
100
+
101
+ = 1.2.0 =
102
+ * Add Admin Menu「Setting Thumbnails」.
103
+
104
+ = 1.1.9 =
105
+ * Compatibility check with WP 3.8.1.
106
+
107
+ = 1.1.8 =
108
+ * Fixed reading of newpost-catch.css file (when using child themes)
109
+
110
+ = 1.1.7 =
111
+ * Compatibility check with WP 3.8.
112
+
113
+ = 1.1.6 =
114
+ * Compatibility check with WP 3.7.1.
115
+ * Add Shortcode.
116
+
117
+ = 1.1.5 =
118
+ * Compatibility check with WP 3.6.
119
+
120
+ = 1.1.4 =
121
+ * Bugfix(the display the first image in the post).
122
+
123
+ = 1.1.3 =
124
+ * Bugfix.
125
+
126
  = 1.1.2 =
127
  * Compatibility check with WP 3.5.2.
128
  * Bugfix.
screenshot-1.png CHANGED
Binary file
uninstall.php CHANGED
@@ -6,4 +6,5 @@ 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
  ?>
6
  */
7
  if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) { exit(); }
8
  delete_option('widget_newpostcatch');
9
+ delete_option('npc_search_posts');
10
  ?>