Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reviews] Extraneous metadata rows added for every post type #887

Closed
actual-saurabh opened this issue Jun 21, 2019 · 0 comments
Closed

[Reviews] Extraneous metadata rows added for every post type #887

actual-saurabh opened this issue Jun 21, 2019 · 0 comments
Labels
good first issue If you're a first time contributor this is a good issue for you! hacktoberfest PRs for this issue count towards Hacktoberfest contributions! help wanted Looking for contributors to assist with this issue Type: Bug Bugs and errors

Comments

@actual-saurabh
Copy link
Contributor

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' ) );
and
/**
* 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:

Screenshot 2019-06-21 at 9 22 04 PM

@actual-saurabh actual-saurabh added Type: Bug Bugs and errors help wanted Looking for contributors to assist with this issue good first issue If you're a first time contributor this is a good issue for you! hacktoberfest PRs for this issue count towards Hacktoberfest contributions! language: php labels Jun 21, 2019
@actual-saurabh actual-saurabh added this to the Scrub June 2019 milestone Jun 21, 2019
@actual-saurabh actual-saurabh changed the title [Reviews] Extraneous post metadata added to every post type [Reviews] Extraneous metadata rows added for every post type Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue If you're a first time contributor this is a good issue for you! hacktoberfest PRs for this issue count towards Hacktoberfest contributions! help wanted Looking for contributors to assist with this issue Type: Bug Bugs and errors
Projects
Archived in project
Development

No branches or pull requests

3 participants