HEX
Server: LiteSpeed
System: Linux chromium.pvtwebs.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: plandeptncgov (1317)
PHP: 8.3.31
Disabled: exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/plandeptncgov/public_html/wp-content/plugins/optimole-wp/inc/compatibilities/pinterest.php
<?php

/**
 * Class Pinterest.
 *
 * @reason Pinterest plugins picks eco images to share
 */
class Optml_pinterest extends Optml_compatibility {
	/**
	 * String with all css selectors to target
	 *
	 * @var string
	 */
	private $selectors;
	/**
	 * Should we load the integration logic.
	 *
	 * @return bool Should we load.
	 */
	function should_load() {

		include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

		$load = false;
		$selectors_array = [];
		if ( $this->isShareaholic() ) {
			$selectors_array[] = 'li.shareaholic-share-button[data-service=\"pinterest\"]';
			$load = true;
		}
		if ( $this->isSassySocialShare() ) {
			$selectors_array[] = '.heateorSssSharing.heateorSssPinterestBackground';
			$load = true;
		}
		$this->selectors = implode( ', ', array_filter( $selectors_array ) );
		return $load;
	}

	/**
	 * Register integration details.
	 */
	public function register() {
		add_action(
			'wp_enqueue_scripts',
			function () {
				wp_register_script( 'optml-pinterest', false );
				wp_enqueue_script( 'optml-pinterest' );
				$script = sprintf(
					'
			(function(w, d){
			w.addEventListener("load", function() {
					const addCustomEventListener = function (selector, event, handler) {
		                let rootElement = document.querySelector(\'body\');
		                  rootElement.addEventListener(event, function (evt) {
			                  var targetElement = evt.target;
			                  while (targetElement != null) {
				                  if (targetElement.matches(selector)) {
					                  handler(evt);
					                  return;
				                  }
			                      targetElement = targetElement.parentElement;
			                  }
		                  },
		                  true
		                   );
                   };
					addCustomEventListener(\'%s\',\'mouseover\',function(){
						let images = d.getElementsByTagName( "img" );
						for ( let i = 0; i < images.length; i++ ) {
							if ( "optSrc" in images[i].dataset ) {
								images[i].src = images[i].dataset.optSrc ;
							}
						}
					});
			});		
			}(window, document));
		',
					$this->selectors
				);
				wp_add_inline_script( 'optml-pinterest', $script );
			}
		);
	}
	/**
	 Check if plugin is active.

	 @return bool
	 */
	private function isShareaholic() {

		if ( ! is_plugin_active( 'shareaholic/shareaholic.php' ) ) {
			return false;
		}
		return true;

	}
	/**
	 * Check if plugin is active.
	 *
	 * @return bool
	 */
	private function isSassySocialShare() {

		if ( ! is_plugin_active( 'sassy-social-share/sassy-social-share.php' ) ) {
			return false;
		}
		$ss_options = get_option( 'heateor_sss' );
		$ss_bars = ['vertical_re_providers', 'horizontal_re_providers'];
		if ( ! is_array( $ss_options ) ) {
			return false;
		}
		foreach ( $ss_bars as $key => $bar ) {
			if ( ! isset( $ss_options[ $bar ] ) ) {
				continue;
			}
			foreach ( $ss_options[ $bar ] as $index => $value ) {
				if ( isset( $value ) && is_string( $value ) ) {
					if ( strpos( $value, 'pinterest' ) !== false ) {
						return true;
					}
				}
			}
		}

		return false;
	}
}