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,508 @@
<?php
if ( ! class_exists( 'BWFAN_Generate_Offer_Link_Handler' ) ) {
final class BWFAN_Generate_Offer_Link_Handler {
public static $instance = null;
public function __construct() {
add_action( 'wp_loaded', [ $this, 'handle_offer_link' ], 101 );
add_filter( 'wfocu_get_funnel_option', [ $this, 'funnel_settings' ], 10, 2 );
add_filter( 'bwfan_automation_node_analytics', array( $this, 'action_node_analytics' ), 10, 4 );
/** Ensure Thank you page open of Funnel */
add_action( 'wfocu_offer_accepted_and_processed', array( $this, 'maybe_set_current_order' ), 1, 5 );
add_filter( 'wfocu_modify_error_json_response', array( $this, 'provide_pay_link_on_error' ), 10, 4 );
add_filter( 'wffn_wfty_filter_page_ids', array( $this, 'maybe_filter_thankyou' ), 99, 2 );
add_action( 'woocommerce_thankyou', array( $this, 'maybe_log_thankyou_visited' ), 999 );
add_action( 'wfocu_offer_rejected_event', array( $this, 'redirect_to_home' ), 1000000 );
add_filter( 'wfocu_get_offer_id_filter', array( $this, 'return_offer_zero' ), 1000000 );
}
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Handle offer recovery link
*
* @return void
* @throws DateMalformedStringException
*/
public function handle_offer_link() {
/** Display notice if link is expired */
if ( function_exists( 'wc_add_notice' ) && isset( $_GET['bwfan-link-expired'] ) ) {
wc_add_notice( 'Link has been expired!', 'notice' );
return;
}
if ( ! isset( $_GET['bwfan-offer-code'] ) || empty( $_GET['bwfan-offer-code'] ) ) {
return;
}
$offer_hash = filter_input( INPUT_GET, 'bwfan-offer-code' );
$order_id = filter_input( INPUT_GET, 'order_id' );
$link_obj = new BWFAN_Generate_Offer_Link( 0, $offer_hash, [ 'clicked' => 1 ] );
/** Save click */
$link_obj->save();
$expiry_days = $link_obj->get_expiry_days();
$create_time = DateTime::createFromFormat( 'Y-m-d H:i:s', $link_obj->get_create_date() );
$expiry_date = clone $create_time;
$expiry_date = $expiry_date->modify( "+$expiry_days days" );
/** Checking if link is expired */
if ( current_time( 'timestamp' ) > $expiry_date->getTimestamp() ) {
wp_safe_redirect( home_url( '?bwfan-link-expired=1' ) );
exit;
}
$offer_data = $link_obj->get_data();
if ( class_exists( 'WFFN_Core' ) && is_array( $offer_data ) && isset( $offer_data['fid'] ) ) {
/**
* Get wffn funnel id by upsell id for increase funnel view
*/
$funnel_id = get_post_meta( $offer_data['fid'], '_bwf_in_funnel', true );
if ( ! empty( $funnel_id ) && class_exists( 'WFFN_Core' ) ) {
WFFN_Core()->public->increase_funnel_visit_session_view( $funnel_id );
}
}
$offer_recovery_link = $link_obj->generate_upsell_link( $order_id );
$offer_recovery_link = empty( $offer_recovery_link ) ? home_url() : $offer_recovery_link;
BWFAN_PRO_Common::wp_redirect( $offer_recovery_link );
exit;
}
/**
* Get step data
*
* @param $sid
*
* @return array
*/
public static function get_step_data( $sid ) {
$step = BWFAN_Model_Automation_Step::get_step_data_by_id( $sid );
$data = isset( $step['data'] ) && BWFAN_Common::is_json( $step['data'] ) ? json_decode( $step['data'], true ) : [];
return isset( $data['sidebarData'] ) ? $data['sidebarData'] : [];
}
/**
* Modify upsell setting
*
* @param $options
* @param $key
*
* @return mixed|string
*/
public function funnel_settings( $options, $key ) {
$created_via = WFOCU_Core()->data->get( 'created_via' );
if ( 'fka_stripe_offer' !== $created_via ) {
return $options;
}
$is_merge = $this->is_order_merge();
if ( 'order_behavior' === $key && true === $is_merge ) {
return 'batching';
}
if ( 'order_behavior' === $key ) {
return 'create_order';
}
if ( 'is_cancel_order' === $key ) {
return 'no';
}
return $options;
}
/**
* Check settings for order will merge or will create new order
*
* @return bool
*/
public function is_order_merge() {
$sid = WFOCU_Core()->data->get( 'fka_sid' );
$create_time = WFOCU_Core()->data->get( 'fka_upsell_created_at' );
$step_data = self::get_step_data( $sid );
if ( ! isset( $step_data['order-settings'] ) || 'new' === $step_data['order-settings'] ) {
return false;
}
$merge_hrs = isset( $step_data['merge_hrs'] ) ? intval( $step_data['merge_hrs'] ) : 0;
if ( empty( $merge_hrs ) ) {
return false;
}
$create_time = DateTime::createFromFormat( 'Y-m-d H:i:s', $create_time );
$expiry_date = clone $create_time;
$expiry_date = $expiry_date->modify( "+$merge_hrs hours" );
/** If given time is exceed */
if ( current_time( 'timestamp' ) > $expiry_date->getTimestamp() ) {
return false;
}
return true;
}
/**
* Return the node analytics of mode upsell-recovery
*
* @param $data
* @param $automation_id
* @param $step_id
* @param $mode
*
* @return array
*/
public function action_node_analytics( $data, $automation_id, $step_id, $mode ) {
/** If step is upsell recovery */
if ( 'upsell-recovery' !== $mode ) {
return $data;
}
$data = BWFAN_Model_Stripe_Offer::get_analytics( $step_id );
$sent = isset( $data['sent'] ) ? $data['sent'] : 0;
$click_rate = isset( $data['click_rate'] ) ? number_format( $data['click_rate'], 2 ) : 0;
$click_count = isset( $data['click_count'] ) ? $data['click_count'] : 0;
$conversions = isset( $data['conversions'] ) ? absint( $data['conversions'] ) : 0;
$revenue = isset( $data['revenue'] ) ? floatval( $data['revenue'] ) : 0;
$contacts_count = isset( $data['contacts_count'] ) ? absint( $data['contacts_count'] ) : 1;
$rev_per_person = empty( $contacts_count ) || empty( $revenue ) ? 0 : number_format( $revenue / $contacts_count, 2 );
$tiles = [
[
'label' => __( 'Created', 'wp-marketing-automations-pro' ),
'value' => empty( $sent ) ? '-' : $sent,
],
[
'label' => __( 'Click Rate', 'wp-marketing-automations-pro' ),
'value' => empty( $click_rate ) ? '-' : $click_rate . ' (' . $click_count . ')',
],
];
if ( bwfan_is_woocommerce_active() ) {
$currency_symbol = get_woocommerce_currency_symbol();
$revenue = html_entity_decode( $currency_symbol . $revenue );
$rev_per_person = html_entity_decode( $currency_symbol . $rev_per_person );
$revenue_tiles = [
[
'label' => __( 'Revenue', 'wp-marketing-automations-pro' ),
'value' => empty( $conversions ) ? '-' : $revenue . ' (' . $conversions . ')',
],
[
'label' => __( 'Revenue/Contact', 'wp-marketing-automations-pro' ),
'value' => empty( $contacts_count ) ? '-' : $rev_per_person,
]
];
$tiles = array_merge( $tiles, $revenue_tiles );
}
return [
'status' => true,
'data' => [
'analytics' => [],
'tile' => $tiles,
]
];
}
/**
* Set current order as the one
*
* @param $get_offer_id
* @param $get_package
* @param $get_parent_order
* @param $new_order
*
* @return void
*/
public function maybe_set_current_order( $get_offer_id, $get_package, $get_parent_order, $new_order ) {
if ( ! $new_order instanceof WC_Order ) {
return;
}
$created_via = WFOCU_Core()->data->get( 'created_via' );
if ( 'fka_stripe_offer' !== $created_via ) {
return;
}
$upsell_id = get_post_meta( $get_offer_id, '_funnel_id', true );
/** This new order is from FKA Stripe offer */
$new_order->update_meta_data( '_bwfan_stripe_offer', '1' );
if ( ! empty( $upsell_id ) && absint( $upsell_id ) > 0 ) {
$new_order->update_meta_data( '_wfocu_funnel_id', $upsell_id );
}
$new_order->save_meta_data();
WFOCU_Core()->data->set( 'corder', WFOCU_WC_Compatibility::get_order_id( $new_order ), 'orders' );
WFOCU_Core()->data->set( 'corder', $new_order, '_orders' );
WFOCU_Core()->data->save( 'orders' );
/** Removing the action */
remove_action( 'wfocu_offer_accepted_event', array( WFOCU_DB_Track::get_instance(), 'add_to_order_meta' ), 990 );
add_action( 'wfocu_offer_accepted_event', array( $this, 'add_to_order_meta' ), 899 );
/** Save order details in offer table */
$p_key = WFOCU_Core()->data->get( 'fka_p_key' );
if ( intval( $p_key ) > 0 ) {
$data = [
'order_id' => $new_order->get_id(),
'order_total' => BWF_Plugin_Compatibilities::get_fixed_currency_price_reverse( $new_order->get_total(), BWF_WC_Compatibility::get_order_currency( $new_order ) ),
'order_date' => $new_order->get_date_created()->format( 'Y-m-d H:i:s' ),
];
$link_obj = new BWFAN_Generate_Offer_Link( $p_key, '', $data );
$link_obj->save();
}
}
public function add_to_order_meta( $args ) {
$get_current_order_id = isset( $args['new_order'] ) ? $args['new_order'] : '';
if ( empty( $get_current_order_id ) ) {
$get_current_order_id = WFOCU_Core()->data->get( 'corder', false, 'orders' );
}
if ( empty( $get_current_order_id ) ) {
return;
}
$get_order = wc_get_order( $get_current_order_id );
if ( ! $get_order instanceof WC_Order ) {
return;
}
$total_sum = floatval( $args['value'] );
$total_sum_currency = floatval( $args['value_in_currency'] );
if ( 0 < $total_sum ) {
$get_order->update_meta_data( '_wfocu_upsell_amount', $total_sum );
}
if ( 0 < $total_sum_currency ) {
$get_order->update_meta_data( '_wfocu_upsell_amount_currency', $total_sum_currency );
}
$aid = WFOCU_Core()->data->get( 'fka_aid' );
$note = "Stripe recovery offer accepted.";
if ( ! empty( $aid ) && intval( $aid ) > 0 ) {
$note .= " Automation ID: " . $aid;
}
$get_order->add_order_note( $note );
/** Add item meta in the order */
$this->update_item_meta( $get_order );
if ( 0 < $total_sum || 0 < $total_sum_currency ) {
$get_order->save_meta_data();
}
global $wpdb;
$query = $wpdb->prepare( 'UPDATE`' . $wpdb->prefix . 'wfocu_session` SET `total` = %s WHERE `order_id` = %s', $total_sum, $get_current_order_id );
$wpdb->query( $query ); //phpcs:ignore
// db call ok; no-cache ok; unprepared SQL ok.
}
/**
* Helper method - Update item meta
*
* @param $order
*
* @return void
*/
protected function update_item_meta( $order ) {
if ( ! $order instanceof WC_Order ) {
return;
}
$items = $order->get_items();
if ( empty( $items ) ) {
return;
}
foreach ( $order->get_items() as $item ) {
$product = $item->get_product();
if ( ! $product instanceof WC_Product ) {
continue;
}
$item->add_meta_data( '_fk_automation_stripe_offer', 'yes', true );
$item->save_meta_data();
}
}
/**
* @param $arr
*
* @return array|mixed
*/
public function provide_pay_link_on_error( $arr ) {
$created_via = WFOCU_Core()->data->get( 'created_via' );
if ( 'fka_stripe_offer' !== $created_via ) {
return $arr;
}
if ( WFOCU_Core()->public->failed_order !== null && isset( $arr['response'] ) && isset( $arr['response']['redirect_url'] ) ) {
$arr['response']['redirect_url'] = WFOCU_Core()->public->failed_order->get_checkout_payment_url();
}
return $arr;
}
/**
* Get upsell id by order id
*
* @param $order_id
*
* @return string|null
*/
public function get_upsell_id( $order_id ) {
global $wpdb;
$query = "SELECT `meta_value` FROM {$wpdb->prefix}wfocu_event_meta WHERE `event_id` = (SELECT `event_id` FROM {$wpdb->prefix}wfocu_event_meta WHERE `meta_key`='_new_order' AND `meta_value`=%d) AND `meta_key`='_funnel_id'";
return $wpdb->get_var( $wpdb->prepare( $query, $order_id ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
}
/**
* @param $thankyou_page_ids
* @param $order
*
* @return array
*/
public function maybe_filter_thankyou( $thankyou_page_ids, $order ) {
if ( ! $order instanceof WC_Order ) {
return $thankyou_page_ids;
}
$created_via = WFOCU_Core()->data->get( 'created_via' );
if ( 'fka_stripe_offer' !== $created_via ) {
return $thankyou_page_ids;
}
$current_step = [];
$step_id = BWF_WC_Compatibility::get_order_meta( $order, '_wfocu_funnel_id' );
if ( empty( $step_id ) ) {
return $thankyou_page_ids;
}
if ( ! empty( $step_id ) && 0 !== abs( $step_id ) ) {
$funnel_id = get_post_meta( $step_id, '_bwf_in_funnel', true );
if ( ! empty( $funnel_id ) && abs( $funnel_id ) !== 0 ) {
$funnel = WFFN_Core()->admin->get_funnel( $funnel_id );
if ( $funnel instanceof WFFN_Funnel ) {
$current_step['id'] = $step_id;
$current_step['type'] = 'wc_upsells';
$get_type_object = WFFN_Core()->steps->get_integration_object( 'wc_thankyou' );
if ( $get_type_object instanceof WFFN_Step ) {
$thankyou_page_ids = $get_type_object->maybe_get_thankyou( $current_step, $funnel );
}
if ( empty( $thankyou_page_ids ) ) {
$thankyou_page_ids = $get_type_object->get_store_checkout_thankyou_page( $thankyou_page_ids, $order );
}
}
}
}
return $thankyou_page_ids;
}
/**
* Record thank you page views in upsell recovery
*
* @param $order_id
*
* @return void
*/
public function maybe_log_thankyou_visited( $order_id ) {
global $post;
$wfty_source = filter_input( INPUT_GET, 'wfty_source' );
if ( empty( $wfty_source ) || is_null( $post ) || ! class_exists( 'WFFN_Core' ) ) {
return;
}
/**
* Check valid upsell session
*/
if ( false === WFOCU_Core()->data->get_funnel_id() ) {
return;
}
$created_via = WFOCU_Core()->data->get( 'created_via' );
if ( 'fka_stripe_offer' !== $created_via ) {
return;
}
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) {
return;
}
$upsell_id = $order->get_meta( '_wfocu_funnel_id' );
if ( empty( $upsell_id ) ) {
return;
}
$funnel_id = get_post_meta( $upsell_id, '_bwf_in_funnel', true );
$funnel = new WFFN_Funnel( $funnel_id );
/**
* Check valid funnel session case
* Return if valid funnel because in upsell recovery has not funnel valid session
*/
if ( ! wffn_is_valid_funnel( $funnel ) || WFFN_Core()->data->has_valid_session() ) {
return;
}
WFCO_Model_Report_views::update_data( gmdate( 'Y-m-d', current_time( 'timestamp' ) ), $post->ID, 5 );
}
/**
* Upon offer reject, hook woocommerce thank you redirect code
*
* @return void
*/
public function redirect_to_home() {
$created_via = WFOCU_Core()->data->get( 'created_via' );
if ( 'fka_stripe_offer' !== $created_via ) {
return;
}
remove_all_filters( 'woocommerce_get_checkout_order_received_url' );
add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'offer_rejected' ), 999999999 );
}
/**
* Return 0 offer id
* As don't want to show next offer
*
* @param $return
*
* @return int|mixed
*/
public function return_offer_zero( $return ) {
$created_via = WFOCU_Core()->data->get( 'created_via' );
if ( 'fka_stripe_offer' !== $created_via ) {
return $return;
}
return 0;
}
/**
* Change thank you url to home page in case of offer reject
*
* @return string|null
*/
public function offer_rejected() {
return home_url();
}
}
BWFAN_Generate_Offer_Link_Handler::get_instance();
}

