| Server IP : 103.88.176.108 / Your IP : 216.73.216.211 Web Server : Apache/2.4.41 (Ubuntu) System : Linux webserver 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/optimole-wp/inc/conflicts/ |
Upload File : |
<?php
/**
* The Abstract class inherited by all conflicts.
*
* @package \Optimole\Inc\Conflicts
* @author Optimole <friends@optimole.com>
*/
/**
* Class Optml_Abstract_Conflict
*
* @since 2.0.6
*/
abstract class Optml_Abstract_Conflict {
/**
* Constant for low severity.
*
* @since 2.0.6
* @const string SEVERITY_LOW
*/
const SEVERITY_LOW = 'low';
/**
* Constant for medium severity.
*
* @since 2.0.6
* @const string SEVERITY_MEDIUM
*/
const SEVERITY_MEDIUM = 'medium';
/**
* Constant for high severity.
*
* @since 2.0.6
* @const string SEVERITY_HIGH
*/
const SEVERITY_HIGH = 'high';
/**
* The type of the conflict if required.
*
* @since 2.0.6
* @access protected
* @var string $type
*/
protected $type = 'base_conflict';
/**
* Level of conflict severity.
*
* @since 2.0.6
* @access protected
* @var string $severity
*/
protected $severity = self::SEVERITY_LOW;
/**
* Message of the conflict.
*
* @since 2.0.6
* @access protected
* @var string
*/
protected $message = '';
/**
* Priority of conflict for same level of severity conflicts.
*
* @since 2.0.6
* @access protected
* @var int
*/
protected $priority = 1;
/**
* Optml_Abstract_Conflict constructor.
*/
public function __construct() {
$this->define_message();
}
/**
* Set the message property
*
* @since 2.0.6
* @access public
*/
abstract public function define_message();
/**
* Checks if conflict is active.
*
* @param array $dismissed_conflicts A list of dismissed conflicts. Passed by the manager.
*
* @return bool
* @since 2.0.6
* @access public
*/
public function is_active( $dismissed_conflicts = [] ) {
$conflict_id = $this->get_id();
if ( isset( $dismissed_conflicts[ $conflict_id ] ) && $dismissed_conflicts[ $conflict_id ] === 'true' ) {
return false;
}
return $this->is_conflict_valid();
}
/**
* Get the id for the conflict.
*
* @param int $length Optional. A length for the generated ID.
*
* @return bool|string
* @since 2.0.6
* @access public
*/
public function get_id( $length = 8 ) {
$hash = sha1( strtolower( get_called_class() ) . $this->type . $this->severity . $this->priority );
return substr( $hash, 0, $length );
}
/**
* Determine if conflict is applicable.
*
* @return bool
* @since 2.0.6
* @access public
*/
abstract public function is_conflict_valid();
/**
* Get the conflict information.
*
* @return array
* @since 2.0.6
* @access public
*/
public function get_conflict() {
return [
'id' => $this->get_id(),
'type' => $this->type,
'priority' => $this->priority,
'severity' => $this->severity,
'message' => $this->message,
];
}
}