HEX
Server: Apache/2
System: Linux vpslll9m.sdns.vn 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
User: thuexe247c (1044)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,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/thuexe247c/public_html/wp-content/plugins/date-counter/Classes/AbstractDatetime.php
<?php


abstract class AbstractDatetime
{

	public $datetime;
	public $timezone;

	public function __construct() {
		add_filter( 'get_my_plugin_instance', [ $this, 'get_instance' ] );

		try {
			$this->timezone = wp_timezone();
		} catch (Exception $e) {
			$this->timezone = new DateTimeZone(date_default_timezone_get());
		} finally {
			$this->datetime = new DateTime( "now", $this->timezone );
		}
	}

	abstract public function display($atts);

	public function get_instance()
	{
		return $this;
	}

	protected function get_datetime(string $datetime_string) : DateTime
	{
		if (strpos(strtolower($datetime_string), 'post:') !== false)
		{
			list($post_type, $date_type) = explode(':', strtolower($datetime_string));

			global $post;

			switch ($date_type) {
				case "created":
					return new DateTime($post->post_date, $this->timezone);
					break;
				case "modified":
					return new DateTime($post->post_modified, $this->timezone);
					break;
				default:
					throw new Exception('Invalid date type, possible values are created and modified.');
					break;
			}
		} else {
			return new DateTime($datetime_string, $this->timezone);
		}
	}

	protected static function error_message($message) {
		return sprintf("<span style='color: #D50032;'>%s error:</span> %s", static::class, $message);
	}
}