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