Unique Headers - Version 1.2

Version Description

Download this release

Release Info

Developer ryanhellyer
Plugin Icon wp plugin Unique Headers
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

inc/class-kd-multiple-featured-images.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Copied from the Multiple Featured Images plugin version 0.3.
5
+ Changes made:
6
+ Changed "$this->nonce = 'mfi-'.$this->args['id'].$this->args['post_type'];" to "$this->nonce = 'mfi-'.$args['id'].$args['post_type'];" to remove a PHP error
7
+ Changed URL to JS file
8
+ Converted spaces to tabs
9
+ Removed trailing ?>
10
+
11
+
12
+ Copyright 2012 Marcus Kober (m.kober@koeln-dialog.de)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License, version 2, as
16
+ published by the Free Software Foundation.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+ if( !class_exists( 'kdMultipleFeaturedImages' ) ) {
29
+
30
+ class kdMultipleFeaturedImages {
31
+
32
+ private $id = '';
33
+ private $post_type = '';
34
+ private $labels = array();
35
+
36
+ private $metabox_id = '';
37
+
38
+ private $post_meta_key = '';
39
+
40
+ private $nonce = '';
41
+
42
+ private $default_labels = array(
43
+ 'name' => 'Featured Image 2',
44
+ 'set' => 'Set featured image 2',
45
+ 'remove' => 'Remove featured image 2',
46
+ 'use' => 'Use as featured image 2',
47
+ );
48
+
49
+ private $default_args = array(
50
+ 'id' => 'featured-image-2',
51
+ 'post_type' => 'page',
52
+ );
53
+
54
+ /**
55
+ * Initialize the plugin
56
+ *
57
+ * @param array $args
58
+ * @return void
59
+ */
60
+ public function __construct( $args ) {
61
+ $this->labels = wp_parse_args( $args['labels'], $this->default_labels );
62
+ unset( $args['labels'] );
63
+ $args = wp_parse_args( $args, $this->default_args );
64
+ $this->id = $args['id'];
65
+ $this->post_type = $args['post_type'];
66
+
67
+ $this->metabox_id = $this->id.'_'.$this->post_type;
68
+
69
+ $this->post_meta_key= 'kd_'.$this->id.'_'.$this->post_type.'_id';
70
+
71
+ $this->nonce = 'mfi-'.$args['id'].$args['post_type'];
72
+
73
+ if( !current_theme_supports( 'post-thumbnails' ) ) {
74
+ add_theme_support( 'post-thumbnails' );
75
+ }
76
+
77
+ add_action( 'admin_init', array( &$this, 'kd_admin_init' ) );
78
+ add_action( 'add_meta_boxes', array( &$this, 'kd_add_meta_box' ) );
79
+ add_filter( 'attachment_fields_to_edit', array( &$this, 'kd_add_attachment_field' ), 11, 2 );
80
+
81
+ add_action( 'wp_ajax_set-MuFeaImg-'.$this->id.'-'.$this->post_type, array( &$this, 'kd_ajax_set_image' ) );
82
+
83
+ add_action( 'delete_attachment', array( &$this, 'kd_delete_attachment' ) );
84
+
85
+ }
86
+
87
+ /**
88
+ * Add admin-Javascript
89
+ *
90
+ * @return void
91
+ */
92
+ public function kd_admin_init() {
93
+ wp_enqueue_script(
94
+ 'kd-multiple-featured-images',
95
+ UNIQUEHEADERS_URL . '/js/kd-admin.js',
96
+ 'jquery'
97
+ );
98
+ }
99
+
100
+ /**
101
+ * Add admin metabox for choosing additional featured images
102
+ *
103
+ * @return void
104
+ */
105
+ public function kd_add_meta_box() {
106
+ add_meta_box(
107
+ $this->metabox_id,
108
+ $this->labels['name'],
109
+ array( $this, 'kd_meta_box_content' ),
110
+ $this->post_type,
111
+ 'side',
112
+ 'low'
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Output the metabox content
118
+ *
119
+ * @global object $post
120
+ * @return void
121
+ */
122
+ public function kd_meta_box_content() {
123
+ global $post;
124
+
125
+ $image_id = get_post_meta(
126
+ $post->ID,
127
+ $this->post_meta_key,
128
+ true
129
+ );
130
+
131
+ echo $this->kd_meta_box_output( $image_id );
132
+ }
133
+
134
+ /**
135
+ * Generate the metabox content
136
+ *
137
+ * @global int $post_ID
138
+ * @param int $image_id
139
+ * @return string
140
+ */
141
+ public function kd_meta_box_output( $image_id = NULL ) {
142
+ global $post_ID;
143
+
144
+ $output = '';
145
+
146
+ $setImageLink = sprintf(
147
+ '<p class="hide-if-no-js"><a title="%2$s" href="%1$s" id="kd_%3$s" class="thickbox">%%s</a></p>',
148
+ get_upload_iframe_src( 'image' ),
149
+ $this->labels['set'],
150
+ $this->id
151
+ );
152
+
153
+ if( $image_id && get_post( $image_id ) ) {
154
+ $nonce_field = wp_create_nonce( $this->nonce.$post_ID );
155
+
156
+ $thumbnail = wp_get_attachment_image( $image_id, array( 266, 266 ) );
157
+ $output.= sprintf( $setImageLink, $thumbnail );
158
+ $output.= '<p class="hide-if-no-js">';
159
+ $output.= sprintf(
160
+ '<a href="#" id="remove-%1$s-image" onclick="kdMuFeaImgRemove( \'%1$s\', \'%2$s\', \'%3$s\' ); return false;">',
161
+ $this->id,
162
+ $this->post_type,
163
+ $nonce_field
164
+ );
165
+ $output.= $this->labels['remove'];
166
+ $output.= '</a>';
167
+ $output.= '</p>';
168
+
169
+ return $output;
170
+ }
171
+ else {
172
+ return sprintf( $setImageLink, $this->labels['set'] );
173
+ }
174
+
175
+ }
176
+
177
+ /**
178
+ * Create a new field in the image upload form
179
+ *
180
+ * @param string $form_fields
181
+ * @param object $post
182
+ * @return string
183
+ */
184
+ public function kd_add_attachment_field( $form_fields, $post ) {
185
+ $calling_id = 0;
186
+ if( isset( $_GET['post_id'] ) ) {
187
+ $calling_id = absint( $_GET['post_id'] );
188
+ }
189
+ elseif( isset( $_POST ) && count( $_POST ) ) {
190
+ $calling_id = $post->post_parent;
191
+ }
192
+
193
+ $calling_post = get_post( $calling_id );
194
+
195
+ if( is_null( $calling_post ) || $calling_post->post_type != $this->post_type ) {
196
+ return $form_fields;
197
+ }
198
+
199
+ $nonce_field = wp_create_nonce( $this->nonce.$calling_id );
200
+
201
+ $output = sprintf(
202
+ '<a href="#" id="%1$s-featuredimage" onclick="kdMuFeaImgSet( %3$s, \'%1$s\', \'%2$s\', \'%6$s\' ); return false;">%5$s</a>',
203
+ $this->id,
204
+ $this->post_type,
205
+ $post->ID,
206
+ $this->labels['name'],
207
+ $this->labels['use'],
208
+ $nonce_field
209
+ );
210
+
211
+ $form_fields['MuFeaImg-'.$this->id.'-'.$this->post_type] = array(
212
+ 'label' => $this->labels['name'],
213
+ 'input' => 'html',
214
+ 'html' => $output
215
+ );
216
+
217
+ return $form_fields;
218
+ }
219
+
220
+ /**
221
+ * Ajax function: set and delete featured image
222
+ *
223
+ * @global int $post_ID
224
+ * @return void
225
+ */
226
+ public function kd_ajax_set_image() {
227
+ global $post_ID;
228
+
229
+ $post_ID = intval( $_POST['post_id'] );
230
+
231
+ if( !current_user_can( 'edit_post', $post_ID ) ) {
232
+ die( '-1' );
233
+ }
234
+
235
+ $thumb_id = intval( $_POST['thumbnail_id'] );
236
+
237
+ check_ajax_referer( $this->nonce.$post_ID );
238
+
239
+ if( $thumb_id == '-1' ) {
240
+ delete_post_meta( $post_ID, $this->post_meta_key );
241
+
242
+ die( $this->kd_meta_box_output( NULL ) );
243
+ }
244
+
245
+ if( $thumb_id && get_post( $thumb_id) ) {
246
+ $thumb_html = wp_get_attachment_image( $thumb_id, 'thumbnail' );
247
+
248
+ if( !empty( $thumb_html ) ) {
249
+ update_post_meta( $post_ID, $this->post_meta_key, $thumb_id );
250
+
251
+ die( $this->kd_meta_box_output( $thumb_id ) );
252
+ }
253
+ }
254
+
255
+ die( '0' );
256
+
257
+ }
258
+
259
+ /**
260
+ * Delete custom featured image if attachmet is deleted
261
+ *
262
+ * @global object $wpdb
263
+ * @param int $post_id
264
+ * @return void
265
+ */
266
+ public function kd_delete_attachment( $post_id ) {
267
+ global $wpdb;
268
+
269
+ $wpdb->query(
270
+ $wpdb->prepare(
271
+ "DELETE FROM $wpdb->postmeta WHERE meta_key = '%s' AND meta_value = %d",
272
+ $this->post_meta_key,
273
+ $post_id
274
+ )
275
+ );
276
+ }
277
+
278
+ /**
279
+ * Retrieve the id of the featured image
280
+ *
281
+ * @global object $post
282
+ * @param string $image_id
283
+ * @param string $post_type
284
+ * @param int $post_id
285
+ * @return int
286
+ */
287
+ public static function get_featured_image_id( $image_id, $post_type, $post_id = NULL) {
288
+ global $post;
289
+
290
+ if( is_null( $post_id ) ) {
291
+ $post_id = get_the_ID();
292
+ }
293
+
294
+ return get_post_meta( $post_id, "kd_{$image_id}_{$post_type}_id", true);
295
+ }
296
+
297
+ /**
298
+ * Return the featured image url
299
+ *
300
+ * @param string $image_id
301
+ * @param string $post_type
302
+ * @param int $post_id
303
+ * @return string
304
+ */
305
+ public static function get_featured_image_url( $image_id, $post_type, $size = 'full', $post_id = NULL ) {
306
+ $id = self::get_featured_image_id( $image_id, $post_type, $post_id);
307
+
308
+ if( $size != 'full' ) {
309
+ $url = wp_get_attachment_image_src( $id, $size );
310
+ $url = $url[0];
311
+ }
312
+ else {
313
+ $url = wp_get_attachment_url( $id );
314
+ }
315
+
316
+ return $url;
317
+ }
318
+
319
+ /**
320
+ * Return the featured image html output
321
+ *
322
+ * @param string $image_id
323
+ * @param string $post_type
324
+ * @param string $size
325
+ * @param int $post_id
326
+ * @return string
327
+ */
328
+ public static function get_the_featured_image( $image_id, $post_type, $size = 'full', $post_id = NULL ) {
329
+ $id = self::get_featured_image_id( $image_id, $post_type, $post_id);
330
+
331
+ $output = '';
332
+
333
+ if( $id ) {
334
+ $output = wp_get_attachment_image(
335
+ $id,
336
+ $size,
337
+ false
338
+ );
339
+ }
340
+
341
+ return $output;
342
+ }
343
+
344
+ /**
345
+ * Output the featured image html output
346
+ *
347
+ * @param string $image_id
348
+ * @param string $post_type
349
+ * @param string $size
350
+ * @param int $post_id
351
+ * @return void
352
+ */
353
+ public static function the_featured_image( $image_id, $post_type, $size = 'full', $post_id = NULL ) {
354
+ echo self::get_the_featured_image( $image_id, $post_type, $size, $post_id );
355
+ }
356
+ }
357
+ }
358
+
359
+ function kd_mfi_get_featured_image_id( $image_id, $post_type, $post_id = NULL ) {
360
+ return kdMultipleFeaturedImages::get_featured_image_id( $image_id, $post_type, $post_id );
361
+ }
362
+
363
+ function kd_mfi_get_featured_image_url( $image_id, $post_type, $size = 'full', $post_id = NULL ) {
364
+ return kdMultipleFeaturedImages::get_featured_image_url( $image_id, $post_type, $size, $post_id );
365
+ }
366
+
367
+ function kd_mfi_get_the_featured_image( $image_id, $post_type, $size = 'full', $post_id = NULL ) {
368
+ return kdMultipleFeaturedImages::get_the_featured_image( $image_id, $post_type, $size, $post_id );
369
+ }
370
+
371
+ function kd_mfi_the_featured_image( $image_id, $post_type, $size = 'full', $post_id = NULL ) {
372
+ return kdMultipleFeaturedImages::the_featured_image( $image_id, $post_type, $size, $post_id );
373
+ }
inc/class-multi-post-thumbnails.php DELETED
@@ -1,343 +0,0 @@
1
- <?php
2
- /*
3
- Code abstracted from the Multiple Post Thumbnails plugin by Chris Scott (http://vocecommuncations.com/)
4
- http://wordpress.org/extend/plugins/multiple-post-thumbnails/
5
-
6
- Copyright 2010 Chris Scott (cscott@voceconnect.com)
7
-
8
- This program is free software; you can redistribute it and/or modify
9
- it under the terms of the GNU General Public License, version 2, as
10
- published by the Free Software Foundation.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program; if not, write to the Free Software
19
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
- */
21
-
22
-
23
- if ( !class_exists( 'MultiPostThumbnails' ) ) :
24
- class MultiPostThumbnails {
25
-
26
- public function __construct($args = array()) {
27
- $this->register($args);
28
- }
29
-
30
- /**
31
- * Register a new post thumbnail.
32
- *
33
- * Required $args contents:
34
- *
35
- * label - The name of the post thumbnail to display in the admin metabox
36
- *
37
- * id - Used to build the CSS class for the admin meta box. Needs to be unique and valid in a CSS class selector.
38
- *
39
- * Optional $args contents:
40
- *
41
- * post_type - The post type to register this thumbnail for. Defaults to post.
42
- *
43
- * priority - The admin metabox priority. Defaults to low to show after normal post thumbnail meta box.
44
- *
45
- * @param array|string $args See above description.
46
- * @return void
47
- */
48
- public function register($args = array()) {
49
- $defaults = array(
50
- 'label' => null,
51
- 'id' => null,
52
- 'post_type' => 'post',
53
- 'priority' => 'low',
54
- );
55
-
56
- $args = wp_parse_args($args, $defaults);
57
-
58
- // Create and set properties
59
- foreach($args as $k => $v) {
60
- $this->$k = $v;
61
- }
62
-
63
- // Need these args to be set at a minimum
64
- if (null === $this->label || null === $this->id) {
65
- if (WP_DEBUG) {
66
- trigger_error(sprintf("The 'label' and 'id' values of the 'args' parameter of '%s::%s()' are required", __CLASS__, __FUNCTION__));
67
- }
68
- return;
69
- }
70
-
71
- // add theme support if not already added
72
- if (!current_theme_supports('post-thumbnails')) {
73
- add_theme_support( 'post-thumbnails' );
74
- }
75
-
76
- add_action('add_meta_boxes', array($this, 'add_metabox'));
77
- add_filter('attachment_fields_to_edit', array($this, 'add_attachment_field'), 20, 2);
78
- add_action( 'admin_init', array( $this, 'enqueue_admin_scripts' ) );
79
- add_action("wp_ajax_set-{$this->post_type}-{$this->id}-thumbnail", array($this, 'set_thumbnail'));
80
- add_action('delete_attachment', array($this, 'action_delete_attachment'));
81
- }
82
-
83
- /**
84
- * Add admin metabox for thumbnail chooser
85
- *
86
- * @return void
87
- */
88
- public function add_metabox() {
89
- add_meta_box("{$this->post_type}-{$this->id}", __($this->label), array($this, 'thumbnail_meta_box'), $this->post_type, 'side', $this->priority);
90
- }
91
-
92
- /**
93
- * Output the thumbnail meta box
94
- *
95
- * @return string HTML output
96
- */
97
- public function thumbnail_meta_box() {
98
- global $post;
99
- $thumbnail_id = get_post_meta($post->ID, "{$this->post_type}_{$this->id}_thumbnail_id", true);
100
- echo $this->post_thumbnail_html($thumbnail_id);
101
- }
102
-
103
- /**
104
- * Throw this in the media attachment fields
105
- *
106
- * @param string $form_fields
107
- * @param string $post
108
- * @return void
109
- */
110
- public function add_attachment_field($form_fields, $post) {
111
- $calling_post_id = 0;
112
- if (isset($_GET['post_id']))
113
- $calling_post_id = absint($_GET['post_id']);
114
- elseif (isset($_POST) && count($_POST)) // Like for async-upload where $_GET['post_id'] isn't set
115
- $calling_post_id = $post->post_parent;
116
-
117
- // check the post type to see if link needs to be added
118
- $calling_post = get_post($calling_post_id);
119
- if (is_null($calling_post) || $calling_post->post_type != $this->post_type) {
120
- return $form_fields;
121
- }
122
-
123
- $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$this->post_type}-{$this->id}-{$calling_post_id}");
124
- $link = sprintf('<a id="%4$s-%1$s-thumbnail-%2$s" class="%1$s-thumbnail" href="#" onclick="MultiPostThumbnailsSetAsThumbnail(\'%2$s\', \'%1$s\', \'%4$s\', \'%5$s\');return false;">Set as %3$s</a>', $this->id, $post->ID, $this->label, $this->post_type, $ajax_nonce);
125
- $form_fields["{$this->post_type}-{$this->id}-thumbnail"] = array(
126
- 'label' => $this->label,
127
- 'input' => 'html',
128
- 'html' => $link);
129
- return $form_fields;
130
- }
131
-
132
- /**
133
- * Enqueue admin scripts
134
- *
135
- * @author Ryan Hellyer <ryan@metronet.no>
136
- */
137
- public function enqueue_admin_scripts() {
138
-
139
- // Bail out now if not on edit post/page page
140
- if ( !isset( $_GET['post'] ) && !isset( $_GET['post_id'] ) )
141
- return;
142
-
143
- // Enqueue the script
144
- wp_enqueue_script(
145
- 'featured-image-custom',
146
- UNIQUEHEADERS_URL . '/scripts/multi-post-thumbnails-admin.js',
147
- array(
148
- 'jquery'
149
- )
150
- );
151
- }
152
-
153
- /**
154
- * Deletes the post meta data for posts when an attachment used as a
155
- * multiple post thumbnail is deleted from the Media Libray
156
- *
157
- * @global object $wpdb
158
- * @param int $post_id
159
- */
160
- public function action_delete_attachment( $post_id ) {
161
- global $wpdb;
162
- $meta_key = "{$this->post_type}_{$this->id}_thumbnail_id";
163
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '%s' AND meta_value = %d", $meta_key, $post_id ));
164
- }
165
-
166
- private function plugins_url($relative_path, $plugin_path) {
167
- $template_dir = get_template_directory();
168
-
169
- foreach ( array('template_dir', 'plugin_path') as $var ) {
170
- $$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs
171
- $$var = preg_replace('|/+|', '/', $$var);
172
- }
173
- if(0 === strpos($plugin_path, $template_dir)) {
174
- $url = get_template_directory_uri();
175
- $folder = str_replace($template_dir, '', dirname($plugin_path));
176
- if ( '.' != $folder ) {
177
- $url .= '/' . ltrim($folder, '/');
178
- }
179
- if ( !empty($relative_path) && is_string($relative_path) && strpos($relative_path, '..') === false ) {
180
- $url .= '/' . ltrim($relative_path, '/');
181
- }
182
- return $url;
183
- } else {
184
- return plugins_url($relative_path, $plugin_path);
185
- }
186
- }
187
-
188
- /**
189
- * Check if post has an image attached.
190
- *
191
- * @param string $post_type The post type.
192
- * @param string $id The id used to register the thumbnail.
193
- * @param string $post_id Optional. Post ID.
194
- * @return bool Whether post has an image attached.
195
- */
196
- public static function has_post_thumbnail($post_type, $id, $post_id = null) {
197
- if (null === $post_id) {
198
- $post_id = get_the_ID();
199
- }
200
-
201
- if (!$post_id) {
202
- return false;
203
- }
204
-
205
- return get_post_meta($post_id, "{$post_type}_{$id}_thumbnail_id", true);
206
- }
207
-
208
- /**
209
- * Display Post Thumbnail.
210
- *
211
- * @param string $post_type The post type.
212
- * @param string $thumb_id The id used to register the thumbnail.
213
- * @param string $post_id Optional. Post ID.
214
- * @param int $size Optional. Image size. Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );.
215
- * @param string|array $attr Optional. Query string or array of attributes.
216
- * @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
217
- */
218
- public static function the_post_thumbnail($post_type, $thumb_id, $post_id = null, $size = 'post-thumbnail', $attr = '', $link_to_original = false) {
219
- echo self::get_the_post_thumbnail($post_type, $thumb_id, $post_id, $size, $attr, $link_to_original);
220
- }
221
-
222
- /**
223
- * Retrieve Post Thumbnail.
224
- *
225
- * @param string $post_type The post type.
226
- * @param string $thumb_id The id used to register the thumbnail.
227
- * @param int $post_id Optional. Post ID.
228
- * @param string $size Optional. Image size. Defaults to 'thumbnail'.
229
- * @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
230
- * @param string|array $attr Optional. Query string or array of attributes.
231
- */
232
- public static function get_the_post_thumbnail($post_type, $thumb_id, $post_id = NULL, $size = 'post-thumbnail', $attr = '' , $link_to_original = false) {
233
- global $id;
234
- $post_id = (NULL === $post_id) ? get_the_ID() : $post_id;
235
- $post_thumbnail_id = self::get_post_thumbnail_id($post_type, $thumb_id, $post_id);
236
- $size = apply_filters("{$post_type}_{$post_id}_thumbnail_size", $size);
237
- if ($post_thumbnail_id) {
238
- do_action("begin_fetch_multi_{$post_type}_thumbnail_html", $post_id, $post_thumbnail_id, $size); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
239
- $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
240
- do_action("end_fetch_multi_{$post_type}_thumbnail_html", $post_id, $post_thumbnail_id, $size);
241
- } else {
242
- $html = '';
243
- }
244
-
245
- if ($link_to_original && $html) {
246
- $html = sprintf('<a href="%s">%s</a>', wp_get_attachment_url($post_thumbnail_id), $html);
247
- }
248
-
249
- return apply_filters("{$post_type}_{$thumb_id}_thumbnail_html", $html, $post_id, $post_thumbnail_id, $size, $attr);
250
- }
251
-
252
- /**
253
- * Retrieve Post Thumbnail ID.
254
- *
255
- * @param string $post_type The post type.
256
- * @param string $id The id used to register the thumbnail.
257
- * @param int $post_id Post ID.
258
- * @return int
259
- */
260
- public static function get_post_thumbnail_id($post_type, $id, $post_id) {
261
- return get_post_meta($post_id, "{$post_type}_{$id}_thumbnail_id", true);
262
- }
263
-
264
- /**
265
- *
266
- * @param string $post_type The post type.
267
- * @param string $id The id used to register the thumbnail.
268
- * @param int $post_id Optional. The post ID. If not set, will attempt to get it.
269
- * @return mixed Thumbnail url or false if the post doesn't have a thumbnail for the given post type, and id.
270
- */
271
- public static function get_post_thumbnail_url($post_type, $id, $post_id = 0) {
272
- if (!$post_id) {
273
- $post_id = get_the_ID();
274
- }
275
-
276
- $post_thumbnail_id = self::get_post_thumbnail_id($post_type, $id, $post_id);
277
-
278
- return wp_get_attachment_url($post_thumbnail_id);
279
- }
280
-
281
- /**
282
- * Output the post thumbnail HTML for the metabox and AJAX callbacks
283
- *
284
- * @param string $thumbnail_id The thumbnail's post ID.
285
- * @return string HTML
286
- */
287
- private function post_thumbnail_html($thumbnail_id = null) {
288
- global $content_width, $_wp_additional_image_sizes, $post_ID;
289
-
290
- $set_thumbnail_link = sprintf('<p class="hide-if-no-js"><a title="%1$s" href="%2$s" id="set-%3$s-%4$s-thumbnail" class="thickbox">%%s</a></p>', esc_attr__( "Set {$this->label}" ), get_upload_iframe_src('image'), $this->post_type, $this->id);
291
- $content = sprintf($set_thumbnail_link, esc_html__( "Set {$this->label}" ));
292
-
293
-
294
- if ($thumbnail_id && get_post($thumbnail_id)) {
295
- $old_content_width = $content_width;
296
- $content_width = 266;
297
- if ( !isset($_wp_additional_image_sizes["{$this->post_type}-{$this->id}-thumbnail"]))
298
- $thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
299
- else
300
- $thumbnail_html = wp_get_attachment_image($thumbnail_id, "{$this->post_type}-{$this->id}-thumbnail");
301
- if (!empty($thumbnail_html)) {
302
- $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$this->post_type}-{$this->id}-{$post_ID}");
303
- $content = sprintf($set_thumbnail_link, $thumbnail_html);
304
- $content .= sprintf('<p class="hide-if-no-js"><a href="#" id="remove-%1$s-%2$s-thumbnail" onclick="MultiPostThumbnailsRemoveThumbnail(\'%2$s\', \'%1$s\', \'%4$s\');return false;">%3$s</a></p>', $this->post_type, $this->id, esc_html__( "Remove {$this->label}" ), $ajax_nonce);
305
- }
306
- $content_width = $old_content_width;
307
- }
308
-
309
- return $content;
310
- }
311
-
312
- /**
313
- * Set/remove the post thumbnail. AJAX handler.
314
- *
315
- * @return string Updated post thumbnail HTML.
316
- */
317
- public function set_thumbnail() {
318
- global $post_ID; // have to do this so get_upload_iframe_src() can grab it
319
- $post_ID = intval($_POST['post_id']);
320
- if ( !current_user_can('edit_post', $post_ID))
321
- die('-1');
322
- $thumbnail_id = intval($_POST['thumbnail_id']);
323
-
324
- check_ajax_referer("set_post_thumbnail-{$this->post_type}-{$this->id}-{$post_ID}");
325
-
326
- if ($thumbnail_id == '-1') {
327
- delete_post_meta($post_ID, "{$this->post_type}_{$this->id}_thumbnail_id");
328
- die($this->post_thumbnail_html(null));
329
- }
330
-
331
- if ($thumbnail_id && get_post($thumbnail_id)) {
332
- $thumbnail_html = wp_get_attachment_image($thumbnail_id, 'thumbnail');
333
- if (!empty($thumbnail_html)) {
334
- update_post_meta($post_ID, "{$this->post_type}_{$this->id}_thumbnail_id", $thumbnail_id);
335
- die($this->post_thumbnail_html($thumbnail_id));
336
- }
337
- }
338
-
339
- die('0');
340
- }
341
-
342
- }
343
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/{class-post-header-images.php → class-uh-post-header-images.php} RENAMED
@@ -8,7 +8,7 @@
8
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
9
  * @since 1.0
