ba4770c9 by Jeff Balicki

post order

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 404e4df6
<?php
/**
* Compatibility : LiteSpeed Cache
* Introduced at :
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class PTO_LiteSpeed_Cache
{
function __construct()
{
if( ! $this->is_plugin_active())
return FALSE;
add_action( 'PTO/order_update_complete', array( $this, 'order_update_complete') );
}
function is_plugin_active()
{
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'litespeed-cache/litespeed-cache.php' ) )
return TRUE;
else
return FALSE;
}
function order_update_complete()
{
if( method_exists( 'LiteSpeed_Cache_API', 'purge_all' ) )
{
LiteSpeed_Cache_API::purge_all() ;
}
}
}
new PTO_LiteSpeed_Cache();
?>
\ No newline at end of file
<?php
/**
* Compatibility : Events Calendar
* Introduced at :
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class PTO_Events_calendar
{
function __construct()
{
add_filter( 'pto/posts_orderby/ignore', array ( $this, 'ignore_post_types_order_sort' ), 10, 3 );
}
function ignore_post_types_order_sort( $ignore, $orderBy, $query )
{
if ( isset($query->query_vars) && !empty( $query->query_vars['post_type'] ))
{
$query_post_types = array();
foreach ( (array)$query->query_vars['post_type'] as $_post_type )
{
$query_post_types[] = $_post_type;
}
if ( in_array("tribe_events", $query_post_types ) )
$ignore = TRUE;
}
return $ignore;
}
}
new PTO_Events_calendar();
?>
\ No newline at end of file
<?php
/**
* Compatibility : Endfold
* Introduced at : 5.6.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class PTO_Enfold
{
function __construct()
{
add_filter( 'pto/posts_orderby/ignore', array ( $this, 'ignore_post_types_order_sort' ), 10, 3 );
}
function ignore_post_types_order_sort( $ignore, $orderBy, $query )
{
if ( isset($query->query_vars) && !empty( $query->query_vars['post_type'] ))
{
$query_post_types = array();
foreach ( (array)$query->query_vars['post_type'] as $_post_type )
{
$query_post_types[] = $_post_type;
}
if ( in_array("avia_framework_post", $query_post_types ) )
$ignore = TRUE;
}
return $ignore;
}
}
new PTO_Enfold();
?>
\ No newline at end of file
{
"name" : "nsp-code/post-types-order",
"description" : "Posts Order and Post Types Objects Order using a Drag and Drop Sortable javascript capability",
"keywords" : ["post order" , "posts order", "sort", "post sort", "posts sort", "post type order", "custom order", "admin posts order"],
"homepage" : "http://www.nsp-code.com/",
"authors" : [
{
"name": "Nsp Code",
"email": "contact@nsp-code.com",
"homepage": "http://www.nsp-code.com/"
}
],
"type" : "wordpress-plugin",
"repositories" :[
{
"type":"composer",
"url":"https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
}
],
"require" : {
"composer/installers": "~1.0"
}
}
#the-list.ui-sortable tr .check-column:hover { cursor: move;}
#the-list.ui-sortable tr.alternate { background-color: #F9F9F9; }
#the-list.ui-sortable tr.ui-sortable-helper { background-color: #ffffff; outline: 1px solid #dfdfdf;}
#the-list.ui-sortable .ui-sortable-placeholder td{border-color:#bbb;background-color:#FCFCFC; height:32px; background-image: none; -moz-border-radius: 6px 6px 6px 6px; border: 3px dashed #E6E6E6; -webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px; box-sizing: border-box;}
#the-list.ui-sortable > tr > th:first-child:after {position: absolute; color: #959595; content: "\f475"; transform: rotate(-90deg); margin: 4px 0 0 6px; display: block; font-family: dashicons;
line-height: 1;
font-weight: 400;
font-style: normal;
text-transform: none;
text-rendering: auto;
font-size: 20px;
text-align: center;}
\ No newline at end of file
#form_data td {vertical-align: top; padding-top: 20px}
#cpto #cpt_info_box {padding: 0 10px; border: 1px dashed #6aadcc; background-color: #FFF; margin-top: 10px;-webkit-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);-moz-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);}
#cpto #cpt_info_box a {text-decoration: none}
#cpto #cpt_info_box #donate_form { padding: 20px 0 17px; text-align: center; width: 100%;}
\ No newline at end of file
#order-post-type #sortable { list-style-type: none; margin: 10px 0 0; padding: 0; width: 100%; }
#order-post-type #sortable ul { margin-left:20px; list-style: none; }
#order-post-type #sortable li { padding: 10px; margin: 3px 0px; border-bottom: 1px solid #f4f4f4;border-left: 4px solid #ccd0d4; cursor: move; background-color: #FFF}
#order-post-type #sortable li:nth-child(2n+1) { background-color: #f9f9f9 !important;}
#order-post-type #sortable li span { display: block; font-size:14px;}
#order-post-type #sortable li.placeholder{border: dashed 2px #ccc;height:18px; background-color: #FFF;}
#cpto h2.subtitle {font-size: 15px; font-style: italic; font-weight: bold; padding-left: 0px}
.wrap .example { color: #666666; font-size: 11px; font-weight: bold}
#cpto #cpt_info_box {padding: 0 10px; border: 1px dashed #6aadcc; background-color: #FFF; margin-top: 10px;-webkit-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);-moz-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);}
#cpto #cpt_info_box a {text-decoration: none}
#cpto #cpt_info_box #donate_form { padding: 20px 0 17px; text-align: center; width: 100%;}
.menu_pto {margin-right: 4px; display: inline; vertical-align: middle; margin-top: -1px;}
#cpto #p_right {float: right; background-color:#f5f5f5; border: 1px dashed #6aadcc; padding: 0px 10px; margin-top: 10px}
#cpto .p_s_item {float: right; padding: 0px 5px; margin-top: 10px; margin-bottom: 5px; }
.clear {clear: both}
\ No newline at end of file
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="11.000000pt" height="29.000000pt" viewBox="0 0 11.000000 29.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,29.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M17 272 c-14 -15 -17 -40 -17 -129 0 -129 10 -147 77 -140 l38 4 -41
1 c-22 1 -45 7 -52 14 -17 17 -17 232 1 246 7 6 30 12 52 15 l40 4 -41 1 c-29
1 -46 -4 -57 -16z"/>
<path d="M30 245 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0
-15 -7 -15 -15z"/>
<path d="M70 245 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0
-15 -7 -15 -15z"/>
<path d="M30 195 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0
-15 -7 -15 -15z"/>
<path d="M70 195 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0
-15 -7 -15 -15z"/>
<path d="M30 145 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0
-15 -7 -15 -15z"/>
<path d="M70 145 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0
-15 -7 -15 -15z"/>
<path d="M30 95 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0 -15
-7 -15 -15z"/>
<path d="M70 95 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0 -15
-7 -15 -15z"/>
<path d="M30 45 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0 -15
-7 -15 -15z"/>
<path d="M70 45 c0 -8 7 -15 15 -15 8 0 15 7 15 15 0 8 -7 15 -15 15 -8 0 -15
-7 -15 -15z"/>
</g>
</svg>
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class CPT_Compatibility
{
function __construct()
{
$this->init();
}
function init()
{
$CompatibilityFiles = array(
'the-events-calendar.php',
'LiteSpeed_Cache.php',
);
foreach( $CompatibilityFiles as $CompatibilityFile )
{
if ( is_file( CPTPATH . 'compatibility/' . $CompatibilityFile ) )
include_once( CPTPATH . 'compatibility/' . $CompatibilityFile );
}
/**
* Themes
*/
$theme = wp_get_theme();
if( ! $theme instanceof WP_Theme )
return FALSE;
$compatibility_themes = array(
'enfold' => 'enfold.php',
);
if (isset( $theme->template ) )
{
foreach ( $compatibility_themes as $theme_slug => $compatibility_file )
{
if ( strtolower( $theme->template ) == $theme_slug || strtolower( $theme->name ) == $theme_slug )
{
include_once( CPTPATH . 'compatibility/themes/' . $compatibility_file );
}
}
}
do_action('cpt/compatibility/init');
}
}
new CPT_Compatibility();
?>
\ No newline at end of file
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class CPTO
{
var $current_post_type = null;
var $functions;
function __construct()
{
$this->functions = new CptoFunctions();
$is_configured = get_option('CPT_configured');
if ($is_configured == '')
add_action( 'admin_notices', array($this, 'admin_configure_notices'));
add_filter('init', array($this, 'on_init'));
add_filter('init', array($this, 'compatibility'));
add_filter('pre_get_posts', array($this, 'pre_get_posts'));
add_filter('posts_orderby', array($this, 'posts_orderby'), 99, 2);
}
function init()
{
include_once(CPTPATH . '/include/class.walkers.php');
//add_action( 'admin_init', array(&$this, 'registerFiles'), 11 );
add_action( 'admin_init', array(&$this, 'admin_init'), 10 );
add_action( 'admin_menu', array(&$this, 'addMenu') );
add_action('admin_menu', array(&$this, 'plugin_options_menu'));
//load archive drag&drop sorting dependencies
add_action( 'admin_enqueue_scripts', array(&$this, 'archiveDragDrop'), 10 );
add_action( 'wp_ajax_update-custom-type-order', array(&$this, 'saveAjaxOrder') );
add_action( 'wp_ajax_update-custom-type-order-archive', array(&$this, 'saveArchiveAjaxOrder') );
}
/**
* On WordPress Init hook
* This is being used to set the navigational links
*
*/
function on_init()
{
if( is_admin() )
return;
//check the navigation_sort_apply option
$options = $this->functions->get_options();
$navigation_sort_apply = ($options['navigation_sort_apply'] == "1") ? TRUE : FALSE;
//Deprecated, rely on pto/navigation_sort_apply
$navigation_sort_apply = apply_filters('cpto/navigation_sort_apply', $navigation_sort_apply);
$navigation_sort_apply = apply_filters('pto/navigation_sort_apply', $navigation_sort_apply);
if( ! $navigation_sort_apply)
return;
add_filter('get_previous_post_where', array($this->functions, 'cpto_get_previous_post_where'), 99, 3);
add_filter('get_previous_post_sort', array($this->functions, 'cpto_get_previous_post_sort') );
add_filter('get_next_post_where', array($this->functions, 'cpto_get_next_post_where'), 99, 3);
add_filter('get_next_post_sort', array($this->functions, 'cpto_get_next_post_sort') );
}
/**
* Compatibility with different 3rd codes
*
*/
function compatibility()
{
include_once( CPTPATH . '/include/class.compatibility.php');
}
function pre_get_posts($query)
{
//no need if it's admin interface
if (is_admin())
return $query;
//check for ignore_custom_sort
if (isset($query->query_vars['ignore_custom_sort']) && $query->query_vars['ignore_custom_sort'] === TRUE)
return $query;
//ignore if "nav_menu_item"
if(isset($query->query_vars) && isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == "nav_menu_item")
return $query;
$options = $this->functions->get_options();
//if auto sort
if ($options['autosort'] == "1")
{
//remove the supresed filters;
if (isset($query->query['suppress_filters']))
$query->query['suppress_filters'] = FALSE;
if (isset($query->query_vars['suppress_filters']))
$query->query_vars['suppress_filters'] = FALSE;
}
return $query;
}
function posts_orderby($orderBy, $query)
{
global $wpdb;
$options = $this->functions->get_options();
//check for ignore_custom_sort
if (isset($query->query_vars['ignore_custom_sort']) && $query->query_vars['ignore_custom_sort'] === TRUE)
return $orderBy;
//ignore the bbpress
if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("reply", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "reply")))
return $orderBy;
if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("topic", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "topic")))
return $orderBy;
//check for orderby GET paramether in which case return default data
if (isset($_GET['orderby']) && $_GET['orderby'] != 'menu_order')
return $orderBy;
//Avada orderby
if (isset($_GET['product_orderby']) && $_GET['product_orderby'] != 'default')
return $orderBy;
//check to ignore
/**
* Deprecated filter
* do not rely on this anymore
*/
if(apply_filters('pto/posts_orderby', $orderBy, $query) === FALSE)
return $orderBy;
$ignore = apply_filters('pto/posts_orderby/ignore', FALSE, $orderBy, $query);
if($ignore === TRUE)
return $orderBy;
//ignore search
if( $query->is_search() && isset( $query->query['s'] ) && ! empty ( $query->query['s'] ) )
return( $orderBy );
if ( ( is_admin() && !wp_doing_ajax() ) || ( wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'query-attachments') )
{
if ( $options['adminsort'] == "1" || ( wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'query-attachments') )
{
global $post;
$order = apply_filters('pto/posts_order', '', $query);
//temporary ignore ACF group and admin ajax calls, should be fixed within ACF plugin sometime later
if (is_object($post) && $post->post_type == "acf-field-group"
|| (defined('DOING_AJAX') && isset($_REQUEST['action']) && strpos($_REQUEST['action'], 'acf/') === 0))
return $orderBy;
if(isset($_POST['query']) && isset($_POST['query']['post__in']) && is_array($_POST['query']['post__in']) && count($_POST['query']['post__in']) > 0)
return $orderBy;
$orderBy = "{$wpdb->posts}.menu_order {$order}, {$wpdb->posts}.post_date DESC";
}
}
else
{
$order = '';
if ($options['use_query_ASC_DESC'] == "1")
$order = isset($query->query_vars['order']) ? " " . $query->query_vars['order'] : '';
$order = apply_filters('pto/posts_order', $order, $query);
if ($options['autosort'] == "1")
{
if(trim($orderBy) == '')
$orderBy = "{$wpdb->posts}.menu_order " . $order;
else
$orderBy = "{$wpdb->posts}.menu_order". $order .", " . $orderBy;
}
}
return($orderBy);
}
/**
* Show not configured notive
*
*/
function admin_configure_notices()
{
if (isset($_POST['form_submit']))
return;
?>
<div class="error fade">
<p><strong><?php esc_html_e('Post Types Order must be configured. Please go to', 'post-types-order'); ?> <a href="<?php echo esc_attr( get_admin_url() ); ?>options-general.php?page=cpto-options"><?php esc_html_e('Settings Page', 'post-types-order'); ?></a> <?php esc_html_e('make the configuration and save', 'post-types-order'); ?></strong></p>
</div>
<?php
}
/**
* Plugin options menu
*
*/
function plugin_options_menu()
{
include (CPTPATH . '/include/class.options.php');
$options_interface = new CptoOptionsInterface();
$options_interface->check_options_update();
$hookID = add_options_page('Post Types Order', '<img class="menu_pto" src="'. CPTURL .'/images/menu-icon.png" alt="" /> Post Types Order', 'manage_options', 'cpto-options', array($options_interface, 'plugin_options_interface'));
add_action('admin_print_styles-' . $hookID , array($this, 'admin_options_print_styles'));
}
function admin_options_print_styles()
{
wp_register_style('pto-options', CPTURL . '/css/cpt-options.css');
wp_enqueue_style( 'pto-options');
}
/**
* Load archive drag&drop sorting dependencies
*
* Since version 1.8.8
*/
function archiveDragDrop()
{
$options = $this->functions->get_options();
//if adminsort turned off no need to continue
if( $options['adminsort'] != '1')
return;
$screen = get_current_screen();
//check if the right interface
if( !isset( $screen->post_type ) || empty($screen->post_type))
return;
if( isset( $screen->taxonomy ) && !empty($screen->taxonomy) )
return;
if ( empty ( $options['allow_reorder_default_interfaces'][$screen->post_type] ) || ( isset ( $options['allow_reorder_default_interfaces'][$screen->post_type] ) && $options['allow_reorder_default_interfaces'][$screen->post_type] != 'yes' ) )
return;
if ( wp_is_mobile() )
return;
//check if post type is sortable
if(isset($options['show_reorder_interfaces'][$screen->post_type]) && $options['show_reorder_interfaces'][ $screen->post_type ] != 'show')
return;
//not for hierarhical
//if ( is_post_type_hierarchical( $screen->post_type ) )
//return;
//if is taxonomy term filter return
if(is_category() || is_tax())
return;
//return if use orderby columns
if (isset($_GET['orderby']) && $_GET['orderby'] != 'menu_order')
return false;
//return if post status filtering
if (isset($_GET['post_status']))
return false;
//return if post author filtering
if (isset($_GET['author']))
return false;
//load required dependencies
wp_enqueue_style('cpt-archive-dd', CPTURL . '/css/cpt-archive-dd.css');
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-sortable');
wp_register_script('cpto', CPTURL . '/js/cpt.js', array('jquery'));
global $userdata;
// Localize the script with new data
$CPTO_variables = array(
'post_type' => $screen->post_type,
'archive_sort_nonce' => wp_create_nonce( 'CPTO_archive_sort_nonce_' . $userdata->ID)
);
wp_localize_script( 'cpto', 'CPTO', $CPTO_variables );
// Enqueued script with localized data.
wp_enqueue_script( 'cpto' );
}
function admin_init()
{
if ( isset($_GET['page']) && substr($_GET['page'], 0, 17) == 'order-post-types-' )
{
$this->current_post_type = get_post_type_object(str_replace( 'order-post-types-', '', $_GET['page'] ));
if ( $this->current_post_type == null)
{
wp_die('Invalid post type');
}
}
//add compatibility filters and code
include_once(CPTPATH . '/compatibility/LiteSpeed_Cache.php');
}
/**
* Save the order set through separate interface
*
*/
function saveAjaxOrder()
{
set_time_limit(600);
global $wpdb;
$nonce = $_POST['interface_sort_nonce'];
//verify the nonce
if (! wp_verify_nonce( $nonce, 'interface_sort_nonce') )
die();
parse_str($_POST['order'], $data);
if (is_array($data))
{
foreach($data as $key => $values )
{
if ( $key == 'item' )
{
foreach( $values as $position => $id )
{
//sanitize
$id = (int)$id;
$data = array('menu_order' => $position);
//Deprecated, rely on pto/save-ajax-order
$data = apply_filters('post-types-order_save-ajax-order', $data, $key, $id);
$data = apply_filters('pto/save-ajax-order', $data, $key, $id);
$wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
}
}
else
{
foreach( $values as $position => $id )
{
//sanitize
$id = (int)$id;
$data = array('menu_order' => $position, 'post_parent' => str_replace('item_', '', $key));
//Deprecated, rely on pto/save-ajax-order
$data = apply_filters('post-types-order_save-ajax-order', $data, $key, $id);
$data = apply_filters('pto/save-ajax-order', $data, $key, $id);
$wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
}
}
}
}
//trigger action completed
do_action('PTO/order_update_complete');
wp_cache_flush();
}
/**
* Save the order set throgh the Archive
*
*/
function saveArchiveAjaxOrder()
{
set_time_limit(600);
global $wpdb, $userdata;
$post_type = filter_var ( $_POST['post_type'], FILTER_SANITIZE_STRING);
$paged = filter_var ( $_POST['paged'], FILTER_SANITIZE_NUMBER_INT);
$nonce = $_POST['archive_sort_nonce'];
//verify the nonce
if (! wp_verify_nonce( $nonce, 'CPTO_archive_sort_nonce_' . $userdata->ID ) )
die();
parse_str($_POST['order'], $data);
if (!is_array($data) || count($data) < 1)
die();
//retrieve a list of all objects
$mysql_query = $wpdb->prepare("SELECT ID FROM ". $wpdb->posts ."
WHERE post_type = %s AND post_status IN ('publish', 'pending', 'draft', 'private', 'future', 'inherit')
ORDER BY menu_order, post_date DESC", $post_type);
$results = $wpdb->get_results($mysql_query);
if (!is_array($results) || count($results) < 1)
die();
//create the list of ID's
$objects_ids = array();
foreach($results as $result)
{
$objects_ids[] = (int)$result->ID;
}
global $userdata;
$objects_per_page = get_user_meta($userdata->ID ,'edit_' . $post_type .'_per_page', TRUE);
$objects_per_page = apply_filters( "edit_{$post_type}_per_page", $objects_per_page );
if(empty($objects_per_page))
$objects_per_page = 20;
$edit_start_at = $paged * $objects_per_page - $objects_per_page;
$index = 0;
for($i = $edit_start_at; $i < ($edit_start_at + $objects_per_page); $i++)
{
if(!isset($objects_ids[$i]))
break;
$objects_ids[$i] = (int)$data['post'][$index];
$index++;
}
//update the menu_order within database
foreach( $objects_ids as $menu_order => $id )
{
$data = array(
'menu_order' => $menu_order
);
//Deprecated, rely on pto/save-ajax-order
$data = apply_filters('post-types-order_save-ajax-order', $data, $menu_order, $id);
$data = apply_filters('pto/save-ajax-order', $data, $menu_order, $id);
$wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
clean_post_cache( $id );
}
//trigger action completed
do_action('PTO/order_update_complete');
wp_cache_flush();
}
function addMenu()
{
global $userdata;
//put a menu for all custom_type
$post_types = get_post_types();
$options = $this->functions->get_options();
//get the required user capability
$capability = '';
if(isset($options['capability']) && !empty($options['capability']))
{
$capability = $options['capability'];
}
else if (is_numeric($options['level']))
{
$capability = $this->functions->userdata_get_user_level();
}
else
{
$capability = 'manage_options';
}
foreach( $post_types as $post_type_name )
{
if ($post_type_name == 'page')
continue;
//ignore bbpress
if ($post_type_name == 'reply' || $post_type_name == 'topic')
continue;
if(is_post_type_hierarchical($post_type_name))
continue;
$post_type_data = get_post_type_object( $post_type_name );
if($post_type_data->show_ui === FALSE)
continue;
if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] != 'show')
continue;
$required_capability = apply_filters('pto/edit_capability', $capability, $post_type_name);
if ( $post_type_name == 'post' )
$hookID = add_submenu_page('edit.php', __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $required_capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
elseif ($post_type_name == 'attachment')
$hookID = add_submenu_page('upload.php', __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $required_capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
else
{
$hookID = add_submenu_page('edit.php?post_type='.$post_type_name, __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $required_capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
}
add_action('admin_print_styles-' . $hookID , array($this, 'admin_reorder_print_styles'));
}
}
function admin_reorder_print_styles()
{
if ( $this->current_post_type != null )
{
wp_enqueue_script('jQuery');
wp_enqueue_script('jquery-ui-sortable');
}
wp_register_style('CPTStyleSheets', CPTURL . '/css/cpt.css');
wp_enqueue_style( 'CPTStyleSheets');
}
function SortPage()
{
?>
<div id="cpto" class="wrap">
<div class="icon32" id="icon-edit"><br></div>
<h2><?php echo esc_html( $this->current_post_type->labels->singular_name . ' - '. esc_html__('Re-Order', 'post-types-order') ); ?></h2>
<?php $this->functions->cpt_info_box(); ?>
<div id="ajax-response"></div>
<noscript>
<div class="error message">
<p><?php esc_html_e('This plugin can\'t work without javascript, because it\'s use drag and drop and AJAX.', 'post-types-order'); ?></p>
</div>
</noscript>
<div id="order-post-type">
<ul id="sortable">
<?php $this->listPages('hide_empty=0&title_li=&post_type='.$this->current_post_type->name); ?>
</ul>
<div class="clear"></div>
</div>
<p class="submit">
<a href="javascript: void(0)" id="save-order" class="button-primary"><?php esc_html_e('Update', 'post-types-order' ); ?></a>
</p>
<?php wp_nonce_field( 'interface_sort_nonce', 'interface_sort_nonce' ); ?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#sortable").sortable({
'tolerance':'intersect',
'cursor':'pointer',
'items':'li',
'placeholder':'placeholder',
'nested': 'ul'
});
jQuery("#sortable").disableSelection();
jQuery("#save-order").bind( "click", function() {
jQuery("html, body").animate({ scrollTop: 0 }, "fast");
jQuery.post( ajaxurl, { action:'update-custom-type-order', order:jQuery("#sortable").sortable("serialize"), 'interface_sort_nonce' : jQuery('#interface_sort_nonce').val() }, function() {
jQuery("#ajax-response").html('<div class="message updated fade"><p><?php esc_html_e('Items Order Updated', 'post-types-order') ?></p></div>');
jQuery("#ajax-response div").delay(3000).hide("slow");
});
});
});
</script>
</div>
<?php
}
function listPages($args = '')
{
$defaults = array(
'depth' => -1,
'date_format' => get_option('date_format'),
'child_of' => 0,
'sort_column' => 'menu_order',
'post_status' => 'any'
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$output = '';
$r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', array()) );
// Query pages.
$r['hierarchical'] = 0;
$args = array(
'sort_column' => 'menu_order',
'post_type' => $post_type,
'posts_per_page' => -1,
'post_status' => 'any',
'orderby' => array(
'menu_order' => 'ASC',
'post_date' => 'DESC'
)
);
$the_query = new WP_Query($args);
$pages = $the_query->posts;
if ( !empty($pages) )
{
$output .= $this->walkTree($pages, $r['depth'], $r);
}
echo wp_kses_post ( $output );
}
function walkTree($pages, $depth, $r)
{
$walker = new Post_Types_Order_Walker;
$args = array($pages, $depth, $r);
return call_user_func_array(array(&$walker, 'walk'), $args);
}
}
?>
\ No newline at end of file
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class CptoFunctions
{
/**
* Return the user level
*
* This is deprecated, will be removed in the next versions
*
* @param mixed $return_as_numeric
*/
function userdata_get_user_level($return_as_numeric = FALSE)
{
global $userdata;
$user_level = '';
for ($i=10; $i >= 0;$i--)
{
if (current_user_can('level_' . $i) === TRUE)
{
$user_level = $i;
if ($return_as_numeric === FALSE)
$user_level = 'level_'.$i;
break;
}
}
return ($user_level);
}
/**
* Retrieve the plugin options
*
*/
function get_options()
{
//make sure the vars are set as default
$options = get_option('cpto_options');
$defaults = array (
'show_reorder_interfaces' => array(),
'allow_reorder_default_interfaces' => array(),
'autosort' => 1,
'adminsort' => 1,
'use_query_ASC_DESC' => '',
'capability' => 'manage_options',
'navigation_sort_apply' => 1,
);
$options = wp_parse_args( $options, $defaults );
$options = apply_filters('pto/get_options', $options);
return $options;
}
/**
* General messages box
*
*/
function cpt_info_box()
{
?>
<div id="cpt_info_box">
<p><?php esc_html_e('Did you find this plugin useful? Please support our work by purchasing the advanced version or write an article about this plugin in your blog with a link to our site', 'post-types-order') ?> <a href="https://www.nsp-code.com/" target="_blank"><strong>https://www.nsp-code.com/</strong></a>.</p>
<h4><?php esc_html_e('Did you know there is available an Advanced version of this plug-in?', 'post-types-order') ?> <a target="_blank" href="https://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/"><?php _e('Read more', 'post-types-order') ?></a></h4>
<p><?php esc_html_e('Check our', 'post-types-order') ?> <a target="_blank" href="https://wordpress.org/plugins/taxonomy-terms-order/">Category Order - Taxonomy Terms Order</a> <?php esc_html_e('plugin which allow to custom sort categories and custom taxonomies terms', 'post-types-order') ?> </p>
<p><span style="color:#CC0000" class="dashicons dashicons-megaphone" alt="f488">&nbsp;</span> <?php esc_html_e('Check out', 'post-types-order') ?> <a href="https://wordpress.org/plugins/wp-hide-security-enhancer/" target="_blank"><b>WP Hide & Security Enhancer</b></a> <?php esc_html_e('an extra layer of security for your site. The easy way to completely hide your WordPress core files, themes and plugins', 'post-types-order') ?>.</p>
<div class="clear"></div>
</div>
<?php
}
function cpto_get_previous_post_where($where, $in_same_term, $excluded_terms)
{
global $post, $wpdb;
if ( empty( $post ) )
return $where;
//?? WordPress does not pass through this varialbe, so we presume it's category..
$taxonomy = 'category';
if(preg_match('/ tt.taxonomy = \'([^\']+)\'/i',$where, $match))
$taxonomy = $match[1];
$_join = '';
$_where = '';
if ( $in_same_term || ! empty( $excluded_terms ) )
{
$_join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
$_where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) )
{
// back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
if ( false !== strpos( $excluded_terms, ' and ' ) )
{
_deprecated_argument( __FUNCTION__, '3.3', sprintf( esc_html__( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
$excluded_terms = explode( ' and ', $excluded_terms );
}
else
{
$excluded_terms = explode( ',', $excluded_terms );
}
$excluded_terms = array_map( 'intval', $excluded_terms );
}
if ( $in_same_term )
{
$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// Remove any exclusions from the term array to include.
$term_array = array_diff( $term_array, (array) $excluded_terms );
$term_array = array_map( 'intval', $term_array );
$_where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
}
if ( ! empty( $excluded_terms ) ) {
$_where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( ',', $excluded_terms ) . ') )';
}
}
$current_menu_order = $post->menu_order;
$query = $wpdb->prepare( "SELECT p.* FROM $wpdb->posts AS p
$_join
WHERE p.post_date < %s AND p.menu_order = %d AND p.post_type = %s AND p.post_status = 'publish' $_where" , $post->post_date, $current_menu_order, $post->post_type);
$results = $wpdb->get_results($query);
if (count($results) > 0)
{
$where .= $wpdb->prepare( " AND p.menu_order = %d", $current_menu_order );
}
else
{
$where = str_replace("p.post_date < '". $post->post_date ."'", "p.menu_order > '$current_menu_order'", $where);
}
return $where;
}
function cpto_get_previous_post_sort($sort)
{
global $post, $wpdb;
$sort = 'ORDER BY p.menu_order ASC, p.post_date DESC LIMIT 1';
return $sort;
}
function cpto_get_next_post_where($where, $in_same_term, $excluded_terms)
{
global $post, $wpdb;
if ( empty( $post ) )
return $where;
$taxonomy = 'category';
if(preg_match('/ tt.taxonomy = \'([^\']+)\'/i',$where, $match))
$taxonomy = $match[1];
$_join = '';
$_where = '';
if ( $in_same_term || ! empty( $excluded_terms ) )
{
$_join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
$_where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) )
{
// back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
if ( false !== strpos( $excluded_terms, ' and ' ) )
{
_deprecated_argument( __FUNCTION__, '3.3', sprintf( esc_html__( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
$excluded_terms = explode( ' and ', $excluded_terms );
}
else
{
$excluded_terms = explode( ',', $excluded_terms );
}
$excluded_terms = array_map( 'intval', $excluded_terms );
}
if ( $in_same_term )
{
$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// Remove any exclusions from the term array to include.
$term_array = array_diff( $term_array, (array) $excluded_terms );
$term_array = array_map( 'intval', $term_array );
$_where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
}
if ( ! empty( $excluded_terms ) ) {
$_where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( ',', $excluded_terms ) . ') )';
}
}
$current_menu_order = $post->menu_order;
//check if there are more posts with lower menu_order
$query = $wpdb->prepare( "SELECT p.* FROM $wpdb->posts AS p
$_join
WHERE p.post_date > %s AND p.menu_order = %d AND p.post_type = %s AND p.post_status = 'publish' $_where", $post->post_date, $current_menu_order, $post->post_type );
$results = $wpdb->get_results($query);
if (count($results) > 0)
{
$where .= $wpdb->prepare(" AND p.menu_order = %d", $current_menu_order );
}
else
{
$where = str_replace("p.post_date > '". $post->post_date ."'", "p.menu_order < '$current_menu_order'", $where);
}
return $where;
}
function cpto_get_next_post_sort($sort)
{
global $post, $wpdb;
$sort = 'ORDER BY p.menu_order DESC, p.post_date ASC LIMIT 1';
return $sort;
}
}
?>
\ No newline at end of file
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class CptoOptionsInterface
{
var $CPTO;
function __construct()
{
global $CPTO;
$this->CPTO = $CPTO;
}
function check_options_update()
{
$options = $this->CPTO->functions->get_options();
if (isset($_POST['form_submit']) && wp_verify_nonce($_POST['cpto_form_nonce'],'cpto_form_submit'))
{
$options['show_reorder_interfaces'] = array_map( 'sanitize_key', (array) $_POST['show_reorder_interfaces'] );
$options['allow_reorder_default_interfaces'] = array_map( 'sanitize_key', (array) $_POST['allow_reorder_default_interfaces'] );
$options['capability'] = sanitize_key($_POST['capability']);
$options['autosort'] = isset($_POST['autosort']) ? intval($_POST['autosort']) : '';
$options['adminsort'] = isset($_POST['adminsort']) ? intval($_POST['adminsort']) : '';
$options['use_query_ASC_DESC'] = isset($_POST['use_query_ASC_DESC']) ? intval($_POST['use_query_ASC_DESC']) : '';
$options['navigation_sort_apply'] = isset($_POST['navigation_sort_apply']) ? intval($_POST['navigation_sort_apply']) : '';
update_option('cpto_options', $options);
update_option('CPT_configured', 'TRUE');
add_action( 'admin_notices', array( $this, 'admin_save_notice') );
}
}
function admin_save_notice()
{
echo "<div class='updated'><p>". esc_html__('Settings Saved', 'post-types-order') ."</p></div>";
}
function plugin_options_interface()
{
$options = $this->CPTO->functions->get_options();
?>
<div id="cpto" class="wrap">
<h2><?php esc_html_e('General Settings', 'post-types-order') ?></h2>
<?php $this->CPTO->functions->cpt_info_box(); ?>
<form id="form_data" name="form" method="post">
<br />
<h2><?php esc_html_e('General', 'post-types-order') ?></h2>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" style="text-align: right;"><label><?php esc_html_e('Show / Hide re-order interface', 'post-types-order') ?></label></th>
<td>
<?php
$post_types = get_post_types();
foreach( $post_types as $post_type_name )
{
//ignore list
$ignore_post_types = array(
'reply',
'topic',
'report',
'status'
);
if( in_array($post_type_name, $ignore_post_types) )
continue;
if( is_post_type_hierarchical($post_type_name) )
continue;
$post_type_data = get_post_type_object( $post_type_name );
if($post_type_data->show_ui === FALSE)
continue;
?>
<p><label>
<select name="show_reorder_interfaces[<?php echo esc_attr($post_type_name) ?>]">
<option value="show" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'show') {echo ' selected="selected"';} ?>><?php esc_html_e( "Show", 'post-types-order' ) ?></option>
<option value="hide" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'hide') {echo ' selected="selected"';} ?>><?php esc_html_e( "Hide", 'post-types-order' ) ?></option>
</select> &nbsp;&nbsp;<?php echo esc_html ( $post_type_data->labels->singular_name ); ?>
</label><br />&nbsp;</p>
<?php } ?>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right;"><label><?php esc_html_e('Minimum Level to use this plugin', 'post-types-order') ?></label></th>
<td>
<select id="role" name="capability">
<option value="read" <?php if (isset($options['capability']) && $options['capability'] == "read") echo 'selected="selected"'?>><?php esc_html_e('Subscriber', 'post-types-order') ?></option>
<option value="edit_posts" <?php if (isset($options['capability']) && $options['capability'] == "edit_posts") echo 'selected="selected"'?>><?php esc_html_e('Contributor', 'post-types-order') ?></option>
<option value="publish_posts" <?php if (isset($options['capability']) && $options['capability'] == "publish_posts") echo 'selected="selected"'?>><?php esc_html_e('Author', 'post-types-order') ?></option>
<option value="publish_pages" <?php if (isset($options['capability']) && $options['capability'] == "publish_pages") echo 'selected="selected"'?>><?php esc_html_e('Editor', 'post-types-order') ?></option>
<option value="manage_options" <?php if (!isset($options['capability']) || empty($options['capability']) || (isset($options['capability']) && $options['capability'] == "manage_options")) echo 'selected="selected"'?>><?php esc_html_e('Administrator', 'post-types-order') ?></option>
<?php do_action('pto/admin/plugin_options/capability') ?>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right;"><label for="autosort"><?php esc_html_e('Auto Sort', 'post-types-order') ?></label></th>
<td>
<p><input type="checkbox" <?php checked( '1', $options['autosort'] ); ?> id="autosort" value="1" name="autosort"> <?php esc_html_e("If checked, the plug-in automatically update the WordPress queries to use the new order", 'post-types-order'); ?> ( <b><?php esc_html_e("No code update is necessarily", 'post-types-order'); ?></b> )</p>
<p class="description"><?php esc_html_e("If only certain queries need to use the custom sort, keep this unchecked and include 'orderby' => 'menu_order' into query parameters", 'post-types-order') ?>.
<br />
<a href="http://www.nsp-code.com/sample-code-on-how-to-apply-the-sort-for-post-types-order-plugin/" target="_blank"><?php esc_html_e('Additional Description and Examples', 'post-types-order') ?></a></p>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right;"><label for="adminsort"><?php esc_html_e('Admin Sort', 'post-types-order') ?></label></th>
<td>
<p>
<input type="checkbox" <?php checked( '1', $options['adminsort'] ); ?> id="adminsort" value="1" name="adminsort">
<?php esc_html_e("To affect the admin interface, to see the post types per your new sort, this need to be checked", 'post-types-order') ?>.</p>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right;"><label for="archive_drag_drop"><?php esc_html_e('Use query ASC / DESC parameter ', 'post-types-order') ?></label></th>
<td>
<p>
<input type="checkbox" <?php checked( '1', $options['use_query_ASC_DESC'] ); ?> id="use_query_ASC_DESC" value="1" name="use_query_ASC_DESC">
<?php esc_html_e("If the query include an Ascending or Descending order paramether, use that. If query order is set to DESC the order will be reversed.", 'post-types-order') ?>.</p>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right;"><label for="archive_drag_drop"><?php esc_html_e('Archive Drag&Drop ', 'post-types-order') ?></label></th>
<td>
<p>
<?php esc_html_e("Allow sortable drag & drop functionality within default WordPress post type archive. Admin Sort need to be active.", 'post-types-order') ?></p>
<br />
<?php
$post_types = get_post_types();
foreach( $post_types as $post_type_name )
{
//ignore list
$ignore_post_types = array(
'reply',
'topic',
'report',
'status'
);
if( in_array($post_type_name, $ignore_post_types) )
continue;
$post_type_data = get_post_type_object( $post_type_name );
if($post_type_data->show_ui === FALSE)
continue;
?>
<p><label>
<select name="allow_reorder_default_interfaces[<?php echo esc_attr($post_type_name) ?>]">
<option value="no" <?php if(isset($options['allow_reorder_default_interfaces'][$post_type_name]) && $options['allow_reorder_default_interfaces'][$post_type_name] == 'no') {echo ' selected="selected"';} ?>><?php esc_html_e( "No", 'post-types-order' ) ?></option>
<option value="yes" <?php if(isset($options['allow_reorder_default_interfaces'][$post_type_name]) && $options['allow_reorder_default_interfaces'][$post_type_name] == 'yes') {echo ' selected="selected"';} ?>><?php esc_html_e( "Yes", 'post-types-order' ) ?></option>
</select> &nbsp;&nbsp;<?php echo esc_html ( $post_type_data->labels->singular_name ); ?>
</label><br />&nbsp;</p>
<?php } ?>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right;"><label for="navigation_sort_apply"><?php esc_html_e('Next / Previous Apply', 'post-types-order') ?></label></th>
<td>
<p>
<input type="checkbox" <?php checked( '1', $options['navigation_sort_apply'] ); ?> id="navigation_sort_apply" value="1" name="navigation_sort_apply">
<?php esc_html_e("Apply the sort on Next / Previous site-wide navigation.", 'post-types-order') ?> <?php esc_html_e('This can also be controlled through', 'post-types-order') ?> <a href="http://www.nsp-code.com/apply-custom-sorting-for-next-previous-site-wide-navigation/" target="_blank"><?php esc_html_e('code', 'post-types-order') ?></a></p>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_html_e('Save Settings', 'post-types-order') ?>">
</p>
<?php wp_nonce_field('cpto_form_submit','cpto_form_nonce'); ?>
<input type="hidden" name="form_submit" value="true" />
</form>
</div>
<?php
}
}
?>
\ No newline at end of file
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Post_Types_Order_Walker extends Walker
{
var $db_fields = array (
'parent' => 'post_parent',
'id' => 'ID'
);
function start_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class='children'>\n";
}
function end_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0)
{
if ( $depth )
$indent = str_repeat("\t", $depth);
else
$indent = '';
extract($args, EXTR_SKIP);
$item_details = apply_filters( 'the_title', $page->post_title, $page->ID );
//Deprecated, rely on pto/interface_itme_data
$item_details = apply_filters('cpto/interface_itme_data', $item_details, $page);
$item_details = apply_filters('pto/interface_item_data', $item_details, $page);
$output .= $indent . '<li id="item_'.$page->ID.'"><span>'. $item_details .'</span>';
}
function end_el(&$output, $page, $depth = 0, $args = array())
{
$output .= "</li>\n";
}
}
?>
\ No newline at end of file
var getUrlParameter = function getUrlParameter(sParam)
{
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
jQuery(document).ready(function()
{
jQuery('table.wp-list-table #the-list').sortable({
placeholder: {
element: function(currentItem) {
var cols = jQuery(currentItem).children('td:visible').length + 1;
return jQuery('<tr class="ui-sortable-placeholder"><td colspan="' + cols + '">&nbsp;</td></tr>')[0];
},
update: function(container, p) {
return;
}
},
'items': 'tr',
'handle': ".check-column",
'axis': 'y',
'update' : function(e, ui) {
var post_type = CPTO.post_type;
var order = jQuery('#the-list').sortable('serialize');
var paged = getUrlParameter('paged');
if(typeof paged === 'undefined')
paged = 1;
var queryString = { "action": "update-custom-type-order-archive", "post_type" : post_type, "order" : order ,"paged": paged, "archive_sort_nonce" : CPTO.archive_sort_nonce};
//send the data through ajax
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: queryString,
cache: false,
dataType: "html",
success: function(data){
},
error: function(html){
}
});
}
});
});
msgid ""
msgstr ""
"Project-Id-Version: Post Types Order\n"
"POT-Creation-Date: 2017-07-17 16:03+0200\n"
"PO-Revision-Date: 2023-02-23 15:43+0200\n"
"Last-Translator: NspCode <contact@nsp-code.com>\n"
"Language-Team: \n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.2\n"
"X-Poedit-KeywordsList: __;_e\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-SearchPath-0: .\n"
#: include/class.cpto.php:207
msgid "Post Types Order must be configured. Please go to"
msgstr ""
#: include/class.cpto.php:207
msgid "Settings Page"
msgstr ""
#: include/class.cpto.php:207
msgid "make the configuration and save"
msgstr ""
#: include/class.cpto.php:485 include/class.cpto.php:487
#: include/class.cpto.php:490 include/class.cpto.php:501
msgid "Re-Order"
msgstr ""
#: include/class.cpto.php:509
msgid ""
"This plugin can't work without javascript, because it's use drag and drop "
"and AJAX."
msgstr ""
#: include/class.cpto.php:522
msgid "Update"
msgstr ""
#: include/class.cpto.php:543
msgid "Items Order Updated"
msgstr ""
#: include/class.functions.php:104
msgid ""
"Did you find this plugin useful? Please support our work by purchasing the "
"advanced version or write an article about this plugin in your blog with a "
"link to our site"
msgstr ""
#: include/class.functions.php:105
msgid "Did you know there is available an Advanced version of this plug-in?"
msgstr ""
#: include/class.functions.php:105
msgid "Read more"
msgstr ""
#: include/class.functions.php:106
msgid "Check our"
msgstr ""
#: include/class.functions.php:106
msgid ""
"plugin which allow to custom sort categories and custom taxonomies terms"
msgstr ""
#: include/class.functions.php:107
msgid "Check out"
msgstr ""
#: include/class.functions.php:107
msgid ""
"the easy way to completely hide your WordPress core files, theme and plugins"
msgstr ""
#: include/class.functions.php:142 include/class.functions.php:221
#, php-format
msgid "Use commas instead of %s to separate excluded terms."
msgstr ""
#: include/class.options.php:40
msgid "Settings Saved"
msgstr ""
#: include/class.options.php:57
msgid "General Settings"
msgstr ""
#: include/class.options.php:63
msgid "General"
msgstr ""
#: include/class.options.php:67
msgid "Show / Hide re-order interface"
msgstr ""
#: include/class.options.php:94
msgid "Show"
msgstr ""
#: include/class.options.php:95
msgid "Hide"
msgstr ""
#: include/class.options.php:102
msgid "Minimum Level to use this plugin"
msgstr ""
#: include/class.options.php:105
msgid "Subscriber"
msgstr ""
#: include/class.options.php:106
msgid "Contributor"
msgstr ""
#: include/class.options.php:107
msgid "Author"
msgstr ""
#: include/class.options.php:108
msgid "Editor"
msgstr ""
#: include/class.options.php:109
msgid "Administrator"
msgstr ""
#: include/class.options.php:116
msgid "Auto Sort"
msgstr ""
#: include/class.options.php:118
msgid ""
"If checked, the plug-in automatically update the WordPress queries to use "
"the new order (<b>No code update is necessarily</b>)"
msgstr ""
#: include/class.options.php:119
msgid ""
"If only certain queries need to use the custom sort, keep this unchecked and "
"include 'orderby' => 'menu_order' into query parameters"
msgstr ""
#: include/class.options.php:121
msgid "Additional Description and Examples"
msgstr ""
#: include/class.options.php:128
msgid "Admin Sort"
msgstr ""
#: include/class.options.php:132
msgid ""
"To affect the admin interface, to see the post types per your new sort, this "
"need to be checked"
msgstr ""
#: include/class.options.php:137
msgid "Use query ASC / DESC parameter "
msgstr ""
#: include/class.options.php:141
msgid ""
"If the query include an Ascending or Descending order paramether, use that. "
"If query order is set to DESC the order will be reversed."
msgstr ""
#: include/class.options.php:146
msgid "Archive Drag&Drop "
msgstr ""
#: include/class.options.php:150
msgid ""
"Allow sortable drag & drop functionality within default WordPress post type "
"archive. Admin Sort need to be active."
msgstr ""
#: include/class.options.php:155
msgid "Next / Previous Apply"
msgstr ""
#: include/class.options.php:159
msgid "Apply the sort on Next / Previous site-wide navigation."
msgstr ""
#: include/class.options.php:159
msgid "This can also be controlled through"
msgstr ""
#: include/class.options.php:159
msgid "code"
msgstr ""
#: include/class.options.php:167
msgid "Save Settings"
msgstr ""
<?php
/*
Plugin Name: Post Types Order
Plugin URI: http://www.nsp-code.com
Description: Posts Order and Post Types Objects Order using a Drag and Drop Sortable javascript capability
Author: Nsp Code
Author URI: http://www.nsp-code.com
Version: 2.1
Text Domain: post-types-order
Domain Path: /languages/
*/
define('CPTPATH', plugin_dir_path(__FILE__));
define('CPTURL', plugins_url('', __FILE__));
include_once(CPTPATH . '/include/class.cpto.php');
include_once(CPTPATH . '/include/class.functions.php');
add_action( 'plugins_loaded', 'cpto_class_load');
function cpto_class_load()
{
global $CPTO;
$CPTO = new CPTO();
}
add_action( 'plugins_loaded', 'cpto_load_textdomain');
function cpto_load_textdomain()
{
load_plugin_textdomain('post-types-order', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages');
}
add_action('wp_loaded', 'initCPTO' );
function initCPTO()
{
global $CPTO;
$options = $CPTO->functions->get_options();
if (is_admin())
{
if(isset($options['capability']) && !empty($options['capability']))
{
if( current_user_can($options['capability']) )
$CPTO->init();
}
else if (is_numeric($options['level']))
{
if ( $CPTO->functions->userdata_get_user_level(true) >= $options['level'] )
$CPTO->init();
}
else
{
$CPTO->init();
}
}
}
?>
\ No newline at end of file
=== Post Types Order ===
Contributors: nsp-code, tdgu
Donate link: http://www.nsp-code.com/donate.php
Tags: post order, posts order, sort, post sort, posts sort, post type order, custom order, admin posts order
Requires at least: 2.8
Tested up to: 6.3
Stable tag: 2.1
Sort Posts and custom Post Type Objects (custom post types) using a Drag and Drop Sortable JavaScript AJAX interface or default WordPress dashboard.
== Description ==
<strong>Over 6.8 MILLIONS DOWNLOADS and near PERFECT rating out of 200 REVIEWS</strong>. <br />
A powerful plugin, Order Posts and Post Types Objects using a Drag and Drop Sortable JavaScript capability.
The order can be customized within **default WordPress post type archive list page** or **a separate Re-Order interface** which displays all objects.
It allows reordering the posts for any custom post types you defined, including the default Posts. Post Order has never been easier.
= Usage =
This plugin was developed considering everyone to be able to use the sorting feature, no matter the WordPress experience:
* Install the plugin through the Install Plugins interface or by uploading the `post-types-order` folder to your `/wp-content/plugins/` directory.
* Activate the Post Order plugin.
* A new setting page will be created within Settings > Post Types Order, you should check with that, and make a first options save.
* Using the <strong>AutoSort option as ON</strong> you don't need to worry about any code changes, the <strong>plugin will apply the customized post order</strong> on fly.
* Use the Re-Order interface which appears to every custom post type (non-hierarchical) to change the post order to a new one.
* If prefer sort apply through the code, include 'orderby' =>'menu_order' within custom query arguments, more details at http://www.nsp-code.com/sample-code-on-how-to-apply-the-sort-for-post-types-order-plugin/
= Example of Usage =
[youtube http://www.youtube.com/watch?v=VEbNKFSfhCc]
As you can see just a matter of drag and drop and post ordering will change on front side right away.
If for some reason the post order does not update on your front side, you either do something wrong or the theme code you are using does not use a standard query per WordPress Codex rules and regulations. But we can still help, use the forum to report your issue as there are many peoples who gladly help or get in touch with us.
<br />Something is wrong with this plugin on your site? Just use the forum or get in touch with us at <a target="_blank" href="http://www.nsp-code.com">Contact</a> and we'll check it out.
<br />Need More? Check out the advanced version of this plugin at <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/">Advanced Post Types Order</a> which include Hierarchically post types order, Manual / Automatic Sorting, Individual Categories Order, Conditionals to apply, Paginations for large list, Mobile ready, Enhanced Interface, Plugins compatibility (MultiSite Network Support, WPML, Polylang, WooCommerce, WP E-Commerce, Platform Pro, Genesis etc), font side re-order interface, ... and many more !!
<br />
<br />This plugin is developed by <a target="_blank" href="http://www.nsp-code.com">Nsp-Code</a>
== Installation ==
1. Upload `post-types-order` folder to your `/wp-content/plugins/` directory.
2. Activate the plugin from Admin > Plugins menu.
3. Once activated you should check with Settings > Post Types Order
4. Use Re-Order link which appear into each post type section or use default WordPress interface to make your sorting.
== Screenshots ==
1. The ReOrder interface through which the sort can be created.
2. Sort can be managed within default WordPress post type interface.
== Frequently Asked Questions ==
Feel free to contact us at electronice_delphi@yahoo.com
= Since I have no PHP knowledge at all, is this plugin for me? =
Absolutely, you can!
Unlike many other plugins, you don't have to do any code changes to make your post order to apply, accordingly to custom-defined order. There is an option to auto-update the WordPress queries so the posts will be returned in customised order. This can be turned off (Autosort) to allow customized code usage.
= How to manually apply the sort on queries =
Include a 'orderby' => 'menu_order' property within your custom query arguments.
= What kind of posts/pages does this plugin allow me to sort? =
You can sort ALL post types that you have defined into your WordPress as long they are not <strong>hierarhically</strong> defined: Posts (default WordPress custom post type), Movies, Reviews, Data etc..
= Ok, i understand about the template post types order, how about the admin interface? =
There's an option you can trigger, to see the post types order as you defined in the sort list, right into the main admin post list interface.
= There is a feature that i want it implemented, can you do something about it? =
All ideas are welcome and i put them on my list to be implemented into the new versions. Anyway this may take time, but if you are in a rush, please consider a small donation and we can arrange something.
= Can i make certain queries to ignore the custom sort when Autosort is turned On? =
This can be done by including the ignore_custom_sort within custom query arguments. An example can be found at <a target="_blank" href="http://www.nsp-code.com/advanced-post-types-order-api/sample-usage/">http://www.nsp-code.com/advanced-post-types-order-api/sample-usage/</a>
= How can i force the sort to apply for certain queries when AutoSort is turned On? =
A filter can be used to achieve that pto/posts_orderby. An example can be found at <a target="_blank" href="http://www.nsp-code.com/ignore-sort-apply-for-certain-query-on-post-types-order/">http://www.nsp-code.com/ignore-sort-apply-for-certain-query-on-post-types-order/</a>
= I still need more features like front sorting interface, shortcodes, filters, conditionals, advanced queries, taxonomy/ category sorting etc =
Consider upgrading to our advanced version of this plugin at a very resonable price <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/">Advanced Post Types Order</a>
== Change Log ==
= 2.1 =
- Trigger wp_cache_flush when saving the order to clear the internal caches
- WordPress 6.3 compatibility check and tag
- Compatibility update for lite speed cache
= 2.0.9 =
- Fix: is_plugin_active
= 2.0.7 =
- Compatibility class re-build
- Fix: Enfold templates when using Admin Sort
= 2.0.5 =
- Merge the "default archive&drop" option and keep the individual menu Yes/No for the default WordPress interfaces, to avoid confusion.
= 2.0.2 =
- The Archive drag & drop is disabled by default
- Small layout changes
- WordPress 6.2 compatibility tag
= 2.0 =
- Update cmoposer.json to use the wpackagist.org
- New option to select the drag & drop available for post types.
- The drag & drop within the default WordPress interfaces can be done now through the new icon, under the checkbox, for each item.
- Check if ajax call to avoid applying the order when autosort is disabled.
- Update plugin header image
= 1.9.9.2 =
- WordPress 6.1.1 compatibility tag
= 1.9.9.1 =
- WordPress 6.0 compatibility tag
= 1.9.9 =
- Fix layout change when sorting by drag&drop within default WordPress interface.
- Add placeholder row size by setting a tr colspan of the dragable element.
= 1.9.8 =
- Readme file updates, typos fixes.
- WordPress 5.9 compatibility tag
= 1.9.7 =
- Remove Twitter button
- Remove unused gif image
- HTPML and CSS cleanup
= 1.9.5.7 =
- Code cleanup
- WordPress 5.8.1 compatibility tag
= 1.9.5.6 =
- Fix PHP implode() notice
= 1.9.5.5 =
- Fix PHP implode() notice
= 1.9.5.4 =
- Fix PHP implode() notice
- Ensure the drag & drop interface show for correct post types, non hierarchically to ensure correct functionality
- WordPress 5.6 compatibility tag
= 1.9.5.2 =
- Clean post cache on order update to allow menu_order to change on cached data
- WordPress 5.5 compatibility tag
= 1.9.5.1 =
- Fix: Outputs the admin save notice through admin_notices filter
= 1.9.5 =
- Fix: disable drag & drop within taxonomies interfaces; fix WooCommerce attributes sort issue
- Reorder interface slight styles improvements
- Compatibility tag update for WordPress 5.4.2
= 1.9.4.3 =
- Option text translation update
- Changed the posts class to to wp-list-table when applying sortable for better compatibility
- Compatibility tag update for WordPress 5.4
= 1.9.4.2 =
- Compatibility tag update for WordPress 5.3
= 1.9.4.1 =
- Ignore the Events Calendar posts
- Filter typo fix
= 1.9.3.9 =
- Ignore sorting when doing Search and there's a search key-phrase specified.
- Ignore sorting when doing Search within admin dashboard
- Removed Google Social as it produced some JavaScript errors
- WordPress 4.9.7 tag update
= 1.9.3.6 =
- Clear LiteSpeed Cache on order update to reflect on front side
- WordPress 4.9.1 tag update
= 1.9.3.5 =
- Fix: updated capability from switch_theme to manage_options within 'Minimum Level to use this plugin' option
- Default admin capability changed from install_plugins to manage_options to prevent DISALLOW_FILE_MODS issue. https://wordpress.org/support/topic/plugin-breaks-when-disallow_file_mods-is-set-to-true/
- Prepare plugin for Composer package
= 1.9.3.3 =
- Plugin option to include query argument ASC / DESC
= 1.9.3.2 =
- Include ASC / DESC if there is a query order argument
- Avada fix 'product_orderby' ignore
= 1.9.3.1 =
- WordPress 4.8 compatibility notice
- Slight code changes, remove unused activate / deactivate hooks
- Updated po translation file
- Updated assets
= 1.9.3 =
- Fix for custom post type objects per page when using default archive interface drag & drop sort
- Plugin code redo and re-structure
- Improved compatibility with other plugins
- Security improvements for AJAX order updates
= 1.9 =
- Remove translations from the package
- Remove link for donate
- Wp Hide plugin availability notification
- New Filter pto/get_options to allow to change default options; Custom capability can be set for 'capability'
- New Filter pto/admin/plugin_options/capability to allow custom capability option to be inserted within html
= 1.8.9.2 =
- WPDB Prepare argument fix
- User preferance objects per page set to default if empty
= 1.8.9 =
- Add Nonce for admin settings
- Update queries to use prepare
- Drag & Drop Sortable within Post Type archive interface
- Code cleanup
- Set time limit for ajax calls to attempt a code execution extend
= 1.8.7 =
- Admin Post / Page Gallery items order fix
- New filter pto/posts_orderby to ignore sort apply
= 1.8.6 =
- PHP 7 deprecated nottice fix Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP;
- Fix: $_REQUEST['action'] comparison evaluate as Identical instead equal
- New filter cpto/interface_itme_data to append additional data for items within sortable interface
- Slight style updates
- Replaced Socialize FB like page
= 1.8.5 =
- Text domain change to post-types-order to allow translations at https://translate.wordpress.org/projects/wp-plugins/post-types-order
- New query argument ignore_custom_sort , to be used with Autosort. Ignore any customised sort and return posts in default order.
= 1.8.4.1 =
- Sortable interface styling improvements
- Portuguese translation update - Pedro Mendonca - http://www.pedromendonca.pt
- Text doamin fix for few texts
= 1.8.3.1 =
- Advanced Custom Fields Page Rule fix
- Show / Hide Re_order inderface for certain menus. Option available within Settings area.
- Media Sort interface objects order fix, when query-attachments REQUEST
- Bug - Thumbnails test code remove
= 1.8.2 =
- Media Uploaded To after sort fix
= 1.8.1 =
- Next / Previous sorting apply bug fix for custom taxonomies
- Portuguese translation update - Pedro Mendonca - http://www.pedromendonca.pt
- Options - phrase translation fix
= 1.7.9 =
- Next / Previous sorting apply option
- Filter for Next / Previous sorting applpy
- Help updates
- Appearance /css updates
- Admin columns sort fix
- Media re-order
= 1.7.7 =
- Next / Previous post link functionality update
- Code improvements
- Norvegian translation update - Bjorn Johansen bjornjohansen.no
- Czech translation - dUDLAJ; Martin Kucera - http://jsemweb.cz/
= 1.7.4 =
- Japanese translation - Git6 Sosuke Watanabe - http://git6.com/
- Portuguese translation update - Pedro Mendon?a - http://www.pedromendonca.pt
- Chinese translation - Coolwp coolwp.com@gmail.com
= 1.7.0 =
- Swedish translation - Onlinebyran - http://onlinebyran.se
- Portuguese translation - Pedro Mendon?a - http://www.pedromendonca.pt
- AJAX save filter
= 1.6.8 =
- Edit Gallery - image order fix
- "re-order" menu item allow translation
- Hungarian translation - Adam Laki - http://codeguide.hu/
- Minor admin style improvements
= 1.6.5 =
- Updates/Fixes
- German translation
- Norwegian (norsk) translation
= 1.6.4 =
- DISALLOW_FILE_MODS fix, change the administrator capability to switch_themes
= 1.6.3 =
- Updates/Fixes
- Menu Walker nottices Fix
= 1.6.2 =
- Updates/Fixes
- Turkish - T?rk?e translation
= 1.6.1 =
- Updates/Fixes
- Menu Walker nottices Fix
- Hebrew translation - Lunasite Team http://www.lunasite.co.il
- Dutch translation - Denver Sessink
= 1.5.8 =
- Updates/Fixes
- Ignore Search queries when Autosort is ON
- Text Instances translatable fix
- Italian translation - Black Studio http://www.blackstudio.it
- Spanish translation - Marcelo Cannobbio
= 1.5.7 =
- Updates/Fixes
- Using Capabilities instead levels
- Updating certain code for WordPress 3.5 compatibility
- Set default order as seccondary query order param
= 1.5.4 =
- Updates/Fixes
= 1.5.1 =
- Updates/Fixes
= 1.4.6 =
- Get Previous / Next Posts Update
= 1.4.3 =
- Small improvements
= 1.4.1 =
- Re-Order Menu Item Appearance fix for update versions
- Improved post order code
= 1.3.9 =
- Re-Order Menu Item Appearance fix
= 1.3.8 =
- Another Plugin conflict fix (thanks Steve Reed)
- Multiple Improvments (thanks for support Video Geek - bestpocketvideocams.com)
- Localisation Update (thanks Gabriel Reguly - ppgr.com.br/wordpress/)
= 1.1.2 =
- Bug Fix
= 1.0.9 =
- Admin will set the roles which can use the plugins (thanks for support Nick - peerpressurecreative.com)
= 1.0.2 =
- Default order used if no sort occour
= 1.0.1 =
- Post order support implemented
= 1.0 =
- First stable version (thanks for support Andrew - PageLines.com)
= 0.9. =
- Initial Release
== Upgrade Notice ==
Make sure you get the latest version.
== Localization ==
Want to contribute with a translation to your language? Please check at https://translate.wordpress.org/projects/wp-plugins/post-types-order
http://www.nsp-code.com