Commit realizado el 12:13:52 08-04-2024

This commit is contained in:
Pagina Web Monito
2024-04-08 12:13:55 -04:00
commit 0c33094de9
7815 changed files with 1365694 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
namespace DeployerForGit\Subpages\LogsPage;
use DeployerForGit\DataManager;
use DeployerForGit\Logger;
/**
* Logs page
*/
class Logs {
/**
* Constructor
*/
public function __construct() {
add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', array( $this, 'init_menu' ) );
}
/**
* Initialize menu
*
* @return void
*/
public function init_menu() {
$menu_slug = \DeployerForGit\Helper::menu_slug();
$capability = is_multisite() ? 'manage_network_options' : 'manage_options';
add_submenu_page(
$menu_slug,
esc_attr__( 'Logs', 'deployer-for-git' ),
esc_attr__( 'Logs', 'deployer-for-git' ),
$capability,
"{$menu_slug}-logs",
array( $this, 'init_page' )
);
}
/**
* Initialize page
*
* @return void
*/
public function init_page() {
$data_manager = new DataManager();
$this->handle_clear_log_form();
include_once __DIR__ . '/template.php';
}
/**
* Handle clear log form
*
* @return void
*/
public function handle_clear_log_form() {
$form_submitted = false;
if ( isset( $_POST[ DFG_SLUG . '_nonce' ] ) && wp_verify_nonce( ( sanitize_text_field( wp_unslash( $_POST[ DFG_SLUG . '_nonce' ] ) ) ), DFG_SLUG . '_clear_log_file' ) ) {
$logger = new Logger();
$clear_log_result = $logger->clear_log_file();
$form_submitted = true;
}
}
}

View File

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

View File

@@ -0,0 +1,33 @@
<?php
use DeployerForGit\Logger;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="wrap">
<h1>
<?php echo esc_attr__( 'Logs', 'deployer-for-git' ); ?>
</h1>
<?php if ( isset( $form_submitted ) && $form_submitted ) : ?>
<?php if ( isset( $clear_log_result ) && $clear_log_result ) : ?>
<div class="updated">
<p><?php echo esc_attr__( 'Log file cleared', 'deployer-for-git' ); ?></p>
</div>
<?php else : ?>
<div class="error">
<p><?php echo esc_attr__( 'Can\'t clear the log file.', 'deployer-for-git' ); ?></p>
</div>
<?php endif; ?>
<?php endif; ?>
<?php $logger = new Logger(); ?>
<textarea class="large-text code dfg_log_textarea" readonly><?php echo esc_textarea( $logger->display_log_content() ); ?></textarea>
<form method="post" action="" onsubmit="return confirm('<?php echo esc_attr__( 'Are you sure?', 'deployer-for-git' ); ?>');">
<input type="hidden" name="action" value="clear_log_file">
<?php wp_nonce_field( DFG_SLUG . '_clear_log_file', DFG_SLUG . '_nonce' ); ?>
<input type="submit" class="button button-primary" value="<?php echo esc_attr__( 'Clear log file', 'deployer-for-git' ); ?>">
</form>
</div>