Changeset 423654
- Timestamp:
- 08/15/2011 07:55:21 AM (15 years ago)
- Location:
- gallery-columns/trunk
- Files:
-
- 2 edited
-
gallery-columns.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gallery-columns/trunk/gallery-columns.php
r231537 r423654 4 4 Plugin URI: http://wordpress.org/extend/plugins/gallery-columns/ 5 5 Description: 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>[gallery]</code> shortcode without altering or tampering its original options. 6 Version: 1.0. 16 Version: 1.0.2 7 7 Author: Safirul Alredha 8 8 Author URI: http://zeo.my 9 License: GPL v29 License: GPLv2 10 10 */ 11 11 12 register_activation_hook( __FILE__, 'gallery_columns_install');12 register_activation_hook( __FILE__, 'gallery_columns_install' ); 13 13 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 ) ) { 17 17 $defaults = array( 18 'columns' => '3', 19 'exclude' => '' 18 'columns' => '3', 19 'exclude' => '', 20 'default_gallery_style' => 1, 20 21 ); 21 22 22 23 foreach ( $defaults as $name => $value ) 23 if ( ! isset($options[$name]) )24 if ( ! isset( $options[$name] ) ) 24 25 $options[$name] = $value; 25 26 26 add_option( 'gallery_columns', $options);27 add_option( 'gallery_columns', $options ); 27 28 } 28 29 } 29 30 30 add_filter( 'the_content', 'gallery_columns');31 function gallery_columns( $content) {31 add_filter( 'the_content', 'gallery_columns' ); 32 function gallery_columns( $content ) { 32 33 global $post; 33 34 34 $options = get_option( 'gallery_columns');35 $options = get_option( 'gallery_columns' ); 35 36 $columns = $options['columns']; 36 37 $exclude = $options['exclude']; … … 39 40 return $content; 40 41 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 ) ) 45 46 return $content; 46 47 } 47 48 48 49 $pattern = array( 49 50 '#(\[gallery(.*?)columns="([0-9])"(.*?)\])#ie', … … 51 52 '#(\[gallery(.*?)\])#ie' 52 53 ); 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\"]" )'; 54 55 55 return preg_replace( $pattern, $replace, $content);56 return preg_replace( $pattern, $replace, $content ); 56 57 } 57 58 add_action( 'admin_menu', 'gallery_columns_admin_menu');58 59 add_action( 'admin_menu', 'gallery_columns_admin_menu' ); 59 60 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' ); 62 63 } 63 64 64 65 function gallery_columns_options_save() { 65 if ( ! isset($_POST['gallery-columns']) )66 if ( ! isset( $_POST['gallery-columns'] ) ) 66 67 return; 67 68 check_admin_referer('gallery-columns-options');69 68 70 $options = $newoptions = get_option('gallery_columns'); 69 check_admin_referer( 'gallery-columns-options' ); 70 71 $options = $newoptions = get_option( 'gallery_columns' ); 71 72 $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']; 73 75 74 76 if ( $options != $newoptions ) { 75 77 $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' ) ); 78 80 exit(); 79 } 81 } 80 82 } 81 83 82 84 function gallery_columns_options_page() { 83 $options = get_option( 'gallery_columns');84 ?> 85 $options = get_option( 'gallery_columns' ); 86 ?> 85 87 <div class="wrap"> 86 88 <?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' ); ?> 90 92 <input type="hidden" name="gallery-columns" value="1" /> 91 93 <table class="form-table"> … … 100 102 </tr> 101 103 <tr valign="top"> 102 <th scope="row"><label for="exclude">Exclude</label></th> 104 <th scope="row"><label for="exclude">Exclude</label></th> 103 105 <td><input type="text" name="exclude" id="exclude" value="<?php echo $options['exclude']; ?>" class="regular-text" /> 104 106 <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> 106 114 </tr> 107 115 </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 122 add_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 1 1 === Gallery Columns === 2 Contributors: Safirul Alredha2 Contributors: zeo 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2E2KFZKA8RAMN 4 4 Tags: gallery, columns, post, images 5 Requires at least: 2.96 Tested up to: 3. 0-beta17 Stable tag: 1.0. 15 Requires at least: 3.1 6 Tested up to: 3.2.1 7 Stable tag: 1.0.2 8 8 9 9 Force and overwrite the current number of [gallery] columns without altering or tampering its original options. … … 11 11 == Description == 12 12 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.13 If 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. 14 14 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. 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. 16 16 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 .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 and removing the default inline styles printed when the `[gallery]` shortcode is used. 18 18 19 [1]: http://codex.wordpress.org/Gallery_Shortcode 19 For more information, check out [zeo.my](http://zeo.my). 20 20 21 21 == Installation == 22 22 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. 23 1. Upload the `gallery-columns` directory to the `/wp-content/plugins/` directory 24 2. Activate the plugin through the 'Plugins' screen in your WordPress admin area 25 3. Then go to Settings > Gallery Columns and set the Columns, Exclude or Gallery style options. Exclude and Gallery style is Optional 25 26 26 27 You're done! … … 30 31 == Changelog == 31 32 33 = 1.0.2 = 34 * Added WordPress default inline styles removal functionality 35 * Whitespace fixes 36 32 37 = 1.0.1 = 33 * Fixed readme.txt .38 * Fixed readme.txt 34 39 35 40 = 1.0 =
Note: See TracChangeset
for help on using the changeset viewer.