Plugin Directory

Changeset 640408


Ignore:
Timestamp:
12/17/2012 09:30:14 AM (13 years ago)
Author:
abmcr
Message:

New 2.0 version

Location:
prettyphot-single-image-zoom/trunk
Files:
71 added
2 edited

Legend:

Unmodified
Added
Removed
  • prettyphot-single-image-zoom/trunk/ab_prettyphoto.php

    r483102 r640408  
    55Description: Add a checkbox to media window for showing large image with prettyphoto javascript
    66Author: Andrea Bersi
    7 Version: 1.0
     7Version: 2.0
    88Author URI: http://www.andreabersi.com/
    99*/
     
    1111
    1212// constants for adding ab_prettyphoto to ADD MEDIA WINDOW
    13 define ('ab_prettyphotoZOOM_JS', plugin_dir_url(__FILE__)."prettyPhoto_3.1.3 2");
     13define ('ab_prettyphotoZOOM_JS', plugin_dir_url(__FILE__)."prettyPhoto_3.1.4");
     14$wp_version=get_bloginfo('version');
    1415
    1516/* Load localization */
     
    1718
    1819
     20/* FOR Wordpress 3.5 new logic: thank you to ungestalatbar
     21//http://wordpress.stackexchange.com/questions/76219/wordpress-3-5-attachment-fields-to-edit-and-media-send-to-editor
     22*/
     23// add highslide option to media dialog
     24function ab_prettyphoto_attachment_fields_to_edit_35( $form_fields, $post ) {
     25   if(get_option('ab_prettyphoto_enabledForDefault') == 1)  $ab_prettyphoto = 'checked="checked" ';
     26        $my_form_fields = array(
     27         'ab_prettyphoto' => array(
     28            'label'     => __('Automatic Zoom on click', 'ab_prettyphoto'),
     29            'input'     => 'html',
     30            'html'      => "
     31            <input type='checkbox' name='attachments[{$post->ID}][ab_prettyphoto]' id='ab_prettyphoto-{$post->ID}' value='1' $ab_prettyphoto/>
     32
     33
     34            <label for='ab_prettyphoto-{$post->ID}'>" . __('Enable zoom', 'ab_prettyphoto') . "</label>" )
     35    );
     36    if( $post->post_mime_type == 'image/jpeg' OR  $post->post_mime_type == 'image/gif' OR $post->post_mime_type == 'image/png' OR $post->post_mime_type == 'image/tiff')
     37      return array_merge( $form_fields, $my_form_fields );
     38    else
     39      return $form_fields;
     40}
     41
     42function ab_prettyphoto_add_meta_35($post, $attachment_data){
     43 // use this filter to add post meta if key exists or delete it if not
     44    if ( !empty($attachment_data['ab_prettyphoto']) && $attachment_data['ab_prettyphoto'] == '1' )
     45         update_post_meta($post['ID'], 'ab_prettyphoto', true);
     46    else
     47         delete_post_meta($post['ID'], 'ab_prettyphoto');
     48    return $post;
     49}
     50
     51
     52
     53function ab_prettyphoto_send_to_editor_35( $html, $id, $att ) {
     54    $is_set = get_post_meta($id,'ab_prettyphoto', true);
     55    if ($is_set and $is_set == '1'){   
     56        $title=get_the_title($id);
     57        return str_replace('<a', '<a rel="prettyPhoto-img" title="'.$title.'"', $html);
     58    }
     59   else
     60      return $html;
     61}
     62
     63
     64
     65if(version_compare( $wp_version, '3.5', '>=' )){
     66    add_filter('attachment_fields_to_save', 'ab_prettyphoto_add_meta_35',10,2);
     67}
     68
     69if(version_compare( $wp_version, '3.5', '>=' )){
     70    add_filter( 'attachment_fields_to_edit', 'ab_prettyphoto_attachment_fields_to_edit_35', 100, 2 );
     71}else{
     72    add_filter( 'attachment_fields_to_edit', 'ab_prettyphoto_attachment_fields_to_edit', 100, 2 );
     73}
     74
     75if(version_compare( $wp_version, '3.5', '>=' )){
     76    add_filter( 'media_send_to_editor', 'ab_prettyphoto_send_to_editor_35', 66, 3 );
     77}else{
     78    add_filter( 'media_send_to_editor', 'ab_prettyphoto_send_to_editor', 66, 3 );
     79}
     80
     81
     82####### OLD WP VERSION < 3.5 #########
    1983// add highslide option to media dialog
    2084function ab_prettyphoto_attachment_fields_to_edit( $form_fields, $post ) {
     
    3498      return $form_fields;
    3599}
    36 add_filter( 'attachment_fields_to_edit', 'ab_prettyphoto_attachment_fields_to_edit', 100, 2 );
     100
    37101
    38102// filter and modify html code send to editor
     
    40104function ab_prettyphoto_send_to_editor( $html, $send_id, $attachment ) {
    41105   if( isset($_POST["ab_prettyphoto-$send_id"]) ){
    42    
    43      $title=($_POST['attachments'][$send_id]['post_title']);
    44       return str_replace('<a', '<a rel="prettyPhoto-img" title="'.$title.'"', $html);
     106        $title=($_POST['attachments'][$send_id]['post_title']);
     107        return str_replace('<a', '<a rel="prettyPhoto-img" title="'.$title.'"', $html);
    45108    }
    46109   else
     
    48111}
    49112
    50 add_filter( 'media_send_to_editor', 'ab_prettyphoto_send_to_editor', 66, 3 );
    51113
    52114// activating the plugin
  • prettyphot-single-image-zoom/trunk/readme.txt

    r483116 r640408  
    44Tags: prettyPhoto, zoom, image zoom, images,
    55Requires at least: 3.0.3
    6 Tested up to: 3.3.1
     6Tested up to: 3.5
    77Stable tag: trunk
    88
     
    3030
    3131= If i want to change the theme? =
    32 The plugin come with a theme dark; into the prettyPhoto_3.1.32/js folder the launch.js file set the theme as
     32The plugin come with a theme dark; into the prettyPhoto_3.1.4/js folder the launch.js file set the theme as
    3333
    3434[…]
     
    4242theme: 'facebook'
    4343
    44 The themes are in prettyPhoto_3.1.32/images/prettyPhoto: you can use a theme you want.
     44The themes are in prettyPhoto_3.1.4/images/prettyPhoto: you can use a theme you want.
    4545
    4646= More info
    47 See at http://www.delianet.eu/servizi/sviluppo-word-press for simple demo and screenshot
     47See the screenshot
    4848
    4949== Screenshots ==
     
    5454
    5555== Changelog ==
    56 
     56= 2.0 =
     57* New code for the new Image Media
     58* Upgraded Pretthy Photo to 3.1.4
    5759= 1.0 =
    5860* First public release.
    5961
    6062== Upgrade Notice ==
    61 Upgrade notice
     63Deactivate the old version, delete it and reinstall. If you want to manualy upgrade, simple copy into
     64plugin direcory the new folder prettyPhoto_3.1.4 and replace the ab_pretthyphoto.php file.
Note: See TracChangeset for help on using the changeset viewer.