ID < 1) { return $query_object; } $options = wbsoft_order_plugin_options(); if (is_admin()) { return false; } if ($options['auto_sort'] == "1") { $query_object->set('suppress_filters', false); } return $query_object; } /** * Add menu_order if auto sort is checked */ add_filter('posts_orderby', 'wbsoft_order_posts_orderby', 99, 2); function wbsoft_order_posts_orderby($order_by, $query_object) { global $wpdb; $options = wbsoft_order_plugin_options(); //Ignore search if($query_object->is_search()) return($order_by); if ($options['auto_sort'] == "1") $order_by = "{$wpdb->posts}.menu_order, " . $order_by; return $order_by; } add_action('admin_menu', 'wbsoft_order_add_admin_menu' ); /** * Add menu to admin section * */ function wbsoft_order_add_admin_menu() { $options = wbsoft_order_plugin_options(); //Check Current User Roles if (!current_user_can(WBSOFT_ORDER_PLUGIN_CAN_SORT)) { return; } //Add order posts section over all post types $post_types = get_post_types(); foreach( $post_types as $post_type ) { //Ignore BBPress if($post_type == 'reply' || $post_type == 'topic' || $post_type == 'forum') continue; //Add Attachment Order if($post_type == 'attachment') { add_submenu_page('upload.php', __('Custom Order', 'wbso'), __('Custom Order', 'wbso'), WBSOFT_ORDER_PLUGIN_CAN_SORT, 'custom-order-'.$post_type, 'wbsoft_order_show_order_page'); } if ($post_type == 'post') { add_submenu_page('edit.php', __('Custom Order', 'wbso'), __('Custom Order', 'wbso'), WBSOFT_ORDER_PLUGIN_CAN_SORT, 'custom-order-'.$post_type, 'wbsoft_order_show_order_page'); }else{ // if (!is_post_type_hierarchical($post_type)) add_submenu_page('edit.php?post_type='.$post_type, 'Custom Order', 'Custom Order', WBSOFT_ORDER_PLUGIN_CAN_SORT, 'custom-order-'.$post_type, 'wbsoft_order_show_order_page'); } } } function wbsoft_order_get_post_type() { $post_type = null; if ( isset($_GET['page']) && strpos($_GET['page'], 'custom-order-') !== false ) { $post_type = get_post_type_object(str_replace( 'custom-order-', '', $_GET['page'] )); } return $post_type; } function wbsoft_order_show_order_page() { $post_type = wbsoft_order_get_post_type(); ?>
Invalid Request!

labels->singular_name . ' - '. __('Custom Order', 'wbso') ?>

0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order', 'link_before' => '', 'link_after' => '', 'walker' => '' ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $output = ''; $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']); $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array(); $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) ); // Query pages. $r['hierarchical'] = 0; $args = array( 'sort_column' => 'menu_order', 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ); if($post_type == 'attachment') $args['post_status'] = 'any'; $the_query = new WP_Query($args); $pages = $the_query->posts; if ( !empty($pages) ) { if ( $r['title_li'] ) $output .= ''; } $output = apply_filters('wp_list_pages', $output, $r); if ( $r['echo'] ) echo $output; else return $output; } function wbsoft_order_walk_tree($pages, $depth, $r) { if ( empty($r['walker']) ) $walker = new WbSoft_Order_Walker; else $walker = $r['walker']; $args = array($pages, $depth, $r); return call_user_func_array(array(&$walker, 'walk'), $args); } add_action('admin_init', 'wbsoft_order_enqueue_files'); /** * Load Scripts and Stylesheets * */ function wbsoft_order_enqueue_files() { if(wbsoft_order_get_post_type()) { wp_enqueue_style('wbsoft-order-stylesheet', WBSOFT_ORDER_PLUGIN_URL . '/css/wbsoft-order.css'); wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-sortable'); } } add_action( 'wp_ajax_update-custom-type-order', 'wbsoft_order_save_sort_results' ); /** * Save Customer Order */ function wbsoft_order_save_sort_results() { global $wpdb; parse_str($_POST['results'], $data); if(is_array($data)) { foreach($data as $key => $values) { if($key == 'item'){ foreach($values as $position => $id) { $wpdb->update($wpdb->posts, array('menu_order' => $position/*, 'post_parent' => 0*/), array('ID' => $id)); } }/*else{ foreach($values as $position => $id) { $wpdb->update($wpdb->posts, array('menu_order' => $position, 'post_parent' => str_replace('item_', '', $key)), array('ID' => $id)); } }*/ } } }