Add option to log all post changes

This was previously done by default, now it needs to be turned on. Which is arguably better.
This commit is contained in:
Tetrakern 2024-09-17 11:38:15 +02:00
parent 899f730eac
commit 29cf93b7a3
4 changed files with 25 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -701,6 +701,12 @@ define( 'FICTIONEER_OPTIONS', array(
'group' => 'fictioneer-settings-general-group',
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
'default' => 0
),
'fictioneer_log_posts' => array(
'name' => 'fictioneer_log_posts',
'group' => 'fictioneer-settings-general-group',
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
'default' => 0
)
),
'integers' => array(
@ -1169,6 +1175,7 @@ function fictioneer_get_option_label( $option ) {
'fictioneer_enable_query_result_caching' => __( 'Enable caching of large query results', 'fictioneer' ),
'fictioneer_allow_rest_save_actions' => __( 'Allow REST requests to trigger save actions', 'fictioneer' ),
'fictioneer_enable_global_splide' => __( 'Enable Splide slider globally', 'fictioneer' ),
'fictioneer_log_posts' => __( 'Log all post updates', 'fictioneer' ),
);
}

View File

@ -141,12 +141,18 @@ function fictioneer_get_wp_debug_log() {
* Logs post update
*
* @since 5.0.0
* @since 5.24.1 - Make dependant on option.
*
* @param int $post_id The post ID.
* @param string $action The action performed.
*/
function fictioneer_log_post_update( $post_id, $action ) {
// Log posts?
if ( ! get_option( 'fictioneer_log_posts' ) ) {
return;
}
// Setup
$type_object = get_post_type_object( get_post_type( $post_id ) );
$post_type_name = $type_object->labels->singular_name;

View File

@ -1155,6 +1155,18 @@ $images = get_template_directory_uri() . '/img/documentation/';
?>
</div>
<div class="fictioneer-card__row">
<?php
fictioneer_settings_label_checkbox(
'fictioneer_log_posts',
__( 'Log all post updates', 'fictioneer' ),
__( 'If you want to track any and all changes.', 'fictioneer' ),
'Enable this option if you want to track every action made to any post: publishing, updating, trashing, and deleting. This may be useful if you have concerns about content changes, but it is not recommended for sites with a high throughput of posts.',
'<div class="helper-modal-image"><img src="' . $images . 'fictioneer_log_posts.jpg"></div>'
);
?>
</div>
<div class="fictioneer-card__row">
<?php
fictioneer_settings_label_checkbox(