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,37 @@
<?php
/**
* Activator for the Update manager
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright (c) 09.09.2017, Webcraftic
* @see Factory480_Activator
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WUPM_Activation extends Wbcr_Factory480_Activator {
/**
* Runs activation actions.
*
* @since 1.0.0
*/
public function activate() {
}
/**
* Runs deactivation actions.
*
* @since 1.0.0
*/
public function deactivate() {
}
}

View File

@@ -0,0 +1,54 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* ajax action for switch option
*/
function wbcr_upm_change_flag() {
check_ajax_referer( 'wbcr_upm_change_flag' );
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( - 1, 403 );
}
$is_theme = false;
$app = WUPM_Plugin::app();
$slug = $app->request->post( 'theme', null, true );
if ( ! empty( $slug ) ) {
$is_theme = true;
} else {
$slug = $app->request->post( 'plugin', null, true );
}
$flag = $app->request->post( 'flag', null, true );
$new_value = (bool) $app->request->post( 'value' );
if ( empty( $slug ) or empty( $flag ) ) {
wp_send_json_error( [ 'error_message' => __( 'Required arguments of slug, flag is empty!', 'webcraftic-updates-manager' ) ] );
}
if ( $is_theme ) {
$plugin_filters = new WUPM_ThemeFilters( $app );
} else {
$plugin_filters = new WUPM_PluginFilters( $app );
}
$method = ( ( $new_value ) ? 'disable' : 'enable' ) . $flag;
if ( ! method_exists( $plugin_filters, $method ) ) {
wp_send_json_error( [ 'error_message' => __( 'Method %s is not found!', 'webcraftic-updates-manager' ) ] );
}
$plugin_filters->$method( $slug );
$plugin_filters->save();
wp_send_json_success();
}
add_action( 'wp_ajax_wbcr-upm-change-flag', 'wbcr_upm_change_flag' );

View File

@@ -0,0 +1,156 @@
/**
* General styles
* @author Alex Kovalev <alex.kovalevv@gmail.com>
* @copyright Alex Kovalev 23.08.2017
*/
#WBCR {
/* upm */
}
#WBCR .wp-list-table th,
#WBCR .wp-list-table .plugin-name {
font-size: 13px;
font-weight: 600;
}
#WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td {
background: #f9f2f0 !important;
}
#WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td .factory-buttons-way,
#WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td input[type="checkbox"] {
border-color: #fff;
background: #fff;
}
#WBCR .wp-list-table th.wbcr-upm-column-premium,
#WBCR .wp-list-table td.wbcr-upm-column-premium {
background: #f9f2f0 !important;
}
#WBCR .wp-list-table th.wbcr-upm-column-premium .factory-buttons-way,
#WBCR .wp-list-table td.wbcr-upm-column-premium .factory-buttons-way,
#WBCR .wp-list-table th.wbcr-upm-column-premium input[type="checkbox"],
#WBCR .wp-list-table td.wbcr-upm-column-premium input[type="checkbox"] {
border-color: #fff;
background: #fff;
}
#WBCR .wp-list-table .plugin-update-tr.active td,
#WBCR .wp-list-table.plugins .active th.check-column {
border-left: 4px solid #e6e6e6 !important;
padding-left: 8px !important;
}
#WBCR .wp-list-table.plugins .row-actions,
#WBCR .wp-list-table.plugins .second {
padding: 0 0 5px;
color: #949292;
}
#WBCR .wp-list-table.plugins .active td,
#WBCR .wp-list-table.plugins .active th {
background-color: #ffffff;
}
#WBCR .wp-list-table.plugins,
#WBCR .wp-list-table.plugins td,
#WBCR .wp-list-table.plugins th,
#WBCR .wp-list-table .row-actions .network_active,
#WBCR .wp-list-table .row-actions .network_only {
color: #777;
}
#WBCR .wp-list-table .widefat ol,
#WBCR .wp-list-table .widefat p,
#WBCR .wp-list-table .widefat tfoot tr td,
#WBCR .wp-list-table .widefat tfoot tr th,
#WBCR .wp-list-table .widefat thead tr td,
#WBCR .wp-list-table .widefat thead tr th,
#WBCR .wp-list-table .widefat ul {
color: #7d7d7d;
}
#WBCR .wp-list-table #disable_updates,
#WBCR .wp-list-table #disable_auto_updates,
#WBCR .wp-list-table #disable_translation_updates,
#WBCR .wp-list-table #hide_item {
width: 100px;
}
#WBCR .column-flags .factory-checkbox {
display: inline-flex;
}
#WBCR .wp-list-table.autoupdate th {
white-space: normal !important;
}
#WBCR .wp-list-table.autoupdate .plugin-title {
white-space: normal !important;
}
#WBCR .wp-list-table__plugins .plugin-title {
max-width: 12rem;
}
#WBCR .wbcr-upm-group-header-pro {
position: relative;
display: inline-block;
}
#WBCR .wbcr-upm-group-header-pro:after {
display: inline-block;
position: relative;
content: 'PRO';
background: #ff5722;
border-radius: 4px;
color: #fff;
font-size: 10px;
line-height: 1;
font-style: normal;
padding: 4px 6px;
margin-left: 4px;
vertical-align: top;
top: 0;
left: auto;
right: 0;
z-index: 11;
}
#WBCR #disable_translation_updates,
#WBCR #hide_item {
position: relative;
}
#WBCR #disable_translation_updates.wbcr-upm-column-pro:after,
#WBCR #hide_item.wbcr-upm-column-pro:after {
display: inline-block;
position: absolute;
content: 'PRO';
background: #ff5722;
border-radius: 4px;
color: #fff;
font-size: 10px;
line-height: 1;
font-style: normal;
padding: 4px 6px;
margin-left: 4px;
vertical-align: top;
top: -10px;
left: auto;
right: 0;
z-index: 11;
}
#WBCR .factory-checkbox.wbcr-upm-icon-pro:after {
display: inline-block;
position: relative;
content: 'PRO';
background: #ff5722;
border-radius: 4px;
color: #fff;
font-size: 10px;
line-height: 1;
font-style: normal;
padding: 4px 6px;
margin-left: 4px;
vertical-align: top;
top: -8px;
left: -10px;
right: auto;
z-index: 11;
}
#WBCR .wp-list-table.autoupdate .check-column {
padding: 10px 9px;
}
.factory-checkbox-disabled input,
.factory-checkbox-disabled button {
pointer-events: none;
cursor: not-allowed;
opacity: 0.65;
filter: alpha(opacity=65);
-webkit-box-shadow: none;
box-shadow: none;
}
/*# sourceMappingURL=general.css.map */

View File

@@ -0,0 +1,33 @@
/**
* Plugins page interface
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright Webcraftic 03.09.2018
*/
/* wordpress default plugins page */
.wbcr-upm-plugin-status,
tbody .check-column:not(.hide-placeholder):after {
display: block;
content: "\f463";
line-height: 1;
font-family: dashicons;
text-decoration: inherit;
font-weight: 400;
font-style: normal;
vertical-align: top;
text-align: center;
margin: 4px 0 0 8px;
color: #b4b9be;
border: 1px solid #b4b9be;
font-size: 14px;
height: 14px;
width: 14px;
}
.wbcr-upm-plugin-status.wbcr-upm-red {
color: rgba(170, 0, 0, 0.58);
border-color: rgba(170, 0, 0, 0.45);
}
.wbcr-upm-plugin-status.wbcr-upm-purple {
color: #ac62b9;
border-color: #a767b3;
}
/*# sourceMappingURL=plugins.css.map */

View File

@@ -0,0 +1,21 @@
/* update manager button */
/*#wpbody .search-form:not(.hide-placeholder):before {
display: inline-block;
content: 'Update manager';
margin-left: 4px;
padding: 4px 8px;
position: relative;
top: -3px;
text-decoration: none;
border: 1px solid #ccc;
border-radius: 2px;
background: #f7f7f7;
text-shadow: none;
font-weight: 600;
font-size: 13px;
line-height: normal;
color: #0073aa;
cursor: pointer;
outline: 0;
}*/
/*# sourceMappingURL=themes.css.map */

View File

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

View File

@@ -0,0 +1,98 @@
jQuery(function($) {
var initAjaxControls = function() {
function toggleRedLine(val){
var row = $(this).parents('tr');
if( !row.hasClass('row-global-disabled') ){
var disable_display = row.find('#wbcr_updates_manager_hide_item').val();
var disable_all_updates = row.find('#wbcr_updates_manager_disable_updates').val();
if(disable_display !== undefined) disable_display = parseInt(disable_display);
if(disable_all_updates !== undefined) disable_all_updates = parseInt(disable_all_updates);
if(!disable_all_updates && (disable_display === undefined || !disable_display)){
row.removeClass('inactive').addClass('active');
}else{
row.removeClass('active').addClass('inactive');
}
}
}
$('.factory-ajax-checkbox').on('change', function(ev) {
var action = $(this).data('action');
var new_value = $(this).val();
var data = {};
data['_wpnonce'] = wbcr_upm_ajax.nonce;
data['action'] = 'wbcr-upm-change-flag';
data['theme'] = $(this).data('theme-slug');
if( !data['theme'] ) {
data['plugin'] = $(this).data('plugin-slug');
}
data['flag'] = $(this).data('action');
data['value'] = new_value;
if( $(this).data('inverse') ){
data['value'] = 0 + ! parseInt(new_value);
}
var disable_group = $(this).data('disable-group');
if( disable_group ) {
if( new_value == true ) {
$("." + disable_group).find('button, input').prop('disabled', true);
toggleRedLine.apply(this);
} else {
$("." + disable_group).each(function(k, v) {
if( !$(v).hasClass('global-disabled') ) {
$(v).find('button, input').prop('disabled', false);
}
toggleRedLine.apply(this);
});
}
}
$.ajax({
url: ajaxurl,
method: 'post',
data: data,
success: function(response) {
if( !response || !response.success ) {
if( response.data.error_message ) {
$.wbcr_factory_templates_134.app.showNotice('Error: [' + response.data.error_message + ']', 'danger');
}
return false;
}
/*var noticeId = $.wbcr_factory_templates_134.app.showNotice('Settings successfully updated', 'success');
setTimeout(function() {
$.wbcr_factory_templates_134.app.hideNotice(noticeId);
}, 5000);*/
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(xhr.responseText);
console.log(thrownError);
$.wbcr_factory_templates_134.app.showNotice('Error: [' + thrownError + '] Status: [' + xhr.status + '] Error massage: [' + xhr.responseText + ']', 'danger');
}
});
});
$('.wbcr_um_select_item').on('change', function(){
$('.wbcr_um_select_all').prop('checked', false);
});
$('.wbcr_um_select_all').on('change', function(){
if($(this).prop('checked')){
$('.wbcr_um_select_item').prop('checked', true);
}else{
$('.wbcr_um_select_item').prop('checked', false);
}
});
};
initAjaxControls();
});

View File

@@ -0,0 +1,39 @@
/**
* Plugins interface
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright (c) 10.09.2017, Webcraftic
* @version 1.0
*/
jQuery(function($) {
window.um_add_plugin_icons = function(info) {
$('#the-list tr[data-plugin]').each(function(k, v) {
var title = window.wbcr_upm_plugins_label_l10n['default'];
var plugin_path = $(v).data('plugin'),
slug_parts = plugin_path.split('/'),
slug = slug_parts[0],
update_class = '',
is_auto_update = false,
is_update_disabled = false;
if( (info['filters']['disable_auto_updates'] === undefined || !info['filters']['disable_auto_updates'][slug]) ) {
is_auto_update = true;
}
if( (info['filters']['disable_updates'] !== undefined && info['filters']['disable_updates'][slug]) ) {
is_update_disabled = true;
}
if( is_auto_update ) {
update_class = 'wbcr-upm-purple';
title = window.wbcr_upm_plugins_label_l10n['auto_update'];
}
if( is_update_disabled ) {
update_class = 'wbcr-upm-red';
title = window.wbcr_upm_plugins_label_l10n['disable_updates'];
}
$(v).find('.check-column').addClass('hide-placeholder').append('<span class="dashicons dashicons-update wbcr-upm-plugin-status ' + update_class + '" title="' + title + '"></span>');
});
};
});

View File

@@ -0,0 +1,238 @@
<?php
/**
* Admin boot
*
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
* @copyright Webcraftic 25.05.2017
* @version 1.0
*/
require_once WUPM_PLUGIN_DIR . '/admin/includes/class-plugin-filters.php';
require_once WUPM_PLUGIN_DIR . '/admin/includes/class-theme-filters.php';
if ( ! defined( 'LOADING_UPDATES_MANAGER_AS_ADDON' ) ) {
function wbcr_upm_set_plugin_meta( $links, $file ) {
if ( $file == WUPM_PLUGIN_BASE ) {
$url = 'https://clearfy.pro';
if ( get_locale() == 'ru_RU' ) {
$url = 'https://ru.clearfy.pro';
}
$url .= '?utm_source=wordpress.org&utm_campaign=' . WUPM_Plugin::app()->getPluginName();
$links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . __( 'Get ultimate plugin free', 'webcraftic-updates-manager' ) . '</a>';
}
return $links;
}
if ( ! defined( 'LOADING_UPDATES_MANAGER_AS_ADDON' ) ) {
add_filter( 'plugin_row_meta', 'wbcr_upm_set_plugin_meta', 10, 2 );
}
/**
* Rating widget url
*
* @param string $page_url
* @param string $plugin_name
*
* @return string
*/
function wbcr_upm_rating_widget_url( $page_url, $plugin_name ) {
if ( ! defined( 'LOADING_UPDATES_MANAGER_AS_ADDON' ) && ( $plugin_name == WUPM_Plugin::app()->getPluginName() ) ) {
return 'https://goo.gl/Be2hQU';
}
return $page_url;
}
add_filter( 'wbcr_factory_pages_480_imppage_rating_widget_url', 'wbcr_upm_rating_widget_url', 10, 2 );
/**
* Удаляем лишние виджеты из правого сайдбара в интерфейсе плагина
*
* - Виджет с премиум рекламой
* - Виджет с рейтингом
* - Виджет с маркерами информации
*/
add_filter( 'wbcr/factory/pages/impressive/widgets', function ( $widgets, $position, $plugin ) {
if ( WUPM_Plugin::app()->getPluginName() == $plugin->getPluginName() && 'right' == $position ) {
unset( $widgets['business_suggetion'] );
unset( $widgets['rating_widget'] );
unset( $widgets['info_widget'] );
}
return $widgets;
}, 20, 3 );
} else {
function wbcr_upm_group_options( $options ) {
$options[] = [
'name' => 'plugin_updates',
'title' => __( 'Disable plugin updates', 'webcraftic-updates-manager' ),
'tags' => [ 'disable_all_updates' ],
'values' => [ 'disable_all_updates' => 'disable_plugin_updates' ]
];
$options[] = [
'name' => 'theme_updates',
'title' => __( 'Disable theme updates', 'webcraftic-updates-manager' ),
'tags' => [ 'disable_all_updates' ],
'values' => [ 'disable_all_updates' => 'disable_theme_updates' ]
];
$options[] = [
'name' => 'auto_tran_update',
'title' => __( 'Disable Automatic Translation Updates', 'webcraftic-updates-manager' ),
'tags' => [ 'disable_all_updates' ]
];
$options[] = [
'name' => 'wp_update_core',
'title' => __( 'Disable wordPress core updates', 'webcraftic-updates-manager' ),
'tags' => [ 'disable_all_updates' ],
'values' => [ 'disable_all_updates' => 'disable_core_updates' ]
];
$options[] = [
'name' => 'enable_update_vcs',
'title' => __( 'Enable updates for VCS Installations', 'webcraftic-updates-manager' ),
'tags' => []
];
$options[] = [
'name' => 'plugins_update_filters',
'title' => __( 'Plugin filters', 'webcraftic-updates-manager' ),
'tags' => []
];
$options[] = [
'name' => 'updates_nags_only_for_admin',
'title' => __( 'Updates nags only for Admin', 'webcraftic-updates-manager' ),
'tags' => [ 'recommended' ]
];
$options[] = [
'name' => 'disable_core_notifications',
'title' => __( 'Core notifications', 'webcraftic-updates-manager' ),
'tags' => []
];
$options[] = [
'name' => 'notify_updated',
'title' => __( 'Notify me when update successful installed', 'webcraftic-updates-manager' ),
'tags' => []
];
$options[] = [
'name' => 'notify_email',
'title' => __( 'Email address', 'webcraftic-updates-manager' ),
'tags' => []
];
return $options;
}
add_filter( "wbcr_clearfy_group_options", 'wbcr_upm_group_options' );
function wbcr_upm_allow_quick_mods( $mods ) {
$mods['disable_all_updates'] = [
'title' => __( 'One click disable all updates', 'webcraftic-updates-manager' ),
'icon' => 'dashicons-update'
];
return $mods;
}
add_filter( "wbcr_clearfy_allow_quick_mods", 'wbcr_upm_allow_quick_mods' );
}
/**
* Ошибки совместимости с похожими плагинами
*/
function wbcr_upm_admin_conflict_notices_error( $notices, $plugin_name ) {
if ( $plugin_name != WUPM_Plugin::app()->getPluginName() ) {
return $notices;
}
$warnings = [];
$default_notice = WUPM_Plugin::app()->getPluginTitle() . ': ' . __( '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.', 'webcraftic-updates-manager' );
$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!', 'webcraftic-updates-manager' );
if ( is_plugin_active( 'companion-auto-update/companion-auto-update.php' ) ) {
$warnings[] = sprintf( $default_notice, 'Companion Auto Update', WUPM_Plugin::app()->getPluginTitle(), 'Companion Auto Update', 'Companion Auto Update' );
}
if ( is_plugin_active( 'disable-updates/disable-updates.php' ) ) {
$warnings[] = sprintf( $default_notice, 'Disable Updates', WUPM_Plugin::app()->getPluginTitle(), 'Disable Updates', 'Disable Updates' );
}
if ( is_plugin_active( 'disable-wordpress-updates/disable-updates.php' ) ) {
$warnings[] = sprintf( $default_notice, 'Disable All WordPress Updates', WUPM_Plugin::app()->getPluginTitle(), 'Disable All WordPress Updates', 'Disable All WordPress Updates' );
}
if ( is_plugin_active( 'stops-core-theme-and-plugin-updates/main.php' ) ) {
$warnings[] = sprintf( $default_notice, 'Easy Updates Manager', WUPM_Plugin::app()->getPluginTitle(), 'Easy Updates Manager', 'Easy Updates Manager' );
}
if ( empty( $warnings ) ) {
return $notices;
}
$notice_text = '';
foreach ( (array) $warnings as $warning ) {
$notice_text .= '<p>' . $warning . '</p>';
}
$notices[] = [
'id' => 'ump_plugin_compatibility',
'type' => 'error',
'dismissible' => true,
'dismiss_expires' => 0,
'text' => $notice_text
];
return $notices;
}
add_filter( 'wbcr/factory/admin_notices', 'wbcr_upm_admin_conflict_notices_error', 10, 2 );
/**
* Подключаем скрипты для создания лейблов для списка плагинов
*/
add_action( 'admin_enqueue_scripts', function ( $handles ) {
if ( ! current_user_can( 'install_plugins' ) || ! in_array( $handles, [ 'plugins.php', 'plugins-network.php' ] ) ) {
return;
}
wp_enqueue_style( 'wbcr-upm-plugins', WUPM_PLUGIN_URL . '/admin/assets/css/plugins.css', [], WUPM_Plugin::app()->getPluginVersion() );
wp_enqueue_script( 'wbcr-upm-plugins-js', WUPM_PLUGIN_URL . '/admin/assets/js/plugins.js', [ 'jquery' ], WUPM_Plugin::app()->getPluginVersion() );
} );
/**
* Добавляем код локализации скриптов для создания лейблов в списке плагинов
*/
add_action( 'admin_footer', function () {
if ( ! current_user_can( 'install_plugins' ) || ! in_array( get_current_screen()->id, [
'plugins',
'plugins-network'
] ) ) {
return;
}
$pluginFilters = new WUPM_PluginFilters( WUPM_Plugin::app() );
$filters = $pluginFilters->getPlugins();
$l10n = [
'default' => __( "Auto-update disabled", 'webcraftic-updates-manager' ),
'auto_update' => __( "Auto-update enabled", 'webcraftic-updates-manager' ),
'disable_updates' => __( "Update disabled", 'webcraftic-updates-manager' ),
'disable_tran_update' => __( "Translation update disabled", 'webcraftic-updates-manager' )
];
?>
<script>
// l10n strings
window.wbcr_upm_plugins_label_l10n = window.wbcr_upm_plugins_label_l10n || <?php echo wp_json_encode( $l10n ); ?>;
jQuery(function($) {
var info = <?= json_encode( [
'filters' => $filters,
] ); ?>;
um_add_plugin_icons(info);
});
</script>
<?php
} );

View File

@@ -0,0 +1,157 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
abstract class WUPM_AbstractFilters {
protected $plugin;
protected $update_filters;
protected $is_disable_updates;
protected $is_auto_updates;
protected $is_disable_translation_updates;
function __construct( Wbcr_Factory480_Plugin $plugin ) {
$this->plugin = $plugin;
$this->load();
}
/**
* disable all updates for item
*
* @param $item_slug string - theme or plugin slug (without main file path)
*/
public function disableUpdates( $item_slug ) {
if ( ! $this->is_disable_updates ) {
if ( ! empty( $item_slug ) ) {
if ( isset( $this->update_filters['disable_updates'] ) ) {
if ( ! isset( $this->update_filters['disable_updates'][ $item_slug ] ) ) {
$this->update_filters['disable_updates'][ $item_slug ] = true;
}
} else {
$this->update_filters['disable_updates'] = [];
$this->update_filters['disable_updates'][ $item_slug ] = true;
}
$this->save();
}
}
}
/**
* enable all updates for item
*
* @param $item_slug string - theme or plugin slug (without main file path)
*/
public function enableUpdates( $item_slug ) {
if ( ! $this->is_disable_updates ) {
if ( ! empty( $item_slug ) ) {
if ( isset( $this->update_filters['disable_updates'] ) && isset( $this->update_filters['disable_updates'][ $item_slug ] ) ) {
unset( $this->update_filters['disable_updates'][ $item_slug ] );
$this->save();
}
}
}
}
/**
* disable auto-update for item
*
* @param $item_slug string - theme or plugin slug (without main file path)
*/
public function disableAutoUpdates( $item_slug ) {
if ( $this->is_auto_updates ) {
if ( ! empty( $item_slug ) ) {
if ( isset( $this->update_filters['disable_auto_updates'] ) ) {
if ( ! isset( $this->update_filters['disable_auto_updates'][ $item_slug ] ) ) {
$this->update_filters['disable_auto_updates'][ $item_slug ] = true;
}
} else {
$this->update_filters['disable_auto_updates'] = [];
$this->update_filters['disable_auto_updates'][ $item_slug ] = true;
}
$this->save();
}
}
}
/**
* enable auto-update for item
*
* @param $item_slug string - theme or plugin slug (without main file path)
*/
public function enableAutoUpdates( $item_slug ) {
if ( $this->is_auto_updates ) {
if ( ! empty( $item_slug ) ) {
if ( isset( $this->update_filters['disable_auto_updates'] ) && isset( $this->update_filters['disable_auto_updates'][ $item_slug ] ) ) {
unset( $this->update_filters['disable_auto_updates'][ $item_slug ] );
$this->save();
}
}
}
}
/**
* enable translation updates for item
*
* @param $item_slug string - theme or plugin slug (without main file path)
*/
public function enableTranslationUpdates( $item_slug ) {
if ( ! $this->is_disable_translation_updates ) {
if ( ! empty( $item_slug ) ) {
if ( isset( $this->update_filters['disable_translation_updates'] ) && isset( $this->update_filters['disable_translation_updates'][ $item_slug ] ) ) {
unset( $this->update_filters['disable_translation_updates'][ $item_slug ] );
$this->save();
}
}
}
}
/**
* disable translation updates for item
*
* @param $item_slug string - theme or plugin slug (without main file path)
*/
public function disableTranslationUpdates( $item_slug ) {
if ( ! $this->is_disable_translation_updates ) {
if ( ! empty( $item_slug ) ) {
if ( ! isset( $this->update_filters['disable_translation_updates'] ) ) {
$this->update_filters['disable_translation_updates'] = [];
}
$this->update_filters['disable_translation_updates'][ $item_slug ] = true;
$this->save();
}
}
}
/**
* Default filters data
*
* @return array
*/
protected function getDefaultOptions() {
return [
'disable_updates' => [],
'disable_auto_updates' => [],
'disable_translation_updates' => [],
'disable_display' => [],
];
}
/**
* load filters data from db
*/
abstract public function load();
/**
* save filters data to db
*/
abstract public function save();
}

View File

@@ -0,0 +1,163 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once WUPM_PLUGIN_DIR . '/admin/includes/class-abstract-filters.php';
class WUPM_PluginFilters extends WUPM_AbstractFilters {
public function load() {
$updates_mode = $this->plugin->getPopulateOption( 'plugin_updates' );
$this->is_disable_updates = $updates_mode == 'disable_plugin_updates';
$this->is_auto_updates = $updates_mode == 'enable_plugin_auto_updates';
$this->is_disable_translation_updates = $this->plugin->getPopulateOption( 'auto_tran_update' );
$default_options = $this->getDefaultOptions();
$options = $this->plugin->getPopulateOption( 'plugins_update_filters' );
$this->update_filters = array_merge( $default_options, (array) $options );
$this->update_filters = apply_filters( 'wbcr/upm/plugin_filters', $this->update_filters );
$this->ignorePersistentPlugins( $this->update_filters );
}
public function save() {
$this->plugin->updatePopulateOption( 'plugins_update_filters', $this->update_filters );
}
/**
* Disable plugin display in default page Plugins
*
* @param $item_slug - plugin slug (without main file path)
*/
public function disableDisplay( $item_slug ) {
if ( ! empty( $item_slug ) ) {
if ( isset( $this->update_filters['disable_display'] ) ) {
if ( ! isset( $this->update_filters['disable_display'][ $item_slug ] ) ) {
$this->update_filters['disable_display'][ $item_slug ] = true;
}
} else {
$this->update_filters['disable_display'] = [];
$this->update_filters['disable_display'][ $item_slug ] = true;
}
$this->save();
}
}
/**
* Enable plugin display in default page Plugins
*
* @param $item_slug - plugin slug (without main file path)
*/
public function enableDisplay( $item_slug ) {
if ( ! empty( $item_slug ) ) {
if ( isset( $this->update_filters['disable_display'] ) && isset( $this->update_filters['disable_display'][ $item_slug ] ) ) {
unset( $this->update_filters['disable_display'][ $item_slug ] );
$this->save();
}
}
}
public function getFilters() {
return $this->update_filters;
}
/**
* Метод возвращает список вычесленных опций для переданных плагинов
*
* @param array|bool $plugin_list - list of plugin slug
*
* @return array
*/
public function getPlugins( $plugin_list = false ) {
// get all plugins
if ( $plugin_list === false ) {
$plugin_list = [];
$all_plugins = get_plugins();
foreach ( $all_plugins as $slug => $plugin ) {
$slug_parts = explode( '/', $slug );
$actual_slug = array_shift( $slug_parts );
$plugin_list[] = $actual_slug;
}
}
$result = $this->getDefaultOptions();
$all_update_disabled = $this->plugin->getPopulateOption( 'plugin_updates' ) === 'disable_plugin_updates';
$update_tran_disabled = $this->plugin->getPopulateOption( 'auto_tran_update' );
$auto_update_disabled = $this->plugin->getPopulateOption( 'plugin_updates' ) !== 'enable_plugin_auto_updates';;
foreach ( $plugin_list as $plugin_slug ) {
// individual rules
$result['disable_updates'][ $plugin_slug ] = false;
if ( isset( $this->update_filters['disable_updates'][ $plugin_slug ] ) and $this->update_filters['disable_updates'][ $plugin_slug ] ) {
$result['disable_updates'][ $plugin_slug ] = true;
}
$result['disable_auto_updates'][ $plugin_slug ] = false;
if ( isset( $this->update_filters['disable_auto_updates'][ $plugin_slug ] ) and $this->update_filters['disable_auto_updates'][ $plugin_slug ] ) {
$result['disable_auto_updates'][ $plugin_slug ] = true;
}
$result['disable_translation_updates'][ $plugin_slug ] = false;
if ( isset( $this->update_filters['disable_translation_updates'][ $plugin_slug ] ) and $this->update_filters['disable_translation_updates'][ $plugin_slug ] ) {
$result['disable_translation_updates'][ $plugin_slug ] = true;
}
if ( isset( $this->update_filters['disable_display'][ $plugin_slug ] ) and $this->update_filters['disable_display'][ $plugin_slug ] ) {
$result['disable_updates'][ $plugin_slug ] = true;
$result['disable_auto_updates'][ $plugin_slug ] = true;
$result['disable_translation_updates'][ $plugin_slug ] = true;
}
// global rules
if ( $all_update_disabled ) {
$result['disable_updates'][ $plugin_slug ] = true;
$result['disable_auto_updates'][ $plugin_slug ] = true;
$result['disable_translation_updates'][ $plugin_slug ] = true;
} else {
if ( $update_tran_disabled ) {
$result['disable_translation_updates'][ $plugin_slug ] = true;
}
if ( $auto_update_disabled ) {
$result['disable_auto_updates'][ $plugin_slug ] = true;
}
}
}
$result = $this->ignorePersistentPlugins( $result );
return $result;
}
/** исключает специальные плагины из фильтров
*
* @param $plugins
*
* @return mixed
*/
private function ignorePersistentPlugins( $plugins ) {
$persistPlugins = self::getPersistentPlugins();
foreach ( $persistPlugins as $persistPlugin ) {
$slug_parts = explode( '/', $persistPlugin );
$actual_slug = array_shift( $slug_parts );
if ( array_key_exists( $actual_slug, (array) $plugins['disable_updates'] ) ) {
unset( $plugins['disable_updates'][ $actual_slug ] );
}
}
return $plugins;
}
/**
* @return array список специальных плагинов
*/
static public function getPersistentPlugins() {
return [
"wp-plugin-clearfy/clearfy.php",
"clearfy/clearfy.php",
"wp-plugin-update-manager/webcraftic-updates-manager.php",
"webcraftic-updates-manager/webcraftic-updates-manager.php"
];
}
}

View File

