This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,75 @@
<?php
namespace Nextend\Framework\Platform;
use Nextend\Framework\Pattern\GetAssetsPathTrait;
abstract class AbstractPlatform {
use GetAssetsPathTrait;
protected $isAdmin = false;
protected $hasPosts = false;
public function isAdmin() {
return $this->isAdmin;
}
public function setIsAdmin($isAdmin) {
$this->isAdmin = $isAdmin;
}
public abstract function getName();
public abstract function getLabel();
public abstract function getVersion();
public function hasPosts() {
return $this->hasPosts;
}
public abstract function getSiteUrl();
public function getCharset() {
return 'UTF-8';
}
public function getMysqlDate() {
return date("Y-m-d H:i:s");
}
public function getTimestamp() {
return time();
}
/**
* @return string
*/
public abstract function getPublicDirectory();
public function getUserEmail() {
return '';
}
public function needStrongerCss() {
return false;
}
public function getDebug() {
return array();
}
public function filterAssetsPath($assetsPath) {
return $assetsPath;
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace Nextend\Framework\Platform;
use Nextend\Framework\Pattern\SingletonTrait;
class Platform {
use SingletonTrait;
/**
* @var AbstractPlatform
*/
private static $platform;
public function __construct() {
self::$platform = new WordPress\PlatformWordPress();
}
public static function getName() {
return self::$platform->getName();
}
public static function getLabel() {
return self::$platform->getLabel();
}
public static function getVersion() {
return self::$platform->getVersion();
}
public static function isAdmin() {
return self::$platform->isAdmin();
}
public static function setIsAdmin($isAdmin) {
self::$platform->setIsAdmin($isAdmin);
}
public static function hasPosts() {
return self::$platform->hasPosts();
}
public static function getSiteUrl() {
return self::$platform->getSiteUrl();
}
public static function getCharset() {
return self::$platform->getCharset();
}
public static function getMysqlDate() {
return self::$platform->getMysqlDate();
}
public static function getTimestamp() {
return self::$platform->getTimestamp();
}
public static function localizeDate($date) {
return self::$platform->localizeDate($date);
}
public static function getPublicDirectory() {
return self::$platform->getPublicDirectory();
}
public static function getUserEmail() {
return self::$platform->getUserEmail();
}
public static function needStrongerCss() {
return self::$platform->needStrongerCss();
}
public static function getDebug() {
return self::$platform->getDebug();
}
public static function filterAssetsPath($assetsPath) {
return self::$platform->filterAssetsPath($assetsPath);
}
}
Platform::getInstance();

View File

@ -0,0 +1,166 @@
<?php
namespace Nextend\Framework\Platform\WordPress;
use Nextend\Framework\Filesystem\Filesystem;
use Nextend\Framework\Platform\AbstractPlatform;
use Nextend\Framework\Request\Request;
use Nextend\Framework\Url\Url;
use Nextend\SmartSlider3\Settings;
class PlatformWordPress extends AbstractPlatform {
protected $hasPosts = true;
public function __construct() {
if (is_admin() || $this->isBeaverBuilderActive()) {
$this->isAdmin = true;
}
}
public function getName() {
return 'wordpress';
}
public function getLabel() {
return 'WordPress';
}
public function getVersion() {
global $wp_version;
return $wp_version;
}
public function getSiteUrl() {
return str_replace(array(
'http://',
'https://'
), '//', site_url('/'));
}
public function getCharset() {
return get_option('blog_charset');
}
public function getMysqlDate() {
return current_time('mysql');
}
public function getTimestamp() {
return current_time('timestamp');
}
public function localizeDate($date) {
return date_i18n(get_option('date_format'), $date);
}
public function filterAssetsPath($assetsPath) {
return str_replace(SMARTSLIDER3_LIBRARY_PATH, NEXTEND_SMARTSLIDER_3 . 'Public', $assetsPath);
}
public function getPublicDirectory() {
$upload_dir = wp_upload_dir();
if (!stream_is_local($upload_dir['basedir'])) {
return $upload_dir['basedir'];
}
/**
* We need to use realpath() to resolve the basedir values where some parts point to the parent folder ( e.g.: ../)
*/
$upload_base_dir_real_path = realpath($upload_dir['basedir']);
$upload_base_dir = $upload_base_dir_real_path ? $upload_base_dir_real_path : $upload_dir['basedir'];
return Filesystem::convertToRealDirectorySeparator(str_replace('//', '/', $upload_base_dir));
}
public function getUserEmail() {
return wp_get_current_user()->user_email;
}
public function needStrongerCss() {
/**
* If Divi plugin installed without Divi theme we must use stronger CSS selectors
*/
if (!$this->isAdmin() && function_exists('et_is_builder_plugin_active') && et_is_builder_plugin_active()) {
return true;
}
return false;
}
public function getDebug() {
$debug = array('');
$debug[] = 'get_site_url: ' . get_site_url();
$debug[] = 'WP_CONTENT_URL: ' . WP_CONTENT_URL;
$translateUrl = Settings::get('translate-url', '|*|');
$debug[] = 'Translate url: ' . ($translateUrl == '|*|' ? 'not used' : $translateUrl);
$debug[] = '';
$debug[] = 'Path to uri:';
$uris = Url::getUris();
$paths = Filesystem::getPaths();
foreach ($uris as $i => $uri) {
$debug[] = $paths[$i] . ' => ' . $uri;
}
$debug[] = '';
$debug[] = 'wp_upload_dir() => ';
foreach (wp_upload_dir() as $k => $v) {
$debug[] = $k . ': ' . $v;
}
$debug[] = '<=';
$debug[] = '';
$theme = wp_get_theme();
$parentTheme = $theme->parent();
if ($parentTheme) {
$debug[] = 'Parent theme: ' . $theme->get('Name') . " is version " . $theme->get('Version');
}
$debug[] = 'Theme: ' . $theme->get('Name') . " is version " . $theme->get('Version');
$plugins = get_plugins();
$notActive = array();
$debug[] = '';
$debug[] = 'Activated Plugins:';
foreach ($plugins as $plugin => $pluginData) {
if (is_plugin_active($plugin)) {
$debug[] = ' - ' . $plugin . ' - ' . $pluginData['Version'] . ' - ' . $pluginData['Name'];
} else {
$notActive[$plugin] = $pluginData;
}
}
$debug[] = '';
$debug[] = '';
$debug[] = 'NOT Activated Plugins:';
foreach ($notActive as $plugin => $pluginData) {
$debug[] = ' - ' . $plugin . ' - ' . $pluginData['Version'] . ' - ' . $pluginData['Name'];
}
return $debug;
}
public function isBeaverBuilderActive() {
return Request::$GET->getVar('fl_builder') !== null;
}
}