From 0e1513f6d99a8f169383ceab934f505dc90ce88d Mon Sep 17 00:00:00 2001 From: Arvind Kala Date: Mon, 8 Feb 2016 12:58:11 +0530 Subject: [PATCH] Added the rank facility, so that you can sort the featured posts too modified: class-ns-featured-posts-admin.php --- class-ns-featured-posts-admin.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/class-ns-featured-posts-admin.php b/class-ns-featured-posts-admin.php index 8253fe2..f2530c3 100644 --- a/class-ns-featured-posts-admin.php +++ b/class-ns-featured-posts-admin.php @@ -239,11 +239,13 @@ function add_featured_column_content( $column, $id ){ if ( $column == 'ns_featured_posts_col' ){ $class = ''; $ns_featured = get_post_meta( $id, '_is_ns_featured_post', true ); + $ns_featured_rank = get_post_meta( $id, '_ns_featured_post_rank', true ); $classes = array('ns_featured_posts_icon'); if ('yes' == $ns_featured) { $classes[] = 'selected'; } - echo ''; + echo ' +

Post Rank: '.$ns_featured_rank.'

'; } } @@ -255,12 +257,19 @@ function add_featured_column_content( $column, $id ){ function nsfp_ajax_featured_post(){ $ns_featured = $_POST['ns_featured']; $id = (int)$_POST['post']; + $ns_featured_post_rank = get_post_meta( $id, '_ns_featured_post_rank', true ); + + if(empty($ns_featured_post_rank)) + $ns_featured_post_rank = 1; + if( !empty( $id ) && $ns_featured !== NULL ) { if ( $ns_featured == 'no' ){ delete_post_meta( $id, "_is_ns_featured_post" ); + delete_post_meta( $id, "_ns_featured_post_rank" ); } else { update_post_meta( $id, "_is_ns_featured_post", 'yes' ); + update_post_meta( $id, "_ns_featured_post_rank", $ns_featured_post_rank ); } } wp_send_json_success(); @@ -367,7 +376,7 @@ function add_featured_meta_boxes(){ function nsfp_meta_box_featured_callback( $post ){ $is_ns_featured_post = get_post_meta( $post->ID, '_is_ns_featured_post', true ); - + $ns_featured_post_rank = get_post_meta( $post->ID, '_ns_featured_post_rank', true ); wp_nonce_field( plugin_basename( __FILE__ ), 'nsfp_featured_metabox_nonce' ); ?>

@@ -375,6 +384,10 @@ function nsfp_meta_box_featured_callback( $post ){ />

+

+ + +