Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace WPDRMS\ASP\Rest;
use WP_Error;
use WPDRMS\ASP\Patterns\SingletonTrait;
/**
* Options Rest service
*
* NONCE verification is NOT needed, as authentication is done via the X-WP-Nonce header automatically.
* It is sufficient to check the user status to properly authenticate in the permission callback.
*/
abstract class AbstractRest implements RestInterface {
use SingletonTrait;
/**
* A permission callback to restrict rest request to logged in users only
*
* @return true|WP_Error
*/
public function allowOnlyLoggedIn() {
if ( !is_user_logged_in() ) {
return new WP_Error( 'rest_forbidden', esc_html__( 'Only logged in users can access this resource.' ), array( 'status' => 401 ) );
}
return true;
}
/**
* A permission callback to restrict rest request to administrator users only
*
* @return true|WP_Error
*/
public function allowOnlyAdmins() {
if ( ! current_user_can( 'manage_options' ) ) {
return new WP_Error( 'rest_forbidden', esc_html__( 'Only administrators can access this resource.' ), array( 'status' => 401 ) );
}
return true;
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace WPDRMS\ASP\Rest;
interface RestInterface {
/**
* @return self
*/
public static function instance();
public function registerRoutes(): void;
}

View File

@@ -0,0 +1,47 @@
<?php
namespace WPDRMS\ASP\Rest;
use WP_Error;
use WP_REST_Request;
use WP_REST_Response;
use WPDRMS\ASP\Modal\Factories\ModalFactory;
use WPDRMS\ASP\Modal\Services\TimedModalService;
class TimedModalRoutes extends AbstractRest {
public function registerRoutes(): void {
register_rest_route(
ASP_DIR,
'timed_modal/get',
array(
'methods' => 'GET',
'callback' => array(
$this,
'getTimedModal',
),
'permission_callback' => array(
$this,
'allowOnlyAdmins',
),
)
);
}
/**
* @param WP_REST_Request $request
* @return WP_REST_Response
*/
public function getTimedModal( WP_REST_Request $request ): WP_REST_Response {
try {
return new WP_REST_Response(
TimedModalService::instance(new ModalFactory())->get(),
200
);
} catch ( \Exception $e ) {
return new WP_REST_Response(
new WP_Error('save_options', $e->getMessage()),
400
);
}
}
}