Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- add_filter( 'manage_edit-mfmchurchactivity_columns', 'my_edit_mfmchurchactivity_columns' ) ;
- function my_edit_mfmchurchactivity_columns( $columns ) {
- $columns = array(
- 'cb' => '<input type="checkbox" />',
- 'title' => __( 'Week' ),
- 'attendance' => __( 'Attendance' ),
- 'punctuality' => __( 'Punctuality' ),
- 'meeting_location' => __( 'Meeting Location' ),
- 'member_group' => __( 'Member Group' ),
- 'donations' => __( 'Donations' ),
- 'payments' => __( 'Payments' ),
- 'branch' => __( 'Branch' ),
- 'region' => __( 'Region' ),
- 'month' => __('Month'),
- 'year' => __( 'Year' ),
- 'country' => __('Country')
- );
- return $columns;
- }
- add_action( 'manage_mfmchurchactivity_posts_custom_column', 'my_manage_mfmchurchactivity_columns', 10, 2 );
- function my_manage_mfmchurchactivity_columns( $column, $post_id ) {
- global $post;
- switch( $column ) {
- /* If displaying the 'attendance' column. */
- case 'attendance' :
- /* Get the post meta. */
- $attendance = get_post_meta( $post_id, '_mfm_churchactivity_s_school_one', true );
- /* If no duration is found, output a default message. */
- if ( empty( $attendance ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf ( __( '%s' ), $attendance );
- break;
- /* If displaying the 'punctuality' column. */
- case 'punctuality' :
- /* Get the post meta. */
- $punctuality = get_post_meta( $post_id, '_mfm_churchactivity_s_service_one', true );
- /* If no duration is found, output a default message. */
- if ( empty( $punctuality ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $punctuality );
- break;
- /* If displaying the 'meeting_location' column. */
- case 'meeting_location' :
- /* Get the post meta. */
- $meeting_location = get_post_meta( $post_id, '_mfm_churchactivity_m_service_one', true );
- /* If no duration is found, output a default message. */
- if ( empty( $meeting_location ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $meeting_location );
- break;
- /* If displaying the 'member_group' column. */
- case 'member_group' :
- /* Get the post meta. */
- $member_group = get_post_meta( $post_id, '_mfm_churchactivity_h_service_one', true );
- /* If no duration is found, output a default message. */
- if ( empty( $member_group ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $member_group );
- break;
- case 'donations' :
- /* Get the post meta. */
- $donations = get_post_meta( $post_id, '_mfm_churchactivity_off_one', true );
- /* If no duration is found, output a default message. */
- if ( empty( $donations ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $donations );
- break;
- case 'payments' :
- /* Get the post meta. */
- $payments = get_post_meta( $post_id, '_mfm_churchactivity_tit_one', true );
- /* If no duration is found, output a default message. */
- if ( empty( $payments ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $payments );
- break;
- case 'branch' :
- /* Get the post meta. */
- $branch = get_post_meta( $post_id, '_mfm_churchactivity_wk_branch', true );
- /* If no duration is found, output a default message. */
- if ( empty( $branch ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $branch );
- break;
- case 'region' :
- /* Get the post meta. */
- $region = get_post_meta( $post_id, '_mfm_churchactivity_wk_region', true );
- /* If no duration is found, output a default message. */
- if ( empty( $region ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $region );
- break;
- case 'month' :
- /* Get the post meta. */
- $month = get_post_meta( $post_id, '_mfm_churchactivity_wk_month', true );
- /* If no duration is found, output a default message. */
- if ( empty( $month ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $month );
- break;
- case 'year' :
- /* Get the post meta. */
- $year = get_post_meta( $post_id, '_mfm_churchactivity_wk_year', true );
- /* If no duration is found, output a default message. */
- if ( empty( $year ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $year );
- break;
- case 'country' :
- /* Get the post meta. */
- $country = get_post_meta( $post_id, '_mfm_churchactivity_wk_country', true );
- /* If no duration is found, output a default message. */
- if ( empty( $country ) )
- echo __( 'Unknown' );
- /* If there is a duration, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $country );
- break;
- case 'year' :
- /* Just break out of the switch statement for everything else. */
- default :
- break;
- }
- }
- add_filter( 'manage_edit-mfmchurchactivity_sortable_columns', 'my_mfmchurchactivity_sortable_columns' );
- function my_mfmchurchactivity_sortable_columns( $columns ) {
- $columns['attendance'] = 'attendance';
- return $columns;
- }
- /*Only run our customization on the 'edit.php' page in the admin. */
- add_action( 'load-edit.php', 'my_edit_mfmchurchactivity_load' );
- function my_edit_mfmchurchactivity_load() {
- add_filter( 'request', 'my_sort_mfmchurchactivity' );
- }
- /* Sorts the movies. */
- function my_sort_mfmchurchactivity( $vars ) {
- /* Check if we're viewing the 'movie' post type. */
- if ( isset( $vars['post_type'] ) && 'mfmchurchactivity' == $vars['post_type'] ) {
- /* Check if 'orderby' is set to 'duration'. */
- if ( isset( $vars['orderby'] ) && 'attendance' == $vars['orderby'] ) {
- /* Merge the query vars with our custom variables. */
- $vars = array_merge(
- $vars,
- array(
- 'meta_key' => '_mfm_churchactivity_s_school_one',
- 'orderby' => 'meta_value_num'
- )
- );
- }
- }
- return $vars;
- }
- add_filter( 'views_edit-mfmchurchactivity', 'meta_views_wpse_94630', 10, 1 );
- function meta_views_wpse_94630( $views )
- {
- //$views['separator'] = ' ';
- $views['metakey'] = '<a href="edit.php?post_type=mfmchurchactivity&_mfm_churchactivity_wk_branch=Ajao">Meta Key</a>';
- return $views;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement