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