about
7 years ago
css
7 years ago
img
8 years ago
js
7 years ago
menu
8 years ago
partials
7 years ago
scss
7 years ago
settings
7 years ago
admin-notices.php
8 years ago
admin.php
7 years ago
class-strong-testimonials-admin-category-list.php
8 years ago
class-strong-testimonials-admin-list.php
7 years ago
class-strong-testimonials-admin-scripts.php
8 years ago
class-strong-testimonials-defaults.php
7 years ago
class-strong-testimonials-help.php
8 years ago
class-strong-testimonials-list-table.php
7 years ago
class-strong-testimonials-page-shortcodes.php
7 years ago
class-strong-testimonials-post-editor.php
7 years ago
class-strong-testimonials-updater.php
7 years ago
class-strong-views-list-table.php
8 years ago
class-walker-strong-category-checklist.php
7 years ago
class-walker-strong-form-category-checklist.php
7 years ago
compat.php
8 years ago
custom-fields-ajax.php
8 years ago
custom-fields.php
7 years ago
form-preview.php
8 years ago
view-list-order.php
8 years ago
views-ajax.php
7 years ago
views-validate.php
7 years ago
views.php
7 years ago
view-list-order.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Function for managing the last sort order on the view list table per user. |
| 4 | */ |
| 5 | |
| 6 | /** |
| 7 | * Save |
| 8 | */ |
| 9 | function wpmtst_save_view_list_order() { |
| 10 | $name = $_REQUEST['name']; |
| 11 | $order = $_REQUEST['order']; |
| 12 | $success = ''; |
| 13 | if ( in_array( $name, array( 'name', 'id' ) ) ) { |
| 14 | $success = update_user_meta( get_current_user_id(), 'strong_view_list_order', array( $name, $order ) ); |
| 15 | } |
| 16 | echo $success; |
| 17 | wp_die(); |
| 18 | } |
| 19 | add_action( 'wp_ajax_wpmtst_save_view_list_order', 'wpmtst_save_view_list_order' ); |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * Fetch |
| 24 | */ |
| 25 | function wpmtst_fetch_view_list_order() { |
| 26 | global $pagenow; |
| 27 | |
| 28 | if ( $pagenow == 'edit.php' |
| 29 | && isset( $_GET['post_type'] ) |
| 30 | && 'wpm-testimonial' == $_GET['post_type'] |
| 31 | && isset( $_GET['page'] ) |
| 32 | && 'testimonial-views' == $_GET['page'] |
| 33 | && ! isset( $_GET['orderby'] ) |
| 34 | && ! isset( $_GET['action'] ) ) |
| 35 | { |
| 36 | $order = get_user_meta( get_current_user_id(), 'strong_view_list_order', true ); |
| 37 | if ( $order ) { |
| 38 | $url = admin_url( "edit.php?post_type=wpm-testimonial&page=testimonial-views&orderby={$order[0]}&order={$order[1]}" ); |
| 39 | wp_redirect( $url ); |
| 40 | exit; |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | add_action( 'admin_init', 'wpmtst_fetch_view_list_order' ); |
| 45 | |
| 46 | |
| 47 | /** |
| 48 | * Clear |
| 49 | */ |
| 50 | function wpmtst_clear_view_list_order() { |
| 51 | delete_user_meta( get_current_user_id(), 'strong_view_list_order' ); |
| 52 | $url = 'edit.php?post_type=wpm-testimonial&page=testimonial-views'; |
| 53 | wp_redirect( $url ); |
| 54 | } |
| 55 | add_action( 'admin_post_clear-view-sort', 'wpmtst_clear_view_list_order' ); |
| 56 |