Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the way of checking if WooCommerce is active #498

Merged
merged 3 commits into from
Feb 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions woocommerce-paypal-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
function init() {
$root_dir = __DIR__;

if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
if ( ! is_woocommerce_activated() ) {
add_action(
'admin_notices',
function() {
Expand Down Expand Up @@ -112,10 +109,7 @@ function () {
add_filter(
'plugin_action_links_' . plugin_basename( __FILE__ ),
function( $links ) {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
if ( ! is_woocommerce_activated() ) {
return $links;
}

Expand All @@ -132,4 +126,13 @@ function( $links ) {
}
);

/**
* Check if WooCommerce is active.
*
* @return bool true if WooCommerce is active, otherwise false.
*/
function is_woocommerce_activated(): bool {
return class_exists( 'woocommerce' );
}

} )();