bles ); $feature_warnings = array(); if ( 'custom_order_tables' === $feature_id && 'yes' === get_option( 'woocommerce_api_enabled' ) ) { if ( is_plugin_active( 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php' ) ) { $legacy_api_and_hpos_incompatibility_warning_text = sprintf( // translators: %s is a URL. __( '⚠ The Legacy REST API plugin is installed and active on this site. Please be aware that the WooCommerce Legacy REST API is not compatible with HPOS.', 'woocommerce' ), 'https://wordpress.org/plugins/woocommerce-legacy-rest-api/' ); } else { $legacy_api_and_hpos_incompatibility_warning_text = sprintf( // translators: %s is a URL. __( '⚠ The Legacy REST API is active on this site. Please be aware that the WooCommerce Legacy REST API is not compatible with HPOS.', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=legacy_api' ) ); } /** * Filter to modify the warning text that appears in the HPOS section of the features settings page * when both the Legacy REST API is active (via WooCommerce core or via the Legacy REST API plugin) * and the orders table is in use as the primary data store for orders. * * @param string $legacy_api_and_hpos_incompatibility_warning_text Original warning text. * @returns string|null Actual warning text to use, or null to suppress the warning. * * @since 8.9.0 */ $legacy_api_and_hpos_incompatibility_warning_text = apply_filters( 'woocommerce_legacy_api_and_hpos_incompatibility_warning_text', $legacy_api_and_hpos_incompatibility_warning_text ); if ( ! is_null( $legacy_api_and_hpos_incompatibility_warning_text ) ) { $feature_warnings[] = $legacy_api_and_hpos_incompatibility_warning_text . "\n"; } } if ( $incompatible_count > 0 ) { if ( 1 === $incompatible_count ) { /* translators: %s = printable plugin name */ $feature_warnings[] = sprintf( __( '⚠ 1 Incompatible plugin detected (%s).', 'woocommerce' ), $this->get_plugin_name( $incompatibles[0] ) ); } elseif ( 2 === $incompatible_count ) { $feature_warnings[] = sprintf( /* translators: %1\$s, %2\$s = printable plugin names */ __( '⚠ 2 Incompatible plugins detected (%1$s and %2$s).', 'woocommerce' ), $this->get_plugin_name( $incompatibles[0] ), $this->get_plugin_name( $incompatibles[1] ) ); } else { $feature_warnings[] = sprintf( /* translators: %1\$s, %2\$s = printable plugin names, %3\$d = plugins count */ _n( '⚠ Incompatible plugins detected (%1$s, %2$s and %3$d other).', '⚠ Incompatible plugins detected (%1$s and %2$s plugins and %3$d others).', $incompatible_count - 2, 'woocommerce' ), $this->get_plugin_name( $incompatibles[0] ), $this->get_plugin_name( $incompatibles[1] ), $incompatible_count - 2 ); } $incompatible_plugins_url = add_query_arg( array( 'plugin_status' => 'incompatible_with_feature', 'feature_id' => $feature_id, ), admin_url( 'plugins.php' ) ); $feature_warnings[] = sprintf( /* translators: %1$s opening link tag %2$s closing link tag. */ __( '%1$sView and manage%2$s', 'woocommerce' ), '', '' ); } return str_replace( "\n", '
', implode( "\n", $feature_warnings ) ); } /** * Filter plugin/feature compatibility info, returning the names of the plugins/features that are considered incompatible. * "Uncertain" information will be included or not depending on the value of the value of the 'default_plugin_compatibility' * flag in the feature definition (default is 'compatible'). * * @param string $feature_id Feature id. * @param array $compatibility_info Array containing "compatible', 'incompatible' and 'uncertain' keys. * @return array Items in 'incompatible' and 'uncertain' if plugins are incompatible by default with the feature; only items in 'incompatible' otherwise. */ public function get_items_considered_incompatible( string $feature_id, array $compatibility_info ): array { $incompatible_by_default = FeaturePluginCompatibility::COMPATIBLE !== wc_get_container()->get( FeaturesController::class )->get_default_plugin_compatibility( $feature_id ); return $incompatible_by_default ? array_merge( $compatibility_info['incompatible'], $compatibility_info['uncertain'] ) : $compatibility_info['incompatible']; } /** * Get the names of the plugins that are excluded from the feature compatibility UI. * These plugins won't be considered as incompatible with any existing feature for the purposes * of displaying compatibility warning in UI, even if they declare incompatibilities explicitly. * * @return string[] Plugin names relative to the root plugins directory. */ public function get_plugins_excluded_from_compatibility_ui() { return $this->plugins_excluded_from_compatibility_ui; } }