Version Description
- Tested with WordPress-3.5.1
Download this release
Release Info
Developer | tariquesani |
Plugin | Auto Post Thumbnail |
Version | 3.3.1 |
Comparing to | |
See all releases |
Code changes from version 3.3.3 to 3.3.1
- auto-post-thumbnail.php +88 -122
- css/style.css +0 -47
- img/apt_logo.jpg +0 -0
- readme.txt +3 -9
auto-post-thumbnail.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Auto Post Thumbnail
|
5 |
Plugin URI: http://www.sanisoft.com/blog/2010/04/19/wordpress-plugin-automatic-post-thumbnail/
|
6 |
Description: Automatically generate the Post Thumbnail (Featured Thumbnail) from the first image in post (or any custom post type) only if Post Thumbnail is not set manually.
|
7 |
-
Version: 3.3.
|
8 |
Author: Aditya Mooley <adityamooley@sanisoft.com>, Tarique Sani <tarique@sanisoft.com>
|
9 |
Author URI: http://www.sanisoft.com/blog/author/adityamooley/
|
10 |
Modified by Dr. Tarique Sani <tarique@sanisoft.com> to make it work with Wordpress 3.4
|
@@ -27,10 +27,11 @@ Modified by Dr. Tarique Sani <tarique@sanisoft.com> to make it work with Wordpre
|
|
27 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
28 |
*/
|
29 |
|
|
|
30 |
add_action('publish_post', 'apt_publish_post');
|
31 |
|
32 |
// This hook will now handle all sort publishing including posts, custom types, scheduled posts, etc.
|
33 |
-
add_action('transition_post_status', 'apt_check_required_transition'
|
34 |
|
35 |
add_action('admin_notices', 'apt_check_perms');
|
36 |
add_action('admin_menu', 'apt_add_admin_menu'); // Add batch process capability
|
@@ -53,132 +54,98 @@ function apt_add_admin_menu() {
|
|
53 |
function apt_interface() {
|
54 |
global $wpdb;
|
55 |
?>
|
56 |
-
<div>
|
57 |
-
<div style="margin-right:260px;">
|
58 |
-
<div style='float:left; width: 100%'>
|
59 |
-
<div id="message" class="updated fade" style="display:none"></div>
|
60 |
|
61 |
-
|
62 |
-
|
63 |
|
64 |
<?php
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
?>
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
<script type="text/javascript">
|
100 |
-
// <![CDATA[
|
101 |
-
jQuery(document).ready(function($){
|
102 |
-
var i;
|
103 |
-
var rt_images = [<?php echo $ids; ?>];
|
104 |
-
var rt_total = rt_images.length;
|
105 |
-
var rt_count = 1;
|
106 |
-
var rt_percent = 0;
|
107 |
-
|
108 |
-
$("#genpostthumbsbar").progressbar();
|
109 |
-
$("#genpostthumbsbar-percent").html( "0%" );
|
110 |
-
|
111 |
-
function genPostThumb( id ) {
|
112 |
-
$.post( "admin-ajax.php", { action: "generatepostthumbnail", id: id }, function() {
|
113 |
-
rt_percent = ( rt_count / rt_total ) * 100;
|
114 |
-
$("#genpostthumbsbar").progressbar( "value", rt_percent );
|
115 |
-
$("#genpostthumbsbar-percent").html( Math.round(rt_percent) + "%" );
|
116 |
-
rt_count = rt_count + 1;
|
117 |
-
|
118 |
-
if ( rt_images.length ) {
|
119 |
-
genPostThumb( rt_images.shift() );
|
120 |
-
} else {
|
121 |
-
$("#message").html("<p><strong><?php echo js_escape( sprintf('All done! Processed %d posts.', $count ) ); ?></strong></p>");
|
122 |
-
$("#message").show();
|
123 |
-
}
|
124 |
-
|
125 |
-
});
|
126 |
-
}
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
genPostThumb( rt_images.shift() );
|
129 |
-
});
|
130 |
-
// ]]>
|
131 |
-
</script>
|
132 |
-
<?php
|
133 |
-
}
|
134 |
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
?>
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
</div>
|
152 |
-
</div>
|
153 |
-
<?php if( !is_plugin_active( 'auto-post-thumbnail-pro/index.php' ) ) { ?>
|
154 |
-
<div class="apt_pro_advertisement">
|
155 |
-
<div>
|
156 |
-
<div class="apt_pro_logo">
|
157 |
-
<img align="middle" src=" <?php echo plugins_url( 'img/apt_logo.jpg' , __FILE__); ?>" />
|
158 |
-
</div>
|
159 |
-
<div class="apt_pro_check_out"><i>Upgrade Now</i></div>
|
160 |
-
</div>
|
161 |
-
<div class="apt_pro_features">
|
162 |
-
<ul>
|
163 |
-
<li>Auto set first image in post as featured</li>
|
164 |
-
<li>Auto set first attachment as featured</li>
|
165 |
-
<li>Featured images from videos</li>
|
166 |
-
<li>Several video services supported</li>
|
167 |
-
<li>External images, shortcode ready</li>
|
168 |
-
<li>Support for Custom Post Type</li>
|
169 |
-
<li>Ability to delete featured images</li>
|
170 |
-
<li>Multilingual ready</li>
|
171 |
-
<li>Free updates, guaranteed support</li>
|
172 |
-
<li>Works with any theme</li>
|
173 |
-
<li>Very reasonably priced</li>
|
174 |
-
</ul>
|
175 |
-
</div>
|
176 |
-
<div class="apt_pro_buy_now">
|
177 |
-
<a href="http://codecanyon.net/item/auto-post-thumbnail-pro/4322624?ref=sanisoft" target=" _blank"><input type="button" value="Upgrade" class="button-primary"/></a>
|
178 |
-
</div>
|
179 |
-
</div>
|
180 |
-
<?php } ?>
|
181 |
-
</div>
|
182 |
</div>
|
183 |
<?php
|
184 |
} //End apt_interface()
|
@@ -202,8 +169,6 @@ function apt_admin_enqueues($hook_suffix) {
|
|
202 |
wp_enqueue_script( 'jquery-ui-progressbar', plugins_url( 'jquery-ui/ui.progressbar.js', __FILE__ ), array( 'jquery-ui-core' ), '1.7.2' );
|
203 |
}
|
204 |
|
205 |
-
wp_enqueue_style( 'style', plugins_url( 'css/style.css', __FILE__ ) );
|
206 |
-
|
207 |
wp_enqueue_style( 'jquery-ui-genpostthumbs', plugins_url( 'jquery-ui/redmond/jquery-ui-1.7.2.custom.css', __FILE__ ), array(), '1.7.2' );
|
208 |
} //End apt_admin_enqueues
|
209 |
|
@@ -261,9 +226,10 @@ function apt_check_perms() {
|
|
261 |
* @return void
|
262 |
*/
|
263 |
function apt_check_required_transition($new_status='', $old_status='', $post='') {
|
|
|
264 |
|
265 |
if ('publish' == $new_status) {
|
266 |
-
apt_publish_post($
|
267 |
}
|
268 |
}
|
269 |
|
4 |
Plugin Name: Auto Post Thumbnail
|
5 |
Plugin URI: http://www.sanisoft.com/blog/2010/04/19/wordpress-plugin-automatic-post-thumbnail/
|
6 |
Description: Automatically generate the Post Thumbnail (Featured Thumbnail) from the first image in post (or any custom post type) only if Post Thumbnail is not set manually.
|
7 |
+
Version: 3.3.1
|
8 |
Author: Aditya Mooley <adityamooley@sanisoft.com>, Tarique Sani <tarique@sanisoft.com>
|
9 |
Author URI: http://www.sanisoft.com/blog/author/adityamooley/
|
10 |
Modified by Dr. Tarique Sani <tarique@sanisoft.com> to make it work with Wordpress 3.4
|
27 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
28 |
*/
|
29 |
|
30 |
+
|
31 |
add_action('publish_post', 'apt_publish_post');
|
32 |
|
33 |
// This hook will now handle all sort publishing including posts, custom types, scheduled posts, etc.
|
34 |
+
add_action('transition_post_status', 'apt_check_required_transition');
|
35 |
|
36 |
add_action('admin_notices', 'apt_check_perms');
|
37 |
add_action('admin_menu', 'apt_add_admin_menu'); // Add batch process capability
|
54 |
function apt_interface() {
|
55 |
global $wpdb;
|
56 |
?>
|
57 |
+
<div id="message" class="updated fade" style="display:none"></div>
|
|
|
|
|
|
|
58 |
|
59 |
+
<div class="wrap genpostthumbs">
|
60 |
+
<h2>Generate Post Thumbnails</h2>
|
61 |
|
62 |
<?php
|
63 |
+
// If the button was clicked
|
64 |
+
if ( !empty($_POST['generate-post-thumbnails']) ) {
|
65 |
+
// Capability check
|
66 |
+
if ( !current_user_can('manage_options') )
|
67 |
+
wp_die('Cheatin’ uh?');
|
68 |
+
|
69 |
+
// Form nonce check
|
70 |
+
check_admin_referer( 'generate-post-thumbnails' );
|
71 |
+
|
72 |
+
// Get id's of all the published posts for which post thumbnails does not exist.
|
73 |
+
$query = "SELECT * FROM {$wpdb->posts} p where p.post_status = 'publish' AND p.ID NOT IN (
|
74 |
+
SELECT DISTINCT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ('_thumbnail_id', 'skip_post_thumb')
|
75 |
+
)";
|
76 |
+
$posts = $wpdb->get_results($query);
|
77 |
+
|
78 |
+
if (empty($posts)) {
|
79 |
+
echo '<p>Currently there are no published posts available to generate thumbnails.</p>';
|
80 |
+
} else {
|
81 |
+
echo '<p>We are generating post thumbnails. Please be patient!</p>';
|
82 |
+
|
83 |
+
// Generate the list of IDs
|
84 |
+
$ids = array();
|
85 |
+
foreach ( $posts as $post )
|
86 |
+
$ids[] = $post->ID;
|
87 |
+
$ids = implode( ',', $ids );
|
88 |
+
|
89 |
+
$count = count( $posts );
|
90 |
?>
|
91 |
+
<noscript><p><em>You must enable Javascript in order to proceed!</em></p></noscript>
|
92 |
+
|
93 |
+
<div id="genpostthumbsbar" style="position:relative;height:25px;">
|
94 |
+
<div id="genpostthumbsbar-percent" style="position:absolute;left:50%;top:50%;width:50px;margin-left:-25px;height:25px;margin-top:-9px;font-weight:bold;text-align:center;"></div>
|
95 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
+
<script type="text/javascript">
|
98 |
+
// <![CDATA[
|
99 |
+
jQuery(document).ready(function($){
|
100 |
+
var i;
|
101 |
+
var rt_images = [<?php echo $ids; ?>];
|
102 |
+
var rt_total = rt_images.length;
|
103 |
+
var rt_count = 1;
|
104 |
+
var rt_percent = 0;
|
105 |
+
|
106 |
+
$("#genpostthumbsbar").progressbar();
|
107 |
+
$("#genpostthumbsbar-percent").html( "0%" );
|
108 |
+
|
109 |
+
function genPostThumb( id ) {
|
110 |
+
$.post( "admin-ajax.php", { action: "generatepostthumbnail", id: id }, function() {
|
111 |
+
rt_percent = ( rt_count / rt_total ) * 100;
|
112 |
+
$("#genpostthumbsbar").progressbar( "value", rt_percent );
|
113 |
+
$("#genpostthumbsbar-percent").html( Math.round(rt_percent) + "%" );
|
114 |
+
rt_count = rt_count + 1;
|
115 |
+
|
116 |
+
if ( rt_images.length ) {
|
117 |
genPostThumb( rt_images.shift() );
|
|
|
|
|
|
|
|
|
|
|
118 |
} else {
|
119 |
+
$("#message").html("<p><strong><?php echo js_escape( sprintf('All done! Processed %d posts.', $count ) ); ?></strong></p>");
|
120 |
+
$("#message").show();
|
121 |
+
}
|
122 |
+
|
123 |
+
});
|
124 |
+
}
|
125 |
+
|
126 |
+
genPostThumb( rt_images.shift() );
|
127 |
+
});
|
128 |
+
// ]]>
|
129 |
+
</script>
|
130 |
+
<?php
|
131 |
+
}
|
132 |
+
} else {
|
133 |
?>
|
134 |
|
135 |
+
<p>Use this tool to generate Post Thumbnail (Featured Thumbnail) for your Published posts.</p>
|
136 |
+
<p>If the script stops executing for any reason, just <strong>Reload</strong> the page and it will continue from where it stopped.</p>
|
137 |
+
|
138 |
+
<form method="post" action="">
|
139 |
+
<?php wp_nonce_field('generate-post-thumbnails') ?>
|
140 |
+
|
141 |
+
|
142 |
+
<p><input type="submit" class="button hide-if-no-js" name="generate-post-thumbnails" id="generate-post-thumbnails" value="Generate Thumbnails" /></p>
|
143 |
+
|
144 |
+
<noscript><p><em>You must enable Javascript in order to proceed!</em></p></noscript>
|
145 |
+
|
146 |
+
</form>
|
147 |
+
<p>Note: Thumbnails won't be generated for posts that already have post thumbnail or <strong><em>skip_post_thumb</em></strong> custom field set.</p>
|
148 |
+
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
</div>
|
150 |
<?php
|
151 |
} //End apt_interface()
|
169 |
wp_enqueue_script( 'jquery-ui-progressbar', plugins_url( 'jquery-ui/ui.progressbar.js', __FILE__ ), array( 'jquery-ui-core' ), '1.7.2' );
|
170 |
}
|
171 |
|
|
|
|
|
172 |
wp_enqueue_style( 'jquery-ui-genpostthumbs', plugins_url( 'jquery-ui/redmond/jquery-ui-1.7.2.custom.css', __FILE__ ), array(), '1.7.2' );
|
173 |
} //End apt_admin_enqueues
|
174 |
|
226 |
* @return void
|
227 |
*/
|
228 |
function apt_check_required_transition($new_status='', $old_status='', $post='') {
|
229 |
+
global $post_ID; // Using the post id from global reference since it is not available in $post object. Strange!
|
230 |
|
231 |
if ('publish' == $new_status) {
|
232 |
+
apt_publish_post($post_ID);
|
233 |
}
|
234 |
}
|
235 |
|
css/style.css
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
.apt_pro_advertisement{
|
2 |
-
float: right;
|
3 |
-
width: 230px;
|
4 |
-
margin-top: 15px;
|
5 |
-
margin-right:-240px;
|
6 |
-
border: medium none;
|
7 |
-
border-radius: 4px;
|
8 |
-
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.3);
|
9 |
-
padding:5px 5px 15px 5px;
|
10 |
-
background: #fff;
|
11 |
-
}
|
12 |
-
|
13 |
-
.apt_pro_logo {
|
14 |
-
float:left;
|
15 |
-
box-shadow: 4px 4px 5px rgba(0, 0, 0, 0.3);
|
16 |
-
margin:10px;
|
17 |
-
border-radius:3px;
|
18 |
-
}
|
19 |
-
|
20 |
-
.apt_pro_logo img {
|
21 |
-
border-radius:3px;
|
22 |
-
}
|
23 |
-
|
24 |
-
.apt_pro_check_out {
|
25 |
-
float:left;
|
26 |
-
font-size:35px;
|
27 |
-
line-height:35px;
|
28 |
-
width:120px;
|
29 |
-
padding-top:10px;
|
30 |
-
text-align: center;
|
31 |
-
font-family:message-box;
|
32 |
-
color: #EEEEEE;
|
33 |
-
text-shadow: 1px 1px 2px #000000;
|
34 |
-
}
|
35 |
-
|
36 |
-
.apt_pro_features {
|
37 |
-
padding-left:10px;
|
38 |
-
clear:both;
|
39 |
-
}
|
40 |
-
|
41 |
-
.apt_pro_features ul {
|
42 |
-
list-style:disc inside;
|
43 |
-
}
|
44 |
-
|
45 |
-
.apt_pro_buy_now {
|
46 |
-
text-align: center;
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
img/apt_logo.jpg
DELETED
Binary file
|
readme.txt
CHANGED
@@ -2,13 +2,14 @@
|
|
2 |
Contributors: adityamooley
|
3 |
Tags: Post, thumbnail, automatic, posts, featured image, image, featured, images, admin
|
4 |
Requires at least: 2.9.1
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 3.3.
|
7 |
|
8 |
Automatically generate the Post Thumbnail (Featured Thumbnail) from the first image in post or any custom post type only if Post Thumbnail is not set manually.
|
9 |
|
10 |
== Description ==
|
11 |
|
|
|
12 |
Go PRO! A premium version of the plugin has been launched with many more features - [See for details](http://codecanyon.net/item/auto-post-thumbnail-pro/4322624?ref=sanisoft)
|
13 |
|
14 |
Auto post thumbnail is a plugin to generate post thumbnail from first image in post or any custom post type. If the first image doesn't work it will automatically search for the next one and so on until the post thumbnail is inserted.
|
@@ -27,13 +28,6 @@ For more details, see http://www.sanisoft.com/blog/2010/04/19/wordpress-plugin-a
|
|
27 |
|
28 |
== Changelog ==
|
29 |
|
30 |
-
= 3.3.3 =
|
31 |
-
* Fix for SQL error begin caused due to no ID
|
32 |
-
|
33 |
-
= 3.3.2 =
|
34 |
-
* Tested with WordPress-3.6.x
|
35 |
-
* Small tweaks
|
36 |
-
|
37 |
= 3.3.1 =
|
38 |
* Tested with WordPress-3.5.1
|
39 |
|
2 |
Contributors: adityamooley
|
3 |
Tags: Post, thumbnail, automatic, posts, featured image, image, featured, images, admin
|
4 |
Requires at least: 2.9.1
|
5 |
+
Tested up to: 3.5.1
|
6 |
+
Stable tag: 3.3.1
|
7 |
|
8 |
Automatically generate the Post Thumbnail (Featured Thumbnail) from the first image in post or any custom post type only if Post Thumbnail is not set manually.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
|
13 |
Go PRO! A premium version of the plugin has been launched with many more features - [See for details](http://codecanyon.net/item/auto-post-thumbnail-pro/4322624?ref=sanisoft)
|
14 |
|
15 |
Auto post thumbnail is a plugin to generate post thumbnail from first image in post or any custom post type. If the first image doesn't work it will automatically search for the next one and so on until the post thumbnail is inserted.
|
28 |
|
29 |
== Changelog ==
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
= 3.3.1 =
|
32 |
* Tested with WordPress-3.5.1
|
33 |
|