ge'] = str_replace('https://wordpress.org/support/forums/', 'https://wpvar.com/support/', $args['message']);
}
return $args;
}
/**
* Get Timezone
*
* Gets Correct timezone.
*
* @since 1.0.0
*
* @return string Timezone format.
*/
private function timezone()
{
$utc = (wp_timezone_override_offset()) ? wp_timezone_override_offset() : get_option('gmt_offset');
$format = explode('.', $utc);
$format = str_replace('+', '', $format);
if (isset($format[1])) {
$result = (($format[0] > 0) ? '+' . $format[0] : $format[0]) . ':' . (($format[1] == 5) ? '30' : $format[1]);
} elseif (isset($format[0]) && !isset($format[1])) {
if ($format[0] == 0) {
return 0;
}
$result = ($format[0] > 0) ? '+' . $format[0] . ':00' : $format[0] . ':00';
} else {
$result = 0;
}
return $result;
}
/**
* Disable shamsi regarding lang
*
* If language is not set to farsi admins can choose to disable shamsi dates.
*
* @since 2.1.0
*
* @return bool true or false.
*/
protected function no_lang_no_shamsi()
{
if ($this->option('activate-no-lang-no-shamsi', true, false) && get_locale() != 'fa_IR' && get_locale() != 'fa_AF') {
return true;
}
return false;
}
/**
* Disable shamsi dates
*
* Disable shamsi dates if link had set so.
*
* @since 3.0.0
*
* @return bool true or false.
*/
protected function can_continue()
{
if (!$this->pro()) {
return true;
}
$links = $this->option('advanced-group', false, null);
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (!empty($links)) {
foreach ($links as $link) {
if ($link['advanced-link'] === $actual_link) {
return false;
}
}
}
return true;
}
/**
* Make dates Jalali aka Shamsi
*
* Convert wordpress dates to Shamsi aka Jalali dates.
*
* @since 1.0.0
*
* @param string $date Date to convert.
* @param string $format format of dates.
* @param int $timestamp Date in timestamp.
* @return mixed converted date.
*/
public function wp_shamsi($date = null, $format = null, $timestamp = null, $timezone = null)
{
if (!$this->can_continue()) {
return $date;
}
if ($timestamp < 0) {
return $date;
}
$date = $this->normalize_date($date);
$go = apply_filters('wpsh_date_before', true);
if ($go !== true) {
return $date;
}
/* Hook to add modify formats*/
$format = apply_filters('wpsh_date_replace_formats', $format);
$skip_formats = array(
// DATE_W3C DATE_ATOM DATE_RFC3339
'Y-m-d\TH:i:sP',
// DATE_RSS DATE_RFC822 DATE_RFC1036 DATE_RFC1123 DATE_RFC2822
'D, d M Y H:i:s O',
// DATE_COOKIE DATE_RFC850
'l, d-M-Y H:i:s T',
// DATE_ISO8601
'Y-m-d\TH:i:sO',
// DATE_ISO8601 Variant
'Y-m-d\TH:i:s',
// DATE_ISO8601 Variant
'Y-m-d\TH:i',
// DATE_W3C DATE_ATOM DATE_RFC3339 Variant
'Y-m-dTH:i:sP'
);
/* Hook to add custom formats to be skipped */
$skip_formats = apply_filters('wpsh_date_skip_formats', $skip_formats);
if (is_array($skip_formats) && in_array($format, $skip_formats)) {
return $date;
}
if (!$this->option('activate-shamsi', true, true) || $this->no_lang_no_shamsi()) {
return $date;
}
if ($this->option('activate-admin-shamsi', true, false) && is_admin()) {
return $date;
}
if ($format == null) {
$format = 'Y m d H:i:s';
}
$format = ($format == 'F j, Y') ? 'j F, Y' : $format; // Make date readable without changing default format.
$format = str_replace(',', '', $format);
$format = str_replace('،', '', $format);
$format = str_replace('.', '', $format);
$format = str_replace('S', '', $format);
$format = str_replace('js', 'j s', $format);
$format = str_replace('M j', 'j M', $format);
$format = str_replace('F j', 'j F', $format);
if ($timezone == null || $timezone == '0') {
$timezone = $this->timezone();
}
if ($this->timezone() == 0) {
$timezone = 1;
}
$date = ($timezone == '1') ? new WPSH_Jalali($timestamp, 'UTC') : new WPSH_Jalali($timestamp, $timezone);
$date = $date->format($format);
/* Deprecated since 2.0.0 */
//$date = $this->persian_num($date);
/* Filter returned date to extend plugins developement capacity */
return apply_filters('wpsh_date', $date, $format, $timestamp, $timezone);
}
/**
* Correct diff
*
* Correct human readable dates
*
* @since 2.1.0
*
* @param string $since The difference in human readable text.
* @param int $diff The difference in seconds.
* @param int $from Unix timestamp from which the difference begins.
* @param int $to Unix timestamp to end the time difference.
* @return string Corrected human readable date.
*/
public function wp_shamsi_diff($since, $diff, $from, $to)
{
if ($from < 0 && $to === time()) {
$from = date('Y-m-d H:i:s', $from);
$from = $this->gregorian($from, 'Y-m-d H:i:s');
$to = time();
return human_time_diff(strtotime($from), $to);
} else {
return $since;
}
}
/**
* Post date to gregorian
*
* Converts any shamsi dates that wants to be stored in posts database to gregorian.
*
* @since 2.0.0
*
* @param array $data post data in array.
* @return array new validated post in array.
*/
public function save_post_date($data)
{
$check_point = date('Y', strtotime($data['post_date']));
if ($check_point >= 1970) {
return $data;
}
$data['post_date'] = $this->gregorian($data['post_date'], 'Y-m-d H:i:s');
$data['post_date_gmt'] = $this->gregorian($data['post_date_gmt'], 'Y-m-d H:i:s');
return $data;
}
/**
* Comment date to gregorian
*
* Converts any shamsi dates that wants to be stored in comments database to gregorian.
*
* @since 2.0.0
*
* @param array $data comment data in array.
* @return array new validated comment data in array.
*/
public function save_comment_date($data)
{
$check_point = date('Y', strtotime($data['comment_date']));
if ($check_point >= 1970) {
return $data;
}
$data['comment_date'] = $this->gregorian($data['comment_date'], 'Y-m-d H:i:s');
$data['comment_date_gmt'] = $this->gregorian($data['comment_date_gmt'], 'Y-m-d H:i:s');
return $data;
}
/**
* Farsi numbers to English
*
* Farsi numbers should not be processed within PHP or Database
*
* @since 2.0.0
*
* @param string $data Date wich we want to validate.
* @return string new validated date.
*/
private function normalize_date($data)
{
$fa = array(
'۰',
'۱',
'۲',
'۳',
'۴',
'۵',
'۶',
'۷',
'۸',
'۹'
);
$en = array(
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
);
$data = str_replace($fa, $en, $data);
return $data;
}
/**
* Shamsi to Gregorian
*
* Convert Shamsi dates to Gregorian.
*
* @since 2.0.0
*
* @param mixed $date Date to convert.
* @param string $format Format of converted dates.
* @return mixed Converted date.
*/
public function gregorian($date, $format = null)
{
$date = $this->normalize_date($date);
if ($format == null) {
$format = 'Y m d H:i:s';
}
$date = new WPSH_Jalali($date, $this->timezone());
$date = $date->tog()
->format($format);
return $date;
}
/**
* Latin numbers to Farsi
*
* Before showing dates converts its latin numbers to farsi.
*
* @deprecated 2.0.0
*
* @param int $content Number to convert.
* @return int Converted number.
*/
private function persian_num($content) // Display dates in persian numbers evein if jQuery is not available or dates displayed in admin area
{
if (!$this->option('persian-num', true, true)) {
return $content;
}
$fa = array(
'۰',
'۱',
'۲',
'۳',
'۴',
'۵',
'۶',
'۷',
'۸',
'۹'
);
$en = array(
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
);
$result = str_replace($en, $fa, $content);
return $result;
}
/**
* Validate pro
*
* Pro version validation.
*
* @since 3.0.0
*
* @return bool true if is validated.
*/
protected function pro($soft = false)
{
$shamsi = WPSH_PLUGINS_PATH . '/wp-shamsi-pro/wp-shamsi-pro.php';
$exists = file_exists($shamsi) ? true : false;
if (in_array('wp-shamsi-pro/wp-shamsi-pro.php', apply_filters('active_plugins', get_option('active_plugins'))) && $exists) {
return true;
} else {
return false;
}
// @deprecated 4.3.0
/*
$serial = !empty(get_option('wpsh_pro_license')) ? get_option('wpsh_pro_license') : false;
$status = !empty(get_option('wpsh_pro_license_status')) && get_option('wpsh_pro_license_status') == 1 ? true : false;
$due = !empty(get_option('wpsh_pro_license_due')) && get_option('wpsh_pro_license_due') > current_time('timestamp', false) ? true : false;
if ($soft) {
if ($serial && $status && $due) {
return true;
} else {
return false;
}
} else {
if (!in_array('wp-shamsi-pro/wp-shamsi-pro.php', apply_filters('active_plugins', get_option('active_plugins')))) {
return false;
}
if ($serial && $status && $due && $exists) {
return true;
} else {
return false;
}
}
*/
}
/**
* Validate VIP
*
* VIP version validation.
*
* @since 3.0.0
*
* @return bool true if is validated.
*/
protected function vip()
{
if (!$this->pro()) {
return false;
} else {
return true; // Since 4.3.0
}
$vip = get_option('wpsh_pro_is_vip');
if (!empty($vip) && $vip == 1) {
return true;
}
return false;
}
/**
* Validate due
*
* Pro version due date.
*
* @since 3.0.0
*
* @return mixed Return in dayas or bool.
*/
protected function pro_due($int = false)
{
if (!$this->pro()) {
return null;
}
$reminder = 30;
$due = get_option('wpsh_pro_license_due');
$days = 60 * 60 * 24;
$now = current_time('timestamp', false);
$remain = floor(($due - $now) / $days);
if ($int) {
return $remain;
} else {
if ($remain < $reminder) {
return true;
} else {
return false;
}
}
}
/**
* $_GET Mask
*
* Mask and escape $_GET
*
* @since 2.1.0
*
* @param string $key Key of $_GET.
* @param string $mode String or boolean.
* @return mixed Escaped result or boolean.
*/
protected function get($key, $mode = 'string')
{
if ($mode == 'string') {
$get = (isset($_GET[$key])) ? wp_kses_post($_GET[$key]) : null;
}
if ($mode == 'bool') {
$get = (isset($_GET[$key])) ? true : false;
}
return $get;
}
/**
* $_POST Mask
*
* Mask and escape $_POST
*
* @since 2.1.0
*
* @param string $key Key of $_POST.
* @param string $mode String or boolean.
* @return mixed Escaped result or boolean.
*/
protected function post($key, $mode = 'string')
{
if ($mode == 'string') {
$post = (isset($_POST[$key])) ? wp_kses_post($_POST[$key]) : null;
}
if ($mode == 'bool') {
$post = (isset($_POST[$key])) ? true : false;
}
return $post;
}
}
Fatal error: Uncaught Error: Class 'WPSH_Core' not found in /home/arasetne/public_html/wp-content/plugins/wp-shamsi/inc/autoload.php:20
Stack trace:
#0 /home/arasetne/public_html/wp-content/plugins/wp-shamsi/wp-shamsi.php(28): require_once()
#1 /home/arasetne/public_html/wp-settings.php(517): include_once('/home/arasetne/...')
#2 /home/arasetne/public_html/wp-config.php(188): require_once('/home/arasetne/...')
#3 /home/arasetne/public_html/wp-load.php(50): require_once('/home/arasetne/...')
#4 /home/arasetne/public_html/wp-blog-header.php(13): require_once('/home/arasetne/...')
#5 /home/arasetne/public_html/index.php(17): require('/home/arasetne/...')
#6 {main}
thrown in /home/arasetne/public_html/wp-content/plugins/wp-shamsi/inc/autoload.php on line 20