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,119 @@
<?php
namespace DeployerForGit\Subpages\MiscellaneousPage;
use DeployerForGit\DataManager;
use DeployerForGit\Helper;
/**
* Miscellaneous page
*/
class Miscellaneous {
/**
* 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 = Helper::menu_slug();
$capability = is_multisite() ? 'manage_network_options' : 'manage_options';
add_submenu_page(
$menu_slug,
esc_attr__( 'Miscellaneous', 'deployer-for-git' ),
esc_attr__( 'Miscellaneous', 'deployer-for-git' ),
$capability,
"{$menu_slug}-miscellaneous",
array( $this, 'init_page' )
);
}
/**
* Initialize page
*
* @return void
*/
public function init_page() {
$regenerate_secret_key_result = $this->handle_regenerate_secret_key_form();
$flush_cache_result = $this->handle_flush_cache_form();
$alert_notification_result = $this->handle_alert_notification_form();
$data_manager = new DataManager();
include_once __DIR__ . '/template.php';
}
/**
* Handle regenerate secret key form
*
* @return boolean|null
*/
public function handle_regenerate_secret_key_form() {
$result = null;
if ( isset( $_POST['action'] ) && $_POST['action'] === 'regenerate_secret_key' ) {
$result = false;
if ( isset( $_POST[ DFG_SLUG . '_nonce' ] ) || wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ DFG_SLUG . '_nonce' ] ) ), DFG_SLUG . '_regenerate_secret_key' ) ) {
$result = true;
Helper::generate_api_secret();
do_action( 'dfg_after_secret_key_regenerate' );
}
}
return $result;
}
/**
* Handle flush cache form
*
* @return boolean|null
*/
public function handle_flush_cache_form() {
$result = null;
if ( isset( $_POST['action'] ) && $_POST['action'] === 'flush_cache' ) {
$result = false;
if ( isset( $_POST[ DFG_SLUG . '_nonce' ] ) || wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ DFG_SLUG . '_nonce' ] ) ), DFG_SLUG . '_flush_cache' ) ) {
$data_manager = new DataManager();
$result = $data_manager->update_flush_cache_setting( isset( $_POST['flush_cache_setting'] ) );
do_action( 'dfg_after_flush_cache_setting_update' );
}
}
return $result;
}
/**
* Handle alert notification form
*
* @return boolean|null
*/
public function handle_alert_notification_form() {
$result = null;
if ( isset( $_POST['action'] ) && $_POST['action'] === 'alert_notification' ) {
$result = false;
if ( isset( $_POST[ DFG_SLUG . '_nonce' ] ) || wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ DFG_SLUG . '_nonce' ] ) ), DFG_SLUG . '_alert_notification' ) ) {
$data_manager = new DataManager();
$result = $data_manager->update_alert_notification_setting( isset( $_POST['alert_notification_setting'] ) );
do_action( 'dfg_after_alert_notification_setting_update' );
}
}
return $result;
}
}

View File

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

View File

