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,29 @@
<?php
/**
* Activator for the cyrlitera
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 09.03.2018, Webcraftic
* @see Wbcr_Factory480_Activator
* @version 1.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WCTR_Activation extends Wbcr_Factory480_Activator {
/**
* Runs activation actions.
*
* @since 1.0.0
*/
public function activate() {
WCTR_Plugin::app()->updatePopulateOption( 'use_transliteration', 1 );
WCTR_Plugin::app()->updatePopulateOption( 'use_transliteration_filename', 1 );
WCTR_Plugin::app()->updatePopulateOption( 'filename_to_lowercase', 1 );
}
}

View File

@@ -0,0 +1,41 @@
jQuery(function($){
// transliterate field-name
acf.addFilter('generate_field_object_name', function(val){
return replace_field(val);
});
$(document).on('keyup change', '.acf-field .field-name', function(){
if ( $(this).is(':focus') ){
return false;
}else{
var val = $(this).val();
val = replace_field( val );
if ( val !== $(this).val() ) {
$(this).val(val);
}
}
});
function replace_field( val ){
console.log(val);
val = $.trim(val);
if(window.cyr_and_lat_dict === undefined){
console.error('Cyrlitera for ACF: lang dictionary not loaded!')
return val;
}
var table = window.cyr_and_lat_dict;
$.each( table, function(k, v){
var regex = new RegExp( k, 'g' );
val = val.replace( regex, v );
});
val = val.replace( /[^\w\d-_]/g, '' );
val = val.replace( /_+/g, '_' );
val = val.replace( /^_?(.*)$/g, '$1' );
val = val.replace( /^(.*)_$/g, '$1' );
return val;
}
});

View File

