term_id = $termId; $term->priority = null; $term->frequency = 'default'; $term->save(); } /** * Handles metabox saving. * * @since 4.0.3 * * @param int $termId Term ID. * @return void */ public function saveTermSettingsMetabox( $termId ) { // Security check if ( ! isset( $_POST['TermSettingsNonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['TermSettingsNonce'] ), 'aioseoTermSettingsNonce' ) ) { return; } // If we don't have our term settings input, we can safely skip. if ( ! isset( $_POST['aioseo-term-settings'] ) ) { return; } $currentTerm = json_decode( stripslashes( $_POST['aioseo-term-settings'] ), true ); // phpcs:ignore HM.Security.ValidatedSanitizedInput // If there is no data, there likely was an error, e.g. if the hidden field wasn't populated on load and the user saved the post without making changes in the metabox. // In that case we should return to prevent a complete reset of the data. if ( empty( $currentTerm ) ) { return; } Models\Term::saveTerm( $termId, $currentTerm ); } }