' . 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.2', '<' ) ) { 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 ); 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 ( ! function_exists( 'get_plugin_data' ) ) { /** * Skip check for WP files. * * @psalm-suppress MissingFile */ require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_data = get_plugin_data( __DIR__ . '/woocommerce-paypal-payments.php', false ); $plugin_version = $plugin_data['Version'] ?? null; $installed_plugin_version = get_option( 'woocommerce-ppcp-version' ); if ( $installed_plugin_version !== $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', $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_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), /** * Add "Settings" link to Plugins screen. * * @param array $links * @retun 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 * @retun 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 ); } } ); add_action( 'in_plugin_update_message-woocommerce-paypal-payments/woocommerce-paypal-payments.php', static function( array $plugin_data, \stdClass $new_data ) { if ( version_compare( $plugin_data['Version'], '3.0.0', '<' ) && version_compare( $new_data->new_version, '3.0.0', '>=' ) ) { printf( '
%s: %s', esc_html__( 'Warning', 'woocommerce-paypal-payments' ), esc_html__( 'WooCommerce PayPal Payments version 3.0.0 contains significant changes that may impact your website. We strongly recommend reviewing the changes and testing the update on a staging site before updating it on your production environment.', 'woocommerce-paypal-payments' ) ); } }, 10, 2 ); /** * Check if WooCommerce is active. * * @return bool true if WooCommerce is active, otherwise false. */ function is_woocommerce_activated(): bool { return class_exists( 'woocommerce' ); } } )();