@@ -0,0 +1,239 @@
<?php
/**
* Admin boot
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright Webcraftic 25.05.2017
* @version 1.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @return array
*/
function wbcr_cyrlitera_install_conflict_plugins() {
$install_plugins = [];
if ( is_plugin_active( 'wp-translitera/wp-translitera.php' ) ) {
$install_plugins[] = 'WP Translitera';
}
if ( is_plugin_active( 'cyr3lat/cyr-to-lat.php' ) ) {
$install_plugins[] = 'Cyr to Lat enhanced';
}
if ( is_plugin_active( 'cyr2lat/cyr-to-lat.php' ) ) {
$install_plugins[] = 'Cyr to Lat';
}
if ( is_plugin_active( 'cyr-and-lat/cyr-and-lat.php' ) ) {
$install_plugins[] = 'Cyr-And-Lat';
}
if ( is_plugin_active( 'rustolat/rus-to-lat.php' ) ) {
$install_plugins[] = 'RusToLat';
}
if ( is_plugin_active( 'rus-to-lat-advanced/ru-translit.php' ) ) {
$install_plugins[] = 'Rus filename and link translit';
}
return $install_plugins;
}
/**
* @return array
*/
function wbcr_cyrlitera_get_conflict_notices_error() {
$notices = [];
$plugin_title = WCTR_Plugin::app()->getPluginTitle();
$default_notice = $plugin_title . ': ' . __( 'We found that you have the plugin %s installed. The functions of this plugin already exist in %s. Please deactivate plugin %s to avoid conflicts between plugins functions.', 'cyrlitera' );
$default_notice .= ' ' . __( 'If you do not want to deactivate the plugin %s for some reason, we strongly recommend do not use the same plugins functions at the same time!', 'cyrlitera' );
$install_conflict_plugins = wbcr_cyrlitera_install_conflict_plugins();
if ( ! empty( $install_conflict_plugins ) ) {
foreach ( (array) $install_conflict_plugins as $plugin_name ) {
$notices[] = sprintf( $default_notice, $plugin_name, $plugin_title, $plugin_name, $plugin_name );
}
}
return $notices;
}
add_filter( 'wbcr_clr_seo_page_warnings', 'wbcr_cyrlitera_get_conflict_notices_error' );
/**
* Печатает ошибки совместимости с похожими плагинами
*/
function wbcr_cyrlitera_admin_conflict_notices_error( $notices, $plugin_name ) {
if ( $plugin_name != WCTR_Plugin::app()->getPluginName() ) {
return $notices;
}
$warnings = wbcr_cyrlitera_get_conflict_notices_error();
if ( empty( $warnings ) ) {
return $notices;
}
$notice_text = '';
foreach ( (array) $warnings as $warning ) {
$notice_text .= '<p>' . $warning . '</p>';
}
$notices[] = [
'id' => 'cyrlitera_plugin_compatibility',
'type' => 'error',
'dismissible' => true,
'dismiss_expires' => 0,
'text' => $notice_text
];
return $notices;
}
add_action( 'wbcr/factory/admin_notices', 'wbcr_cyrlitera_admin_conflict_notices_error', 10, 2 );
if ( ! defined( 'LOADING_CYRLITERA_AS_ADDON' ) ) {
function wbcr_cyrlitera_set_plugin_meta( $links, $file ) {
if ( $file == WCTR_PLUGIN_BASE ) {
$url = 'https://clearfy.pro';
if ( get_locale() == 'ru_RU' ) {
$url = 'https://ru.clearfy.pro';
}
$url .= '?utm_source=wordpress.org&utm_campaign=' . WCTR_Plugin::app()->getPluginName();
$links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . __( 'Get ultimate plugin free', 'cyrlitera' ) . '</a>';
}
return $links;
}
add_filter( 'plugin_row_meta', 'wbcr_cyrlitera_set_plugin_meta', 10, 2 );
/**
* Виджет отзывов
*
* @param string $page_url
* @param string $plugin_name
*
* @return string
*/
function wbcr_cyrlitera_rating_widget_url( $page_url, $plugin_name ) {
if ( ! defined( 'LOADING_CYRLITERA_AS_ADDON' ) && ( $plugin_name == WCTR_Plugin::app()->getPluginName() ) ) {
return 'https://goo.gl/ecaj2V';
}
return $page_url;
}
add_filter( 'wbcr_factory_pages_480_imppage_rating_widget_url', 'wbcr_cyrlitera_rating_widget_url', 10, 2 );
/**
* Удаляем лишние виджеты из правого сайдбара в интерфейсе плагина
*
* - Виджет с премиум рекламой
* - Виджет с рейтингом
* - Виджет с маркерами информации
*/
add_filter( 'wbcr/factory/pages/impressive/widgets', function ( $widgets, $position, $plugin ) {
if ( WCTR_Plugin::app()->getPluginName() == $plugin->getPluginName() && 'right' == $position ) {
unset( $widgets['business_suggetion'] );
unset( $widgets['rating_widget'] );
unset( $widgets['info_widget'] );
}
return $widgets;
}, 20, 3 );
} else {
/**
* Когда в CLearfy пользователь выполняет быструю настройку "ONE CLICK SEO OPTIMIZATION",
* мы включаем транслитерацию и преобразовываем слаги для уже существующих страниц, терминов
*
* @param string $mode_name - имя режима быстрой настройки
*/
add_action( 'wbcr_clearfy_configurated_quick_mode', function ( $mode_name ) {
if ( $mode_name == 'seo_optimize' ) {
$use_transliterations = WCTR_Plugin::app()->getPopulateOption( 'use_transliteration' );
$transliterate_existing_slugs = WCTR_Plugin::app()->getPopulateOption( 'transliterate_existing_slugs' );
if ( ! $use_transliterations || $transliterate_existing_slugs ) {
return;
}
WCTR_Helper::convertExistingSlugs();
WCTR_Plugin::app()->updatePopulateOption( 'transliterate_existing_slugs', 1 );
}
} );
function wbcr_cyrlitera_group_options( $options ) {
$install_conflict_plugins = wbcr_cyrlitera_install_conflict_plugins();
$is_cyrilic = in_array( get_locale(), [ 'ru_RU', 'bel', 'kk', 'uk', 'bg', 'bg_BG', 'ka_GE' ] );
if ( ! empty( $install_conflict_plugins ) || ! $is_cyrilic ) {
$tags = [];
} else {
$tags = [ 'recommended', 'seo_optimize' ];
}
$options[] = [
'name' => 'use_transliteration',
'title' => __( 'Use transliteration', 'cyrlitera' ),
'tags' => $tags
];
$options[] = [
'name' => 'use_force_transliteration',
'title' => __( 'Force transliteration', 'cyrlitera' ),
'tags' => []
];
$options[] = [
'name' => 'dont_use_transliteration_on_frontend',
'title' => __( 'Don\'t use transliteration in frontend', 'cyrlitera' ),
'tags' => []
];
$options[] = [
'name' => 'use_transliteration_filename',
'title' => __( 'Convert file names', 'cyrlitera' ),
'tags' => $tags
];
$options[] = [
'name' => 'filename_to_lowercase',
'title' => __( 'Convert file names into lowercase', 'cyrlitera' ),
'tags' => $tags
];
$options[] = [
'name' => 'redirect_from_old_urls',
'title' => __( 'Redirection old URLs to new ones', 'cyrlitera' ),
'tags' => []
];
$options[] = [
'name' => 'custom_symbols_pack',
'title' => __( 'Character Sets', 'cyrlitera' ),
'tags' => []
];
return $options;
}
add_filter( "wbcr_clearfy_group_options", 'wbcr_cyrlitera_group_options' );
}

