Plugin Directory

Changeset 637987


Ignore:
Timestamp:
12/12/2012 07:20:29 PM (13 years ago)
Author:
aesqe
Message:

version 1.7.6 => 3.5 compatibility

Location:
file-gallery
Files:
135 added
7 edited

Legend:

Unmodified
Added
Removed
  • file-gallery/trunk/file-gallery.php

    r581828 r637987  
    33Plugin Name: File Gallery
    44Plugin URI: http://skyphe.org/code/wordpress/file-gallery/
    5 Version: 1.7.5.3
     5Version: 1.7.6
    66Description: "File Gallery" extends WordPress' media (attachments) capabilities by adding a new gallery shortcode handler with templating support, a new interface for attachment handling when editing posts, and much more.
    77Author: Bruno "Aesqe" Babic
     
    3232 */
    3333
    34 define('FILE_GALLERY_VERSION', '1.7.5.3');
     34define('FILE_GALLERY_VERSION', '1.7.6');
    3535define('FILE_GALLERY_DEFAULT_TEMPLATES', serialize( array('default', 'file-gallery', 'list', 'simple') ) );
    3636
     
    999999            "tags_from"          => true,
    10001000            "clear_cache_nonce"  => wp_create_nonce('file-gallery-clear_cache'),
    1001             "post_thumb_nonce"   => wp_create_nonce( "set_post_thumbnail-" . $post_ID )
     1001            "post_thumb_nonce"   => wp_create_nonce( "set_post_thumbnail-" . $post_ID ),
     1002            "wp_version"         => floatval(get_bloginfo('version'))
    10021003        );
    10031004       
     
    12321233        add_meta_box('file_gallery', __( 'File Gallery', 'file-gallery' ), 'file_gallery_content', 'page', 'normal');
    12331234    }
     1235   
     1236    if( function_exists('get_taxonomies_for_attachments') ) // WP 3.5
     1237    {
     1238        add_meta_box( 'file_gallery_attachment_custom_fields', __('File Gallery: Attachment Custom Fields'), 'file_gallery_attachment_custom_fields_metabox', 'attachment', 'normal' );
     1239    }
    12341240}
    12351241add_action('admin_menu', 'file_gallery');
  • file-gallery/trunk/includes/attachments-custom-fields.php

    r559463 r637987  
    77function file_gallery_attachment_custom_fields_table( $attachment_id )
    88{
     9    if( function_exists('get_taxonomies_for_attachments') ) // WP 3.5
     10    {
     11        $attachment = get_post($attachment_id);
     12        require_once(ABSPATH . '/wp-admin/includes/meta-boxes.php');
     13        post_custom_meta_box($attachment);
     14        return;
     15    }
     16   
    917    $form_fields = array();
    1018    $custom = get_post_custom($attachment_id);
     
    131139
    132140/**
    133  * Displays attachment custom fields on media editing page.
     141 * Displays attachment custom fields on media editing page (pre 3.5)
    134142 *
    135143 * @since 1.6.5
     
    222230    add_filter('attachment_fields_to_save', 'file_gallery_attachment_fields_to_save', 10, 2);
    223231
     232/**
     233 * Attachment meta box for WordPress >= 3.5
     234 * @since 1.7.6
     235 */
     236function file_gallery_attachment_custom_fields_metabox()
     237{
     238    global $post;
     239    post_custom_meta_box($post);
     240}
  • file-gallery/trunk/includes/attachments.php

    r581828 r637987  
    11<?php
     2
     3function add_media_tag( $meta, $file, $sourceImageType )
     4{
     5    $image_file_types = apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) );
     6
     7    // Check that it's an image type
     8    if (  in_array( $sourceImageType, $image_file_types ) && function_exists('iptcparse') )
     9    {
     10        getimagesize($file, $info);
     11       
     12        if( isset($info['APP13']) )
     13        {
     14            $iptc = iptcparse($info['APP13']);
     15           
     16            if( isset($iptc['2#103']) && isset($iptc['2#103'][0]) ) {
     17                $meta['mediatag'] = $iptc['2#103'][0];
     18            }
     19        }
     20    }
     21
     22    return $meta;
     23}
     24add_filter('wp_read_image_metadata', 'add_media_tag', 10, 3);
     25
     26function add_media_tags_to_uploaded_file( $metadata, $attachment_id )
     27{
     28    if( defined('FILE_GALLERY_MEDIA_TAG_NAME') )
     29    {
     30        if( isset($metadata['image_meta']['mediatag']) ) {
     31            wp_set_object_terms($attachment_id, $metadata['image_meta']['mediatag'] , FILE_GALLERY_MEDIA_TAG_NAME);
     32        }
     33    }
     34   
     35    return $metadata;
     36}
     37add_filter( 'wp_generate_attachment_metadata', 'add_media_tags_to_uploaded_file', 10, 2 );
    238
    339function file_gallery_check_attachment_originality()
     
    321357    <div id="attachment_data_edit_form">
    322358   
     359    <?php
     360   
     361        $imagemeta = get_post_meta( $attachment->ID, '_wp_attachment_metadata', true );
     362       
     363        print_r($imagemeta['image_meta']);
     364   
     365    ?>
     366   
    323367        <input type="hidden" name="post_id" id="fgae_post_id" value="<?php echo $_POST['post_id']; ?>" />
    324368        <input type="hidden" name="attachment_id" id="fgae_attachment_id" value="<?php echo $_POST['attachment_id']; ?>" />
  • file-gallery/trunk/includes/main-form.php

    r559463 r637987  
    8787                        <option value="none"<?php if( "none" == $file_gallery_options["default_linkto"]){ ?> selected="selected"<?php } ?>><?php _e("nothing (do not link)", "file-gallery"); ?></option>
    8888                        <option value="file"<?php if( "file" == $file_gallery_options["default_linkto"]){ ?> selected="selected"<?php } ?>><?php _e("file", "file-gallery"); ?></option>
    89                         <option value="attachment"<?php if( "attachment" == $file_gallery_options["default_linkto"]){ ?> selected="selected"<?php } ?>><?php _e("attachment page", "file-gallery"); ?></option>
     89                        <?php if( floatval(get_bloginfo('version')) >= 3.5 ) : ?>
     90                            <option value="post"<?php if( "attachment" == $file_gallery_options["default_linkto"]){ ?> selected="selected"<?php } ?>><?php _e("attachment page", "file-gallery"); ?></option>
     91                        <?php else: ?>
     92                            <option value="attachment"<?php if( "attachment" == $file_gallery_options["default_linkto"]){ ?> selected="selected"<?php } ?>><?php _e("attachment page", "file-gallery"); ?></option>
     93                        <?php endif; ?>
     94
    9095                        <option value="parent_post"<?php if( "parent_post" == $file_gallery_options["default_linkto"]){ ?> selected="selected"<?php } ?>><?php _e("parent post", "file-gallery"); ?></option>
    9196                        <option value="external_url"<?php if( "external_url" == $file_gallery_options["default_external_url"]){ ?> selected="selected"<?php } ?>><?php _e("external url", "file-gallery"); ?></option>
  • file-gallery/trunk/includes/templating.php

    r581828 r637987  
    407407    }
    408408   
     409    $defaults = array(
     410        /* default values: */
     411        'order'             => 'ASC',
     412        'orderby'           => '',
     413        'id'                => $post->ID,
     414        'columns'           => 3,
     415        'size'              => 'thumbnail',
     416        'link'              => 'attachment',
     417        'include'           => '',
     418        'ids'               => '',
     419        'exclude'           => '',
     420
     421        /* added by file gallery: */
     422        'template'          => 'default',
     423        'linkclass'         => '',
     424        'imageclass'        => '',
     425        'galleryclass'      => '',
     426        'rel'               => 1,
     427        'tags'              => '',
     428        'tags_from'         => 'current',
     429        'output_type'       => 'html',
     430        'output_params'     => 1,               // needed when outputting html
     431        'attachment_ids'    => '',              // old alias of 'include' and 'ids'
     432        'mimetype'          => '',
     433        'limit'             => -1,
     434        'offset'            => -1,
     435        'paginate'          => 0,
     436        'link_size'         => 'full',
     437        'include_meta'      => false
     438    );
     439   
     440    if( floatval(get_bloginfo('version')) >= 3.5 ) {
     441        $defaults['link'] = 'post';
     442    }
     443   
    409444    // extract the defaults...
    410     extract(
    411         shortcode_atts(
    412             array(
    413                 /* default values: */
    414                 'order'             => 'ASC',
    415                 'orderby'           => '',
    416                 'id'                => $post->ID,
    417                 'columns'           => 3,
    418                 'size'              => 'thumbnail',
    419                 'link'              => 'attachment',
    420                 'include'           => '',
    421                 'exclude'           => '',
    422    
    423                 /* added by file gallery: */
    424                 'template'          => 'default',
    425                 'linkclass'         => '',
    426                 'imageclass'        => '',
    427                 'galleryclass'      => '',
    428                 'rel'               => 1,
    429                 'tags'              => '',
    430                 'tags_from'         => 'current',
    431                 'output_type'       => 'html',
    432                 'output_params'     => 1,               // needed when outputting html
    433                 'attachment_ids'    => '',              // alias of 'include'
    434                 'mimetype'          => '',
    435                 'limit'             => -1,
    436                 'offset'            => -1,
    437                 'paginate'          => 0,
    438                 'link_size'         => 'full',
    439                 'include_meta'      => false
    440             )
    441         , $attr)
    442     );
     445    extract( shortcode_atts($defaults, $attr) );
    443446
    444447    if( ! in_array($template, $default_templates) )
     
    517520    $file_gallery->debug_add('pagination', compact('paginate', 'page'));
    518521
    519     if( '' != $include && '' == $attachment_ids )
    520         $attachment_ids = $include;
    521    
     522/**/
     523    $_attachment_ids = explode(',', trim($attachment_ids, ','));
     524    $_include = explode(',', trim($include, ','));
     525    $_ids = explode(',', trim($ids, ','));
     526
     527    $attachment_ids = array_merge($_attachment_ids, $_include, $_ids);
     528    $attachment_ids = array_unique($attachment_ids);
     529    $attachment_ids = implode(',', $attachment_ids);
     530    $attachment_ids = trim($attachment_ids, ',');
     531    $attachment_ids = trim($attachment_ids);
     532/**/
     533
    522534    if( ! isset( $linkto ) )
    523535        $linkto = $link;
     
    531543    }
    532544
    533     $approved_attachment_post_statuses = apply_filters('file_gallery_approved_attachment_post_statuses', array('inherit', 'draft'));
     545    $approved_attachment_post_statuses = apply_filters('file_gallery_approved_attachment_post_statuses', array('inherit'));
    534546    $ignored_attachment_post_statuses  = apply_filters('file_gallery_ignored_attachment_post_statuses', array('trash', 'private', 'pending', 'future'));
    535547   
     
    575587    elseif( '' != $attachment_ids )
    576588    {
    577         $attachment_ids = trim($attachment_ids, ',');
    578589        $attachment_ids = explode(',', $attachment_ids);
    579         $sql_limit      = count($attachment_ids);
     590        $sql_limit = count($attachment_ids);
    580591
    581592        if( 'rand' == $orderby )
     
    584595        $attachment_ids = implode(',', $attachment_ids);
    585596
    586         if( '' == $orderby || 'rand' == $orderby )
     597        if( '' == $orderby || 'rand' == $orderby || $orderby == 'post__in' )
    587598        {
    588599            $orderby = sprintf("FIELD(ID, %s)", $attachment_ids);
     
    603614        $query .= $sql_mimetype;
    604615        $query .= sprintf(" ORDER BY %s %s ", $orderby, $order);
    605        
     616
    606617        if( true !== $paginate )
    607618            $limit = $sql_limit;
  • file-gallery/trunk/js/file-gallery.js

    r559463 r637987  
    140140        tinymce_gallery : function( title )
    141141        {
    142             var opt = title.replace("gallery", ""), // gets gallery options from image title
    143                 attachment_ids = opt.match(/attachment_ids=['"]([0-9,]+)['"]/),
     142            var opt = title.replace("gallery", "").replace("attachment_ids", "ids"), // gets gallery options from image title
     143                attachment_ids = opt.match(/ids=['"]([0-9,]+)['"]/),
    144144                attachment_includes = opt.match(/include=['"]([0-9,]+)['"]/),
    145145                post_id = opt.match(/id=['"](\d+)['"]/),
    146                 size = opt.match(/\ssize=['"]([^'"]+)['"]/i),
     146                size = opt.match(/(^|[\s]+)size=['"]([^'"]+)['"]/i),
    147147                linkto = opt.match(/link=['"]([^'"]+)['"]/i),
    148148                thelink = linkto ? linkto[1] : "attachment",
     
    164164                tags_from = opt.match(/tags_from=['"]([^'"]+)['"]/i);
    165165
    166             if( linkto && "none" != thelink && "file" != thelink && "parent_post" != thelink )
     166            if( thelink === "attachment" && file_gallery_options.wp_version >= 3.5 ) {
     167                thelink = "post";
     168            }
     169
     170            if( linkto && thelink !== "none" && thelink !== "file" && thelink !== "parent_post" && thelink !== "post" )
    167171            {
    168172                external_url = decodeURIComponent(thelink);
    169173                thelink = "external_url";
    170174            }
    171            
     175       
    172176            $("#file_gallery_postid").val( post_id ? post_id[1] : ""  );
    173177            $("#file_gallery_size").val(size ? size[1] : "thumbnail" );
     
    464468                originals = "",
    465469                file_gallery_order = "",
    466                 file_gallery_orderby = "";
     470                file_gallery_orderby = "",
     471                include_attribute_name = file_gallery_options.wp_version >= 3.5 ? "ids" : "include";
    467472           
    468473            if( "undefined" == typeof(internal_event) )
     
    609614            else
    610615                tags_from = ' tags_from="all"';
    611        
     616
    612617            if( "" != tags )
    613618                serial = '[gallery tags="' + tags + '"' + tags_from;
    614619            else if( "" != serial && false === file_gallery.is_all_checked() )
    615                 serial = '[gallery include="' + serial + '"';
     620                serial = '[gallery ' + include_attribute_name + '="' + serial + '"';
    616621            else
    617622                serial = '[gallery';
     
    20672072        });
    20682073       
    2069        
    2070         // thickbox window closed
    2071         // WP >= 3.3
    2072         if( "function" === typeof(jQuery.fn.on) )
    2073         {
    2074             jQuery(document.body).on("tb_unload", "#TB_window", function(e)
     2074        if( file_gallery_options.wp_version >= 3.5 )
     2075        {
     2076            jQuery('.media-modal-close').live("click", function(e)
    20752077            {
    20762078                file_gallery.tinymce_deselect( true );
     
    20782080            });
    20792081        }
    2080         else // WP < 3.3
    2081         {
    2082             jQuery('#TB_window').live("unload", function(e)
    2083             {
    2084                 file_gallery.tinymce_deselect( true );
    2085                 file_gallery.init();
    2086             });
     2082        else
     2083        {
     2084            // thickbox window closed
     2085            // WP >= 3.3
     2086            if( "function" === typeof(jQuery.fn.on) )
     2087            {
     2088                jQuery(document.body).on("tb_unload", "#TB_window", function(e)
     2089                {
     2090                    file_gallery.tinymce_deselect( true );
     2091                    file_gallery.init();
     2092                });
     2093            }
     2094            else // WP < 3.3
     2095            {
     2096                jQuery('#TB_window').live("unload", function(e)
     2097                {
     2098                    file_gallery.tinymce_deselect( true );
     2099                    file_gallery.init();
     2100                });
     2101            }
    20872102        }
    20882103    }
  • file-gallery/trunk/readme.txt

    r581828 r637987  
    44Tags: attachment, attachments, gallery, galleries, template, templates, shortcode, file, files, attach, detach, unattach, copy, media, tags, library, custom, custom fields, custom fields for attachments, attachment custom fields, drag drop upload
    55Requires at least: 3.1
    6 Tested up to: 3.5-alpha-21419
    7 Stable tag: 1.7.5.3
     6Tested up to: 3.5
     7Stable tag: 1.7.6
    88
    99File Gallery extends WordPress media (attachments) capabilities
     
    159159
    160160== Changelog ==
     161
     162= 1.7.6 =
     163* December 12th, 2012
     164* support for WordPress 3.5:
     165   - "ids" instead of "includes" in gallery shortcode;
     166   - attachment custom fields on single media item page;
     167   - some minor compatibility corrections and adjustments
    161168
    162169= 1.7.5.3 =
Note: See TracChangeset for help on using the changeset viewer.