WordPress.org

Plugin Directory

Changeset 423654


Ignore:
Timestamp:
08/15/11 07:55:21 (3 years ago)
Author:
Zeo
Message:
  • version bump
  • Added WordPress default inline styles removal functionality
  • Whitespace fixes
Location:
gallery-columns/trunk
Files:
2 edited

Legend:

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

    r231537 r423654  
    44Plugin URI: http://wordpress.org/extend/plugins/gallery-columns/ 
    55Description: By WordPress default, the number of gallery columns is 3. This plugin force and overwrite the current number of gallery columns within any post that uses <code>&#91;gallery&#93;</code> shortcode without altering or tampering its original options. 
    6 Version: 1.0.1 
     6Version: 1.0.2 
    77Author: Safirul Alredha 
    88Author URI: http://zeo.my 
    9 License: GPL v2 
     9License: GPLv2 
    1010*/ 
    1111 
    12 register_activation_hook(__FILE__, 'gallery_columns_install'); 
     12register_activation_hook( __FILE__, 'gallery_columns_install' ); 
    1313    function gallery_columns_install() { 
    14         $options = get_option('gallery_columns'); 
    15          
    16         if ( !is_array($options) ) { 
     14        $options = get_option( 'gallery_columns' ); 
     15 
     16        if ( ! is_array( $options ) ) { 
    1717            $defaults = array( 
    18                 'columns' => '3',  
    19                 'exclude' => '' 
     18                'columns' => '3', 
     19                'exclude' => '', 
     20                'default_gallery_style' => 1, 
    2021            ); 
    2122 
    2223            foreach ( $defaults as $name => $value ) 
    23                 if ( !isset($options[$name]) ) 
     24                if ( ! isset( $options[$name] ) ) 
    2425                    $options[$name] = $value; 
    2526 
    26             add_option('gallery_columns', $options); 
     27            add_option( 'gallery_columns', $options ); 
    2728        } 
    2829    } 
    2930 
    30 add_filter('the_content', 'gallery_columns'); 
    31     function gallery_columns($content) { 
     31add_filter( 'the_content', 'gallery_columns' ); 
     32    function gallery_columns( $content ) { 
    3233        global $post; 
    3334 
    34         $options = get_option('gallery_columns'); 
     35        $options = get_option( 'gallery_columns' ); 
    3536        $columns = $options['columns']; 
    3637        $exclude = $options['exclude']; 
     
    3940            return $content; 
    4041 
    41         if ( !empty($exclude) ) { 
    42             $exclude = is_array($exclude) ? $exclude : preg_split('/[\s]*[,][\s]*/', $exclude); 
    43              
    44             if ( in_array($post->ID, $exclude) )  
     42        if ( ! empty( $exclude ) ) { 
     43            $exclude = is_array( $exclude ) ? $exclude : preg_split( '/[\s]*[,][\s]*/', $exclude ); 
     44 
     45            if ( in_array( $post->ID, $exclude ) ) 
    4546                return $content; 
    4647        } 
    47              
     48 
    4849        $pattern = array( 
    4950            '#(\[gallery(.*?)columns="([0-9])"(.*?)\])#ie', 
     
    5152            '#(\[gallery(.*?)\])#ie' 
    5253        ); 
    53         $replace = 'stripslashes(strstr("\1", "columns=\"$columns\"") ? "\1" : "[gallery \2 \4 columns=\"$columns\"]")'; 
     54        $replace = 'stripslashes( strstr( "\1", "columns=\"$columns\"" ) ? "\1" : "[gallery \2 \4 columns=\"$columns\"]" )'; 
    5455 
    55         return preg_replace($pattern, $replace, $content);       
     56        return preg_replace( $pattern, $replace, $content ); 
    5657    } 
    57      
    58 add_action('admin_menu', 'gallery_columns_admin_menu'); 
     58 
     59add_action( 'admin_menu', 'gallery_columns_admin_menu' ); 
    5960    function gallery_columns_admin_menu() { 
    60         $hook = add_options_page('Gallery Columns', 'Gallery Columns', 'manage_options', 'gallery-columns', 'gallery_columns_options_page'); 
    61         add_action('load-' . $hook, 'gallery_columns_options_save'); 
     61        $hook = add_options_page( 'Gallery Columns', 'Gallery Columns', 'manage_options', 'gallery-columns', 'gallery_columns_options_page' ); 
     62        add_action( 'load-' . $hook, 'gallery_columns_options_save' ); 
    6263    } 
    6364 
    6465    function gallery_columns_options_save() { 
    65         if ( !isset($_POST['gallery-columns']) )   
     66        if ( ! isset( $_POST['gallery-columns'] ) ) 
    6667            return; 
    67              
    68         check_admin_referer('gallery-columns-options'); 
    6968 
    70         $options = $newoptions = get_option('gallery_columns'); 
     69        check_admin_referer( 'gallery-columns-options' ); 
     70 
     71        $options = $newoptions = get_option( 'gallery_columns' ); 
    7172        $newoptions['columns'] = (int) $_POST['columns']; 
    72         $newoptions['exclude'] = strip_tags(stripslashes($_POST['exclude'])); 
     73        $newoptions['exclude'] = strip_tags( stripslashes( $_POST['exclude'] ) ); 
     74        $newoptions['default_gallery_style'] = $_POST['default_gallery_style']; 
    7375 
    7476        if ( $options != $newoptions ) { 
    7577            $options = $newoptions; 
    76             update_option('gallery_columns', $options); 
    77             wp_redirect( admin_url('options-general.php?page=gallery-columns&updated=true') ); 
     78            update_option( 'gallery_columns', $options ); 
     79            wp_redirect( admin_url( 'options-general.php?page=gallery-columns&updated=true' ) ); 
    7880            exit(); 
    79         }  
     81        } 
    8082    } 
    8183 
    8284    function gallery_columns_options_page() { 
    83         $options = get_option('gallery_columns'); 
    84     ?>   
     85        $options = get_option( 'gallery_columns' ); 
     86    ?> 
    8587    <div class="wrap"> 
    8688        <?php screen_icon(); ?> 
    87         <h2>Gallery Columns Settings</h2>    
    88             <form action="<?php echo admin_url('options-general.php?page=gallery-columns'); ?>" method="post"> 
    89             <?php wp_nonce_field('gallery-columns-options'); ?> 
     89        <h2>Gallery Columns Settings</h2> 
     90            <form action="<?php echo admin_url( 'options-general.php?page=gallery-columns' ); ?>" method="post"> 
     91            <?php wp_nonce_field( 'gallery-columns-options' ); ?> 
    9092            <input type="hidden" name="gallery-columns" value="1" /> 
    9193            <table class="form-table"> 
     
    100102                </tr> 
    101103                <tr valign="top"> 
    102                     <th scope="row"><label for="exclude">Exclude</label></th>            
     104                    <th scope="row"><label for="exclude">Exclude</label></th> 
    103105                    <td><input type="text" name="exclude" id="exclude" value="<?php echo $options['exclude']; ?>" class="regular-text" /> 
    104106                    <span class="description">Enter the Post IDs (separated by commas). Configuring this is optional. By default, it should be blank.</span> 
    105                     </td>            
     107                    </td> 
     108                </tr> 
     109                <tr valign="top"> 
     110                    <th scope="row"><label for="default_gallery_style">Gallery styles</label></th> 
     111                    <td><input type="checkbox" name="default_gallery_style" id="default_gallery_style" value="1" <?php checked( '1', $options['default_gallery_style'] ); ?> /> 
     112                    Use WordPress default gallery inline styles. 
     113                    </td> 
    106114                </tr> 
    107115            </table> 
    108              
    109             <p class="submit"><input type="submit" class="button-primary" value="Save Changes" /></p> 
    110             </form>      
    111     </div> <!-- END .wrap --> 
    112     <?php }  
    113 ?> 
     116 
     117            <?php submit_button(); ?> 
     118            </form> 
     119    </div><!-- END .wrap --> 
     120    <?php } 
     121 
     122add_action( 'init', 'gallery_columns_use_default_gallery_style' ); 
     123    function gallery_columns_use_default_gallery_style() { 
     124        $options = get_option( 'gallery_columns' ); 
     125        if ( ! $options['default_gallery_style'] ) 
     126            add_filter( 'use_default_gallery_style', '__return_false' ); 
     127    } 
  • gallery-columns/trunk/readme.txt

    r231534 r423654  
    11=== Gallery Columns === 
    2 Contributors: Safirul Alredha 
     2Contributors: zeo 
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2E2KFZKA8RAMN 
    44Tags: gallery, columns, post, images 
    5 Requires at least: 2.9 
    6 Tested up to: 3.0-beta1 
    7 Stable tag: 1.0.1 
     5Requires at least: 3.1 
     6Tested up to: 3.2.1 
     7Stable tag: 1.0.2 
    88 
    99Force and overwrite the current number of [gallery] columns without altering or tampering its original options. 
     
    1111== Description == 
    1212 
    13 If you use [`[gallery]`][1] shortcode without setting the columns value, the default is set to 3. Some WordPress theme can either fit 3 or more column per row or less.  
     13If you use [`[gallery]`](http://codex.wordpress.org/Gallery_Shortcode) shortcode without setting the columns value, the default is set to 3. Some WordPress theme can either fit 3 or more column per row or less. 
    1414 
    15 Imagine if you use `[gallery]` shortcode with default options regularly within your posts, you switch to a new theme and the theme could only fit gallery with 2 columns per row.  
     15Imagine if you use `[gallery]` shortcode with default options regularly within your posts, you switch to a new theme and the theme could only fit gallery with 2 columns per row. 
    1616 
    17 To overcome this issue, the plugin will force and overwrite the current number of gallery columns within any post that uses `[gallery]` shortcode with a new number of columns of your choice without altering or tampering its original options. It also includes feature to exclude post from being overwritten by this plugin. 
     17To overcome this issue, the plugin will force and overwrite the current number of gallery columns within any post that uses `[gallery]` shortcode with a new number of columns of your choice without altering or tampering its original options. It also includes feature to exclude post from being overwritten by this plugin and removing the default inline styles printed when the `[gallery]` shortcode is used. 
    1818 
    19 [1]: http://codex.wordpress.org/Gallery_Shortcode 
     19For more information, check out [zeo.my](http://zeo.my). 
    2020 
    2121== Installation == 
    2222 
    23 * Upload the Gallery Columns plugin to your blog and Activate it.  
    24 * Then go to Settings > Gallery Columns and set the Columns or Exclude options. Exclude is Optional. 
     231. Upload the `gallery-columns` directory to the `/wp-content/plugins/` directory 
     242. Activate the plugin through the 'Plugins' screen in your WordPress admin area 
     253. Then go to Settings > Gallery Columns and set the Columns, Exclude or Gallery style options. Exclude and Gallery style is Optional 
    2526 
    2627You're done! 
     
    3031== Changelog == 
    3132 
     33= 1.0.2 = 
     34* Added WordPress default inline styles removal functionality 
     35* Whitespace fixes 
     36 
    3237= 1.0.1 = 
    33 * Fixed readme.txt. 
     38* Fixed readme.txt 
    3439 
    3540= 1.0 = 
Note: See TracChangeset for help on using the changeset viewer.