@@ -0,0 +1,50 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once WUPM_PLUGIN_DIR . '/admin/includes/class-abstract-filters.php';
class WUPM_ThemeFilters extends WUPM_AbstractFilters {
public function load() {
$updates_mode = $this->plugin->getPopulateOption( 'theme_updates' );
$this->is_disable_updates = $updates_mode == 'disable_theme_updates';
$this->is_auto_updates = $updates_mode == 'enable_theme_auto_updates';
$this->is_disable_translation_updates = $this->plugin->getPopulateOption( 'auto_tran_update' );
$default_options = $this->getDefaultOptions();
$options = $this->plugin->getPopulateOption( 'themes_update_filters' );
$this->update_filters = array_merge( $default_options, (array) $options );
}
public function save() {
$this->plugin->updatePopulateOption( 'themes_update_filters', $this->update_filters );
}
public function disableUpdates( $item_slug ) {
parent::disableUpdates( $item_slug );
$this->clearThemeUpdateCache();
}
public function enableUpdates( $item_slug ) {
parent::enableUpdates( $item_slug );
$this->clearThemeUpdateCache();
}
public function clearThemeUpdateCache() {
$last_update = get_site_transient( 'update_themes' );
if ( ! is_object( $last_update ) ) {
$last_update = new stdClass;
}
// set expired time
$last_update->last_checked = 0;
set_site_transient( 'update_themes', $last_update );
}
}

View File

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

View File

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

View File

@@ -0,0 +1,150 @@
<?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
*/
class WUPM_AdvancedPage extends WBCR\Factory_Templates_134\Pages\PageBase {
/**
* {@inheritDoc}
*
* @var string
*/
public $id = "updates_advanced";
/**
* {@inheritDoc}
*
* @var string
*/
public $type = "page";
/**
* {@inheritDoc}
*
* @var string
*/
public $page_parent_page = 'updates';
/**
* {@inheritDoc}
*
* @var string
*/
public $page_menu_dashicon = 'dashicons-cloud';
/**
* {@inheritDoc}
*
* @var bool
*/
public $available_for_multisite = true;
/**
* {@inheritDoc}
*
* @since 1.1.0
* @var bool
*/
public $show_right_sidebar_in_options = true;
/**
* WUPM_AdvancedPage constructor.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*
* @param \Wbcr_Factory480_Plugin $plugin
*/
public function __construct( Wbcr_Factory480_Plugin $plugin ) {
$this->menu_title = __( 'Advanced', 'webcraftic-updates-manager' );
parent::__construct( $plugin );
}
/**
* {@inheritDoc}
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*
* @param \Wbcr_Factory480_ScriptList $scripts
* @param \Wbcr_Factory480_StyleList $styles
*/
public function assets( $scripts, $styles ) {
parent::assets( $scripts, $styles );
// Add Clearfy styles for HMWP pages
if ( defined( 'WCL_PLUGIN_ACTIVE' ) ) {
$this->styles->add( WCL_PLUGIN_URL . '/admin/assets/css/general.css' );
}
}
/**
* {@inheritDoc}
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*/
public function warningNotice() {
parent::warningNotice();
if ( isset( $_GET['wbcr_force_update'] ) ) {
$concat = __( 'Please, wait 90 sec. to see the forced automatic update result.', 'webcraftic-updates-manager' ) . '<br>';
$this->printWarningNotice( $concat );
}
}
public function showPageContent() {
?>
<div style="padding: 20px;">
<h4><?php _e( 'Force Automatic Updates', 'webcraftic-updates-manager' ); ?></h4>
<p><?php _e( 'This will attempt to force automatic updates. This is useful for debugging.', 'webcraftic-updates-manager' ); ?></p>
<a href="<?php $this->actionUrl( 'force-plugins-update' ) ?>" class="button button-default"><?php _e( 'Force update', 'webcraftic-updates-manager' ); ?></a>
</div>
<?php
}
public function forcePluginsUpdateAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
return;
}
$shedule_auto_update = function () {
wp_schedule_single_event( time() + 10, 'wp_update_plugins' );
wp_schedule_single_event( time() + 10, 'wp_version_check' );
wp_schedule_single_event( time() + 10, 'wp_update_themes' );
wp_schedule_single_event( time() + 45, 'wp_maybe_auto_update' );
if ( get_option( 'auto_updater.lock', false ) ) {
update_option( 'auto_updater.lock', time() - HOUR_IN_SECONDS * 2 );
}
};
if ( WUPM_Plugin::app()->isNetworkAdmin() ) {
foreach ( WUPM_Plugin::app()->getActiveSites() as $site ) {
switch_to_blog( $site->blog_id );
$shedule_auto_update();
restore_current_blog();
}
} else {
$shedule_auto_update();
}
$this->redirectToAction( 'index', [ 'wbcr_force_update' => 1 ] );
}
}

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 WUPM_MoreFeaturesPage extends \WBCR\Factory_Templates_134\Pages\MoreFeatures {
}

View File

