PluginProbe
YayMail – WooCommerce Email Customizer / 3.4
YayMail – WooCommerce Email Customizer v3.4
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / includes / License / LicensingPlugin.php

LicensingPlugin.php in YayMail – WooCommerce Email Customizer 3.4, at includes/License/LicensingPlugin.php

61 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\License;
4
5 use YayMail\License\LicenseHandler;
6 use YayMail\License\LicenseAPI;
7 use YayMail\License\License;
8
9 class LicensingPlugin {
10
11 public $slug = null;
12
13 protected $plugin_info = null;
14
15 protected $license = null;
16
17 public function __construct( $slug ) {
18 $this->slug = $slug;
19 $licensing_plugins = LicenseHandler::get_licensing_plugins();
20 $matching_position = array_search( $this->slug, array_column( $licensing_plugins, 'slug' ) );
21 if ( false !== $matching_position ) {
22 $this->plugin_info = $licensing_plugins[ $matching_position ];
23 }
24 $this->license = new License( $slug );
25 }
26
27 public function get_option( $key ) {
28 if ( $this->plugin_info ) {
29 return $this->plugin_info[ $key ];
30 }
31 return null;
32 }
33
34 public function get_license() {
35 return $this->license;
36 }
37
38 public function get_version_info() {
39 $info = get_option( $this->slug . '_version_info' );
40 $info = is_string( $info ) ? \json_decode( $info, true ) : $info;
41 return $info;
42 }
43
44 public function set_version_info( $data ) {
45 update_option( $this->slug . '_version_info', $data );
46 }
47
48 public function update_version_info() {
49 $license = $this->license;
50 if ( $license instanceof License ) {
51 $license_key = $license->get_license_key();
52 $item_id = $this->get_option( 'item_id' );
53 $response = LicenseAPI::get_version( $item_id, $license_key );
54 if ( $response ) {
55 $this->set_version_info( $response );
56 }
57 }
58 }
59
60 }
61