-
Notifications
You must be signed in to change notification settings - Fork 139
[Reviews] Extraneous metadata rows added for every post type #887
Copy link
Copy link
Closed
Labels
Type: BugBugs and errorsBugs and errorsgood first issueIf you're a first time contributor this is a good issue for you!If you're a first time contributor this is a good issue for you!hacktoberfestPRs for this issue count towards Hacktoberfest contributions!PRs for this issue count towards Hacktoberfest contributions!help wantedLooking for contributors to assist with this issueLooking for contributors to assist with this issue
Milestone
Description
The review metadata saving is hooked into saved posts and no post type is checked in
| add_action( 'save_post', array( $this, 'save_review_meta_boxes' ) ); |
lifterlms/includes/admin/class.llms.admin.reviews.php
Lines 159 to 187 in cdbee2b
| /** | |
| * This function handles the logic to save the information that is contained | |
| * in the custom metabox. It looks at each of the values, then makes sure that | |
| * there are proper default values so that the program doesn't go crashy crashy | |
| * (nobody likes crashy crashy) | |
| * | |
| * @return void | |
| */ | |
| public function save_review_meta_boxes() { | |
| $enabled = (isset( $_POST['_llms_reviews_enabled'] )) ? $_POST['_llms_reviews_enabled'] : ''; | |
| $display = (isset( $_POST['_llms_display_reviews'] )) ? $_POST['_llms_display_reviews'] : ''; | |
| $num = (isset( $_POST['_llms_num_reviews'] )) ? $_POST['_llms_num_reviews'] : 0; | |
| $multiple = (isset( $_POST['_llms_multiple_reviews_disabled'] )) ? $_POST['_llms_multiple_reviews_disabled'] : ''; | |
| if ( isset( $_POST['post_ID'] ) ) { | |
| update_post_meta( $_POST['post_ID'], '_llms_reviews_enabled', $enabled ); | |
| } | |
| if ( isset( $_POST['post_ID'] ) ) { | |
| update_post_meta( $_POST['post_ID'], '_llms_display_reviews', $display ); | |
| } | |
| if ( isset( $_POST['post_ID'] ) ) { | |
| update_post_meta( $_POST['post_ID'], '_llms_num_reviews', $num ); | |
| } | |
| if ( isset( $_POST['post_ID'] ) ) { | |
| update_post_meta( $_POST['post_ID'], '_llms_multiple_reviews_disabled', $multiple ); | |
| } | |
| } | |
| } |
Additionally, even for posts where there are no reviews (metadata value is empty), the metadata is saved anyway leading to useless rows in the postmeta table. This example is of a certificate:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type: BugBugs and errorsBugs and errorsgood first issueIf you're a first time contributor this is a good issue for you!If you're a first time contributor this is a good issue for you!hacktoberfestPRs for this issue count towards Hacktoberfest contributions!PRs for this issue count towards Hacktoberfest contributions!help wantedLooking for contributors to assist with this issueLooking for contributors to assist with this issue
Type
Projects
Status
Done