@@ -0,0 +1,566 @@
<?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
*/
class WUPM_PluginsPage extends WBCR\Factory_Templates_134\Pages\PageBase {
/**
*{@inheritDoc}
*
* @var string
*/
public $id = "plugins";
/**
* {@inheritDoc}
*
* @var string
*/
public $type = "page";
/**
* {@inheritDoc}
*
* @var string
*/
public $page_parent_page = 'updates';
/**
* {@inheritDoc}
*
* @var string
*/
public $page_menu_dashicon = 'dashicons-cloud';
/**
* {@inheritDoc}
*
* @var bool
*/
public $available_for_multisite = true;
/**
* {@inheritDoc}
*
* @since 1.1.0
* @var bool
*/
public $show_right_sidebar_in_options = true;
/**
* @var
*/
private $is_disable_updates;
/**
* @var
*/
private $is_auto_updates;
private $is_disable_translation_updates;
/**
* @var array
*/
private $plugins_update_filters = [];
/**
* WUPM_PluginsPage constructor.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*
* @param \Wbcr_Factory480_Plugin $plugin
*/
public function __construct( Wbcr_Factory480_Plugin $plugin ) {
$this->menu_title = __( 'Plugins', 'webcraftic-updates-manager' );
parent::__construct( $plugin );
$updates_mode = $this->getPopulateOption( 'plugin_updates' );
$this->is_disable_updates = $updates_mode == 'disable_plugin_updates';
$this->is_auto_updates = $updates_mode == 'enable_plugin_auto_updates';
$this->is_disable_translation_updates = $this->getPopulateOption( 'auto_tran_update' );
$this->plugins_update_filters = $this->getPopulateOption( 'plugins_update_filters' );
}
public function warningNotice() {
parent::warningNotice();
$concat = '';
if ( $this->is_disable_updates ) {
$concat .= __( '- To disable updates individually choose the “Manual or automatic plugin updates” option then save settings and comeback to this page.', 'webcraftic-updates-manager' ) . '<br>';
}
if ( ! $this->is_auto_updates ) {
$concat .= __( '- To configure plugin auto updates individually, choose the “Enable auto updates” option then save settings and comeback to this page.', 'webcraftic-updates-manager' );
}
if ( ! empty( $concat ) ) {
$this->printWarningNotice( $concat );
}
}
/**
* {@inheritDoc}
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*
* @param \Wbcr_Factory480_ScriptList $scripts
* @param \Wbcr_Factory480_StyleList $styles
*/
public function assets( $scripts, $styles ) {
parent::assets( $scripts, $styles );
$this->styles->add( WUPM_PLUGIN_URL . '/admin/assets/css/general.css' );
$this->scripts->add( WUPM_PLUGIN_URL . '/admin/assets/js/ajax-components.js' );
$this->scripts->localize(
'wbcr_upm_ajax',
array(
'nonce' => wp_create_nonce( 'wbcr_upm_change_flag')
)
);
// Add Clearfy styles for HMWP pages
if ( defined( 'WCL_PLUGIN_ACTIVE' ) ) {
$this->styles->add( WCL_PLUGIN_URL . '/admin/assets/css/general.css' );
}
}
public function savePluginsUpdateFilters() {
$this->plugin->updatePopulateOption( 'plugins_update_filters', $this->plugins_update_filters );
}
public function disablePluginUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! $this->is_disable_updates ) {
$plugin_slug = $this->request->get( 'plugin_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $plugin_slug );
if ( ! empty( $plugin_slug ) ) {
if ( isset( $this->plugins_update_filters['disable_updates'] ) ) {
if ( ! isset( $this->plugins_update_filters['disable_updates'][ $plugin_slug ] ) ) {
$this->plugins_update_filters['disable_updates'][ $plugin_slug ] = true;
}
} else {
$this->plugins_update_filters['disable_updates'] = [];
$this->plugins_update_filters['disable_updates'][ $plugin_slug ] = true;
}
$this->savePluginsUpdateFilters();
}
}
$this->redirectToAction( 'index' );
}
public function enablePluginUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! $this->is_disable_updates ) {
$plugin_slug = $this->request->get( 'plugin_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $plugin_slug );
if ( ! empty( $plugin_slug ) ) {
if ( isset( $this->plugins_update_filters['disable_updates'] ) && isset( $this->plugins_update_filters['disable_updates'][ $plugin_slug ] ) ) {
unset( $this->plugins_update_filters['disable_updates'][ $plugin_slug ] );
$this->savePluginsUpdateFilters();
}
}
}
$this->redirectToAction( 'index' );
}
public function disablePluginAutoupdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( $this->is_auto_updates ) {
$plugin_slug = $this->request->get( 'plugin_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $plugin_slug );
if ( ! empty( $plugin_slug ) ) {
if ( isset( $this->plugins_update_filters['disable_auto_updates'] ) ) {
if ( ! isset( $this->plugins_update_filters['disable_auto_updates'][ $plugin_slug ] ) ) {
$this->plugins_update_filters['disable_auto_updates'][ $plugin_slug ] = true;
}
} else {
$this->plugins_update_filters['disable_auto_updates'] = [];
$this->plugins_update_filters['disable_auto_updates'][ $plugin_slug ] = true;
}
$this->savePluginsUpdateFilters();
}
}
$this->redirectToAction( 'index' );
}
public function enablePluginAutoupdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( $this->is_auto_updates ) {
$plugin_slug = $this->request->get( 'plugin_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $plugin_slug );
if ( ! empty( $plugin_slug ) ) {
if ( isset( $this->plugins_update_filters['disable_auto_updates'] ) && isset( $this->plugins_update_filters['disable_auto_updates'][ $plugin_slug ] ) ) {
unset( $this->plugins_update_filters['disable_auto_updates'][ $plugin_slug ] );
$this->savePluginsUpdateFilters();
}
}
}
$this->redirectToAction( 'index' );
}
public function enablePluginTranslationUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! $this->is_disable_translation_updates ) {
$plugin_slug = $this->request->get( 'plugin_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $plugin_slug );
if ( ! empty( $plugin_slug ) ) {
if ( isset( $this->plugins_update_filters['disable_translation_updates'] ) && isset( $this->plugins_update_filters['disable_translation_updates'][ $plugin_slug ] ) ) {
unset( $this->plugins_update_filters['disable_translation_updates'][ $plugin_slug ] );
$this->savePluginsUpdateFilters();
}
}
}
$this->redirectToAction( 'index' );
}
public function disablePluginTranslationUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! $this->is_disable_translation_updates ) {
$plugin_slug = $this->request->get( 'plugin_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $plugin_slug );
if ( ! empty( $plugin_slug ) ) {
if ( ! isset( $this->plugins_update_filters['disable_translation_updates'] ) ) {
$this->plugins_update_filters['disable_translation_updates'] = [];
}
$this->plugins_update_filters['disable_translation_updates'][ $plugin_slug ] = true;
$this->savePluginsUpdateFilters();
}
}
$this->redirectToAction( 'index' );
}
public function showPageContent() {
if ( isset( $_POST['wbcr_upm_apply'] ) ) {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$bulk_action = $this->request->post( 'wbcr_upm_bulk_actions', null, true );
$plugin_slugs = $this->request->post( 'plugin_slugs', [], true );
$plugin_slugs = array_map( 'strip_tags', $plugin_slugs );
check_admin_referer( $this->getResultId() . '_form' );
// validate $bulk_action
if ( ! empty( $bulk_action ) and ! in_array( $bulk_action, [
'disable_updates',
'enable_updates',
'enable_auto_updates',
'disable_auto_updates',
'disable_translation_updates',
'enable_translation_updates',
'disable_display',
'enable_display'
] ) ) {
$bulk_action = null;
}
if ( ! $this->is_disable_updates ) {
if ( ! empty( $bulk_action ) && ! empty( $plugin_slugs ) && is_array( $plugin_slugs ) ) {
foreach ( (array) $plugin_slugs as $slug ) {
if ( $bulk_action == 'enable_updates' && isset( $this->plugins_update_filters['disable_updates'] ) && isset( $this->plugins_update_filters['disable_updates'][ $slug ] ) ) {
unset( $this->plugins_update_filters['disable_updates'][ $slug ] );
}
if ( $bulk_action == 'enable_auto_updates' ) {
if ( $this->is_auto_updates ) {
if ( isset( $this->plugins_update_filters['disable_auto_updates'] ) && isset( $this->plugins_update_filters['disable_auto_updates'][ $slug ] ) ) {
unset( $this->plugins_update_filters['disable_auto_updates'][ $slug ] );
}
}
} else {
if ( $bulk_action == 'disable_auto_updates' && ! $this->is_auto_updates ) {
continue;
}
$this->plugins_update_filters[ $bulk_action ][ $slug ] = true;
}
if ( $bulk_action == 'disable_translation_updates' ) {
if ( ! $this->is_disable_translation_updates ) {
$this->plugins_update_filters['disable_translation_updates'][ $slug ] = true;
}
}
if ( $bulk_action == 'enable_translation_updates' && array_key_exists( $slug, $this->plugins_update_filters['disable_translation_updates'] ) ) {
if ( ! $this->is_disable_translation_updates ) {
unset( $this->plugins_update_filters['disable_translation_updates'][ $slug ] );
}
}
}
}
}
if ( ! empty( $bulk_action ) && ! empty( $plugin_slugs ) && is_array( $plugin_slugs ) ) {
foreach ( (array) $plugin_slugs as $slug ) {
if ( $bulk_action == 'disable_display' ) {
if ( ! isset( $this->plugins_update_filters['disable_display'] ) ) {
$this->plugins_update_filters['disable_display'] = [];
}
$this->plugins_update_filters['disable_display'][ $slug ] = true;
}
if ( $bulk_action == 'enable_display' && isset( $this->plugins_update_filters['disable_display'] ) && isset( $this->plugins_update_filters['disable_display'][ $slug ] ) ) {
unset( $this->plugins_update_filters['disable_display'][ $slug ] );
}
}
}
$this->savePluginsUpdateFilters();
}
$is_premium = defined( 'WUPMP_PLUGIN_ACTIVE' );
?>
<div class="wbcr-factory-page-group-header">
<strong><?php _e( 'Plugins list', 'webcraftic-updates-manager' ) ?></strong>
<p>
<?php _e( 'This page you can individually disable plugin updates and auto updates.', 'webcraftic-updates-manager' ) ?>
</p>
</div>
<style>
#the-list tr.inactive .check-column {
border-left: 3px solid #D54E21;
}
#the-list tr.inactive {
background: #FEF7F1;
}
</style>
<form method="post" style="padding: 20px;">
<?php wp_nonce_field( $this->getResultId() . '_form' ) ?>
<p>
<select name="wbcr_upm_bulk_actions" id="wbcr_upm_bulk_actions">
<option value="0"><?php _e( 'Bulk actions', 'webcraftic-updates-manager' ); ?></option>
<option value="disable_updates"><?php _e( 'Disable updates', 'webcraftic-updates-manager' ); ?></option>
<option value="enable_updates"><?php _e( 'Enable updates', 'webcraftic-updates-manager' ); ?></option>
<option value="enable_auto_updates"><?php _e( 'Enable auto-updates', 'webcraftic-updates-manager' ); ?></option>
<option value="disable_auto_updates"><?php _e( 'Disable auto-updates', 'webcraftic-updates-manager' ); ?></option>
<option value="disable_translation_updates"<?= ( ! $is_premium ? ' disabled' : '' ) ?>><?php _e( 'Disable translation updates', 'webcraftic-updates-manager' ); ?></option>
<option value="enable_translation_updates"<?= ( ! $is_premium ? ' disabled' : '' ) ?>><?php _e( 'Enable translation updates', 'webcraftic-updates-manager' ); ?></option>
<option value="disable_display"<?= ( ! $is_premium ? ' disabled' : '' ) ?>><?php _e( 'Hide plugin', 'webcraftic-updates-manager' ); ?></option>
<option value="enable_display"<?= ( ! $is_premium ? ' disabled' : '' ) ?>><?php _e( 'Show plugin', 'webcraftic-updates-manager' ); ?></option>
</select>
<input type="submit" name="wbcr_upm_apply" id="wbcr_upm_apply" class='button button-alt' value='<?php _e( "Apply", "webcraftic-updates-manager" ); ?>'>
</p>
<table class="wp-list-table widefat autoupdate striped plugins wp-list-table__plugins">
<thead>
<tr>
<th id='cb' class='manage-column column-cb check-column'>
<input class="wbcr_um_select_all" type="checkbox">
</th>
<th id='name' class='manage-column column-name column-primary'>
<strong><?php _e( 'Plugin', 'webcraftic-updates-manager' ); ?></strong></th>
<th id="disable_updates">
<strong><?php _e( 'Disable updates', 'webcraftic-updates-manager' ); ?></strong>
</th>
<th id="disable_auto_updates">
<strong><?php _e( 'Auto-updates', 'webcraftic-updates-manager' ); ?></strong>
</th>
<th id="disable_translation_updates"<?= ( ! $is_premium ? ' class="wbcr-upm-column-pro"' : '' ) ?>>
<strong><?php _e( 'Translation updates', 'webcraftic-updates-manager' ); ?></strong>
</th>
<th id="hide_item"<?= ( ! $is_premium ? ' class="wbcr-upm-column-pro"' : '' ) ?>>
<strong><?php _e( 'Hide plugin', 'webcraftic-updates-manager' ); ?></strong>
</th>
</tr>
</thead>
<tbody id="the-list">
<?php
$prefix = $this->plugin->getPrefix();
foreach ( get_plugins() as $key => $value ):
$slug = $key;
$slug_parts = explode( '/', $slug );
$actual_slug = array_shift( $slug_parts );
$slug_hash = md5( $slug );
$description = $name = 'Empty';
foreach ( (array) $value as $k => $v ) {
if ( $k == "Name" ) {
$name = $v;
}
if ( $k == "Description" ) {
$description = $v;
}
}
$class = 'active';
$is_disable_updates = false;
$is_auto_updates = true;
$is_disable_translation_update = false;
$is_disable_display = false;
if ( ! empty( $this->plugins_update_filters ) ) {
if ( isset( $this->plugins_update_filters['disable_auto_updates'] ) && isset( $this->plugins_update_filters['disable_auto_updates'][ $actual_slug ] ) ) {
$is_auto_updates = false;
}
if ( ( isset( $this->plugins_update_filters['disable_updates'] ) && isset( $this->plugins_update_filters['disable_updates'][ $actual_slug ] ) ) ) {
$is_disable_updates = true;
}
}
if ( $this->is_disable_updates ) {
$is_disable_updates = true;
}
if ( ! empty( $this->plugins_update_filters ) ) {
if ( isset( $this->plugins_update_filters['disable_translation_updates'] ) && isset( $this->plugins_update_filters['disable_translation_updates'][ $actual_slug ] ) ) {
$is_disable_translation_update = true;
}
}
if ( isset( $this->plugins_update_filters['disable_display'] ) && isset( $this->plugins_update_filters['disable_display'][ $actual_slug ] ) ) {
$is_disable_display = true;
}
if ( $is_disable_display or $is_disable_updates ) {
$class = 'inactive';
}
if ( $this->is_disable_updates ) {
$class = 'inactive row-global-disabled';
}
?>
<tr id="post-<?= esc_attr( $slug_hash ) ?>" class="<?= $class ?>">
<td scope="row" class="check-column">
<label class="screen-reader-text" for="cb-select-<?= esc_attr( $slug_hash ) ?>"><?php _e( 'Select', 'webcraftic-updates-manager' ) ?><?= esc_html( $name ) ?></label>
<input id="cb-select-<?= esc_attr( $slug_hash ) ?>" type="checkbox" name="plugin_slugs[]" value="<?= esc_attr( $actual_slug ) ?>">
<label></label>
<div class="locked-indicator"></div>
</td>
<td class="plugin-title column-primary">
<strong class="plugin-name">
<?= esc_html( $name ) ?>
</strong>
</td>
<!-- отключить все обновления -->
<td class="column-flags">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-all-' . $slug_hash; ?>">
<?php
$disabled = $this->is_disable_updates;
if ( $is_disable_display ) {
$disabled = true;
}
$checked = false;
if ( $is_disable_updates ) {
$checked = true;
}
if ( in_array( $key, WUPM_PluginFilters::getPersistentPlugins() ) ) {
// deny disable update for update manager
$disabled = true;
}
?>
<button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ( $checked ? 'active' : '' ); ?>" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'On', 'webcraftic-updates-manager' ); ?></button>
<button type="button" class="btn btn-default btn-small btn-sm factory-off <?= ( ! $checked ? 'active' : '' ); ?>" data-value="0" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'Off', 'webcraftic-updates-manager' ); ?></button>
<input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_updates" class="factory-result factory-ajax-checkbox"
data-disable-group="<?= 'group-' . $slug_hash; ?>" data-action="Updates" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int) $checked ?>" <?= ( $checked ? 'checked' : '' ); ?> <?= ( $disabled ? 'disabled' : '' ); ?>>
</div>
</td>
<!-- отключить авто-обновления -->
<td class="column-flags">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= 'group-all-' . $slug_hash; ?> <?= ( ! $this->is_auto_updates ) ? 'global-disabled' : ''; ?> ">
<?php
$disabled = false;
if ( ! $this->is_auto_updates or $is_disable_updates or $is_disable_display ) {
$disabled = true;
}
$checked = $is_auto_updates;
?>
<button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ( $checked ? 'active' : '' ); ?>" <?= ( $disabled ) ? 'disabled' : ''; ?>><?php _e( 'On', 'webcraftic-updates-manager' ); ?></button>
<button type="button" class="btn btn-default btn-small btn-sm factory-off <?= ( ! $checked ? 'active' : '' ); ?>" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'Off', 'webcraftic-updates-manager' ); ?></button>
<input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_auto_updates" class="factory-result factory-ajax-checkbox"
data-action="AutoUpdates" data-inverse="1" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int) $checked ?>" <?= ( $checked ? 'checked' : '' ); ?> <?= ( $disabled ? 'disabled' : '' ); ?>>
</div>
</td>
<!-- отключить обновления переводов -->
<td class="column-flags <?= ( ! $is_premium ) ? "wbcr-upm-column-premium" : ""; ?>">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= 'group-all-' . $slug_hash; ?> <?= ( ! $is_premium or $this->is_disable_translation_updates ? 'global-disabled' : '' ); ?>">
<?php
$disabled = false;
if ( ! $is_premium or $is_disable_updates or $this->is_disable_translation_updates or $is_disable_display ) {
$disabled = true;
}
$checked = ! $is_disable_translation_update;
?>
<button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ( $checked ) ? 'active' : ''; ?>" <?= ( $disabled ) ? 'disabled' : ''; ?>><?php _e( 'On', 'webcraftic-updates-manager' ); ?></button>
<button type="button" class="btn btn-default btn-small btn-sm factory-off <?= ( ! $checked ) ? 'active' : ''; ?>" data-value="0" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'Off', 'webcraftic-updates-manager' ); ?></button>
<input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_translation_updates" class="factory-result factory-ajax-checkbox"
data-action="TranslationUpdates" data-inverse="1" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int) $checked ?>" <?= ( $checked ? 'checked' : '' ); ?> <?= ( $disabled ? 'disabled' : '' ); ?>>
</div>
</td>
<!-- скрыть плагин -->
<td class="column-flags <?= ( ! $is_premium ? "wbcr-upm-column-premium" : "" ); ?>">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= ( ! $is_premium ? 'global-disabled' : '' ); ?>">
<?php
$checked = $is_disable_display;
$disabled = false;
if ( ! $is_premium ) {
$disabled = true;
}
?>
<button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ( $checked ? 'active' : '' ); ?>" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'On', 'webcraftic-updates-manager' ); ?></button>
<button type="button" class="btn btn-default btn-small btn-sm factory-off <?= ( ! $checked ? 'active' : '' ); ?>" data-value="0" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'Off', 'webcraftic-updates-manager' ); ?></button>
<input type="checkbox" style="display: none" id="wbcr_updates_manager_hide_item" class="factory-result factory-ajax-checkbox"
data-disable-group="<?= 'group-all-' . $slug_hash; ?>" data-action="Display" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int) $checked ?>" <?= ( $checked ? 'checked' : '' ); ?> <?= ( $disabled ? 'disabled' : '' ); ?>>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</form>
<?php
}
}

