Action uncanny-automator

automator_settings_general_logs_content

Fires when the general logs section of Automator settings is being displayed, allowing for custom content insertion.

add_action( 'automator_settings_general_logs_content', $callback, 10, 1 );

Description

Fires within the Uncanny Automator general settings "Data management" section. Developers can hook into this action to add custom log management options or controls to this area of the WordPress admin.


Usage

add_action( 'automator_settings_general_logs_content', 'your_function_name', 10, 1 );

Examples

<?php
/**
 * Add a custom section to the Uncanny Automator logs settings page to manage automated log purging.
 *
 * This function hooks into 'automator_settings_general_logs_content' and outputs HTML
 * for controlling the automatic purging of old logs based on user-defined criteria.
 *
 * @since 1.0.0
 */
function my_custom_automator_log_purge_section() {
    // Check if the current user has the necessary capabilities to manage these settings.
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }

    // Get the current log retention period from WordPress options, or use a default.
    $log_retention_days = get_option( 'automator_log_retention_days', 30 );
    $auto_purge_enabled = get_option( 'automator_auto_purge_logs_enabled', 'no' );

    ?>
    <div class="uap-settings-section">
        <h4><?php esc_html_e( 'Automated Log Purging', 'my-text-domain' ); ?></h4>
        <p><?php esc_html_e( 'Configure automatic deletion of old automation logs to save disk space.', 'my-text-domain' ); ?></p>

        <table class="form-table">
            <tr>
                <th scope="row"><?php esc_html_e( 'Enable Automated Purging', 'my-text-domain' ); ?></th>
                <td>
                    <input type="checkbox" name="automator_auto_purge_logs_enabled" value="yes" <?php checked( $auto_purge_enabled, 'yes' ); ?> />
                    <label for="automator_auto_purge_logs_enabled"><?php esc_html_e( 'Automatically purge logs older than the specified days.', 'my-text-domain' ); ?></label>
                </td>
            </tr>
            <tr>
                <th scope="row"><?php esc_html_e( 'Log Retention Period (Days)', 'my-text-domain' ); ?></th>
                <td>
                    <input type="number" name="automator_log_retention_days" value="<?php echo esc_attr( $log_retention_days ); ?>" min="1" max="365" class="regular-text" />
                    <p class="description"><?php esc_html_e( 'Logs older than this number of days will be automatically removed.', 'my-text-domain' ); ?></p>
                </td>
            </tr>
        </table>

        <?php
        // You would typically save these options in a separate save_post or admin_init hook.
        // This is just for outputting the settings.
        submit_button( __( 'Save Purge Settings', 'my-text-domain' ) );
        ?>
    </div>
    <?php
}

// Hook the custom function into the Uncanny Automator logs settings content area.
// The priority '20' ensures it appears after the default Uncanny Automator settings.
// The '3' indicates that this callback function accepts 3 arguments if they were passed by the hook (though this hook doesn't pass any).
add_action( 'automator_settings_general_logs_content', 'my_custom_automator_log_purge_section', 20, 3 );
?>

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/core/views/admin-settings/tab/general/logs.php:27

<div class="uap-settings-panel-title">
			<?php esc_html_e( 'Data management', 'uncanny-automator' ); ?>
		</div>

		<div class="uap-settings-panel-content">

			<?php do_action( 'automator_settings_general_logs_content' ); ?>

		</div>

	</div>

</div>

Internal Usage

Found in src/core/admin/class-prune-logs.php:67:

add_action( 'automator_settings_general_logs_content', array( $this, 'add_purge_settings' ), 10 );

Found in src/core/admin/class-prune-logs.php:70:

add_action( 'automator_settings_general_logs_content', array( $this, 'add_user_deleted_settings' ), 10 );

Found in src/core/admin/class-prune-logs.php:93:

add_action( 'automator_settings_general_logs_content', array( $this, 'add_pro_auto_prune_settings' ), 15 );

Found in uncanny-automator-pro/src/core/extensions/activity-log-settings.php:26:

add_action( 'automator_settings_general_logs_content', array( $this, 'tab_output_auto_purge_fields' ) );
Scroll to Top