first commit

This commit is contained in:
User A0264400
2026-04-01 23:20:16 +03:00
commit a766acdc90
23071 changed files with 4933189 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Disable comments
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
*
* @copyright (c) 2018 Webraftic Ltd
*/
class WGZ_Plugin {
/**
* @see self::app()
* @var WCL_Plugin
*/
private static $app;
/**
* Конструктор
*
* Применяет конструктор родительского класса и записывает экземпляр текущего класса в свойство $app.
* Подробнее о свойстве $app см. self::app()
*
* @param string $plugin_path
* @param array $data
*
* @throws Exception
*/
public function __construct() {
if ( ! class_exists( 'WCL_Plugin' ) ) {
throw new Exception( 'Plugin Clearfy is not installed!' );
}
self::$app = WCL_Plugin::app();
$this->global_scripts();
if ( is_admin() ) {
require( WGZ_PLUGIN_DIR . '/admin/boot.php' );
}
add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
// Wordpress 6.7 fix
add_action( 'init', function () {
if ( is_admin() ) {
$this->register_pages();
}
} );
}
/**
* Статический метод для быстрого доступа к интерфейсу плагина.
*
* Позволяет разработчику глобально получить доступ к экземпляру класса плагина в любом месте
* плагина, но при этом разработчик не может вносить изменения в основной класс плагина.
*
* Используется для получения настроек плагина, информации о плагине, для доступа к вспомогательным
* классам.
*
* @return WCL_Plugin
*/
public static function app() {
return self::$app;
}
/**
* @throws \Exception
*/
public function plugins_loaded() {
}
/**
* Регистрирует классы страниц в плагине
*
* Мы указываем плагину, где найти файлы страниц и какое имя у их класса. Чтобы плагин
* выполнил подключение классов страниц. После регистрации, страницы будут доступные по url
* и в меню боковой панели администратора. Регистрируемые страницы будут связаны с текущим плагином
* все операции выполняемые внутри классов страниц, имеют отношение только текущему плагину.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @throws \Exception
*/
private function register_pages() {
$admin_path = WGZ_PLUGIN_DIR . '/admin/pages';
self::app()->registerPage( 'WGZ_AssetsManagerPage', $admin_path . '/class-pages-settings.php' );
}
/**
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 1.1.0
*/
private function global_scripts() {
require_once( WGZ_PLUGIN_DIR . '/includes/classes/class-views.php' );
require_once WGZ_PLUGIN_DIR . '/includes/classes/class-assets-manager-global.php';
new WGZ_Assets_Manager_Public( self::$app );
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,104 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Assets manager core class
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 19.02.2018, Webcraftic
* @version 1.0
*/
class WGZ_Plugin extends Wbcr_Factory480_Plugin {
/**
* @see self::app()
* @var Wbcr_Factory480_Plugin
*/
private static $app;
/**
* Конструктор
*
* Применяет конструктор родительского класса и записывает экземпляр текущего класса в свойство $app.
* Подробнее о свойстве $app см. self::app()
*
* @param string $plugin_path
* @param array $data
*
* @throws Exception
*/
public function __construct( $plugin_path, $data ) {
parent::__construct( $plugin_path, $data );
self::$app = $this;
$this->global_scripts();
if ( is_admin() ) {
$this->init_activation();
require( WGZ_PLUGIN_DIR . '/admin/boot.php' );
}
add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
// Wordpress 6.7 fix
add_action( 'init', function () {
if ( is_admin() ) {
$this->register_pages();
}
} );
}
/**
* Статический метод для быстрого доступа к интерфейсу плагина.
*
* Позволяет разработчику глобально получить доступ к экземпляру класса плагина в любом месте
* плагина, но при этом разработчик не может вносить изменения в основной класс плагина.
*
* Используется для получения настроек плагина, информации о плагине, для доступа к вспомогательным
* классам.
*
* @return \Wbcr_Factory480_Plugin|\WGZ_Plugin
*/
public static function app() {
return self::$app;
}
/**
* @throws \Exception
*/
public function plugins_loaded() {
}
protected function init_activation() {
include_once( WGZ_PLUGIN_DIR . '/admin/activation.php' );
self::app()->registerActivation( 'WGNZ_Activation' );
}
/**
* Регистрирует классы страниц в плагине
*
* Мы указываем плагину, где найти файлы страниц и какое имя у их класса. Чтобы плагин
* выполнил подключение классов страниц. После регистрации, страницы будут доступные по url
* и в меню боковой панели администратора. Регистрируемые страницы будут связаны с текущим плагином
* все операции выполняемые внутри классов страниц, имеют отношение только текущему плагину.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @throws \Exception
*/
private function register_pages() {
$admin_path = WGZ_PLUGIN_DIR . '/admin/pages';
self::app()->registerPage( 'WGZ_AssetsManagerPage', $admin_path . '/class-pages-settings.php' );
self::app()->registerPage( 'WGZ_MoreFeaturesPage', $admin_path . '/class-pages-more-features.php' );
}
private function global_scripts() {
require_once( WGZ_PLUGIN_DIR . '/includes/classes/class-views.php' );
require_once WGZ_PLUGIN_DIR . '/includes/classes/class-assets-manager-global.php';
new WGZ_Assets_Manager_Public( self::$app );
}
}

View File

@@ -0,0 +1,521 @@
<?php
// Exit if accessed directly
if( !defined('ABSPATH') ) {
exit;
}
/**
* Assets manager base class
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 10.09.20198, Webcraftic
* @since 2.0
*/
class WGZ_Check_Conditions {
protected $condition;
public function __construct($condition)
{
if( empty($condition) ) {
$this->condition = [];
} else {
$condition = @json_decode(stripslashes($condition));
$this->condition = $condition;
}
}
/**
* Проверяем в правильном ли формате нам передано условие
*
* @param \stdClass $condition
*
* @return bool
* @since 2.2.0
*
*/
protected function validate_condition_schema($condition)
{
$isset_attrs = !empty($condition->param) && !empty($condition->operator) && !empty($condition->type) && isset($condition->value);
$allow_params = in_array($condition->param, [
'user-role',
'user-mobile',
'user-cookie-name',
'current-url',
'query-string',
'location-page',
'regular-expression',
'location-some-page',
'location-post-type',
'location-taxonomy'
]);
$allow_operators = in_array($condition->operator, [
'equals',
'notequal',
'less',
'older',
'greater',
'younger',
'contains',
'notcontain',
'between'
]);
$allow_types = in_array($condition->type, ['select', 'text', 'default', 'regexp', 'equals']);
return $isset_attrs && $allow_params && $allow_operators && $allow_types;
}
/**
* @return bool
* @since 2.0.0
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*/
public function validate()
{
if( empty($this->condition) && !is_array($this->condition) ) {
return false;
}
$or = null;
foreach($this->condition as $group_OR) {
if( !empty($group_OR->conditions) && is_array($group_OR->conditions) ) {
$and = null;
foreach($group_OR->conditions as $condition) {
if( $this->validate_condition_schema($condition) ) {
$method_name = str_replace('-', '_', $condition->param);
if( is_null($and) ) {
$and = $this->call_method($method_name, $condition->operator, $condition->value);
} else {
$and = $and && $this->call_method($method_name, $condition->operator, $condition->value);
}
}
}
$or = is_null($or) ? $and : $or || $and;
}
}
return is_null($or) ? false : $or;
}
/**
* Call specified method
*
* @param $method_name
* @param $operator
* @param $value
*
* @return bool
*/
protected function call_method($method_name, $operator, $value)
{
if( method_exists($this, $method_name) ) {
return $this->$method_name($operator, $value);
} else {
return apply_filters('wam/conditions/call_method', false, $method_name, $operator, $value);
}
}
/**
* @param string $path
*
* @return string
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 2.0.0
*
*/
protected function get_admin_url_path($path)
{
return str_replace(site_url(), '', admin_url($path));
}
/**
* Get referer URL
*
* @return string
*/
protected function get_referer_url()
{
$out = "";
$url = explode('?', str_replace(site_url(), '', $_SERVER['HTTP_REFERER']), 2);
if( isset($url[0]) ) {
$out = trim($url[0], '/');
}
return $out ? urldecode($out) : '/';
}
/**
* Get current URL
*
* @return string
*/
protected function get_current_url_path($clear_query = false)
{
if( !is_admin() && !$clear_query ) {
$url = explode('?', $_SERVER['REQUEST_URI'], 2);
if( strlen($url[0]) > 1 ) {
$out = rtrim($url[0], '/');
} else {
$out = $url[0];
}
return "/" === $out ? "/" : untrailingslashit($out);
}
$removeble_args = array_merge(['wbcr_assets_manager'], wp_removable_query_args());
$url = remove_query_arg($removeble_args, $_SERVER['REQUEST_URI']);
return esc_url_raw(untrailingslashit($url));
}
/**
* Check by operator
*
* @param $operator
* @param $first
* @param $second
* @param $third
*
* @return bool
*/
public function apply_operator($operator, $first, $second, $third = false)
{
switch( $operator ) {
case 'equals':
return $first === $second;
case 'notequal':
return $first !== $second;
case 'less':
case 'older':
return $first > $second;
case 'greater':
case 'younger':
return $first < $second;
case 'contains':
return strpos($first, $second) !== false;
case 'notcontain':
return strpos($first, $second) === false;
case 'between':
return $first < $second && $second < $third;
default:
return $first === $second;
}
}
/**
* Get timestamp
*
* @param $units
* @param $count
*
* @return integer
*/
protected function get_timestamp($units, $count)
{
switch( $units ) {
case 'seconds':
return $count;
case 'minutes':
return $count * MINUTE_IN_SECONDS;
case 'hours':
return $count * HOUR_IN_SECONDS;
case 'days':
return $count * DAY_IN_SECONDS;
case 'weeks':
return $count * WEEK_IN_SECONDS;
case 'months':
return $count * MONTH_IN_SECONDS;
case 'years':
return $count * YEAR_IN_SECONDS;
default:
return $count;
}
}
/**
* Get date timestamp
*
* @param $value
*
* @return integer
*/
public function get_date_timestamp($value)
{
if( is_object($value) ) {
return (current_time('timestamp') - $this->get_timestamp($value->units, $value->unitsCount)) * 1000;
} else {
return $value;
}
}
/**
* A some selected page
*
* @param $operator
* @param $value
*
* @return boolean
*/
protected function location_some_page($operator, $value)
{
if( !is_admin() ) {
// For frontend area
switch( $value ) {
case 'base_web': // Basic - Entire Website
$result = !is_admin();
break;
case 'base_sing': // Basic - All Singulars
$result = is_singular();
break;
case 'base_arch': // Basic - All Archives
$result = is_archive();
break;
case 'spec_404': // Special Pages - 404 Page
$result = is_404();
break;
case 'spec_search': // Special Pages - Search Page
$result = is_search();
break;
case 'spec_blog': // Special Pages - Blog / Posts Page
$result = is_home();
break;
case 'spec_front': // Special Pages - Front Page
$result = is_front_page();
break;
case 'spec_date': // Special Pages - Date Archive
$result = is_date();
break;
case 'spec_auth': // Special Pages - Author Archive
$result = is_author();
break;
case 'post_all': // Posts - All Posts
case 'page_all': // Pages - All Pages
$result = false;
$post_id = (!is_404() && !is_search() && !is_archive() && !is_home()) ? get_the_ID() : false;
if( false !== $post_id ) {
$post_type = 'post_all' == $value ? 'post' : 'page';
$result = $post_type == get_post_type($post_id);
}
break;
case 'post_arch': // Posts - All Posts Archive
case 'page_arch': // Pages - All Pages Archive
$result = false;
if( is_archive() ) {
$post_type = 'post_arch' == $value ? 'post' : 'page';
$result = $post_type == get_post_type();
}
break;
case 'post_cat': // Posts - All Categories Archive
case 'post_tag': // Posts - All Tags Archive
$result = false;
if( is_archive() && 'post' == get_post_type() ) {
$taxonomy = 'post_tag' == $value ? 'post_tag' : 'category';
$obj = get_queried_object();
$current_taxonomy = '';
if( '' !== $obj && null !== $obj ) {
$current_taxonomy = $obj->taxonomy;
}
if( $current_taxonomy == $taxonomy ) {
$result = true;
}
}
break;
default:
$result = true;
}
} else {
// For admin area
switch( $value ) {
case 'all_admin_area':
$result = is_admin();
break;
case 'dashboard_home':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('index.php');
break;
case 'dashboard_wordpress_updates':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('update-core.php');
break;
case 'posts_all':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('edit.php');
break;
case 'posts_add_new':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('post-new.php');
break;
case 'posts_taxonomies':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('edit-tags.php');
break;
case 'media_library':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('upload.php');
break;
case 'media_library_add_new':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('media-new.php');
break;
case 'appearance_themes':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('themes.php');
break;
case 'appearance_customize':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('customize.php');
break;
case 'appearance_widgets':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('widgets.php');
break;
case 'appearance_menus':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('nav-menus.php');
break;
case 'appearance_theme_editor':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('theme-editor.php');
break;
case 'plugins_installed':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('plugins.php');
break;
case 'plugins_add_new':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('plugin-install.php');
break;
case 'plugins_editor':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('plugin-editor.php');
break;
case 'users_all':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('users.php');
break;
case 'users_add_new':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('user-new.php');
break;
case 'users_your_profile':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('profile.php');
break;
case 'tools_available':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('tools.php');
break;
case 'tools_import':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('import.php');
break;
case 'tools_export':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('export.php');
break;
case 'tools_site_health':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('site-health.php');
break;
case 'tools_export_personal_data':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('tools.php');
break;
case 'tools_erase_personal_data':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('tools.php');
break;
case 'settings_general':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('options-general.php');
break;
case 'settings_writing':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('options-writing.php');
break;
case 'settings_reading':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('options-reading.php');
break;
case 'settings_media':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('options-media.php');
break;
case 'settings_permalinks':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('options-permalink.php');
break;
case 'settings_privacy':
$result = $this->get_current_url_path(true) === $this->get_admin_url_path('privacy.php');
break;
default:
$result = true;
}
}
return $this->apply_operator($operator, $result, true);
}
/**
* Проверяет текущий URL страницы.
*
* Если url в условии и url текущей страницы совпадают,
* условие будет выполнено успешно.
*
* @param string $operator
* @param string $value
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 2.0.0
*
*/
protected function current_url($operator, $value)
{
$value = ("/" === $value) ? "/" : untrailingslashit($value);
$current_url = $this->get_current_url_path();
return $this->apply_operator($operator, $value, $current_url);
}
/**
* A post type of the current page
*
* @param $operator
* @param $value
*
* @return boolean
*/
protected function location_post_type($operator, $value)
{
if( is_singular() ) {
return $this->apply_operator($operator, $value, get_post_type());
}
return false;
}
/**
* A taxonomy of the current page
*
* @param $operator
* @param $value
*
* @return boolean
* @since 2.2.8 The bug is fixed, the condition was not checked
* for tachonomies, only posts.
*
*/
protected function location_taxonomy($operator, $value)
{
$taxonomy = null;
if( is_tax() || is_tag() || is_category() ) {
$taxonomy = get_queried_object()->taxonomy;
}
return $this->apply_operator($operator, $taxonomy, $value);
}
/**
* Checking for the existence of a variable in a query string
*
* @param $operator
* @param $value
*
* @return boolean
* @since 2.2.8 The bug is fixed, the condition was not checked
* for tachonomies, only posts.
*
*/
protected function query_string($operator, $value)
{
if( is_object($value) ) {
if( !empty($value->var_name) && isset($_GET[$value->var_name]) ) {
return $this->apply_operator($operator, $_GET[$value->var_name], $value->var_value);
}
}
return false;
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* Class that handles templates.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 05.04.2019, Webcraftic
* @version 1.0
*/
class WGZ_Views {
/**
* The single instance of the class.
*
* @since 1.3.0
* @access protected
* @var array
*/
protected static $_instance = [];
/**
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 1.3.0
* @var string
*/
protected $plugin_dir;
/**
* WRIO_Views constructor.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*
* @param string $plugin_dir
*/
public function __construct( $plugin_dir ) {
$this->plugin_dir = $plugin_dir;
}
/**
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 1.3.6 - add instace id
* @since 1.3.0
*
* @param string $plugin_dir
*
* @return object|\WGZ_Views object Main instance.
*/
public static function get_instance( $plugin_dir ) {
$instance_id = md5( $plugin_dir );
if ( ! isset( self::$_instance[ $instance_id ] ) ) {
self::$_instance[ $instance_id ] = new self( $plugin_dir );
}
return self::$_instance[ $instance_id ];
}
/**
* Get a template contents.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 1.3.0
*
* @param string $template The template name.
* @param mixed $data Some data to pass to the template.
* @param WBCR\Factory_Templates_134\Pages\PageBase $page
*
* @return bool|string The page contents. False if the template doesn't exist.
*/
public function get_template( $template, $data = [], WBCR\Factory_Templates_134\Pages\PageBase $page = null ) {
$template = str_replace( '_', '-', $template );
$path = $this->plugin_dir . '/views/' . $template . '.php';
if ( ! file_exists( $path ) ) {
return false;
}
ob_start();
include $path;
$contents = ob_get_clean();
return trim( (string) $contents );
}
/**
* Print a template.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @access public
*
* @since 1.3.0
*
* @param string $template The template name.
* @param mixed $data Some data to pass to the template.
* @param WBCR\Factory_Templates_134\Pages\PageBase $page
*/
public function print_template( $template, $data = [], WBCR\Factory_Templates_134\Pages\PageBase $page = null ) {
echo $this->get_template( $template, $data, $page );
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Helpers functions
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 11.05.2019, Webcraftic
* @version 1.0
*/
/**
* Assets manager MU dynamically activated only plugins that you have selected in each page.
* This method installs the MU plugin if it does not exist or its current version does not
* match the current version.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 1.0.7
*/
function wbcr_gnz_deploy_mu_plugin() {
if ( wp_mkdir_p( WPMU_PLUGIN_DIR ) ) {
if ( ! file_exists( WPMU_PLUGIN_DIR . "/assets-manager.php" ) ) {
@copy( WGZ_PLUGIN_DIR . '/mu-plugins/assets-manager.php', WPMU_PLUGIN_DIR . '/assets-manager.php' );
} else {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$dp = get_plugin_data( WPMU_PLUGIN_DIR . "/assets-manager.php", false, false );
$sp = get_plugin_data( WGZ_PLUGIN_DIR . '/mu-plugins/assets-manager.php', false, false );
if ( version_compare( $dp['Version'], $sp['Version'], '!=' ) ) {
@copy( WGZ_PLUGIN_DIR . '/mu-plugins/assets-manager.php', WPMU_PLUGIN_DIR . '/assets-manager.php' );
}
}
}
}
/**
* Remove MU plugin
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 1.0.7
*/
function wbcr_gnz_remove_mu_plugin() {
if ( file_exists( WPMU_PLUGIN_DIR . "/assets-manager.php" ) ) {
@unlink( WPMU_PLUGIN_DIR . '/assets-manager.php' );
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.