View File

@@ -0,0 +1,194 @@
<?php
if ( ! class_exists( 'BWFAN_Generate_Offer_Link' ) ) {
class BWFAN_Generate_Offer_Link {
public $id = 0;
private $data = [];
public function __construct( $id = 0, $hash_code = '', $data = [] ) {
if ( intval( $id ) > 0 ) {
$this->data = BWFAN_Model_Stripe_Offer::get( $id );
}
if ( ! empty( $hash_code ) ) {
$db_data = BWFAN_Model_Stripe_Offer::get_specific_rows( 'hash_code', $hash_code );
$this->data = isset( $db_data[0] ) ? $db_data[0] : $this->data;
}
if ( ! empty( $data ) ) {
$this->set_data( $data );
}
}
/**
* @return mixed
*/
public function get_expiry_days() {
return $this->data['expiry_days'];
}
/**
* @return mixed
*/
public function get_create_date() {
return $this->data['created_at'];
}
/**
* @return array|mixed|object|stdClass|null
*/
public function get_data() {
return $this->data;
}
/**
* @param $data
*
* @return void
*/
public function set_data( $data ) {
foreach ( $data as $key => $value ) {
$this->data[ $key ] = $value;
}
if ( empty( $data['updated_at'] ) ) {
$this->data['updated_at'] = current_time( 'mysql' );
}
}
/**
* Generate upsell link
*
* @param $order_id
*
* @return string
*/
public function generate_upsell_link( $order_id ) {
if ( ! class_exists( 'WFOCU_Core' ) ) {
return '';
}
$order = wc_get_order( $order_id );
WFOCU_Core()->data->set( 'funnel_id', $this->data['fid'] );
$funnel_offers = WFOCU_Core()->offers->get_offers( $this->data['fid'] );
/** Get offer from funnel */
$offer_data = isset( $funnel_offers[ $this->data['oid'] ] ) ? $funnel_offers[ $this->data['oid'] ] : [];
if ( empty( $offer_data ) ) {
return '';
}
$offer = [ $this->data['oid'] => $offer_data ];
WFOCU_Core()->data->set( 'funnel', $offer );
/** Set flag and step id */
WFOCU_Core()->data->set( 'created_via', 'fka_stripe_offer' );
WFOCU_Core()->data->set( 'fka_upsell_created_at', $this->data['created_at'] );
WFOCU_Core()->data->set( 'fka_sid', $this->data['sid'] );
WFOCU_Core()->data->set( 'fka_p_key', $this->data['ID'] );
/** Set automation id if found in url query argument */
if ( isset( $_GET['automation_id'] ) && intval( $_GET['automation_id'] ) > 0 ) {
WFOCU_Core()->data->set( 'fka_aid', intval( $_GET['automation_id'] ) );
}
$ins = BWFAN_Generate_Offer_Link_Handler::get_instance();
remove_filter( 'wfocu_get_offer_id_filter', array( $ins, 'return_offer_zero' ), 1000000 );
$get_payment_gateway = WFOCU_WC_Compatibility::get_payment_gateway_from_order( $order );
$get_integration = WFOCU_Core()->gateways->get_integration( $get_payment_gateway );
$get_compatibility_class = WFOCU_Plugin_Compatibilities::get_compatibility_class( 'subscriptions' );
remove_filter( 'wfocu_front_payment_gateway_integration_enabled', array( $get_compatibility_class, 'maybe_disable_integration_when_subscription_in_cart' ), 10 );
$offer_url = '';
if ( WFOCU_Core()->data->is_funnel_exists() && $get_integration instanceof WFOCU_Gateway && $get_integration->is_enabled( $order ) && ( $get_integration->has_token( $order ) || $get_integration->is_run_without_token() ) ) {
$get_offer = WFOCU_Core()->offers->get_the_first_offer();
if ( 0 === absint( $get_offer ) ) { //integer check done
return $offer_url;
}
/**
* Check if parent order is same as the one saved in the session
* check if offer is the one saved in the session
* If both matches then we need to only return the upsell url we have and skip setting up upsell funnel again
*/
$get_order_id = WFOCU_Core()->data->get( 'porder', 0, 'orders' );
$get_current_offer = WFOCU_Core()->data->get( 'current_offer' );
if ( $get_order_id === WFOCU_WC_Compatibility::get_order_id( $order ) && ! empty( $get_current_offer ) && $get_current_offer === $get_offer ) {
return $this->get_the_upsell_url( $get_offer );
}
WFOCU_Core()->data->set( 'porder', $order, '_orders' );
WFOCU_Core()->data->set( 'porder', WFOCU_WC_Compatibility::get_order_id( $order ), 'orders' );
WFOCU_Core()->data->set( 'current_offer', $get_offer );
WFOCU_Core()->data->set( 'useremail', WFOCU_WC_Compatibility::get_order_data( $order, 'billing_email' ) );
WFOCU_Core()->data->save( 'orders' );
WFOCU_Core()->data->save();
do_action( 'wfocu_funnel_init_event', WFOCU_Core()->data->get_funnel_id(), 0, WFOCU_Core()->data->get( 'useremail' ), $order->get_payment_method(), $order->get_meta( '_woofunnel_cid' ) );
return $this->get_the_upsell_url( $get_offer );
}
return $offer_url;
}
/**
* Get upsell url
*
* @param $offer
*
* @return string
*/
public function get_the_upsell_url( $offer ) {
if ( empty( $offer ) ) {
return '';
}
$offer_data = WFOCU_Core()->offers->get_offer( $offer );
$link = WFOCU_Core()->offers->get_the_link( $offer );
if ( 'custom-page' === $offer_data->template ) {
$custom_page_id = get_post_meta( $offer, '_wfocu_custom_page', true );
if ( ! empty( $custom_page_id ) && intval( $custom_page_id ) > 0 ) {
$get_custom_page_post = get_post( $custom_page_id );
if ( is_null( $get_custom_page_post ) || ( is_object( $get_custom_page_post ) && 'publish' !== $get_custom_page_post->post_status ) ) {
return '';
}
}
}
return add_query_arg( array(
'wfocu-key' => WFOCU_Core()->data->get_funnel_key(),
'wfocu-si' => WFOCU_Core()->data->get_transient_key(),
), $link );
}
/**
* @return int|mixed
*/
public function save() {
if ( 0 === $this->get_id() ) {
BWFAN_Model_Stripe_Offer::insert( $this->data );
return BWFAN_Model_Stripe_Offer::insert_id();
}
$data = $this->data;
if ( isset( $data['ID'] ) ) {
unset( $data['ID'] );
}
BWFAN_Model_Stripe_Offer::update( $data, [ 'ID' => $this->get_id() ] );
return $this->id;
}
/**
* @return mixed
*/
public function get_id() {
$this->id = isset( $this->data['ID'] ) ? intval( $this->data['ID'] ) : 0;
return $this->id;
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class BWFAN_FK_Fetch_Bumps {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function get_slug() {
return 'fk_fetch_bumps';
}
public function get_options( $search ) {
return BWFAN_PRO_Common::get_bumps( $search );
}
}
if ( class_exists( 'BWFAN_Load_Custom_Search' ) ) {
BWFAN_Load_Custom_Search::register( 'BWFAN_FK_Fetch_Bumps' );
}

View File

@@ -0,0 +1,45 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class BWFAN_FK_Fetch_Offers {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function get_slug() {
return 'fk_fetch_offers';
}
public function get_options( $search ) {
return BWFAN_Pro_Common::get_offers( $search );
}
public static function get_data( $args, $search ) {
$posts = get_posts( $args );
$offers = [];
foreach ( $posts as $post ) {
$offers[ $post->ID ] = $post->post_title . '(#' . $post->ID . ')';
}
return array_filter( $offers, function ( $offer ) use ( $search ) {
return false !== strpos( strtolower( $offer ), strtolower( $search ) );
} );
}
}
if ( class_exists( 'BWFAN_Load_Custom_Search' ) ) {
BWFAN_Load_Custom_Search::register( 'BWFAN_FK_Fetch_Offers' );
}

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.