View File

@@ -0,0 +1,508 @@
<?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
*/
class WUPM_ThemesPage extends WBCR\Factory_Templates_134\Pages\PageBase {
/**
* {@inheritDoc}
*
* @var string
*/
public $id = "themes";
/**
* {@inheritDoc}
*
* @var string
*/
public $type = "page";
/**
* {@inheritDoc}
*
* @var string
*/
public $page_parent_page = 'updates';
/**
* {@inheritDoc}
*
* @var string
*/
public $page_menu_dashicon = 'dashicons-cloud';
/**
* {@inheritDoc}
*
* @var bool
*/
public $available_for_multisite = true;
/**
* {@inheritDoc}
*
* @since 1.1.0
* @var bool
*/
public $show_right_sidebar_in_options = true;
/**
* {@inheritDoc}
*
* @var
*/
private $is_disable_updates;
/**
* {@inheritDoc}
*
* @var
*/
private $is_auto_updates;
/**
* @var mixed|void
*/
private $is_disable_translation_updates;
/**
* @var array
*/
private $themes_update_filters = [];
/**
* @param Wbcr_Factory480_Plugin $plugin
*/
public function __construct( Wbcr_Factory480_Plugin $plugin ) {
$this->menu_title = __( 'Themes', 'webcraftic-updates-manager' );
parent::__construct( $plugin );
$updates_mode = $this->getPopulateOption( 'theme_updates' );
$this->is_disable_updates = $updates_mode == 'disable_theme_updates';
$this->is_auto_updates = $updates_mode == 'enable_theme_auto_updates';
$this->is_disable_translation_updates = $this->getPopulateOption( 'auto_tran_update' );
$this->themes_update_filters = $this->getPopulateOption( 'themes_update_filters' );
}
public function warningNotice() {
parent::warningNotice();
$concat = '';
if ( $this->is_disable_updates ) {
$concat .= __( '- To disable updates individually choose the “Manual or automatic theme updates” option then save settings and comeback to this page.', 'webcraftic-updates-manager' ) . '<br>';
}
if ( ! $this->is_auto_updates ) {
$concat .= __( '- To configure theme auto updates individually, choose the “Enable auto updates” option then save settings and comeback to this page.', 'webcraftic-updates-manager' );
}
if ( ! empty( $concat ) ) {
$this->printWarningNotice( $concat );
}
}
/**
* Requests assets (js and css) for the page.
*
* @since 1.0.0
* @return void
* @see FactoryPages480_AdminPage
*
*/
public function assets( $scripts, $styles ) {
parent::assets( $scripts, $styles );
$this->styles->add( WUPM_PLUGIN_URL . '/admin/assets/css/general.css' );
$this->scripts->add( WUPM_PLUGIN_URL . '/admin/assets/js/ajax-components.js' );
// Add Clearfy styles for HMWP pages
if ( defined( 'WCL_PLUGIN_ACTIVE' ) ) {
$this->styles->add( WCL_PLUGIN_URL . '/admin/assets/css/general.css' );
}
}
public function saveThemesUpdateFilters() {
$this->plugin->updateOption( 'themes_update_filters', $this->themes_update_filters );
}
public function disableThemeUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! $this->is_disable_updates ) {
$theme_slug = $this->request->get( 'theme_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $theme_slug );
if ( ! empty( $theme_slug ) ) {
if ( isset( $this->themes_update_filters['disable_updates'] ) ) {
if ( ! isset( $this->themes_update_filters['disable_updates'][ $theme_slug ] ) ) {
$this->themes_update_filters['disable_updates'][ $theme_slug ] = true;
}
} else {
$this->themes_update_filters['disable_updates'] = [];
$this->themes_update_filters['disable_updates'][ $theme_slug ] = true;
}
$this->saveThemesUpdateFilters();
}
}
$this->redirectToAction( 'index' );
}
public function enableThemeUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! $this->is_disable_updates ) {
$theme_slug = $this->request->get( 'theme_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $theme_slug );
if ( ! empty( $theme_slug ) ) {
if ( isset( $this->themes_update_filters['disable_updates'] ) && isset( $this->themes_update_filters['disable_updates'][ $theme_slug ] ) ) {
unset( $this->themes_update_filters['disable_updates'][ $theme_slug ] );
$this->saveThemesUpdateFilters();
}
}
}
$this->redirectToAction( 'index' );
}
public function disableThemeAutoupdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( $this->is_auto_updates ) {
$theme_slug = $this->request->get( 'theme_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $theme_slug );
if ( ! empty( $theme_slug ) ) {
if ( isset( $this->themes_update_filters['disable_auto_updates'] ) ) {
if ( ! isset( $this->themes_update_filters['disable_auto_updates'][ $theme_slug ] ) ) {
$this->themes_update_filters['disable_auto_updates'][ $theme_slug ] = true;
}
} else {
$this->themes_update_filters['disable_auto_updates'] = [];
$this->themes_update_filters['disable_auto_updates'][ $theme_slug ] = true;
}
$this->saveThemesUpdateFilters();
}
}
$this->redirectToAction( 'index' );
}
public function enableThemeAutoupdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( $this->is_auto_updates ) {
$theme_slug = $this->request->get( 'theme_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $theme_slug );
if ( ! empty( $theme_slug ) ) {
if ( isset( $this->themes_update_filters['disable_auto_updates'] ) && isset( $this->themes_update_filters['disable_auto_updates'][ $theme_slug ] ) ) {
unset( $this->themes_update_filters['disable_auto_updates'][ $theme_slug ] );
$this->saveThemesUpdateFilters();
}
}
}
$this->redirectToAction( 'index' );
}
public function disableThemeTranslationUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$theme_slug = $this->request->get( 'theme_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $theme_slug );
if ( ! empty( $theme_slug ) ) {
if ( ! isset( $this->themes_update_filters['disable_translation_updates'] ) ) {
$this->themes_update_filters['disable_translation_updates'] = [];
}
$this->themes_update_filters['disable_translation_updates'][ $theme_slug ] = true;
$this->saveThemesUpdateFilters();
}
$this->redirectToAction( 'index' );
}
public function enableThemeTranslationUpdatesAction() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$theme_slug = $this->request->get( 'theme_slug', null, true );
check_admin_referer( $this->getResultId() . '_' . $theme_slug );
if ( ! empty( $theme_slug ) ) {
if ( isset( $this->themes_update_filters['disable_translation_updates'] ) && isset( $this->themes_update_filters['disable_translation_updates'][ $theme_slug ] ) ) {
unset( $this->themes_update_filters['disable_translation_updates'][ $theme_slug ] );
$this->saveThemesUpdateFilters();
}
}
$this->redirectToAction( 'index' );
}
public function showPageContent() {
if ( isset( $_POST['wbcr_upm_apply'] ) ) {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$bulk_action = $this->request->post( 'wbcr_upm_bulk_actions', null, true );
$theme_slugs = $this->request->post( 'theme_slugs', [], true );
$theme_slugs = array_map( 'strip_tags', $theme_slugs );
check_admin_referer( $this->getResultId() . '_form' );
// validate $bulk_action
if ( ! empty( $bulk_action ) and ! in_array( $bulk_action, [
'disable_updates',
'enable_updates',
'enable_auto_updates',
'disable_auto_updates',
'disable_translation_updates',
'enable_translation_updates',
] ) ) {
$bulk_action = null;
}
if ( ! $this->is_disable_updates ) {
if ( ! empty( $bulk_action ) && ! empty( $theme_slugs ) && is_array( $theme_slugs ) ) {
foreach ( (array) $theme_slugs as $slug ) {
if ( $bulk_action == 'enable_updates' && isset( $this->themes_update_filters['disable_updates'] ) && isset( $this->themes_update_filters['disable_updates'][ $slug ] ) ) {
unset( $this->themes_update_filters['disable_updates'][ $slug ] );
}
if ( $bulk_action == 'enable_auto_updates' ) {
if ( $this->is_auto_updates ) {
if ( isset( $this->themes_update_filters['disable_auto_updates'] ) && isset( $this->themes_update_filters['disable_auto_updates'][ $slug ] ) ) {
unset( $this->themes_update_filters['disable_auto_updates'][ $slug ] );
}
}
} else {
if ( $bulk_action == 'disable_auto_updates' && ! $this->is_auto_updates ) {
continue;
}
$this->themes_update_filters[ $bulk_action ][ $slug ] = true;
}
if ( $bulk_action == 'disable_translation_updates' ) {
if ( ! $this->is_disable_translation_updates ) {
$this->themes_update_filters['disable_translation_updates'][ $slug ] = true;
}
}
if ( $bulk_action == 'enable_translation_updates' && array_key_exists( $slug, $this->themes_update_filters['disable_translation_updates'] ) ) {
if ( ! $this->is_disable_translation_updates ) {
unset( $this->themes_update_filters['disable_translation_updates'][ $slug ] );
}
}
}
$this->saveThemesUpdateFilters();
}
}
}
$is_premium = defined( 'WUPMP_PLUGIN_ACTIVE' );
?>
<div class="wbcr-factory-page-group-header">
<strong<?= ( ! $is_premium ? ' class="wbcr-upm-group-header-pro"' : '' ); ?>><?php _e( 'Themes list', 'webcraftic-updates-manager' ) ?></strong>
<p>
<?php _e( 'This page you can individually disable theme updates and auto updates.', 'webcraftic-updates-manager' ) ?>
</p>
</div>
<style>
#the-list tr.inactive .check-column {
border-left: 3px solid #D54E21;
}
#the-list tr.inactive {
background: #FEF7F1;
}
</style>
<form method="post" style="padding: 20px;">
<?php wp_nonce_field( $this->getResultId() . '_form' ) ?>
<p>
<select name="wbcr_upm_bulk_actions" id="wbcr_upm_bulk_actions" <?= ( ! $is_premium ? 'disabled' : '' ); ?>>
<option value="0"><?php _e( 'Bulk actions', 'webcraftic-updates-manager' ); ?></option>
<option value="disable_updates"><?php _e( 'Disable updates', 'webcraftic-updates-manager' ); ?></option>
<option value="enable_updates"><?php _e( 'Enable updates', 'webcraftic-updates-manager' ); ?></option>
<option value="enable_auto_updates"><?php _e( 'Enable auto-updates', 'webcraftic-updates-manager' ); ?></option>
<option value="disable_auto_updates"><?php _e( 'Disable auto-updates', 'webcraftic-updates-manager' ); ?></option>
<option value="disable_translation_updates"><?php _e( 'Disable translation updates', 'webcraftic-updates-manager' ); ?></option>
<option value="enable_translation_updates"><?php _e( 'Enable translation updates', 'webcraftic-updates-manager' ); ?></option>
</select>
<input type="submit" name="wbcr_upm_apply" id="wbcr_upm_apply" class='button button-alt' value='<?php _e( "Apply", "webcraftic-updates-manager" ); ?>' <?= ( ! $is_premium ) ? 'disabled' : ''; ?>>
</p>
<table class="wp-list-table wbcr-upm-list-table-pro widefat autoupdate striped plugins <?= ( ! $is_premium ? "wbcr-upm-column-premium" : "" ); ?>">
<thead>
<tr>
<th id='cb' class='manage-column column-cb check-column'>
<input class="wbcr_um_select_all" type="checkbox">
</th>
<th id='name' class='manage-column column-name column-primary'>
<strong><?php _e( 'Theme', 'webcraftic-updates-manager' ); ?></strong></th>
<th id="disable_updates">
<strong><?php _e( 'Disable updates', 'webcraftic-updates-manager' ); ?></strong>
</th>
<th id="disable_auto_updates">
<strong><?php _e( 'Auto-updates', 'webcraftic-updates-manager' ); ?></strong>
</th>
<th id="disable_translation_updates">
<strong><?php _e( 'Translation updates', 'webcraftic-updates-manager' ); ?></strong>
</th>
</tr>
</thead>
<tbody id="the-list">
<?php
$prefix = $this->plugin->getPrefix();
foreach ( wp_get_themes() as $key => $value ):
$actual_slug = $key;
$slug_hash = md5( $actual_slug );
$description = $name = 'Empty';
if ( $value->Name ) {
$name = $value->Name;
}
if ( $value->Description ) {
$description = $value->Description;
}
$class = 'active';
$is_disable_updates = false;
$is_auto_updates = true;
$is_disable_translation_update = false;
if ( ! empty( $this->themes_update_filters ) ) {
if ( isset( $this->themes_update_filters['disable_auto_updates'] ) && isset( $this->themes_update_filters['disable_auto_updates'][ $actual_slug ] ) ) {
$is_auto_updates = false;
}
if ( ( isset( $this->themes_update_filters['disable_updates'] ) && isset( $this->themes_update_filters['disable_updates'][ $actual_slug ] ) ) ) {
$class = 'inactive';
$is_disable_updates = true;
}
}
if ( $this->is_disable_updates ) {
$class = 'inactive row-global-disabled';
$is_disable_updates = true;
}
if ( ! empty( $this->themes_update_filters ) ) {
if ( isset( $this->themes_update_filters['disable_translation_updates'] ) && isset( $this->themes_update_filters['disable_translation_updates'][ $actual_slug ] ) ) {
$is_disable_translation_update = true;
}
}
?>
<tr id="post-<?= esc_attr( $slug_hash ) ?>" class="<?= $class ?>">
<td scope="row" class="check-column">
<label class="screen-reader-text" for="cb-select-<?= esc_attr( $slug_hash ) ?>"><?php _e( 'Select', 'webcraftic-updates-manager' ) ?><?= esc_html( $name ) ?></label>
<input id="cb-select-<?= esc_attr( $slug_hash ) ?>" class="wbcr_um_select_item" type="checkbox" name="theme_slugs[]" value="<?= esc_attr( $actual_slug ) ?>" <?= ( ! $is_premium ? 'disabled' : '' ); ?>>
<label></label>
<div class="locked-indicator"></div>
</td>
<td class="plugin-title column-primary">
<strong class="plugin-name">
<?= esc_html( $name ) ?>
</strong>
</td>
<!-- отключить все обновления -->
<td class="column-flags">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group">
<?php
$disabled = $this->is_disable_updates;
$checked = false;
if ( $is_disable_updates ) {
$checked = true;
}
if ( ! $is_premium ) {
$disabled = true;
}
?>
<button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ( $checked ? 'active' : '' ); ?>" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'On', 'webcraftic-updates-manager' ); ?></button>
<button type="button" class="btn btn-default btn-small btn-sm factory-off <?= ( ! $checked ) ? 'active' : ''; ?>" data-value="0" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'Off', 'webcraftic-updates-manager' ); ?></button>
<input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_updates" class="factory-result factory-ajax-checkbox"
data-disable-group="<?= 'group-' . $slug_hash; ?>" data-action="Updates" data-theme-slug="<?= $actual_slug ?>" value="<?= (int) $checked ?>" <?= ( $checked ? 'checked' : '' ); ?> <?= ( $disabled ? 'disabled' : '' ); ?>>
</div>
</td>
<!-- отключить авто-обновления -->
<td class="column-flags">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= ( ! $is_premium or ! $this->is_auto_updates ) ? 'global-disabled' : ''; ?>">
<?php
$disabled = false;
if ( ! $is_premium or ! $this->is_auto_updates or $is_disable_updates ) {
$disabled = true;
}
$checked = false;
if ( $is_auto_updates ) {
$checked = true;
}
?>
<button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ( $checked ? 'active' : '' ); ?>" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'On', 'webcraftic-updates-manager' ); ?></button>
<button type="button" class="btn btn-default btn-small btn-sm factory-off <?= ( ! $checked ) ? 'active' : ''; ?>" data-value="0" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'Off', 'webcraftic-updates-manager' ); ?></button>
<input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_auto_updates" class="factory-result factory-ajax-checkbox"
data-action="AutoUpdates" data-inverse="1" data-theme-slug="<?= $actual_slug ?>" value="<?= (int) $checked ?>" <?= ( $checked ? 'checked' : '' ); ?> <?= ( $disabled ? 'disabled' : '' ); ?>>
</div>
</td>
<!-- отключить обновления переводов -->
<td class="column-flags">
<div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= ( ! $is_premium or $this->is_disable_translation_updates ) ? 'global-disabled' : ''; ?>">
<?php
$disabled = false;
if ( ! $is_premium or $is_disable_updates or $this->is_disable_translation_updates ) {
$disabled = true;
}
$checked = false;
if ( ! $is_disable_translation_update ) {
$checked = true;
}
?>
<button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ( $checked ? 'active' : '' ); ?>" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'On', 'webcraftic-updates-manager' ); ?></button>
<button type="button" class="btn btn-default btn-small btn-sm factory-off <?= ( ! $checked ) ? 'active' : ''; ?>" data-value="0" <?= ( $disabled ? 'disabled' : '' ); ?>><?php _e( 'Off', 'webcraftic-updates-manager' ); ?></button>
<input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_translation_updates" class="factory-result factory-ajax-checkbox"
data-action="TranslationUpdates" data-inverse="1" data-theme-slug="<?= $actual_slug ?>" value="<?= (int) $checked ?>" <?= ( $checked ? 'checked' : '' ); ?> <?= ( $disabled ? 'disabled' : '' ); ?>>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</form>
<?php
}
}