@@ -0,0 +1,199 @@
<?php
use DeployerForGit\Helper;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="wrap">
<h1>
<?php echo esc_attr__( 'Miscellaneous', 'deployer-for-git' ); ?>
</h1>
<?php
if ( isset( $regenerate_secret_key_result ) && $regenerate_secret_key_result !== null ) {
if ( $regenerate_secret_key_result === false ) {
echo '<div class="notice notice-error is-dismissible"><p>' . esc_attr__( 'Error while regenerating secret key.', 'deployer-for-git' ) . '</p></div>';
} else {
echo '<div class="notice notice-success is-dismissible"><p>' . esc_attr__( 'Secret key has been successfully regenerated.', 'deployer-for-git' ) . '</p></div>';
}
}
?>
<?php
if ( isset( $flush_cache_result ) && $flush_cache_result !== null ) {
echo '<div class="notice notice-success is-dismissible"><p>' . esc_attr__( 'Cache setting has been updated.', 'deployer-for-git' ) . '</p></div>';
}
?>
<?php
if ( isset( $alert_notification_result ) && $alert_notification_result !== null ) {
echo '<div class="notice notice-success is-dismissible"><p>' . esc_attr__( 'Alert notification setting has been updated.', 'deployer-for-git' ) . '</p></div>';
}
?>
<div class="dfg_form_box">
<h3><span class="dashicons dashicons-admin-network"></span> <?php echo esc_attr__( 'Secret Key management', 'deployer-for-git' ); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php echo esc_attr__( 'Current secret key:', 'deployer-for-git' ); ?>
</th>
<td>
<span><?php echo esc_attr( Helper::get_api_secret() ); ?></span>
</td>
</tr>
</table>
<form method="post" action="" onsubmit="return confirm( '<?php echo esc_attr__( 'Are you sure?', 'deployer-for-git' ); ?>' );">
<input type="hidden" name="action" value="regenerate_secret_key">
<?php wp_nonce_field( DFG_SLUG . '_regenerate_secret_key', DFG_SLUG . '_nonce' ); ?>
<input type="submit" class="button button-primary" value="<?php echo esc_attr__( 'Regenerate Secret Key', 'deployer-for-git' ); ?>">
</form>
</div>
<div class="dfg_form_box">
<h3><span class="dashicons dashicons-database"></span> <?php echo esc_attr__( 'Flush cache', 'deployer-for-git' ); ?></h3>
<p class="description">
<?php echo esc_attr__( 'Activate this option if you want the plugin to clear the cache every time the package update link is triggered. We support next list of plugins:', 'deployer-for-git' ); ?>
<ul>
<li>
WP Rocket |
<?php if ( Helper::wp_rocket_activated() ) : ?>
<span class="wp-ui-text-highlight">
<?php echo esc_attr__( 'Active plugin found', 'deployer-for-git' ); ?>
</span>
<?php else : ?>
<span class="wp-ui-text-notification">
<?php echo esc_attr__( 'No plugin detected', 'deployer-for-git' ); ?>
</span>
<?php endif; ?>
</li>
<li>
WP-Optimize |
<?php if ( Helper::wp_optimize_activated() ) : ?>
<span class="wp-ui-text-highlight">
<?php echo esc_attr__( 'Active plugin found', 'deployer-for-git' ); ?>
</span>
<?php else : ?>
<span class="wp-ui-text-notification">
<?php echo esc_attr__( 'No plugin detected', 'deployer-for-git' ); ?>
</span>
<?php endif; ?>
</li>
<li>W3 Total Cache |
<?php if ( Helper::w3tc_activated() ) : ?>
<span class="wp-ui-text-highlight">
<?php echo esc_attr__( 'Active plugin found', 'deployer-for-git' ); ?>
</span>
<?php else : ?>
<span class="wp-ui-text-notification">
<?php echo esc_attr__( 'No plugin detected', 'deployer-for-git' ); ?>
</span>
<?php endif; ?>
</li>
<li>
LiteSpeed Cache |
<?php if ( Helper::litespeed_cache_activated() ) : ?>
<span class="wp-ui-text-highlight">
<?php echo esc_attr__( 'Active plugin found', 'deployer-for-git' ); ?>
</span>
<?php else : ?>
<span class="wp-ui-text-notification">
<?php echo esc_attr__( 'No plugin detected', 'deployer-for-git' ); ?>
</span>
<?php endif; ?>
</li>
<li>
WP Super Cache |
<?php if ( Helper::wp_super_cache_activated() ) : ?>
<span class="wp-ui-text-highlight">
<?php echo esc_attr__( 'Active plugin found', 'deployer-for-git' ); ?>
</span>
<?php else : ?>
<span class="wp-ui-text-notification">
<?php echo esc_attr__( 'No plugin detected', 'deployer-for-git' ); ?>
</span>
<?php endif; ?>
</li>
<li>
WP Fastest Cache |
<?php if ( Helper::wp_fastest_cache_activated() ) : ?>
<span class="wp-ui-text-highlight">
<?php echo esc_attr__( 'Active plugin found', 'deployer-for-git' ); ?>
</span>
<?php else : ?>
<span class="wp-ui-text-notification">
<?php echo esc_attr__( 'No plugin detected', 'deployer-for-git' ); ?>
</span>
<?php endif; ?>
</li>
<li>
Autoptimize |
<?php if ( Helper::autoptimize_activated() ) : ?>
<span class="wp-ui-text-highlight">
<?php echo esc_attr__( 'Active plugin found', 'deployer-for-git' ); ?>
</span>
<?php else : ?>
<span class="wp-ui-text-notification">
<?php echo esc_attr__( 'No plugin detected', 'deployer-for-git' ); ?>
</span>
<?php endif; ?>
</li>
</ul>
</p>
<form method="post" action="">
<input type="hidden" name="action" value="flush_cache">
<?php wp_nonce_field( DFG_SLUG . '_flush_cache', DFG_SLUG . '_nonce' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php echo esc_attr__( 'Enable', 'deployer-for-git' ); ?>
</th>
<td>
<input type="checkbox" name="flush_cache_setting" <?php echo $data_manager->get_flush_cache_setting() === true ? 'checked' : ''; ?> value="1">
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php echo esc_attr__( 'Save Caching Settings', 'deployer-for-git' ); ?>" />
</p>
</form>
</div>
<div class="dfg_form_box">
<h3><span class="dashicons dashicons-feedback"></span> <?php echo esc_attr__( 'Alert notification', 'deployer-for-git' ); ?></h3>
<p class="description">
<?php echo esc_attr__( 'Enable this option if you wish to display a notification message at the top of WordPress Admin interface (/wp-admin). The message is intended for developers, reminding them not to make any changes to the theme or plugin directly on this site, but rather use Git for such modifications.', 'deployer-for-git' ); ?>
</p>
<form method="post" action="">
<input type="hidden" name="action" value="alert_notification">
<?php wp_nonce_field( DFG_SLUG . '_alert_notification', DFG_SLUG . '_nonce' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php echo esc_attr__( 'Enable', 'deployer-for-git' ); ?>
</th>
<td>
<input type="checkbox" name="alert_notification_setting" <?php echo $data_manager->get_alert_notification_setting() === true ? 'checked' : ''; ?> value="1">
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php echo esc_attr__( 'Save Alert Notification Settings', 'deployer-for-git' ); ?>" />
</p>
</form>
</div>
</div>