PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.14
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.14
7.8.14 7.8.14.1 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 months ago front 3 days ago helpers 1 month ago metas 3 months ago multisite 5 months ago palettes 3 years ago provider 1 month ago providers 3 days ago templates 3 years ago update 5 months ago class-hustle-admin-page-abstract.php 1 month ago class-hustle-auth-token.php 5 months ago class-hustle-condition-factory.php 6 years ago class-hustle-cross-sell.php 10 months ago class-hustle-dashboard-admin.php 1 month ago class-hustle-data.php 1 month ago class-hustle-db.php 2 years ago class-hustle-installer.php 4 years ago class-hustle-meta.php 3 years ago class-hustle-module-admin.php 1 month ago class-hustle-module-collection.php 5 months ago class-hustle-module-fields.php 3 months ago class-hustle-module-page-abstract.php 1 month ago class-hustle-module-validator.php 3 months ago class-hustle-notifications.php 3 days ago class-hustle-settings-admin.php 1 month ago class-hustle-wp-dashboard-page.php 5 months ago class-opt-in.php 3 days ago hustle-background-conversion-log.php 3 months ago hustle-deletion.php 3 months ago hustle-embedded-admin.php 3 years ago hustle-entries-admin.php 5 months ago hustle-entry-model.php 1 month ago hustle-general-data-protection.php 5 months ago hustle-init.php 1 month ago hustle-mail.php 5 months ago hustle-migration.php 5 months ago hustle-model.php 3 days ago hustle-module-model.php 1 month ago hustle-module-widget-legacy.php 5 months ago hustle-module-widget.php 5 months ago hustle-modules-common-admin-ajax.php 1 month ago hustle-popup-admin.php 3 years ago hustle-providers-admin.php 1 month ago hustle-providers.php 5 months ago hustle-settings-admin-ajax.php 1 month ago hustle-settings-page.php 3 years ago hustle-slidein-admin.php 3 years ago hustle-sshare-admin.php 3 days ago hustle-sshare-model.php 3 days ago hustle-tracking-model.php 3 months ago interface-hustle-auth-provider.php 5 months ago opt-in-geo.php 5 months ago opt-in-utils.php 3 days ago opt-in-wpmudev-api.php 5 months ago
class-hustle-module-admin.php
285 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 $admin_url = admin_url( 'admin.php' );
124 $settings_url = add_query_arg( 'page', 'hustle', $admin_url );
125 $links = array(
126 'settings' => '<a href="' . esc_url( $settings_url ) . '">' . esc_html__( 'Dashboard', 'hustle' ) . '</a>',
127 'docs' => '<a href="' . esc_url( Opt_In_Utils::get_link( 'docs', 'hustle_pluginlist_docs' ) ) . '" target="_blank">' . esc_html__( 'Docs', 'hustle' ) . '</a>',
128 );
129
130 // Upgrade link.
131 if ( Opt_In_Utils::is_free() ) {
132 if ( ! Opt_In_Utils::is_hustle_included_in_membership() ) {
133 $url = Opt_In_Utils::get_link( 'plugin', 'hustle_pluginlist_upgrade' );
134 $label = __( 'Get Hustle Pro', 'hustle' );
135 } else {
136 $url = Opt_In_Utils::get_link( 'install_plugin' );
137 $label = __( 'Upgrade', 'hustle' );
138 }
139 if ( is_network_admin() || ! is_multisite() ) {
140 $links['upgrade'] = '<a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( $label ) . '" target="_blank" style="color: #8D00B1;">' . esc_html( $label ) . '</a>';
141 }
142 } else {
143 $status = Opt_In_Utils::get_membership_status();
144 if ( in_array( $status, array( 'expired', 'free', 'paused', '' ), true ) ) {
145 $links['renew'] = '<a href="' . esc_url( Opt_In_Utils::get_link( 'wpmudev', 'hustle_pluginlist_renew' ) ) . '" target="_blank" style="color: #8D00B1;">' . esc_html__( 'Renew Membership', 'hustle' ) . '</a>';
146 }
147 }
148
149 $actions = array_merge( $links, $actions );
150 }
151
152 return $actions;
153 }
154
155 /**
156 * Links next to version number in the "Plugins" page.
157 *
158 * @since unknown
159 *
160 * @param array $plugin_meta An array of the plugin's metadata.
161 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
162 * @return array
163 */
164 public function add_plugin_meta_links( $plugin_meta, $plugin_file ) {
165 if ( Opt_In::$plugin_base_file === $plugin_file ) {
166 $row_meta = array();
167
168 if ( Opt_In_Utils::is_free() ) {
169 $row_meta['rate'] = '<a href="https://wordpress.org/support/plugin/wordpress-popup/reviews/#new-post" target="_blank">' . esc_html__( 'Rate Hustle', 'hustle' ) . '</a>';
170 }
171
172 $support_text = 'full' === Opt_In_Utils::get_membership_status() ? esc_html__( 'Premium Support', 'hustle' ) : esc_html__( 'Support', 'hustle' );
173
174 // Returns the wp.org link when ! is_member(), and the premium link otherwise.
175 $row_meta['support'] = '<a href="' . esc_url( Opt_In_Utils::get_link( 'support' ) ) . '" target="_blank">' . $support_text . '</a>';
176
177 $row_meta['roadmap'] = '<a href="' . esc_url( Opt_In_Utils::get_link( 'roadmap' ) ) . '" target="_blank">' . esc_html__( 'Roadmap', 'hustle' ) . '</a>';
178 $plugin_meta = array_merge( $plugin_meta, $row_meta );
179 }
180
181 return $plugin_meta;
182 }
183
184 /**
185 * Flags the previous version on upgrade so we can handle notices and modals.
186 * This action runs in the old version of the plugin, not the new one.
187 *
188 * @since 4.2.0
189 *
190 * @param WP_Upgrader $upgrader_object Instance of the WP_Upgrader class.
191 * @param array $data Upgrade data.
192 */
193 public function upgrader_process_complete( $upgrader_object, $data ) {
194
195 if ( 'update' === $data['action'] && 'plugin' === $data['type'] && ! empty( $data['plugins'] ) ) {
196
197 foreach ( $data['plugins'] as $plugin ) {
198
199 // Make sure our plugin is among the ones being updated and set the flag for the previous version.
200 if ( Opt_In::$plugin_base_file === $plugin ) {
201 update_site_option( 'hustle_previous_version', Opt_In::VERSION );
202 }
203 }
204 }
205 }
206
207 /**
208 * Handles the scripts for non-hustle pages.
209 *
210 * @since 4.2.0
211 */
212 private function handle_non_hustle_pages() {
213 global $pagenow;
214
215 if ( 'index.php' === $pagenow || wp_doing_ajax() ) {
216
217 $analytic_settings = Hustle_Settings_Admin::get_hustle_settings( 'analytics' );
218 $analytics_enabled = ! empty( $analytic_settings['enabled'] ) && ! empty( $analytic_settings['modules'] );
219
220 // Only initialize if the analytics are enabled.
221 // That's the only use for this class for now.
222 if ( $analytics_enabled && current_user_can( 'hustle_analytics' ) ) {
223 new Hustle_Wp_Dashboard_Page( $analytic_settings );
224 }
225 }
226 }
227
228 /**
229 * Renders the recommended plugins notice when the conditions are correct.
230 * This is shown when:
231 * -The current version is Free
232 * -The admin isn't logged to WPMU Dev dashboard
233 * -The notice hasn't been dismissed
234 * -The majority of our plugins aren't installed
235 * -A month has passed since the plugin was installed
236 * There are filters to force the display.
237 *
238 * @see https://bitbucket.org/incsub/recommended-plugins-notice/src/master/
239 *
240 * @since 4.2.0
241 */
242 private function maybe_add_recommended_plugins_notice() {
243 if ( ! Opt_In_Utils::is_free() ) {
244 return;
245 }
246
247 require_once Opt_In::$plugin_path . 'lib/plugin-notice/notice.php';
248 do_action(
249 'wpmudev-recommended-plugins-register-notice', // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
250 Opt_In::$plugin_base_file,
251 __( 'Hustle', 'hustle' ),
252 $this->get_admin_pages_for_free(),
253 array( 'after', '.sui-wrap .sui-header' )
254 );
255 }
256
257 /**
258 * Checks if it's module admin page
259 *
260 * @return bool
261 */
262 private function is_hustle_page() {
263 $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_SPECIAL_CHARS );
264 return in_array( $page, Hustle_Data::get_hustle_pages(), true );
265 }
266
267 /**
268 * Return an array with the slugs of the admin pages
269 *
270 * @since 4.1.1
271 * @return array
272 */
273 private function get_admin_pages_for_free() {
274 $names = Hustle_Data::get_hustle_pages();
275 $with_prefix = array( 'toplevel_page_hustle' );
276
277 foreach ( $names as $name ) {
278 $with_prefix[] = 'hustle_page_' . $name;
279 }
280 return $with_prefix;
281 }
282 }
283
284 endif;
285