printf( '
%1$s

%2$s

', esc_html__( 'The plugin WooCommerce PayPal Payments has been deactivated', 'woocommerce-paypal-payments' ), wp_kses( sprintf( // translators: %s is a link to install WooCommerce. esc_html__( 'WooCommerce PayPal Payments requires WooCommerce to be installed and active. %s', 'woocommerce-paypal-payments' ), sprintf( '%s', esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=woocommerce' ) ), esc_html__( 'You can download WooCommerce here.', 'woocommerce-paypal-payments' ) ) ), array( 'a' => array( 'href' => array(), 'target' => array(), ), ) ) ) ); return; } if ( version_compare( PHP_VERSION, '7.4', '<' ) ) { show_admin_notice_and_deactivate( static fn() => printf( '
%1$s

%2$s

', esc_html__( 'The plugin WooCommerce PayPal Payments has been deactivated', 'woocommerce-paypal-payments' ), esc_html__( 'WooCommerce PayPal Payments requires PHP 7.4 or above.', 'woocommerce-paypal-payments' ) ) ); return; } static $initialized; if ( ! $initialized ) { $bootstrap = require "$root_dir/bootstrap.php"; $app_container = $bootstrap( $root_dir ); PPCP::init( $app_container ); $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 ( ! is_woocommerce_activated() ) { return; } add_action( 'init', function () { $current_plugin_version = (string) PPCP::container()->get( 'ppcp.plugin' )->getVersion(); $installed_plugin_version = get_option( 'woocommerce-ppcp-version' ); if ( $installed_plugin_version !== $current_plugin_version ) { /** * The hook fired when the plugin is installed or updated. */ do_action( 'woocommerce_paypal_payments_gateway_migrate', $installed_plugin_version ); if ( $installed_plugin_version ) { /** * The hook fired when the plugin is updated. */ do_action( 'woocommerce_paypal_payments_gateway_migrate_on_update' ); } update_option( 'woocommerce-ppcp-version', $current_plugin_version ); } }, -1 ); } ); 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_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), /** * Add "Settings" link to Plugins screen. * * @param array $links * @return array */ 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&ppcp-tab=' . Settings::CONNECTION_TAB_ID ), __( 'Settings', 'woocommerce-paypal-payments' ) ) ); return $links; } ); add_filter( 'plugin_row_meta', /** * Add links below the description on the Plugins page. * * @param array $links * @param string $file * @return array */ function( $links, $file ) { if ( plugin_basename( __FILE__ ) !== $file ) { return $links; } return array_merge( $links, array( sprintf( '%2$s', 'https://woocommerce.com/document/woocommerce-paypal-payments/', __( 'Documentation', 'woocommerce-paypal-payments' ) ), sprintf( '%2$s', 'https://woocommerce.com/document/woocommerce-paypal-payments/#get-help', __( 'Get help', 'woocommerce-paypal-payments' ) ), sprintf( '%2$s', 'https://woocommerce.com/feature-requests/woocommerce-paypal-payments/', __( 'Request a feature', 'woocommerce-paypal-payments' ) ), sprintf( '%2$s', 'https://github.com/woocommerce/woocommerce-paypal-payments/issues/new?assignees=&labels=type%3A+bug&template=bug_report.md', __( 'Submit a bug', 'woocommerce-paypal-payments' ) ), ) ); }, 10, 2 ); add_action( 'before_woocommerce_init', function() { if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { /** * Skip WC class check. * * @psalm-suppress UndefinedClass */ \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); } } ); /** * Check if WooCommerce is active. * * @return bool true if WooCommerce is active, otherwise false. */ function is_woocommerce_activated(): bool { return class_exists( 'woocommerce' ); } add_action( 'woocommerce_paypal_payments_gateway_migrate', /** * Set new merchant flag on plugin install. * * When installing the plugin for the first time, we direct the user to * the new UI without a data migration, and fully hide the #legacy-ui. * * @param string|false $version String with previous installed plugin version. * Boolean false on first installation on a new site. */ static function ( $version ) { if ( ! $version ) { update_option( 'woocommerce-ppcp-is-new-merchant', '1' ); } } ); } )();