← All changes
|
modules/logs/classes/class-log-changes-logs-helper.php
+40
-0
6.1
→
6.2.2
View file →
| @@ -331,8 +331,48 @@ | ||
| 331 | 331 | return $defaults; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | + * Method get_changes_logs_object_title(). | |
| 336 | + * | |
| 337 | + * @param object $item Logs type code. | |
| 338 | + * @param string $default_title Default title. | |
| 339 | + * | |
| 340 | + * @return strinng Object title. | |
| 341 | + */ | |
| 342 | + public static function get_changes_logs_object_title( $item = null, $default_title = '' ) { //phpcs:ignore -- NOSONAR - long function. | |
| 343 | + $title = ''; | |
| 344 | + if ( ! empty( $item->log_type_id ) ) { | |
| 345 | + $meta = isset( $item->meta ) && is_array( $item->meta ) | |
| 346 | + ? $item->meta | |
| 347 | + : array(); | |
| 348 | + if ( 'system-setting' === $item->context ) { | |
| 349 | + $title = isset( self::get_changes_logs_types( $item->log_type_id )['title'] ) ? self::get_changes_logs_types( $item->log_type_id )['title'] : ''; | |
| 350 | + if ( empty( $title ) ) { | |
| 351 | + $title = esc_html__( 'System Setting', 'mainwp' ); | |
| 352 | + } | |
| 353 | + } elseif ( 'database' === $item->context ) { | |
| 354 | + if ( ! empty( $meta['tablenames'] ) ) { | |
| 355 | + $title = is_array( $meta['tablenames'] ) ? implode( ', ', $meta['tablenames'] ) : esc_html( $meta['tablenames'] ); | |
| 356 | + $title = esc_html( $title ); | |
| 357 | + } | |
| 358 | + if ( empty( $title ) ) { | |
| 359 | + $title = esc_html__( 'Database Table', 'mainwp' ); | |
| 360 | + } | |
| 361 | + } elseif ( ( 1970 === (int) $item->log_type_id || 1980 === (int) $item->log_type_id ) ) { | |
| 362 | + if ( ! empty( $meta['name'] ) && is_scalar( $meta['name'] ) ) { | |
| 363 | + $title = esc_html( $meta['name'] ); | |
| 364 | + } elseif ( empty( $default_title ) ) { | |
| 365 | + $title = 1970 === (int) $item->log_type_id | |
| 366 | + ? esc_html__( 'Plugin', 'mainwp' ) | |
| 367 | + : esc_html__( 'Theme', 'mainwp' ); | |
| 368 | + } | |
| 369 | + } | |
| 370 | + } | |
| 371 | + return ! empty( $title ) ? $title : $default_title; | |
| 372 | + } | |
| 373 | + | |
| 374 | + /** | |
| 335 | 375 | * Method get_history_changes(). |
| 336 | 376 | * |
| 337 | 377 | * @param array $args Arguments. |
| 338 | 378 | * |