PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.0.2
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.0.2
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 / popover.php
wordpress-popup Last commit date
assets 6 years ago inc 6 years ago languages 6 years ago lib 6 years ago palettes 6 years ago vendor 6 years ago views 6 years ago humans.txt 7 years ago license.txt 7 years ago opt-in-static.php 6 years ago popover.php 6 years ago readme.txt 6 years ago
popover.php
763 lines
1 <?php
2 /*
3 Plugin Name: Hustle
4 Plugin URI: https://wordpress.org/plugins/wordpress-popup/
5 Description: Start collecting email addresses and quickly grow your mailing list with big bold pop-ups, slide-ins, widgets, or in post opt-in forms.
6 Version: 7.0.2
7 Author: WPMU DEV
8 Author URI: https://premium.wpmudev.org
9 Text Domain: wordpress-popup
10
11 */
12
13 // +----------------------------------------------------------------------+
14 // | Copyright Incsub (http://incsub.com/) |
15 // +----------------------------------------------------------------------+
16 // | This program is free software; you can redistribute it and/or modify |
17 // | it under the terms of the GNU General Public License, version 2, as |
18 // | published by the Free Software Foundation. |
19 // | |
20 // | This program is distributed in the hope that it will be useful, |
21 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 // | GNU General Public License for more details. |
24 // | |
25 // | You should have received a copy of the GNU General Public License |
26 // | along with this program; if not, write to the Free Software |
27 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
28 // | MA 02110-1301 USA |
29 // +----------------------------------------------------------------------+
30
31 // Display admin notice about plugin deactivation
32 add_action( 'network_admin_notices', 'hustle_activated_deactivated' );
33 add_action( 'admin_notices', 'hustle_activated_deactivated' );
34 if ( ! function_exists( 'hustle_activated_deactivated' ) ) {
35 function hustle_activated_deactivated() {
36 // for Pro
37 if ( get_site_option( 'hustle_free_deactivated' ) && is_super_admin() ) { ?>
38 <div class="notice notice-success is-dismissible">
39 <p><?php esc_html_e( 'Congratulations! You have activated Hustle Pro! We have automatically deactivated the free version.', 'hustle' ); ?></p>
40 </div>
41 <?php
42 delete_site_option( 'hustle_free_deactivated' );
43 }
44 // for Free
45 if ( get_site_option( 'hustle_free_activated' ) && is_super_admin() ) {
46 ?>
47 <div class="notice notice-error is-dismissible">
48 <p><?php esc_html_e( 'You already have Hustle Pro activated. If you really wish to go back to the free version of Hustle, please deactivate the Pro version first.', 'hustle' ); ?></p>
49 </div>
50 <?php
51 delete_site_option( 'hustle_free_activated' );
52 }
53 }
54 }
55
56 // Deactivate the .org version, if pro version is active
57 add_action( 'activated_plugin', 'hustle_activated', 10, 2 );
58 if ( ! function_exists( 'hustle_activated' ) ) {
59 function hustle_activated( $plugin, $network_activation ) {
60
61 if ( is_plugin_active( 'hustle/opt-in.php' ) && is_plugin_active( 'wordpress-popup/popover.php' ) ) {
62
63 // deactivate free version
64 deactivate_plugins( 'wordpress-popup/popover.php' );
65
66 if ( 'hustle/opt-in.php' === $plugin ) {
67 //Store in database about free version deactivated, in order to show a notice on page load
68 update_site_option( 'hustle_free_deactivated', 1 );
69 } else if ( 'wordpress-popup/popover.php' === $plugin ) {
70 //Store in database about free version being activated even pro is already active
71 update_site_option( 'hustle_free_activated', 1 );
72 }
73 }
74 }
75 }
76
77 if ( version_compare( PHP_VERSION, '5.3.2', '>=' ) ) {
78 if ( ! class_exists( 'ComposerAutoloaderInitda98371940d11703c56dee923bbb392f' ) ) {
79 require_once 'vendor/autoload.php';
80 }
81 } else {
82 if ( ! class_exists( 'ComposerAutoloaderInitdc2feb09422541020a75a34eeac8ae2a' ) ) {
83 require_once 'vendor/autoload_52.php';
84 }
85 }
86
87 require_once 'lib/wpmu-lib/core.php';
88 require_once 'opt-in-static.php';
89 //require_once 'assets/shared-ui/plugin-ui.php';
90
91 if ( ! defined( 'HUSTLE_SUI_VERSION' ) ) {
92 define( 'HUSTLE_SUI_VERSION', '2.3.29' );
93 }
94
95 if ( ! class_exists( 'Opt_In' ) ) :
96
97 class Opt_In extends Opt_In_Static{
98
99 const VERSION = '4.0.2';
100
101 /**
102 * Text domain for translation.
103 * We're replacing this string via Gulp when compiling.
104 */
105 const TEXT_DOMAIN = 'wordpress-popup';
106
107 const VIEWS_FOLDER = 'views';
108 const EXPORT_MODULE_ACTION = 'module_export';
109
110
111 private $hustle_provider_loader;
112
113
114 public static $plugin_base_file;
115 public static $plugin_url;
116 public static $plugin_path;
117 public static $vendor_path;
118 public static $template_path;
119
120 protected static $_registered_providers = array();
121
122 /**
123 * Opt_In constructor.
124 *
125 *
126 * @since 1.0.0
127 */
128 public function __construct() {
129
130 self::$plugin_base_file = plugin_basename( __FILE__ );
131 self::$plugin_url = plugin_dir_url( self::$plugin_base_file );
132 self::$plugin_path = trailingslashit( dirname( __FILE__ ) );
133 self::$vendor_path = self::$plugin_path . 'vendor/';
134 self::$template_path = trailingslashit( dirname( __FILE__ ) ) . 'views/';
135
136 // Register autoloader
137 spl_autoload_register( array( $this, 'autoload' ) );
138
139 // Register text domain
140 add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) );
141
142 //check caps
143 add_action( 'admin_init', array( $this, 'hustle_check_caps' ), 999 );
144
145 /**
146 * Boot up and instantiate core classes
147 */
148 $this->_boot();
149 }
150
151 /**
152 * Returns list of optin providers based on their declared classes that implement Opt_In_Provider_Interface
153 *
154 * @return array
155 */
156 public function get_providers() {
157 if ( empty( self::$_registered_providers ) ) {
158 self::$_registered_providers = Hustle_Provider_Utils::get_activable_providers_list();
159 }
160 return self::$_registered_providers;
161 }
162
163 /**
164 * Loads text domain
165 *
166 * @since 1.0.0
167 */
168 public function load_text_domain() {
169 load_plugin_textdomain( 'wordpress-popup', false, dirname( plugin_basename( self::$plugin_base_file ) ) . '/languages/' );
170 }
171
172 /**
173 * Autoloads undefined classes
174 *
175 * @since 1.0.0
176 *
177 * @param $class
178 * @return bool
179 */
180 public function autoload( $class ) {
181
182 $dirs = array( 'inc', 'inc/provider', 'inc/display-conditions', 'inc/popup', 'inc/slidein', 'inc/embed', 'inc/sshare' );
183
184 foreach ( $dirs as $dir ) {
185 $filename = self::$plugin_path . $dir . DIRECTORY_SEPARATOR . str_replace( '_', '-', strtolower( $class ) ) . '.php';
186 if ( is_readable( $filename ) ) {
187 require_once $filename;
188 return true;
189 }
190 }
191
192 return false;
193 }
194
195 /**
196 * Boots up the plugin and instantiates core classes
197 *
198 * @since 1.0.0
199 */
200 private function _boot() {
201 // Registers the existing activable providers
202 $this->_init_providers();
203 }
204
205 private function _init_providers() {
206
207 /**
208 * Triggered before registering internal providers
209 *
210 * @since xxx
211 */
212 do_action( 'hustle_before_load_providers' );
213
214 $this->hustle_provider_loader = Hustle_Providers::get_instance();
215 // Load packaged providers
216 $autoloader = new Hustle_Provider_Autoload();
217 $autoloader->load();
218
219 /*
220 * Triggered after hustle packaged providers were loaded
221 *
222 * @since xxx
223 */
224 do_action( 'hustle_providers_loaded' );
225 }
226
227 /**
228 * Show Exit-intent description
229 *
230 * @since 3.0.8
231 * @todo move it somewhere else. No need to have this in this file. It's used in wizard's trigger sections.
232 */
233 public function get_exitintent_description() {
234 printf( esc_html__( '%1$sNote:%2$s Exit-intent will show only by detecting mouse movement and not with finger scroll.', 'wordpress-popup' ), '<b>', '</b>' );
235 }
236
237 /**
238 * Get smallcaps singular
239 *
240 * @param string $module_type
241 * @return string
242 */
243 public static function get_smallcaps_singular( $module_type ) {
244 $smallcaps_singular = '';
245
246 if ( Hustle_Module_Model::POPUP_MODULE === $module_type ) {
247 $smallcaps_singular = esc_html__( 'pop-up', 'wordpress-popup' );
248 } elseif ( Hustle_Module_Model::SLIDEIN_MODULE === $module_type ) {
249 $smallcaps_singular = esc_html__( 'slide-in', 'wordpress-popup' );
250 } elseif ( Hustle_Module_Model::EMBEDDED_MODULE === $module_type ) {
251 $smallcaps_singular = esc_html__( 'embed', 'wordpress-popup' );
252 } elseif ( Hustle_Module_Model::SOCIAL_SHARING_MODULE === $module_type ) {
253 $smallcaps_singular = esc_html__( 'social sharing', 'wordpress-popup' );
254 }
255
256 return $smallcaps_singular;
257 }
258
259
260 /**
261 * Renders a view file
262 *
263 * @param $file
264 * @param array $params
265 * @param bool|false $return
266 * @return string
267 */
268 public function render( $file, $params = array(), $return = false ) {
269 // $params = array_merge( array('self' => $this), $params );
270 /**
271 * assign $file to a variable which is unlikely to be used by users of the method
272 */
273 $opt_in_to_be_file_name = $file;
274 if ( array_key_exists( 'this', $params ) ) {
275 unset( $params['this'] );
276 }
277 extract( $params, EXTR_OVERWRITE ); // phpcs:ignore
278
279 if ( $return ) {
280 ob_start();
281 }
282
283 $template_file = trailingslashit( self::$plugin_path ) . self::VIEWS_FOLDER . '/' . $opt_in_to_be_file_name . '.php';
284 if ( file_exists( $template_file ) ) {
285 include $template_file;
286 } else {
287 $template_path = self::$template_path . $opt_in_to_be_file_name . '.php';
288 // Render file located outside the plugin's folder. Useful when adding third party integrations.
289 $external_path = $opt_in_to_be_file_name . '.php';
290
291 if ( file_exists( $template_path ) ) {
292 include $template_path;
293 } elseif ( file_exists( $external_path ) ) {
294 include $external_path;
295 } elseif ( file_exists( $opt_in_to_be_file_name ) ) {
296 include $opt_in_to_be_file_name;
297 }
298 }
299
300 if ( $return ) {
301 return ob_get_clean();
302 }
303
304 if ( ! empty( $params ) ) {
305 foreach ( $params as $param ) {
306 unset( $param );
307 }
308 }
309 }
310
311 /**
312 * Renders a view file with static call
313 *
314 * @param $file
315 * @param array $params
316 * @param bool|false $return
317 * @return string
318 */
319 public static function static_render( $file, $params = array(), $return = false ) {
320 $params = array_merge( $params );
321 /**
322 * assign $file to a variable which is unlikely to be used by users of the method
323 */
324 $opt_in_to_be_file_name = $file;
325 extract( $params, EXTR_OVERWRITE ); // phpcs:ignore
326
327 if ( $return ) {
328 ob_start();
329 }
330
331 $template_file = trailingslashit( self::$plugin_path ) . self::VIEWS_FOLDER . '/' . $opt_in_to_be_file_name . '.php';
332 if ( file_exists( $template_file ) ) {
333 include $template_file;
334 } else {
335 $template_path = self::$template_path . $opt_in_to_be_file_name . '.php';
336 // Render file located outside the plugin's folder. Useful when adding third party integrations.
337 $external_path = $opt_in_to_be_file_name . '.php';
338
339 if ( file_exists( $template_path ) ) {
340 include $template_path;
341 } elseif ( file_exists( $external_path ) ) {
342 include $external_path;
343 } elseif ( file_exists( $opt_in_to_be_file_name ) ) {
344 include $opt_in_to_be_file_name;
345 }
346 }
347
348 if ( $return ) {
349 return ob_get_clean();
350 }
351
352 if ( ! empty( $params ) ) {
353 foreach ( $params as $param ) {
354 unset( $param );
355 }
356 }
357 }
358
359
360 protected function get_palette( $palette_name ) {
361 $palette_name = ucwords( str_replace( '_', ' ', $palette_name ) );
362
363 $palettes = $this->get_palettes();
364 return $palettes[ $palette_name ];
365 }
366
367 public function current_page_type() {
368 /**
369 * @var $wp_query WP_Query
370 */
371 global $wp_query, $post;
372 $type = 'notfound';
373
374 if ( $wp_query->is_page ) {
375 $type = is_front_page() ? 'front' : 'page';
376 } elseif ( $wp_query->is_home ) {
377 $type = 'home';
378 } elseif ( $wp_query->is_single ) {
379 $type = ( $wp_query->is_attachment ) ? 'attachment' : get_post_type();
380 } elseif ( $wp_query->is_category ) {
381 $type = 'category';
382 } elseif ( $wp_query->is_tag ) {
383 $type = 'tag';
384 } elseif ( $wp_query->is_tax ) {
385 $type = 'tax';
386 } elseif ( $wp_query->is_archive ) {
387 if ( $wp_query->is_day ) {
388 $type = 'day';
389 } elseif ( $wp_query->is_month ) {
390 $type = 'month';
391 } elseif ( $wp_query->is_year ) {
392 $type = 'year';
393 } elseif ( $wp_query->is_author ) {
394 $type = 'author';
395 } else {
396 $type = 'archive';
397 }
398 } elseif ( $wp_query->is_search ) {
399 $type = 'search';
400 } elseif ( $wp_query->is_404 ) {
401 $type = 'notfound';
402 }
403
404 return $type;
405 }
406
407 /**
408 * Prepares the custom css string
409 *
410 * @since 1.0
411 * @param $css_string
412 * @param $prefix
413 * @param bool|false $as_array
414 * @param bool|true $separate_prefix
415 * @return array|string
416 */
417 public static function prepare_css( $css_string, $prefix, $as_array = false, $separate_prefix = true, $wildcard = '' ) {
418
419 $css_array = array(); // master array to hold all values
420 $elements = explode( '}', $css_string );
421
422 // Output is the final processed CSS string.
423 $output = '';
424 $prepared = '';
425 $have_media = false;
426 $media_names = array();
427 $media_names_key = 0;
428 $index = 0;
429
430 foreach ( $elements as $element ) {
431
432 $check_element = trim( $element );
433
434 if ( empty( $check_element ) ) {
435 $index++; // Still increment $index even if empty.
436 continue;
437 }
438
439 // get the name of the CSS element
440 $a_name = explode( '{', $element );
441 $name = $a_name[0];
442
443 // check if @media is present
444 $media_name = '';
445
446 if ( strpos( $name, '@media' ) !== false && isset( $a_name[1] ) ) {
447
448 $have_media = true;
449 $media_name = $name;
450 $media_names[ $media_names_key ] = array(
451 'name' => $media_name,
452 );
453 $name = $a_name[1];
454 $media_names_key++;
455
456 }
457
458 if ( $have_media ) {
459 $prepared = '';
460 }
461
462 // get all the key:value pair styles
463 $a_styles = explode( ';', $element );
464
465 // remove element name from first property element
466 $remove_element_name = ( ! empty( $media_name ) ) ? $media_name . '{' . $name : $name;
467 $a_styles[0] = str_replace( $remove_element_name . '{', '', $a_styles[0] );
468 $names = explode( ',', $name );
469
470 foreach ( $names as $name ) {
471
472 if ( $separate_prefix && empty( $wildcard ) ) {
473 $space_needed = true;
474 } elseif ( $separate_prefix && ! empty( $wildcard ) ) {
475
476 // wildcard is the sibling class of target selector e.g. "wph-modal"
477 if ( strpos( $name, $wildcard ) ) {
478 $space_needed = false;
479 } else {
480 $space_needed = true;
481 }
482 } else {
483 $space_needed = false;
484 }
485
486 $maybe_put_space = ( $space_needed ) ? ' ' : '';
487
488 $prepared .= ( $prefix . $maybe_put_space . trim( $name ).',' );
489
490 }
491
492 $prepared = trim( $prepared, ',' );
493 $prepared .= '{';
494
495 // loop through each style and split apart the key from the value
496 $count = count( $a_styles );
497
498 for ( $a = 0;$a < $count; $a++ ) {
499
500 if ( trim( $a_styles[ $a ] ) ) {
501
502 $a_key_value = explode( ':', $a_styles[ $a ] );
503
504 // build the master css array
505 if ( count( $a_key_value ) > 2 ) {
506 $a_key_value_to_join = array_slice( $a_key_value, 1 );
507 $a_key_value[1] = implode( ':', $a_key_value_to_join );
508 }
509
510 if ( ! isset( $a_key_value[1] ) ) {
511 continue;
512 }
513
514 $css_array[ $name ][ $a_key_value[0] ] = $a_key_value[1];
515 $prepared .= ($a_key_value[0] . ': ' . $a_key_value[1]); // . strpos($a_key_value[1], "!important") === false ? " !important;": ";";
516
517 if ( '' === $a_key_value[1] ) {
518 $prepared .= '';
519 }
520
521 $prepared .= ';';
522 }
523 }
524
525 $prepared .= '}';
526
527 // if have @media earlier, append these styles
528 $prev_media_names_key = $media_names_key - 1;
529
530 if ( isset( $media_names[ $prev_media_names_key ] ) ) {
531
532 if ( isset( $media_names[ $prev_media_names_key ]['styles'] ) ) {
533
534 // See if there were two closing '}' or just one.
535 // (each element is exploded/split on '}' symbol, so having two empty strings afterward in the elements array means two '}'s.
536 $next_element = isset( $elements[ $index + 2 ] ) ? trim( $elements[ $index + 2 ] ) : false;
537
538 // If inside @media block.
539 if ( ! empty( $next_element ) ) {
540 $media_names[ $prev_media_names_key ]['styles'] .= $prepared;
541 } else {
542 // If outside of @media block, add to output.
543 $output .= $prepared;
544 }
545 } else {
546 $media_names[ $prev_media_names_key ]['styles'] = $prepared;
547 }
548 } else {
549
550 // If no @media, add styles to $output outside @media.
551 $output .= $prepared;
552 }
553
554 // Increase index.
555 $index++;
556 }
557
558 // if have @media, populate styles using $media_names
559 if ( $have_media ) {
560
561 // reset first $prepared styles
562 $prepared = '';
563
564 foreach ( $media_names as $media ) {
565 $prepared .= $media['name'] . '{ ' . $media['styles'] . ' }';
566 }
567
568 // Add @media styles to output.
569 $output .= $prepared;
570 }
571
572 return $as_array ? $css_array : $output;
573
574 }
575
576 public static function render_attributes( $html_options, $echo = true ) {
577
578 $special_attributes = array(
579 'async' => 1,
580 'autofocus' => 1,
581 'autoplay' => 1,
582 'checked' => 1,
583 'controls' => 1,
584 'declare' => 1,
585 'default' => 1,
586 'defer' => 1,
587 'disabled' => 1,
588 'formnovalidate' => 1,
589 'hidden' => 1,
590 'ismap' => 1,
591 'loop' => 1,
592 'multiple' => 1,
593 'muted' => 1,
594 'nohref' => 1,
595 'noresize' => 1,
596 'novalidate' => 1,
597 'open' => 1,
598 'readonly' => 1,
599 'required' => 1,
600 'reversed' => 1,
601 'scoped' => 1,
602 'seamless' => 1,
603 'selected' => 1,
604 'typemustmatch' => 1,
605 );
606 if ( array() === $html_options ) {
607 return ''; }
608
609 $html = '';
610 if ( isset( $html_options['encode'] ) ) {
611 $raw = ! $html_options['encode'];
612 unset( $html_options['encode'] );
613 } else {
614 $raw = false;
615 }
616 foreach ( $html_options as $name => $value ) {
617 if ( isset( $special_attributes[ $name ] ) ) {
618 if ( $value ) {
619 $html .= ' ' . $name;
620 $html .= '="' . $name . '"';
621 }
622 } elseif ( null !== $value ) {
623 $html .= ' ' . esc_attr( $name ) . '="' . ($raw ? $value : esc_attr( $value ) ) . '"'; }
624 }
625
626 if ( $echo ) {
627 echo $html; // WPCS: xss ok.
628 } else { return $html; }
629 }
630
631 /**
632 * SUI summary config
633 *
634 * @since 4.0.0
635 */
636 public static function get_sui_summary_config( $class = null ) {
637 $style = '';
638 $image_url = apply_filters( 'wpmudev_branding_hero_image', null );
639 if ( ! empty( $image_url ) ) {
640 $style = 'background-image:url(' . esc_url( $image_url ) . ')';
641 }
642 $sui = array(
643 'summary' => array(
644 'style' => $style,
645 'classes' => array(
646 'sui-box',
647 'sui-summary',
648 ),
649 ),
650 );
651 if ( ! empty( $class ) && is_string( $class ) ) {
652 $sui['summary']['classes'][] = $class;
653 }
654 /**
655 * Dash integration
656 *
657 * @since 4.0.0
658 */
659 $hide_branding = apply_filters( 'wpmudev_branding_hide_branding', false );
660 $branding_image = apply_filters( 'wpmudev_branding_hero_image', null );
661 if ( $hide_branding && ! empty( $branding_image ) ) {
662 $sui['summary']['classes'][] = 'sui-rebranded';
663 } elseif ( $hide_branding && empty( $branding_image ) ) {
664 $sui['summary']['classes'][] = 'sui-unbranded';
665 }
666 return $sui;
667 }
668
669 //a callback function when user migrates from 3x to 4x from ftp
670 //since the activation hook won't run we'd have to check it in init.
671 public function hustle_check_caps(){
672 $admin = get_role( 'administrator' );
673 $roles = get_editable_roles();
674 if( ( $admin && ! $admin->has_cap( 'hustle_menu' ) ) || ( ! $admin && ! empty( $roles ) ) ) {
675 hustle_activation();
676 }
677 }
678 }
679
680 endif;
681
682 /**
683 * Initializing Hustle classes
684 */
685 $hustle = new Opt_In();
686 $hustle_init = new Hustle_Init( $hustle );
687
688 //Load dashboard notice
689 if ( file_exists( Opt_In::$plugin_path . 'lib/wpmudev-dashboard/wpmudev-dash-notification.php' ) ) {
690 global $wpmudev_notices;
691 $wpmudev_notices[] = array(
692 'id' => 1107020,
693 'name' => 'Hustle',
694 'screens' => array(
695 'toplevel_page_hustle',
696 'optin-pro_page_inc_optin',
697 ),
698 );
699 require_once Opt_In::$plugin_path . 'lib/wpmudev-dashboard/wpmudev-dash-notification.php';
700 }
701
702 if ( is_admin() && Opt_In_Utils::_is_free() ) {
703 require_once Opt_In::$plugin_path . 'lib/free-dashboard/module.php';
704 // Register the current plugin.
705 do_action(
706 'wdev-register-plugin',
707 plugin_basename( __FILE__ ), // 1. Plugin ID
708 'Hustle', // 2. Plugin Title
709 '/plugins/wordpress-popup/', // 3. https://wordpress.org
710 __( 'Sign Me Up', 'wordpress-popup' ), // 4. Email Button CTA
711 'f68d9fbc51' // 5. Mailchimp List id
712 );
713 }
714
715 if ( ! function_exists( 'hustle_activation' ) ) {
716 function hustle_activation() {
717 update_option( 'hustle_activated_flag', 1 );
718 delete_option( Hustle_Db::DB_VERSION_KEY );
719
720 /**
721 * Add Hustle's custom capabilities.
722 * @since 4.0.1
723 */
724 $hustle_capabilities = array(
725 'hustle_menu',
726 'hustle_edit_module',
727 'hustle_create',
728 'hustle_edit_integrations',
729 'hustle_access_emails',
730 'hustle_edit_settings',
731 );
732
733 $admin = get_role( 'administrator' );
734
735 if ( $admin ) {
736 // If there's an "administrator" role.
737 foreach ( $hustle_capabilities as $cap ) {
738 $admin->add_cap( $cap );
739 }
740
741 } else {
742 // If there's no "administrator".
743 $roles = get_editable_roles();
744
745 foreach( $roles as $role_name => $data ) {
746
747 // Add the capabilities to anyone who can manage options. This was the checked capability in 3.x.
748 if ( isset( $data['capabilities']['manage_options'] ) && $data['capabilities']['manage_options'] ) {
749
750 $role = get_role( $role_name );
751 foreach ( $hustle_capabilities as $cap ) {
752 if ( $role ) {
753 $role->add_cap( $cap );
754 }
755 }
756 }
757 }
758 }
759
760 }
761 }
762 register_activation_hook( __FILE__, 'hustle_activation' );
763