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,42 @@
<?php
class BWFAN_API_Get_Recipes extends BWFAN_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public $total_count = 0;
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/recipes';
}
public function default_args_values() {
$args = [];
return $args;
}
public function process_api_call() {
$recipe_sync = $this->get_sanitized_arg( 'sync' );
$all_recipes = BWFAN_Recipe_Loader::get_recipes_array( $recipe_sync == 'true' ? true : false );
$this->response_code = 200;
$this->total_count = is_array( $all_recipes ) ? count( $all_recipes ) : 0;
return $this->success_response( $all_recipes, __( 'Recipes found', 'wp-marketing-automations' ) );
}
public function get_result_total_count() {
return $this->total_count;
}
}
BWFAN_API_Loader::register( 'BWFAN_API_Get_Recipes' );

View File

@@ -0,0 +1,61 @@
<?php
class BWFAN_API_Get_Automation_Recipe extends BWFAN_API_Base {
public static $ins;
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/automation/recipe/';
}
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function process_api_call() {
$recipe_slug = $this->get_sanitized_arg( 'recipe_slug' );
if ( empty( $recipe_slug ) ) {
return $this->error_response( __( 'Invalid / Empty automation ID provided', 'wp-marketing-automations' ), null, 400 );
}
/** Fetch Recipe data */
$recipe_data = $this->get_selected_recipe( $recipe_slug );
if ( empty( $recipe_data ) ) {
return $this->error_response( __( 'Recipe not found.', 'wp-marketing-automations' ), null, 400 );
}
$this->response_code = 200;
return $this->success_response( $recipe_data, ! empty( $automation_data['message'] ) ? $automation_data['message'] : __( 'Recipes found', 'wp-marketing-automations' ) );
}
/**
* @param $slug recipe slug
*
* @return void
*/
public function get_selected_recipe( $slug ) {
$request = wp_remote_get( "https://app.getautonami.com/recipe/$slug" );
if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
return false;
}
$data = wp_remote_retrieve_body( $request );
if ( isset( $data['error'] ) ) {
return false;
}
return json_decode( $data, true );
}
}
BWFAN_API_Loader::register( 'BWFAN_API_Get_Automation_Recipe' );

View File

@@ -0,0 +1,87 @@
<?php
class BWFAN_API_Import_Automation_Recipe extends BWFAN_API_Base {
public static $ins;
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/automation/recipe/import';
}
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function process_api_call() {
$recipe_slug = $this->get_sanitized_arg( 'recipe_slug' );
$automation_title = $this->get_sanitized_arg( 'title', 'text_field' );
if ( empty( $recipe_slug ) ) {
return $this->error_response( __( 'Invalid / Empty automation ID provided', 'wp-marketing-automations' ), null, 400 );
}
/** Fetch Recipe data */
$recipe_data = $this->get_selected_recipe( $recipe_slug );
if ( empty( $recipe_data ) ) {
return $this->error_response( __( 'Recipe not found', 'wp-marketing-automations' ), null, 400 );
}
/** Check dependencies */
if ( isset( $recipe_data['dependencies'] ) && ! empty( $recipe_data['dependencies'] ) ) {
/** Validate the recipe dependencies */
$dependency = new BWFAN_Recipe_Dependency();
$dependency->set_data( $recipe_data['dependencies'] );
$result = $dependency->validate();
if ( true !== $result ) {
return $this->error_response( $result, null, 400 );
}
}
/** Set blank if not available */
$recipe_data['tips'] = ( isset( $recipe_data['tips'] ) && count( $recipe_data['tips'] ) > 0 ) ? $recipe_data['tips'] : [];
/**
* Import automation
*/
$automation_id = 0;
if ( isset( $recipe_data['import'] ) && ! empty( $recipe_data['import'] ) ) {
$automation_id = BWFAN_Core()->automations->import( $recipe_data['import'], $automation_title, $recipe_data['tips'], true );
if ( empty( $automation_id ) ) {
return $this->error_response( '', null, 400 );
}
}
$this->response_code = 200;
return $this->success_response( [ 'automation_id' => $automation_id ], __( 'Recipe imported', 'wp-marketing-automations' ) );
}
/**
* @param $slug recipe slug
*
* @return void
*/
public function get_selected_recipe( $slug ) {
$request = wp_remote_get( "https://app.getautonami.com/recipe/$slug" );
if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
return false;
}
$data = json_decode( wp_remote_retrieve_body( $request ), true );
if ( isset( $data['error'] ) ) {
return false;
}
return $data;
}
}
BWFAN_API_Loader::register( 'BWFAN_API_Import_Automation_Recipe' );