name = $name; // handle backwards compatibility. if ( ! empty( $file ) ) { $this->file = $file; $this->public_token = $public_token; } else { $this->file = $public_token; } $this->set_basename_and_slug(); $this->license(); $this->activation(); $this->updater(); } /** * Initialize plugin/theme updater * * @return SureCartQuickWebP\Updater */ public function updater() { if ( ! class_exists( __NAMESPACE__ . '\Updater' ) ) { require_once __DIR__ . '/Updater.php'; } // if already instantiated, return the cached one. $this->updater = $this->updater ? $this->updater : new Updater( $this ); return $this->updater; } /** * Initialize license model * * @return SureCartQuickWebP\Licensing */ public function license() { if ( ! class_exists( __NAMESPACE__ . '\License' ) ) { require_once __DIR__ . '/License.php'; } // if already instantiated, return the cached one. $this->license = $this->license ? $this->license : new License( $this ); return $this->license; } /** * Initialize activation model * * @return SureCartQuickWebP\Licensing */ public function activation() { if ( ! class_exists( __NAMESPACE__ . '\Activation' ) ) { require_once __DIR__ . '/Activation.php'; } // if already instantiated, return the cached one. $this->activation = $this->activation ? $this->activation : new Activation( $this ); return $this->activation; } /** * Initialize settings page * * @return SureCartQuickWebP\Licensing */ public function settings() { if ( ! class_exists( __NAMESPACE__ . '\Settings' ) ) { require_once __DIR__ . '/Settings.php'; } // if already instantiated, return the cached one. $this->settings = $this->settings ? $this->settings : new Settings( $this ); return $this->settings; } /** * API Endpoint * * @return string */ public function endpoint() { // allow a constant to be set. if ( defined( 'SURECART_LICENSING_ENDPOINT' ) ) { return trailingslashit( SURECART_LICENSING_ENDPOINT ); } // filterable endpoint. // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound return trailingslashit( apply_filters( 'surecart_licensing_endpoint', 'https://api.surecart.com' ) ); } /** * Set project basename, slug and version * * @return void */ protected function set_basename_and_slug() { // it's a plugin. if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) { $this->basename = plugin_basename( $this->file ); list( $this->slug ) = explode( '/', $this->basename ); require_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugin_data = get_plugin_data( $this->file ); if ( empty( $plugin_data['Version'] ) ) { add_action( 'admin_notices', function() { printf( '
' . esc_html( $this->name ) . ' Licensing Configuration Error: The __FILE__ must point to the main file of your plugin.
' . esc_html( $this->name ) . ' Licensing Configuration Error: The __FILE__ must point to the main file of your theme.