Skip to content

Instantly share code, notes, and snippets.

@meloniq
Created September 28, 2016 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meloniq/534a2f1ec385fc4ac443bd11a75ed039 to your computer and use it in GitHub Desktop.
Save meloniq/534a2f1ec385fc4ac443bd11a75ed039 to your computer and use it in GitHub Desktop.
[ClassiPress] Make the description field optional
/**
* Mark description field as not required.
*
* @param object $result
* @param object $post
*
* @return object
*/
function childtheme_make_description_not_required( $result, $post ) {
if ( $result->field_name == 'post_content' ) {
$result->field_req = false;
}
return $result;
}
add_filter( 'cp_formbuilder_field', 'childtheme_make_description_not_required', 10, 2 );
/**
* Remove error from validation about empty description field.
*
* @param object $errors
*
* @return object
*/
function childtheme_remove_empty_description_error( $errors ) {
$errors->remove( 'missed-post_content' );
return $errors;
}
add_filter( 'cp_listing_validate_fields', 'childtheme_remove_empty_description_error', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment