Attachments - Version 1.5.3

Version Description

  • Added Polish translation, courtesy of Wiktor Maj
  • Added Posts and Pages to Settings
  • Added new setting to natively 'Attach' Attachments via $post->post_parent
Download this release

Release Info

Developer jchristopher
Plugin Icon wp plugin Attachments
Version 1.5.3
Comparing to
See all releases

Code changes from version 1.5.2 to 1.5.3

attachments-pl_PL.mo ADDED
Binary file
attachments-pl_PL.po ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Attachments pl_PL version\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-06-03 15:16-0500\n"
6
+ "PO-Revision-Date: 2011-06-03 15:18-0500\n"
7
+ "Last-Translator: Wiktor Maj <w.maj@majpage.com>\n"
8
+ "Language-Team: Wiktor Maj <w.maj@majpage.com>\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-KeywordsList: _e;__\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "X-Poedit-Language: Polski\n"
15
+ "X-Poedit-Country: POLAND\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ # @ attachments
20
+ #: attachments.options.php:28
21
+ #, fuzzy
22
+ msgid "Post Type Settings"
23
+ msgstr "Ustawienia Custom Post Types"
24
+
25
+ # @ attachments
26
+ #: attachments.options.php:29
27
+ #, fuzzy
28
+ msgid "Include Attachments in the following Post Types:"
29
+ msgstr "Dodaj załączniki do następujących Custom Post Types:"
30
+
31
+ # @ attachments
32
+ #: attachments.options.php:41
33
+ msgid "Attachments can be integrated with your Custom Post Types. Unfortunately, there are none to work with at this time."
34
+ msgstr "Załączniki mogą być zintegrowane z Custom Post Types. Niestety w tej chwili nie ma żadnych zarejestrowanych Custom Post Types."
35
+
36
+ #: attachments.options.php:47
37
+ msgid "Miscellaneous"
38
+ msgstr ""
39
+
40
+ # @ attachments
41
+ #: attachments.options.php:57
42
+ msgid "Save"
43
+ msgstr "Zapisz"
44
+
45
+ # @ attachments
46
+ #: attachments.php:132
47
+ #: attachments.php:482
48
+ msgid "Attach"
49
+ msgstr "Załącz"
50
+
51
+ # @ attachments
52
+ #: attachments.php:156
53
+ msgid "Delete"
54
+ msgstr "Usuń"
55
+
56
+ # @ attachments
57
+ #: attachments.php:160
58
+ msgid "Title"
59
+ msgstr "Tytuł"
60
+
61
+ # @ attachments
62
+ #: attachments.php:164
63
+ msgid "Caption"
64
+ msgstr "Opis"
65
+
66
+ # @ attachments
67
+ #: attachments.php:214
68
+ msgid "Attachments"
69
+ msgstr "Załączniki"
70
+
attachments.options.php CHANGED
@@ -7,19 +7,26 @@
7
  <?php if( function_exists( 'get_post_types' ) ) : ?>
8
 
9
  <?php
10
- $args = array(
11
- 'public' => true,
12
- '_builtin' => false
13
- );
14
- $output = 'objects';
15
- $operator = 'and';
16
- $post_types = get_post_types( $args, $output, $operator );
 
 
 
 
 
 
 
17
  ?>
18
 
19
  <?php if( count( $post_types ) ) : ?>
20
 
21
- <h3><?php _e("Custom Post Type Settings", "attachments"); ?></h3>
22
- <p><?php _e("Include Attachments in the following Custom Post Types:", "attachments"); ?></p>
23
  <?php foreach($post_types as $post_type) : ?>
24
 
25
  <div class="attachments_checkbox">
@@ -28,12 +35,6 @@
28
  </div>
29
 
30
  <?php endforeach ?>
31
-
32
- <input type="hidden" name="action" value="update" />
33
- <input type="hidden" name="page_options" value="attachments_limit_to_user,<?php if( !empty( $post_types ) ) : foreach( $post_types as $post_type ) : ?>attachments_cpt_<?php echo $post_type->name; ?>,<?php endforeach; endif; ?>" />
34
- <p class="submit">
35
- <input type="submit" class="button-primary" value="<?php _e("Save", "attachments");?>" />
36
- </p>
37
 
38
  <?php else: ?>
39
 
@@ -43,5 +44,18 @@
43
 
44
  <?php endif ?>
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  </form>
47
  </div>
7
  <?php if( function_exists( 'get_post_types' ) ) : ?>
8
 
9
  <?php
