WordPress.org

Plugin Directory

Changeset 368500


Ignore:
Timestamp:
04/03/11 21:07:06 (3 years ago)
Author:
stefsoton
Message:

Adding second version of my plugin

Location:
gallery-just-better/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gallery-just-better/trunk/galleryjustbetter.php

    r339329 r368500  
    44 * Plugin URI: http://www.stefaniamarchisio.com/gallery-just-better-plugin/ 
    55 * Description: A gallery of images displayed as native gallery does with a few extra features. 
    6  * Version: 0.1 
     6 * Version: 0.2 
    77 * Author: Stefania Marchisio 
    88 * Author URI: http://stefaniamarchisio.com/about/ 
     
    3636 
    3737// [galleryjb] 
    38 function galleryjb_handler($atts) { 
     38function galleryjb_handler($attr) { 
    3939    global $post, $wp_locale; 
    4040 
     
    4343 
    4444    // Allow plugins/themes to override the default gallery template. 
    45     $output = apply_filters('post_gallery', '', $atts); 
     45    $output = apply_filters('post_gallery', '', $attr); 
    4646    if ( $output != '' ) 
    4747        return $output; 
    4848 
    4949    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement 
    50     if ( isset( $atts['orderby'] ) ) { 
    51         $atts['orderby'] = sanitize_sql_orderby( $atts['orderby'] ); 
    52         if ( !$atts['orderby'] ) 
    53             unset( $atts['orderby'] ); 
     50    if ( isset( $attr['orderby'] ) ) { 
     51        $attr['orderby'] = sanitize_sql_orderby( $atts['orderby'] ); 
     52        if ( !$attr['orderby'] ) 
     53            unset( $attr['orderby'] ); 
    5454    } 
    5555 
     
    6565        'include'    => '', 
    6666        'exclude'    => '', 
    67         'link'      => '', 
    68         'target'    => false, 
    69         'author'    => true 
    70     ), $atts)); 
     67        'link'       => '', 
     68        'target'     => false, 
     69        'author'     => true 
     70    ), $attr)); 
    7171 
    7272    $id = intval($id); 
     
    102102    $captiontag = tag_escape($captiontag); 
    103103    $columns = intval($columns); 
    104     $itemwidth = $columns > 0 ? floor(100/$columns) : 100; 
     104     
     105    $itemwidth = ($columns > 0) ? floor(100/$columns) : '100'; 
     106 
    105107    $float = is_rtl() ? 'right' : 'left'; 
    106108 
    107109    $selector = "gallery-{$instance}"; 
    108110 
    109     $output = apply_filters('gallery_style', " 
     111    $gallery_style = $gallery_div = ''; 
     112    if ( apply_filters( 'use_default_gallery_style', true ) ) 
     113        $gallery_style = " 
    110114        <style type='text/css'> 
    111115            #{$selector} { 
     
    116120                margin-top: 10px; 
    117121                text-align: center; 
    118                 width: {$itemwidth}%;           } 
     122                width: {$itemwidth}%; 
     123            } 
    119124            #{$selector} img { 
    120125                border: 2px solid #cfcfcf; 
    121126            } 
    122127            #{$selector} .gallery-caption { 
    123                 background-color: #cfcfcf; 
    124128                margin-left: 0; 
    125129            } 
    126130        </style> 
    127         <!-- see gallery_shortcode() in wp-includes/media.php --> 
    128         <div id='$selector' class='gallery galleryid-{$id}'>"); 
     131        <!-- see gallery_shortcode() in wp-includes/media.php -->"; 
     132    $size_class = sanitize_html_class( $size ); 
     133    $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; 
     134    $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div ); 
    129135 
    130136    $i = 0; 
    131137    foreach ( $attachments as $id => $attachment ) { 
    132         // $link = isset($atts['link']) && 'file' == $atts['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); 
    133         $_post = & get_post( $id ); 
     138        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); 
    134139 
    135140        switch ($atts['link']) { 
    136                 case 'file': // link images to their filenames 
    137                     $url = wp_get_attachment_url($_post->ID); 
    138                     $link = wp_get_attachment_linkedimg($id, $size, $url, $target); 
    139                     break; 
    140                 case 'null': // do not make images linkable 
    141                     $link = wp_get_attachment_image($id, $size); 
    142                     break; 
    143                 case 'url': // do not make images linkable 
    144                     $url = $attachment->post_content; 
    145                     $link = wp_get_attachment_linkedimg($id, $size, $url, $target); 
    146                     break; 
    147                 default: // link images to their permalink 
    148                     $url = get_attachment_link($_post->ID); 
    149                     $link = wp_get_attachment_linkedimg($id, $size, $url, $target); 
     141            case 'null': // images are not linked 
     142                $link = wp_get_attachment_image($id, $size); 
     143                break; 
     144            case 'url': // images are linked to external URLs defined in Description textboxes 
     145                $url = $attachment->post_content; 
     146                $link = wp_get_attachment_linkedimg($id, $size, $url, $target); 
     147                break; 
     148            case 'file': // link images to their filenames (from native wp gallery) 
     149                $url = wp_get_attachment_url($_post->ID); 
     150                $link = wp_get_attachment_linkedimg($id, $size, $url, $target); 
     151                break; 
     152            default: // link images to their permalink (from native wp gallery) 
     153                $url = get_attachment_link($_post->ID); 
     154                $link = wp_get_attachment_linkedimg($id, $size, $url, $target); 
    150155        } 
    151156        $output .= "<{$itemtag} class='gallery-item'>"; 
     
    157162        if ( $captiontag && trim($attachment->post_excerpt) ) { 
    158163            $output .= " 
    159                 <{$captiontag} class='gallery-caption'> 
     164                <{$captiontag} class='wp-caption-text gallery-caption'> 
    160165                " . wptexturize($attachment->post_excerpt) . " 
    161166                </{$captiontag}>"; 
     
    170175        </div>\n"; 
    171176 
    172  
    173177    // if author has been selected 
    174178    if ($author !== false && $author !== "false") { 
    175179        $output .= '<p style="text-align:center; font-size: 0.8em">powered by <a target="_blank" href="http://www.stefaniamarchisio.com/gallery-just-better-plugin/">Gallery Just Better plugin</a></p>'; 
     180 
     181        $output .= ''; 
    176182    } 
    177183    return $output; 
  • gallery-just-better/trunk/readme.txt

    r339329 r368500  
    22Contributors: stefsoton 
    33Donate link: http://www.stefaniamarchisio.com/donations/ 
    4 Tags: gallery, image, images, picture, pictures, photo, photos, photograph, photographs, photoblog, photoblogs, thimbnail, thumbnails, link, links, linkable, clickable, framed, shortcode 
     4Tags: gallery, mosaic, image, images, picture, pictures, photo, photos, photograph, photographs, photoblog, photoblogs, thumbnail, thumbnails, link, links, linkable, clickable, framed, shortcode 
    55Requires at least: 2.5 
    6 Tested up to: 3.0.4 
    7 Stable tag: 0.1 
     6Tested up to: 3.1 
     7Stable tag: 0.2 
    88 
    9 The look & feel of the native wordpress [gallery] with a few new features: non-linked images, images linkable to extrenal URLs and linked objects displayable on a new tab/window. 
     9The look & feel of the native wp [gallery] with added features: non-linkable images or linkable to external URLs; linked page viewable in a new window. 
    1010 
    1111== Description == 
    1212 
    13 It's a tiny bit more flexible wp native gallery. It finally allows non-linked images and images linking to external URLs and linked object opening in a new page. 
     13It's a tiny bit more flexible than wp native gallery. It finally allows non-linked images and images linking to external URLs. It also allows linked images/pages opening in a new page. 
    1414 
    1515== Installation == 
    1616 
    17 1. From Plugins->Installed of your wordpress administration, select "Add new", search for "gallery just better" into the search text-box then click on 'Install' (on the right) when prompted with this plugin 
     171. From Plugins of your wordpress administration, select "Add new", search for "gallery just better" into the search text-box then click on 'Install Now' (below the plugin name) when prompted OR download this plugin from [wordpress repository](http://wordpress.org/extend/plugins/gallery-just-better/) or from [Stef's blog](http://www.stefaniamarchisio.com/wp-content/uploads/2011/04/gallery-just-better-0.2.zip), unzip it (a directory with 2 files will be extracted) and upload it to the '/wp-content/plugins/' directory of your wordpress 
    1818 
    19                                     OR 
     193. Activate the plugin from the Plugins menu in your WordPress administration 
    2020 
    21 2. Download this plugin from [wordpress repository](http://wordpress.org/extend/plugins/gallery-just-better/) or from [Stef's blog](http://www.stefaniamarchisio.com/wp-content/uploads/2011/01/gallery-just-better-0.1.zip), unzip it (a directory with 2 files will be extracted) and upload it to the '/wp-content/plugins/' directory of your wordpress 
    22  
    23 3. Activate the plugin through the Plugins->Installed menu in your WordPress administration 
    24  
    25 4. Enter it (see Usage in Other Notes) 
     214. Use it! (see Usage in Other Notes) 
    2622 
    2723== Frequently Asked Questions == 
    2824 
    29 = Why the heck would I need/want it? 
     25= Why would I need/want it? 
    3026 
    31 = it can be either a replacement for wp native gallery if you need the added features described above or a simple no frills/no nonsenses gallery. More, much more to come. 
     27= it can either be a replacement to wp native gallery if you need the added features described above or a simple no frills/no nonsenses gallery. More, much more to come. 
    3228 
    3329== Screenshots == 
     
    3733== Changelog == 
    3834 
    39 = 0.1 = 
     35= 0.2 = 
    4036 
    41 * First release. Based on wp 3.0.4 native gallery 
    42 == Upgrade Notice == 
     37* Second release. Based on wp 3.1 native wp gallery 
    4338 
    4439= 0.1 = 
    4540 
    46 * First release. Based on wp 3.0.4 native gallery 
     41* First release. Based on wp 3.0.4 native wp gallery 
     42 
     43== Upgrade Notice == 
     44 
     45= 0.2 = 
     46 
     47* Second release. Code changed according to amendments made to 3.1 native wp gallery 
     48^ Adjustments to readme.txt file 
     49 
     50= 0.1 = 
     51 
     52* First release. Based on wp 3.0.4 native wp gallery 
     53 
     54== Other Notes == 
    4755 
    4856== Usage == 
    4957 
    50 As a shortcode: 
     58As it is a shortcode: 
    5159 
    52 * Your admin wp page->Posts/Pages->Add New or Edit, select HTML in the entry form; 
    53 * enter [galleryjb];  
    54 No mandatory attributes. It shows the attached images if attachments are present in the current post or in postid if defined. 
     60^ From the admin wp page->Posts/Pages->Add New or Edit, select HTML in the entry form and enter [galleryjb] 
     61^ Attach one or more images to the post or define a PostID attribute which has attachements i.e. [galleryjb postid=123] 
     62^ There are no mandatory attributes: it will show the attached images as a gallery if attachments are present in the current post or in postid, if postid as attribute is defined. 
     63^ Optional attributes are all those you can see in wp 3.0.4 or 3.1 of native gallery plus: 
     64^^ link: besides "file" (= images are linked to imagefile) and the default null string (= images are linked to the attachment's permalink) already present in wp gallery, there is now "null" (images are not clickable/linkable) and "url" (images are linked to external URLs defined in Description). 
     65Please note that if you choose link="url", the Description textbox in Media library needs to contain a url (http(s)..etc) and not a textual description. On the other hand, Description is not used by wp native [ gallery ] in any case. 
     66^^ target: boolean. if true linked objects open in a new/the same window, if false (default) in the same window 
     67^^ author: true (default) or false whether you allow this plugin's author footer to be displayed or not (please, say yes). 
    5568 
    56 Optional attributes are all those of wp 3.0.4 native gallery plus: 
     69== Examples == 
    5770 
    58 * link: besides "file" (links images to imagefile), there is now "null" (images are not clickable/linkable) and "url" (links to external url defined in Description). Default is '' (null string) (images link to the attachment's permalink) 
    59 * target: boolean. if true linked objects open in a new/the same window, if false (default) in the same window 
    60 * author: true (default) or false whether you allow this plugin's author footer to be displayed or not (please, say yes). 
    61  
    62 Examples:  
    63 [galleryjb link="url" target="true"] //images link to external url defined in Description textbox (in Media library). These pages open in a new page. 
    64 [galleryjb link="null"] // images are not clickable 
    65 [galleryjb target="true"] // images link to the attachment's permalink and open up in a new page. 
    66  
    67 Note: Please note that if you choose link="url", the Description textbox in Media library needs to contain a url (http(s)..etc) and not a description. On the other hand, Description would not be used anyhow by [gallery] plugin. 
    68  
    69 == The Future == 
    70 * Bespoken table to store images so that these are independent from posts (no need to be attached to posts). 
    71  
    72 == Interaction == 
    73 * Would you like to see a new feature in this plugin? Please write me here: mywizardwebs@gmail.com; 
    74 * Would you like to see a broken/orphan plugin working again? Write me anyhow, I might (hey, MIGHT not will/shall) find the time to give it a look. 
     71[galleryjb link="null"] ==> Images are not clickable 
     72[galleryjb target="true"] ==> Images link to the attachment's permalink and open up in a new page 
     73[galleryjb link="url"target="true"] ==> Images link to external URL defined in the Description textbox (in Media library). These URLs will open up in a new page. 
     74[galleryjb link="url"] ==> Images link to external urls defined in the Description textbox (in Media library). They will open up in the same page (as default) 
Note: See TracChangeset for help on using the changeset viewer.