WordPress.org

Plugin Directory

Changeset 615022


Ignore:
Timestamp:
10/20/12 19:30:06 (18 months ago)
Author:
jakemgold
Message:

Automatically deactivates under WordPress 3.5 or newer (as it was folded into core)

Location:
sort-query-by-post-in/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sort-query-by-post-in/trunk/readme.txt

    r364802 r615022  
    11=== Sort Query by Post In === 
    2 Contributors: jakemgold, thinkoomph 
    3 Donate link: http://www.get10up.com/plugins/sort-query-by-post-in-wordpress/ 
     2Contributors: jakemgold, thinkoomph, 10up 
     3Donate link: http://10up.com/plugins/sort-query-by-post-in-wordpress/ 
    44Tags: post query, query, wp query, developer, orderby, order 
    55Requires at least: 3.0 
    6 Tested up to: 3.1 
    7 Stable tag: 1.2.2 
     6Tested up to: 3.4.2 
     7Stable tag: 1.2.3 
    88 
    99A very simple plug-in that allows post queries to sort the results by the order specified in the "post__in" parameter. 
    1010 
    1111== Description == 
     12 
     13NOTE: This plug-in has been incorporated into WordPress core as of version 3.5. 
    1214 
    1315Sort Query by Post In is a very light weight (less than 10 lines of code) plug-in intended for developers executing custom post queries. You're welcome to include it in your theme and redistribute - just offer us some credit, please! 
     
    1618 
    1719And don't worry about the plug-in being deactivated - your post queries with the new `post__in` value used for `orderby` will simply gracefully fall back to the default date sorting. 
     20 
     21 
    1822 
    1923== Installation == 
     
    3236== Changelog == 
    3337 
     38= 1.2.3 = 
     39* Automatically deactivates under WordPress 3.5 or newer (as it was folded into core) 
     40 
    3441= 1.2.2 = 
    3542* Teeny code simplication, update support information 
     
    4350== Upgrade Notice == 
    4451 
     52= 1.2.3 = 
     53This plug-in has been folded into WordPress 3.5. If you are running 3.5 or newer, it will self-deactivate. 
     54 
    4555= 1.2.1 = 
    4656Do not upgrade if you're using a version of WordPress older than 3.0; support for pre-3.0 has been dropped. 
  • sort-query-by-post-in/trunk/sort_query_by_post_in.php

    r364802 r615022  
    22/** 
    33 Plugin Name: Sort Query by Post In 
    4  Plugin URI: http://www.get10up.com/plugins/sort-query-by-post-in-wordpress/ 
     4 Plugin URI: http://10up.com/plugins/sort-query-by-post-in-wordpress/ 
    55 Description: Allows post queries to sort the results by the order specified in the <em>post__in</em> parameter. Just set the <em>orderby</em> parameter to <em>post__in</em>!  
    6  Version: 1.2.2 
    7  Author: Jake Goldman (10up) 
    8  Author URI: http://www.get10up.com 
    9  
    10     Plugin: Copyright 2011 10up  (email : jake@get10up.com) 
    11  
    12     This program is free software; you can redistribute it and/or modify 
    13     it under the terms of the GNU General Public License as published by 
    14     the Free Software Foundation; either version 2 of the License, or 
    15     (at your option) any later version. 
    16  
    17     This program is distributed in the hope that it will be useful, 
    18     but WITHOUT ANY WARRANTY; without even the implied warranty of 
    19     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    20     GNU General Public License for more details. 
    21  
    22     You should have received a copy of the GNU General Public License 
    23     along with this program; if not, write to the Free Software 
    24     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
     6 Version: 1.2.3 
     7 Author: Jake Goldman, 10up, Oomph 
     8 Author URI: http://10up.com 
     9 License: GPLv2 or later 
    2510*/ 
    2611 
    27 add_filter( 'posts_orderby', 'sort_query_by_post_in', 10, 2 ); 
    28      
    29 function sort_query_by_post_in( $sortby, $thequery ) { 
    30     if ( !empty($thequery->query['post__in']) && isset($thequery->query['orderby']) && $thequery->query['orderby'] == 'post__in' ) 
    31         $sortby = "find_in_set(ID, '" . implode( ',', $thequery->query['post__in'] ) . "')"; 
    32      
    33     return $sortby; 
     12if ( version_compare( floatval( get_bloginfo( 'version' ) ), '3.5', '>=' ) ) { 
     13 
     14    add_action( 'admin_init', 'sort_query_by_post_in_deactivate' ); 
     15    add_action( 'admin_notices', 'sort_query_by_post_in_admin_notice' ); 
     16 
     17    function sort_query_by_post_in_deactivate() { 
     18        deactivate_plugins( plugin_basename( __FILE__ ) ); 
     19    } 
     20 
     21    function sort_query_by_post_in_admin_notice() { 
     22        echo '<div class="updated"><p><strong>Sort Query by Post In plug-in</strong> was folded into WordPress core in 3.5; the plug-in has been <strong>deactivated</strong>.</p></div>'; 
     23        if ( isset( $_GET['activate'] ) ) 
     24            unset( $_GET['activate'] ); 
     25    } 
     26 
     27} else { 
     28 
     29    add_filter( 'posts_orderby', 'sort_query_by_post_in', 10, 2 ); 
     30 
     31    function sort_query_by_post_in( $sortby, $thequery ) { 
     32        if ( !empty($thequery->query['post__in']) && isset($thequery->query['orderby']) && $thequery->query['orderby'] == 'post__in' ) 
     33            $sortby = "find_in_set(ID, '" . implode( ',', $thequery->query['post__in'] ) . "')"; 
     34 
     35        return $sortby; 
     36    } 
     37 
    3438} 
Note: See TracChangeset for help on using the changeset viewer.