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,76 @@
<?php
/**
* Bulk Action Clone API file
*
* @package BWFCRM_API_Base
*/
/**
* Bulk Action Clone API class
*/
class BWFCRM_API_Clone_Bulk_Action extends BWFCRM_API_Base {
/**
* BWFCRM_Core obj
*
* @var BWFCRM_Core
*/
public static $ins;
/**
* Return class instance
*/
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
/**
* Class constructor
*/
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/bulk-action/(?P<id>[\\d]+)/clone';
$this->request_args = array(
'id' => array(
'description' => __( 'Bulk action ID whose data to be cloned.', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
}
/**
* Default arg.
*/
public function default_args_values() {
return array(
'id' => 0,
);
}
/**
* API callback
*/
public function process_api_call() {
$id = $this->get_sanitized_arg( 'id', 'key' );
if ( intval( $id ) > 0 ) {
$data = BWFAN_Model_Bulk_Action::clone_bulk_action( $id );
$this->response_code = $data['status'];
if ( $data['status'] === 200 ) {
return $this->success_response( [], $data['message'] );
}
return $this->error_response( $data['message'] );
}
$this->response_code = 404;
return $this->error_response( __( 'Please provide a valid bulk action id.', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Clone_Bulk_Action' );

View File

@@ -0,0 +1,144 @@
<?php
/**
* Create bulk action API
*/
class BWFCRM_Api_Create_Bulk_Action 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::CREATABLE;
$this->route = '/bulk-action';
$this->response_code = 200;
}
public function default_args_values() {
return array(
'title' => '',
);
}
public function process_api_call() {
$title = $this->get_sanitized_arg( 'title', 'text_field', $this->args['title'] );
$only_action = isset( $this->args['only_action'] ) && boolval( $this->args['only_action'] );
$include_ids = isset( $this->args['include_ids'] ) && ! empty( $this->args['include_ids'] ) ? $this->args['include_ids'] : [];
$actions = isset( $this->args['actions'] ) && ! empty( $this->args['actions'] ) ? $this->args['actions'] : [];
if ( empty( $title ) && ! $only_action ) {
$this->response_code = 400;
$response = __( 'Oops Title not entered, enter title to create bulk action', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
$already_exists = ! $only_action ? BWFAN_Model_Bulk_Action::check_bulk_action_exists_with( 'title', $title ) : false;
if ( $already_exists ) {
$this->response_code = 400;
$response = __( 'Bulk Action already exists with title : ', 'wp-marketing-automations-pro' ) . $title;
return $this->error_response( $response );
}
$utc_time = current_time( 'mysql', 1 );
$store_time = current_time( 'mysql' );
$data = [
'title' => $only_action ? __( 'Contacts Bulk Action ', 'wp-marketing-automation-pro' ) . '(' . $store_time . ')' : $title,
'status' => 0,
'created_by' => get_current_user_id(),
'created_at' => $utc_time,
'updated_at' => $utc_time,
];
if ( $only_action ) {
if ( empty( $actions ) ) {
$this->response_code = 400;
$response = __( 'Oops Actions not entered, enter actions to create bulk action', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
/** Check for directory exists */
if ( ! file_exists( BWFCRM_BULK_ACTION_LOG_DIR . '/' ) ) {
wp_mkdir_p( BWFCRM_BULK_ACTION_LOG_DIR );
}
/** Create log file */
$file_name = 'FKA-Bulk-Action-' . time() . '-' . wp_generate_password( 5, false ) . '-log.csv';
/** Open log file */
$file = fopen( BWFCRM_BULK_ACTION_LOG_DIR . '/' . $file_name, "wb" );
if ( ! empty( $file ) ) {
/** Updating headers in log file */
fputcsv( $file, array_merge( [ 'Contact ID' ], array_keys( $actions ) ) );
/** Close log file */
fclose( $file );
}
$enable_automation = isset( $this->args['enable_automation'] ) && boolval( $this->args['enable_automation'] );
$data['actions'] = json_encode( $this->add_new_list_and_tags( $actions ) );
$data['status'] = 1;
$data['count'] = count( $include_ids );
// Set meta data
$data['meta']['include_ids'] = $include_ids;
$data['meta']['log_file'] = $file_name;
$data['meta']['enable_automation_run'] = $enable_automation;
$data['meta'] = json_encode( $data['meta'] );
}
$result = BWFAN_Model_Bulk_Action::bwfan_create_new_bulk_action( $data );
if ( empty( $result ) ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to create bulk action', 'wp-marketing-automations-pro' ) );
}
if ( $only_action ) {
BWFCRM_Core()->bulk_action->schedule_bulk_action( $result );
}
return $this->success_response( [ 'id' => $result ], __( 'Bulk action created', 'wp-marketing-automations-pro' ) );
}
/**
* Create tags and list
*
* @param $actions
*
* @return array
*/
public function add_new_list_and_tags( $actions ) {
foreach ( $actions as $action_key => $action_val ) {
$terms = [];
$term_type = 0;
if ( $action_key === 'add_tags' ) {
$term_type = BWFCRM_Term_Type::$TAG;
$terms = $action_val;
} else if ( $action_key === 'add_to_lists' ) {
$term_type = BWFCRM_Term_Type::$LIST;
$terms = $action_val;
}
if ( is_array( $terms ) && ! empty( $terms ) && method_exists( 'BWFAN_PRO_Common', 'get_or_create_terms' ) ) {
$terms = BWFAN_PRO_Common::get_or_create_terms( $terms, $term_type );
$actions[ $action_key ] = $terms;
}
}
return $actions;
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Create_Bulk_Action' );

View File

@@ -0,0 +1,52 @@
<?php
class BWFCRM_Api_Delete_Bulk_Action 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 = '/bulk-actions/delete';
}
public function default_args_values() {
return array(
'ids' => [],
);
}
public function process_api_call() {
$ids = $this->args['ids'];
if ( empty( $ids ) || ! is_array( $ids ) ) {
return $this->error_response( __( 'Bulk actions ids are missing.', 'wp-marketing-automations-pro' ), null, 500 );
}
/** delete actions */
$deleted = BWFAN_Model_Bulk_Action::delete_multiple_bulk_actions( $ids );
if ( false === $deleted ) {
$this->response_code = 404;
$response = __( 'Unable to delete the bulk actions', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
$this->response_code = 200;
$success_message = __( 'Bulk action deleted', 'wp-marketing-automations-pro' );
return $this->success_response( [], $success_message );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Delete_Bulk_Action' );

View File

@@ -0,0 +1,76 @@
<?php
class BWFCRM_API_Download_Log_File 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::READABLE;
$this->route = 'bulk-action/download/(?P<bulk_action_id>[\\d]+)';
}
public function process_api_call() {
$bulk_action_id = absint( $this->get_sanitized_arg( 'bulk_action_id' ) );
if ( empty( $bulk_action_id ) ) {
$this->response_code = 404;
return $this->error_response( __( 'Invalid Bulk Action ID', 'wp-marketing-automations-pro' ) );
}
$action_data = BWFAN_Model_Bulk_Action::bwfan_get_bulk_action( $bulk_action_id );
if ( ! isset( $action_data['log_file'] ) ) {
$this->response_code = 404;
return $this->error_response( __( 'Log file url is missing', 'wp-marketing-automations-pro' ) );
}
$filename = BWFCRM_BULK_ACTION_LOG_DIR . '/' . $action_data['log_file'];
if ( ! file_exists( $filename ) ) {
$filename = BWFCRM_BULK_ACTION_LOG_DIR_BACKUP . '/' . $action_data['log_file'];
}
if ( ! file_exists( $filename ) ) {
wp_die();
}
// Define header information
header( 'Content-Description: File Transfer' );
header( 'Content-Type: application/octet-stream' );
header( 'Cache-Control: no-cache, must-revalidate' );
header( 'Expires: 0' );
header( 'Content-Disposition: attachment; filename="' . basename( $filename ) . '"' );
header( 'Content-Length: ' . filesize( $filename ) );
header( 'Pragma: public' );
// Clear system output buffer
flush();
// Read the size of the file
readfile( $filename );
exit;
}
/**
* Rest api permission callback
*
* @return bool
*/
public function rest_permission_callback( WP_REST_Request $request ) {
$query_params = $request->get_query_params();
if ( isset( $query_params['bwf-nonce'] ) && $query_params['bwf-nonce'] === get_option( 'bwfan_unique_secret', '' ) ) {
return true;
}
return false;
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Download_Log_File' );

View File

@@ -0,0 +1,61 @@
<?php
/**
* Get Bulk Action Status API
*/
class BWFCRM_Api_Get_Bulk_Action_Status 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::READABLE;
$this->route = '/bulk-action/status/(?P<bulk_action_id>[\\d]+)';
$this->request_args = array(
'bulk_action_id' => array(
'description' => __( 'Bulk Action ID to retrieve', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
}
/**
* Process API Call
*
* @return WP_Error|WP_HTTP_Response|WP_REST_Response
*/
public function process_api_call() {
$id = $this->get_sanitized_arg( 'bulk_action_id' );
if ( empty( $id ) ) {
return $this->error_response( __( 'Invalid / Empty bulk action ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
/** Check for bulk action entry */
$data = BWFAN_Model_Bulk_Action::bwfan_get_bulk_action( $id );
if ( empty( $data ) ) {
return $this->error_response( __( 'Bulk Action not found with provided ID', 'wp-marketing-automations-pro' ), null, 400 );
}
/** Get bulk action status */
$action_status = BWFCRM_Core()->bulk_action->get_bulk_action_status( $id );
if ( empty( $action_status ) ) {
return $this->error_response( __( 'Bulk Action data to found with provided ID.', 'wp-marketing-automations-pro' ), null, 400 );
}
$this->response_code = 200;
return $this->success_response( $action_status );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Get_Bulk_Action_Status' );

View File

@@ -0,0 +1,87 @@
<?php
/**
* Get Bulk Action API
*/
class BWFCRM_Api_Get_Bulk_Action 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::READABLE;
$this->route = '/bulk-action/(?P<bulk_action_id>[\\d]+)';
$this->request_args = array(
'bulk_action_id' => array(
'description' => __( 'Bulk Action ID to retrieve', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
}
public function process_api_call() {
$bulk_action_id = $this->get_sanitized_arg( 'bulk_action_id' );
if ( empty( $bulk_action_id ) ) {
return $this->error_response( __( 'Invalid / Empty bulk action ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
$data = BWFAN_Model_Bulk_Action::bwfan_get_bulk_action( $bulk_action_id );
if ( empty( $data ) ) {
return $this->error_response( __( 'Bulk Action not found with provided ID', 'wp-marketing-automations-pro' ), null, 400 );
}
/** Fetch updated list */
if ( isset( $data['actions']['add_to_lists'] ) ) {
$data['actions']['add_to_lists'] = BWFAN_Common::get_updated_tags_and_list( $data['actions']['add_to_lists'] );
}
/** Fetch updated Tags */
if ( isset( $data['actions']['add_tags'] ) ) {
$data['actions']['add_tags'] = BWFAN_Common::get_updated_tags_and_list( $data['actions']['add_tags'] );
}
$response = [
'data' => $data,
'actions' => $this->format_action_array( BWFCRM_Core()->actions->get_all_action_list( 2 ) ),
'action_schema' => BWFCRM_Core()->actions->get_all_actions_schema_data(),
'group_data' => BWFCRM_Core()->actions->get_group_list(),
];
$this->response_code = 200;
return $this->success_response( $response );
}
/**
* Format the action data
*
* @param $actions
*
* @return array|array[]
*/
public function format_action_array( $actions ) {
if ( empty( $actions ) ) {
return [];
}
return array_map( function ( $slug, $nice_name ) {
return [
'value' => $slug,
'label' => $nice_name,
];
}, array_keys( $actions ), $actions );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Get_Bulk_Action' );

View File

@@ -0,0 +1,90 @@
<?php
/**
* Get bulk action API
*/
class BWFCRM_Api_Get_Bulk_Actions extends BWFCRM_API_Base {
public static $ins;
public $total_count = 0;
public $count_data = [];
public $extra_data = [];
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 = '/bulk-actions';
}
/**
* Set default Values
*
* @return string[]
*/
public function default_args_values() {
return array( 's' => '' );
}
/**
* API call handler
*
* @return WP_Error|WP_HTTP_Response|WP_REST_Response
*/
public function process_api_call() {
$search = ! empty( $this->get_sanitized_arg( 'search', 'key' ) ) ? $this->get_sanitized_arg( 'search', 'text_field' ) : '';
$offset = ! empty( $this->get_sanitized_arg( 'offset', 'key' ) ) ? $this->get_sanitized_arg( 'offset', 'text_field' ) : 0;
$limit = ! empty( $this->get_sanitized_arg( 'limit', 'key' ) ) ? $this->get_sanitized_arg( 'limit', 'text_field' ) : 0;
$status = ! empty( $this->get_sanitized_arg( 'status', 'key' ) ) ? $this->get_sanitized_arg( 'status', 'text_field' ) : '';
$ids = empty( $this->args['ids'] ) ? array() : explode( ',', $this->args['ids'] );
/**
* Get bulk action data
*/
$bulk_action_data = BWFAN_Model_Bulk_Action::get_bulk_actions( $search, $status, $limit, $offset, true, $ids );
$bulk_actions = isset( $bulk_action_data['list'] ) ? $bulk_action_data['list'] : [];
$this->total_count = isset( $bulk_action_data['total'] ) ? intval( $bulk_action_data['total'] ) : 0;
$this->extra_data['total'] = BWFAN_PRO_Common::get_bulk_actions_data_count();
$this->extra_data['actions'] = ( array ) BWFCRM_Core()->actions->get_all_action_list( 2 );
$this->count_data = BWFAN_PRO_Common::get_contact_data_counts();
$this->response_code = 200;
return $this->success_response( $bulk_actions );
}
/**
* Returns total count
*
* @return int
*/
public function get_result_total_count() {
return $this->total_count;
}
/**
* Returns extra data
*
* @return array|int
*/
public function get_result_extra_data() {
return $this->extra_data;
}
/**
* Returns bulk action count based on status
*
* @return array|int
*/
public function get_result_count_data() {
return $this->count_data;
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Get_Bulk_Actions' );

View File

@@ -0,0 +1,72 @@
<?php
/**
* Update bulk action status API
*/
class BWFCRM_Api_Update_Bulk_Action_Status 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::CREATABLE;
$this->route = '/bulk-action/(?P<bulk_action_id>[\\d]+)/update-status';
$this->request_args = array(
'bulk_action_id' => array(
'description' => __( 'Bulk Action ID to update', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
$this->response_code = 200;
}
public function process_api_call() {
$bulk_action_id = $this->get_sanitized_arg( 'bulk_action_id' );
$status = $this->get_sanitized_arg( 'status', 'text_field', $this->args['status'] );
if ( empty( $bulk_action_id ) ) {
return $this->error_response( __( 'Invalid / Empty bulk action ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
$data = BWFAN_Model_Bulk_Action::bwfan_get_bulk_action( $bulk_action_id, false );
if ( empty( $data ) ) {
return $this->error_response( __( 'Bulk Action not found with provided ID', 'wp-marketing-automations-pro' ), null, 400 );
}
$data['updated_at'] = current_time( 'mysql', 1 );
if ( isset( $data['status'] ) ) {
$data['status'] = intval( $status );
}
$result = BWFAN_Model_Bulk_Action::update_bulk_action_data( $bulk_action_id, $data );
if ( intval( $status ) === 3 && ! empty( $result ) ) {
if ( bwf_has_action_scheduled( 'bwfcrm_bulk_action_process', array( 'bulk_action_id' => absint( $bulk_action_id ) ), 'bwfcrm' ) ) {
bwf_unschedule_actions( 'bwfcrm_bulk_action_process', array( 'bulk_action_id' => absint( $bulk_action_id ) ), 'bwfcrm' );
}
}
if ( intval( $status ) === 1 && ! empty( $result ) ) {
BWFCRM_Core()->bulk_action->schedule_bulk_action( $bulk_action_id );
}
if ( empty( $result ) ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to update bulk action status', 'wp-marketing-automations-pro' ) );
}
return $this->success_response( [ 'id' => $result ], __( 'Successfully updated bulk action status', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Update_Bulk_Action_Status' );

View File

@@ -0,0 +1,179 @@
<?php
/**
* Update bulk action API
*/
class BWFCRM_Api_Update_Bulk_Action 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 = '/bulk-action/(?P<bulk_action_id>[\\d]+)';
$this->response_code = 200;
}
public function default_args_values() {
return array(
'bulk_action_id' => '',
'count' => 0,
);
}
public function process_api_call() {
$bulk_action_id = $this->get_sanitized_arg( 'bulk_action_id', 'key' );
$title = $this->get_sanitized_arg( 'title', 'text_field', $this->args['title'] );
$created_at = isset( $this->args['created_at'] ) ? $this->args['created_at'] : '';
if ( empty( $created_at ) ) {
/** Title update call */
BWFAN_Model_Bulk_Action::update_bulk_action_data( $bulk_action_id, [ 'title' => $title ] );
$data = BWFAN_Model_Bulk_Action::bwfan_get_bulk_action( $bulk_action_id );
return $this->success_response( $data, __( 'Bulk action updated', 'wp-marketing-automations-pro' ) );
}
$count = $this->get_sanitized_arg( 'count', 'text_field', $this->args['count'] );
$actions = isset( $this->args['actions'] ) && ! empty( $this->args['actions'] ) ? $this->args['actions'] : [];
$contact_filters = isset( $this->args['contactFilters'] ) && ! empty( $this->args['contactFilters'] ) ? $this->args['contactFilters'] : [];
$exclude_ids = isset( $this->args['exclude_ids'] ) && ! empty( $this->args['exclude_ids'] ) ? $this->args['exclude_ids'] : [];
$include_ids = isset( $this->args['include_ids'] ) && ! empty( $this->args['include_ids'] ) ? $this->args['include_ids'] : [];
$start_bulk_action = isset( $this->args['start_bulk_action'] ) && boolval( $this->args['start_bulk_action'] );
$stop_bulk_action = isset( $this->args['stop_bulk_action'] ) && boolval( $this->args['stop_bulk_action'] );
$file_name = isset( $this->args['log_file'] ) && boolval( $this->args['log_file'] );
$enable_automation_run = isset( $this->args['enable_automation_run'] ) && boolval( $this->args['enable_automation_run'] );
$meta = [];
if ( empty( $title ) ) {
$this->response_code = 400;
$response = __( 'Oops Title not entered, enter title to save bulk action', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
$already_exists = BWFAN_Model_Bulk_Action::check_bulk_action_exists_with( 'ID', $bulk_action_id );
if ( ! $already_exists ) {
$this->response_code = 400;
$response = __( "Bulk Action doesn't exists with id : ", 'wp-marketing-automations-pro' ) . $bulk_action_id;
return $this->error_response( $response );
}
$update_time = current_time( 'mysql', 1 );
$meta['contactFilters'] = $contact_filters;
$meta['exclude_ids'] = $exclude_ids;
$meta['include_ids'] = $include_ids;
$meta['enable_automation_run'] = $enable_automation_run;
$actions = $this->add_new_list_and_tags( $actions );
$link_data = [
'title' => $title,
'count' => intval( $count ) > 0 ? $count : 0,
'actions' => json_encode( $actions ),
'updated_at' => $update_time,
];
if ( $start_bulk_action ) {
$link_data['status'] = 1;
/** Check if file already exists */
if ( empty( $file_name ) ) {
/** Check for directory exists */
if ( ! file_exists( BWFCRM_BULK_ACTION_LOG_DIR . '/' ) ) {
wp_mkdir_p( BWFCRM_BULK_ACTION_LOG_DIR );
}
/** Create log file */
$file_name = 'FKA-Bulk-Action-' . time() . '-' . wp_generate_password( 5, false ) . '-log.csv';
/** Open log file */
$file = fopen( BWFCRM_BULK_ACTION_LOG_DIR . '/' . $file_name, "wb" );
if ( ! empty( $file ) ) {
/** Updating headers in log file */
fputcsv( $file, array_merge( [ 'Contact ID' ], array_keys( $actions ) ) );
/** Close log file */
fclose( $file );
}
}
$meta['log_file'] = $file_name;
}
if ( $stop_bulk_action ) {
$link_data['status'] = 3;
if ( bwf_has_action_scheduled( 'bwfcrm_bulk_action_process', array( 'bulk_action_id' => absint( $bulk_action_id ) ), 'bwfcrm' ) ) {
bwf_unschedule_actions( 'bwfcrm_bulk_action_process', array( 'bulk_action_id' => absint( $bulk_action_id ) ), 'bwfcrm' );
}
}
$link_data['meta'] = json_encode( $meta );
/** Updating db entry for bulk action */
$result = BWFAN_Model_Bulk_Action::update_bulk_action_data( $bulk_action_id, $link_data );
/** Error handle */
if ( empty( $result ) ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to update bulk action', 'wp-marketing-automations-pro' ) );
}
/** Schedule action */
if ( $start_bulk_action ) {
BWFCRM_Core()->bulk_action->schedule_bulk_action( $bulk_action_id );
}
/** Get bulk action data to return */
$data = BWFAN_Model_Bulk_Action::bwfan_get_bulk_action( $bulk_action_id );
if ( empty( $data ) ) {
return $this->error_response( __( 'Bulk Action not found with provided ID', 'wp-marketing-automations-pro' ), null, 400 );
}
/** Set success response */
return $this->success_response( $data, __( 'Bulk action updated', 'wp-marketing-automations-pro' ) );
}
/**
* Create tags and list
*
* @param $actions
*
* @return array
*/
public function add_new_list_and_tags( $actions ) {
foreach ( $actions as $action_key => $action_val ) {
$terms = [];
$term_type = 0;
if ( $action_key === 'add_tags' ) {
$term_type = BWFCRM_Term_Type::$TAG;
$terms = $action_val;
} else if ( $action_key === 'add_to_lists' ) {
$term_type = BWFCRM_Term_Type::$LIST;
$terms = $action_val;
}
if ( is_array( $terms ) && ! empty( $terms ) && method_exists( 'BWFAN_PRO_Common', 'get_or_create_terms' ) ) {
$terms = BWFAN_PRO_Common::get_or_create_terms( $terms, $term_type );
$actions[ $action_key ] = $terms;
}
}
return $actions;
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Update_Bulk_Action' );