10
+ $args = array(
11
+ 'public' => true,
12
+ '_builtin' => false
13
+ );
14
+ $output = 'objects';
15
+ $operator = 'and';
16
+ $post_types = get_post_types( $args, $output, $operator );
17
+
18
+ // we also want to optionally enable Pages and Posts
19
+ $post_types['post']->labels->name = 'Posts';
20
+ $post_types['post']->name = 'post';
21
+ $post_types['page']->labels->name = 'Pages';
22
+ $post_types['page']->name = 'page';
23
+
24
  ?>
25
 
26
  <?php if( count( $post_types ) ) : ?>
27
 
28
+ <h3><?php _e("Post Type Settings", "attachments"); ?></h3>
29
+ <p><?php _e("Include Attachments in the following Post Types:", "attachments"); ?></p>
30
  <?php foreach($post_types as $post_type) : ?>
31
 
32
  <div class="attachments_checkbox">
35
  </div>
36
 
37
  <?php endforeach ?>
 
 
 
 
 
 
38
 
39
  <?php else: ?>
40
 
44
 
45
  <?php endif ?>
46
 
47
+ <h3><?php _e("Miscellaneous", "attachments"); ?></h3>
48
+ <div class="attachments_checkbox">
49
+ <input type="checkbox" name="attachments_store_native" id="attachments_store_native" value="true"<?php if (get_option('attachments_store_native')=='true') : ?> checked="checked"<?php endif ?> />
50
+ <label for="attachments_store_native">Make WordPress-level attachment relationships</label>
51
+ <p class="note">If checked, Attachments will tell WordPress that all Attachments for the entry should be marked as such as though it were included in the main editor. The association will be made as though it were. Changing this option <strong>will not</strong> update existing Attachments, it only effects future saves.</p>
52
+ </div>
53
+
54
+ <input type="hidden" name="action" value="update" />
55
+ <input type="hidden" name="page_options" value="attachments_store_native,<?php if( !empty( $post_types ) ) : foreach( $post_types as $post_type ) : ?>attachments_cpt_<?php echo $post_type->name; ?>,<?php endforeach; endif; ?>" />
56
+ <p class="submit">
57
+ <input type="submit" class="button-primary" value="<?php _e("Save", "attachments");?>" />
58
+ </p>
59
+
60
  </form>
61
  </div>
attachments.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Attachments
4
  Plugin URI: http://mondaybynoon.com/wordpress-attachments/
5
  Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
6
- Version: 1.5.2
7
  Author: Jonathan Christopher
8
  Author URI: http://mondaybynoon.com/
9
  */
@@ -104,7 +104,7 @@ function attachments_options()
104
  */
105
  function attachments_menu()
106
  {
107
- add_options_page('Settings', 'Attachments', 8, __FILE__, 'attachments_options');
108
  }
109
 
110
 
@@ -197,18 +197,12 @@ function attachments_add()
197
 
198
  function attachments_meta_box()
199
  {
200
- // for posts
201
- add_meta_box( 'attachments_list', __( 'Attachments', 'attachments' ), 'attachments_add', 'post', 'normal' );
202
-
203
- // for pages
204
- add_meta_box( 'attachments_list', __( 'Attachments', 'attachments' ), 'attachments_add', 'page', 'normal' );
205
-
206
  // for custom post types
207
  if( function_exists( 'get_post_types' ) )
208
  {
209
  $args = array(
210
  'public' => true,
211
- '_builtin' => false
212
  );
213
  $output = 'objects';
214
  $operator = 'and';
@@ -333,11 +327,13 @@ function attachments_save($post_id)
333
  {
334
  if( !empty( $_POST['attachment_id_' . $i] ) )
335
  {
 
 
336
  $attachment_details = array(
337
- 'id' => $_POST['attachment_id_' . $i],
338
  'title' => str_replace( '"', '&quot;', $_POST['attachment_title_' . $i] ),
339
  'caption' => str_replace( '"', '&quot;', $_POST['attachment_caption_' . $i] ),
340
- 'order' => $_POST['attachment_order_' . $i]
341
  );
342
 
343
  // serialize data and encode
@@ -345,6 +341,24 @@ function attachments_save($post_id)
345
 
346
  // add individual attachment
347
  add_post_meta( $post_id, '_attachments', $attachment_serialized );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  }
349
  }
350
 
@@ -453,7 +467,7 @@ function is_attachments_context()
453
  global $pagenow;
454
 
455
  // if post_id is set, it's the editor upload...
456
- if ( ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) && empty( $_REQUEST['post_id'] ) )
457
  {
458
  return true;
459
  }
@@ -495,7 +509,7 @@ function attachments_init()
495
  }
