Plugin Directory

Changeset 730333


Ignore:
Timestamp:
06/23/2013 12:14:07 PM (13 years ago)
Author:
rolice
Message:

v1.3

  • Fix of inner join with left one in join method. This fixes the bug with disappeared custom posts.
  • New settings field for custom post types in plugin admin. For now it tells WordPress to make Sorting column sortable, since the plugin is attached to any post type.
  • General code refactoring.
Location:
post-sorter/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • post-sorter/trunk/css/style.css

    r730151 r730333  
    2424.post_sorter_form .controller { margin-top: 24px; clear: both; }
    2525
    26 .post_sorter_form input[type="checkbox"], .post_sorter_form input[type="radio"]
     26.post_sorter_form input[type="checkbox"],
     27.post_sorter_form input[type="radio"]
    2728{
    2829    margin-right: 16px;
    2930}
    3031
    31 .post_sorter_form textarea {}
    32 .post_sorter_form textarea[readonly="readonly"] { background-color: #eee; }
     32.post_sorter_form input[type="text"],
     33.post_sorter_form textarea
     34{
     35    width: 480px;
     36}
     37
     38.post_sorter_form input[type="text"][readonly="readonly"],
     39.post_sorter_form textarea[readonly="readonly"]
     40{ background-color: #eee; }
  • post-sorter/trunk/page/general.php

    r730151 r730333  
    5454                        <input name="post_sorter_arrows_enabled" id="post_sorter_arrows_enabled" type="checkbox" <?php checked( 1, get_option( 'post_sorter_arrows_enabled' ) )?> />
    5555                        <span class="hint"><?php _e( 'Allows quick sorting with arrow buttons in the sorting column', 'post_sorter' ) ?></span>
     56                    </td>
     57                </tr>
     58                <tr valign="top">
     59                    <th scope="row"><label for="post_sorter_custom_types"><?php _e( 'Custom post types', 'post_sorter' ) ?></label>:</th>
     60                    <td>
     61                        <input name="post_sorter_custom_types" id="post_sorter_custom_types" type="text" value="<?php echo get_option( 'post_sorter_custom_types' ) ?>" /><br />
     62                        <span class="hint"><?php _e( 'Enables sorting on the Sorting column for those types.<br />However, the sort column is shown on every post type. Example: <b>custom1, custom2</b>', 'post_sorter' ) ?></span>
    5663                    </td>
    5764                </tr>
  • post-sorter/trunk/post_sorter.php

    r730151 r730333  
    44  Plugin URI: http://intellisys.org/
    55  Description: Plugin for easy sorting of posts and pages by numeric value, both ascending and descending.
    6   Version: 1.2
     6  Version: 1.3
    77  Author: Lyubomir Gardev
    88  Author URI: http://rolice.intellisys.info/
     
    3636        add_filter( 'manage_edit-page_sortable_columns', array( $this, 'add_sorter_sort' ) );
    3737
     38        $custom_types = get_option( 'post_sorter_custom_types' );
     39        $custom_types = explode( ',', sanitize_text_field( trim( str_replace( ' ', '', $custom_types ) ) ) );
     40
     41        if( $custom_types && is_array( $custom_types ) )
     42            foreach( $custom_types as $t )
     43                add_filter( 'manage_edit-' . $t . '_sortable_columns', array( $this, 'add_sorter_sort' ) );
    3844
    3945        //add_filter( 'request', array( $this, 'order_by_at_request' ) );
     
    210216        }
    211217           
    212         $sql .= "INNER JOIN {$wpdb->postmeta} AS post_sorter ON ({$wpdb->posts}.ID = post_sorter.post_id AND post_sorter.meta_key = '" . POST_SORTER_META_KEY . "')";
     218        $sql .= "LEFT JOIN {$wpdb->postmeta} AS post_sorter ON ({$wpdb->posts}.ID = post_sorter.post_id AND post_sorter.meta_key = '" . POST_SORTER_META_KEY . "')";
    213219
    214220        return $sql;
     
    285291    }
    286292
     293
     294    /**
     295     * Saves settings for the plugin
     296     */
     297    public function save_settings() {
     298        if ( !current_user_can( 'manage_options' ) )
     299            return;
     300
     301        if ( empty( $_POST ) )
     302            return;
     303
     304        update_option( 'post_sorter_enabled', isset( $_POST['post_sorter_enabled'] ) );
     305        update_option( 'post_sorter_direction', isset( $_POST['post_sorter_direction'] ) && mb_strtoupper( $_POST['post_sorter_direction'] ) == 'DESC' ? 'DESC' : ''    );
     306
     307        $custom_types = isset($_POST['post_sorter_custom_types']) ? $_POST['post_sorter_custom_types'] : ''; // Get custom post types from $_POST or make it empty if no data is received
     308        $custom_types = sanitize_text_field( trim( str_replace( ' ', '', $custom_types ) ) ); // cleanup, trimming and space removal
     309
     310        $custom_types = explode( ',', $custom_types ); // To be sure it explodable
     311
     312        update_option( 'post_sorter_arrows_enabled', isset( $_POST['post_sorter_arrows_enabled'] ) );
     313        update_option( 'post_sorter_custom_types', implode( ', ', $custom_types ) );
     314       
     315        update_option( 'post_sorter_custom_enabled', isset( $_POST['post_sorter_custom_enabled'] ) );
     316        $own_risk = get_option( 'post_sorter_custom_enabled' );
     317       
     318        update_option( 'post_sorter_join_clause', $own_risk ? $this->_sanitize_sql( $_POST['post_sorter_join_clause'] ) : '' );
     319        update_option( 'post_sorter_order_by_clause', $own_risk ? $this->_sanitize_sql( $_POST['post_sorter_order_by_clause'] ) : '' );
     320    }
     321
    287322    /**
    288323     * Save a position for a given post. Data for post ID and position is retrieved from $_POST
     
    337372       
    338373        return $sql;
    339     }
    340    
    341     /**
    342      * Saves settings for the plugin
    343      */
    344     public function save_settings() {
    345         if ( !current_user_can( 'manage_options' ) )
    346             return;
    347 
    348         if ( empty( $_POST ) )
    349             return;
    350 
    351         update_option( 'post_sorter_enabled', isset( $_POST['post_sorter_enabled'] ) );
    352         update_option(
    353             'post_sorter_direction', isset( $_POST['post_sorter_direction'] ) && mb_strtoupper( $_POST['post_sorter_direction'] ) == 'DESC' ? 'DESC' : ''
    354         );
    355 
    356         update_option( 'post_sorter_arrows_enabled', isset( $_POST['post_sorter_arrows_enabled'] ) );
    357        
    358         update_option( 'post_sorter_custom_enabled', isset( $_POST['post_sorter_custom_enabled'] ) );
    359         $own_risk = get_option( 'post_sorter_custom_enabled' );
    360        
    361         update_option( 'post_sorter_join_clause', $own_risk ? $this->_sanitize_sql( $_POST['post_sorter_join_clause'] ) : '' );
    362         update_option( 'post_sorter_order_by_clause', $own_risk ? $this->_sanitize_sql( $_POST['post_sorter_order_by_clause'] ) : '' );
    363374    }
    364375
  • post-sorter/trunk/readme.txt

    r730173 r730333  
    55Requires at least: 3.2
    66Tested up to: 3.5
    7 Stable tag: 1.2
     7Stable tag: 1.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6767== Changelog ==
    6868
     69= 1.3 =
     70* Fixed a bug where custom post types disappear from the list. This problem was due to INNER join, but not OUTER.
     71* New option for custom post types in the settings. With it post sorter will know which custom post types it has to handle (it handles them already, but some functionality needs explicit telling).
     72
    6973= 1.2 =
    7074* Fixed a ordering bug where the postmeta.meta_value is sorted as longtext, but not as unsigned int.
  • post-sorter/trunk/uninstall.php

    r730151 r730333  
    88
    99delete_option( 'post_sorter_arrows_enabled' );
     10delete_option( 'post_sorter_custom_types' );
    1011
    1112delete_option( 'post_sorter_custom_enabled' );
Note: See TracChangeset for help on using the changeset viewer.