| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); |
| 3 |
|
| 4 |
/** |
| 5 |
* Class containing deprecated methods of Imagify_Assets. |
| 6 |
* |
| 7 |
* @since 1.9.2 |
| 8 |
* @author Grégory Viguier |
| 9 |
*/ |
| 10 |
class Imagify_Assets_Deprecated { |
| 11 |
|
| 12 |
/** |
| 13 |
* Add Intercom on Options page an Bulk Optimization. |
| 14 |
* Previously was _imagify_admin_print_intercom() |
| 15 |
* |
| 16 |
* @since 1.6.10 |
| 17 |
* @since 1.9.2 Deprecated. |
| 18 |
* @author Grégory Viguier |
| 19 |
* @deprecated |
| 20 |
*/ |
| 21 |
public function print_support_script() { |
| 22 |
_deprecated_function( get_class( $this ) . '::' . __FUNCTION__ . '()', '1.9.2' ); |
| 23 |
|
| 24 |
if ( ! Imagify_Requirements::is_api_key_valid() ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
$user = get_imagify_user(); |
| 29 |
|
| 30 |
if ( empty( $user->is_intercom ) || empty( $user->display_support ) ) { |
| 31 |
return; |
| 32 |
} |
| 33 |
?> |
| 34 |
<script> |
| 35 |
window.intercomSettings = { |
| 36 |
app_id: 'cd6nxj3z', |
| 37 |
user_id: <?php echo (int) $user->id; ?> |
| 38 |
}; |
| 39 |
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/cd6nxj3z';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})() |
| 40 |
</script> |
| 41 |
<?php |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Make sure Heartbeat is registered if the given script requires it. |
| 46 |
* Lots of people love deregister Heartbeat. |
| 47 |
* |
| 48 |
* @since 1.6.11 |
| 49 |
* @since 1.9.3 Deprecated. |
| 50 |
* @author Grégory Viguier |
| 51 |
* @deprecated |
| 52 |
* |
| 53 |
* @param string $handle Name of the script. Should be unique. |
| 54 |
*/ |
| 55 |
protected function maybe_register_heartbeat( $handle ) { |
| 56 |
global $wp_version; |
| 57 |
|
| 58 |
_deprecated_function( get_class( $this ) . '::' . __FUNCTION__ . '()', '1.9.3' ); |
| 59 |
|
| 60 |
if ( wp_script_is( 'heartbeat', 'registered' ) ) { |
| 61 |
return; |
| 62 |
} |
| 63 |
|
| 64 |
if ( ! empty( $this->scripts[ $handle ] ) ) { |
| 65 |
// If we registered it, it's one of our scripts. |
| 66 |
$handle = self::JS_PREFIX . $handle; |
| 67 |
} |
| 68 |
|
| 69 |
$wp_scripts = wp_scripts(); |
| 70 |
$dependencies = $wp_scripts->query( $handle ); |
| 71 |
|
| 72 |
if ( ! $dependencies || ! $dependencies->deps ) { |
| 73 |
return; |
| 74 |
} |
| 75 |
|
| 76 |
$dependencies = array_flip( $dependencies->deps ); |
| 77 |
|
| 78 |
if ( ! isset( $dependencies['heartbeat'] ) ) { |
| 79 |
return; |
| 80 |
} |
| 81 |
|
| 82 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
| 83 |
$depts = [ 'jquery' ]; |
| 84 |
|
| 85 |
if ( version_compare( $wp_version, '5.0.0' ) >= 0 ) { |
| 86 |
$depts[] = 'wp-hooks'; |
| 87 |
} |
| 88 |
|
| 89 |
wp_register_script( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", $depts, false, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NoExplicitVersion |
| 90 |
|
| 91 |
if ( $wp_scripts->get_data( 'heartbeat', 'data' ) ) { |
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
/** This filter is documented in /wp-includes/script-loader.php */ |
| 96 |
$data = apply_filters( 'heartbeat_settings', [] ); |
| 97 |
|
| 98 |
if ( empty( $data['nonce'] ) ) { |
| 99 |
$data = wp_heartbeat_settings( $data ); |
| 100 |
} |
| 101 |
|
| 102 |
wp_localize_script( 'heartbeat', 'heartbeatSettings', $data ); |
| 103 |
} |
| 104 |
} |
| 105 |
|