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,46 @@
<?php
/**
* Activator for the GA cache
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 09.09.2017, Webcraftic
* @see Factory480_Activator
* @version 1.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WGA_Activation extends Wbcr_Factory480_Activator {
/**
* Runs activation actions.
*
* @since 1.0.0
*/
public function activate() {
$ga_cache = WGA_Plugin::app()->getPopulateOption( 'ga_cache' );
if ( $ga_cache ) {
wp_clear_scheduled_hook( 'wbcr/gac/update_analytic_library' );
if ( ! wp_next_scheduled( 'wbcr/gac/update_analytic_library' ) ) {
wp_schedule_event( time(), 'daily', 'wbcr/gac/update_analytic_library' );
}
}
}
/**
* Runs activation actions.
*
* @since 1.0.0
*/
public function deactivate() {
if ( wp_next_scheduled( 'wbcr/gac/update_analytic_library' ) ) {
wp_clear_scheduled_hook( 'wbcr/gac/update_analytic_library' );
}
}
}

View File

@@ -0,0 +1,274 @@
<?php
/**
* The boot file is needed to connect backend files, as well as register hooks.
* Some hooks are so small that it does not make sense to put them into a file
* or put them into a specific group of code.
*
* I usually register administrator notifications, create handlers before saving
* plugin settings or after, register options in the Clearfy plugin.
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright Webcraftic
*/
// Exit if accessed directly
if( !defined('ABSPATH') ) {
exit;
}
/**
* After saving the settings in the plugin, we check whether the
* options for analytic caching are enabled or not. If enabled,
* add cron task.
*
* @param Wbcr_FactoryPages480_ImpressiveThemplate $page
*
* @param Wbcr_Factory480_Plugin $plugin
*
* @return void
* @since 3.0.1
*
*/
add_action('wbcr/factory/pages/impressive/after_form_save', function ($plugin, $page) {
if( WGA_Plugin::app()->getPluginName() != $plugin->getPluginName() ) {
return;
}
$ga_cache = WGA_Plugin::app()->getPopulateOption('ga_cache');
if( $ga_cache ) {
if( !wp_next_scheduled('wbcr/gac/update_analytic_library') ) {
wp_schedule_event(time(), 'daily', 'wbcr/gac/update_analytic_library');
}
} else {
if( wp_next_scheduled('wbcr/gac/update_analytic_library') ) {
wp_clear_scheduled_hook('wbcr/gac/update_analytic_library');
}
}
}, 10, 2);
if( !defined('LOADING_GA_CACHE_AS_ADDON') ) {
/**
* Notice that the plugin has been seriously updated!
*
* @param string $plugin_name
*
* @param array $notices all registered notices
*
* @return array all notices
* @since 3.0.1
*
*/
function wbcr_ga_admin_conflict_notices_error($notices, $plugin_name)
{
if( $plugin_name != WGA_Plugin::app()->getPluginName() ) {
return $notices;
}
$text = '<p>' . __('The <b>Simple Google Analytics</b> plugin has some major changes!', 'simple-google-analytics') . '</p>';
$text .= '<p>' . __('Unfortunately, the old version of the plugin (2.2.2) is no longer supported, but you still can download it from the WordPress repository in case if the new release doesnt work for you.', 'simple-google-analytics') . '</p>';
$text .= '<p>' . __('Weve updated the code and fixed the compatibility issue for the latest WordPress and PHP versions. Weve also added additional feature of the Local Google Analytics this way your website will load faster. The plugins name has been changed to Local Google Analytics, but all features remained the same.', 'simple-google-analytics') . '</p>';
$text .= '<p>' . sprintf(__('Please, check <a href="%s">plugin settings</a> and its performance on your website. We do care about you and want to avoid any problems with the new version.', 'simple-google-analytics') . '</p>', admin_url('options-general.php?page=ga_cache-' . WGA_Plugin::app()->getPluginName())) . '</p>';
$text .= '<p>' . sprintf(__('We are aimed to pay more attention to the speed and security aspects of your website. Thats why you should definitely try our basic WordPress optimization plugin as well. Clearfy includes functionality of this plugin and has many additional features for the website optimization:
<a href="%s">Donwload Clearfy for free</a>', 'simple-google-analytics'), 'https://clearfy.pro?utm_source=wordpress.org&utm_campaign=' . WGA_Plugin::app()->getPluginName()) . '</p>';
$notices[] = [
'id' => 'ga_plugin_upgrade_notice1',
'type' => 'warning',
'dismissible' => true,
'dismiss_expires' => 0,
'text' => $text
];
return $notices;
}
add_filter('wbcr/factory/admin_notices', 'wbcr_ga_admin_conflict_notices_error', 10, 2);
/**
* Migrate settings from the old plugin to the new one.
*
* @return void
* @since 3.0.1
*/
add_action('init', function () {
global $wpdb;
if( defined('LOADING_GA_CACHE_AS_ADDON') ) {
return;
}
$is_migrate_up_to_230 = WGA_Plugin::app()->getPopulateOption('is_migrate_up_to_230', false);
if( !$is_migrate_up_to_230 ) {
$old_plugin_tracking_id = get_option('sga_analytics_id');
$old_plugin_code_location = get_option('sga_code_location');
$old_plugin_demographic_and_interest = (int)get_option('sga_demographic_and_interest');
$old_plugin_sga_render_when_loggedin = (int)get_option('sga_render_when_loggedin');
if( !empty($old_plugin_tracking_id) ) {
WGA_Plugin::app()->updatePopulateOption('ga_cache', 1);
WGA_Plugin::app()->updatePopulateOption('ga_tracking_id', $old_plugin_tracking_id);
$script_position = 'footer';
if( $old_plugin_code_location == 'head' ) {
$script_position = 'header';
}
WGA_Plugin::app()->updatePopulateOption('ga_script_position', $script_position);
WGA_Plugin::app()->updatePopulateOption('ga_anonymize_ip', $old_plugin_demographic_and_interest);
WGA_Plugin::app()->updatePopulateOption('ga_track_admin', $old_plugin_sga_render_when_loggedin);
$wpdb->query("DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE 'sga_%';");
}
WGA_Plugin::app()->updatePopulateOption('is_migrate_up_to_230', 1);
}
});
/**
* Add a link to plugin meta. You can find this link in admin panel on
* the page plugins.php. Look under plugin short description.
*
* @param array $links An array of the plugin's metadata, including the version,
* author, author URI, and plugin URI.
* @param string $file path to the plugin file, relative to the plugins directory.
*
* @return array
*/
add_filter('plugin_row_meta', function ($links, $file) {
if( $file == WGA_PLUGIN_BASE ) {
$url = 'https://clearfy.pro';
if( get_locale() == 'ru_RU' ) {
$url = 'https://ru.clearfy.pro';
}
$url .= '?utm_source=wordpress.org&utm_campaign=' . WGA_Plugin::app()->getPluginName();
$links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . __('Get ultimate plugin free', 'simple-google-analytics') . '</a>';
}
return $links;
}, 10, 2);
/**
* Rating widget url
*
* @param string $page_url
* @param string $plugin_name
*
* @return string
*/
add_filter('wbcr_factory_imppage_rating_widget_url', function ($page_url, $plugin_name) {
if( $plugin_name == WGA_Plugin::app()->getPluginName() ) {
return 'https://wordpress.org/support/plugin/simple-google-analytics/reviews/#new-post';
}
return $page_url;
}, 10, 2);
/**
* Удаляем лишние виджеты из правого сайдбара в интерфейсе плагина
*
* - Виджет с премиум рекламой
* - Виджет с рейтингом
* - Виджет с маркерами информации
*/
add_filter('wbcr/factory/pages/impressive/widgets', function ($widgets, $position, $plugin) {
if( WGA_Plugin::app()->getPluginName() == $plugin->getPluginName() && 'right' == $position ) {
unset($widgets['business_suggetion']);
unset($widgets['rating_widget']);
unset($widgets['info_widget']);
}
return $widgets;
}, 20, 3);
} else {
/**
* This action is executed when the component of the Clearfy plugin
* is activate and if this component is name ga_cache
*
* @return void
* @since 3.0.1
*/
add_action('wbcr/clearfy/activated_component', function ($component_name) {
if( $component_name == 'ga_cache' ) {
require_once WGA_PLUGIN_DIR . '/admin/activation.php';
$plugin = new WGA_Activation(WGA_Plugin::app());
$plugin->activate();
}
});
/**
* This action is executed when the component of the Clearfy plugin
* is deactivated and if this component is name ga_cache
*
* @return void
* @since 3.0.1
*/
add_action('wbcr_clearfy_pre_deactivate_component', function ($component_name) {
if( $component_name == 'ga_cache' ) {
require_once WGA_PLUGIN_DIR . '/admin/activation.php';
$plugin = new WGA_Activation(WGA_Plugin::app());
$plugin->deactivate();
}
});
/**
* We register options of this plugin in global Clearfy options. Clearfy later can automatically
* set default values for this options or completely delete it from site database.
*
* In more detail you can read about it here: wp-plugin-clearfy\admin\includes\options.php
*
* @param array $options all available component options plugin clearfy
*
* @return array
*/
function wbcr_ga_group_options($options)
{
$options[] = [
'name' => 'ga_cache',
'title' => __('Google Analytics Cache', 'simple-google-analytics'),
'tags' => []
];
$options[] = [
'name' => 'ga_tracking_id',
'title' => __('Google analytic Code', 'clearfy'),
'tags' => []
];
$options[] = [
'name' => 'ga_adjusted_bounce_rate',
'title' => __('Use adjusted bounce rate?', 'clearfy'),
'tags' => []
];
$options[] = [
'name' => 'ga_enqueue_order',
'title' => __('Change enqueue order?', 'clearfy'),
'tags' => []
];
$options[] = [
'name' => 'ga_disable_display_features',
'title' => __('Disable all display features functionality?', 'clearfy'),
'tags' => []
];
$options[] = [
'name' => 'ga_anonymize_ip',
'title' => __('Use Anonymize IP? (Required by law for some countries)', 'clearfy'),
'tags' => []
];
$options[] = [
'name' => 'ga_track_admin',
'title' => __('Track logged in Administrators?', 'clearfy'),
'tags' => []
];
return $options;
}
add_filter("wbcr_clearfy_group_options", 'wbcr_ga_group_options');
}

View File

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

View File

@@ -0,0 +1,174 @@
<?php
/**
* Options for additionally form
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 21.01.2018, Webcraftic
* @version 1.0
*/
// Exit if accessed directly
if( !defined('ABSPATH') ) {
exit;
}
/**
* @return array
*/
function wbcr_ga_get_plugin_options()
{
$options = [];
$options[] = [
'type' => 'html',
'html' => '<div class="wbcr-factory-page-group-header">' . __('<strong>Improve browser caching for 3rd-party services</strong>.', 'simple-google-analytics') . '<p>' . __('To improve Google Page Speed indicators Analytics caching is needed. However, it can also slightly increase your website loading speed, because Analytics js files will load locally. The second case that you might need these settings is the usual Google Analytics connection to your website. You do not need to do this with other plugins or insert the tracking code into your theme.', 'simple-google-analytics') . '</p></div>'
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'facebook_cache',
'title' => __('Improve browser caching for Facebook Pixel', 'simple-google-analytics'),
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('Clearfy will host these Facebook Pixels locally on your server to help satisfy the PageSpeed recommendation for Leverage browser caching.', 'simple-google-analytics') . '<br>--<br><span class="wbcr-factory-light-orange-color">' . __('ATTENTION! Before using this option, remove the previously installed Google Analytics code inside your theme or plugins associated with this feature!', 'simple-google-analytics') . '</span>',
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'google_analytics_cache',
'title' => __('Improve browser caching for Google Analytics', 'simple-google-analytics'),
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('Clearfy will host these Google scripts locally on your server to help satisfy the PageSpeed recommendation for Leverage browser caching.', 'simple-google-analytics') . (WGA_Plugin::app()->getPopulateOption('ga_cache') ? '<br>--<br><span class="wbcr-factory-light-orange-color">' . __('ATTENTION! Before using this option, please disable the option "Add Google Analytics code and Cache"!', 'simple-google-analytics') . '</span>' : ''),
'cssClass' => WGA_Plugin::app()->getPopulateOption('ga_cache') ? ['factory-checkbox-disabled'] : [],
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'yandex_metrika_cache',
'title' => __('Improve browser caching for Yandex metrika', 'simple-google-analytics'),
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('Clearfy will host these Yandex metrika scripts locally on your server to help satisfy the PageSpeed recommendation for Leverage browser caching..', 'simple-google-analytics') . (WGA_Plugin::app()->getPopulateOption('ga_cache') ? '<br>--<br><span class="wbcr-factory-light-orange-color">' . __('ATTENTION! Before using this option, please disable the option "Add Google Analytics code and Cache"!', 'simple-google-analytics') . '</span>' : ''),
'default' => false
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'ga_cache',
'title' => __('Add Google Analytics code and Cache', 'simple-google-analytics'),
//'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('If you enable this option, the plugin will begin to save a local copy of Google Analytics to speed up the loading of your website and improve Google Page Speed.', 'simple-google-analytics') . '<br>--<br><span class="wbcr-factory-red-color">' . __('ATTENTION! This option is deprecated and cannot be used since plugin version 1.9.0! Use the new option "Improve browser caching for Google Analytics", you will have to insert the google analytics code yourself without the Clearfy plugin.', 'simple-google-analytics') . '</span>',
'default' => false,
'cssClass' => !WGA_Plugin::app()->getPopulateOption('ga_cache') ? ['factory-checkbox-disabled'] : [],
'eventsOn' => [
'show' => '#wbcr-clearfy-performance-ga-block'
],
'eventsOff' => [
'hide' => '#wbcr-clearfy-performance-ga-block'
]
];
$options[] = [
'type' => 'div',
'id' => 'wbcr-clearfy-performance-ga-block',
'items' => [
[
'type' => 'textbox',
'way' => 'buttons',
'name' => 'ga_tracking_id',
'title' => __('Google analytic Code', 'simple-google-analytics'),
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('Set the Google Analytics tracking code.', 'simple-google-analytics'),
'placeholder' => 'UA-XXXXX-Y'
],
[
'type' => 'dropdown',
'way' => 'buttons',
'name' => 'ga_script_position',
'data' => [
['header', 'Header'],
['footer', 'Footer'],
],
'title' => __('Save GA in', 'simple-google-analytics'),
'hint' => __('Select location for the Google Analytics code.', 'simple-google-analytics'),
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'default' => 'footer'
],
[
'type' => 'integer',
'name' => 'ga_adjusted_bounce_rate',
'title' => __('Use adjusted bounce rate?', 'simple-google-analytics'),
'default' => 0,
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('Essentially, you set up an event which is triggered after a user spends a certain amount of time on the landing page, telling Google Analytics not to count these users as bounces. A user may come to your website, find all of the information they need (a phone number, for example) and then leave the site without visiting another page. Without adjusted bounce rate, such a user would be considered a bounce, even though they had a successful experience. By defining a time limit after which you can consider a user to be "engaged," that user would no longer count as a bounce, and you\'d get a more accurate idea of whether they found what they were looking for.', 'simple-google-analytics')
],
[
'type' => 'integer',
'way' => 'buttons',
'name' => 'ga_enqueue_order',
'title' => __('Change enqueue order?', 'simple-google-analytics'),
'default' => 0,
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('By default, Google Analytics code is loaded before other scripts and javasscript code, but if you set the value to 100, the GA code will be loaded after all other scripts. By changing the priority, you can set code position on the page.', 'simple-google-analytics')
],
[
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'ga_disable_display_features',
'title' => __('Disable all display features functionality?', 'simple-google-analytics'),
//'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
'hint' => sprintf(__('Disable all <a href="%s">display features functionality?</a>', 'simple-google-analytics'), 'https://developers.google.com/analytics/devguides/collection/analyticsjs/display-features'),
'default' => false
],
[
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'ga_anonymize_ip',
'title' => __('Use Anonymize IP? (Required by law for some countries)', 'simple-google-analytics'),
//'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
'hint' => sprintf(__('Use <a href="%s">Anonymize IP?</a> (Required by law for some countries)', 'simple-google-analytics'), 'https://support.google.com/analytics/answer/2763052'),
'default' => false
],
[
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'ga_track_admin',
'title' => __('Track logged in Administrators?', 'simple-google-analytics'),
'layout' => ['hint-type' => 'icon', 'hint-icon-color' => 'grey'],
'hint' => __('Track logged in Administrators?', 'simple-google-analytics'),
'default' => false
]
]
];
return $options;
}
/**
* @param $form
* @param $page Wbcr_FactoryPages480_ImpressiveThemplate
*
* @return mixed
*/
function wbcr_ga_additionally_form_options($form, $page)
{
if( empty($form) ) {
return $form;
}
$options = wbcr_ga_get_plugin_options();
foreach($options as $option) {
$form[0]['items'][] = $option;
}
return $form;
}
add_filter('wbcr_clr_code_clean_form_options', 'wbcr_ga_additionally_form_options', 10, 2);

View File

@@ -0,0 +1,97 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Страница общих настроек для этого плагина.
*
* Может быть использована только, если этот плагин используется как отдельный плагин, а не как аддон
* дя плагина Clearfy. Если плагин загружен, как аддон для Clearfy, эта страница не будет подключена.
*
* Поддерживает режим работы с мультисаймами. Вы можете увидеть эту страницу в панели настройки сети.
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 2018 Webraftic Ltd
* @version 1.0
*/
class WGA_CachePage extends WBCR\Factory_Templates_134\Pages\PageBase {
/**
* {@inheritDoc}
*
* @var string
*/
public $id = "ga_cache";
/**
* {@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;
/**
* @param Wbcr_Factory480_Plugin $plugin
*/
public function __construct( Wbcr_Factory480_Plugin $plugin ) {
$this->menu_title = __( 'Local Google Analytics', 'simple-google-analytics' );
if ( ! defined( 'LOADING_GA_CACHE_AS_ADDON' ) ) {
$this->internal = false;
$this->menu_target = 'options-general.php';
$this->add_link_to_plugin_actions = true;
}
parent::__construct( $plugin );
$this->plugin = $plugin;
}
/**
* {@inheritDoc}
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @since 3.1.0
* @return string|void
*/
public function getPageTitle() {
return __( 'General', 'simple-google-analytics' );
}
/**
* Permalinks options.
*
* @since 1.0.0
* @return mixed[]
*/
public function getPageOptions() {
$options = wbcr_ga_get_plugin_options();
$formOptions = [];
$formOptions[] = [
'type' => 'form-group',
'items' => $options,
//'cssClass' => 'postbox'
];
return apply_filters( 'wbcr_ga_notices_form_options', $formOptions, $this );
}
}

View File

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

View File

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