Skip to content

Commit

Permalink
Merge pull request #434 from aristath/remove/add_post_meta
Browse files Browse the repository at this point in the history
Remove unnecessary calls to add_post_meta
  • Loading branch information
SteveJonesDev authored Dec 20, 2023
2 parents d6adf40 + a684408 commit 9e9432f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions accessibility-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function edac_include_rules_files() {
}
foreach ( $rules as $rule ) {
if ( ( array_key_exists( 'ruleset', $rule ) && 'php' === $rule['ruleset'] )
|| ( ! array_key_exists( 'ruleset', $rule ) && $rule['slug'] )
|| ( ! array_key_exists( 'ruleset', $rule ) && $rule['slug'] )
) {
require_once plugin_dir_path( __FILE__ ) . 'includes/rules/' . $rule['slug'] . '.php';
}
Expand Down Expand Up @@ -384,9 +384,7 @@ function edac_summary( $post_id ) {
$content_length = $issue_density_array[0][1];
$issue_density = edac_get_issue_density( $issue_count, $element_count, $content_length );

if ( ! add_post_meta( $post_id, '_edac_issue_density', $issue_density, true ) ) {
update_post_meta( $post_id, '_edac_issue_density', $issue_density );
}
update_post_meta( $post_id, '_edac_issue_density', $issue_density );
} else {
delete_post_meta( $post_id, '_edac_issue_density' );
}
Expand Down
6 changes: 2 additions & 4 deletions admin/class-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,7 @@ public function simplified_summary() {
$post_id = intval( $_REQUEST['post_id'] );
$summary = sanitize_text_field( $_REQUEST['summary'] );

if ( ! add_post_meta( $post_id, '_edac_simplified_summary', $summary, true ) ) {
update_post_meta( $post_id, '_edac_simplified_summary', $summary );
}
update_post_meta( $post_id, '_edac_simplified_summary', $summary );

$simplified_summary = get_post_meta( $post_id, '_edac_simplified_summary', $single = true );

Expand All @@ -708,7 +706,7 @@ public function simplified_summary() {
*/
public function dismiss_welcome_cta() {

update_user_meta( get_current_user_id(), 'edac_welcome_cta_dismissed', true );
update_user_meta( get_current_user_id(), 'edac_welcome_cta_dismissed', true );

wp_send_json( 'success' );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function edac_validate( $post_ID, $post, $action ) {
edac_remove_corrected_posts( $post_ID, $post->post_type, $pre = 2, 'php' );

// set post meta checked.
add_post_meta( $post_ID, '_edac_post_checked', true, true );
update_post_meta( $post_ID, '_edac_post_checked', true );

do_action( 'edac_after_validate', $post_ID, $action );
}
Expand Down

0 comments on commit 9e9432f

Please sign in to comment.