Last active
August 29, 2015 14:23
-
-
Save mt8/cd5102c0562e4145594c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! function_exists( 'mw_wp_form_colored_status' ) ) : | |
function mw_wp_form_colored_status( $classes, $class, $ID ) | |
{ | |
if ( ! in_array( 'mw-wp-form/mw-wp-form.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
return $classes; | |
} | |
if ( 'edit.php' !== basename( $_SERVER['PHP_SELF'] ) ) { | |
return $classes; | |
} | |
if ( ! isset( $_REQUEST['post_type'] ) || ! post_type_exists( $_REQUEST['post_type'] ) || false === strpos( $_REQUEST['post_type'], MWF_Config::DBDATA ) ) { | |
return $classes; | |
} | |
foreach ( $classes as $key => $value ) { | |
if ( $value == 'status-publish' ) { | |
unset( $classes[$key] ); | |
} | |
} | |
$meta = get_post_meta( $ID, MWF_Config::CONTACT_DATA_NAME, true ); | |
if ( ! is_array( $meta ) || ! array_key_exists( 'response_status', $meta ) ) { | |
$classes[] = 'status-draft'; | |
return $classes; | |
} | |
switch ( $meta['response_status'] ) { | |
case 'reservation': | |
$classes[] = 'status-pending'; | |
break; | |
case 'supported': | |
$classes[] = 'status-publish'; | |
break; | |
case 'not-supported': | |
default : | |
$classes[] = 'status-draft'; | |
break; | |
} | |
return $classes; | |
} | |
add_filter( 'post_class', 'mw_wp_form_colored_status', 10, 3 ); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment