' . esc_html__( 'Settings saved.', 'renderbit-faq-structured-data' ) . '
';
}
$cache_ttl = isset( $options['cache_ttl'] ) ? intval( $options['cache_ttl'] ) : 12 * HOUR_IN_SECONDS;
$batch_size = isset( $options['batch_size'] ) ? intval( $options['batch_size'] ) : 500;
$output_type = rfsd_normalize_output_type( isset( $options['output_type'] ) ? $options['output_type'] : '' );
?>
' . esc_html__( 'All FAQ transients purged.', 'renderbit-faq-structured-data' ) . '
';
}
?>
get_col(
$wpdb->prepare(
"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s",
$wpdb->esc_like( '_transient_rfsd_faq_json_' ) . '%',
$wpdb->esc_like( '_transient_timeout_rfsd_faq_json_' ) . '%'
)
);
// phpcs:enable
foreach ( $rows as $option_name ) {
delete_option( $option_name );
}
}
return $generation;
}
/**
* Normalize a stored output type. "FAQSection" is not a schema.org type, so legacy and unknown values become FAQPage.
*
* @param mixed $type Stored or posted value.
* @return string
*/
function rfsd_normalize_output_type( $type ) {
unset( $type );
return 'faqpage';
}
/**
* Cached output depends on the output type, so changing it must purge.
*
* @param mixed $old_value Previous settings.
* @param mixed $value New settings.
*/
function rfsd_maybe_purge_on_settings_change( $old_value, $value ) {
$old_type = is_array( $old_value ) && isset( $old_value['output_type'] ) ? rfsd_normalize_output_type( $old_value['output_type'] ) : 'faqpage';
$new_type = is_array( $value ) && isset( $value['output_type'] ) ? rfsd_normalize_output_type( $value['output_type'] ) : 'faqpage';
if ( $old_type !== $new_type ) {
rfsd_purge_all_faq_transients();
}
}
add_action( 'update_option_' . RFSD_OPTION_KEY, 'rfsd_maybe_purge_on_settings_change', 10, 2 );