PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.4
YayMail – WooCommerce Email Customizer v4.3.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 / src / License / LicensingPlugin.php

LicensingPlugin.php in YayMail – WooCommerce Email Customizer 4.3.4, at src/License/LicensingPlugin.php

65 lines 1.7 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 /**
10 * LicensingPlugin
11 *
12 * @package LicensingPlugin
13 */
14 class LicensingPlugin {
15
16 public $slug = null;
17
18 protected $plugin_info = null;
19
20 protected $license = null;
21
22 public function __construct( $slug ) {
23 $this->slug = $slug;
24 $licensing_plugins = LicenseHandler::get_licensing_plugins();
25 $matching_position = array_search( $this->slug, array_column( $licensing_plugins, 'slug' ) );
26 if ( false !== $matching_position ) {
27 $this->plugin_info = $licensing_plugins[ $matching_position ];
28 }
29 $this->license = new License( $slug );
30 }
31
32 public function get_option( $key ) {
33 if ( $this->plugin_info ) {
34 return $this->plugin_info[ $key ];
35 }
36 return null;
37 }
38
39 public function get_license() {
40 return $this->license;
41 }
42
43 public function get_version_info() {
44 $info = get_option( $this->slug . '_version_info' );
45 $info = is_string( $info ) ? \json_decode( $info, true ) : $info;
46 return $info;
47 }
48
49 public function set_version_info( $data ) {
50 update_option( $this->slug . '_version_info', $data );
51 }
52
53 public function update_version_info() {
54 $license = $this->license;
55 if ( $license instanceof License ) {
56 $license_key = $license->get_license_key();
57 $item_id = $this->get_option( 'item_id' );
58 $response = LicenseAPI::get_version( $item_id, $license_key );
59 if ( $response ) {
60 $this->set_version_info( $response );
61 }
62 }
63 }
64 }
65