Plugin Directory

Changeset 1364414


Ignore:
Timestamp:
03/05/2016 01:40:09 AM (10 years ago)
Author:
weiluri
Message:

update trunk with 1.4 ver

Location:
wp-order-by/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-order-by/trunk/admin-options.php

    r1314584 r1364414  
    6767   
    6868    private static function draw_posts_select_box($type = '', $select_default_text='', $post_ids) {
    69        
     69        //var_dump($post_ids);
    7070        $post_type = WpobPlugin::get_admin_screen_current_post_type();
    7171        $posts = WpobPlugin::get_all_posts_of_current_post_type();
     
    7676            foreach($posts as $p) { //iterate posts
    7777                $selected = '';
     78               
    7879                foreach($post_ids as $pid) { //iterate selected posts
    7980                    if($p->ID == $pid && !empty( $post_ids[0] ) ) {
     
    111112    public function process_form_vals() {
    112113        if(!empty($_POST['_wpnonce']) && !empty($_POST['_wp_http_referer']) ) {
     114            $cf_arr = array();
     115            $ptype = !empty($_POST["post_type"]) ? $_POST["post_type"] : '';
     116            $cf_arr[] = $_POST["wpob-options-".$ptype];
    113117            if(!empty($_POST["wpob-cf-type"])) {
    114                 $cf_arr = array();
    115                 $ptype = !empty($_POST["post_type"]) ? $_POST["post_type"] : '';
    116                 $cf_arr[] = $_POST["wpob-options-".$ptype];
    117118                $cf_arr[] = $_POST["wpob-cf-type"];
    118119                $cf_arr[] = !empty($_POST["wpob_other_posts"]);
    119                 $cf_arr[] = $_POST["wpob_cf_order"];
    120                 $_POST["wpob-options-".$ptype] = $cf_arr;
    121             }
     120                //$cf_arr[] = $_POST["wpob_cf_order"];
     121                //$_POST["wpob-options-".$ptype] = $cf_arr;
     122            }
     123            $cf_arr[] = $_POST["wpob_cf_order"];
     124            //var_dump($cf_arr);
     125            $_POST["wpob-options-".$ptype] = $cf_arr;
    122126        }
    123127    }
     
    179183   
    180184    public function merge_excluded($exclude) {
    181        
     185
    182186        $pt = !empty( $_POST['post_type'] ) ? $_POST['post_type'] : '';
    183        
    184187        $db_exclude = get_option('wpob-exclude-posts');
     188        //var_dump($exclude);
     189       
    185190        if( !is_array( $db_exclude ) ) $db_exclude = array();
     191        $tmp_exclude = array();
    186192        foreach ( $db_exclude as $key => $val ) {
    187193       
    188194            $tmp_post = get_post( $val );   
    189195            $tmp_pt = $tmp_post->post_type;
     196           
    190197            if($tmp_pt == $pt) {
    191                 unset($db_exclude[$key]);
    192                 $db_exclude = array_values($db_exclude);
    193             }
    194            
    195         }
    196        
    197         if( !empty( $exclude[0] ) ) {
    198             $db_exclude = array_unique( array_merge( $exclude, $db_exclude ) );
    199         }
     198                $tmp_exclude[] = $db_exclude[$key];
     199            //var_dump( key ($db_exclude));
     200                //unset($db_exclude[$key]);
     201                //$db_exclude = array_values($db_exclude);
     202            }
     203           
     204        }
     205       
     206        $new_db_exclude = array_diff( $db_exclude, $tmp_exclude );
     207        if( empty( $exclude[0] ) ) {
     208            $exclude = array();
     209        }
     210        $db_exclude = array_unique( array_merge( $exclude, $new_db_exclude ) );
     211       
    200212       
    201213        return $db_exclude;
     
    229241        if(empty($exclude)) $exclude = array('');
    230242        if($exclude != get_option( 'wpob-exclude-posts' )) {
    231             $is_update_general = update_option( 'wpob-exclude-posts', $exclude );
     243            if( empty( $exclude[0] ) ) {
     244                $exclude_empty = array( $exclude[0] );
     245                $is_update_general = update_option( 'wpob-exclude-posts', $exclude_empty );
     246            } else {
     247                $is_update_general = update_option( 'wpob-exclude-posts', $exclude );
     248            }
    232249            if(!$is_update_general) $updated = 'false';
    233250        }
     
    247264     
    248265        $options = get_option('wpob-options-'.$args['post_type']);
    249         if($options=='' || !$options) $options = 'datedesc';
     266        if($options=='' || !$options) $options = 'date';
    250267        if(!empty($_POST['wpob-options-']) ) $options = $_POST['wpob-options-']; //global settings for all post types
    251268        $args['options'] = $options;
     
    361378        $option = get_option('wpob-options-'.$post_type);
    362379       
     380       
    363381        if($option) {   
    364382           
     
    371389                }
    372390            }
    373            
     391            //var_dump($post_type);
    374392            switch ($opt) {
    375                 case "abcasc":
     393                case "title":
    376394                    $query->set( 'orderby', 'title' );
    377                         $query->set( 'order', 'ASC' );
    378                     break;
    379                 case "abcdesc":
     395                    break;
     396                /*case "abcdesc":
    380397                    $query->set( 'orderby', 'title' );
    381398                        $query->set( 'order', 'DESC' );
    382                     break;
     399                    break;*/
    383400                case "name":
    384401                    $query->set( 'orderby', 'name' );
    385402                    break;
    386                  case "datedesc":
     403                 case "date":
    387404                    $query->set( 'orderby', 'date' );
    388                         $query->set( 'order', 'DESC' );
    389405                    break;
    390406                case "modified":
    391407                    $query->set( 'orderby', 'modified' );
    392                         $query->set( 'order', 'DESC' );
    393408                    break;
    394409                case "author":
    395410                    $query->set( 'orderby', 'author' );
    396                         $query->set( 'order', 'ASC' );
    397411                    break;
    398412                case "parent":
     
    414428                default:
    415429                    $query->set('orderby', $m_val);     
    416                     if(is_array($option)) $query->set( 'order', $option[3] );
     430                    //if(is_array($option)) $query->set( 'order', $option[3] );
    417431                    $query->set('meta_key', $opt);
    418432                   
     
    423437                           
    424438            }
     439            $order = end($option);
     440            $query->set( 'order', $order );
    425441           
    426442        }
  • wp-order-by/trunk/js/wpob.js

    r1293180 r1364414  
    2121        $('input[name="wpob-cf-type"]').prop('disabled',true);
    2222        $('input[name="wpob_other_posts"]').prop('disabled',true);
    23         $('input[name="wpob_cf_order"]').prop('disabled',true);
     23        //$('input[name="wpob_cf_order"]').prop('disabled',true);
    2424    } else {   
    2525        if($('#order_custom_fields option:selected').val() == "") {
     
    2727            $('input[name="wpob-cf-type"]').prop('disabled',true);
    2828            $('input[name="wpob_other_posts"]').prop('disabled',true);
    29             $('input[name="wpob_cf_order"]').prop('disabled',true);
     29            //$('input[name="wpob_cf_order"]').prop('disabled',true);
    3030        }
    3131    }
     
    3333    //init custom type radio buttons
    3434    if($('#order_custom_fields').attr('value') == '') {
    35         $('#cf_desc').attr('checked',true)
     35        //$('#cf_desc').attr('checked',true)
    3636    }
    3737   
     
    4545        $('input[name="wpob_other_posts"]').prop('checked',false);
    4646        $('input[name="wpob_other_posts"]').prop('disabled',true);
    47         $('input[name="wpob_cf_order"]').prop('disabled',true);
     47        //$('input[name="wpob_cf_order"]').prop('disabled',true);
    4848       
    4949    })
     
    5454        $('input[name="wpob-cf-type"]').prop('disabled',false);
    5555        $('input[name="wpob_other_posts"]').prop('disabled',false);
    56         $('input[name="wpob_cf_order"]').prop('disabled',false);
     56        //$('input[name="wpob_cf_order"]').prop('disabled',false);
    5757    })
    5858   
  • wp-order-by/trunk/readme.txt

    r1345984 r1364414  
    55Requires at least: 4.1
    66Tested up to: 4.4
    7 Stable tag: 1.3
     7Stable tag: 1.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1212
    1313== Description ==
    14 Simple and easy way to order your posts, pages or any other custom post-type in a various options, with the ability to define a different logic for each content type.
    15 This plugin suits for large amount of posts/pages ordering when it is not convenient to manually order them by drag and drop.
     14Simple and easy way to order your posts, pages or any other custom post-type in a various options, with the ability to define a different order option for each content type.
    1615
    1716A new menu will appear on the admin side-menu under each content type that is defined on your site (posts, pages etc.) and it will also be added automatically to future custom post types you will add in the future.
     
    2524**Ordering Options**
    2625
    27 *   Date Descending (WordPress default)
    28 *   Last Modified Date (Descending)
    29 *   Title Ascending
    30 *   Title Descending
    31 *   Author (Alphabet Ascending order)
     26*   Date
     27*   Last Modified Date
     28*   Title
     29*   Author
    3230*   Post,Page or post-type Id
    33 *   Post/Page Parent Id (Descending)
    34 *   Menu Order (Descending)
     31*   Post/Page Parent Id
     32*   Menu Order
    3533*   Randomly
    36 *   Number of Comments (Descending, from many to few)
     34*   Number of Comments
    3735*   By Custom Field
    3836
     
    4139*   Exclude ordering for a specific page/s on your site
    4240
    43 I'll appreciate if you rate me on the plugin page.
     41I'll appreciate if you rate me or write a review on the plugin page.
    4442I'm doing my best to maintain and improve this plugin. if you feel like donating a small amount, of your choice, through the donation link on the plugin page, I will be very glad :)
    4543
     
    5452= What if I want to retrieve settings to default? =
    5553
    56 You should update your settings to the first option - *Date Descending (from new to old)* which is WordPress default ordering.
     54You should update your settings to the first option - *Date* and check the *Descending* order radio button, which is WordPress default ordering.
    5755You can make the update for a specific content type (e.g. posts) or from the main settings page under *settings -> WP Order By Settings*  if you want to make the change for all page/post/post-types on your site.
    5856
     
    6664
    6765== Changelog ==
     66
     67= 1.4 =
     68Order direction option added to all order-by options.
     69Bug fix on the exclude pages feature.
    6870
    6971= 1.3 =
  • wp-order-by/trunk/views/form_elements.php

    r1317715 r1364414  
     1<?php //if( !is_array( $args['options'] ) ) $args['options'] = array( $args['options'] ); var_dump($args['options']); ?>
    12<div class="wpob_option">
    23   
    3     <input id="order_date_desc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="datedesc" <?php if($args['options']=='datedesc') echo ' checked'; ?> />
    4     <label for="order_date_desc">Date Descending (from new to old)</label>
     4    <input id="order_date_desc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="date" <?php if($args['options'][0]=='date') echo ' checked'; ?> />
     5    <label for="order_date_desc">Date Created</label>
    56</div>
    67<div class="wpob_option">
    78   
    8     <input id="order_modified" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="modified" <?php if($args['options']=='modified') echo ' checked'; ?> />
     9    <input id="order_modified" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="modified" <?php if($args['options'][0]=='modified') echo ' checked'; ?> />
    910    <label for="order_modified">Last Modified Date </label>
    1011</div>
    1112<div class="wpob_option">
    1213   
    13     <input id="order_abcasc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="abcasc" <?php if($args['options']=='abcasc') echo ' checked'; ?> />
    14     <label for="order_abcasc">Title Ascending</label>
     14    <input id="order_title" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="title" <?php if($args['options'][0]=='title') echo ' checked'; ?> />
     15    <label for="order_title">Title</label>
    1516</div>
     17
    1618<div class="wpob_option">
    1719   
    18     <input id="order_abcdesc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="abcdesc" <?php if($args['options']=='abcdesc') echo ' checked'; ?>  />
    19     <label for="order_abcdesc">Title Descending</label>
    20 </div>
    21 <div class="wpob_option">
    22    
    23     <input id="order_author" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="author" <?php if($args['options']=='author') echo ' checked'; ?>  />
     20    <input id="order_author" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="author" <?php if($args['options'][0]=='author') echo ' checked'; ?>  />
    2421    <label for="order_author">Author</label>
    2522</div>
    2623<div class="wpob_option">
    2724   
    28     <input id="order_post_id" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="ID" <?php if($args['options']=='ID') echo ' checked'; ?>  />
     25    <input id="order_post_id" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="ID" <?php if($args['options'][0]=='ID') echo ' checked'; ?>  />
    2926    <label for="order_post_id">Post/Page Id</label>
    3027</div>
    3128<div class="wpob_option">
    3229   
    33     <input id="order_parent" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="parent" <?php if($args['options']=='parent') echo ' checked'; ?>  />
    34     <label for="order_parent">Post/Page Parent Id (Highest first)</label>
     30    <input id="order_parent" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="parent" <?php if($args['options'][0]=='parent') echo ' checked'; ?>  />
     31    <label for="order_parent">Post/Page Parent Id</label>
    3532</div>
    3633<div class="wpob_option">
    3734   
    38     <input id="order_menu_order" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="menu_order" <?php if($args['options']=='menu_order') echo ' checked'; ?>  />
    39     <label for="order_menu_order">Menu Order - the order value in the Attributes box. usually on the buttom-right of the page/post-type. (Highest first)</label>
     35    <input id="order_menu_order" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="menu_order" <?php if($args['options'][0]=='menu_order') echo ' checked'; ?>  />
     36    <label for="order_menu_order">Menu Order - the order value in the Attributes box. usually on the buttom-right of the page/post-type.</label>
    4037</div>
    4138<div class="wpob_option">
    4239   
    43     <input id="order_rand" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="rand" <?php if($args['options']=='rand') echo ' checked'; ?>  />
     40    <input id="order_rand" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="rand" <?php if($args['options'][0]=='rand') echo ' checked'; ?>  />
    4441    <label for="order_rand">Random</label>
    4542</div>
    4643<div class="wpob_option">
    4744   
    48     <input id="order_comments" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="comment_count" <?php if($args['options']=='comment_count') echo ' checked'; ?>  />
    49     <label for="order_comments">Number of Comments (descending, from many to few)</label>
     45    <input id="order_comments" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="comment_count" <?php if($args['options'][0]=='comment_count') echo ' checked'; ?>  />
     46    <label for="order_comments">Number of Comments</label>
    5047</div>
    5148<div class="wpob_option">
     
    6764        ?>
    6865    </select>
    69    
    70     &nbsp;&nbsp;Ascending&nbsp;<input type="radio" value="ASC" name="wpob_cf_order" id="cf_asc" <?php if(is_array($args['options']) && !empty($args['options'][3]) && $args['options'][3]=='ASC') echo ' checked'; ?>>
    71     &nbsp;Descending&nbsp;<input type="radio" value="DESC" name="wpob_cf_order" id="cf_desc" <?php if(is_array($args['options']) && !empty($args['options'][3]) && $args['options'][3]=='DESC') echo ' checked'; ?> <?php if( empty($args['options'][3]) ) echo ' checked '; ?>>
    7266    <div class="custom_fields_type_container">
    7367        <div class="description">What type of values this custom field contains:</div>
     
    7872        <p class="warning">Warning: if your custom field contains both numeric and string values this order option may give an unpredictable results </p>
    7973    </div>
     74    <?php $order = end($args['options']); //var_dump($order); ?>
     75    <br>
     76    <h3>Order Direction:</h3>
     77    <input type="radio" value="ASC" name="wpob_cf_order" id="cf_asc" <?php if(is_array($args['options']) && !empty($order) && $order=='ASC') echo ' checked'; ?>><label for="cf_asc">&nbsp;Ascending&nbsp;&nbsp;</label>
     78    <input type="radio" value="DESC" name="wpob_cf_order" id="cf_desc" <?php if(is_array($args['options']) && !empty($order) && $order=='DESC') echo ' checked'; ?> <?php if( empty($order) ) echo ' checked '; ?>><label for="cf_desc">&nbsp;Descending</label>
     79
    8080   
    8181</div>
  • wp-order-by/trunk/wp-order-by.php

    r1314584 r1364414  
    44 * Plugin URI: https://wordpress.org/plugins/wp-order-by/
    55 * Description: A wordpress post, post types and pages ordering plugin
    6  * Version: 1.3
     6 * Version: 1.4
    77 * Author: Uri Weil
    88 * Text Domain: wp-order-by
Note: See TracChangeset for help on using the changeset viewer.