PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.1.0
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.1.0
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 6 years ago license.txt 6 years ago opt-in-static.php 6 years ago phpunit.xml 6 years ago popover.php 6 years ago readme.txt 6 years ago uninstall.php 6 years ago
popover.php
804 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.1.0
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 if ( !function_exists( 'array_key_first' ) ) {
88 /**
89 * Gets the first key of an array
90 *
91 * @param array $array
92 * @return mixed
93 */
94 function array_key_first( array $array ) {
95 return $array ? array_keys( $array )[0] : null;
96 }
97 }
98
99 require_once 'lib/wpmu-lib/core.php';
100 require_once 'opt-in-static.php';
101 //require_once 'assets/shared-ui/plugin-ui.php';
102
103 if ( ! defined( 'HUSTLE_SUI_VERSION' ) ) {
104 define( 'HUSTLE_SUI_VERSION', '2.5.0' );
105 }
106
107 if ( ! class_exists( 'Opt_In' ) ) :
108
109 class Opt_In extends Opt_In_Static{
110
111 const VERSION = '4.1.0';
112
113 /**
114 * Text domain for translation.
115 * We're replacing this string via Gulp when compiling.
116 */
117 const TEXT_DOMAIN = 'wordpress-popup';
118
119 const VIEWS_FOLDER = 'views';
120 const EXPORT_MODULE_ACTION = 'module_export';
121
122
123 private $hustle_provider_loader;
124
125
126 public static $plugin_base_file;
127 public static $plugin_url;
128 public static $plugin_path;
129 public static $vendor_path;
130 public static $template_path;
131
132 protected static $_registered_providers = array();
133
134 /**
135 * Opt_In constructor.
136 *
137 *
138 * @since 1.0.0
139 */
140 public function __construct() {
141
142 self::$plugin_base_file = plugin_basename( __FILE__ );
143 self::$plugin_url = plugin_dir_url( self::$plugin_base_file );
144 self::$plugin_path = trailingslashit( dirname( __FILE__ ) );
145 self::$vendor_path = self::$plugin_path . 'vendor/';
146 self::$template_path = trailingslashit( dirname( __FILE__ ) ) . 'views/';
147
148 // Register autoloader
149 spl_autoload_register( array( $this, 'autoload' ) );
150
151 // Register text domain
152 add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) );
153
154 //check caps
155 add_action( 'admin_init', array( $this, 'hustle_check_caps' ), 999 );
156
157 /**
158 * Boot up and instantiate core classes
159 */
160 $this->_boot();
161
162 if ( is_admin() ) {
163 // Add notice to plugin row for 4.1 on Plugins page
164 if ( Opt_In_Utils::_is_free() ) {
165 add_action( 'in_plugin_update_message-wordpress-popup/popover.php', array( $this, 'in_plugin_update_message' ), 10, 2 );
166 } else {
167 add_action(
168 'load-plugins.php',
169 function() {
170 add_action( 'after_plugin_row_hustle/opt-in.php', array( $this, 'in_plugin_update_message' ), 10, 3 );
171 },
172 22 // Must be called after Dashboard which is 21
173 );
174 }
175 }
176 }
177
178 /**
179 * Add notice to plugin row for 4.1version on Plugins page
180 */
181 public function in_plugin_update_message( $project_id, $plugin_data, $project_name = '' ) {
182 $plugin_data = (object) $plugin_data;
183 $needed_version = Opt_In_Utils::_is_free() ? '7.1' : '4.1';
184 if ( empty( $plugin_data->new_version ) || empty( $plugin_data->plugin ) || $needed_version !== $plugin_data->new_version ) {
185 return;
186 }
187 $heads_up = __( 'Heads up!', 'wordpress-popup' );
188 $title = sprintf( __( 'We’ve fixed visibility conditions in Hustle %1$s which may affect the visibility behavior of your pop-ups and other modules.', 'wordpress-popup' ), $plugin_data->new_version );
189 $description = sprintf( __( 'Prior to Hustle %1$s, the visibility engine would require you to set rules for every post type your theme used, not just the ones you specified to make it appear on correct pages. We’ve updated this behavior to only display modules based on the post types explicitly defined in your conditions. For Example, if you add a “Pages” condition to show your module on 1 page only, you’d no longer have to add other post type conditions to hide your module on them. After updating, we recommend double-checking your Hustle modules’ visibility conditions are working as expected.', 'wordpress-popup' ), $plugin_data->new_version );
190
191 echo "<script type='text/javascript'>
192 (function ($) {
193 $(document).ready(function (e) {
194 $( '.wp-list-table tr[data-plugin=\"" . esc_attr( $plugin_data->plugin ) . "\"] .notice-warning' ).append( '<hr><br><span><strong>" . esc_html( $heads_up ) . "</strong> " . esc_html( $title ) . "</span><br><br><span>" . esc_html( $description ) . "</span><br><br>' );
195 });
196 })(jQuery);
197 </script>";
198 }
199
200 /**
201 * Returns list of optin providers based on their declared classes that implement Opt_In_Provider_Interface
202 *
203 * @return array
204 */
205 public function get_providers() {
206 if ( empty( self::$_registered_providers ) ) {
207 self::$_registered_providers = Hustle_Provider_Utils::get_activable_providers_list();
208 }
209 return self::$_registered_providers;
210 }
211
212 /**
213 * Loads text domain
214 *
215 * @since 1.0.0
216 */
217 public function load_text_domain() {
218 load_plugin_textdomain( 'wordpress-popup', false, dirname( plugin_basename( self::$plugin_base_file ) ) . '/languages/' );
219 }
220
221 /**
222 * Autoloads undefined classes
223 *
224 * @since 1.0.0
225 *
226 * @param $class
227 * @return bool
228 */
229 public function autoload( $class ) {
230
231 $dirs = array( 'inc', 'inc/update', 'inc/provider', 'inc/display-conditions', 'inc/popup', 'inc/slidein', 'inc/embed', 'inc/sshare' );
232
233 foreach ( $dirs as $dir ) {
234 $filename = self::$plugin_path . $dir . DIRECTORY_SEPARATOR . str_replace( '_', '-', strtolower( $class ) ) . '.php';
235 if ( is_readable( $filename ) ) {
236 require_once $filename;
237 return true;
238
239 } else {
240
241 // Include files using 'class' as the filename prefix.
242 $filename = self::$plugin_path . $dir . DIRECTORY_SEPARATOR . 'class-' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
243 if ( is_readable( $filename ) ) {
244 require_once $filename;
245 return true;
246 }
247 }
248 }
249
250 return false;
251 }
252
253 /**
254 * Boots up the plugin and instantiates core classes
255 *
256 * @since 1.0.0
257 */
258 private function _boot() {
259 // Registers the existing activable providers
260 $this->_init_providers();
261 }
262
263 private function _init_providers() {
264
265 /**
266 * Triggered before registering internal providers
267 *
268 * @since xxx
269 */
270 do_action( 'hustle_before_load_providers' );
271
272 $this->hustle_provider_loader = Hustle_Providers::get_instance();
273 // Load packaged providers
274 $autoloader = new Hustle_Provider_Autoload();
275 $autoloader->load();
276
277 /*
278 * Triggered after hustle packaged providers were loaded
279 *
280 * @since 3.0.5
281 */
282 do_action( 'hustle_providers_loaded' );
283 }
284
285 /**
286 * Get smallcaps singular
287 *
288 * @param string $module_type
289 * @return string
290 */
291 public static function get_smallcaps_singular( $module_type ) {
292 $smallcaps_singular = '';
293
294 if ( Hustle_Module_Model::POPUP_MODULE === $module_type ) {
295 $smallcaps_singular = esc_html__( 'pop-up', 'wordpress-popup' );
296 } elseif ( Hustle_Module_Model::SLIDEIN_MODULE === $module_type ) {
297 $smallcaps_singular = esc_html__( 'slide-in', 'wordpress-popup' );
298 } elseif ( Hustle_Module_Model::EMBEDDED_MODULE === $module_type ) {
299 $smallcaps_singular = esc_html__( 'embed', 'wordpress-popup' );
300 } elseif ( Hustle_Module_Model::SOCIAL_SHARING_MODULE === $module_type ) {
301 $smallcaps_singular = esc_html__( 'social sharing', 'wordpress-popup' );
302 }
303
304 return $smallcaps_singular;
305 }
306
307
308 /**
309 * Renders a view file
310 *
311 * @param $file
312 * @param array $params
313 * @param bool|false $return
314 * @return string
315 */
316 public function render( $file, $params = array(), $return = false ) {
317 // $params = array_merge( array('self' => $this), $params );
318 /**
319 * assign $file to a variable which is unlikely to be used by users of the method
320 */
321 $opt_in_to_be_file_name = $file;
322 if ( array_key_exists( 'this', $params ) ) {
323 unset( $params['this'] );
324 }
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 * Renders a view file with static call
361 *
362 * @param $file
363 * @param array $params
364 * @param bool|false $return
365 * @return string
366 */
367 public static function static_render( $file, $params = array(), $return = false ) {
368 $params = array_merge( $params );
369 /**
370 * assign $file to a variable which is unlikely to be used by users of the method
371 */
372 $opt_in_to_be_file_name = $file;
373 extract( $params, EXTR_OVERWRITE ); // phpcs:ignore
374
375 if ( $return ) {
376 ob_start();
377 }
378
379 $template_file = trailingslashit( self::$plugin_path ) . self::VIEWS_FOLDER . '/' . $opt_in_to_be_file_name . '.php';
380 if ( file_exists( $template_file ) ) {
381 include $template_file;
382 } else {
383 $template_path = self::$template_path . $opt_in_to_be_file_name . '.php';
384 // Render file located outside the plugin's folder. Useful when adding third party integrations.
385 $external_path = $opt_in_to_be_file_name . '.php';
386
387 if ( file_exists( $template_path ) ) {
388 include $template_path;
389 } elseif ( file_exists( $external_path ) ) {
390 include $external_path;
391 } elseif ( file_exists( $opt_in_to_be_file_name ) ) {
392 include $opt_in_to_be_file_name;
393 }
394 }
395
396 if ( $return ) {
397 return ob_get_clean();
398 }
399
400 if ( ! empty( $params ) ) {
401 foreach ( $params as $param ) {
402 unset( $param );
403 }
404 }
405 }
406
407 public function current_page_type() {
408 /**
409 * @var $wp_query WP_Query
410 */
411 global $wp_query, $post;
412 $type = 'notfound';
413
414 if ( $wp_query->is_page ) {
415 $type = is_front_page() ? 'front' : 'page';
416 } elseif ( $wp_query->is_home ) {
417 $type = 'home';
418 } elseif ( $wp_query->is_single ) {
419 $type = ( $wp_query->is_attachment ) ? 'attachment' : get_post_type();
420 } elseif ( $wp_query->is_category ) {
421 $type = 'category';
422 } elseif ( $wp_query->is_tag ) {
423 $type = 'tag';
424 } elseif ( $wp_query->is_tax ) {
425 $type = 'tax';
426 } elseif ( $wp_query->is_archive ) {
427 if ( $wp_query->is_day ) {
428 $type = 'day';
429 } elseif ( $wp_query->is_month ) {
430 $type = 'month';
431 } elseif ( $wp_query->is_year ) {
432 $type = 'year';
433 } elseif ( $wp_query->is_author ) {
434 $type = 'author';
435 } else {
436 $type = 'archive';
437 }
438 } elseif ( $wp_query->is_search ) {
439 $type = 'search';
440 } elseif ( $wp_query->is_404 ) {
441 $type = 'notfound';
442 }
443
444 return $type;
445 }
446
447 /**
448 * Prepares the custom css string
449 *
450 * @since 1.0
451 * @param $css_string
452 * @param $prefix
453 * @param bool|false $as_array
454 * @param bool|true $separate_prefix
455 * @return array|string
456 */
457 public static function prepare_css( $css_string, $prefix, $as_array = false, $separate_prefix = true, $wildcard = '' ) {
458
459 $css_array = array(); // master array to hold all values
460 $elements = explode( '}', $css_string );
461
462 // Output is the final processed CSS string.
463 $output = '';
464 $prepared = '';
465 $have_media = false;
466 $media_names = array();
467 $media_names_key = 0;
468 $index = 0;
469
470 foreach ( $elements as $element ) {
471
472 $check_element = trim( $element );
473
474 if ( empty( $check_element ) ) {
475 $index++; // Still increment $index even if empty.
476 continue;
477 }
478
479 // get the name of the CSS element
480 $a_name = explode( '{', $element );
481 $name = $a_name[0];
482
483 // check if @media is present
484 $media_name = '';
485
486 if ( strpos( $name, '@media' ) !== false && isset( $a_name[1] ) ) {
487
488 $have_media = true;
489 $media_name = $name;
490 $media_names[ $media_names_key ] = array(
491 'name' => $media_name,
492 );
493 $name = $a_name[1];
494 $media_names_key++;
495
496 }
497
498 if ( $have_media ) {
499 $prepared = '';
500 }
501
502 // get all the key:value pair styles
503 $a_styles = explode( ';', $element );
504
505 // remove element name from first property element
506 $remove_element_name = ( ! empty( $media_name ) ) ? $media_name . '{' . $name : $name;
507 $a_styles[0] = str_replace( $remove_element_name . '{', '', $a_styles[0] );
508 $names = explode( ',', $name );
509
510 foreach ( $names as $name ) {
511
512 if ( $separate_prefix && empty( $wildcard ) ) {
513 $space_needed = true;
514 } elseif ( $separate_prefix && ! empty( $wildcard ) ) {
515
516 // wildcard is the sibling class of target selector e.g. "wph-modal"
517 if ( strpos( $name, $wildcard ) ) {
518 $space_needed = false;
519 } else {
520 $space_needed = true;
521 }
522 } else {
523 $space_needed = false;
524 }
525
526 $maybe_put_space = ( $space_needed ) ? ' ' : '';
527
528 $prepared .= ( $prefix . $maybe_put_space . trim( $name ).',' );
529
530 }
531
532 $prepared = trim( $prepared, ',' );
533 $prepared .= '{';
534
535 // loop through each style and split apart the key from the value
536 $count = count( $a_styles );
537
538 for ( $a = 0;$a < $count; $a++ ) {
539
540 if ( trim( $a_styles[ $a ] ) ) {
541
542 $a_key_value = explode( ':', $a_styles[ $a ] );
543
544 // build the master css array
545 if ( count( $a_key_value ) > 2 ) {
546 $a_key_value_to_join = array_slice( $a_key_value, 1 );
547 $a_key_value[1] = implode( ':', $a_key_value_to_join );
548 }
549
550 if ( ! isset( $a_key_value[1] ) ) {
551 continue;
552 }
553
554 $css_array[ $name ][ $a_key_value[0] ] = $a_key_value[1];
555 $prepared .= ($a_key_value[0] . ': ' . $a_key_value[1]); // . strpos($a_key_value[1], "!important") === false ? " !important;": ";";
556
557 if ( '' === $a_key_value[1] ) {
558 $prepared .= '';
559 }
560
561 $prepared .= ';';
562 }
563 }
564
565 $prepared .= '}';
566
567 // if have @media earlier, append these styles
568 $prev_media_names_key = $media_names_key - 1;
569
570 if ( isset( $media_names[ $prev_media_names_key ] ) ) {
571
572 if ( isset( $media_names[ $prev_media_names_key ]['styles'] ) ) {
573
574 // See if there were two closing '}' or just one.
575 // (each element is exploded/split on '}' symbol, so having two empty strings afterward in the elements array means two '}'s.
576 $next_element = isset( $elements[ $index + 2 ] ) ? trim( $elements[ $index + 2 ] ) : false;
577
578 // If inside @media block.
579 if ( ! empty( $next_element ) ) {
580 $media_names[ $prev_media_names_key ]['styles'] .= $prepared;
581 } else {
582 // If outside of @media block, add to output.
583 $output .= $prepared;
584 }
585 } else {
586 $media_names[ $prev_media_names_key ]['styles'] = $prepared;
587 }
588 } else {
589
590 // If no @media, add styles to $output outside @media.
591 $output .= $prepared;
592 }
593
594 // Increase index.
595 $index++;
596 }
597
598 // if have @media, populate styles using $media_names
599 if ( $have_media ) {
600
601 // reset first $prepared styles
602 $prepared = '';
603
604 foreach ( $media_names as $media ) {
605 $prepared .= $media['name'] . '{ ' . $media['styles'] . ' }';
606 }
607
608 // Add @media styles to output.
609 $output .= $prepared;
610 }
611
612 return $as_array ? $css_array : $output;
613
614 }
615
616 public static function render_attributes( $html_options, $echo = true ) {
617
618 $special_attributes = array(
619 'async' => 1,
620 'autofocus' => 1,
621 'autoplay' => 1,
622 'checked' => 1,
623 'controls' => 1,
624 'declare' => 1,
625 'default' => 1,
626 'defer' => 1,
627 'disabled' => 1,
628 'formnovalidate' => 1,
629 'hidden' => 1,
630 'ismap' => 1,
631 'loop' => 1,
632 'multiple' => 1,
633 'muted' => 1,
634 'nohref' => 1,
635 'noresize' => 1,
636 'novalidate' => 1,
637 'open' => 1,
638 'readonly' => 1,
639 'required' => 1,
640 'reversed' => 1,
641 'scoped' => 1,
642 'seamless' => 1,
643 'selected' => 1,
644 'typemustmatch' => 1,
645 );
646 if ( array() === $html_options ) {
647 return ''; }
648
649 $html = '';
650 if ( isset( $html_options['encode'] ) ) {
651 $raw = ! $html_options['encode'];
652 unset( $html_options['encode'] );
653 } else {
654 $raw = false;
655 }
656 foreach ( $html_options as $name => $value ) {
657 if ( isset( $special_attributes[ $name ] ) ) {
658 if ( $value ) {
659 $html .= ' ' . $name;
660 $html .= '="' . $name . '"';
661 }
662 } elseif ( null !== $value ) {
663 $html .= ' ' . esc_attr( $name ) . '="' . ($raw ? $value : esc_attr( $value ) ) . '"'; }
664 }
665
666 if ( $echo ) {
667 echo $html; // WPCS: xss ok.
668 } else { return $html; }
669 }
670
671 /**
672 * SUI summary config
673 *
674 * @since 4.0.0
675 */
676 public static function get_sui_summary_config( $class = null ) {
677 $style = '';
678 $image_url = apply_filters( 'wpmudev_branding_hero_image', null );
679 if ( ! empty( $image_url ) ) {
680 $style = 'background-image:url(' . esc_url( $image_url ) . ')';
681 }
682 $sui = array(
683 'summary' => array(
684 'style' => $style,
685 'classes' => array(
686 'sui-box',
687 'sui-summary',
688 ),
689 ),
690 );
691 if ( ! empty( $class ) && is_string( $class ) ) {
692 $sui['summary']['classes'][] = $class;
693 }
694 /**
695 * Dash integration
696 *
697 * @since 4.0.0
698 */
699 $hide_branding = apply_filters( 'wpmudev_branding_hide_branding', false );
700 $branding_image = apply_filters( 'wpmudev_branding_hero_image', null );
701 if ( $hide_branding && ! empty( $branding_image ) ) {
702 $sui['summary']['classes'][] = 'sui-rebranded';
703 } elseif ( $hide_branding && empty( $branding_image ) ) {
704 $sui['summary']['classes'][] = 'sui-unbranded';
705 }
706 return $sui;
707 }
708
709 //a callback function when user migrates from 3x to 4x from ftp
710 //since the activation hook won't run we'd have to check it in init.
711 public function hustle_check_caps(){
712 $admin = get_role( 'administrator' );
713 $roles = get_editable_roles();
714 if( ( $admin && ! $admin->has_cap( 'hustle_menu' ) ) || ( ! $admin && ! empty( $roles ) ) ) {
715 hustle_activation();
716 }
717 }
718 }
719
720 endif;
721
722 /**
723 * Initializing Hustle classes
724 */
725 $hustle = new Opt_In();
726 $hustle_init = new Hustle_Init( $hustle );
727
728 //Load dashboard notice
729 if ( file_exists( Opt_In::$plugin_path . 'lib/wpmudev-dashboard/wpmudev-dash-notification.php' ) ) {
730 global $wpmudev_notices;
731 $wpmudev_notices[] = array(
732 'id' => 1107020,
733 'name' => 'Hustle',
734 'screens' => array(
735 'toplevel_page_hustle',
736 'optin-pro_page_inc_optin',
737 ),
738 );
739 require_once Opt_In::$plugin_path . 'lib/wpmudev-dashboard/wpmudev-dash-notification.php';
740 }
741
742 if ( is_admin() && Opt_In_Utils::_is_free() ) {
743 require_once Opt_In::$plugin_path . 'lib/free-dashboard/module.php';
744 // Register the current plugin.
745 do_action(
746 'wdev-register-plugin',
747 plugin_basename( __FILE__ ), // 1. Plugin ID
748 'Hustle', // 2. Plugin Title
749 '/plugins/wordpress-popup/', // 3. https://wordpress.org
750 __( 'Sign Me Up', 'wordpress-popup' ), // 4. Email Button CTA
751 'f68d9fbc51' // 5. Mailchimp List id
752 );
753 }
754
755 if ( ! function_exists( 'hustle_activation' ) ) {
756 function hustle_activation() {
757 update_option( 'hustle_activated_flag', 1 );
758
759 Hustle_Db::maybe_create_tables( true );
760
761 /**
762 * Add Hustle's custom capabilities.
763 * @since 4.0.1
764 */
765 $hustle_capabilities = array(
766 'hustle_menu',
767 'hustle_edit_module',
768 'hustle_create',
769 'hustle_edit_integrations',
770 'hustle_access_emails',
771 'hustle_edit_settings',
772 );
773
774 $admin = get_role( 'administrator' );
775
776 if ( $admin ) {
777 // If there's an "administrator" role.
778 foreach ( $hustle_capabilities as $cap ) {
779 $admin->add_cap( $cap );
780 }
781
782 } else {
783 // If there's no "administrator".
784 $roles = get_editable_roles();
785
786 foreach( $roles as $role_name => $data ) {
787
788 // Add the capabilities to anyone who can manage options. This was the checked capability in 3.x.
789 if ( isset( $data['capabilities']['manage_options'] ) && $data['capabilities']['manage_options'] ) {
790
791 $role = get_role( $role_name );
792 foreach ( $hustle_capabilities as $cap ) {
793 if ( $role ) {
794 $role->add_cap( $cap );
795 }
796 }
797 }
798 }
799 }
800
801 }
802 }
803 register_activation_hook( __FILE__, 'hustle_activation' );
804