akashop/volumes/wp/wp-content/plugins/optimole-wp/inc/manager.php

731 lines
56 KiB
PHP
Raw Normal View History

2024-03-20 07:48:21 +00:00
<?php
/**
* Class Optml_Manager. Adds hooks for processing tags and urls.
*
* @package \Optml\Inc
* @author Optimole <friends@optimole.com>
*/
final class Optml_Manager {
/**
* Holds allowed compatibilities objects.
*
* @var Optml_compatibility[] Compatibilities objects.
*/
public static $loaded_compatibilities = [];
/**
* Cached object instance.
*
* @var Optml_Manager
*/
protected static $instance = null;
/**
* Holds the url replacer class.
*
* @access public
* @since 1.0.0
* @var Optml_Url_Replacer Replacer instance.
*/
public $url_replacer;
/**
* Holds the tag replacer class.
*
* @access public
* @since 1.0.0
* @var Optml_Tag_Replacer Replacer instance.
*/
public $tag_replacer;
/**
* Holds the lazyload replacer class.
*
* @access public
* @since 1.0.0
* @var Optml_Lazyload_Replacer Replacer instance.
*/
public $lazyload_replacer;
/**
* Holds the hero preloader class.
*
* @access public
* @since 3.9.0
* @var Optml_Hero_Preloader Preloader instance.
*/
public $hero_preloader;
/**
* Holds plugin settings.
*
* @var Optml_Settings WordPress settings.
*/
protected $settings;
/**
* Possible integrations with different plugins.
*
* @var array Integrations classes.
*/
private $possible_compatibilities = [
'shortcode_ultimate',
'foogallery',
'envira',
'beaver_builder',
'jet_elements',
'revslider',
'metaslider',
'essential_grid',
'yith_quick_view',
'cache_enabler',
'elementor_builder',
'divi_builder',
'thrive',
'master_slider',
'pinterest',
'sg_optimizer',
'wp_fastest_cache',
'swift_performance',
'w3_total_cache',
'translate_press',
'give_wp',
'woocommerce',
'smart_search_woocommerce',
'facetwp',
'wp_rest_cache',
'wp_bakery',
'elementor_builder_late',
'wpml',
'otter_blocks',
'spectra',
];
/**
* The current state of the buffer.
*
* @var boolean Buffer state.
*/
private static $ob_started = false;
/**
* Class instance method.
*
* @codeCoverageIgnore
* @static
* @return Optml_Manager
* @since 1.0.0
* @access public
*/
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self();
self::$instance->url_replacer = Optml_Url_Replacer::instance();
self::$instance->tag_replacer = Optml_Tag_Replacer::instance();
self::$instance->lazyload_replacer = Optml_Lazyload_Replacer::instance();
self::$instance->hero_preloader = Optml_Hero_Preloader::instance();
add_action( 'after_setup_theme', [ self::$instance, 'init' ] );
add_action( 'wp_footer', [ self::$instance, 'banner' ] );
}
return self::$instance;
}
/**
* The initialize method.
*/
public function init() {
$this->settings = new Optml_Settings();
$added_sizes = $this->settings->get( 'defined_image_sizes' );
foreach ( $added_sizes as $key => $value ) {
add_image_size( $key, $value['width'], $value['height'], true );
}
foreach ( $this->possible_compatibilities as $compatibility_class ) {
$compatibility_class = 'Optml_' . $compatibility_class;
$compatibility = new $compatibility_class;
/**
* Check if we should load compatibility.
*
* @var Optml_compatibility $compatibility Class to register.
*/
if ( $compatibility->will_load() ) {
if ( $compatibility->should_load_early() ) {
$compatibility->register();
continue;
}
self::$loaded_compatibilities[ $compatibility_class ] = $compatibility;
}
}
if ( ! $this->should_replace() ) {
return;
}
$this->register_hooks();
}
/**
* Render banner.
*
* @return void
*/
public function banner() {
if ( defined( 'REST_REQUEST' ) ) {
return;
}
$has_banner = $this->settings->get( 'banner_frontend' ) === 'enabled';
if ( ! $has_banner ) {
return;
}
$string = __( 'Optimized by Optimole', 'optimole-wp' );
$div_style = [
'display' => 'flex',
'position' => 'fixed',
'align-items' => 'center',
'bottom' => '15px',
'right' => '15px',
'background-color' => '#fff',
'padding' => '8px 6px',
'font-size' => '12px',
'font-weight' => '600',
'color' => '#444',
'border' => '1px solid #E9E9E9',
'z-index' => '9999999999',
'border-radius' => '4px',
'text-decoration' => 'none',
'font-family' => 'Arial, Helvetica, sans-serif',
];
$logo = OPTML_URL . 'assets/img/logo.svg';
$link = 'https://optimole.com/wordpress/?from=badgeOn';
$css = '';
foreach ( $div_style as $key => $value ) {
$css .= $key . ':' . $value . ';';
}
$output = '<a style="' . esc_attr( $css ) . '" href="' . esc_url( $link ) . '" rel="nofollow" target="_blank">';
$output .= '
<svg style="margin-right:6px" width="20" height="20" viewBox="0 0 251 250" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M217.696 99.0926C240.492 152.857 211.284 215.314 153.249 239.999C95.2141 264.683 30.4436 242.239 7.64869 188.474C-15.1462 134.71 14.8767 75.1972 72.9116 50.4991C130.947 25.8007 194.902 45.3142 217.696 99.0926Z" fill="#EDF0FF"/>
<path d="M217.696 99.0926C240.492 152.857 211.284 215.314 153.249 239.999C95.2141 264.683 30.4436 242.239 7.64869 188.474C-15.1462 134.71 14.8767 75.1972 72.9116 50.4991C130.947 25.8007 194.902 45.3142 217.696 99.0926Z" fill="#D7EEFC"/>
<path d="M181.711 75.8034C176.438 78.931 171.418 82.6928 167.832 87.6665C164.246 92.6402 162.221 98.9662 163.346 104.996C163.458 105.602 163.627 106.236 164.091 106.645C164.71 107.18 165.624 107.11 166.425 107.011C178.786 105.334 190.57 99.628 199.556 90.9633C204.956 85.7784 210.103 79.1566 217.542 78.2969C220.987 77.8883 224.475 78.8464 227.582 80.3685C229.186 81.1431 230.732 82.1012 231.899 83.4397C234.571 86.4971 234.796 90.9771 234.402 95.0352C233.967 99.487 232.968 103.926 231.393 108.11C230.001 111.815 226.851 114.661 224.193 117.578C218.203 124.171 211.678 130.301 204.52 135.612C194.437 143.079 184.833 150.772 173.654 156.703C167.93 159.732 162.671 162.029 157.974 166.651C153.488 171.06 149.832 176.33 147.231 182.064C145.093 186.784 143.842 191.546 141.409 196.182C138.836 201.07 135.938 205.804 132.634 210.228C128.584 215.667 124.689 218.809 118.319 221.373C108.63 225.276 98.0689 226.332 87.6486 226.98C79.9569 227.459 72.2365 227.727 64.5448 227.262C62.5477 227.149 58.1321 226.713 57.6544 224.134C57.1197 221.232 61.0852 219.893 63.11 219.471C75.6818 216.85 88.4785 213.145 98.477 205.072C100.502 203.437 102.569 201.056 101.852 198.562C96.5926 198.323 91.5721 200.507 86.5096 201.944C80.9129 203.536 75.0631 204.24 69.2552 204.029C67.3714 203.958 64.9242 203.226 64.9242 201.338C64.9385 199.774 66.6681 198.914 68.0885 198.266C72.9537 196.083 77.0602 192.56 81.096 189.08C84.5268 186.122 88.1269 182.909 89.3643 178.541C89.533 177.95 89.6457 177.288 89.3643 176.752C88.7456 175.541 86.9597 175.865 85.7084 176.386C79.3382 179.021 73.1085 182.007 67.0617 185.332C59.4121 189.545 51.3682 194.448 42.678 193.73C40.9623 193.589 38.7826 192.575 39.12 190.884C39.303 189.94 40.2308 189.348 41.0607 188.869C63.2649 175.935 82.277 156.238 87.3534 131.019C91.5019 110.406 85.9334 89.0332 87.8178 68.0968C88.0987 64.9266 88.5631 61.7426 89.6458 58.7416C90.3911 56.6705 91.4173 54.6978 92.5287 52.7957C99.8831 40.0872 110.711 29.4076 123.493 22.208C135.291 15.5862 148.328 15.0649 160.829 9.92232C168.788 6.6536 176.874 2.80726 185.48 2.97633C186.071 2.99042 186.689 3.03269 187.153 3.38492C187.561 3.70897 187.772 4.21618 187.941 4.72339C189.263 8.6261 189.249 12.8529 190.261 16.8542C190.36 17.2628 190.514 17.7136 190.88 17.9109C191.245 18.1081 191.71 17.9954 192.103 17.8686C195.478 16.7978 198.853 15.727 202.228 14.6563C203.283 14.3181 204.422 13.9941 205.448 14.3745C207.431 15.1071 207.656 17.7981 207.459 19.9116C205.533 41.0312 199.936 64.9968 181.711 75.8034Z" fill="#577BF9"/>
<path d="M118.165 39.6223C108.461 45.8356 99.8553 53.7539 92.8244 62.8836C97.6475 64.3067 102.4 66.0112 107.027 67.9977C103.132 71.8867 98.4348 74.9718 93.3303 77.0008C87.6496 79.2549 83.7963 82.0873 80.3649 87.1594C87.6772 89.1315 95.2572 85.9895 102.387 83.4258C109.572 80.8472 116.941 78.8043 124.436 77.3248C129.006 76.423 133.858 75.6341 137.429 72.6331C137.711 72.3937 138.006 72.0835 137.992 71.7175C137.978 71.4073 137.739 71.1541 137.514 70.9424C134.195 67.885 129.47 66.6172 126.391 63.306C126.053 62.94 125.716 62.4607 125.843 61.9819C125.941 61.6015 126.306 61.3477 126.644 61.1365C130.005 59.009 133.352 56.8816 136.712 54.7541C132.41 50.1187 128.036 45.5397 123.593 41.0453C122.242 39.6786 119.781 38.5796 118.165 39.6223Z" fill="#EE686B"/>
<path d="M165.793 91.1041C163.67 96.2326 163.205 101.953 163.74 107.49C168.296 107.011 172.782 105.897 177.015 104.165C177.703 103.883 178.435 103.545 178.815 102.897C179.067 102.46 179.124 101.924 179.152 101.417C179.461 95.4293 177.085 89.3432 178.617 83.5524C178.969 82.2277 180.08 78.7904 177.788 78.4095C176.551 78.1983 174.553 80.4385 173.639 81.1291C170.152 83.7779 167.466 87.0465 165.793 91.1041Z" fill="#F6E5C1"/>
<path d="M171.558 156.534C169.041 157.929 166.524 159.338 164.274 161.128C161.222 163.565 158.762 166.665 156.498 169.863C150.17 178.824 145.276 188.7 140.411 198.534C139.44 200.479 138.484 202.423 137.514 204.368C136.318 206.776 135.109 209.242 134.8 211.919C134.687 212.905 134.771 214.061 135.573 214.652C136.108 215.047 136.839 215.075 137.499 215.033C140.298 214.892 143.012 214.061 145.656 213.131C164.893 206.34 181.81 193.138 193.073 176.104C194.283 174.273 195.45 172.385 196.223 170.328C196.913 168.482 197.292 166.552 197.63 164.607C198.572 159.226 199.275 153.801 199.697 148.349C199.838 146.587 199.964 142.488 197.574 142.192C195.563 141.938 190.782 145.827 188.967 146.827C183.174 150.068 177.366 153.308 171.558 156.534Z" fill="#F6E5C1"/>
<path d="M58.9198 140.29C55.4043 141.952 51.6495 143.798 49.7369 147.194C47.7403 150.744 48.2744 155.365 50.4259 158.831C52.5778 162.297 56.1071 164.72 59.862 166.298C60.9728 166.763 62.1538 167.172 63.3492 167.031C64.6287 166.89 65.7539 166.143 66.7807 165.354C71.59 161.607 74.9644 156.351 78.241 151.223C82.2209 145.01 86.2987 138.486 87.1005 131.146C87.8878 123.862 79.7317 130.498 77.102 131.738C71.0415 134.583 64.9804 137.43 58.9198 140.29Z" fill="#336093"/>
<path d="M136.515 18.9961C142.604 15.6429 149.129 13.149 155.626 10.6694C164.471 7.30208 173.358 3.92065 182.667 2.24404C183.427 2.10315 184.228 1.99043 184.931 2.2863C185.663 2.58218 186.155 3.27255 186.577 3.93474C188.995 7.82333 190.163 12.4869 189.853 17.0659C189.825 17.5167 189.769 17.9957 189.474 18.3339C189.277 18.5734 188.981 18.7002 188.7 18.827C185.747 20.1655 182.653 21.2645 179.827 22.8565C176.986 24.4486 174.357 26.6183 172.923 29.5348C170.265 34.9309 172.135 41.7078 169.618 47.1744C168.183 50.3022 165.469 52.627 162.727 54.6982C158.621 57.812 153.756 60.714 148.651 60.0097C145.698 59.6011 143.04 58.0232 140.495 56.4591C139.103 55.6137 137.724 54.7827 136.332 53.9374C130.088 50.1473 123.353 45.7373 121.286 38.7209C119.725 33.3952 121.286 30.7183 125.068 27.1396C128.5 23.9273 132.409 21.2504 136.515 18.9961Z" fill="#D6EDFB"/>
<path d="M199.416 58.9386C199.894 59.8829 200.78 60.7847 201.835 60.6575C202.285 60.6011 202.693 60.3761 203.086 60.1362C204.605 59.235 206.18 58.2907 207.08 56.7691C207.924 55.3604 208.064 53.6553 208.177 52.0351C208.416 48.6115 208.5 44.8355 206.391 42.1304C206.152 41.8346 205.857 41.5246 205.477 41.4823C202.468 41.102 200.682 45.7232 200.161 47.8648C199.275 51.4434 197.574 55.3322 199.416 58.9386Z" fill="#F6E5C1"/>
<path d="M220.565 71.295C217.767 72.5633 214.673 74.9163 215.193 77.9594C218.892 77.7764 222.647 77.8046 226.19 78.9031C229.72 80.0023 233.024 82.3127 234.571 85.6803C236.99 90.9354 234.656 97.163 235.696 102.841C240.646 100.178 244.626 95.7538 246.763 90.555C247.663 88.343 248.254 85.8915 247.733 83.5667C247.298 81.6366 246.13 79.8895 245.891 77.9312C245.638 75.8319 246.468 73.789 247.199 71.8025C247.523 70.9428 247.79 69.8581 247.171 69.1675C246.552 68.4775 245.47 68.6185 244.569 68.7733C240.28 69.5341 236.146 69.2665 231.885 68.6041C228.089 68.0264 224.067 69.7171 220.565 71.295Z" fill="#F6E5C1"/>
<path d="M40.5681 149.138C40.4415 149.8 40.3994 150.49 40.1606 151.124C39.1338 153.773 35.2808 154.125 33.7621 156.52C33.4246 157.056 33.2137 157.704 33.3121 158.338C33.495 159.578 34.7324 160.381 35.9277 160.79C37.123 161.198 38.4167 161.409 39.387 162.212C40.9341 163.494 41.1166 165.876 42.5088 167.341C43.451 168.341 44.8289 168.778 46.1509 169.102C49.0477 169.82 52.029 170.201 55.0103 170.229C55.8397 170.243 56.7681 170.173 57.3166 169.553C58.0055 168.778 57.682 167.482 56.9649 166.735C56.2478 165.988 55.2492 165.594 54.3352 165.087C52.0428 163.818 50.2292 161.705 49.3147 159.239C48.3587 156.619 48.4571 153.745 49.1604 151.068C49.6382 149.264 52.5631 145.235 51.2416 143.53C50.0601 142.008 46.4605 143.009 45.0821 143.643C42.8743 144.672 41.0464 146.686 40.5681 149.138Z" fill="#F6E5C1"/>
<path d="M25.8872 210.694C26.0419 211.68 27.1809 212.116 28.1371 212.37C30.6543 213.018 33.1855 213.554 35.7448 214.019C36.9823 214.23 38.2338 214.427 39.4715 214.23C40.7089 214.033 41.932 213.37 42.5087 212.272C42.8321 211.651 42.9449 210.933 42.9726 210.214C43.0151 209.242 42.9023 208.242 42.4384 207.383C41.5665 205.79 39.6257 205.086 37.812 205.044C36.012 205.016 34.2401 205.509 32.4402 205.748C30.134 206.058 25.3247 207.242 25.8872 210.694Z" fill="#6B8FCA"/>
<path d="M151.745 39.27C154.262 38.2133 157.186 38.2133 159.816 39.4954C161.026 38.2274 162.165 36.8748 163.219 35.48C163.304 35.3673 164.57 33.5639 164.471 33.578C163.29 33.6766 162.109 33.9584 160.998 34.381C160.351 34.6206 159.577 33.9725 158.959 33.7471C158.129 33.4371 157.271 33.2257 156.399 33.113C154.599 32.8876 152.392 33.099 150.746 33.8738C148.721 34.8319 146.935 36.3394 145.599 38.1147C143.631 40.7212 142.548 43.9617 143.11 47.2022C143.153 47.4276 143.251 47.6953 143.476 47.7094C143.617 47.7094 143.729 47.6249 143.827 47.5263C145.332 46.1596 146.373 44.328 147.512 42.6655C148.623 41.1157 150.099 39.9604 151.745 39.27Z" fill="#1D445C"/>
<path opacity="0.5" d="M132.213 48.3997C132.606 48.8223 133.07 49.2732 133.605 49.8226C135.475 51.7106 137.022 53.8942 138.991 55.6695C140.284 56.825 142.028 58.121 143.814 58.3045C144.404 58.3609 148.567 58.4875 148.68 58.1635C151.45 49.4423 153.812 40.6788 156.287 31.8449C156.962 29.4356 164.232 9.25987 162.446 8.69632C161.997 8.55544 161.504 8.75266 161.068 8.93582C156.147 11.0915 151.239 13.2471 146.317 15.4028C142.942 16.8821 142.155 18.8828 140.72 22.0811C138.681 26.6459 136.727 31.239 134.842 35.8603C133.717 38.6217 132.649 41.4114 131.537 44.187C130.694 46.2158 131.116 47.188 132.213 48.3997Z" fill="white"/>
<path opacity="0.5" d="M157.693 55.6844C161.448 54.2187 165.498 52.5142 167.453 48.9778C168.507 47.0616 168.817 44.8496 169.098 42.6799C170.799 29.8165 172.501 16.939 174.203 4.07556C174.258 3.61062 170.687 4.97727 170.335 5.35768C169.407 6.3439 169.393 7.59788 169.028 8.87995C167.973 12.5995 166.693 16.2627 165.625 19.9822C163.473 27.4918 161.616 35.0859 160.042 42.7363C159.184 47.0335 158.396 51.3588 157.693 55.6844Z" fill="white"/>
<path d="M199.289 106.546C190.261 110.969 181.725 112.703 171.839 112.914C164.077 113.083 155.879 112.351 149.481 107.941C147.948 106.884 146.556 105.644 145.346 104.249C148.44 104.63 151.52 106.475 154.529 107.349C157.623 108.25 160.829 108.73 164.049 108.405C170.785 107.729 177.267 105.292 183.188 102.094C189.361 98.7685 195.042 94.6402 200.737 90.5544C202.551 89.2584 204.225 87.8635 205.589 86.1446C207.122 84.2145 208.823 82.4674 211.073 81.3965C213.956 80.0298 217.275 79.9452 220.467 80.0718C223.617 80.199 226.865 80.5512 229.579 82.1573C233.995 84.7636 235.978 90.7236 234.121 95.4291C232.883 92.8229 229.973 91.2167 227.09 91.2449C222.59 91.287 217.809 95.4573 214.209 97.7965C209.385 100.938 204.478 103.953 199.317 106.489C199.331 106.531 199.303 106.531 199.289 106.546Z" fill="#6C99CE"/>
<path d="M179.096 24.4344C173.091 28.0553 171.249 34.4096 171.46 41.0033C171.685 47.8084 176.649 52.4015 183.23 54.1485C203.058 59.4036 207.361 34.4519 208.05 20.1513C208.106 18.8551 208.078 17.3898 207.15 16.474C206.503 15.8401 205.575 15.6287 204.675 15.516C198.994 14.8115 192.792 16.474 188.081 19.6864C185.241 21.6166 181.964 22.7015 179.096 24.4344Z" fill="#6C99CE"/>
<path d="M86.9743 69.4919C86.5242 72.7041 86.3556 76.1137 87.7473 79.044C93.9488 75.7897 99.9397 72.1263 105.663 68.0826C102.119 67.0963 98.5756 66.1105 95.032 65.1098C94.4973 64.9688 93.9206 64.7858 93.6397 64.307C93.3445 63.8277 93.4567 63.194 93.6254 62.6583C94.4409 60.052 96.3115 57.9246 98.224 55.9663C103.764 50.2881 110.036 45.3146 116.828 41.2288C118.192 40.4115 119.655 39.524 120.26 38.0728C121.202 35.8326 119.796 33.0288 121.005 30.9295C121.806 29.5347 123.452 28.9571 124.872 28.1822C127.656 26.6746 128.331 23.3918 124.829 22.2224C122.074 21.3066 119.936 23.6595 117.77 25.0403C112.427 28.4499 107.449 31.8594 103.075 36.5088C94.5537 45.54 88.7038 57.1638 86.9743 69.4919Z" fill="#336093"/>
<path d="M94.9195 86.8914C88.4791 87.3143 86.6794 88.0751 87.1576 94.5139C87.7056 102.023 88.4227 109.589 88.4791 117.127C88.5494 126.341 87.3821 135.795 83.1213 143.967C79.9437 150.053 75.2605 155.238 71.1407 160.677C67.1608 165.932 63.3639 170.99 58.6674 175.696C61.6625 172.695 68.328 171.469 72.111 169.313C76.7655 166.665 81.1386 163.522 85.1467 159.958C100.123 146.658 112.005 129.314 115.422 109.265C117.053 99.6988 116.857 89.9206 116.66 80.2275C109.826 82.5237 102.133 86.4264 94.9195 86.8914Z" fill="#336093"/>
<path d="M43.1137 204.283C42.9169 204.156 42.7062 204.015 42.5094 203.93C41.0746 203.184 39.6685 203.282 38.0093 203.297C35.9984 203.325 34.0297 203.423 32.0609 203.776C28.1798 204.452 24.383 205.79 20.8674 207.396C18.8143 208.341 12.0785 210.679 15.7488 213.666C17.1128 214.793 18.8705 215.286 20.6002 215.653C25.1142 216.653 29.7688 216.991 34.3812 216.681C36.8562 216.512 38.8391 216.132 41.131 215.061C41.9891 214.652 42.8605 214.244 43.5638 213.61C46.2919 211.186 46.1371 206.382 43.1137 204.283ZM40.5686 209.862C38.9514 212.328 33.889 211.595 31.5125 211.37C30.711 211.285 29.8672 211.158 29.3188 210.567C29.2063 210.44 29.1079 210.271 29.1079 210.116C29.1079 209.806 29.4032 209.608 29.6844 209.482C31.4 208.622 33.2844 208.059 35.1968 207.847C36.4624 207.72 38.6983 207.312 39.8233 208.059C40.8075 208.721 40.9203 209.327 40.5686 209.862Z" fill="#1D445C"/>
<path d="M185.1 49.0198C186.155 48.2309 187.336 47.2164 187.238 45.9061C187.111 44.3282 185.1 43.4687 183.722 43.8773C182.372 44.2718 180.966 45.8498 180.052 46.8501C175.453 51.894 170.869 56.9519 166.271 61.9958C165.933 62.3624 164.302 63.7993 165.708 63.7429C166.679 63.7009 167.986 62.5034 168.746 61.9538C170.743 60.4887 172.529 58.7554 174.455 57.2195C177.943 54.4302 181.5 51.6968 185.1 49.0198Z" fill="#1D445C"/>
<path d="M175.411 66.871C175.017 67.5334 173.302 70.1258 175.271 68.7171C176.775 67.618 177.802 66.0821 178.983 64.6733C180.234 63.18 181.514 61.7005 182.836 60.2636C184.074 58.9107 185.48 57.7414 186.703 56.3608C187.772 55.1489 190.233 52.4158 188.475 50.7533C187.913 50.2179 186.703 50.6828 186.141 51.0632C185.142 51.7395 184.748 52.8384 184.059 53.7822C183.3 54.8249 182.695 55.9522 181.936 56.9806C179.63 60.179 177.45 63.4758 175.411 66.871Z" fill="#1D445C"/>
<path d="M248.746 78.0012C248.605 77.7336 248.451 77.508 248.296 77.325C248.914 75.8035 249.407 74.1692 249.744 72.3801C249.871 71.7316 250.18 70.21 249.463 68.7449C248.83 67.491 247.55 66.5749 246.06 66.2791C245.005 66.0817 244.007 66.1945 243.093 66.3637C242.137 66.5328 241.222 66.7722 240.323 67.068C237.046 65.1241 233.615 65.5045 230.563 65.8423L229.917 65.9269C226.359 66.3355 222.843 67.5612 219.75 69.5057C215.77 71.9715 212.226 75.5923 209.189 80.2697C206.067 82.3407 203.241 84.9614 200.583 87.399C199.05 88.8221 197.601 90.1601 196.153 91.372C192.778 94.1336 189.727 96.6133 186.338 98.6844C184.903 99.5861 183.398 100.403 181.852 101.122C179.756 94.373 179.883 87.1596 182.274 81.397C183.469 78.579 185.269 76.4377 187.195 74.1548C188.081 73.1126 188.981 72.0135 189.895 70.8016C190.5 69.9845 191.105 69.1535 191.723 68.3081C193.327 66.0817 194.803 63.7856 196.223 61.4464C196.8 60.4888 197.826 59.5306 198.684 60.9394C199.092 61.5874 199.205 62.4189 199.753 62.9541C200.681 63.7994 202.144 63.3063 203.254 62.7147C205.715 61.3762 208.106 59.5163 209.076 56.8536C209.793 54.8671 209.611 52.6549 209.414 50.5416C209.104 47.1884 208.795 43.8492 208.5 40.5242C208.289 38.2981 207.909 36.072 208.148 33.8459C208.373 31.5071 209.245 29.1824 209.709 26.8718C209.821 26.3363 209.99 25.6742 210.159 24.9556C210.651 22.969 211.143 20.9684 211.607 18.9959C212.086 16.9389 212.901 14.9523 213.435 12.9939C214.139 10.4579 214.87 7.1328 213.323 4.77991C211.874 2.582 208.682 1.8071 206.573 3.44144C206.404 3.55415 206.278 3.68096 206.137 3.82185C205.589 4.3995 205.153 5.13215 204.422 5.44209C203.831 5.7098 203.17 5.65346 202.509 5.62526C200.892 5.59707 199.219 5.89297 197.925 6.86509C195.267 8.89393 195.998 11.2891 197.756 13.318C197.32 13.6279 196.912 13.9097 196.561 14.0647C195.605 14.5578 194.634 14.9523 193.65 15.2764C192.919 12.8389 192.173 10.4156 191.414 7.96405C190.669 5.56892 189.867 1.34215 187.322 0.271376C186.689 0.00368107 185.972 -0.0104081 185.283 0.00368111C176.255 0.0882161 167.733 3.61051 159.577 7.17509C157.721 7.97815 155.893 8.73896 154.107 9.49978C150.985 10.8101 147.877 12.1204 144.812 13.5575C143.546 14.1492 142.407 14.9382 141.071 15.2905C139.707 15.6567 138.287 15.7695 136.909 16.1076C135.531 16.4598 134.167 16.9389 132.774 17.277C130.426 17.8265 128.092 18.531 125.828 19.3622C121.342 21.0106 117.039 23.1663 113.059 25.7728C105.114 30.9435 98.3362 37.8754 93.3157 45.9344C90.2083 50.922 87.7893 56.3461 86.1438 61.9959C85.3426 64.7719 84.5409 67.5612 84.0488 70.4074C83.5423 73.3238 83.5705 76.1275 83.7535 79.0721C83.7535 79.1705 83.7673 79.2551 83.7392 79.3541C83.7115 79.4669 83.6407 79.5653 83.5705 79.6637C82.7268 80.8192 81.4755 81.5236 80.4349 82.5099C77.594 85.1726 74.5004 87.5118 72.1101 90.6251C72.124 90.5969 74.1349 90.6958 74.3318 90.7097C75.1191 90.724 75.9065 90.7379 76.6944 90.7522C77.4818 90.7522 78.2691 90.7522 79.0565 90.7522C79.8444 90.7379 80.6317 90.724 81.4191 90.7097C82.291 90.6815 83.1486 90.5692 84.0067 90.4985C84.1754 90.4846 84.3722 90.4846 84.4989 90.6112C84.5973 90.7097 84.6111 90.8506 84.6393 90.9778C84.9346 93.2319 85.6379 95.4721 85.6379 97.7964C85.6661 98.1492 85.7225 98.5014 85.7363 98.8535C85.9331 100.53 86.0736 102.235 86.1582 103.926C86.2002 104.362 86.2428 104.813 86.2566 105.25C86.3412 106.701 86.3832 108.152 86.397 109.631C86.4396 111.576 86.4252 113.506 86.3268 115.45C86.2146 118.367 85.947 121.298 85.5251 124.2C79.1411 128.201 71.7867 132.047 62.3931 136.359C60.9445 137.007 59.4118 137.725 57.8647 138.542C57.5413 138.641 57.1338 138.726 56.7539 138.782C55.7133 138.994 54.6727 139.163 53.6603 139.303C48.9494 140.05 44.0981 140.839 39.7809 144.531C37.2074 146.715 35.6043 149.504 35.2809 152.378C35.2668 152.547 35.2809 152.702 35.2809 152.871C34.2403 153.618 33.2278 154.491 32.2294 155.52C31.8216 155.943 30.8654 156.929 30.6966 158.394C30.556 159.691 31.0482 161.029 32.0607 161.987C32.7497 162.635 33.5232 163.016 34.2544 163.34C34.9434 163.635 35.6184 163.861 36.3215 164.058C37.7699 166.848 40.3151 168.13 42.5654 169.229L43.0432 169.468C47.4449 171.652 51.9866 171.708 56.3884 171.751C56.
<path d="M57.1758 149.912C57.063 150.124 56.9369 150.335 56.9508 150.574C56.9646 150.814 57.1476 151.054 57.3865 151.039C57.5131 151.026 57.6115 150.955 57.7099 150.885C60.0161 149.222 62.3506 147.531 64.2493 145.418C66.1475 143.305 67.6381 140.698 67.9472 137.866C67.9898 137.415 67.9334 136.851 67.5115 136.711C67.3147 136.64 67.1035 136.697 66.9066 136.739C65.6272 137.091 63.7567 137.768 62.8709 138.81C62.1399 139.669 62.0973 140.811 61.6755 141.882C60.5364 144.742 58.6803 147.249 57.1758 149.912Z" fill="#1D445C"/>
<path d="M66.4287 147.926C66.2744 148.194 66.1196 148.49 66.1334 148.786C66.1478 149.095 66.3867 149.42 66.6963 149.392C66.8506 149.377 66.9916 149.279 67.1182 149.194C70.1272 147.024 73.1505 144.827 75.6398 142.079C78.1285 139.332 80.0554 135.936 80.4491 132.245C80.5055 131.668 80.4347 130.921 79.8867 130.738C79.6335 130.653 79.3521 130.709 79.0988 130.78C77.4395 131.245 74.9929 132.104 73.8395 133.471C72.8835 134.598 72.8414 136.077 72.2929 137.472C70.8023 141.191 68.3976 144.46 66.4287 147.926Z" fill="#1D445C"/>
<path d="M106.605 99.9099C106.521 100.036 106.366 100.107 106.212 100.177C102.71 101.713 99.1663 103.249 95.37 103.996C93.9916 104.278 92.5711 104.447 91.1512 104.475C89.4919 104.517 87.8044 104.362 86.2009 103.967C86.1169 102.263 85.9759 100.572 85.7791 98.8953C86.5106 98.4447 87.2841 98.0925 88.0294 97.9654C88.9152 97.8244 89.7728 97.9936 90.6309 98.233C91.2635 98.4022 91.8965 98.5713 92.5711 98.6698C96.8181 99.2901 101.093 98.8671 105.326 98.9379C105.649 98.9379 106.015 98.9517 106.282 99.1209C106.577 99.2757 106.774 99.6561 106.605 99.9099Z" fill="#1D445C"/>
<path d="M100.727 110.97C100.642 111.097 100.487 111.167 100.333 111.238C97.3938 112.506 94.4407 113.802 91.305 114.62C90.7002 114.803 90.0958 114.929 89.4771 115.056C88.4642 115.267 87.4236 115.408 86.3691 115.479C86.4676 113.534 86.4814 111.604 86.4394 109.66C86.524 109.674 86.6224 109.688 86.7064 109.702C88.2535 109.928 89.8005 110.012 91.3471 110.026C94.047 110.069 96.7613 109.913 99.4612 109.956C99.7846 109.956 100.136 109.97 100.417 110.139C100.712 110.308 100.895 110.702 100.727 110.97Z" fill="#1D445C"/>
<path d="M182.837 193.871C181.5 195.322 180.136 196.731 178.702 198.07C177.071 197.351 175.524 196.519 174.005 195.618C172.74 194.871 171.502 194.082 170.251 193.293C170.124 193.209 169.97 193.11 169.913 192.969C169.787 192.687 170.026 192.349 170.349 192.222C170.659 192.11 170.996 192.138 171.348 192.194C173.12 192.462 174.905 192.786 176.663 193.096C178.702 193.448 180.756 193.772 182.837 193.871Z" fill="#1D445C"/>
<path d="M175.074 201.282C173.147 202.888 171.151 204.396 169.055 205.818C167.902 205.283 166.777 204.649 165.737 203.945C165.287 203.649 164.837 203.325 164.415 203.015C161.743 201 159.409 198.619 157.117 196.252C157.004 196.139 156.892 196.026 156.85 195.858C156.807 195.561 157.13 195.266 157.454 195.224C157.792 195.195 158.129 195.308 158.439 195.435C161.996 196.816 165.413 198.619 169.112 199.718C169.534 199.845 169.955 199.957 170.406 200.07C171.966 200.465 173.598 200.352 174.92 201.169C174.948 201.197 175.018 201.226 175.074 201.282Z" fill="#1D445C"/>
</svg>';
$output .= '<span>' . esc_html( $string ) . '</span>';
$output .= '</a>';
echo $output;
}
/**
* Check if we should rewrite the urls.
*
* @return bool If we can replace the image.
*/
public function should_replace() {
if ( apply_filters( 'optml_should_replace_page', false ) ) {
return false;
}
if ( apply_filters( 'optml_force_replacement', false ) === true ) {
return true;
}
if ( is_customize_preview() && $this->settings->get( 'offload_media' ) !== 'enabled' ) {
return false;
}
if ( ( is_admin() && ! self::is_ajax_request() ) || ! $this->settings->is_connected() || ! $this->settings->is_enabled() ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'preview', $_GET ) && ! empty( $_GET['preview'] ) ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'optml_off', $_GET ) && 'true' == $_GET['optml_off'] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'elementor-preview', $_GET ) && ! empty( $_GET['elementor-preview'] ) ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'ct_builder', $_GET ) && ! empty( $_GET['ct_builder'] ) ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'et_fb', $_GET ) && ! empty( $_GET['et_fb'] ) ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'tve', $_GET ) && $_GET['tve'] == 'true' ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'trp-edit-translation', $_GET ) && ( $_GET['trp-edit-translation'] == 'true' || $_GET['trp-edit-translation'] == 'preview' ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'context', $_GET ) && $_GET['context'] == 'edit' ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return false; // @codeCoverageIgnore
}
// avada
if ( array_key_exists( 'fb-edit', $_GET ) && ! empty( $_GET['fb-edit'] ) ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'builder', $_GET ) && ! empty( $_GET['builder'] )
&& array_key_exists( 'builder_id', $_GET ) && ! empty( $_GET['builder_id'] ) ) {
return false; // @codeCoverageIgnore
}
// Motion.page iFrame & builder
if ( ( array_key_exists( 'motionpage_iframe', $_GET ) && $_GET['motionpage_iframe'] == 'true' ) || ( array_key_exists( 'page', $_GET ) && $_GET['page'] == 'motionpage' ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return false; // @codeCoverageIgnore
}
/**
* Disable replacement on POST request and when user is logged in, but allows for sample image call widget in dashboard
*/
if (
isset( $_SERVER['REQUEST_METHOD'] ) &&
$_SERVER['REQUEST_METHOD'] == 'POST' && // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
is_user_logged_in()
&& ( ! isset( $_GET['quality'] ) || ! current_user_can( 'manage_options' ) )
) {
return false; // @codeCoverageIgnore
}
if ( class_exists( 'FLBuilderModel', false ) ) {
$post_data = FLBuilderModel::get_post_data();
if ( isset( $_GET['fl_builder'] ) || isset( $post_data['fl_builder'] ) ) {
return false;
}
}
$filters = $this->settings->get_filters();
return Optml_Filters::should_do_page( $filters[ Optml_Settings::FILTER_TYPE_OPTIMIZE ][ Optml_Settings::FILTER_URL ], $filters[ Optml_Settings::FILTER_TYPE_OPTIMIZE ][ Optml_Settings::FILTER_URL_MATCH ] );
}
/**
* Check if we are in a ajax contex where we should enable replacement.
*
* @return bool Is ajax request?
*/
public static function is_ajax_request() {
if ( apply_filters( 'optml_force_replacement_on', false ) === true ) {
return true;
}
if ( ! function_exists( 'is_user_logged_in' ) ) {
return false;
}
// Disable for logged in users to avoid unexpected results.
if ( is_user_logged_in() ) {
return false;
}
if ( ! function_exists( 'wp_doing_ajax' ) ) {
return false;
}
if ( ! wp_doing_ajax() ) {
return false;
}
if ( isset( $_REQUEST['action'] ) && strpos( $_REQUEST['action'], 'wpmdb' ) !== false ) {
return false;
}
return true;
}
/**
* Register frontend replacer hooks.
*/
public function register_hooks() {
do_action( 'optml_replacer_setup' );
if ( $this->settings->get( 'native_lazyload' ) === 'disabled' ) {
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
}
add_filter( 'the_content', [ $this, 'process_images_from_content' ], PHP_INT_MAX );
/**
* When we have to process cdn images, i.e MIRROR is defined,
* we need this as late as possible for other replacers to occur.
* Otherwise, we can hook first to avoid any other plugins to take care of replacement.
*/
add_action(
self::is_ajax_request() ? 'init' : 'template_redirect',
[
$this,
'process_template_redirect_content',
],
defined( 'OPTML_SITE_MIRROR' ) ? PHP_INT_MAX : PHP_INT_MIN
);
add_action( 'template_redirect', [ $this, 'register_after_setup' ] );
add_action( 'rest_api_init', [ $this, 'process_template_redirect_content' ], PHP_INT_MIN );
foreach ( self::$loaded_compatibilities as $registered_compatibility ) {
$registered_compatibility->register();
}
}
/**
* Run after Optimole is fully setup.
*/
public function register_after_setup() {
do_action( 'optml_after_setup' );
}
/**
* Filter raw HTML content for urls.
*
* @param string $html HTML to filter.
*
* @return mixed Filtered content.
*/
public function replace_content( $html ) {
if ( defined( 'REST_REQUEST' ) && REST_REQUEST && is_user_logged_in() && ( apply_filters( 'optml_force_replacement', false ) !== true ) ) {
return $html;
}
$html = $this->add_html_class( $html );
$html = $this->process_images_from_content( $html );
if ( $this->settings->get( 'video_lazyload' ) === 'enabled' ) {
$html = apply_filters( 'optml_video_replace', $html );
if ( Optml_Lazyload_Replacer::found_iframe() === true ) {
if ( strpos( $html, Optml_Lazyload_Replacer::IFRAME_TEMP_COMMENT ) !== false ) {
$html = str_replace( Optml_Lazyload_Replacer::IFRAME_TEMP_COMMENT, Optml_Lazyload_Replacer::IFRAME_PLACEHOLDER_CLASS, $html );
} else {
$html = preg_replace( '/<head>(.*)<\/head>/ism', '<head> $1' . Optml_Lazyload_Replacer::IFRAME_PLACEHOLDER_STYLE . '</head>', $html );
}
}
}
$html = apply_filters( 'optml_url_pre_process', $html );
$html = $this->process_urls_from_content( $html );
$html = apply_filters( 'optml_url_post_process', $html );
return $html;
}
/**
* Adds a filter that allows adding classes to the HTML tag.
*
* @param string $content The HTML content.
*
* @return mixed
*/
public function add_html_class( $content ) {
if ( empty( $content ) ) {
return $content;
}
$additional_html_classes = apply_filters( 'optml_additional_html_classes', [] );
if ( ! $additional_html_classes ) {
return $content;
}
if ( preg_match( '/<html.*>/ismU', $content, $matches, PREG_OFFSET_CAPTURE ) === 1 ) {
$add_classes = implode( ' ', $additional_html_classes );
foreach ( $matches as $match ) {
if ( strpos( $match[0], 'class' ) !== false ) {
$new_tag = str_replace( [ 'class="', "class='" ], [ 'class="' . $add_classes, "class='" . $add_classes ], $match[0] );
} else {
$new_tag = str_replace( 'html ', 'html class="' . $add_classes . '" ', $match[0] );
}
$content = str_replace( $match[0], $new_tag, $content );
}
}
return $content;
}
/**
* Adds a filter with detected images tags and the content.
*
* @param string $content The HTML content.
*
* @return mixed
*/
public function process_images_from_content( $content ) {
if ( self::should_ignore_image_tags() ) {
return $content;
}
$images = self::parse_images_from_html( $content );
if ( empty( $images ) ) {
return $content;
}
return apply_filters( 'optml_content_images_tags', $content, $images );
}
/**
* Check if we are on a amp endpoint.
*
* IMPORTANT: This needs to be used after parse_query hook, otherwise will return false positives.
*
* @return bool
*/
public static function should_ignore_image_tags() {
// Ignore image tag replacement in feed context as we don't need it.
if ( is_feed() ) {
return true;
}
// Ignore image tags replacement in amp context as they are not available.
if ( function_exists( 'is_amp_endpoint' ) ) {
return is_amp_endpoint();
}
if ( function_exists( 'ampforwp_is_amp_endpoint' ) ) {
return ampforwp_is_amp_endpoint();
}
return apply_filters( 'optml_should_ignore_image_tags', false ) === true;
}
/**
* Match all images and any relevant <a> tags in a block of HTML.
*
* @param string $content Some HTML.
*
* @return array An array of $images matches, where $images[0] is
* an array of full matches, and the link_url, img_tag,
* and img_url keys are arrays of those matches.
*/
public static function parse_images_from_html( $content ) {
$images = [];
$header_start = null;
$header_end = null;
if ( preg_match( '/<header.*<\/header>/ismU', $content, $matches, PREG_OFFSET_CAPTURE ) === 1 ) {
$header_start = $matches[0][1];
$header_end = $header_start + strlen( $matches[0][0] );
}
$regex = '/(?:<a[^>]+?href=["|\'](?P<link_url>[^\s]+?)["|\'][^>]*?>\s*)?(?P<img_tag>(?:<noscript\s*>\s*)?<img[^>]*?\s?(?:' . implode( '|', array_merge( [ 'src' ], Optml_Tag_Replacer::possible_src_attributes() ) ) . ')=["\'\\\\]*?(?P<img_url>[' . Optml_Config::$chars . ']{10,}).*?>(?:\s*<\/noscript\s*>)?){1}(?:\s*<\/a>)?/ismu';
if ( preg_match_all( $regex, $content, $images, PREG_OFFSET_CAPTURE ) ) {
if ( OPTML_DEBUG ) {
do_action( 'optml_log', $images );
}
foreach ( $images as $key => $unused ) {
// Simplify the output as much as possible, mostly for confirming test results.
if ( is_numeric( $key ) && $key > 0 ) {
unset( $images[ $key ] );
continue;
}
$is_no_script = false;
foreach ( $unused as $url_key => $url_value ) {
if ( $key === 'img_url' ) {
$images[ $key ][ $url_key ] = rtrim( $url_value[0], '\\' );
continue;
}
$images[ $key ][ $url_key ] = $url_value[0];
if ( $key === 0 ) {
$images['in_header'][ $url_key ] = $header_start !== null ? ( $url_value[1] > $header_start && $url_value[1] < $header_end ) : false;
// Check if we are in the noscript context.
if ( $is_no_script === false ) {
$is_no_script = strpos( $images[0][ $url_key ], '<noscript' ) !== false ? true : false;
}
if ( $is_no_script ) {
$images['in_header'][ $url_key ] = true;
$is_no_script = strpos( $images[0][ $url_key ], '</noscript' ) !== false ? false : true;
}
}
}
}
return $images;
}
return [];
}
/**
* Process url replacement from raw html strings.
*
* @param string $html Raw html.
*
* @return string Processed string.
*/
public function process_urls_from_content( $html ) {
$extracted_urls = $this->extract_urls_from_content( $html );
if ( OPTML_DEBUG ) {
do_action( 'optml_log', 'matched urls' );
do_action( 'optml_log', $extracted_urls );
}
return $this->do_url_replacement( $html, $extracted_urls );
}
/**
* Method to extract assets from content.
*
* @param string $content The HTML content.
*
* @return array
*/
public function extract_urls_from_content( $content ) {
$extensions = array_keys( Optml_Config::$image_extensions );
if ( $this->settings->use_cdn() && ! self::should_ignore_image_tags() ) {
$extensions = array_merge( $extensions, array_keys( Optml_Config::$assets_extensions ) );
}
$regex = '/(?:[(|\s\';",=\]])((?:http|\/|\\\\){1}(?:[' . Optml_Config::$chars . ']{10,}\.(?:' . implode( '|', $extensions ) . ')))(?=(?:http|>|%3F|\?|"|&|,|\s|\'|\)|\||\\\\|}|\[))/Uu';
preg_match_all(
$regex,
$content,
$urls
);
return $this->normalize_urls( $urls[1] );
}
/**
* Normalize extracted urls.
*
* @param array $urls Raw urls extracted.
*
* @return array Normalized array.
*/
private function normalize_urls( $urls ) {
$urls = array_map(
function ( $value ) {
$value = str_replace( '&quot;', '', $value );
return rtrim( $value, '\\";\'' );
},
$urls
);
$urls = array_unique( $urls );
return array_values( $urls );
}
/**
* Process string content and replace possible urls.
*
* @param string $html String content.
* @param array $extracted_urls Urls to check.
*
* @return string Processed html.
*/
public function do_url_replacement( $html, $extracted_urls ) {
$extracted_urls = apply_filters( 'optml_extracted_urls', $extracted_urls );
if ( empty( $extracted_urls ) ) {
return $html;
}
$slashed_config = addcslashes( Optml_Config::$service_url, '/' );
$extracted_urls = array_filter(
$extracted_urls,
function ( $value ) use ( $slashed_config ) {
return strpos( $value, Optml_Config::$service_url ) === false && strpos( $value, $slashed_config ) === false || Optml_Media_Offload::is_not_processed_image( $value ) || $this->tag_replacer->url_has_dam_flag( $value );
}
);
$upload_resource = $this->tag_replacer->get_upload_resource();
$urls = array_combine( $extracted_urls, $extracted_urls );
$urls = array_map(
function ( $url ) use ( $upload_resource ) {
$is_slashed = strpos( $url, '\/' ) !== false;
$is_relative = strpos(
$url,
$is_slashed ?
addcslashes( $upload_resource['content_path'], '/' ) :
$upload_resource['content_path']
) === 0;
if ( $is_relative ) {
$url = $upload_resource['content_host'] . $url;
}
return apply_filters( 'optml_content_url', $url );
},
$urls
);
foreach ( $urls as $origin => $replace ) {
$html = preg_replace( '/(?<![\/|:|\\w])' . preg_quote( $origin, '/' ) . '/m', $replace, $html );
}
return $html;
}
/**
* Init html replacer handler.
*/
public function process_template_redirect_content() {
// Early exit if function was already called, we don't want duplicate ob_start
if ( self::$ob_started === true ) {
return;
}
self::$ob_started = true;
// We no longer need this if the handler was started.
remove_filter( 'the_content', [ $this, 'process_images_from_content' ], PHP_INT_MAX );
ob_start(
[ &$this, 'replace_content' ]
);
}
/**
* Throw error on object clone
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @codeCoverageIgnore
* @access public
* @return void
* @since 1.0.0
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'optimole-wp' ), '1.0.0' );
}
/**
* Disable unserializing of the class
*
* @codeCoverageIgnore
* @access public
* @return void
* @since 1.0.0
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'optimole-wp' ), '1.0.0' );
}
}