* * @see http://wcpos.com * @package WCPOS\WooCommercePOS */ namespace WCPOS\WooCommercePOS\Admin; use WCPOS\WooCommercePOS\Services\Analytics; use const WCPOS\WooCommercePOS\PLUGIN_FILE; use const WCPOS\WooCommercePOS\VERSION; /** * Plugins class. */ class Plugins { /** * Constructor. */ public function __construct() { add_filter( 'plugin_action_links_' . PLUGIN_FILE, array( $this, 'plugin_action_links' ) ); add_action( 'in_plugin_update_message-' . PLUGIN_FILE, array( $this, 'plugin_update_message' ), 10, 2 ); } /** * Filters the list of action links displayed for a specific plugin in the Plugins list table. * * @param string[] $actions An array of plugin action links. */ public function plugin_action_links( array $actions ): array { $settings = array( 'settings' => '' . // translators: Plugin row action link that opens WCPOS settings. __( 'Settings', 'woocommerce-pos' ) . '', ); // Add "Upgrade to Pro" link if Pro is not installed. if ( ! defined( 'WCPOS\WooCommercePOSPro\VERSION' ) ) { Analytics::instance()->capture_once( 'upgrade_cta_viewed', array( 'placement' => 'plugin_row_action', ), 'plugin_row_action', Analytics::AMBIENT_IMPRESSION_TTL ); $actions['upgrade'] = '' . /* translators: Plugin admin screen label or notice for WCPOS. */ __( 'Upgrade to Pro', 'woocommerce-pos' ) . ''; } return $settings + $actions; } /** * Fires at the end of the update message container in each row of the plugins list table. * Thanks to: http://andidittrich.de/2015/05/howto-upgrade-notice-for-wordpress-plugins.html. * * @param array $plugin_data An array of plugin metadata. * @param object $r An object of metadata about the available plugin update. * * @since 2.8.0 */ public function plugin_update_message( $plugin_data, $r ): void { // Check if updating to v1.8.x from an earlier version. $new_version = isset( $r->new_version ) ? $r->new_version : ''; $current_version = VERSION; // Show major update notice when upgrading to 1.8.x from earlier versions. // @phpstan-ignore-next-line. if ( version_compare( $new_version, '1.8.0', '>=' ) && version_compare( $current_version, '1.8.0', '<' ) ) { $this->show_major_update_notice(); } // Show any additional upgrade notice from readme.txt. if ( isset( $r->upgrade_notice ) && \strlen( trim( $r->upgrade_notice ) ) > 0 ) { echo '

' . // translators: Prefix for an important plugin update notice in the WordPress plugins screen. esc_html__( 'Important:', 'woocommerce-pos' ) . ' '; echo esc_html( $r->upgrade_notice ), '

'; } } /** * Display a major update notice for v1.8. */ private function show_major_update_notice(): void { ?>

wcpos.com/my-account' ); ?>