496
 
497
  wp_enqueue_style( 'attachments', WP_PLUGIN_URL . '/attachments/css/attachments.css' );
498
- wp_enqueue_script( 'attachments', WP_PLUGIN_URL . '/attachments/js/attachments.js', array( 'thickbox' ), false, false );
499
 
500
  if( function_exists( 'load_plugin_textdomain' ) )
501
  {
3
  Plugin Name: Attachments
4
  Plugin URI: http://mondaybynoon.com/wordpress-attachments/
5
  Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
6
+ Version: 1.5.3
7
  Author: Jonathan Christopher
8
  Author URI: http://mondaybynoon.com/
9
  */
104
  */
105
  function attachments_menu()
106
  {
107
+ add_options_page('Settings', 'Attachments', 'manage_options', __FILE__, 'attachments_options');
108
  }
109
 
110
 
197
 
198
  function attachments_meta_box()
199
  {
 
 
 
 
 
 
200
  // for custom post types
201
  if( function_exists( 'get_post_types' ) )
202
  {
203
  $args = array(
204
  'public' => true,
205
+ '_builtin' => true
206
  );
207
  $output = 'objects';
208
  $operator = 'and';
327
  {
328
  if( !empty( $_POST['attachment_id_' . $i] ) )
329
  {
330
+ $attachment_id = intval( $_POST['attachment_id_' . $i] );
331
+
332
  $attachment_details = array(
333
+ 'id' => $attachment_id,
334
  'title' => str_replace( '"', '&quot;', $_POST['attachment_title_' . $i] ),
335
  'caption' => str_replace( '"', '&quot;', $_POST['attachment_caption_' . $i] ),
336
+ 'order' => intval( $_POST['attachment_order_' . $i] )
337
  );
338
 
339
  // serialize data and encode
341
 
342
  // add individual attachment
343
  add_post_meta( $post_id, '_attachments', $attachment_serialized );
344
+
345
+ // save native Attach
346
+ if( get_option( 'attachments_store_native' ) == 'true' )
347
+ {
348
+ // need to first check to make sure we're not overwriting a native Attach
349
+ $attach_post_ref = get_post( $attachment_id );
350
+
351
+ if( $attach_post_ref->post_parent == 0 )
352
+ {
353
+ // no current Attach, we can add ours
354
+ $attach_post = array();
355
+ $attach_post['ID'] = $attachment_id;
356
+ $attach_post['post_parent'] = $post_id;
357
+
358
+ wp_update_post( $attach_post );
359
+ }
360
+ }
361
+
362
  }
363
  }
364
 
467
  global $pagenow;
468
 
469
  // if post_id is set, it's the editor upload...
470
+ if ( ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) && ( empty( $_REQUEST['post_id'] ) && $_REQUEST['post_id'] != '0' ) )
471
  {
472
  return true;
473
  }
509
  }
510
 
511
  wp_enqueue_style( 'attachments', WP_PLUGIN_URL . '/attachments/css/attachments.css' );
512
+ wp_enqueue_script( 'attachments', WP_PLUGIN_URL . '/attachments/js/attachments.js', array( 'jquery', 'thickbox' ), false, false );
513
 
514
  if( function_exists( 'load_plugin_textdomain' ) )
515
  {
css/attachments.css CHANGED
@@ -7,9 +7,9 @@ ul#attachments-actions { overflow:hidden; zoom:1; padding-top:4px; }
7
  ul#attachments-actions li { width:50%; float:left; }
8
  li#attachments-add-new { float:right; text-align:right; }
9
 
10
- #attachments-instructions { background:#fff; margin:0; padding:12px 0 !important; }
11
 
12
- #attachments-file-list { padding:0; background:#fff; }
13
  .attachments-file-section { padding:0 0 20px 0; }
14
  p.attachments-actions { float:right; margin:6px 0 0 !important; }
15
 
@@ -34,13 +34,13 @@ p.attachments-actions { float:right; margin:6px 0 0 !important; }
34
  /* = META BOX FILE LISTING = */
35
  /* ========================= */
36
  #attachments-list ul { padding:10px 0; }
37
- #attachments-list li.attachments-file { overflow:hidden; zoom:1; background:#fff; }
38
  .attachments-data { display:none; }
39
  #poststuff li.attachments-file { height:115px; }
40
  #poststuff li.attachments-file h2 { margin:0; overflow:hidden; zoom:1; }
41
  #poststuff li.attachments-file h2 a { text-decoration:none; color:inherit; }
42
  #poststuff li.attachments-file h2 span { display:block; float:left; }
43
- #poststuff li.attachments-file h2 a span.attachment-handle-icon { padding:9px 0 0 0; cursor:move; }
44
  #poststuff li.attachments-file h2 span.attachment-name { padding:0 10px; height:2em; overflow:hidden; width:60%; }
45
  #poststuff li.attachments-file h2 span.attachment-delete { width:80px; text-align:center; padding:0.7em 0 0 0; float:right; margin-right:3px; }
46
  #poststuff li.attachments-file h2 span.attachment-delete a { font:11px "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; color:#21759b; text-decoration:underline; }
@@ -63,6 +63,7 @@ p.attachments-actions { float:right; margin:6px 0 0 !important; }
63
  .attachments_checkbox { overflow:hidden; zoom:1; padding:0 0 7px 0; }
64
  .attachments_checkbox input { display:block; float:left; margin-top:2px; }
65
  .attachments_checkbox label { display:block; float:left; padding:0 0 0 7px; }
 
66
 
67
  #attachments-tabs .subsubsub { float:left; }
68
  #attachments-tabs .subsubsub a { color:#21759b !important; }
7
  ul#attachments-actions li { width:50%; float:left; }
8
  li#attachments-add-new { float:right; text-align:right; }
9
 
10
+ #attachments-instructions { margin:0; padding:12px 0 !important; }
11
 
12
+ #attachments-file-list { padding:0; }
13
  .attachments-file-section { padding:0 0 20px 0; }
14
  p.attachments-actions { float:right; margin:6px 0 0 !important; }
15
 
34
  /* = META BOX FILE LISTING = */
35
  /* ========================= */
36
  #attachments-list ul { padding:10px 0; }
37
+ #attachments-list li.attachments-file { overflow:hidden; zoom:1; }
38
  .attachments-data { display:none; }
39
  #poststuff li.attachments-file { height:115px; }
40
  #poststuff li.attachments-file h2 { margin:0; overflow:hidden; zoom:1; }
41
  #poststuff li.attachments-file h2 a { text-decoration:none; color:inherit; }
42
  #poststuff li.attachments-file h2 span { display:block; float:left; }
43
+ #poststuff li.attachments-file h2 a span.attachment-handle-icon { padding:6px 0 0 0; cursor:move; }
44
  #poststuff li.attachments-file h2 span.attachment-name { padding:0 10px; height:2em; overflow:hidden; width:60%; }
45
  #poststuff li.attachments-file h2 span.attachment-delete { width:80px; text-align:center; padding:0.7em 0 0 0; float:right; margin-right:3px; }
46
  #poststuff li.attachments-file h2 span.attachment-delete a { font:11px "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; color:#21759b; text-decoration:underline; }
63
  .attachments_checkbox { overflow:hidden; zoom:1; padding:0 0 7px 0; }
64
  .attachments_checkbox input { display:block; float:left; margin-top:2px; }
65
  .attachments_checkbox label { display:block; float:left; padding:0 0 0 7px; }
66
+ .attachments_checkbox p.note { clear:both; font-style:italic; padding:4px 0 0 21px; max-width:550px; color:#888; }
67
 
68
  #attachments-tabs .subsubsub { float:left; }
69
  #attachments-tabs .subsubsub a { color:#21759b !important; }
images/handle.gif CHANGED
Binary file
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: jchristopher
3
  Donate link: http://mondaybynoon.com/donate/
4
  Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
5
  Requires at least: 3.0
6
- Tested up to: 3.1
7
- Stable tag: 1.5.2
8
 
9
  Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
10
 
@@ -44,6 +44,12 @@ Attachments uses WordPress' built in Media library for uploads and storage.
44
 
45
  == Changelog ==
46
 
 
 
 
 
 
 
47
  = 1.5.2 =
48
  * Added Swedish translation, courtesy of Sebastian Johansson
49
  * 'Attach' button is now localized
3
  Donate link: http://mondaybynoon.com/donate/
4
  Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
5
  Requires at least: 3.0
6
+ Tested up to: 3.2
7
+ Stable tag: 1.5.3
8
 
9
  Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
10
 
44
 
45
  == Changelog ==
46
 
47
+ = 1.5.3 =
48
+ * Added Polish translation, courtesy of Wiktor Maj
49
+ * Added Posts and Pages to Settings
50
+ * Added new setting to natively 'Attach' Attachments via $post->post_parent
51
+
52
+
53
  = 1.5.2 =
54
  * Added Swedish translation, courtesy of Sebastian Johansson
55
  * 'Attach' button is now localized