PluginProbe
Team Members Showcase / trunk
Team Members Showcase vtrunk
4.1.3 4.1.2 4.1.1 4.1.0 4.0.1 4.0.0 trunk 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.8 2.9.9 3.0.0 3.1.0 3.1.1 3.1.5 3.2.3 3.3.0 3.3.1 3.3.2 3.3.4 All 41 releases
wps-team / initialize.php

initialize.php in Team Members Showcase trunk, at initialize.php

107 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPSpeedo_Team;
4
5 if ( ! defined('ABSPATH') ) exit;
6
7 class Initialize {
8
9 public function __construct() {
10
11 if ( ! version_compare( PHP_VERSION, '7.4', '>=' ) ) {
12 return add_action( 'admin_notices', array( $this, 'fail_php_version' ) );
13 }
14
15 if ( ! version_compare( get_bloginfo( 'version' ), '5.9', '>=' ) ) {
16 return add_action( 'admin_notices', array( $this, 'fail_wp_version' ) );
17 }
18
19 add_action( 'plugins_loaded', array( $this, 'load_freemius' ), 5 );
20 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
21 add_action( 'plugins_loaded', array( $this, 'save_install_time' ) );
22 add_action( 'plugins_loaded', array( $this, 'initialize' ) );
23
24 add_action( 'admin_head', [ $this, 'load_admin_icon_css' ] );
25
26 }
27
28 function load_freemius() {
29 require_once WPS_TEAM_PATH . 'freemius.php';
30 }
31
32 function load_admin_icon_css() {
33 echo "<style>#adminmenu .menu-icon-wps-team-members .wp-menu-image img{padding-top:8px;width:22px;opacity:.8;height:auto;}</style>";
34 }
35
36 public function load_textdomain() {
37 // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound
38 load_plugin_textdomain( 'wps-team', false, dirname( plugin_basename( WPS_TEAM_FILE ) ) . '/languages/' );
39 }
40
41 public function save_install_time() {
42 $installed_time = get_option( '_wps_team_installed_time' );
43 if ( ! $installed_time ) {
44 update_option( '_wps_team_installed_time', time() );
45 }
46 }
47
48 public function fail_php_version() {
49 $message = '<strong>WPS Team</strong> ' . sprintf(
50 /* translators: %s: Required PHP version */
51 esc_html_x(
52 'plugin requires PHP version %s+, plugin is currently NOT RUNNING.',
53 'Dashboard',
54 'wps-team'
55 ),
56 '7.4'
57 );
58
59 echo wp_kses_post( sprintf( '<div class="error">%s</div>', wpautop( $message ) ) );
60 }
61
62 public function fail_wp_version() {
63 $message = '<strong>WPS Team</strong> ' . sprintf(
64 /* translators: %s: Required WordPress version */
65 esc_html_x(
66 'plugin requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT RUNNING.',
67 'Dashboard',
68 'wps-team'
69 ),
70 '5.9'
71 );
72
73 echo wp_kses_post( sprintf( '<div class="error">%s</div>', wpautop( $message ) ) );
74 }
75
76 function maybe_update_version() {
77 if ( WPS_TEAM_VERSION === get_option('wps_team_version') ) return false;
78 Upgrader::instance( get_option('wps_team_version'), WPS_TEAM_VERSION );
79 update_option( 'wps_team_version', WPS_TEAM_VERSION );
80 plugin()->assets->assets_purge_all();
81 return true;
82 }
83
84 function maybe_update_pro_status() {
85 $is_pro_active = get_option('wps_team_is_pro_active');
86 $current_pro_status = wps_team_fs()->can_use_premium_code() ? 'yes' : 'no';
87 if ( $is_pro_active === $current_pro_status ) return;
88 update_option( 'wps_team_is_pro_active', $current_pro_status );
89 plugin()->assets->assets_purge_all();
90 }
91
92 public function initialize() {
93 require_once WPS_TEAM_INC_PATH . 'autoloader.php';
94 require_once WPS_TEAM_INC_PATH . 'thumbly.php';
95 Autoloader::run();
96 Plugin::instance();
97 $this->maybe_update_pro_status();
98 $this->maybe_update_version();
99 }
100
101 }
102
103 new Initialize();
104
105 function plugin() {
106 return Plugin::instance();
107 }