10
  */
11
- class Post_Header_Images {
12
 
13
  /**
14
  * Class constructor
@@ -36,30 +36,38 @@ class Post_Header_Images {
36
  */
37
  public function header_image_filter( $url ) {
38
 
39
- global $post;
40
-
41
  // Bail out now if not in post or page
42
- if ( !is_single() && !is_page() )
43
  return $url;
44
 
45
- // Grab current post ID
46
- $post_ID = $post->ID;
47
-
48
  // Pick post type
49
- if ( is_single() )
50
  $slug = 'post';
51
- else
52
  $slug = 'page';
 
53
 
54
  // Grab the post thumbnail ID
55
- $post_thumbnail_id = MultiPostThumbnails::get_post_thumbnail_id( $slug, 'custom-header', $post_ID );
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  // If no post thumbnail ID set, then use default
58
- if ( '' == $post_thumbnail_id )
59
  return $url;
 
60
 
61
  // Grab URL from WordPress
62
- $url = wp_get_attachment_image_src( $post_thumbnail_id, 'full' );
63
  $url = $url[0];
64
 
65
  return $url;
8
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
9
  * @since 1.0
10
  */
11
+ class UH_Post_Header_Images {
12
 
13
  /**
14
  * Class constructor
36
  */
37
  public function header_image_filter( $url ) {
38
 
 
 
39
  // Bail out now if not in post or page
40
+ if ( ! is_single() && ! is_page() )
41
  return $url;
42
 
 
 
 
43
  // Pick post type
44
+ if ( is_single() ) {
45
  $slug = 'post';
46
+ } else {
47
  $slug = 'page';
48
+ }
49
 
50
  // Grab the post thumbnail ID
51
+ $attachment_id = get_post_meta( get_the_ID(), 'kd_custom-header_' . $slug . '_id', true );
52
+
53
+ if ( '' == $attachment_id ) {
54
+
55
+ // If not set, then hunt for a legacy value (from when we used the Multiple Post Thumbnails plugins class)
56
+ $attachment_id = get_post_meta( get_the_ID(), $slug . '_custom-header_thumbnail_id', true );
57
+
58
+ // If attachment ID set here, then update the new ID
59
+ if ( '' != $attachment_id ) {
60
+ update_post_meta( get_the_ID(), 'kd_custom-header_post_id', $attachment_id );
61
+ }
62
+ }
63
 
64
  // If no post thumbnail ID set, then use default
65
+ if ( '' == $attachment_id ) {
66
  return $url;
67
+ }
68
 
69
  // Grab URL from WordPress
70
+ $url = wp_get_attachment_image_src( $attachment_id, 'full' );
71
  $url = $url[0];
72
 
73
  return $url;
inc/{class-taxonomy-header-images.php → class-uh-taxonomy-header-images.php} RENAMED
@@ -8,7 +8,7 @@
8
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
9
  * @since 1.0
10
  */
11
- class Taxonomy_Header_Images {
12
 
13
  /**
14
  * Class constructor
8
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
9
  * @since 1.0
10
  */
11
+ class UH_Taxonomy_Header_Images {
12
 
13
  /**
14
  * Class constructor
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Unique Headers
4
  Plugin URI: http://geek.ryanhellyer.net/
5
  Description: Unique Headers
6
- Version: 1.1
7
  Author: Ryan Hellyer / Metronet
8
  Author URI: http://geek.ryanhellyer.net/
9
 
@@ -43,9 +43,9 @@ if ( !defined( 'ABSPATH' ) )
43
  * @since 1.0
44
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
45
  */
46
- require( 'inc/class-taxonomy-header-images.php' );
47
- require( 'inc/class-post-header-images.php' );
48
- require( 'inc/class-multi-post-thumbnails.php' );
49
 
50
  /**
51
  * Define constants
@@ -55,7 +55,6 @@ require( 'inc/class-multi-post-thumbnails.php' );
55
  */
56
  define( 'UNIQUEHEADERS_DIR', dirname( __FILE__ ) . '/' ); // Plugin folder DIR
57
  define( 'UNIQUEHEADERS_URL', WP_PLUGIN_URL . '/' . basename( UNIQUEHEADERS_DIR ) . '' ); // Plugin folder URL
58
- define( 'UNIQUEHEADERS_OPTION', 'hyper-headers' );
59
 
60
  /**
61
  * Instantiate classes
@@ -63,19 +62,18 @@ define( 'UNIQUEHEADERS_OPTION', 'hyper-headers' );
63
  * @since 1.0
64
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
65
  */
66
- new Taxonomy_Header_Images();
67
- new Post_Header_Images();
68
- new MultiPostThumbnails(
69
- array(
70
- 'label' => __( 'Custom Header', 'unique_headers' ),
71
- 'id' => 'custom-header',
72
- 'post_type' => 'post'
73
- )
74
- );
75
- new MultiPostThumbnails(
76
- array(
77
- 'label' => __( 'Custom Header', 'unique_headers' ),
78
- 'id' => 'custom-header',
79
- 'post_type' => 'page'
80
  )
81
  );
 
 
 
3
  Plugin Name: Unique Headers
4
  Plugin URI: http://geek.ryanhellyer.net/
5
  Description: Unique Headers
6
+ Version: 1.2
7
  Author: Ryan Hellyer / Metronet
8
  Author URI: http://geek.ryanhellyer.net/
9
 
43
  * @since 1.0
44
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
45
  */
46
+ require( 'inc/class-uh-taxonomy-header-images.php' );
47
+ require( 'inc/class-uh-post-header-images.php' );
48
+ require( 'inc/class-kd-multiple-featured-images.php' );
49
 
50
  /**
51
  * Define constants
55
  */
56
  define( 'UNIQUEHEADERS_DIR', dirname( __FILE__ ) . '/' ); // Plugin folder DIR
57
  define( 'UNIQUEHEADERS_URL', WP_PLUGIN_URL . '/' . basename( UNIQUEHEADERS_DIR ) . '' ); // Plugin folder URL
 
58
 
59
  /**
60
  * Instantiate classes
62
  * @since 1.0
63
  * @author Ryan Hellyer <ryanhellyer@gmail.com>
64
  */
65
+ new UH_Taxonomy_Header_Images();
66
+ new UH_Post_Header_Images();
67
+ $args = array(
68
+ 'id' => 'custom-header',
69
+ 'post_type' => 'post', // Set this to post or page
70
+ 'labels' => array(
71
+ 'name' => __( 'Custom header', 'unique_headers' ),
72
+ 'set' => __( 'Set custom header', 'unique_headers' ),
73
+ 'remove' => __( 'Remove custom header', 'unique_headers' ),
74
+ 'use' => __( 'Use custom header', 'unique_headers' ),
 
 
 
 
75
  )
76
  );
77
+ new kdMultipleFeaturedImages( $args );
78
+ $args['post_type'] = 'page';
79
+ new kdMultipleFeaturedImages( $args );
js/kd-admin.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function kdMuFeaImgSetBoxContent( content, featuredImageID, post_type ) {
2
+ //jQuery( '.inside', '#kd_' + featuredImageID ).html( content );
3
+ jQuery( '#' + featuredImageID + '_' + post_type + ' .inside' ).html( content );
4
+ }
5
+ function kdMuFeaImgSetMetaValue( id, featuredImageID, post_type ) {
6
+ var field = jQuery('input[value=kd_' + featuredImageID + '_' + post_type + '_id]', '#list-table');
7
+ if ( field.size() > 0 ) {
8
+ jQuery('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text( id );
9
+ }
10
+ }
11
+
12
+ function kdMuFeaImgRemove ( featuredImageID, post_type, nonce ) {
13
+ jQuery.post( ajaxurl, {
14
+ action: 'set-MuFeaImg-' + featuredImageID + '-' + post_type,
15
+ post_id: jQuery('#post_ID').val(),
16
+ thumbnail_id: -1,
17
+ _ajax_nonce: nonce,
18
+ cookie: encodeURIComponent(document.cookie)
19
+ }, function( str ) {
20
+ if( str == '0' ) {
21
+ alert( setPostThumbnailL10n.error );
22
+ }
23
+ else {
24
+ kdMuFeaImgSetBoxContent( str, featuredImageID, post_type );
25
+ }
26
+ });
27
+ }
28
+
29
+ function kdMuFeaImgSet( id, featuredImageID, post_type, nonce ) {
30
+ var $link = jQuery( 'a#' + featuredImageID + '-featuredimage' );
31
+
32
+ $link.text( setPostThumbnailL10n.saving );
33
+
34
+ jQuery.post( ajaxurl, {
35
+ action: 'set-MuFeaImg-' + featuredImageID + '-' + post_type,
36
+ post_id: post_id,
37
+ thumbnail_id: id,
38
+ _ajax_nonce: nonce,
39
+ cookie: encodeURIComponent(document.cookie)
40
+ }, function( str ) {
41
+ if( str == '0' ) {
42
+ alert( setPostThumbnailL10n.error );
43
+ }
44
+ else {
45
+ var win = window.dialogArguments || opener || parent || top;
46
+
47
+ $link.show().text( setPostThumbnailL10n.done );
48
+
49
+ $link.fadeOut( 'slow', function() {
50
+ jQuery('tr.MuFeaImg-' + featuredImageID + '-' + post_type ).hide();
51
+ });
52
+
53
+ win.kdMuFeaImgSetBoxContent( str, featuredImageID, post_type );
54
+ win.kdMuFeaImgSetMetaValue( id, featuredImageID, post_type );
55
+ }
56
+ });
57
+ }
license.txt CHANGED
File without changes
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Unique Headers ===
2
- Contributors: ryanhellyer, metronet
3
- Tags: header, metronet, headers, image, header-image, header-images, taxonomy, tag, category, posts, pages, taxonomies, post, page, unique
4
  Donate link: http://geek.ryanhellyer.net/donate/
5
- Requires at least: 3.4
6
- Stable tag: 1.1
7
 
8
 
9
  Adds the ability to use unique custom headers on individual pages, posts or categories or tags.
@@ -13,8 +13,6 @@ Adds the ability to use unique custom headers on individual pages, posts or cate
13
  The <a href="http://geek.ryanhellyer.net/products/unique-headers/">Unique Headers Plugin</a> adds the ability to use unique custom headers on
14
  individual pages, posts or categories. This plugin makes use of the excellent <a href="http://wordpress.org/extend/plugins/taxonomy-metadata/">Taxonomy Metadata plugin</a> for handling header images for categories and tags.
15
 
16
- The creation of this plugin was sponsored by the <a href="http://www.dss.dep.no/">Norwegian Government Administration Services (G.A.S.)</a> and <a href="http://metronet.no/">Metronet</a>. Coding assistance was provided from <a href="http://camaya.net/">Jakob Schröter</a>.
17
-
18
 
19
  == Installation ==
20
 
@@ -27,7 +25,7 @@ After you've downloaded and extracted the files:
27
 
28
  Now you will see sections for changing your custom headers on the posts, pages and category listings.
29
 
30
- Visit the <a href="http://pixopoint.com/products/unique-headers/">Unique Headers Plugin</a> for more information.
31
 
32
 
33
  == Frequently Asked Questions ==
@@ -39,6 +37,10 @@ the taxonomy meta data which this plugin needs to use to store the custom header
39
  functionality should begin working.
40
 
41
 
 
 
 
 
42
  = Where's the settings page? =
43
 
44
  There isn't one.
@@ -62,6 +64,7 @@ No, I'm too busy. Having said that, if you are willing to pay me a small fortune
62
 
63
  == Changelog ==
64
 
 
65
  Version 1.1: Added support for tags <br />
66
  Version 1.0.4: Added support for displaying a category specific image on the single post pages<br />
67
  Version 1.0.3: Correction for $new_url for categories<br />
@@ -74,5 +77,4 @@ Version 1.0: Initial release<br />
74
 
75
  Thanks to the following for help with the development of this plugin:<br />
76
  * <a href="http://onmytodd.org">Todd</a> - Assistance with implementing support for tags<br />
77
- * <a href="http://metronet.no/">Metronet</a> - Plugin sponsor<br />
78
- * <a href="http://www.dss.dep.no/">Norwegian Government Administration Services (G.A.S.)</a> - Plugin sponsor<br />
1
  === Unique Headers ===
2
+ Contributors: ryanhellyer
3
+ Tags: header, headers, image, header-image, header-images, taxonomy, tag, category, posts, pages, taxonomies, post, page, unique
4
  Donate link: http://geek.ryanhellyer.net/donate/
5
+ Requires at least: 3.9
6
+ Stable tag: 1.2
7
 
8
 
9
  Adds the ability to use unique custom headers on individual pages, posts or categories or tags.
13
  The <a href="http://geek.ryanhellyer.net/products/unique-headers/">Unique Headers Plugin</a> adds the ability to use unique custom headers on
14
  individual pages, posts or categories. This plugin makes use of the excellent <a href="http://wordpress.org/extend/plugins/taxonomy-metadata/">Taxonomy Metadata plugin</a> for handling header images for categories and tags.
15
 
 
 
16
 
17
  == Installation ==
18
 
25
 
26
  Now you will see sections for changing your custom headers on the posts, pages and category listings.
27
 
28
+ Visit the <a href="http://geek.ryanhellyer.net/products/unique-headers/">Unique Headers Plugin</a> for more information.
29
 
30
 
31
  == Frequently Asked Questions ==
37
  functionality should begin working.
38
 
39
 
40
+ = I set an image, but now I can't change it :/ =
41
+ This is caused by a bug in a code library we've used. To work around this, you need to remove the image before adding a new one.
42
+
43
+
44
  = Where's the settings page? =
45
 
46
  There isn't one.
64
 
65
  == Changelog ==
66
 
67
+ Version 1.2: Converted to use the class from the Multiple Featured Images plugin<br />
68
  Version 1.1: Added support for tags <br />
69
  Version 1.0.4: Added support for displaying a category specific image on the single post pages<br />
70
  Version 1.0.3: Correction for $new_url for categories<br />
77
 
78
  Thanks to the following for help with the development of this plugin:<br />
79
  * <a href="http://onmytodd.org">Todd</a> - Assistance with implementing support for tags<br />
80
+ * <a href="http://www.dss.dep.no/">Norwegian Government Administration Services (G.A.S.)</a><br />
 
screenshot-1.png CHANGED
File without changes
screenshot-2.png CHANGED
File without changes
scripts/multi-post-thumbnails-admin.js DELETED
@@ -1,48 +0,0 @@
1
- function MultiPostThumbnailsSetThumbnailHTML(html, id, post_type){
2
- jQuery('.inside', '#' + post_type + '-' + id).html(html);
3
- };
4
-
5
- function MultiPostThumbnailsSetThumbnailID(thumb_id, id, post_type){
6
- var field = jQuery('input[value=_' + post_type + '_' + id + '_thumbnail_id]', '#list-table');
7
- if ( field.size() > 0 ) {
8
- jQuery('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(thumb_id);
9
- }
10
- };
11
-
12
- function MultiPostThumbnailsRemoveThumbnail(id, post_type, nonce){
13
- jQuery.post(ajaxurl, {
14
- action:'set-' + post_type + '-' + id + '-thumbnail', post_id: jQuery('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
15
- }, function(str){
16
- if ( str == '0' ) {
17
- alert( setPostThumbnailL10n.error );
18
- } else {
19
- MultiPostThumbnailsSetThumbnailHTML(str, id, post_type);
20
- }
21
- }
22
- );
23
- };
24
-
25
-
26
- function MultiPostThumbnailsSetAsThumbnail(thumb_id, id, post_type, nonce){
27
- var $link = jQuery('a#' + post_type + '-' + id + '-thumbnail-' + thumb_id);
28
-
29
- $link.text( setPostThumbnailL10n.saving );
30
- jQuery.post(ajaxurl, {
31
- action:'set-' + post_type + '-' + id + '-thumbnail', post_id: post_id, thumbnail_id: thumb_id, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
32
- }, function(str){
33
- var win = window.dialogArguments || opener || parent || top;
34
- $link.text( setPostThumbnailL10n.setThumbnail );
35
- if ( str == '0' ) {
36
- alert( setPostThumbnailL10n.error );
37
- } else {
38
- $link.show();
39
- $link.text( setPostThumbnailL10n.done );
40
- $link.fadeOut( 2000, function() {
41
- jQuery('tr.' + post_type + '-' + id + '-thumbnail').hide();
42
- });
43
- win.MultiPostThumbnailsSetThumbnailID(thumb_id, id, post_type);
44
- win.MultiPostThumbnailsSetThumbnailHTML(str, id, post_type);
45
- }
46
- }
47
- );
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/my-uploads.js DELETED
@@ -1,15 +0,0 @@
1
- jQuery(document).ready(function() {
2
-
3
- jQuery('#upload_image_button').click(function() {
4
- formfield = jQuery('#upload_image').attr('name');
5
- tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
6
- return false;
7
- });
8
-
9
- window.send_to_editor = function(html) {
10
- imgurl = jQuery('img',html).attr('src');
11
- jQuery('#upload_image').val(imgurl);
12
- tb_remove();
13
- }
14
-
15
- });