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,30 @@
<?php
/**
* Подключение файлов из категории 3rd-party
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @copyright (c) 20.01.2021, CreativeMotion
* @version 1.0
*/
add_filter('wbcr_factory_480_form_items', function ($forms_groups, $name) {
require_once(WCL_PLUGIN_DIR . '/includes/classes/3rd-party/class-base.php');
require_once(WCL_PLUGIN_DIR . '/includes/classes/3rd-party/plugins/class-wp-rocket.php');
require_once(WCL_PLUGIN_DIR . '/includes/classes/3rd-party/class-form-entity.php');
$form_entities = \Clearfy\ThirdParty\Form_Entity::recursive_search_controls($forms_groups);
if( !empty($form_entities) ) {
foreach($form_entities as $control) {
$wp_rocket_no_conflict = new \Clearfy\ThirdParty\Wp_Rocket();
if( $wp_rocket_no_conflict->is_enabled_mapped_option($control->get_name()) ) {
$control->make_control_disabled();
$control->modify_control_hint(__('WARNING! You cannot enable this option as you are using a similar option in the wp rocket plugin. Using the same functionality in both plugins can lead to conflicts. To enable this option, you must disable a similar option in the wp rocket plugin.', 'clearfy'));
}
}
}
return $forms_groups;
}, 10, 2);

View File

@@ -0,0 +1,104 @@
<?php
/**
* Базовый класс для реализации совместимости со сторонними плагинами
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @copyright (c) 12.01.2021, CreativeMotion
* @version 1.0
*/
namespace Clearfy\ThirdParty;
// Exit if accessed directly
if( !defined('ABSPATH') ) {
exit;
}
abstract class Base {
protected $map_options = [];
protected $defualt_disabled_options = [];
private $_disabled_clearfy_options = [];
/**
* Получить значение опции конфликтующего плагина
* @param string $option_name Имя опции
* @return mixed
*/
public abstract function get_3rd_plugin_option($option_name);
public function is_clearfy_option_mapped($option_name)
{
return isset($this->map_options[$option_name]);
}
public function is_3rd_plugin_option_mapped($option_name)
{
return in_array($option_name, $this->map_options);
}
public function is_enabled_mapped_option($option_name)
{
if( $this->is_clearfy_option_mapped($option_name) ) {
return $this->is_enabled_3rd_plugin_option($this->map_options[$option_name]);
}
return in_array($option_name, (array)$this->defualt_disabled_options);
}
public function is_enabled_clearfy_option($option_name)
{
return \WCL_Plugin::app()->getPopulateOption($option_name);
}
/**
* Включена ли опция конфликтующего плагина?
* @param string $option_name Имя опции
* @return bool - true, если включена, false если нет
*/
public function is_enabled_3rd_plugin_option($option_name)
{
$option_value = $this->get_3rd_plugin_option($option_name);
return !is_null($option_value) && $option_value;
}
/**
* Деактивирует опции в клеарфи, соответствующие карте опций
*
* Если к примеру в wp rocket включена опции минификации скриптов, то соотвественно
* в Clearfy мы деактивируем опцию минификации скриптов.
*/
public function disable_clearfy_options()
{
if( !empty($this->map_options) ) {
foreach((array)$this->map_options as $clearfy_option_name => $thirdparty_plugin_option_name) {
if( $this->is_enabled_clearfy_option($clearfy_option_name) && $this->is_enabled_3rd_plugin_option($thirdparty_plugin_option_name) ) {
$this->disable_clearfy_option($clearfy_option_name);
}
}
}
if( !empty($this->defualt_disabled_options) ) {
foreach((array)$this->defualt_disabled_options as $option_name) {
if( $this->is_enabled_clearfy_option($clearfy_option_name) ) {
$this->disable_clearfy_option($option_name);
}
}
}
$this->save_options();
}
private function disable_clearfy_option($option_name)
{
$this->_disabled_clearfy_options[] = $option_name;
}
private function save_options()
{
foreach($this->_disabled_clearfy_options as $option_name) {
\WCL_Plugin::app()->updatePopulateOption($option_name, 0);
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* Базовый класс для реализации совместимости со сторонними плагинами
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @copyright (c) 12.01.2021, CreativeMotion
* @version 1.0
*/
namespace Clearfy\ThirdParty;
// Exit if accessed directly
if( !defined('ABSPATH') ) {
exit;
}
class Form_Entity {
private $control = [];
public function __construct(array &$control)
{
$this->control = &$control;
}
/**
* Extracted options from a nested array
* @param array $options
* @return array
* @since 2.2.0
*/
public static function recursive_search_controls(&$options)
{
$extracted_options = [];
foreach($options as &$option) {
if( isset($option['items']) ) {
$extracted_options = array_merge($extracted_options, static::recursive_search_controls($option['items']));
} else {
if( static::is_control($option) ) {
$extracted_options[] = new static($option);
}
}
}
return $extracted_options;
}
public function get_name()
{
if( !isset($this->control['name']) ) {
return null;
}
return $this->control['name'];
}
protected static function is_control(array $item)
{
return isset($item['type']) && isset(\Wbcr_FactoryForms480_Manager::$registered_controls[$item['type']]);
}
/**
* Returns true if a given item is an control holder item.
*
* @param mixed[] $item
* @return bool
* @since 1.0.0
*/
protected static function is_control_holder(array $item)
{
return isset($item['type']) && isset(\Wbcr_FactoryForms480_Manager::$registered_holders[$item['type']]);
}
/**
* Returns true if a given item is html markup.
*
* @param mixed[] $item
* @return bool
* @since 1.0.0
*/
protected static function is_custom_element(array $item)
{
return isset($item['type']) && isset(\Wbcr_FactoryForms480_Manager::$registered_custom_elements[$item['type']]);
}
public function make_control_disabled()
{
$this->control['cssClass'] = ['factory-checkbox-disabled disabled'];
}
public function modify_control_hint($message)
{
unset($this->control['layout']['hint-type']);
unset($this->control['layout']['hint-icon-color']);
$this->control['layout']['column-left'] = '4';
$this->control['layout']['column-right'] = '8';
$old_hint = !empty($this->control['hint']) ? $this->control['hint'] . "<br><br>" : "";
$this->control['hint'] = $old_hint . '<span style="display:block; font-size:12px; color:#d48a6f;">' . $message . '</span>';
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* Thirdparty Forms
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @copyright (c) 12.01.2021, CreativeMotion
* @version 1.0
*/
namespace Clearfy\ThirdParty;
// Exit if accessed directly
if( !defined('ABSPATH') ) {
exit;
}
final class Wp_Rocket extends Base {
private $wp_rocket_options;
protected $defualt_disabled_options = [
'disable_emoji',
'remove_js_version',
'remove_style_version',
//todo: Starting WP Rocket V 3.7 (August 2020), HTML Minify has been removed.
//'html_optimize',
'move_js_to_footer',
'dont_move_jquery_to_footer'
];
protected $map_options = [
'css_optimize' => 'minify_css',
'js_optimize' => 'minify_js',
'ajs_enabled' => 'defer_all_js',
'disable_embeds' => 'embeds'
];
public function __construct()
{
$this->wp_rocket_options = get_option('wp_rocket_settings');
}
public function get_3rd_plugin_option($option_name)
{
return isset($this->wp_rocket_options[$option_name]) ? $this->wp_rocket_options[$option_name] : null;
}
}