%PDF-
%PDF-
Mini Shell
Mini Shell
Direktori : / platform /misc /
Current File : //platform/misc/wp-cli-helper.php
<?php
if (!defined('WP_CLI') || !WP_CLI) {
return;
}
require_once __DIR__ . '/wp-cli-helper-prefix.php';
$wpCliTimeout = max( (int) getenv('WP_CLI_COMMAND_TIMEOUT'), 0 ) ?: 600;
ini_set('max_execution_time', $wpCliTimeout);
define('WPAAS_MHP_CLI_HELPER_BOUNDARY_START', '////////WPAAS_MHP_START////////');
define('WPAAS_MHP_CLI_HELPER_BOUNDARY_END', '////////WPAAS_MHP_END////////');
/**
* wp-cli cmds to add boundary to
*/
$boundaryWpCliCmds = [
'cache',
'cli',
'config',
'core',
'cron',
'db',
'godaddy',
'nux',
'option',
'plugin',
'post',
'rewrite',
'search',
'theme',
'user',
'wpaas',
];
// Get error key
function wpaas_mhp_cli_helper_get_error_key($errno, $errstr)
{
// Maybe generalize the unserialize offset notices.
if ((E_NOTICE === $errno || E_WARNING === $errno) && false !== strpos($errstr, 'unserialize(): Error at offset')) {
$errstr = 'unserialize(): Error at offset X of Y bytes (generalized)';
}
return "{$errno}-{$errstr}";
}
function wpaas_mhp_cli_helper_error_handler($errno, $errstr, $errfile = null, $errline = null) {
static $errorCounter = [];
static $errorTypeCounter = [];
$errorKey = wpaas_mhp_cli_helper_get_error_key($errno, $errstr);
if (!isset($errorCounter[$errorKey])) {
$errorCounter[$errorKey] = 0;
}
if (!isset($errorTypeCounter[$errno])) {
$errorTypeCounter[$errno] = 0;
}
// Swallow the error if there are large numbers of the same one.
if (20 < $errorCounter[$errorKey]) {
return;
}
// Swallow the error if there are large numbers of the same type.
if (100 < $errorTypeCounter[$errno]) {
return;
}
$errorCounter[$errorKey]++;
$errorTypeCounter[$errno]++;
$formattedError = wpaas_mhp_cli_helper_format_error($errno, $errstr, $errfile, $errline);
fwrite(STDERR, $formattedError);
$isFatal = $errno & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR);
if ($isFatal) {
exit(1);
}
}
set_error_handler('wpaas_mhp_cli_helper_error_handler');
foreach ($boundaryWpCliCmds as $cmd) {
WP_CLI::add_hook('before_invoke:' . $cmd, static function () {
fwrite(STDOUT, WPAAS_MHP_CLI_HELPER_BOUNDARY_START . PHP_EOL);
});
WP_CLI::add_hook('after_invoke:' . $cmd, static function () {
fwrite(STDOUT, PHP_EOL . WPAAS_MHP_CLI_HELPER_BOUNDARY_END);
});
}
function wpaas_mhp_cli_helper_format_error($errno, $errstr, $errfile = null, $errline = null)
{
$errType = wpaas_mhp_cli_helper_error_type($errno);
return "{$errType}({$errno}): {$errstr} {$errfile}#{$errline}" . PHP_EOL;
}
function wpaas_mhp_cli_helper_error_type($errno)
{
switch ($errno) {
case E_ERROR:
return 'Error';
case E_WARNING:
return 'Warning';
case E_PARSE:
return 'Parse';
case E_NOTICE:
return 'Notice';
case E_CORE_ERROR:
return 'Core Error';
case E_CORE_WARNING:
return 'Core Warning';
case E_COMPILE_ERROR:
return 'Compile Error';
case E_COMPILE_WARNING:
return 'Compile Warning';
case E_DEPRECATED:
return 'Deprecated';
case E_USER_ERROR:
return 'User Error';
case E_USER_WARNING:
return 'User Warning';
case E_USER_NOTICE:
return 'User Notice';
case E_USER_DEPRECATED:
return 'User Deprecated';
case E_STRICT:
return 'Strict';
default:
return 'Unknown';
}
}
/**
* Backup Prime Mover constants file (WPVTWO-6946).
*
* The Prime Mover plugin creates wp-content/mu-plugins/000-prime-mover-constants.php
* with hardcoded paths that cause breakage during domain modifications.
* This function backs up the file before domain changes.
*
* @return array Status information with keys: success, message, backup_filename (optional)
*/
function wpaas_mhp_cli_helper_backup_prime_mover_constants()
{
$filename = '000-prime-mover-constants.php';
$file = ABSPATH . 'wp-content/mu-plugins/' . $filename;
$timestamp = time();
$backup_filename = $filename . '.' . $timestamp . '.bak';
$backup_file = ABSPATH . 'wp-content/mu-plugins/' . $backup_filename;
if (file_exists($file)) {
if (@rename($file, $backup_file)) {
return [
'success' => true,
'message' => "Backed up $filename to $backup_filename",
'backup_filename' => $backup_filename,
];
} else {
$error = error_get_last();
$errorMessage = (is_array($error) && isset($error['message'])) ? $error['message'] : 'Unknown error';
return [
'success' => false,
'message' => "Failed to backup $filename",
'error' => $errorMessage,
];
}
}
return [
'success' => true,
'message' => "File $filename does not exist, no action needed",
];
}
/**
* Restore Prime Mover constants file from backup (WPVTWO-6946).
*
* Restores the Prime Mover constants file from its backup after domain modifications.
*
* @param string $backup_filename Filename only (no path) of the backup file to restore (e.g., 000-prime-mover-constants.php.1234567890.bak)
* @return array Status information with keys: success, message
*/
function wpaas_mhp_cli_helper_restore_prime_mover_constants($backup_filename)
{
if (empty($backup_filename)) {
return [
'success' => false,
'message' => 'No backup filename specified',
];
}
// Sanitize: ensure it only contains the filename, no path separators
if (strpos($backup_filename, '/') !== false || strpos($backup_filename, '\\') !== false || strpos($backup_filename, '..') !== false) {
return [
'success' => false,
'message' => 'Invalid backup filename: must not contain path separators',
];
}
// Validate filename format: should be 000-prime-mover-constants.php.{timestamp}.bak
if (!preg_match('/^000-prime-mover-constants\.php\.\d+\.bak$/', $backup_filename)) {
return [
'success' => false,
'message' => 'Invalid backup filename format',
];
}
$original_filename = '000-prime-mover-constants.php';
$original_file = ABSPATH . 'wp-content/mu-plugins/' . $original_filename;
$backup_file = ABSPATH . 'wp-content/mu-plugins/' . $backup_filename;
if (!file_exists($backup_file)) {
return [
'success' => false,
'message' => "Backup file $backup_filename does not exist",
];
}
if (@rename($backup_file, $original_file)) {
return [
'success' => true,
'message' => "Restored $original_filename from $backup_filename",
];
} else {
$error = error_get_last();
$errorMessage = (is_array($error) && isset($error['message'])) ? $error['message'] : 'Unknown error';
return [
'success' => false,
'message' => "Failed to restore $original_filename from $backup_filename",
'error' => $errorMessage,
];
}
}
Zerion Mini Shell 1.0
Custom Staffing Solutions | Beyond A Resume
Skip to content
Distinguish Your Business From The Rest With The People That Make Up Your Team
We go Beyond a Resume to find high value, committed people
ready, willing, and able to add true value toward your organization's mission.
The right people make or break your business
We focus on resolving two types of challenges surrounding staffing and recruiting at Beyond a Resume: The first challenge comes when a business continues to grow, but does not have the full-time, internal, talent acquisition resources to hire the right people or talent necessary to keep up with their rate of progression as a company.
The second is a business that has a dedicated internal Human Resources Team, but requires outsourced assistance when the volume of people and talent needed exceeds short term internal capacity, OR the position(s) they seek to fill demand a specific skill set that is difficult to find, requiring added bandwidth.
In nearly any line of business, growth is a challenge in and of itself. Yet, the real problems arise in managing growth to ensure your progress remains profitable, sustainable, and repeatable. The biggest factor in this equation is usually found in your people. When you have the right people, success is unlimited. On the other hand, when you don’t have the right people in place or are having trouble finding enough of the right people, failure or stagnation is imminent.
The frustration that comes with the process of “hiring” can bring you to new levels of stress as the time cost involved eats away at your production elsewhere. If you have experienced this in the past, or are currently struggling with this issue, you’re certainly not alone. You may simply need the right partner to take the worst parts of this process off your plate so you can concentrate on your responsibilities, while we work diligently to reduce the noise and deliver only the ideal candidates worth your time and attention.
People can make or break your business and we go Beyond a Resume to find high value, committed people ready, willing, and able to add true value.
Primary Industry Experience
Healthcare and Home Healthcare
Talent Acquisition Solutions
Statement of Work Projects
Scroll To Top