WC_Install::delete_obsolete_notes()public staticWC 1.0

Delete obsolete notes.

Метод класса: WC_Install{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$result = WC_Install::delete_obsolete_notes();

Код WC_Install::delete_obsolete_notes() WC 8.3.1

public static function delete_obsolete_notes() {
	global $wpdb;
	$obsolete_notes_names = array(
		'wc-admin-welcome-note',
		'wc-admin-insight-first-product-and-payment',
		'wc-admin-store-notice-setting-moved',
		'wc-admin-store-notice-giving-feedback',
		'wc-admin-first-downloadable-product',
		'wc-admin-learn-more-about-product-settings',
		'wc-admin-adding-and-managing-products',
		'wc-admin-onboarding-profiler-reminder',
		'wc-admin-historical-data',
		'wc-admin-manage-store-activity-from-home-screen',
		'wc-admin-review-shipping-settings',
		'wc-admin-home-screen-feedback',
		'wc-admin-update-store-details',
		'wc-admin-effortless-payments-by-mollie',
		'wc-admin-google-ads-and-marketing',
		'wc-admin-insight-first-sale',
		'wc-admin-marketing-intro',
		'wc-admin-draw-attention',
		'wc-admin-welcome-to-woocommerce-for-store-users',
		'wc-admin-need-some-inspiration',
		'wc-admin-choose-niche',
		'wc-admin-start-dropshipping-business',
		'wc-admin-filter-by-product-variations-in-reports',
		'wc-admin-learn-more-about-variable-products',
		'wc-admin-getting-started-ecommerce-webinar',
		'wc-admin-navigation-feedback',
		'wc-admin-navigation-feedback-follow-up',
		'wc-admin-set-up-additional-payment-types',
		'wc-admin-deactivate-plugin',
		'wc-admin-complete-store-details',
	);

	/**
	 * An array of deprecated notes to delete on update.
	 *
	 * @since 6.5.0
	 */
	$additional_obsolete_notes_names = apply_filters(
		'woocommerce_admin_obsolete_notes_names',
		array()
	);

	if ( is_array( $additional_obsolete_notes_names ) ) {
		$obsolete_notes_names = array_merge(
			$obsolete_notes_names,
			$additional_obsolete_notes_names
		);
	}

	$note_names_placeholder = substr( str_repeat( ',%s', count( $obsolete_notes_names ) ), 1 );

	$note_ids = $wpdb->get_results(
		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Ignored for allowing interpolation in the IN statement.
		$wpdb->prepare(
			"SELECT note_id FROM {$wpdb->prefix}wc_admin_notes WHERE name IN ( $note_names_placeholder )",
			$obsolete_notes_names
		),
		ARRAY_N
		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
	);

	if ( ! $note_ids ) {
		return;
	}

	$note_ids             = array_column( $note_ids, 0 );
	$note_ids_placeholder = substr( str_repeat( ',%d', count( $note_ids ) ), 1 );

	$wpdb->query(
		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Ignored for allowing interpolation in the IN statement.
		$wpdb->prepare(
			"DELETE FROM {$wpdb->prefix}wc_admin_notes WHERE note_id IN ( $note_ids_placeholder )",
			$note_ids
		)
		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
	);

	$wpdb->query(
		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Ignored for allowing interpolation in the IN statement.
		$wpdb->prepare(
			"DELETE FROM {$wpdb->prefix}wc_admin_note_actions WHERE note_id IN ( $note_ids_placeholder )",
			$note_ids
		)
		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
	);
}