PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.3.7
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.3.7
7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / class-hustle-module-admin.php
wordpress-popup / inc Last commit date
display-conditions 5 years ago front 5 years ago helpers 5 years ago metas 5 years ago palettes 5 years ago provider 5 years ago providers 5 years ago templates 5 years ago update 5 years ago class-hustle-admin-page-abstract.php 5 years ago class-hustle-condition-factory.php 6 years ago class-hustle-dashboard-admin.php 5 years ago class-hustle-data.php 5 years ago class-hustle-db.php 6 years ago class-hustle-module-admin.php 5 years ago class-hustle-module-collection.php 5 years ago class-hustle-module-decorator.php 5 years ago class-hustle-module-page-abstract.php 5 years ago class-hustle-notifications.php 5 years ago class-hustle-settings-admin.php 5 years ago class-hustle-upsell-page.php 5 years ago class-hustle-wp-dashboard-page.php 5 years ago hustle-collection.php 6 years ago hustle-deletion.php 5 years ago hustle-embedded-admin.php 6 years ago hustle-entries-admin.php 5 years ago hustle-entry-model.php 5 years ago hustle-general-data-protection.php 6 years ago hustle-init.php 5 years ago hustle-mail.php 5 years ago hustle-meta.php 5 years ago hustle-migration.php 5 years ago hustle-model.php 5 years ago hustle-module-model.php 5 years ago hustle-module-widget-legacy.php 5 years ago hustle-module-widget.php 5 years ago hustle-modules-common-admin-ajax.php 5 years ago hustle-popup-admin.php 6 years ago hustle-providers-admin.php 5 years ago hustle-providers.php 6 years ago hustle-settings-admin-ajax.php 5 years ago hustle-settings-page.php 5 years ago hustle-slidein-admin.php 6 years ago hustle-sshare-admin.php 5 years ago hustle-sshare-model.php 5 years ago hustle-tracking-model.php 5 years ago opt-in-geo.php 5 years ago opt-in-utils.php 5 years ago opt-in-wpmudev-api.php 6 years ago
class-hustle-module-admin.php
288 lines
1 <?php
2 /**
3 * File for Hustle_Module_Admin class.
4 *
5 * @package Hustle
6 * @since unknown
7 */
8
9 if ( ! class_exists( 'Hustle_Module_Admin' ) ) :
10
11 /**
12 * Class Hustle_Module_Admin
13 */
14 class Hustle_Module_Admin {
15
16 const UPGRADE_MODAL_PARAM = 'requires-pro';
17
18 /**
19 * Hustle_Module_Admin constructor
20 */
21 public function __construct() {
22 $admin_notices = Hustle_Notifications::get_instance();
23
24 if ( $this->is_hustle_page() ) {
25 $admin_notices->add_in_hustle_notices();
26 $this->maybe_add_recommended_plugins_notice();
27 } else {
28 $this->handle_non_hustle_pages();
29 }
30
31 if ( $this->is_hustle_page() || wp_doing_ajax() ) {
32 Hustle_Provider_Autoload::initiate_providers();
33 }
34
35 Hustle_Provider_Autoload::load_block_editor();
36
37 add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
38
39 add_filter( 'w3tc_save_options', array( $this, 'filter_w3tc_save_options' ), 10, 1 );
40 add_filter( 'plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 2 );
41 add_filter( 'network_admin_plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 2 );
42 add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
43
44 add_action( 'upgrader_process_complete', array( $this, 'upgrader_process_complete' ), 10, 2 );
45 }
46
47 /**
48 * Add Privacy Messages
49 *
50 * @since 3.0.6
51 */
52 public function add_privacy_message() {
53 if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
54 $external_integrations_list = '';
55 $external_integrations_privacy_url_list = '';
56 $params = array(
57 'external_integrations_list' => apply_filters( 'hustle_privacy_external_integrations_list', $external_integrations_list ),
58 'external_integrations_privacy_url_list' => apply_filters( 'hustle_privacy_url_external_integrations_list', $external_integrations_privacy_url_list ),
59 );
60
61 $renderer = new Hustle_Layout_Helper();
62 $content = $renderer->render( 'general/policy-text', $params, true );
63 wp_add_privacy_policy_content( 'Hustle', wp_kses_post( $content ) );
64 }
65 }
66
67 /**
68 * Forcefully rejects the minify for Hustle's js and css.
69 *
70 * @since unknown
71 *
72 * @param array $config w3tc configs.
73 * @return array
74 */
75 public function filter_w3tc_save_options( $config ) {
76
77 // Reject js.
78 $defined_rejected_js = $config['new_config']->get( 'minify.reject.files.js' );
79 $reject_js = array(
80 Opt_In::$plugin_url . 'assets/js/admin.min.js',
81 Opt_In::$plugin_url . 'assets/js/ad.js',
82 Opt_In::$plugin_url . 'assets/js/front.min.js',
83 );
84 foreach ( $reject_js as $r_js ) {
85 if ( ! in_array( $r_js, $defined_rejected_js, true ) ) {
86 array_push( $defined_rejected_js, $r_js );
87 }
88 }
89 $config['new_config']->set( 'minify.reject.files.js', $defined_rejected_js );
90
91 // Reject css.
92 $defined_rejected_css = $config['new_config']->get( 'minify.reject.files.css' );
93 $reject_css = array(
94 Opt_In::$plugin_url . 'assets/css/front.min.css',
95 );
96 foreach ( $reject_css as $r_css ) {
97 if ( ! in_array( $r_css, $defined_rejected_css, true ) ) {
98 array_push( $defined_rejected_css, $r_css );
99 }
100 }
101 $config['new_config']->set( 'minify.reject.files.css', $defined_rejected_css );
102
103 return $config;
104 }
105
106 /**
107 * Adds custom links on "Plugins" page.
108 *
109 * @since unknown
110 *
111 * @param array $actions Array of plugin actions links.
112 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
113 * @return array
114 */
115 public function add_plugin_action_links( $actions, $plugin_file ) {
116 static $plugin;
117
118 if ( ! isset( $plugin ) ) {
119 $plugin = Opt_In::$plugin_base_file;
120 }
121
122 if ( $plugin === $plugin_file ) {
123 if ( is_network_admin() ) {
124 $admin_url = network_admin_url( 'admin.php' );
125 } else {
126 $admin_url = admin_url( 'admin.php' );
127 }
128 $settings_url = add_query_arg( 'page', 'hustle_settings', $admin_url );
129 $links = array(
130 'settings' => '<a href="' . $settings_url . '">' . esc_html__( 'Settings', 'hustle' ) . '</a>',
131 'docs' => '<a href="https://premium.wpmudev.org/project/hustle/#wpmud-hg-project-documentation?utm_source=hustle&utm_medium=plugin&utm_campaign=hustle_pluginlist_docs" target="_blank">' . esc_html__( 'Docs', 'hustle' ) . '</a>',
132 );
133
134 // Upgrade link.
135 if ( Opt_In_Utils::_is_free() ) {
136 if ( ! Opt_In_Utils::is_hustle_included_in_membership() ) {
137 $url = 'https://premium.wpmudev.org/project/hustle/?utm_source=hustle&utm_medium=plugin&utm_campaign=hustle_pluginlist_upgrade';
138 $label = __( 'Upgrade to Hustle Pro', 'hustle' );
139 } else {
140 $url = lib3()->get_link( 'hustle', 'install_plugin', '' );
141 $label = __( 'Upgrade', 'hustle' );
142 }
143 if ( is_network_admin() || ! is_multisite() ) {
144 $links['upgrade'] = '<a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( $label ) . '" target="_blank" style="color: #8D00B1;">' . esc_html( $label ) . '</a>';
145 }
146 } else {
147 if ( 'expired' === Opt_In_Utils::get_membership_status() ) {
148 $links['renew'] = '<a href="https://premium.wpmudev.org/?utm_source=hustle&utm_medium=plugin&utm_campaign=hustle_pluginlist_renew" target="_blank" style="color: #8D00B1;">' . esc_html__( 'Renew Membership', 'hustle' ) . '</a>';
149 }
150 }
151
152 $actions = array_merge( $links, $actions );
153 }
154
155 return $actions;
156 }
157
158 /**
159 * Links next to version number in the "Plugins" page.
160 *
161 * @since unknown
162 *
163 * @param array $plugin_meta An array of the plugin's metadata.
164 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
165 * @return array
166 */
167 public function add_plugin_meta_links( $plugin_meta, $plugin_file ) {
168 if ( Opt_In::$plugin_base_file === $plugin_file ) {
169 if ( Opt_In_Utils::_is_free() ) {
170 $row_meta = array(
171 'rate' => '<a href="https://wordpress.org/support/plugin/wordpress-popup/reviews/#new-post" target="_blank">' . esc_html__( 'Rate Hustle', 'hustle' ) . '</a>',
172 'support' => '<a href="https://wordpress.org/support/plugin/wordpress-popup/" target="_blank">' . esc_html__( 'Support', 'hustle' ) . '</a>',
173 );
174 } else {
175 $row_meta = array(
176 'support' => '<a href="https://premium.wpmudev.org/hub/support/#wpmud-chat-pre-survey-modal" target="_blank">' . esc_html__( 'Premium Support', 'hustle' ) . '</a>',
177 );
178 }
179
180 $row_meta['roadmap'] = '<a href="https://premium.wpmudev.org/roadmap/" target="_blank">' . esc_html__( 'Roadmap', 'hustle' ) . '</a>';
181 $plugin_meta = array_merge( $plugin_meta, $row_meta );
182 }
183
184 return $plugin_meta;
185 }
186
187 /**
188 * Flags the previous version on upgrade so we can handle notices and modals.
189 * This action runs in the old version of the plugin, not the new one.
190 *
191 * @since 4.2.0
192 *
193 * @param WP_Upgrader $upgrader_object Instance of the WP_Upgrader class.
194 * @param array $data Upgrade data.
195 */
196 public function upgrader_process_complete( $upgrader_object, $data ) {
197
198 if ( 'update' === $data['action'] && 'plugin' === $data['type'] && ! empty( $data['plugins'] ) ) {
199
200 foreach ( $data['plugins'] as $plugin ) {
201
202 // Make sure our plugin is among the ones being updated and set the flag for the previous version.
203 if ( Opt_In::$plugin_base_file === $plugin ) {
204 update_site_option( 'hustle_previous_version', Opt_In::VERSION );
205 }
206 }
207 }
208 }
209
210 /**
211 * Handles the scripts for non-hustle pages.
212 *
213 * @since 4.2.0
214 */
215 private function handle_non_hustle_pages() {
216 global $pagenow;
217
218 if ( 'index.php' === $pagenow || wp_doing_ajax() ) {
219
220 $analytic_settings = Hustle_Settings_Admin::get_hustle_settings( 'analytics' );
221 $analytics_enabled = ! empty( $analytic_settings['enabled'] ) && ! empty( $analytic_settings['modules'] );
222
223 // Only initialize if the analytics are enabled.
224 // That's the only use for this class for now.
225 if ( $analytics_enabled && current_user_can( 'hustle_analytics' ) ) {
226 new Hustle_Wp_Dashboard_Page( $analytic_settings );
227 }
228 }
229 }
230
231 /**
232 * Renders the recommended plugins notice when the conditions are correct.
233 * This is shown when:
234 * -The current version is Free
235 * -The admin isn't logged to WPMU Dev dashboard
236 * -The notice hasn't been dismissed
237 * -The majority of our plugins aren't installed
238 * -A month has passed since the plugin was installed
239 * There are filters to force the display.
240 *
241 * @see https://bitbucket.org/incsub/recommended-plugins-notice/src/master/
242 *
243 * @since 4.2.0
244 */
245 private function maybe_add_recommended_plugins_notice() {
246 if ( ! Opt_In_Utils::_is_free() ) {
247 return;
248 }
249
250 require_once Opt_In::$plugin_path . 'lib/plugin-notice/notice.php';
251 do_action(
252 'wpmudev-recommended-plugins-register-notice', // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
253 Opt_In::$plugin_base_file,
254 __( 'Hustle', 'hustle' ),
255 $this->get_admin_pages_for_free(),
256 array( 'after', '.sui-wrap .sui-header' )
257 );
258 }
259
260 /**
261 * Checks if it's module admin page
262 *
263 * @return bool
264 */
265 private function is_hustle_page() {
266 $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
267 return in_array( $page, Hustle_Data::get_hustle_pages(), true );
268 }
269
270 /**
271 * Return an array with the slugs of the admin pages
272 *
273 * @since 4.1.1
274 * @return array
275 */
276 private function get_admin_pages_for_free() {
277 $names = Hustle_Data::get_hustle_pages();
278 $with_prefix = array( 'toplevel_page_hustle' );
279
280 foreach ( $names as $name ) {
281 $with_prefix[] = 'hustle_page_' . $name;
282 }
283 return $with_prefix;
284 }
285 }
286
287 endif;
288