v-wordpress-plugin-updater/v-wp-updater/helpers/SilentUpgraderSkin.php
copilot-swe-agent[bot] 1070d9a61f Add Project: UpdateAPI / Author: Vontainment headers to all production PHP files
Co-authored-by: djav1985 <174835544+djav1985@users.noreply.github.com>
2026-03-06 03:16:09 +00:00

104 lines
2 KiB
PHP

<?php // phpcs:disable WordPress.Files.FileName.NotHyphenatedLowercase phpcs:disable WordPress.Files.FileName.InvalidClassFileName
/**
* Project: UpdateAPI
* Author: Vontainment <services@vontainment.com>
* License: https://opensource.org/licenses/MIT MIT License
* Link: https://vontainment.com
* Version: 2.0.0
*
* File: SilentUpgraderSkin.php
* Description: V WordPress Plugin Updater
*/
namespace VWPU\Helpers;
use WP_Error;
use WP_Upgrader_Skin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Silent Upgrader Skin for WordPress Plugin and Theme Updates.
*
* Suppresses output during plugin and theme upgrades, capturing messages and errors internally.
*
* @since 1.0.0
* @see WP_Upgrader_Skin
*/
class SilentUpgraderSkin extends WP_Upgrader_Skin {
/**
* Stores feedback messages.
*
* @since 1.0.0
* @var array
*/
public $messages = array();
/**
* Stores error messages.
*
* @since 1.0.0
* @var array
*/
public $errors = array();
/**
* Overrides the header method to suppress output.
*
* @since 1.0.0
*/
public function header() {}
/**
* Overrides the footer method to suppress output.
*
* @since 1.0.0
*/
public function footer() {}
/**
* Captures feedback messages.
*
* @since 1.0.0
* @param string $msg The feedback message.
* @param mixed ...$args Optional arguments for vsprintf.
*/
public function feedback( $msg, ...$args ) {
if ( $args ) {
$msg = vsprintf( $msg, $args );
}
$this->messages[] = $msg;
}
/**
* Captures error messages.
*
* @since 1.0.0
* @param string|WP_Error $errors The error(s).
*/
public function error( $errors ) {
if ( is_wp_error( $errors ) ) {
foreach ( $errors->get_error_messages() as $msg ) {
$this->errors[] = $msg;
}
} elseif ( is_string( $errors ) ) {
$this->errors[] = $errors;
}
}
/**
* Overrides the before action to suppress output.
*
* @since 1.0.0
*/
public function before() {}
/**
* Overrides the after action to suppress output.
*
* @since 1.0.0
*/
public function after() {}
}