' . sprintf( esc_html__( 'WooCommerce PayPal Payments requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-paypal-payments' ), 'WooCommerce' ) . '

'; } ); return; } if ( version_compare( PHP_VERSION, '7.1', '<' ) ) { add_action( 'admin_notices', function() { echo '

' . esc_html__( 'WooCommerce PayPal Payments requires PHP 7.1 or above.', 'woocommerce-paypal-payments' ), '

'; } ); return; } static $initialized; if ( ! $initialized ) { $bootstrap = require "$root_dir/bootstrap.php"; $app_container = $bootstrap( $root_dir ); $initialized = true; /** * The hook fired after the plugin bootstrap with the app services container as parameter. */ do_action( 'woocommerce_paypal_payments_built_container', $app_container ); } } add_action( 'plugins_loaded', function () { init(); if ( ! function_exists( 'get_plugin_data' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_data = get_plugin_data( __DIR__ . '/woocommerce-paypal-payments.php' ); $plugin_version = $plugin_data['Version'] ?? null; if ( get_option( 'woocommerce-ppcp-version' ) !== $plugin_version ) { /** * The hook fired when the plugin is installed or updated. */ do_action( 'woocommerce_paypal_payments_gateway_migrate' ); update_option( 'woocommerce-ppcp-version', $plugin_version ); } } ); register_activation_hook( __FILE__, function () { init(); /** * The hook fired in register_activation_hook. */ do_action( 'woocommerce_paypal_payments_gateway_activate' ); } ); register_deactivation_hook( __FILE__, function () { init(); /** * The hook fired in register_deactivation_hook. */ do_action( 'woocommerce_paypal_payments_gateway_deactivate' ); } ); // Add "Settings" link to Plugins screen. add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function( $links ) { if ( ! is_woocommerce_activated() ) { return $links; } array_unshift( $links, sprintf( '%2$s', admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' ), __( 'Settings', 'woocommerce-paypal-payments' ) ) ); return $links; } ); /** * Check if WooCommerce is active. * * @return bool true if WooCommerce is active, otherwise false. */ function is_woocommerce_activated(): bool { return class_exists( 'woocommerce' ); } } )();