PluginProbe
Instantio — Side Cart & One-Page Checkout for WooCommerce / trunk
Instantio — Side Cart & One-Page Checkout for WooCommerce vtrunk
3.3.34 trunk 1.0 1.1 1.1.1 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 2.0.0 2.1.0 2.1.2 2.1.3 2.2.0 2.2.1 2.2.2 2.2.3 2.3.1 2.3.2 All 122 releases
instantio / includes / controller / Admin.php

Admin.php in Instantio — Side Cart & One-Page Checkout for WooCommerce trunk, at includes/controller/Admin.php

190 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Themefic\Instantio\Controller;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Admin {
7
8 public function __construct() {
9
10 add_action( 'init', array( $this, 'ins_update_option' ) );
11
12 /**
13 * Check if WooCommerce is active, and if it isn't, disable the plugin.
14 *
15 * @since 1.0
16 */
17 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
18 add_action( 'admin_notices', array( $this, 'ins_is_woo' ) );
19 // deactivate_plugins('instantio/instantio.php');
20 }
21
22 /**
23 * Check if Instantio Pro version is 3.0.0 or above, if it isn't, disable the plugin.
24 *
25 * @since 3.0
26 */
27 if ( class_exists( 'WOOINS' ) ) {
28 $minimum_pro_version = '3.0.0';
29
30 if ( ! defined( 'INSTANTIO_PRO_VERSION' ) || version_compare( INSTANTIO_PRO_VERSION, $minimum_pro_version, '<' ) ) {
31 deactivate_plugins( 'wooinstant/wooinstant.php' );
32 add_action( 'admin_notices', array( $this, 'version_warning' ) );
33 add_action( 'admin_notices', array( $this, 'ins_wooinstantio_updated' ) );
34 }
35 }
36
37 // Define Plugin Action Links.
38 add_filter( 'plugin_action_links_' . INSTANTIO_BASE_LOCATION, array( $this, 'instantio_plugin_action_links' ) );
39
40 // Activation & Dactivation Hook
41 register_activation_hook( INSTANTIO_PATH . 'instantio.php', array( $this, 'ins_activate' ) );
42 register_deactivation_hook( INSTANTIO_PATH . 'instantio.php', array( $this, 'ins_deactivate' ) );
43 }
44
45
46 /**
47 * Update Instantio Notice
48 */
49
50 public function ins_update_option() {
51 $update_option = get_option( 'wiopt_update_option' );
52 if ( '3.0.0' == INSTANTIO_VERSION && $update_option < 1 ) {
53 update_option( 'wiopt', '' );
54 update_option( 'wiopt_update_option', '1' );
55 }
56 }
57
58
59 // Version Warning Admin Notice
60 public function version_warning() { ?>
61 <div class="notice notice-error">
62 <p><?php esc_html_e( 'We have noticed a discrepancy between the version of your Pro plugin and the free plugin. Please update your Pro plugin to ensure compatibility and optimal performance.', 'instantio' ); ?></p>
63 </div>
64 <?php }
65
66
67
68 /**
69 * Called when WooCommerce is inactive to display an inactive notice.
70 *
71 * @since 1.0
72 */
73 public function ins_is_woo() {
74 if ( current_user_can( 'activate_plugins' ) ) {
75 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && ! file_exists( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
76 ?>
77
78 <div id="message" class="error">
79 <p>
80 <?php
81 /* translators: 1: opening link markup, 2: closing link markup. */
82 echo wp_kses_post( sprintf( __( 'Instantio requires %1$s WooCommerce %2$s to be activated.', 'instantio' ), '<strong><a href="https://wordpress.org/plugins/woocommerce/" target="_blank">', '</a></strong>' ) );
83 ?>
84 </p>
85 <p>
86 <a href="plugin-install.php?s=woocommerce%2520%2520&tab=search&type=term" class="install-now button ins_wooinstall">
87 <?php esc_attr_e( 'Install Now', 'instantio' ); ?>
88 </a>
89 </p>
90 </div>
91 <?php
92 } elseif ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && file_exists( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
93 ?>
94
95 <div id="message" class="error">
96 <p>
97 <?php
98 /* translators: 1: opening link markup, 2: closing link markup. */
99 echo wp_kses_post( sprintf( __( 'Instantio requires %1$s WooCommerce %2$s to be activated.', 'instantio' ), '<strong><a href="https://wordpress.org/plugins/woocommerce/" target="_blank">', '</a></strong>' ) );
100 ?>
101 </p>
102 <p>
103 <a href="<?php echo esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php' ) ); ?>" class="button activate-now button-primary">
104 <?php esc_attr_e( 'Activate', 'instantio' ); ?>
105 </a>
106 </p>
107 </div>
108
109 <?php
110 } elseif ( version_compare( get_option( 'woocommerce_db_version' ), '7.0', '<' ) ) {
111 ?>
112
113 <div id="message" class="error">
114 <p>
115 <?php
116 /* translators: 1: opening strong tag, 2: closing strong tag, 3: opening update link, 4: closing update link. */
117 echo wp_kses_post( sprintf( __( '%1$sInstantio is inactive.%2$s This plugin requires WooCommerce 7.0 or newer. Please %3$supdate WooCommerce to version 7.0 or newer%4$s', 'instantio' ), '<strong>', '</strong>', '<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '&nbsp;&raquo;</a>' ) );
118 ?>
119 </p>
120 </div>
121
122 <?php
123 }
124 }
125 }
126
127 /**
128 * Called when Instantio Pro is inactive to display an inactive notice.
129 *
130 * @since 3.0
131 */
132 public function ins_wooinstantio_updated() {
133 if ( current_user_can( 'activate_plugins' ) ) {
134 ?>
135 <div id="message" class="error">
136 <p>
137 <?php esc_html_e( 'To activate Instantio, it is necessary to have Instantio Pro version 3 installed.', 'instantio' ); ?>
138 </p>
139
140 <p>
141 <span class="ins-notices" data-plugin-slug="instantiopro">
142 <?php esc_attr_e( 'Please Updated Now', 'instantio' ); ?>
143 </span>
144 </p>
145 </div>
146
147 <?php
148 }
149 }
150
151
152 /**
153 * Add plugin action links.
154 *
155 */
156 public function instantio_plugin_action_links( $links ) {
157
158 $settings_link = array(
159 '<a href="admin.php?page=wiopt#tab=layout_option">' . esc_html__( 'Settings', 'instantio' ) . '</a>',
160 );
161
162 if ( ! is_plugin_active( 'wooinstant/wooinstant.php' ) ) {
163 $gopro_link = array(
164 '<a href="https://themefic.com/instantio/go/upgrade" target="_blank" style="color:#cc0000;font-weight: bold;text-shadow: 0px 1px 1px hsl(0deg 0% 0% / 28%);">' . esc_html__( 'GO PRO', 'instantio' ) . '</a>',
165 );
166 } else {
167 $gopro_link = array( '' );
168 }
169 return array_merge( $settings_link, $links, $gopro_link );
170 }
171
172 // Activation Hooks
173 public function ins_activate() {
174 $installed = get_option( 'instantio_active_time' );
175
176 if ( ! $installed ) {
177 update_option( 'instantio_active_time', time() );
178 }
179
180 }
181
182 // Deactivation Hooks
183 public function ins_deactivate() {
184 $installed = get_option( 'instantio_active_time' );
185 if ( $installed ) {
186 delete_option( 'instantio_active_time' );
187 }
188 }
189 }
190