$value){ $new_columns[$key] = $value; if($key == 'title'){ $new_columns['aFSPrior_column'] = 'Priority'; $new_columns['aFSldTyp_column'] = 'Type'; } } return $new_columns; } return $columns; } add_filter('manage_edit-slides_sortable_columns','aFS_manage_sortable_columns'); function aFS_manage_sortable_columns($sortable_columns){ $sortable_columns['aFSPrior_column'] = 'aFSPrior'; $sortable_columns['aFSldTyp_column'] = 'aFSldTyp'; return $sortable_columns; } add_action('manage_posts_custom_column','aFS_manage_posts_custom_column',10,2); function aFS_manage_posts_custom_column($column_name,$post_id){ switch($column_name){ case 'aFSPrior_column': echo '
'.get_post_meta($post_id,'aFSPrior',true).'
'; break; case 'aFSldTyp_column': echo '
'.get_post_meta($post_id,'aFSldTyp',true).'
'; break; } } add_action('pre_get_posts','aFS_pre_get_posts',1); function aFS_pre_get_posts($query){ if($query->is_main_query() && ($orderby = $query->get('orderby'))){ switch($orderby){ case 'aFSPrior': $query->set('meta_key','aFSPrior'); $query->set('orderby','meta_value_num'); break; case 'aFSldTyp': $query->set('meta_key','aFSldTyp'); $query->set('orderby','meta_value'); break; } } } /* Q U I C K E D I T & B U L K E D I T =========================================== */ add_action('bulk_edit_custom_box','aFS_bulk_quick_edit_custom_box',10,2); add_action('quick_edit_custom_box','aFS_bulk_quick_edit_custom_box',10,2); function aFS_bulk_quick_edit_custom_box($column_name,$post_type){ switch($post_type){ case 'slides': switch($column_name){ case 'aFSPrior_column': ?>
post_type) && $post->post_type == 'revision')return $post_id; // if(!current_user_can('edit_post'))return $post_id; // Note: this Breaks Quick Edit $custom_fields = array('aFSPrior','aFSldTyp','aFSClass', 'aFSBgdOn','aFSBgd_Z','aFSBgImg','aFSBgdFx','aFSBgdFl','aFSBgdRp','aFSBgdGr','aFSBgdCo','aFSBgdOp','aFSBgdXY','aFSBgdHL', 'aFSMnIOn','aFSMnImg','aFSMnLnk','aFSMTarg','aFSMnAlt'); if(isset($_POST['aFSUpdateFlag'])){ if(isset($_POST['aFSMBNonce']) && !wp_verify_nonce($_POST['aFSMBNonce'],'aFSNonce'))return $post_id; foreach($custom_fields as $field){ if(isset($_POST[$field])){ update_post_meta($post_id,$field,$_POST[$field]); } else{ delete_post_meta($post_id,$field); } } } else{ if(isset($_POST['_inline_edit']) && !wp_verify_nonce($_POST['_inline_edit'],'inlineeditnonce'))return $post_id; foreach($custom_fields as $field){ if(isset($_POST[$field]))update_post_meta($post_id,$field,$_POST[$field]); } } } add_action('wp_ajax_aFS_bulk_quick_save_edit','aFS_bulk_quick_save_edit'); function aFS_bulk_quick_save_edit(){ // we need the post IDs $post_ids =(isset($_POST['post_ids']) && !empty($_POST['post_ids']))? $_POST['post_ids'] : NULL; // if we have post IDs if(!empty($post_ids) && is_array($post_ids)){ // get the custom fields $custom_fields = array('aFSPrior','aFSldTyp'); foreach($custom_fields as $field){ // if it has a value,doesn't update if empty on bulk if(isset($_POST[ $field]) && !empty($_POST[ $field])){ // update for each post ID foreach($post_ids as $post_id){ update_post_meta($post_id,$field,$_POST[$field]); } } } } }