Skip to content

Instantly share code, notes, and snippets.

@BoDonkey
Last active March 7, 2019 11:29
Show Gist options
  • Save BoDonkey/ca150207992aaf6c9beb5b031a299628 to your computer and use it in GitHub Desktop.
Save BoDonkey/ca150207992aaf6c9beb5b031a299628 to your computer and use it in GitHub Desktop.
Remove the 'Divi' post status
/**
* Remove 'Divi' from post states.
*
* @param array $post_states Existing post states.
* @param object $post Current post object.
*
* @return array
*/
function divi_removal_filter( $post_states, $post ){
// Make sure that $post_states is an array. Third party plugin might modify $post_states and makes it null which can create issues
if ( ! is_array( $post_states ) ) {
$post_states = array();
}
//Check if Divi was used to create the page and remove the 'Divi' status if it exists
if ( et_pb_is_pagebuilder_used( $post->ID ) ) {
$key = array_search( 'Divi', $post_states );
if ( false !== $key ) {
unset( $post_states[ $key ] );
}
}
return $post_states;
}
//Make sure that the filter has a LOWER priority than the filter used to put the Divi post state in originally (10)
add_filter( 'display_post_states', 'change_post_states', 11, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment