Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.