Created
September 28, 2016 06:13
-
-
Save meloniq/534a2f1ec385fc4ac443bd11a75ed039 to your computer and use it in GitHub Desktop.
[ClassiPress] Make the description field optional
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
/** | |
* 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