| 1 |
<?php |
| 2 |
/** |
| 3 |
* Centralized manager for WordPress backend functionality. |
| 4 |
* |
| 5 |
* @package MainWP\Dashboard |
| 6 |
* @version 4.5.1 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace MainWP\Dashboard\Module\Log; |
| 10 |
|
| 11 |
use MainWP\Dashboard\MainWP_Utility; |
| 12 |
use MainWP\Dashboard\MainWP_Settings; |
| 13 |
use MainWP\Dashboard\MainWP_Settings_Indicator; |
| 14 |
|
| 15 |
defined( 'ABSPATH' ) || exit; |
| 16 |
|
| 17 |
/** |
| 18 |
* Class - Log_Settings |
| 19 |
*/ |
| 20 |
class Log_Settings { |
| 21 |
|
| 22 |
/** |
| 23 |
* Holds Instance of manager object |
| 24 |
* |
| 25 |
* @var Log_manager |
| 26 |
*/ |
| 27 |
public $manager; |
| 28 |
|
| 29 |
/** |
| 30 |
* Holds settings values. |
| 31 |
* |
| 32 |
* @var options |
| 33 |
*/ |
| 34 |
public $options; |
| 35 |
|
| 36 |
/** |
| 37 |
* Current page. |
| 38 |
* |
| 39 |
* @static |
| 40 |
* @var string $page Current page. |
| 41 |
*/ |
| 42 |
public static $page; |
| 43 |
|
| 44 |
/** |
| 45 |
* Store enable logs items settings. |
| 46 |
* |
| 47 |
* @static |
| 48 |
* @var array $enable_logs_items Enabled logs items. |
| 49 |
*/ |
| 50 |
private static $enable_logs_items; |
| 51 |
|
| 52 |
/** |
| 53 |
* Class constructor. |
| 54 |
* |
| 55 |
* @param Log_Manager $manager Instance of manager object. |
| 56 |
*/ |
| 57 |
public function __construct( $manager ) { |
| 58 |
$this->manager = $manager; |
| 59 |
|
| 60 |
$this->load_settings(); |
| 61 |
|
| 62 |
add_action( 'admin_init', array( $this, 'admin_init' ) ); |
| 63 |
add_filter( 'mainwp_getsubpages_settings', array( $this, 'add_subpage_menu_settings' ) ); |
| 64 |
add_filter( 'mainwp_init_primary_menu_items', array( $this, 'hook_init_primary_menu_items' ), 10, 2 ); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
/** |
| 69 |
* Handle admin_init action. |
| 70 |
*/ |
| 71 |
public function admin_init() { // phpcs:ignore -- NOSONAR - complex. |
| 72 |
//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 73 |
if ( isset( $_POST['mainwp_module_log_settings_nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['mainwp_module_log_settings_nonce'] ), 'logs_settings_nonce' ) ) { |
| 74 |
|
| 75 |
$old_settings = MainWP_Settings::get_all_settings_values(); |
| 76 |
|
| 77 |
$old_enable = is_array( $this->options ) && ! empty( $this->options['enabled'] ) && ! empty( $this->options['auto_archive'] ) ? true : false; |
| 78 |
|
| 79 |
$this->options['enabled'] = isset( $_POST['mainwp_module_log_enabled'] ) && ! empty( $_POST['mainwp_module_log_enabled'] ) ? 1 : 0; |
| 80 |
$this->options['records_logs_ttl'] = isset( $_POST['mainwp_module_log_records_ttl'] ) ? intval( $_POST['mainwp_module_log_records_ttl'] ) : 3 * YEAR_IN_SECONDS; |
| 81 |
$this->options['child_logs_ttl'] = isset( $_POST['mainwp_module_log_child_activities_ttl'] ) ? intval( $_POST['mainwp_module_log_child_activities_ttl'] ) : 7; |
| 82 |
$this->options['auto_archive'] = isset( $_POST['mainwp_module_log_enable_auto_archive'] ) && ! empty( $_POST['mainwp_module_log_enable_auto_archive'] ) ? 1 : 0; |
| 83 |
MainWP_Utility::update_option( 'mainwp_module_log_settings', $this->options ); |
| 84 |
|
| 85 |
$new_enable = is_array( $this->options ) && ! empty( $this->options['enabled'] ) && ! empty( $this->options['auto_archive'] ) ? true : false; |
| 86 |
|
| 87 |
if ( $old_enable !== $new_enable ) { |
| 88 |
// To reset. |
| 89 |
$sched = wp_next_scheduled( 'mainwp_module_log_cron_job_auto_archive' ); |
| 90 |
if ( false !== $sched ) { |
| 91 |
wp_unschedule_event( $sched, 'mainwp_module_log_cron_job_auto_archive' ); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
$logs_data = array( |
| 96 |
'dashboard' => array(), |
| 97 |
'nonmainwpchanges' => array(), |
| 98 |
'changeslogs' => array(), |
| 99 |
); |
| 100 |
|
| 101 |
if ( isset( $_POST['mainwp_settings_logs_data'] ) && is_array( $_POST['mainwp_settings_logs_data'] ) ) { |
| 102 |
$selected_data = $_POST['mainwp_settings_logs_data']; //phpcs:ignore -- NOSONAR -ok. |
| 103 |
foreach ( array( 'dashboard', 'nonmainwpchanges', 'changeslogs' ) as $type ) { |
| 104 |
$selected_type = isset( $selected_data[ $type ] ) && is_array( $selected_data[ $type ] ) ? array_map( 'sanitize_text_field', wp_unslash( $selected_data[ $type ] ) ) : array(); |
| 105 |
foreach ( $selected_type as $name ) { |
| 106 |
$logs_data[ $type ][ $name ] = 1; |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
if ( isset( $_POST['mainwp_settings_logs_name'] ) && is_array( $_POST['mainwp_settings_logs_name'] ) ) { |
| 112 |
$name_data = $_POST['mainwp_settings_logs_name']; //phpcs:ignore -- NOSONAR -ok. |
| 113 |
foreach ( array( 'dashboard', 'nonmainwpchanges', 'changeslogs' ) as $type ) { |
| 114 |
$name_type = isset( $name_data[ $type ] ) && is_array( $name_data[ $type ] ) ? array_map( 'sanitize_text_field', wp_unslash( $name_data[ $type ] ) ) : array(); |
| 115 |
foreach ( $name_type as $name ) { |
| 116 |
if ( ! isset( $logs_data[ $type ][ $name ] ) ) { |
| 117 |
$logs_data[ $type ][ $name ] = 0; |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
MainWP_Utility::update_option( 'mainwp_module_log_settings_logs_selection_data', wp_json_encode( $logs_data ) ); |
| 123 |
|
| 124 |
$new_settings = MainWP_Settings::get_all_settings_values(); |
| 125 |
|
| 126 |
/** |
| 127 |
* Action: mainwp_after_save_settings |
| 128 |
* |
| 129 |
* Fires after save settings. |
| 130 |
* |
| 131 |
* @since 6.0 |
| 132 |
* |
| 133 |
* @param array $new_settings The new settings. |
| 134 |
* @param array $old_settings The old settings. |
| 135 |
*/ |
| 136 |
do_action( 'mainwp_after_save_settings', $new_settings, $old_settings ); |
| 137 |
|
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* Init sub menu logs settings. |
| 143 |
* |
| 144 |
* @param array $subpages Sub pages. |
| 145 |
* |
| 146 |
* @action init |
| 147 |
*/ |
| 148 |
public function add_subpage_menu_settings( $subpages = array() ) { |
| 149 |
$subpages[] = array( |
| 150 |
'title' => esc_html__( 'Network Activity Settings', 'mainwp' ), |
| 151 |
'slug' => 'Insights', |
| 152 |
'callback' => array( $this, 'render_settings_page' ), |
| 153 |
'class' => '', |
| 154 |
); |
| 155 |
return $subpages; |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* Init sub menu logs settings. |
| 160 |
* |
| 161 |
* @param array $items Sub menu items. |
| 162 |
* @param string $which_menu first|second. |
| 163 |
* |
| 164 |
* @return array $tmp_items Menu items. |
| 165 |
*/ |
| 166 |
public function hook_init_primary_menu_items( $items, $which_menu ) { |
| 167 |
if ( ! is_array( $items ) || 'first' !== $which_menu ) { |
| 168 |
return $items; |
| 169 |
} |
| 170 |
$items[] = array( |
| 171 |
'slug' => 'InsightsOverview', |
| 172 |
'menu_level' => 2, |
| 173 |
'menu_rights' => array( |
| 174 |
'dashboard' => array( |
| 175 |
'access_insights_dashboard', |
| 176 |
), |
| 177 |
), |
| 178 |
'init_menu_callback' => array( static::class, 'init_menu' ), |
| 179 |
'leftbar_order' => 2.9, |
| 180 |
); |
| 181 |
return $items; |
| 182 |
} |
| 183 |
|
| 184 |
/** |
| 185 |
* Method init_menu() |
| 186 |
* |
| 187 |
* Add Insights Operations sub menu "Insights". |
| 188 |
*/ |
| 189 |
public static function init_menu() { |
| 190 |
|
| 191 |
static::$page = add_submenu_page( |
| 192 |
'mainwp_tab', |
| 193 |
esc_html__( 'Insights', 'mainwp' ), |
| 194 |
'<span id="mainwp-insights">' . esc_html__( 'Insights', 'mainwp' ) . '</span>', |
| 195 |
'read', |
| 196 |
'InsightsOverview', |
| 197 |
array( |
| 198 |
Log_Insights_Page::instance(), |
| 199 |
'render_insights_overview', |
| 200 |
) |
| 201 |
); |
| 202 |
|
| 203 |
Log_Insights_Page::init_left_menu(); |
| 204 |
|
| 205 |
if ( isset( $_GET['page'] ) && 'InsightsOverview' === $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 206 |
add_filter( 'mainwp_enqueue_script_gridster', '__return_true' ); |
| 207 |
} |
| 208 |
|
| 209 |
add_action( 'load-' . static::$page, array( static::class, 'on_load_page' ) ); |
| 210 |
} |
| 211 |
|
| 212 |
/** |
| 213 |
* Method load_settings(). |
| 214 |
*/ |
| 215 |
public function load_settings() { |
| 216 |
if ( null === $this->options ) { |
| 217 |
$this->options = get_option( 'mainwp_module_log_settings', array() ); |
| 218 |
if ( ! is_array( $this->options ) ) { |
| 219 |
$this->options = array(); |
| 220 |
} |
| 221 |
|
| 222 |
$update = false; |
| 223 |
|
| 224 |
if ( ! isset( $this->options['enabled'] ) ) { |
| 225 |
$this->options['enabled'] = 1; |
| 226 |
$update = true; |
| 227 |
} |
| 228 |
if ( ! isset( $this->options['records_logs_ttl'] ) ) { |
| 229 |
$this->options['records_logs_ttl'] = 3 * YEAR_IN_SECONDS; |
| 230 |
$update = true; |
| 231 |
} |
| 232 |
|
| 233 |
if ( $update ) { |
| 234 |
MainWP_Utility::update_option( 'mainwp_module_log_settings', $this->options ); |
| 235 |
} |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
/** |
| 240 |
* Method get_settings(). |
| 241 |
*/ |
| 242 |
public function get_settings() { |
| 243 |
return $this->options; |
| 244 |
} |
| 245 |
|
| 246 |
/** |
| 247 |
* Method on_load_page() |
| 248 |
* |
| 249 |
* Run on page load. |
| 250 |
*/ |
| 251 |
public static function on_load_page() { |
| 252 |
Log_Insights_Page::instance()->on_load_page( static::$page ); |
| 253 |
} |
| 254 |
|
| 255 |
/** |
| 256 |
* Render Insights settings page. |
| 257 |
*/ |
| 258 |
public function render_settings_page() { // phpcs:ignore -- NOSONAR - complex method. |
| 259 |
/** This action is documented in ../pages/page-mainwp-manage-sites.php */ |
| 260 |
do_action( 'mainwp_pageheader_settings', 'Insights' ); |
| 261 |
$enabled = ! empty( $this->options['enabled'] ) ? true : false; |
| 262 |
$enabled_auto_archive = isset( $this->options['auto_archive'] ) && ! empty( $this->options['auto_archive'] ) ? true : false; |
| 263 |
|
| 264 |
$child_logs_ttl = isset( $this->options['child_logs_ttl'] ) ? $this->options['child_logs_ttl'] : 7; |
| 265 |
|
| 266 |
?> |
| 267 |
<div id="mainwp-module-log-settings-wrapper" class="ui padded segment"> |
| 268 |
<?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-network-activity-settings-info-message' ) ) : ?> |
| 269 |
<div class="ui info message"> |
| 270 |
<i class="close icon mainwp-notice-dismiss" notice-id="mainwp-network-activity-settings-info-message"></i> |
| 271 |
<div class="ui header"><?php esc_html_e( 'Network Activity and Insights Data Logging', 'mainwp' ); ?></div> |
| 272 |
<p><?php esc_html_e( 'The Network Activity system records actions performed through your MainWP Dashboard or directly on your child sites. This data powers both the Network Activity feature which displays a detailed timeline of changes and events and Dashboard Insights, which summarizes the same information to help you analyze usage trends and overall activity.', 'mainwp' ); ?></p> |
| 273 |
<p><?php esc_html_e( 'All collected data is stored locally on your server. It is never sent to MainWP servers or shared with any third parties.', 'mainwp' ); ?></p> |
| 274 |
</div> |
| 275 |
<?php else : ?> |
| 276 |
<div class="ui info message"> |
| 277 |
<div><?php esc_html_e( 'All collected data is stored locally on your server. It is never sent to MainWP servers or shared with any third parties.', 'mainwp' ); ?></div> |
| 278 |
</div> |
| 279 |
<?php endif; ?> |
| 280 |
<div class="ui form"> |
| 281 |
<form method="post" class="mainwp-table-container"> |
| 282 |
<div id="mainwp-message-zone" style="display:none;" class="ui message"></div> |
| 283 |
<h3 class="ui dividing header"> |
| 284 |
<?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-insights' ); ?> |
| 285 |
<?php esc_html_e( 'Dashboard Insights Settings', 'mainwp' ); ?> |
| 286 |
<div class="sub header"><?php esc_html_e( 'Manage how MainWP records, stores, and displays Dashboard activity data used by Network Activity and Insights.', 'mainwp' ); ?></div> |
| 287 |
</h3> |
| 288 |
<div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-insights" default-indi-value="1"> |
| 289 |
<label class="six wide column middle aligned"> |
| 290 |
<?php |
| 291 |
MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_module_log_enabled', (int) $enabled ); |
| 292 |
esc_html_e( 'Enable Network Activity logging', 'mainwp' ); |
| 293 |
?> |
| 294 |
</label> |
| 295 |
<div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="auto-archive;child-logs-ttl"> |
| 296 |
<input type="checkbox" class="settings-field-value-change-handler" name="mainwp_module_log_enabled" id="mainwp_module_log_enabled" <?php echo $enabled ? 'checked="true"' : ''; ?> /><label></label> |
| 297 |
</div> |
| 298 |
</div> |
| 299 |
<div class="ui grid field"> |
| 300 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Automatically archive logs', 'mainwp' ); ?></label> |
| 301 |
<div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="auto-archive" data-tooltip="<?php esc_attr_e( 'Automatically move older logs to the archive after a specified period of time. This helps keep your active logs organized while maintaining a searchable history.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left"> |
| 302 |
<input type="checkbox" name="mainwp_module_log_enable_auto_archive" id="mainwp_module_log_enable_auto_archive" <?php echo $enabled_auto_archive ? 'checked="true"' : ''; ?> /><label></label> |
| 303 |
</div> |
| 304 |
</div> |
| 305 |
<div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" <?php echo ( $enabled && $enabled_auto_archive ) ? '' : 'style="display:none"'; ?> hide-element="auto-archive" default-indi-value="<?php echo (int) 3 * YEAR_IN_SECONDS; ?>"> |
| 306 |
<label class="six wide column middle aligned"> |
| 307 |
<?php |
| 308 |
$records_ttl = $this->options['records_logs_ttl']; |
| 309 |
MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_module_log_records_ttl', $records_ttl, true, 3 * YEAR_IN_SECONDS ); |
| 310 |
esc_html_e( 'Data retention period', 'mainwp' ); |
| 311 |
?> |
| 312 |
</label> |
| 313 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Define how long logs should remain active before being automatically moved to the archive.', 'mainwp' ); ?>" data-inverted="" data-position="top left" > |
| 314 |
<select name="mainwp_module_log_records_ttl" id="mainwp_module_log_records_ttl" class="ui dropdown settings-field-value-change-handler"> |
| 315 |
<option value="<?php echo (int) MONTH_IN_SECONDS; ?>" <?php echo (int) MONTH_IN_SECONDS === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'One month', 'mainwp' ); ?></option> |
| 316 |
<option value="<?php echo (int) 2 * MONTH_IN_SECONDS; ?>" <?php echo 2 * MONTH_IN_SECONDS === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'Two months', 'mainwp' ); ?></option> |
| 317 |
<option value="<?php echo (int) 3 * MONTH_IN_SECONDS; ?>" <?php echo 3 * MONTH_IN_SECONDS === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'Three months', 'mainwp' ); ?></option> |
| 318 |
<option value="<?php echo (int) 6 * MONTH_IN_SECONDS; ?>" <?php echo 6 * MONTH_IN_SECONDS === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'Half a year', 'mainwp' ); ?></option> |
| 319 |
<option value="<?php echo (int) YEAR_IN_SECONDS; ?>" <?php echo (int) YEAR_IN_SECONDS === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'Year', 'mainwp' ); ?></option> |
| 320 |
<option value="<?php echo (int) 2 * YEAR_IN_SECONDS; ?>" <?php echo 2 * YEAR_IN_SECONDS === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'Two years', 'mainwp' ); ?></option> |
| 321 |
<option value="<?php echo (int) 3 * YEAR_IN_SECONDS; ?>" <?php echo 3 * YEAR_IN_SECONDS === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'Three years', 'mainwp' ); ?></option> |
| 322 |
<option value="0" <?php echo 0 === (int) $records_ttl ? 'selected' : ''; ?>><?php esc_html_e( 'Forever', 'mainwp' ); ?></option> |
| 323 |
</select> |
| 324 |
</div> |
| 325 |
</div> |
| 326 |
<div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-insights" <?php echo ( $enabled ) ? '' : 'style="display:none"'; ?> hide-element="child-logs-ttl" default-indi-value="7"> |
| 327 |
<label class="six wide column middle aligned"> |
| 328 |
<?php |
| 329 |
MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_module_log_child_activities_ttl', (int) get_option( 'mainwp_module_log_child_activities_ttl', 7 ) ); |
| 330 |
esc_html_e( 'Retention period for Network Activity Logs on child sites', 'mainwp' ); |
| 331 |
?> |
| 332 |
</label> |
| 333 |
<div class="five wide column" data-tooltip="<?php esc_attr_e( 'Controls how long network activity logs are stored on child sites before local cleanup. This does not affect log retention on the Dashboard.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 334 |
<input type="number" class="settings-field-value-change-handler small-text" name="mainwp_module_log_child_activities_ttl" id="mainwp_module_log_child_activities_ttl" placeholder="" min="1" max="9999" step="1" value="<?php echo intval( $child_logs_ttl ); ?>"> |
| 335 |
</div> |
| 336 |
</div> |
| 337 |
|
| 338 |
<?php |
| 339 |
static::render_logs_data_selection(); |
| 340 |
?> |
| 341 |
<div class="ui divider"></div> |
| 342 |
<input type="submit" name="submit" id="submit" class="ui button green big" value="<?php esc_html_e( 'Save Settings', 'mainwp' ); ?>"> |
| 343 |
<input type="hidden" name="mainwp_module_log_settings_nonce" value="<?php echo esc_attr( wp_create_nonce( 'logs_settings_nonce' ) ); ?>"> |
| 344 |
</div> |
| 345 |
</form> |
| 346 |
</div> |
| 347 |
|
| 348 |
<?php |
| 349 |
/** This action is documented in ../pages/page-mainwp-manage-sites.php */ |
| 350 |
do_action( 'mainwp_pagefooter_settings', 'Insights' ); |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
/** |
| 355 |
* Method load_actions_logs_selection_settings(). |
| 356 |
* |
| 357 |
* @return array Enable logs types. |
| 358 |
*/ |
| 359 |
public static function load_actions_logs_selection_settings() { |
| 360 |
if ( null === static::$enable_logs_items ) { |
| 361 |
$enable_logs = get_option( 'mainwp_module_log_settings_logs_selection_data' ); |
| 362 |
|
| 363 |
if ( ! empty( $enable_logs ) ) { |
| 364 |
static::$enable_logs_items = json_decode( $enable_logs, true ); |
| 365 |
} |
| 366 |
|
| 367 |
if ( ! is_array( static::$enable_logs_items ) ) { |
| 368 |
static::$enable_logs_items = array(); |
| 369 |
} |
| 370 |
|
| 371 |
if ( ! isset( static::$enable_logs_items['changeslogs'] ) ) { |
| 372 |
static::$enable_logs_items['changeslogs'] = array_fill_keys( static::get_disabled_changes_logs_default_settings(), 0 ); |
| 373 |
} |
| 374 |
} |
| 375 |
return static::$enable_logs_items; |
| 376 |
} |
| 377 |
|
| 378 |
/** |
| 379 |
* Method get_disabled_changes_logs_default_settings(). |
| 380 |
* |
| 381 |
* @return array Disalbed default. |
| 382 |
*/ |
| 383 |
public static function get_disabled_changes_logs_default_settings() { |
| 384 |
return array( 1925, 1930, 1935, 1940, 1945, 1950, 1955 ); |
| 385 |
} |
| 386 |
|
| 387 |
/** |
| 388 |
* Method is_action_log_enabled(). |
| 389 |
* |
| 390 |
* @param string $name Log item name. |
| 391 |
* @param string $type Log type dashboard|nonmainwpchanges. |
| 392 |
* |
| 393 |
* @return bool Enable log or not. |
| 394 |
*/ |
| 395 |
public static function is_action_log_enabled( $name, $type = 'dashboard' ) { |
| 396 |
|
| 397 |
if ( ! in_array( $type, array( 'dashboard', 'nonmainwpchanges', 'changeslogs' ) ) ) { |
| 398 |
return true; |
| 399 |
} |
| 400 |
|
| 401 |
static::load_actions_logs_selection_settings(); |
| 402 |
|
| 403 |
if ( isset( static::$enable_logs_items[ $type ][ $name ] ) ) { |
| 404 |
return ! empty( static::$enable_logs_items[ $type ][ $name ] ) ? true : false; |
| 405 |
} else { |
| 406 |
$un_logs = static::get_data_logs_default( 'unlogs' ); |
| 407 |
if ( ! is_array( $un_logs ) ) { |
| 408 |
$un_logs = array(); |
| 409 |
} |
| 410 |
if ( isset( $un_logs[ $name ] ) ) { |
| 411 |
return empty( $un_logs[ $name ] ) ? false : true; // default is enable log, if disabled in un logs list it will be disabled. |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
return true; |
| 416 |
} |
| 417 |
|
| 418 |
/** |
| 419 |
* Method get_disabled_logs_type(). |
| 420 |
* |
| 421 |
* @param string $type Log type dashboard|nonmainwpchanges|changeslogs. |
| 422 |
* |
| 423 |
* @return mixed Disabled logs settings. |
| 424 |
*/ |
| 425 |
public static function get_disabled_logs_type( $type = 'dashboard' ) { |
| 426 |
if ( ! in_array( $type, array( 'dashboard', 'nonmainwpchanges', 'changeslogs' ) ) ) { |
| 427 |
return false; |
| 428 |
} |
| 429 |
|
| 430 |
static::load_actions_logs_selection_settings(); |
| 431 |
|
| 432 |
$selection_items_type = isset( static::$enable_logs_items[ $type ] ) ? static::$enable_logs_items[ $type ] : array(); |
| 433 |
|
| 434 |
if ( ! is_array( $selection_items_type ) || empty( $selection_items_type ) ) { |
| 435 |
return array(); |
| 436 |
} |
| 437 |
|
| 438 |
return array_keys( |
| 439 |
array_filter( |
| 440 |
$selection_items_type, |
| 441 |
function ( $value ) { |
| 442 |
return empty( $value ); |
| 443 |
} |
| 444 |
) |
| 445 |
); |
| 446 |
} |
| 447 |
|
| 448 |
/** |
| 449 |
* Method render_logs_data_selection(). |
| 450 |
* |
| 451 |
* @return void |
| 452 |
*/ |
| 453 |
private static function render_logs_data_selection() { //phpcs:ignore -- NOSONAR - ok. |
| 454 |
$list_logs = static::get_data_logs_default_to_render(); |
| 455 |
$setting_page = true; |
| 456 |
?> |
| 457 |
<div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous"> |
| 458 |
<label class="six wide column top aligned"> |
| 459 |
<?php |
| 460 |
MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-logs-data' ); |
| 461 |
esc_html_e( 'Select events to log', 'mainwp' ); |
| 462 |
?> |
| 463 |
</label> |
| 464 |
<div class="ten wide column" <?php echo $setting_page ? 'data-tooltip="' . esc_attr__( 'Select which types of site changes should be recorded in the logs. Only checked items will generate log entries, helping you focus on the most relevant activity.', 'mainwp' ) . '"' : ''; ?> data-inverted="" data-position="top left"> |
| 465 |
<?php |
| 466 |
foreach ( $list_logs as $item ) { |
| 467 |
if ( ! is_array( $item ) ) { |
| 468 |
continue; |
| 469 |
} |
| 470 |
if ( isset( $item['name_id'] ) && '_separator_title' === $item['name_id'] ) { |
| 471 |
?> |
| 472 |
<div class="ui header"><?php echo esc_html( $item['label'] ); ?></div> |
| 473 |
<?php |
| 474 |
continue; |
| 475 |
} |
| 476 |
?> |
| 477 |
<ul class="mainwp_hide_wpmenu_checkboxes"> |
| 478 |
<?php |
| 479 |
|
| 480 |
$type = isset( $item['log_group'] ) ? $item['log_group'] : ''; |
| 481 |
$name = isset( $item['name_id'] ) ? $item['name_id'] : ''; |
| 482 |
$title = isset( $item['label'] ) ? $item['label'] : ''; |
| 483 |
|
| 484 |
if ( in_array( $type, array( 'dashboard', 'nonmainwpchanges', 'changeslogs' ) ) ) { |
| 485 |
$_selected = ''; |
| 486 |
if ( static::is_action_log_enabled( $name, $type ) ) { |
| 487 |
$_selected = 'checked'; |
| 488 |
} |
| 489 |
?> |
| 490 |
<li> |
| 491 |
<div class="ui checkbox"> |
| 492 |
<input type="checkbox" class="settings-field-value-change-handler" id="mainwp_select_logs_<?php echo esc_attr( $type ); ?>_<?php echo esc_attr( $name ); ?>" name="mainwp_settings_logs_data[<?php echo esc_attr( $type ); ?>][]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>"> |
| 493 |
<label for="mainwp_select_logs_<?php echo esc_attr( $type ); ?>_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label> |
| 494 |
</div> |
| 495 |
<input type="hidden" name="mainwp_settings_logs_name[<?php echo esc_attr( $type ); ?>][]" value="<?php echo esc_attr( $name ); ?>"> |
| 496 |
</li> |
| 497 |
<?php |
| 498 |
} |
| 499 |
?> |
| 500 |
</ul> |
| 501 |
<?php |
| 502 |
} |
| 503 |
?> |
| 504 |
</div> |
| 505 |
</div> |
| 506 |
<?php |
| 507 |
} |
| 508 |
|
| 509 |
|
| 510 |
/** |
| 511 |
* Method get_data_logs_default(). |
| 512 |
* |
| 513 |
* @param string $type Type of logs info. |
| 514 |
* |
| 515 |
* @return array data. |
| 516 |
*/ |
| 517 |
private static function get_data_logs_default( $type = '' ) { |
| 518 |
|
| 519 |
$init_un_logs = array( |
| 520 |
'sites_sync' => 0, |
| 521 |
); |
| 522 |
|
| 523 |
$logs = array( |
| 524 |
'dashboard' => array( |
| 525 |
'sites_added' => __( 'Site Added', 'mainwp' ), |
| 526 |
'sites_updated' => __( 'Site Updated', 'mainwp' ), |
| 527 |
'sites_sync' => __( 'Site Synchronized', 'mainwp' ), |
| 528 |
'sites_deleted' => __( 'Site Deleted', 'mainwp' ), |
| 529 |
'sites_reconnect' => __( 'Site Reconnected', 'mainwp' ), |
| 530 |
'sites_suspend' => __( 'Site Suspended', 'mainwp' ), |
| 531 |
'sites_unsuspend' => __( 'Site Unsuspended', 'mainwp' ), |
| 532 |
|
| 533 |
'tags_created' => __( 'Tag Created', 'mainwp' ), |
| 534 |
'tags_deleted' => __( 'Tag Deleted', 'mainwp' ), |
| 535 |
'tags_updated' => __( 'Tag Updated', 'mainwp' ), |
| 536 |
|
| 537 |
'theme_install' => __( 'Theme Installed', 'mainwp' ), |
| 538 |
'theme_activate' => __( 'Theme Activated', 'mainwp' ), |
| 539 |
'theme_deactivate' => __( 'Theme Deactivated', 'mainwp' ), |
| 540 |
'theme_update' => __( 'Theme Updated', 'mainwp' ), |
| 541 |
'theme_switch' => __( 'Theme Switched', 'mainwp' ), |
| 542 |
'theme_delete' => __( 'Theme Deleted', 'mainwp' ), |
| 543 |
|
| 544 |
'plugin_install' => __( 'Plugin Installed', 'mainwp' ), |
| 545 |
'plugin_activate' => __( 'Plugin Activated', 'mainwp' ), |
| 546 |
'plugin_deactivate' => __( 'Plugin Deactivated', 'mainwp' ), |
| 547 |
'plugin_updated' => __( 'Plugin Updated', 'mainwp' ), |
| 548 |
'plugin_delete' => __( 'Plugin Deleted', 'mainwp' ), |
| 549 |
|
| 550 |
'translation_updated' => __( 'Translation Updated', 'mainwp' ), |
| 551 |
'core_updated' => __( 'WordPress Core Updated', 'mainwp' ), |
| 552 |
|
| 553 |
'post_created' => __( 'Post Created', 'mainwp' ), |
| 554 |
'post_published' => __( 'Post Published', 'mainwp' ), |
| 555 |
'post_unpublished' => __( 'Post Unpublished', 'mainwp' ), |
| 556 |
'post_updated' => __( 'Post Updated', 'mainwp' ), |
| 557 |
'post_trashed' => __( 'Post Trashed', 'mainwp' ), |
| 558 |
'post_deleted' => __( 'Post Deleted', 'mainwp' ), |
| 559 |
'post_restored' => __( 'Post Restored', 'mainwp' ), |
| 560 |
|
| 561 |
'page_created' => __( 'Page Created', 'mainwp' ), |
| 562 |
'page_published' => __( 'Page Published', 'mainwp' ), |
| 563 |
'page_unpublished' => __( 'Page Unpublished', 'mainwp' ), |
| 564 |
'page_updated' => __( 'Page Updated', 'mainwp' ), |
| 565 |
'page_trashed' => __( 'Page Trashed', 'mainwp' ), |
| 566 |
'page_deleted' => __( 'Page Deleted', 'mainwp' ), |
| 567 |
'page_restored' => __( 'Page Restored', 'mainwp' ), |
| 568 |
|
| 569 |
'clients_created' => __( 'Client Created', 'mainwp' ), |
| 570 |
'clients_updated' => __( 'Client Updated', 'mainwp' ), |
| 571 |
'clients_suspend' => __( 'Client Suspended', 'mainwp' ), |
| 572 |
'clients_unsuspend' => __( 'Client Unsuspended', 'mainwp' ), |
| 573 |
'clients_lead' => __( 'Client Marked as Lead', 'mainwp' ), |
| 574 |
'clients_lost' => __( 'Client Marked as Lost', 'mainwp' ), |
| 575 |
|
| 576 |
'users_created' => __( 'User Created', 'mainwp' ), |
| 577 |
'users_update' => __( 'User Updated', 'mainwp' ), |
| 578 |
'users_delete' => __( 'User Deleted', 'mainwp' ), |
| 579 |
'users_change_role' => __( 'User Role Changed', 'mainwp' ), |
| 580 |
'users_update_password' => __( 'Admin Password Updated', 'mainwp' ), |
| 581 |
), |
| 582 |
'nonmainwpchanges' => array( |
| 583 |
'theme_install' => __( 'Theme Installed', 'mainwp' ), |
| 584 |
'theme_activate' => __( 'Theme Activated', 'mainwp' ), |
| 585 |
'theme_deactivate' => __( 'Theme Deactivated', 'mainwp' ), |
| 586 |
'theme_updated' => __( 'Theme Updated', 'mainwp' ), |
| 587 |
'theme_switch' => __( 'Theme Switched', 'mainwp' ), |
| 588 |
'theme_delete' => __( 'Theme Deleted', 'mainwp' ), |
| 589 |
'plugin_install' => __( 'Plugin Installed', 'mainwp' ), |
| 590 |
'plugin_activate' => __( 'Plugin Activated', 'mainwp' ), |
| 591 |
'plugin_deactivate' => __( 'Plugin Deactivated', 'mainwp' ), |
| 592 |
'plugin_updated' => __( 'Plugin Updated', 'mainwp' ), |
| 593 |
'plugin_delete' => __( 'Plugin Deleted', 'mainwp' ), |
| 594 |
'core_updated' => __( 'WordPress Core Updated', 'mainwp' ), |
| 595 |
), |
| 596 |
); |
| 597 |
|
| 598 |
$logs['changeslogs'] = Log_Changes_Logs_Helper::get_changes_logs_types(); |
| 599 |
|
| 600 |
if ( 'unlogs' === $type ) { |
| 601 |
return $init_un_logs; |
| 602 |
} |
| 603 |
|
| 604 |
return $logs; |
| 605 |
} |
| 606 |
|
| 607 |
/** |
| 608 |
* Method get_data_logs_default_to_render(). |
| 609 |
* |
| 610 |
* @return array data. |
| 611 |
*/ |
| 612 |
private static function get_data_logs_default_to_render() { |
| 613 |
|
| 614 |
$list_compatible = array( 1960, 1965, 1970, 1975, 1980 ); |
| 615 |
|
| 616 |
// Convert |
| 617 |
$list_to_render = array( |
| 618 |
|
| 619 |
array( |
| 620 |
'label' => __( 'Events triggered from MainWP Dashboard', 'mainwp' ), |
| 621 |
'name_id' => '_separator_title', |
| 622 |
), |
| 623 |
array( |
| 624 |
'label' => __( 'Site Added', 'mainwp' ), |
| 625 |
'name_id' => 'sites_added', |
| 626 |
'log_group' => 'dashboard', |
| 627 |
), |
| 628 |
array( |
| 629 |
'label' => __( 'Site Updated', 'mainwp' ), |
| 630 |
'name_id' => 'sites_updated', |
| 631 |
'log_group' => 'dashboard', |
| 632 |
), |
| 633 |
array( |
| 634 |
'label' => __( 'Site Synchronized', 'mainwp' ), |
| 635 |
'name_id' => 'sites_sync', |
| 636 |
'log_group' => 'dashboard', |
| 637 |
), |
| 638 |
array( |
| 639 |
'label' => __( 'Site Deleted', 'mainwp' ), |
| 640 |
'name_id' => 'sites_deleted', |
| 641 |
'log_group' => 'dashboard', |
| 642 |
), |
| 643 |
array( |
| 644 |
'label' => __( 'Site Reconnected', 'mainwp' ), |
| 645 |
'name_id' => 'sites_reconnect', |
| 646 |
'log_group' => 'dashboard', |
| 647 |
), |
| 648 |
array( |
| 649 |
'label' => __( 'Site Suspended', 'mainwp' ), |
| 650 |
'name_id' => 'sites_suspend', |
| 651 |
'log_group' => 'dashboard', |
| 652 |
), |
| 653 |
array( |
| 654 |
'label' => __( 'Site Unsuspended', 'mainwp' ), |
| 655 |
'name_id' => 'sites_unsuspend', |
| 656 |
'log_group' => 'dashboard', |
| 657 |
), |
| 658 |
array( |
| 659 |
'label' => __( 'Tag Created', 'mainwp' ), |
| 660 |
'name_id' => 'tags_created', |
| 661 |
'log_group' => 'dashboard', |
| 662 |
), |
| 663 |
array( |
| 664 |
'label' => __( 'Tag Deleted', 'mainwp' ), |
| 665 |
'name_id' => 'tags_deleted', |
| 666 |
'log_group' => 'dashboard', |
| 667 |
), |
| 668 |
array( |
| 669 |
'label' => __( 'Tag Updated', 'mainwp' ), |
| 670 |
'name_id' => 'tags_updated', |
| 671 |
'log_group' => 'dashboard', |
| 672 |
), |
| 673 |
array( |
| 674 |
'label' => __( 'Theme Installed', 'mainwp' ), |
| 675 |
'name_id' => 'theme_install', |
| 676 |
'log_group' => 'dashboard', |
| 677 |
), |
| 678 |
array( |
| 679 |
'label' => __( 'Theme Activated', 'mainwp' ), |
| 680 |
'name_id' => 'theme_activate', |
| 681 |
'log_group' => 'dashboard', |
| 682 |
), |
| 683 |
array( |
| 684 |
'label' => __( 'Theme Deactivated', 'mainwp' ), |
| 685 |
'name_id' => 'theme_deactivate', |
| 686 |
'log_group' => 'dashboard', |
| 687 |
), |
| 688 |
array( |
| 689 |
'label' => __( 'Theme Updated', 'mainwp' ), |
| 690 |
'name_id' => 'theme_update', |
| 691 |
'log_group' => 'dashboard', |
| 692 |
), |
| 693 |
array( |
| 694 |
'label' => __( 'Theme Switched', 'mainwp' ), |
| 695 |
'name_id' => 'theme_switch', |
| 696 |
'log_group' => 'dashboard', |
| 697 |
), |
| 698 |
array( |
| 699 |
'label' => __( 'Theme Deleted', 'mainwp' ), |
| 700 |
'name_id' => 'theme_delete', |
| 701 |
'log_group' => 'dashboard', |
| 702 |
), |
| 703 |
array( |
| 704 |
'label' => __( 'Plugin Installed', 'mainwp' ), |
| 705 |
'name_id' => 'plugin_install', |
| 706 |
'log_group' => 'dashboard', |
| 707 |
), |
| 708 |
array( |
| 709 |
'label' => __( 'Plugin Activated', 'mainwp' ), |
| 710 |
'name_id' => 'plugin_activate', |
| 711 |
'log_group' => 'dashboard', |
| 712 |
), |
| 713 |
array( |
| 714 |
'label' => __( 'Plugin Deactivated', 'mainwp' ), |
| 715 |
'name_id' => 'plugin_deactivate', |
| 716 |
'log_group' => 'dashboard', |
| 717 |
), |
| 718 |
array( |
| 719 |
'label' => __( 'Plugin Updated', 'mainwp' ), |
| 720 |
'name_id' => 'plugin_updated', |
| 721 |
'log_group' => 'dashboard', |
| 722 |
), |
| 723 |
array( |
| 724 |
'label' => __( 'Plugin Deleted', 'mainwp' ), |
| 725 |
'name_id' => 'plugin_delete', |
| 726 |
'log_group' => 'dashboard', |
| 727 |
), |
| 728 |
array( |
| 729 |
'label' => __( 'Translation Updated', 'mainwp' ), |
| 730 |
'name_id' => 'translation_updated', |
| 731 |
'log_group' => 'dashboard', |
| 732 |
), |
| 733 |
array( |
| 734 |
'label' => __( 'WordPress Core Updated', 'mainwp' ), |
| 735 |
'name_id' => 'core_updated', |
| 736 |
'log_group' => 'dashboard', |
| 737 |
), |
| 738 |
array( |
| 739 |
'label' => __( 'Post Created', 'mainwp' ), |
| 740 |
'name_id' => 'post_created', |
| 741 |
'log_group' => 'dashboard', |
| 742 |
), |
| 743 |
array( |
| 744 |
'label' => __( 'Post Published', 'mainwp' ), |
| 745 |
'name_id' => 'post_published', |
| 746 |
'log_group' => 'dashboard', |
| 747 |
), |
| 748 |
array( |
| 749 |
'label' => __( 'Post Unpublished', 'mainwp' ), |
| 750 |
'name_id' => 'post_unpublished', |
| 751 |
'log_group' => 'dashboard', |
| 752 |
), |
| 753 |
array( |
| 754 |
'label' => __( 'Post Updated', 'mainwp' ), |
| 755 |
'name_id' => 'post_updated', |
| 756 |
'log_group' => 'dashboard', |
| 757 |
), |
| 758 |
array( |
| 759 |
'label' => __( 'Post Trashed', 'mainwp' ), |
| 760 |
'name_id' => 'post_trashed', |
| 761 |
'log_group' => 'dashboard', |
| 762 |
), |
| 763 |
array( |
| 764 |
'label' => __( 'Post Deleted', 'mainwp' ), |
| 765 |
'name_id' => 'post_deleted', |
| 766 |
'log_group' => 'dashboard', |
| 767 |
), |
| 768 |
array( |
| 769 |
'label' => __( 'Post Restored', 'mainwp' ), |
| 770 |
'name_id' => 'post_restored', |
| 771 |
'log_group' => 'dashboard', |
| 772 |
), |
| 773 |
array( |
| 774 |
'label' => __( 'Page Created', 'mainwp' ), |
| 775 |
'name_id' => 'page_created', |
| 776 |
'log_group' => 'dashboard', |
| 777 |
), |
| 778 |
array( |
| 779 |
'label' => __( 'Page Published', 'mainwp' ), |
| 780 |
'name_id' => 'page_published', |
| 781 |
'log_group' => 'dashboard', |
| 782 |
), |
| 783 |
array( |
| 784 |
'label' => __( 'Page Unpublished', 'mainwp' ), |
| 785 |
'name_id' => 'page_unpublished', |
| 786 |
'log_group' => 'dashboard', |
| 787 |
), |
| 788 |
array( |
| 789 |
'label' => __( 'Page Updated', 'mainwp' ), |
| 790 |
'name_id' => 'page_updated', |
| 791 |
'log_group' => 'dashboard', |
| 792 |
), |
| 793 |
array( |
| 794 |
'label' => __( 'Page Trashed', 'mainwp' ), |
| 795 |
'name_id' => 'page_trashed', |
| 796 |
'log_group' => 'dashboard', |
| 797 |
), |
| 798 |
array( |
| 799 |
'label' => __( 'Page Deleted', 'mainwp' ), |
| 800 |
'name_id' => 'page_deleted', |
| 801 |
'log_group' => 'dashboard', |
| 802 |
), |
| 803 |
array( |
| 804 |
'label' => __( 'Page Restored', 'mainwp' ), |
| 805 |
'name_id' => 'page_restored', |
| 806 |
'log_group' => 'dashboard', |
| 807 |
), |
| 808 |
array( |
| 809 |
'label' => __( 'Client Created', 'mainwp' ), |
| 810 |
'name_id' => 'clients_created', |
| 811 |
'log_group' => 'dashboard', |
| 812 |
), |
| 813 |
array( |
| 814 |
'label' => __( 'Client Updated', 'mainwp' ), |
| 815 |
'name_id' => 'clients_updated', |
| 816 |
'log_group' => 'dashboard', |
| 817 |
), |
| 818 |
array( |
| 819 |
'label' => __( 'Client Suspended', 'mainwp' ), |
| 820 |
'name_id' => 'clients_suspend', |
| 821 |
'log_group' => 'dashboard', |
| 822 |
), |
| 823 |
array( |
| 824 |
'label' => __( 'Client Unsuspended', 'mainwp' ), |
| 825 |
'name_id' => 'clients_unsuspend', |
| 826 |
'log_group' => 'dashboard', |
| 827 |
), |
| 828 |
array( |
| 829 |
'label' => __( 'Client Marked as Lead', 'mainwp' ), |
| 830 |
'name_id' => 'clients_lead', |
| 831 |
'log_group' => 'dashboard', |
| 832 |
), |
| 833 |
array( |
| 834 |
'label' => __( 'Client Marked as Lost', 'mainwp' ), |
| 835 |
'name_id' => 'clients_lost', |
| 836 |
'log_group' => 'dashboard', |
| 837 |
), |
| 838 |
array( |
| 839 |
'label' => __( 'User Created', 'mainwp' ), |
| 840 |
'name_id' => 'users_created', |
| 841 |
'log_group' => 'dashboard', |
| 842 |
), |
| 843 |
array( |
| 844 |
'label' => __( 'User Updated', 'mainwp' ), |
| 845 |
'name_id' => 'users_update', |
| 846 |
'log_group' => 'dashboard', |
| 847 |
), |
| 848 |
array( |
| 849 |
'label' => __( 'User Deleted', 'mainwp' ), |
| 850 |
'name_id' => 'users_delete', |
| 851 |
'log_group' => 'dashboard', |
| 852 |
), |
| 853 |
array( |
| 854 |
'label' => __( 'User Role Changed', 'mainwp' ), |
| 855 |
'name_id' => 'users_change_role', |
| 856 |
'log_group' => 'dashboard', |
| 857 |
), |
| 858 |
array( |
| 859 |
'label' => __( 'Admin Password Updated', 'mainwp' ), |
| 860 |
'name_id' => 'users_update_password', |
| 861 |
'log_group' => 'dashboard', |
| 862 |
), |
| 863 |
array( |
| 864 |
'label' => __( 'Non-MainWP Changes - Events triggered on child sites', 'mainwp' ), |
| 865 |
'name_id' => '_separator_title', |
| 866 |
), |
| 867 |
array( |
| 868 |
'label' => __( 'Theme Installed', 'mainwp' ), |
| 869 |
'name_id' => 1975, |
| 870 |
'log_group' => 'changeslogs', |
| 871 |
), |
| 872 |
array( |
| 873 |
'label' => __( 'Theme Activated', 'mainwp' ), |
| 874 |
'name_id' => 'theme_activate', |
| 875 |
'log_group' => 'nonmainwpchanges', |
| 876 |
), |
| 877 |
array( |
| 878 |
'label' => __( 'Theme Deactivated', 'mainwp' ), |
| 879 |
'name_id' => 'theme_deactivate', |
| 880 |
'log_group' => 'nonmainwpchanges', |
| 881 |
), |
| 882 |
array( |
| 883 |
'label' => __( 'Theme Updated', 'mainwp' ), |
| 884 |
'name_id' => 1980, |
| 885 |
'log_group' => 'changeslogs', |
| 886 |
), |
| 887 |
array( |
| 888 |
'label' => __( 'Theme Switched', 'mainwp' ), |
| 889 |
'name_id' => 'theme_switch', |
| 890 |
'log_group' => 'nonmainwpchanges', |
| 891 |
), |
| 892 |
array( |
| 893 |
'label' => __( 'Theme Deleted', 'mainwp' ), |
| 894 |
'name_id' => 'theme_delete', |
| 895 |
'log_group' => 'nonmainwpchanges', |
| 896 |
), |
| 897 |
array( |
| 898 |
'label' => __( 'Plugin Installed', 'mainwp' ), |
| 899 |
'name_id' => 1965, |
| 900 |
'log_group' => 'changeslogs', |
| 901 |
), |
| 902 |
array( |
| 903 |
'label' => __( 'Plugin Activated', 'mainwp' ), |
| 904 |
'name_id' => 'plugin_activate', |
| 905 |
'log_group' => 'nonmainwpchanges', |
| 906 |
), |
| 907 |
array( |
| 908 |
'label' => __( 'Plugin Deactivated', 'mainwp' ), |
| 909 |
'name_id' => 'plugin_deactivate', |
| 910 |
'log_group' => 'nonmainwpchanges', |
| 911 |
), |
| 912 |
array( |
| 913 |
'label' => __( 'Plugin Updated', 'mainwp' ), |
| 914 |
'name_id' => 1970, |
| 915 |
'log_group' => 'changeslogs', |
| 916 |
), |
| 917 |
array( |
| 918 |
'label' => __( 'Plugin Deleted', 'mainwp' ), |
| 919 |
'name_id' => 'plugin_delete', |
| 920 |
'log_group' => 'nonmainwpchanges', |
| 921 |
), |
| 922 |
array( |
| 923 |
'label' => __( 'WordPress Core Updated', 'mainwp' ), |
| 924 |
'name_id' => 1960, |
| 925 |
'log_group' => 'changeslogs', |
| 926 |
), |
| 927 |
); |
| 928 |
|
| 929 |
$raw_logs = Log_Changes_Logs_Helper::get_changes_logs_types(); |
| 930 |
|
| 931 |
foreach ( $raw_logs as $item ) { |
| 932 |
|
| 933 |
if ( ! empty( $item['type_id'] ) && in_array( $item['type_id'], $list_compatible ) ) { |
| 934 |
continue; |
| 935 |
} |
| 936 |
|
| 937 |
$list_to_render[] = array( |
| 938 |
'label' => $item['desc'], |
| 939 |
'name_id' => $item['type_id'], |
| 940 |
'log_group' => 'changeslogs', |
| 941 |
); |
| 942 |
} |
| 943 |
|
| 944 |
return $list_to_render; |
| 945 |
} |
| 946 |
} |
| 947 |
|