ryanjs (July 30th, 2015)
/** * Validates the posted fields on an Create/Edit project form. * * @uses apply_filters() Calls 'hrb_project_validate_fields' * */ function validate_fields( $order, $checkout ){ global $hrb_options; if ( empty( $_POST['post_title'] ) ) { appthemes_add_notice( 'no-title', __( 'No title was submitted.', APP_TD ) ); } if ( empty( $_POST['budget_price'] ) || ! intval( $_POST['budget_price'] ) ) { appthemes_add_notice( 'invalid-price', __( 'Please insert a valid budget price.', APP_TD ) ); } if ( ! hrb_charge_listings() && ( isset( $_POST['duration'] ) && $hrb_options->project_duration < (int) $_POST['duration'] ) ) { appthemes_add_notice( 'invalid-duration', sprintf( __( 'The project duration must be equal or inferior to %d.', APP_TD ), $hrb_options->project_duration ) ); } if ( ! hrb_charge_listings() && ( ! isset( $_POST['duration'] ) && $hrb_options->project_duration > 0 ) ) { appthemes_add_notice( 'empty-duration', __( 'The project duration cannot be empty.', APP_TD ) ); } $project_categories = _hrb_posted_terms( HRB_PROJECTS_CATEGORY ); if ( ! $project_categories ) { appthemes_add_notice( 'wrong-cat', __( 'No category was submitted.', APP_TD ) ); } if ( ! empty( $_REQUEST['ID'] ) ) { $project_id = (int) $_REQUEST['ID']; // make sure the categories were not changed after editing a purchased Project if ( ! hrb_categories_editable( $project_id ) ) { $terms = get_the_hrb_project_terms( $project_id, HRB_PROJECTS_CATEGORY ); $diff_cats = hrb_parent_terms_diff( $terms, $project_categories ); if ( ! empty( $diff_cats ) ) { appthemes_add_notice( 'hack-cat', __( 'Categories cannot be changed after purchase!', APP_TD ) ); } } } APP_Notices::$notices = apply_filters( 'hrb_project_validate_fields', APP_Notices::$notices, $order, $checkout ); if ( APP_Notices::$notices->get_error_code() ) { return false; } return true; }
ryanjs (July 30th, 2015)
There are currently 1 users browsing this thread. (0 members and 1 guests)