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,97 @@
<?php
class BWFCRM_Api_Create_Fields extends BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function default_args_values() {
$args = array(
'group_id' => '',
'field' => [],
);
return $args;
}
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::CREATABLE;
$this->route = '/fields';
$this->response_code = 200;
}
public function process_api_call() {
/**
* getting post data
*/
$field = $this->get_sanitized_arg( '', 'text_field', $this->args['field'] );
$group_id = $this->get_sanitized_arg( 'group_id', 'text_field' );
$group_id = ! empty( $group_id ) && is_numeric( $group_id ) ? $group_id : 0;
if ( empty( $field['name'] ) ) {
$this->response_code = 400;
return $this->error_response( __( 'Field name is mandatory', 'wp-marketing-automations-pro' ) );
}
/** Checking field slug is reserved key or not */
if ( in_array( sanitize_title( $field['name'] ), BWFCRM_Fields::$reserved_keys, true ) ) {
$this->response_code = 400;
return $this->error_response( __( sanitize_title( $field['name'] ) . ' is a reserved key', 'wp-marketing-automations-pro' ) );
}
/**
* Check group exist.
*/
$group = BWFCRM_Group::get_groupby_id( $group_id );
if ( $group_id > 0 && empty( $group ) ) {
$this->response_code = 400;
return $this->error_response( __( 'Field Group ID ' . $group_id . ' is mandatory', 'wp-marketing-automations-pro' ) );
}
if ( empty( $field['type'] ) ) {
$this->response_code = 400;
return $this->error_response( __( 'Field type is mandatory', ' autonami-automations-pro' ) );
}
$field_name = $field['name'];
$type = $field['type'];
$mode = isset( $field['mode'] ) ? absint( $field['mode'] ) : 1;
$vmode = isset( $field['vmode'] ) ? absint( $field['vmode'] ) : 1;
$search = isset( $field['search'] ) ? absint( $field['search'] ) : 1;
if ( ! empty( $this->args['field']['options'] ) ) {
$options = $this->get_sanitized_arg( '', 'text_field', $this->args['field']['options'] );
}
$options = ! empty( $options ) && is_array( $options ) ? $options : [];
$placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
$field = BWFCRM_Fields::add_field( $field_name, $type, $options, $placeholder, $mode, $vmode, $search, $group_id );
if ( is_wp_error( $field ) ) {
return $this->error_response( '', $field, $field->get_error_code() );
}
if ( isset( $field['err_msg'] ) ) {
$this->response_code = 400;
return $this->error_response( __( 'Cannot create a field. Error: ' . $field['err_msg'] . '. Contact Funnelkit support.', ' autonami-automations-pro' ) );
}
$field['merge_tag'] = BWFCRM_Core()->merge_tags->get_field_tag( $field['slug'] );
return $this->success_response( $field, __( 'Field created', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Create_Fields' );

View File

@@ -0,0 +1,48 @@
<?php
class BWFCRM_Api_Delete_Field extends BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::DELETABLE;
$this->route = '/fields/(?P<field_id>[\\d]+)';
$this->response_code = 200;
}
public function default_args_values() {
$args = array(
'field_id' => ''
);
return $args;
}
public function process_api_call() {
$field_id = $this->get_sanitized_arg( 'field_id', 'text_field' );
$delete_field = BWFCRM_Fields::delete_field( $field_id );
if ( 0 === $delete_field ) {
$this->response_code = 400;
return $this->error_response( __( 'Unable to delete field with id #' . $field_id, 'wp-marketing-automations-pro' ) );
}
return $this->success_response( __( 'Field deleted', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Delete_Field' );

View File

@@ -0,0 +1,77 @@
<?php
class BWFCRM_Api_Get_All_Fields extends BWFCRM_API_Base {
public static $ins;
public $total_count = 0;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/all/fields';
$this->response_code = 200;
}
public function process_api_call() {
$all_fields = BWFCRM_Fields::get_fields( '', 1 );
if ( isset( $all_fields['creation_date'] ) ) {
unset( $all_fields['creation_date'] );
}
$fields = $all_fields;
$select_fields = [ 'timezone', 'status', 'country' ];
$statuses = [];
if ( method_exists( 'BWFAN_Common', 'get_contact_status_array_list' ) ) {
$status = BWFAN_Common::get_contact_status_array_list();
foreach ( $status as $key => $value ) {
$statuses[ $key ] = $value['name'];
}
} else {
$statuses = array(
'0' => 'Unverified',
'1' => 'Subscribed',
'3' => 'Unsubscribed',
'2' => 'Bounced',
);
}
$all_fields = array_map( function ( $field ) use ( $fields, $select_fields, $statuses ) {
if ( ! is_array( $field ) ) {
$field_id = array_search( $field, $fields );
$field = [
'group_id' => 0,
'ID' => $field_id,
'type' => in_array( $field_id, $select_fields ) ? 4 : 1,
'name' => $field,
'meta' => [],
];
if ( 'status' === $field_id ) {
$field['meta']['options'] = $statuses;
}
}
return $field;
}, $all_fields );
$this->total_count = count( $all_fields );
return $this->success_response( $all_fields, __( empty( $all_fields ) ? 'No Fields found.' : 'Got all fields', 'wp-marketing-automations-pro' ) );
}
public function get_result_total_count() {
return $this->total_count;
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Get_All_Fields' );

View File

@@ -0,0 +1,45 @@
<?php
class BWFCRM_Api_Get_Fields extends BWFCRM_API_Base
{
public static $ins;
public $total_count = 0;
public function __construct()
{
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/fields';
$this->response_code = 200;
}
public static function get_instance()
{
if (null === self::$ins) {
self::$ins = new self();
}
return self::$ins;
}
public function process_api_call()
{
$type = isset($this->args['type']) ? $this->get_sanitized_arg('type', 'text_field', $this->args['type']) : null;
$all_fields = isset($this->args['all']) ? $this->get_sanitized_arg('all', 'text_field', $this->args['all']) : false;
$fields = BWFCRM_Fields::get_custom_fields( null, $all_fields ? 1 : null, null, $all_fields ? false : true, $all_fields ? null : 1, $type);
$fields = BWFAN_PRO_Common::get_sorted_fields( $fields );
$this->total_count = count($fields);
return $this->success_response($fields, __(empty($fields) ? 'No Fields found.' : 'Got all fields', 'wp-marketing-automations-pro'));
}
public function get_result_total_count()
{
return $this->total_count;
}
}
BWFCRM_API_Loader::register('BWFCRM_Api_Get_Fields');

View File

@@ -0,0 +1,98 @@
<?php
class BWFCRM_Api_Update_Field extends BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::EDITABLE;
$this->route = '/fields/(?P<field_id>[\\d]+)';
$this->response_code = 200;
}
public function default_args_values() {
$args = array(
'group_id' => '',
'name' => '',
'type' => '',
'slug' => '',
'options' => [],
'placeholder' => '',
);
return $args;
}
public function process_api_call() {
$field_id = $this->get_sanitized_arg( 'field_id', 'text_field' );
$group_id = $this->get_sanitized_arg( 'group_id', 'text_field' );
$group_id = ! empty( $group_id ) && is_numeric( $group_id ) ? $group_id : 0;
if ( empty( $field_id ) ) {
$this->response_code = 400;
$response = __( "Field Id is missing", 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
$slug = $this->get_sanitized_arg( 'slug', 'text_field' );
/** Checking field slug is reserved key or not */
if ( in_array( sanitize_title( $slug ), BWFCRM_Fields::$reserved_keys, true ) ) {
$this->response_code = 400;
return $this->error_response( __( sanitize_title( $slug ) . ' is a reserved key', 'wp-marketing-automations-pro' ) );
}
$group = BWFCRM_Group::get_groupby_id( $group_id );
if ( $group_id > 0 && empty( $group ) ) {
$this->response_code = 400;
return $this->error_response( __( 'Field Group ID ' . $group_id . ' is mandatory', 'wp-marketing-automations-pro' ) );
}
if ( ! isset( $this->args['group_id'] ) ) {
$group_id = false;
}
$field_name = $this->get_sanitized_arg( 'name', 'text_field' );
$type = $this->get_sanitized_arg( 'type', 'text_field' );
$options = $this->get_sanitized_arg( '', 'text_field', $this->args['options'] );
$placeholder = $this->get_sanitized_arg( 'placeholder', 'text_field' );
$mode = $this->get_sanitized_arg( 'mode', 'text_field' );
$vmode = $this->get_sanitized_arg( 'vmode', 'text_field' );
$search = $this->get_sanitized_arg( 'search', 'text_field' );
if ( empty( $slug ) ) {
$this->response_code = 400;
return $this->error_response( __( 'Field slug is mandatory', 'wp-marketing-automations-pro' ) );
}
$update_field = BWFCRM_Fields::update_field( $field_id, $group_id, $field_name, $type, $options, $placeholder, $slug, $mode, $vmode, $search );
$this->response_code = $update_field['status'];
if ( $update_field['status'] == 404 ) {
return $this->error_response( $update_field['message'] );
}
$field = BWFAN_Model_Fields::get( $field_id );
$meta = json_decode( $field['meta'] );
$field['meta'] = $meta;
$field['merge_tag'] = BWFCRM_Core()->merge_tags->get_field_tag( $slug );
return $this->success_response( $field, __( 'Field updated', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Update_Field' );

View File

@@ -0,0 +1,3 @@
<?php
//silence is golden