View File

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

View File

@@ -0,0 +1,285 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Страница общих настроек для этого плагина.
*
* Может быть использована только, если этот плагин используется как отдельный плагин, а не как аддон
* дя плагина Clearfy. Если плагин загружен, как аддон для Clearfy, эта страница не будет подключена.
*
* Поддерживает режим работы с мультисаймами. Вы можете увидеть эту страницу в панели настройки сети.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 2018 Webraftic Ltd
* @version 1.0
*/
class WCTR_CyrliteraPage extends WBCR\Factory_Templates_134\Pages\PageBase {
/**
* {@inheritDoc}
*
* @var string
*/
public $id = "transliteration";
/**
* {@inheritDoc}
*
* @var string
*/
public $page_parent_page = "seo";
/**
* {@inheritDoc}
*
* @var string
*/
public $page_menu_dashicon = 'dashicons-testimonial';
/**
* {@inheritDoc}
*
* @var bool
*/
public $available_for_multisite = true;
/**
* {@inheritDoc}
*
* @since 1.1.0
* @var bool
*/
public $show_right_sidebar_in_options = true;
/**
* WCTR_CyrliteraPage constructor.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*
* @param \Wbcr_Factory480_Plugin $plugin
*/
public function __construct( Wbcr_Factory480_Plugin $plugin ) {
$this->menu_title = __( 'Cyrlitera', 'cyrlitera' );
if ( ! defined( 'LOADING_CYRLITERA_AS_ADDON' ) ) {
$this->internal = false;
$this->menu_target = 'options-general.php';
$this->add_link_to_plugin_actions = true;
$this->page_parent_page = null;
$this->show_search_options_form = false;
}
parent::__construct( $plugin );
$this->plugin = $plugin;
}
public function getPageTitle() {
return defined( 'LOADING_CYRLITERA_AS_ADDON' ) ? __( 'Transliteration', 'cyrlitera' ) : __( 'General', 'cyrlitera' );
}
/**
* Этот метод преобразовываем слаги для уже существующих страниц, терминов. Если это преобразование уже было выполнено,
* то мы больше незапускаем массовую конвертацию
*/
public function convertExistingSlugs() {
$use_transliterations = $this->plugin->getPopulateOption( 'use_transliteration' );
$transliterate_existing_slugs = $this->plugin->getPopulateOption( 'transliterate_existing_slugs' );
if ( ! $use_transliterations || $transliterate_existing_slugs ) {
return;
}
WCTR_Helper::convertExistingSlugs();
$this->plugin->updatePopulateOption( 'transliterate_existing_slugs', 1 );
}
/**
* Метод выполняется после сохранения формы настроек. Когда пользователь включает транслитерацию,
* метод запускает массовую конвертацию слагов для уже существующих страниц,
* терминов. Если это преобразование уже было выполнено, то мы больше незапускаем массовую конвертацию
*/
protected function afterFormSave() {
$this->convertExistingSlugs();
}
/**
* Permalinks options.
*
* @since 1.0.0
* @return mixed[]
*/
public function getPageOptions() {
$options[] = [
'type' => 'html',
'html' => '<div class="wbcr-factory-page-group-header">' . '<strong>' . __( 'Transliteration of Cyrillic alphabet.', 'cyrlitera' ) . '</strong>' . '<p>' . __( 'Converts Cyrillic permalinks of post, pages, taxonomies and media files to the Latin alphabet. Supports Russian, Ukrainian, Georgian, Bulgarian languages. Example: http://site.dev/последние-новости -> http://site.dev/poslednie-novosti', 'cyrlitera' ) . '</p>' . '</div>'
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'use_transliteration',
'title' => __( 'Use transliteration', 'cyrlitera' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'green' ],
'hint' => __( 'If you enable this option, all URLs of new pages, posts, tags, and categories will automatically be converted to Latin.', 'cyrlitera' ),
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'use_transliteration_filename',
'title' => __( 'Convert file names', 'cyrlitera' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'green' ],
'hint' => __( 'This option works only for new media library files. All Cyrillic names of the downloaded files will be converted to names with Latin characters.', 'cyrlitera' ),
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'use_force_transliteration',
'title' => __( 'Force transliteration', 'cyrlitera' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'hint' => sprintf( __( 'If any of your plugins affects transliteration of links and file names, you can use this option to change the plugin of %s to overwrite the changes of the other plugins.', 'cyrlitera' ), WCTR_Plugin::app()->getPluginTitle() ),
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'filename_to_lowercase',
'title' => __( 'Convert file names into lowercase', 'cyrlitera' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'green' ],
'hint' => __( 'This function works only for new upload files. Example: File_Name.jpg -> file_name.jpg', 'cyrlitera' ),
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'redirect_from_old_urls',
'title' => __( 'Redirection old URLs to new ones', 'cyrlitera' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'hint' => __( 'If at the time of the plugin installation you had pages with unconverted links, use this option to redirect users from old to new URLs with the Latin alphabet.', 'cyrlitera' ),
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'dont_use_transliteration_on_frontend',
'title' => __( 'Don\'t use transliteration in frontend', 'cyrlitera' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'hint' => __( 'Enable when have a problem in frontend.', 'cyrlitera' ),
'default' => false
];
$options[] = [
'type' => 'textarea',
'way' => 'buttons',
'name' => 'custom_symbols_pack',
'title' => __( 'Character Sets', 'cyrlitera' ),
'hint' => __( 'You can supplement current base of transliteration characters. Write pairs of values separated by commas. Example:', 'cyrlitera' ) . ' <b>Ё=Jo,ё=jo,Ж=Zh,ж=zh</b>'
];
// Произвольный html код
$options[] = [
'type' => 'html', // тип элемента формы
'html' => [ $this, 'rollbackButton' ]
];
$formOptions = [];
$formOptions[] = [
'type' => 'form-group',
'items' => $options,
//'cssClass' => 'postbox'
];
return apply_filters( 'wbcr_cyrlitera_general_form_options', $formOptions, $this );
}
/**
* @param $html_builder Wbcr_FactoryForms480_Html
*/
public function rollbackButton( $html_builder ) {
$form_name = $html_builder->getFormName();
$rollback = false;
$convert_now = false;
if ( isset( $_POST['wbcr_cyrlitera_rollback_action'] ) ) {
check_admin_referer( $form_name, 'wbcr_cyrlitera_rollback_nonce' );
if ( WCTR_Plugin::app()->isNetworkActive() ) {
foreach ( WCTR_Plugin::app()->getActiveSites() as $site ) {
switch_to_blog( $site->blog_id );
WCTR_Helper::rollbackUrlChanges();
restore_current_blog();
}
} else {
WCTR_Helper::rollbackUrlChanges();
}
$rollback = true;
}
if ( isset( $_POST['wbcr_cyrlitera_convert_now_action'] ) ) {
check_admin_referer( $form_name, 'wbcr_cyrlitera_convert_now_nonce' );
if ( WCTR_Plugin::app()->isNetworkActive() ) {
foreach ( WCTR_Plugin::app()->getActiveSites() as $site ) {
switch_to_blog( $site->blog_id );
WCTR_Helper::convertExistingSlugs();
restore_current_blog();
}
} else {
WCTR_Helper::convertExistingSlugs();
}
$convert_now = true;
}
?>
<div class="form-group form-group-checkbox factory-control-convert_now_button">
<label for="wbcr_clearfy_convert_now_button" class="col-sm-4 control-label">
<span class="factory-hint-icon factory-hint-icon-grey" data-toggle="factory-tooltip" data-placement="right" title="" data-original-title="<?php _e( 'If at the time of the plugin installation you already had posts, pages, tags and categories, click on this button and the plugin will automatically convert URLs into Latin. Attention! Previously uploaded files will not be converted.', 'cyrlitera' ) ?>">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt="">
</span>
</label>
<div class="control-group col-sm-8">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group">
<form method="post">
<?php wp_nonce_field( $form_name, 'wbcr_cyrlitera_convert_now_nonce' ); ?>
<input type="submit" name="wbcr_cyrlitera_convert_now_action" value="<?php _e( 'Convert already created posts and categories', 'cyrlitera' ) ?>" class="button button-default"/>
<?php if ( $convert_now ): ?>
<div style="color:green;margin-top:5px;"><?php _e( 'Url of old posts, pages,terms,tags successfully converted into Latin!', 'cyrlitera' ) ?></div>
<?php endif; ?>
</form>
</div>
</div>
</div>
<div class="form-group form-group-checkbox factory-control-rollback_button">
<label for="wbcr_clearfy_rollback_button" class="col-sm-4 control-label">
<span class="factory-hint-icon factory-hint-icon-grey" data-toggle="factory-tooltip" data-placement="right" title="" data-original-title="<?php _e( 'Allows you to restore converted URLs by using the "Convert already created posts and categories" button. This can be useful in case of incorrect URLs or incorrect transliteration of some characters. You can roll back changes and advance the character sets above to correct the plugin\'s work. ', 'cyrlitera' ) ?>">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt="">
</span>
</label>
<div class="control-group col-sm-8">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group">
<form method="post">
<?php wp_nonce_field( $form_name, 'wbcr_cyrlitera_rollback_nonce' ); ?>
<input type="submit" name="wbcr_cyrlitera_rollback_action" value="<?php _e( 'Rollback changes', 'cyrlitera' ) ?>" class="button button-default"/>
<?php if ( $rollback ): ?>
<div style="color:green;margin-top:5px;"><?php _e( 'The rollback of new changes was successful!', 'cyrlitera' ) ?></div>
<?php endif; ?>
</form>
</div>
</div>
</div>
<?php
}
}

View File

@@ -0,0 +1,23 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Рекламная страница.
*
* Используется для рекламы плагина Clearfy. Пользователь может изучить все возможности плагина Clearfy
* и перейти на лендинг плагина, чтобы скачать и попробовать его.
*
* Может быть использована только, если этот плагин используется как отдельный плагин, а не как аддон
* для плагина Clearfy. Если плагин загружен, как аддон для Clearfy, эта страница не будет подключена.
*
* НЕ поддерживает режим работы с мультисаймами!
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 2018 Webraftic Ltd
*/
class WCTR_MoreFeaturesPage extends \WBCR\Factory_Templates_134\Pages\MoreFeatures {
}

View File

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