upskill-event-manager/wordpress-dev/vendor/antecedent/patchwork/Patchwork.php
bengizmo cdef12ee80 feat(events): Implement fallback logic and UI for Create/Modify Event page
- Refactored fallback submission logic in `class-event-handler.php` to remove `wp_die`/`exit` calls and use redirects for error handling, enabling proper unit testing.
- Implemented meta-data saving (dates, venue, organizer) in the fallback logic using `update_post_meta`.
- Updated unit tests (`test-event-management.php`) to remove `markTestIncomplete` calls related to handler errors and uncommented meta assertions. Unit tests for fallback logic now pass.
- Added Instructions section and Return to Dashboard button to the event form shortcode (`display_event_form_shortcode`).
- Applied basic theme styling classes (`ast-container`, `notice`, `ast-button`) to the event form.
- Updated `docs/implementation_plan.md` to reflect completion of tasks 4.1-4.5 and set focus to Task 5.

Refs: Task 4.1, 4.2, 4.3, 4.4, 4.5
2025-04-01 11:46:24 -03:00

144 lines
3.2 KiB
PHP

<?php
/**
* @author Ignas Rudaitis <ignas.rudaitis@gmail.com>
* @copyright 2010-2023 Ignas Rudaitis
* @license http://www.opensource.org/licenses/mit-license.html
*/
namespace Patchwork;
if (function_exists('Patchwork\replace')) {
return;
}
require_once __DIR__ . '/src/Exceptions.php';
require_once __DIR__ . '/src/CallRerouting.php';
require_once __DIR__ . '/src/CodeManipulation.php';
require_once __DIR__ . '/src/Utils.php';
require_once __DIR__ . '/src/Stack.php';
require_once __DIR__ . '/src/Config.php';
function redefine($subject, callable $content)
{
$handle = null;
foreach (array_slice(func_get_args(), 1) as $content) {
$handle = CallRerouting\connect($subject, $content, $handle);
}
$handle->silence();
return $handle;
}
function relay(?array $args = null)
{
return CallRerouting\relay($args);
}
function fallBack()
{
throw new Exceptions\NoResult;
}
function restore(CallRerouting\Handle $handle)
{
$handle->expire();
}
function restoreAll()
{
CallRerouting\disconnectAll();
}
function silence(CallRerouting\Handle $handle)
{
$handle->silence();
}
function assertEventuallyDefined(CallRerouting\Handle $handle)
{
$handle->unsilence();
}
function getClass()
{
return Stack\top('class');
}
function getCalledClass()
{
return Stack\topCalledClass();
}
function getFunction()
{
return Stack\top('function');
}
function getMethod()
{
return getClass() . '::' . getFunction();
}
function configure()
{
Config\locate();
}
function hasMissed($callable)
{
return Utils\callableWasMissed($callable);
}
function always($value)
{
return function() use ($value) {
return $value;
};
}
Utils\alias('Patchwork', [
'redefine' => ['replace', 'replaceLater'],
'relay' => 'callOriginal',
'fallBack' => 'pass',
'restore' => 'undo',
'restoreAll' => 'undoAll',
]);
configure();
Utils\markMissedCallables();
CodeManipulation\Stream::discoverOtherWrapper();
CodeManipulation\Stream::wrap();
CodeManipulation\register([
CodeManipulation\Actions\CodeManipulation\propagateThroughEval(),
CodeManipulation\Actions\CallRerouting\injectCallInterceptionCode(),
CodeManipulation\Actions\RedefinitionOfInternals\spliceNamedFunctionCalls(),
CodeManipulation\Actions\RedefinitionOfInternals\spliceDynamicCalls(),
CodeManipulation\Actions\RedefinitionOfNew\spliceAllInstantiations,
CodeManipulation\Actions\RedefinitionOfNew\publicizeConstructors,
CodeManipulation\Actions\ConflictPrevention\preventImportingOtherCopiesOfPatchwork(),
]);
CodeManipulation\onImport([
CodeManipulation\Actions\CallRerouting\markPreprocessedFiles(),
]);
Utils\clearOpcodeCaches();
register_shutdown_function('Patchwork\Utils\clearOpcodeCaches');
CallRerouting\createStubsForInternals();
CallRerouting\connectDefaultInternals();
require __DIR__ . '/src/Redefinitions/LanguageConstructs.php';
CodeManipulation\register([
CodeManipulation\Actions\RedefinitionOfLanguageConstructs\spliceAllConfiguredLanguageConstructs(),
CodeManipulation\Actions\CallRerouting\injectQueueDeploymentCode(),
CodeManipulation\Actions\CodeManipulation\injectStreamWrapperReinstatementCode(),
]);
if (Utils\wasRunAsConsoleApp()) {
require __DIR__ . '/src/Console.php';
}