View File

@@ -0,0 +1,285 @@
<?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
*/
class WUPM_UpdatesPage extends WBCR\Factory_Templates_134\Pages\PageBase {
/**
* {@inheritDoc}
*
* @var string
*/
public $id = "updates";
/**
* {@inheritDoc}
*
* @var string
*/
public $page_menu_dashicon = 'dashicons-cloud';
/**
* {@inheritDoc}
*
* @var bool
*/
public $available_for_multisite = true;
/**
* {@inheritDoc}
*
* @since 1.1.0
* @var bool
*/
public $show_right_sidebar_in_options = true;
/**
* WUPM_UpdatesPage constructor.
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
*
* @param \Wbcr_Factory480_Plugin $plugin
*/
public function __construct( Wbcr_Factory480_Plugin $plugin ) {
$this->menu_title = __( 'Updates manager', 'webcraftic-updates-manager' );
$this->page_menu_short_description = __( 'Manage all site updates', 'webcraftic-updates-manager' );
if ( ! defined( 'LOADING_UPDATES_MANAGER_AS_ADDON' ) ) {
$this->internal = false;
$this->menu_target = 'options-general.php';
$this->add_link_to_plugin_actions = true;
$this->show_search_options_form = false;
}
parent::__construct( $plugin );
}
/*public function getMenuTitle() {
return defined( 'LOADING_UPDATES_MANAGER_AS_ADDON' ) ? __( 'Updates', 'webcraftic-updates-manager' ) : __( 'Updates manager', 'webcraftic-updates-manager' );
}*/
/**
* {@inheritDoc}
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com>
* @return string|void
*/
public function getPageTitle() {
return defined( 'LOADING_UPDATES_MANAGER_AS_ADDON' ) ? __( 'Updates', 'webcraftic-updates-manager' ) : __( 'General', 'webcraftic-updates-manager' );
}
/**
* {@inheritDoc}
*
* @author Alexander Kovalev <alex.kovalevv@gmail.com> *
*
* @param \Wbcr_Factory480_ScriptList $scripts
* @param \Wbcr_Factory480_StyleList $styles
*/
public function assets( $scripts, $styles ) {
parent::assets( $scripts, $styles );
$this->styles->add( WUPM_PLUGIN_URL . '/admin/assets/css/general.css' );
// Add Clearfy styles for HMWP pages
if ( defined( 'WCL_PLUGIN_ACTIVE' ) ) {
$this->styles->add( WCL_PLUGIN_URL . '/admin/assets/css/general.css' );
}
}
/**
* Permalinks options.
*
* @since 1.0.0
* @return mixed[]
*/
public function getPageOptions() {
$is_premium = defined( 'WUPMP_PLUGIN_ACTIVE' );
$options = [];
$options[] = [
'type' => 'html',
'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __( 'General settings for WordPress, plugins and themes updates', 'webcraftic-updates-manager' ) . '</strong><p>' . __( 'This page, you can enable or disable automatic updates. To test the automatic updates, click the "Advanced" tab.', 'webcraftic-updates-manager' ) . '</p></div>'
];
$options[] = [
'type' => 'dropdown',
'name' => 'plugin_updates',
'way' => 'buttons',
'title' => __( 'Plugin Updates', 'webcraftic-updates-manager' ),
'data' => [
[ 'enable_plugin_monual_updates', __( 'Manual updates', 'webcraftic-updates-manager' ) ],
[ 'enable_plugin_auto_updates', __( 'Enable auto updates', 'webcraftic-updates-manager' ) ],
[ 'disable_plugin_updates', __( 'Disable updates', 'webcraftic-updates-manager' ) ]
],
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'hint' => __( 'You can disable all plugin updates or choose manual or automatic update mode.', 'webcraftic-updates-manager' ),
'default' => 'enable_plugin_monual_updates'
];
$options[] = [
'type' => 'dropdown',
'name' => 'theme_updates',
'way' => 'buttons',
'title' => __( 'Theme Updates', 'webcraftic-updates-manager' ),
'data' => [
[ 'enable_theme_monual_updates', __( 'Manual updates', 'webcraftic-updates-manager' ) ],
[ 'enable_theme_auto_updates', __( 'Enable auto updates', 'webcraftic-updates-manager' ) ],
[ 'disable_theme_updates', __( 'Disable updates', 'webcraftic-updates-manager' ) ]
],
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'hint' => __( 'You can disable all themes updates or choose manual or automatic update mode.', 'webcraftic-updates-manager' ),
'default' => 'enable_theme_monual_updates'
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'auto_tran_update',
'title' => __( 'Disable Automatic Translation Updates', 'webcraftic-updates-manager' ),
//'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
//'hint' => __('', 'webcraftic-updates-manager') . '<br><br><b>Clearfy: </b>' . __('', 'webcraftic-updates-manager'),
'default' => false,
];
$options[] = [
'type' => 'dropdown',
'name' => 'wp_update_core',
'title' => __( 'WordPress Core Updates', 'webcraftic-updates-manager' ),
'data' => [
[ 'disable_core_updates', __( 'Disable updates', 'webcraftic-updates-manager' ) ],
[ 'disable_core_auto_updates', __( 'Disable auto updates', 'webcraftic-updates-manager' ) ],
[
'allow_minor_core_auto_updates',
__( 'Allow minor auto updates', 'webcraftic-updates-manager' )
],
[
'allow_major_core_auto_updates',
__( 'Allow major auto updates', 'webcraftic-updates-manager' )
],
[
'allow_dev_core_auto_updates',
__( 'Allow development auto updates', 'webcraftic-updates-manager' )
]
],
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'hint' => __( 'You can disable all core WordPress updates, or disable only automatic updates. Also you can select the update mode. By default (minor)', 'webcraftic-updates-manager' ) . '<br>-' . __( 'Major - automatically update to major releases (e.g., 4.1, 4.2, 4.3).', 'webcraftic-updates-manager' ) . '<br>-' . __( 'Minor - automatically update to minor releases (e.g., 4.1.1, 4.1.2, 4.1.3)..', 'webcraftic-updates-manager' ) . '<br>-' . __( 'Development - update automatically to Bleeding Edge releases.', 'webcraftic-updates-manager' ),
'default' => 'allow_minor_core_auto_updates',
'events' => [
'disable_core_updates' => [
'hide' => '.factory-control-disable_core_notifications'
],
'disable_core_auto_updates' => [
'show' => '.factory-control-disable_core_notifications'
],
'allow_minor_core_auto_updates' => [
'show' => '.factory-control-disable_core_notifications'
],
'allow_major_core_auto_updates' => [
'show' => '.factory-control-disable_core_notifications'
],
'allow_dev_core_auto_updates' => [
'show' => '.factory-control-disable_core_notifications'
],
]
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'enable_update_vcs',
'title' => __( 'Enable updates for VCS Installations', 'webcraftic-updates-manager' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'hint' => __( 'Enable Automatic Updates even if a VCS folder (.git, .hg, .svn) was found in the WordPress directory', 'webcraftic-updates-manager' ),
'default' => false,
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'updates_nags_only_for_admin',
'title' => __( 'Updates nags only for Admin', 'webcraftic-updates-manager' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'green' ],
'hint' => __( 'This plugin allows you to hide the update WordPress reminder from all users that are not assumed Administrators (cannot upgrade plugins).
If you have multiple users then this means those who are not admins dont need to see the message. Useful for CMS based sites, so the client doesnt see the notice.', 'webcraftic-updates-manager' ),
'default' => false,
];
$options[] = [
'type' => 'html',
'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __( 'Email Notifications', 'webcraftic-updates-manager' ) . '</strong><p>' . __( 'Email notifications are send once a day, you can choose what notifications to send below.', 'webcraftic-updates-manager' ) . '</p></div>'
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'notify_update_available',
'title' => __( 'Update available', 'webcraftic-updates-manager' ),
'hint' => __( 'Send me emails when an update is available.', 'webcraftic-updates-manager' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'default' => false,
'cssClass' => ( ! $is_premium ) ? [ 'factory-checkbox-disabled wbcr-upm-icon-pro' ] : [],
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'notify_updated',
'title' => __( 'Successful update', 'webcraftic-updates-manager' ),
'hint' => __( 'Send me emails when something has been updated.', 'webcraftic-updates-manager' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'default' => false,
'cssClass' => ( ! $is_premium ) ? [ 'factory-checkbox-disabled wbcr-upm-icon-pro' ] : [],
];
$options[] = [
'type' => 'textbox',
'way' => 'buttons',
'name' => 'notify_email',
'title' => __( 'Email address', 'webcraftic-updates-manager' ),
'hint' => __( 'Seperate email addresses using commas.', 'webcraftic-updates-manager' ),
'default' => $this->plugin->isNetworkActive() ? get_site_option( 'admin_email' ) : get_option( 'admin_email' ),
'htmlAttrs' => ( ! $is_premium ) ? [ 'disabled' => 'disabled' ] : [],
];
$options[] = [
'type' => 'html',
'html' => '<div class="wbcr-factory-page-group-header factory-control-disable_core_notifications"><strong>' . __( 'Core notifications', 'webcraftic-updates-manager' ) . '</strong><p>' . __( 'Core notifications are handled by WordPress and not by this plugin. You can only disable them, changing your email address in the settings above will not affect these notifications.', 'webcraftic-updates-manager' ) . '</p></div>'
];
$options[] = [
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'disable_core_notifications',
'title' => __( 'Core notifications', 'webcraftic-updates-manager' ),
'hint' => __( 'By default wordpress sends an email when a core update happend. Uncheck this box to disable these emails.', 'webcraftic-updates-manager' ),
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
'default' => true,
'cssClass' => ( ! $is_premium ) ? [ 'factory-checkbox-disabled wbcr-upm-icon-pro' ] : [],
];
$formOptions = [];
$formOptions[] = [
'type' => 'form-group',
'items' => $options,
//'cssClass' => 'postbox'
];
return apply_filters( 'wbcr/upm/updates_form_options', $formOptions );
}
}

View File

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