| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Electro Extension Compatibility |
| 5 |
* |
| 6 |
* @package WPFunnels\Compatibility\Plugin |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace WPFunnels\Compatibility\Plugin; |
| 10 |
|
| 11 |
use WPFunnels\Wpfnl_functions; |
| 12 |
use WPFunnels\Traits\SingletonTrait; |
| 13 |
|
| 14 |
/** |
| 15 |
* Electro Extension Compatibility |
| 16 |
* |
| 17 |
* @package WPFunnels\Compatibility\Plugin |
| 18 |
*/ |
| 19 |
class ElectroExtension extends PluginCompatibility{ |
| 20 |
use SingletonTrait; |
| 21 |
|
| 22 |
/** |
| 23 |
* Initiate Filters/Hook |
| 24 |
* |
| 25 |
* @since 2.7.7 |
| 26 |
*/ |
| 27 |
public function init() { |
| 28 |
add_filter( 'template_redirect', [ $this, 'set_cookie' ] ); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
/** |
| 33 |
* Set post id in cookie variable |
| 34 |
* |
| 35 |
* @return void |
| 36 |
* @since 2.7.7 |
| 37 |
*/ |
| 38 |
public function set_cookie(){ |
| 39 |
if ( Wpfnl_functions::is_funnel_step_page() ) { |
| 40 |
global $post; |
| 41 |
if( !$post ){ |
| 42 |
return; |
| 43 |
} |
| 44 |
$step_id = isset($post->ID) ? $post->ID : ''; |
| 45 |
if( !$step_id ){ |
| 46 |
return; |
| 47 |
} |
| 48 |
|
| 49 |
$cookie_name = 'wpfunnels_current_post_id'; |
| 50 |
ob_start(); |
| 51 |
setcookie( $cookie_name, wp_json_encode( $step_id ), time() + 3600 * 6, '/', COOKIE_DOMAIN ); |
| 52 |
ob_end_flush(); |
| 53 |
|
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
/** |
| 60 |
* Check if electro extensions is activated |
| 61 |
* |
| 62 |
* @return bool |
| 63 |
* @since 2.7.7 |
| 64 |
*/ |
| 65 |
public function maybe_activate() |
| 66 |
{ |
| 67 |
if (in_array('electro-extension/electro-extensions.php', apply_filters('active_plugins', get_option('active_plugins')))) { |
| 68 |
return true; |
| 69 |
}elseif( function_exists('is_plugin_active') ){ |
| 70 |
if( is_plugin_active( 'electro-extensions/electro-extensions.php' )){ |
| 71 |
return true; |
| 72 |
} |
| 73 |
} |
| 74 |
return false; |
| 75 |
} |
| 76 |
} |
| 77 |
|