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,218 @@
<?php
if ( ! function_exists( 'bwf_get_remote_rest_args' ) ) {
/**
* Get wp remote post arguments
*
* @param $data
* @param $method
*
* @return mixed|void
*/
function bwf_get_remote_rest_args( $data = '', $method = 'POST' ) {
return apply_filters( 'bwf_get_remote_rest_args', [
'method' => $method,
'body' => $data,
'timeout' => 0.01,
'sslverify' => false,
] );
}
}
if ( ! function_exists( 'bwf_clean' ) ) {
/**
* Sanitize the given string or array
*
* @param $var
*
* @return array|mixed|string
*/
function bwf_clean( $var ) {
if ( is_array( $var ) ) {
return array_map( 'bwf_clean', $var );
}
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
}
}
if ( ! function_exists( 'bwf_get_states' ) ) {
/**
* Get states nice name from country and state slugs
*
* @param $country
* @param $state
*
* @return mixed|string
*/
function bwf_get_states( $country = '', $state = '' ) {
$country_states = apply_filters( 'bwf_get_states', include WooFunnel_Loader::$ultimate_path . 'helpers/states.php' );
if ( empty( $state ) ) {
return '';
}
if ( empty( $country ) ) {
return $state;
}
if ( ! isset( $country_states[ $country ] ) ) {
return $state;
}
if ( ! isset( $country_states[ $country ][ $state ] ) ) {
return $state;
}
return $country_states[ $country ][ $state ];
}
}
if ( ! function_exists( 'bwf_get_fonts_list' ) ) {
/**
* get the list of all the registered fonts
* we have 3 modes here, 'standard', 'name_only','name_key' and 'all'
*
* @param string $mode
*
* @return array|int[]|mixed|string[]
*/
function bwf_get_fonts_list( $mode = 'standard' ) {
$fonts = [];
$font_path = WooFunnel_Loader::$ultimate_path . '/helpers/fonts.json';
$google_fonts = json_decode( file_get_contents( $font_path ), true ); //phpcs:ignore WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown
$web_fonts = ( $mode !== 'all' ) ? array_keys( $google_fonts ) : $google_fonts;
if ( $mode === 'all' || $mode === 'name_only' ) {
return $web_fonts;
}
/**
* if the name_key mode
*/
if ( $mode === 'name_key' ) {
foreach ( $web_fonts as $web_font_family ) {
if ( $web_font_family !== 'Open Sans' ) {
$fonts[ $web_font_family ] = $web_font_family;
}
}
return $fonts;
}
/**
* if standard mode
*/
$fonts[] = array(
'id' => 'default',
'name' => __( 'Default', 'woofunnels' ) // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
);
foreach ( $web_fonts as $web_font_family ) {
if ( $web_font_family !== 'Open Sans' ) {
$fonts[] = array(
'id' => $web_font_family,
'name' => $web_font_family,
);
}
}
return $fonts;
}
}
/**
* Converts a string (e.g. 'yes' or 'no' , 'true') to a bool.
*
* @param $string
*
* @return bool
*/
if ( ! function_exists( 'bwf_string_to_bool' ) ) {
function bwf_string_to_bool( $string ) {
return is_bool( $string ) ? $string : ( 'yes' === strtolower( $string ) || 1 === $string || 'true' === strtolower( $string ) || '1' === $string );
}
}
if ( ! function_exists( 'bwf_clear_queries' ) ) {
/**
* Dev
* Make WPDB queries empty
* @return void
*/
function bwf_clear_queries() {
global $wpdb;
$wpdb->queries = [];
}
}
if ( ! function_exists( 'bwf_save_queries' ) ) {
/**
* Dev
* Save DB calls from WPDB class object
*
* @param $file_name
* @param $folder_name
* @param $reference
*
* @return void
*/
function bwf_save_queries( $file_name = 'general', $folder_name = 'funnelkit', $reference = 'DB Call' ) {
global $wpdb;
if ( empty( $wpdb->queries ) || ! is_array( $wpdb->queries ) ) {
return;
}
$queries = [];
foreach ( $wpdb->queries as $q ) {
$queries[] = [ $q[0], $q[2] ];
}
$message = print_r( $queries, true );
$file_name = sanitize_title( $file_name );
$logger_obj = BWF_Logger::get_instance();
add_filter( 'bwf_logs_allowed', 'bwf_return_true', 99999 );
if ( ! empty( $reference ) ) {
$logger_obj->log( $reference, $file_name, $folder_name );
}
$logger_obj->log( $message, $file_name, $folder_name );
remove_filter( 'bwf_logs_allowed', 'bwf_return_true', 99999 );
}
}
if ( ! function_exists( 'bwf_return_true' ) ) {
/**
* @return bool
*/
function bwf_return_true() {
return true;
}
}
if ( ! function_exists( 'bwf_generate_random_bytes' ) ) {
/**
* Generate random bytes for the given count
*
* @param $count
*
* @return string
*/
function bwf_generate_random_bytes( $count ) {
$output = '';
$state = microtime();
if ( function_exists( 'getmypid' ) ) {
$state .= getmypid();
}
if ( strlen( $output ) < $count ) {
$output = '';
for ( $i = 0; $i < $count; $i += 16 ) {
$state = md5( microtime() . $state );
$output .= md5( $state, true );
}
$output = substr( $output, 0, $count );
}
return $output;
}
}

View File

@@ -0,0 +1,259 @@
<?php
/**
* Class to control breadcrumb and its behaviour accross the buildwoofunnels
* @author buildwoofunnels
*/
if ( ! class_exists( 'BWF_Admin_Breadcrumbs' ) ) {
#[AllowDynamicProperties]
class BWF_Admin_Breadcrumbs {
private static $ins = null;
/**
* @var array nodes use to contain all the nodes
*/
public static $nodes = [];
/**
* @var array ref used to contain refs to pass to the urls
*/
public static $ref = [];
/**
* Insert a single node into the property
*
* @param $config [] of the node getting registered
*/
public static function register_node( $config ) {
self::$nodes[] = wp_parse_args( $config, [ 'class' => '', 'link' => '', 'text' => '' ] );
}
/**
* Insert a referral property so that we can populate the referral across all urls.
*
* @param $key
* @param $val
*/
public static function register_ref( $key, $val ) {
self::$ref[ $key ] = $val;
}
/**
* Render HTML for all the registered nodes
*/
public static function render() {
if ( empty( self::$nodes ) ) {
return '';
}
$last_item = end( self::$nodes );
?>
<ul>
<li class="<?php echo esc_attr( $last_item['class'] ) ?>">
<?php echo wp_kses_post( $last_item['text'] ); ?>
</li>
</ul>
<?php
}
/**
* rearrange all the collected nodes and maybe print them
*
* @param false $return_nodes should just return nodes or print
*
* @return array|false
*/
public static function render_top_bar( $return_nodes = false ) {
if ( empty( self::$nodes ) ) {
return false;
}
if ( ! is_array( self::$nodes ) || count( self::$nodes ) == 0 ) {
return false;
}
self::$nodes = array_filter( self::$nodes, function ( $v ) {
if ( isset( $v['text'] ) && ! empty( $v['text'] ) ) {
return true;
}
} );
if ( ! is_array( self::$nodes ) || count( self::$nodes ) == 0 ) {
return false;
}
if ( true === $return_nodes ) {
return self::$nodes;
}
$count = count( self::$nodes );
$h = 0;
foreach ( self::$nodes as $menu ) {
if ( ! isset( $menu['text'] ) || empty( $menu['text'] ) ) {
continue;
}
$h ++;
echo '<span>';
if ( $count !== $h && isset( $menu['link'] ) && ! empty( $menu['link'] ) ) {
echo '<a href="' . esc_url($menu['link']) . '">' . $menu['text'] . '</a>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
echo $menu['text']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '</span>';
}
return self::$nodes;
}
/**
* Add the registered referral to the url passed
* ref should contain the query param as key and value as value
*
* @param $url URL to add refs to
*
* @return string modified url
*/
public static function maybe_add_refs( $url ) {
if ( empty( self::$ref ) ) {
return $url;
}
return add_query_arg( self::$ref, $url );
}
public static function render_sticky_bar() {
?>
<style>
/* Sticky Bar */
.bwf-header-bar {
background: #fff;
box-sizing: border-box;
border-bottom: 1px solid #fff;
padding: 0 0 0 20px;
min-height: 56px;
position: fixed;
width: 100%;
top: 32px;
z-index: 1001;
display: flex;
align-items: center;
box-shadow: 0 0px 10px 0 #c8c8c8
}
.bwf-header-bar > img {
max-width: 24px
}
.bwf-bar-navigation {
font-size: 16px;
padding-left: 15px;
display: flex
}
.bwf-bar-navigation > span {
padding-right: 25px;
position: relative
}
.bwf-bar-navigation > span a {
text-decoration: none;
font-weight: normal
}
.bwf-bar-navigation > span:after {
content: "\f345";
font-family: 'dashicons';
font-size: 15px;
position: absolute;
right: 4px;
top: 1px
}
.bwf-bar-navigation > span:last-child:after {
content: ""
}
.bwf-bar-quick-links {
display: flex;
flex-direction: row;
align-items: center;
position: fixed;
right: 0;
top: 32px;
height: 56px
}
.bwf-bar-quick-links a.bwf-bar-link {
display: block;
font-size: 13px;
height: 56px;
text-decoration: none;
text-align: center;
padding: 0 10px;
min-width: 70px;
transition: all 0.4s ease;
-webkit-transition: all 0.4s ease;
box-sizing: border-box
}
.bwf-bar-quick-links a.bwf-bar-link:hover {
background: #f0f0f0
}
.bwf-bar-quick-links a * {
display: block;
margin: 0 auto;
padding: 0;
float: none;
color: #757575
}
.bwf-bar-quick-links a i {
font-size: 20px;
color: #757575;
margin-top: 8px
}
.wrap.bwf-funnel-common {
padding: 60px 0 0 20px;
margin: 0 20px 0 0
}
.bwf-header-bar .bwf-breadcrub-svg-icon {
max-width: 35px;
}
</style>
<div class="bwf-header-bar">
<img class="bwf-breadcrub-svg-icon" src="<?php echo esc_url( plugin_dir_url( WooFunnel_Loader::$ultimate_path ) . 'woofunnels/assets/img/bwf-icon-white-bg.svg' ); ?>"/>
<div class="bwf-bar-navigation">
<?php
global $submenu;
if ( array_key_exists( 'bwf_dashboard', $submenu ) ) {
echo '<span><a href="' . esc_url(admin_url( 'admin.php?page=bwf_dashboard' )) . '">FunnelKit</a></span> ';
}
if ( method_exists( 'BWF_Admin_Breadcrumbs', 'render_top_bar' ) ) {
BWF_Admin_Breadcrumbs::render_top_bar();
}
?>
</div>
<div class="bwf-bar-quick-links">
<a class="bwf-bar-link" href="https://funnelkit.com/documentation/" target="_blank">
<i class="dashicons dashicons-format-chat"></i>
<span>Docs</span>
</a>
<a class="bwf-bar-link" href="https://funnelkit.com/support/" target="_blank">
<i class="dashicons dashicons-businessman"></i>
<span>Support</span>
</a>
</div>
</div>
<?php
}
}
}

View File

@@ -0,0 +1,553 @@
<?php
/**
* Class to control Settings and its behaviour across the buildwoofunnels
* @author buildwoofunnels
*/
if ( ! class_exists( 'BWF_Admin_General_Settings' ) ) {
#[AllowDynamicProperties]
class BWF_Admin_General_Settings {
private static $ins = null;
private $options = array();
public function __construct() {
add_filter( 'woofunnels_global_settings', function ( $menu ) {
array_push( $menu, array(
'title' => __( 'General', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'slug' => 'woofunnels_general_settings',
'link' => apply_filters( 'bwf_general_settings_link', 'javascript:void(0)' ),
'priority' => 5,
) );
return $menu;
} );
add_action( 'wp_ajax_bwf_general_settings_update', [ $this, 'update_general_settings' ] );
add_action( 'init', array( $this, 'maybe_flush_rewrite_rules' ), 101 );
add_action( 'admin_head', array( $this, 'hide_from_menu' ) );
add_filter( 'admin_title', array( $this, 'maybe_change_title' ), 99 );
add_filter( 'woofunnels_global_settings_fields', array( $this, 'add_settings_fields_array' ), 99 );
add_action( 'bwf_global_save_settings_woofunnels_general_settings', array( $this, 'update_global_settings_fields' ), 99 );
}
/**
* Get the instance of the BWF_Admin_General_Settings class
*
* @return BWF_Admin_General_Settings The instance of the class
*/
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function maybe_flush_rewrite_rules() {
$is_required_rewrite = get_option( 'bwf_needs_rewrite', 'no' );
if ( 'yes' === $is_required_rewrite ) {
flush_rewrite_rules(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
WooFunnels_Dashboard::get_all_templates();
update_option( 'bwf_needs_rewrite', 'no', true );
}
}
public function add_settings_fields_array( $fields ) {
$fields['woofunnels_general_settings'] = $this->all_fields();
return $fields;
}
public function __callback() {
/** Registering Settings in top bar */
if ( class_exists( 'BWF_Admin_Breadcrumbs' ) ) {
BWF_Admin_Breadcrumbs::register_node( [ 'text' => 'Settings' ] );
}
BWF_Admin_Breadcrumbs::render_sticky_bar();
?>
<div class="wrap bwf-funnel-common">
<h1 class="wp-heading-inline"><?php esc_html_e( 'Settings', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?></h1>
<?php
$admin_settings = BWF_Admin_Settings::get_instance();
$admin_settings->render_tab_html( 'woofunnels_general_settings' );
$i = 0;
?>
<div id="bwf_general_settings_vue_wrap" class="bwf-hide" v-bind:class="`1`===is_initialized?'bwf-show':''">
<div class="bwf-vue-custom-msg" v-if="'' != errorMsg"><p v-html="errorMsg"></p></div>
<div class="bwf-tabs-view-vertical bwf-widget-tabs">
<div class="bwf-tabs-wrapper">
<div class="bwf-tab-title" data-tab="<?php $i ++;
echo esc_attr($i); ?>" role="tab">
<?php esc_html_e( 'Permalinks', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</div>
<div class="bwf-tab-title" data-tab="<?php $i ++;
echo esc_attr($i); ?>" role="tab">
<?php esc_html_e( 'Facebook Pixel', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</div>
<div class="bwf-tab-title" data-tab="<?php $i ++;
echo esc_attr($i); ?>" role="tab">
<?php esc_html_e( 'Google Analytics', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</div>
<?php if ( apply_filters( 'bwf_enable_ecommerce_integration_gad', false ) ) { ?>
<div class="bwf-tab-title" data-tab="<?php $i ++;
echo esc_attr($i); ?>" role="tab">
<?php esc_html_e( 'Google Ads', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</div>
<?php }
if ( apply_filters( 'bwf_enable_ecommerce_integration_pinterest', false ) ) { ?>
<div class="bwf-tab-title" data-tab="<?php $i ++;
echo esc_attr($i); ?>" role="tab">
<?php esc_html_e( 'Pinterest', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</div>
<?php }
if ( apply_filters( 'bwf_enable_ecommerce_integration_tiktok', false ) ) { ?>
<div class="bwf-tab-title" data-tab="<?php $i ++;
echo esc_attr($i); ?>" role="tab">
<?php esc_html_e( 'TikTok', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</div>
<?php }
if ( apply_filters( 'bwf_enable_ecommerce_integration_snapchat', false ) ) { ?>
<div class="bwf-tab-title" data-tab="<?php $i ++;
echo esc_attr($i); ?>" role="tab">
<?php esc_html_e( 'Snapchat', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</div>
<?php } ?>
</div>
<div class="bwf-tabs-content-wrapper">
<div class="bwf_setting_inner">
<form class="bwf_forms_wrap">
<fieldset>
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator>
</fieldset>
<div style="display: none" id="modal-general-settings_success" data-iziModal-icon="icon-home">
</div>
</form>
<div class="bwf_form_button">
<span class="bwf_loader_global_save spinner" style="float: left;"></span>
<button v-on:click.self="onSubmit" class="bwf_save_btn_style"><?php esc_html_e( 'Save Changes', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?></button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
public function default_general_settings() {
return apply_filters( 'bwf_general_settings_default_config', array(
'tiktok_pixel' => '',
'is_tiktok_add_to_cart_bump' => '',
'tiktok_add_to_cart_event' => '',
'tiktok_initiate_checkout_event' => '',
'is_tiktok_purchase_event' => array(),
'pint_key' => '',
'is_pint_lead_op' => array(),
'is_pint_add_to_cart_bump' => '',
'is_pint_custom_bump' => '',
'is_pint_page_view_lp' => array(),
'is_pint_page_view_op' => array(),
'is_pint_pageview_event' => array(),
'is_pint_page_view_global' => '',
'pint_is_page_view' => '',
'pint_add_to_cart_event' => '',
'pint_initiate_checkout_event' => '',
'is_pint_purchase_event' => array(),
'is_pint_custom_events' => '',
'pint_variable_as_simple' => '',
'pint_content_id_type' => '0',
'pint_content_id_prefix' => '',
'pint_content_id_suffix' => '',
'pint_exclude_from_total' => array(),
'gad_key' => '',
'gad_conversion_label' => '',
'gad_lead_conversion_label' => '',
'gad_addtocart_checkout_conversion_label' => '',
'gad_addtocart_bump_conversion_label' => '',
'gad_addtocart_global_conversion_label' => '',
'is_gad_page_view_global' => '',
'is_gad_view_item_global' => '',
'is_gad_page_view_lp' => array(),
'is_gad_page_view_op' => array(),
'is_gad_lead_op' => array(),
'is_gad_add_to_cart_bump' => '',
'is_gad_custom_bump' => '',
'google_ads_is_page_view' => '',
'google_ads_add_to_cart_event' => '',
'is_gad_pageview_event' => array(),
'is_gad_purchase_event' => array(),
'is_gad_custom_events' => '',
'google_ads_variable_as_simple' => '',
'google_ads_content_id_type' => '0',
'google_ads_content_id_prefix' => '',
'google_ads_content_id_suffix' => '',
'gad_exclude_from_total' => array(),
'ga_key' => '',
'is_ga_page_view_global' => '',
'is_ga_view_item_global' => '',
'is_ga_page_view_lp' => array(),
'is_ga_page_view_op' => array(),
'is_ga_lead_op' => array(),
'google_ua_is_page_view' => '',
'google_ua_add_to_cart_event' => '',
'google_ua_initiate_checkout_event' => '',
'google_ua_add_payment_info_event' => '',
'is_ga_purchase_page_view' => array(),
'is_ga_purchase_event' => array(),
'is_ga_custom_events' => '',
'google_ua_variable_as_simple' => '',
'google_ua_content_id_type' => '0',
'google_ua_content_id_prefix' => '',
'google_ua_content_id_suffix' => '',
'ga_exclude_from_total' => array(),
'fb_pixel_key' => '',
'conversion_api_access_token' => '',
'is_fb_conv_enable_test' => array(),
'conversion_api_test_event_code' => '',
'is_fb_conversion_api_log' => array(),
'is_fb_page_view_global' => '',
'is_fb_page_product_content_global' => '',
'is_fb_page_view_lp' => array(),
'is_fb_page_view_op' => array(),
'is_fb_lead_op' => array(),
'is_fb_add_to_cart_bump' => '',
'is_fb_custom_bump' => '',
'label_section_head_fb' => '',
'pixel_is_page_view' => '',
'pixel_initiate_checkout_event' => '',
'pixel_add_to_cart_event' => '',
'pixel_add_payment_info_event' => '',
'is_fb_purchase_page_view' => array(),
'is_fb_purchase_event' => array(),
'enable_general_event' => array(),
'general_event_name' => 'GeneralEvent',
'is_fb_custom_events' => '',
'is_fb_enable_content' => [],
'pixel_variable_as_simple' => '',
'pixel_content_id_type' => '0',
'pixel_content_id_prefix' => '',
'pixel_content_id_suffix' => '',
'exclude_from_total' => array(),
'is_fb_advanced_event' => array(),
'is_tiktok_advanced_event' => array(),
'default_selected_builder' => '',
'track_utms' => "1",
'snapchat_pixel' => '',
'is_snapchat_page_view_global' => '',
'is_snapchat_page_view_lp' => array(),
'is_snapchat_page_view_op' => array(),
'is_snapchat_add_to_cart_bump' => '',
'label_section_head_snapchat' => '',
'snapchat_is_page_view' => '',
'snapchat_add_to_cart_event' => '',
'snapchat_initiate_checkout_event' => '',
'snapchat_add_payment_info_event' => '',
'is_snapchat_purchase_event' => array(),
'snapchat_variable_as_simple' => '',
'is_fb_add_to_cart_global' => '',
'is_ga_add_to_cart_global' => '',
'is_gad_add_to_cart_global' => '',
'is_snapchat_add_to_cart_global' => '',
'is_tiktok_page_view_global' => '',
'is_tiktok_page_view_lp' => array(),
'is_tiktok_page_view_op' => array(),
'is_tiktok_pageview_event' => array(),
'tiktok_is_page_view' => '',
'tiktok_variable_as_simple' => '',
'is_tiktok_add_to_cart_global' => '',
'is_pint_add_to_cart_global' => '',
'is_pint_page_visit_global' => '',
'track_traffic_source' => [], //for backcompat, not calling anywhere
'ga_track_traffic_source' => [], //for backcompat, not calling anywhere
'is_ga_add_to_cart_bump' => '',
'is_ga_custom_bump' => '',
'custom_aud_opt_conf' => [],
'allow_theme_css' => array( 'wfacp_checkout' ),
'bwf_enable_notification' => true,
'bwf_notification_frequency' => array( 'weekly', 'monthly' ),
'bwf_notification_user_selector' => array(),
'bwf_external_user' => array(),
'bwf_notification_time' => [
'hours' => '10',
'minutes' => '00',
'ampm' => 'am'
],
) );
}
public function get_option( $key = 'all' ) {
if ( empty( $this->options ) ) {
$this->setup_options();
}
if ( 'all' === $key ) {
return $this->options;
}
return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
}
public function setup_options() {
$db_options = get_option( 'bwf_gen_config', [] );
$db_options = ( ! empty( $db_options ) && is_array( $db_options ) ) ? array_map( function ( $val ) {
return is_scalar( $val ) ? html_entity_decode( $val ) : $val;
}, $db_options ) : array();
$this->options = wp_parse_args( $db_options, $this->default_general_settings() );
return $this->options;
}
public function maybe_add_js() {
wp_enqueue_script( 'bwf-general-settings', plugin_dir_url( WooFunnel_Loader::$ultimate_path ) . 'woofunnels/assets/js/bwf-general-settings.js', [], BWF_VERSION );
wp_enqueue_style( 'bwf-general-settings', plugin_dir_url( WooFunnel_Loader::$ultimate_path ) . 'woofunnels/assets/css/bwf-general-settings.css', array(), BWF_VERSION );
wp_localize_script( 'bwf-general-settings', 'bwfAdminGen', $this->get_localized_data() );
}
public function get_localized_data() {
$localized_data = [
'nonce_general_settings' => wp_create_nonce( 'bwf_general_settings_update' ),
'texts' => array(
'settings_success' => __( 'Changes saved', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'permalink_help_text' => __( 'Leave empty to remove slug completely from url', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
),
'globalOptionsFields' => array(
'options' => $this->filter_admin_options( $this->get_option() ),
'legends_texts' => array(
'fb' => __( 'Facebook Pixel', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'ga' => __( 'Google Analytics', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'gad' => __( 'Google Ads', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'pint' => __( 'Pinterest', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'permalinks' => __( 'Permalinks', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'tiktok' => __( 'Tiktok', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'snapchat' => __( 'Snapchat', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
),
'fields' => $this->all_fields()
)
];
$localized_data['is_pinterest_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_pinterest', false ) ) ? 1 : 0;
$localized_data['is_tiktok_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_tiktok', false ) ) ? 1 : 0;
$localized_data['is_snapchat_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_snapchat', false ) ) ? 1 : 0;
$localized_data['is_gad_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_gad', false ) ) ? 1 : 0;
$localized_data['is_pixel_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_pixel', false ) ) ? 1 : 0;
$localized_data['is_ga_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_ga', false ) ) ? 1 : 0;
$localized_data['if_fb_checkout_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_fb_checkout', false ) ) ? 1 : 0;
$localized_data['if_fb_purchase_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_fb_purchase', false ) ) ? 1 : 0;
$localized_data['if_ga_checkout_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_ga_checkout', false ) ) ? 1 : 0;
$localized_data['if_ga_purchase_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_ga_purchase', false ) ) ? 1 : 0;
$localized_data['if_gad_checkout_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_gad_checkout', false ) ) ? 1 : 0;
$localized_data['if_gad_purchase_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_gad_purchase', false ) ) ? 1 : 0;
$localized_data['if_pint_checkout_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_pint_checkout', false ) ) ? 1 : 0;
$localized_data['if_pint_purchase_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_pint_purchase', false ) ) ? 1 : 0;
$localized_data['if_tiktok_checkout_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_tiktok_checkout', false ) ) ? 1 : 0;
$localized_data['if_tiktok_purchase_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_tiktok_purchase', false ) ) ? 1 : 0;
$localized_data['if_snapchat_checkout_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_snapchat_checkout', false ) ) ? 1 : 0;
$localized_data['if_snapchat_purchase_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_snapchat_purchase', false ) ) ? 1 : 0;
$localized_data['if_landing_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_landing', false ) ) ? 1 : 0;
$localized_data['if_optin_enabled'] = ( true === apply_filters( 'bwf_enable_ecommerce_integration_optin', false ) ) ? 1 : 0;
$localized_data['if_ga4_enabled'] = ( true === apply_filters( 'bwf_enable_ga4', false ) ) ? 1 : 0;
$checkout_page_slug = 'checkout';
$checkout_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'checkout' ) : 0;
if ( $checkout_id > - 1 ) {
$checkout_page = get_post( $checkout_id );
if ( $checkout_page instanceof WP_Post ) {
$checkout_page_slug = $checkout_page->post_name;
}
}
$localized_data['checkout_page_slug'] = $checkout_page_slug;
$localized_data['permalink_structure'] = get_option( 'permalink_structure' );
$localized_data['errors'] = array(
'checkout_slug' => sprintf( __( 'Error: The permalink "%s" is reserved by Native WooCommerce Checkout Page. Try another permalink.', 'woofunnels' ), $checkout_page_slug ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
'empty_base' => sprintf( __( 'Error: The current Permalinks settings does not allow blank values. Switch Permalink settings to \'Post name\'. <a href="%s">Click Here To Change</a>', 'woofunnels' ), admin_url( 'options-permalink.php' ) ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
);
return $localized_data;
}
public function get_localized_bwf_data() {
$localized_data = [];
$checkout_page_slug = 'checkout';
$checkout_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'checkout' ) : 0;
if ( $checkout_id > - 1 ) {
$checkout_page = get_post( $checkout_id );
if ( $checkout_page instanceof WP_Post ) {
$checkout_page_slug = $checkout_page->post_name;
}
}
$localized_data['checkout_page_slug'] = $checkout_page_slug;
$localized_data['permalink_structure'] = get_option( 'permalink_structure' );
$localized_data['errors'] = array(
'checkout_slug' => sprintf( __( 'Error: The permalink "%s" is reserved by Native WooCommerce Checkout Page. Try another permalink.', 'woofunnels' ), $checkout_page_slug ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
'empty_base' => sprintf( __( 'Error: The current Permalinks settings does not allow blank values. Switch Permalink settings to \'Post name\'. <a href="%s">Click Here To Change</a>', 'woofunnels' ), admin_url( 'options-permalink.php' ) ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
);
$localized_data['pro_status'] = [];
$License = WooFunnels_licenses::get_instance();
if ( is_object( $License ) && is_array( $License->plugins_list ) && count( $License->plugins_list ) ) {
foreach ( $License->plugins_list as $license ) {
if ( in_array( $license['product_file_path'], array( '7b31c172ac2ca8d6f19d16c4bcd56d31026b1bd8', '913d39864d876b7c6a17126d895d15322e4fd2e8' ), true ) ) {
continue;
}
$license_data = [];
if ( isset( $license['_data'] ) && isset( $license['_data']['data_extra'] ) ) {
$license_data = $license['_data']['data_extra'];
if ( isset( $license_data['api_key'] ) ) {
$license_data['api_key'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxx' . substr( $license_data['api_key'], - 6 );
$license_data['licence'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxx' . substr( $license_data['api_key'], - 6 );
}
}
if ( $license['plugin'] === 'FunnelKit Funnel Builder Pro' || $license['plugin'] === 'FunnelKit Funnel Builder Basic' ) {
$data = array(
'id' => $license['product_file_path'],
'label' => $license['plugin'],
'type' => 'license',
'key' => $license['product_file_path'],
'license' => ! empty( $license_data ) ? $license_data : false,
'is_manually_deactivated' => ( isset( $license['_data']['manually_deactivated'] ) && true === bwf_string_to_bool( $license['_data']['manually_deactivated'] ) ) ? 1 : 0,
'activated' => ( isset( $license['_data']['activated'] ) && true === bwf_string_to_bool( $license['_data']['activated'] ) ) ? 1 : 0,
'expired' => ( isset( $license['_data']['expired'] ) && true === bwf_string_to_bool( $license['_data']['expired'] ) ) ? 1 : 0
);
$localized_data['pro_status'] = $data;
}
}
}
return $localized_data;
}
public function update_general_settings() {
check_admin_referer( 'bwf_general_settings_update', '_nonce' );
$options = isset( $_POST['data'] ) ? bwf_clean( $_POST['data'] ) : 0;
$resp = $this->update_global_settings_fields( $options );
wp_send_json( $resp );
}
public function update_global_settings_fields( $options ) {
$options = ( is_array( $options ) && wp_unslash( bwf_clean( $options ) ) ) ? bwf_clean( $options ) : 0;
$resp = [
'status' => false,
'msg' => __( 'Settings Updated', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'data' => '',
];
$db_options = get_option( 'bwf_gen_config', [] );
if(!is_array($db_options)) {
$db_options = [];
}
$options = array_merge( $this->default_general_settings(), $db_options, $options );
if ( $options !== 0 ) {
update_option( 'bwf_gen_config', $options, true );
update_option( 'bwf_needs_rewrite', 'yes', true );
if ( class_exists( 'BWF_JSON_Cache' ) && method_exists( 'BWF_JSON_Cache', 'run_json_endpoints_cache_handling' ) ) {
BWF_JSON_Cache::run_json_endpoints_cache_handling();
}
$resp['status'] = true;
}
do_action( 'bwf_general_settings_updated', $options );
return $resp;
}
public function get_settings_link() {
return apply_filters( 'bwf_general_settings_link', 'javascript:void(0)' );
}
public function hide_from_menu() {
global $woofunnels_menu_slug;
global $parent_file, $plugin_page, $submenu_file; //phpcs:ignore
if ( filter_input( INPUT_GET, 'tab', FILTER_UNSAFE_RAW ) === 'bwf_settings' ) :
$parent_file = $woofunnels_menu_slug;//phpcs:ignore
$submenu_file = 'admin.php?page=woofunnels_settings'; //phpcs:ignore
endif;
}
/**
* Filter options before passing it to the javascript
*
* @param $config array configuration array
*
* @return array
*/
public function filter_admin_options( $config ) {
foreach ( $config as $key => &$data ) {
/**
* Check if data is 'false' (string) then make it blank so that checkboxes works accordingly
*/
if ( 'false' === $data ) {
$config[ $key ] = '';
}
}
return $config;
}
public function maybe_change_title( $title ) {
if ( 'bwf_settings' === filter_input( INPUT_GET, 'tab', FILTER_UNSAFE_RAW ) || 'bwf_settings' === filter_input( INPUT_GET, 'section', FILTER_UNSAFE_RAW ) ) {
$admin_title = get_bloginfo( 'name' );
$title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress', 'woofunnels' ), 'FunnelKit', $admin_title ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
}
return $title;
}
public function all_fields() {
$static_config = include WooFunnel_Loader::$ultimate_path . '/helpers/settings.php';
$legacy = apply_filters( 'bwf_general_settings_fields', [] );
$legacy_altered = [];
if ( count( $legacy ) > 0 ) {
$i = 0;
foreach ( $legacy as $key => $new ) {
$legacy_altered[ $i ] = array( 'key' => $key );
$legacy_altered[ $i ] = array_merge( $legacy_altered[ $i ], $new );
$i ++;
}
}
$static_config['permalinks']['fields'] = $legacy_altered;
foreach ( $static_config as &$arr ) {
$values = [];
foreach ( $arr['fields'] as &$field ) {
$values[ $field['key'] ] = $this->get_option( $field['key'] );
}
$arr['values'] = $values;
}
return $static_config;
}
}
}
BWF_Admin_General_Settings::get_instance();

View File

@@ -0,0 +1,90 @@
<?php
if ( ! class_exists( 'BWF_Data_Tags' ) ) {
#[AllowDynamicProperties]
class BWF_Data_Tags {
public $shortcodes = array(
'get_cookie',
'get_url_parameter',
);
// The pattern to match restricted cookies 'wordpress_*', '_fk_contact_uid', 'wp-settings-*', 'PHPSESSID', 'wordpress_logged_in_*', 'wp_woocommerce_session_*'
public $restricted_cookie_pattern = "/^(wordpress_.*|_fk_contact_uid|wp-settings-.*|PHPSESSID|wordpress_logged_in_.*|wp_woocommerce_session_.*)$/";
public function __construct() {
foreach ( $this->shortcodes as $code ) {
add_shortcode( 'wf_' . $code, array( $this, $code ) );
}
}
private static $ins = null;
/**
* @return BWF_Optin_Tags|null
*/
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function get_first_name( $attr ) {
if ( isset( $this->get_optin()->optin_first_name ) && ! empty( $this->get_optin()->optin_first_name ) ) {
return $this->get_optin()->optin_first_name;
}
return $this->get_default( $attr, 'first_name' );
}
public function get_cookie( $attr ) {
$attr = shortcode_atts( array(
'key' => '',
), $attr );
if ( empty( $attr['key'] ) ) {
return '';
}
// Check if the cookie key is restricted
if (preg_match($this->restricted_cookie_pattern, $attr['key'])) {
return '';
}
$data = isset( $_COOKIE[ $attr['key'] ] ) ? bwf_clean( $_COOKIE[ $attr['key'] ] ) : '';
/*** read cookie when drop cookie on page **/
if ( empty( $data ) ) {
$key = str_replace( 'bwf_', '', $attr['key'] );
$data = isset( $_GET[ $key ] ) ? bwf_clean( $_GET[ $key ] ) : '';
}
return $data;
}
public function get_url_parameter( $attr ) {
$attr = shortcode_atts( array(
'key' => '',
), $attr );
if ( empty( $attr['key'] ) ) {
return '';
}
return isset( $_GET[ $attr['key'] ] ) ? bwf_clean( $_GET[ $attr['key'] ] ) : '';
}
}
BWF_Data_Tags::get_instance();
}

View File

@@ -0,0 +1,60 @@
<?php
if ( ! class_exists( 'BWF_Facebook_Sdk_Factory' ) ) {
#[AllowDynamicProperties]
class BWF_Facebook_Sdk_Factory {
private static $pixel_id = null;
private static $access_token = null;
private static $version = null;
private static $setup_run = false;
private static $test_event_code = false;
private static $partner_code = false;
/**
* @param $pixel_id
* @param $access_token
* @param string $version
*
* @return boolean
*/
public static function setup( $pixel_id, $access_token, $version = 'v11.0' ) {
if ( empty( $pixel_id ) || empty( $access_token ) ) {
return false;
}
self::$pixel_id = $pixel_id;
self::$access_token = $access_token;
self::$version = $version;
self::$setup_run = true;
return true;
}
public static function set_test( $test_code ) {
self::$test_event_code = $test_code;
}
public static function set_partner( $partner_code ) {
self::$partner_code = $partner_code;
}
public static function create() {
if ( false == self::$setup_run ) {
return null;
}
$instance = new BWF_Facebook_Sdk( self::$pixel_id, self::$access_token, self::$version );
if ( ! empty( self::$test_event_code ) ) {
$instance->set_test_event_code( self::$test_event_code );
}
if ( ! empty( self::$partner_code ) ) {
$instance->set_partner_agent( self::$partner_code );
}
return $instance;
}
}
}

View File

@@ -0,0 +1,353 @@
<?php
if ( ! class_exists( 'BWF_Facebook_Sdk' ) ) {
#[AllowDynamicProperties]
class BWF_Facebook_Sdk {
private static $instance = null;
protected $container = array();
protected $event_data = array();
private $api_url = 'https://graph.facebook.com';
private $version = '';
private $pixel_id = '';
private $event_name = '';
private $time = '';
private $test_event_code = '';
private $partner_agent = '';
private $body = [];
private $response_body = null;
private $access_token = '';
public function __construct( $pixel_id, $access_token, $version = 'v11.0' ) {
if ( ! empty( $pixel_id ) ) {
$this->pixel_id = $pixel_id;
}
if ( ! empty( $access_token ) ) {
$this->access_token = $access_token;
}
if ( ! empty( $version ) ) {
$this->version = $version;
}
$this->time = time();
}
public static function create( $pixel_id, $access_token, $version = 'v11.0' ) {
if ( is_null( self::$instance ) ) {
self::$instance = new self( $pixel_id, $access_token, $version );
}
return self::$instance;
}
public function set_event_data( $event_name, $event_data ) {
$this->event_name = $event_name;
$this->event_data = $event_data;
}
public function set_event_source_url( $url = '' ) {
$this->source_url = $url;
}
public function execute() {
$out_response = [ 'status' => false, 'errors' => [] ];
if ( empty( $this->event_name ) && empty( $this->event_data ) ) {
$out_response['errors'][] = 'Event Name is empty';
}
if ( count( $out_response['errors'] ) > 0 ) {
return $out_response;
}
$event_id = $this->get_event_id();
$input = [ 'event_name' => $this->event_name, 'event_time' => $this->get_time(), 'action_source' => 'website', 'event_id' => $event_id ];
if ( isset( $this->source_url ) ) {
$input['event_source_url'] = $this->source_url;
}
$user_data = $this->get_user_data();
if ( ! empty( $user_data ) ) {
$input['user_data'] = $user_data;
}
$input['custom_data'] = $this->event_data;
$body = [ 'data' => [ $input ] ];
if ( ! empty( $this->test_event_code ) ) {
$body['test_event_code'] = $this->test_event_code;
}
if ( ! empty( $this->partner_agent ) ) {
$body['partner_agent'] = $this->partner_agent;
}
$headers = [
'Authorization' => 'Bearer ' . $this->access_token,
];
$this->body = $body;
$post = wp_remote_post( $this->get_api_url(), [
'timeout' => 2,
'sslverify' => false,
'body' => $this->body,
'headers' => $headers
] );
$this->response_body = wp_remote_retrieve_body( $post );
return array( 'request' => $this->get_request_body(), 'response' => $this->response_body );
}
public function get_event_id() {
return isset( $this->container['event_id'] ) ? $this->container['event_id'] : '';
}
public function get_time() {
return time();
}
public function get_user_data() {
$normalized_payload = array();
$normalized_payload['em'] = self::hash( $this->getEmail() );
$normalized_payload['ph'] = self::hash( $this->getPhone() );
$normalized_payload['ge'] = self::hash( $this->getGender() );
$normalized_payload['db'] = self::hash( $this->getDateOfBirth() );
$normalized_payload['ln'] = self::hash( $this->getLastName() );
$normalized_payload['fn'] = self::hash( $this->getFirstName() );
$normalized_payload['ct'] = self::hash( $this->getCity() );
$normalized_payload['st'] = self::hash( $this->getState() );
$normalized_payload['zp'] = self::hash( $this->getZipCode() );
$normalized_payload['country'] = self::hash( $this->getCountryCode() );
$normalized_payload['dobd'] = self::hash( $this->getDobd() );
$normalized_payload['dobm'] = self::hash( $this->getDobm() );
$normalized_payload['doby'] = self::hash( $this->getDoby() );
$normalized_payload['client_ip_address'] = $this->getIpAddress();
$normalized_payload['client_user_agent'] = $this->getHttpUserAgent();
$normalized_payload['fbc'] = $this->getFbc();
$normalized_payload['fbp'] = $this->getFbp();
$normalized_payload['external_id'] = $this->getExternalId();
$normalized_payload = array_filter( $normalized_payload );
return $normalized_payload;
}
/**
* @param string $data hash input data using SHA256 algorithm.
*
* @return string
*/
public static function hash( $data ) {
if ( $data == null || self::isHashed( $data ) ) {
return $data;
}
return hash( 'sha256', $data, false );
}
/**
* @param string $pii PII data to check if its hashed.
*
* @return bool
*/
public static function isHashed( $pii ) {
// it could be sha256 or md5
return preg_match( '/^[A-Fa-f0-9]{64}$/', $pii ) || preg_match( '/^[a-f0-9]{32}$/', $pii );
}
/**
* Gets an email address, in lowercase.
* @return string
*/
public function getEmail() {
return $this->container['email'];
}
/**
* Gets a phone number
* @return string
*/
public function getPhone() {
return $this->container['phone'];
}
/**
* Gets gender.
* @return string
*/
public function getGender() {
return $this->container['gender'];
}
/**
* Gets Date Of Birth.
* @return string
*/
public function getDateOfBirth() {
return $this->container['date_of_birth'];
}
/**
* Gets Last Name.
* @return string
*/
public function getLastName() {
return $this->container['last_name'];
}
/**
* Gets First Name.
* @return string
*/
public function getFirstName() {
return $this->container['first_name'];
}
/**
* Gets city.
* @return string
*/
public function getCity() {
return $this->container['city'];
}
/**
* Gets state.
* @return string
*/
public function getState() {
return $this->container['state'];
}
/**
* Gets zip code
* @return string
*/
public function getZipCode() {
return $this->container['zip_code'];
}
/**
* Gets country code.
* @return string
*/
public function getCountryCode() {
return $this->container['country_code'];
}
/**
* Gets the date of birth day.
* @return string
*/
public function getDobd() {
return $this->container['dobd'];
}
/**
* Gets the date of birth month.
* @return string
*/
public function getDobm() {
return $this->container['dobm'];
}
/**
* Gets the date of birth year.
* @return string
*/
public function getDoby() {
return $this->container['doby'];
}
/**
* Extracts the IP Address from the PHP Request Context.
* @return string
*/
public function getIpAddress() {
return $this->container['client_ip_address'];
}
/**
* Extracts the HTTP User Agent from the PHP Request Context.
* @return string
*/
public function getHttpUserAgent() {
return $this->container['client_user_agent'];
}
/**
* Extracts the FBC cookie from the PHP Request Context.
* @return string
*/
public function getFbc() {
return $this->container['fbc'];
}
/**
* Extracts the FBP cookie from the PHP Request Context.
* @return string
*/
public function getFbp() {
return $this->container['fbp'];
}
public function getExternalId() {
return $this->container['external_id'];
}
public function get_api_url() {
return $this->api_url . '/' . $this->version . '/' . $this->pixel_id . '/events';
}
public function get_request_body() {
return $this->body;
}
public function set_user_data( $data = [] ) {
$this->container['email'] = isset( $data['email'] ) ? $data['email'] : ( isset( $data['em'] ) ? $data['em'] : null );
$this->container['phone'] = isset( $data['phone'] ) ? $data['phone'] : ( isset( $data['ph'] ) ? $data['ph'] : null );
$this->container['gender'] = isset( $data['gender'] ) ? $data['gender'] : null;
$this->container['date_of_birth'] = isset( $data['date_of_birth'] ) ? $data['date_of_birth'] : null;
$this->container['last_name'] = isset( $data['last_name'] ) ? $data['last_name'] : ( isset( $data['ln'] ) ? $data['ln'] : null );
$this->container['first_name'] = isset( $data['first_name'] ) ? $data['first_name'] : ( isset( $data['fn'] ) ? $data['fn'] : null );
$this->container['city'] = isset( $data['city'] ) ? $data['city'] : ( isset( $data['ct'] ) ? $data['ct'] : null );
$this->container['state'] = isset( $data['state'] ) ? $data['state'] : ( isset( $data['st'] ) ? $data['st'] : null );
$this->container['dobd'] = isset( $data['dobd'] ) ? $data['dobd'] : null;
$this->container['dobm'] = isset( $data['dobm'] ) ? $data['dobm'] : null;
$this->container['doby'] = isset( $data['doby'] ) ? $data['doby'] : null;
$this->container['country_code'] = isset( $data['country_code'] ) ? $data['country_code'] : ( isset( $data['country'] ) ? $data['country'] : null );
$this->container['zip_code'] = isset( $data['zip_code'] ) ? $data['zip_code'] : null;
$this->container['client_user_agent'] = isset( $data['client_user_agent'] ) ? $data['client_user_agent'] : null;
$this->container['client_ip_address'] = isset( $data['client_ip_address'] ) ? $data['client_ip_address'] : null;
$this->container['fbp'] = isset( $data['fbp'] ) ? $data['fbp'] : null;
$this->container['fbc'] = isset( $data['fbc'] ) ? $data['fbc'] : null;
$this->container['fbp'] = isset( $data['_fbp'] ) ? $data['_fbp'] : $this->container['fbp'];
$this->container['fbc'] = isset( $data['_fbc'] ) ? $data['_fbc'] : $this->container['fbc'];
$this->container['external_id'] = isset( $data['external_id'] ) ? $data['external_id'] : null;
}
public function get_response_body() {
return $this->response_body;
}
public function set_event_id( $event_id ) {
return $this->container['event_id'] = $event_id;
}
public function set_test_event_code( $event_code ) {
$this->test_event_code = $event_code;
}
public function set_partner_agent( $partner_agent ) {
$this->partner_agent = $partner_agent;
}
/**
* Extracts the URI from the PHP Request Context.
* @return string
*/
public function getRequestUri() {
return $this->container['reuqesturi'];
}
}
}

View File

@@ -0,0 +1,327 @@
<?php
if ( ! class_exists( 'BWF_JSON_Cache' ) ) {
class BWF_JSON_Cache {
public static function run_json_endpoints_cache_handling() {
/** Litespeed cache */
self::check_litespeed();
/** WordPress REST API Authentication */
self::check_wp_rest_api_authentication();
/** WP rocket cache */
self::check_wp_rocket();
/** WP fastest cache */
self::check_wp_fastest_cache();
}
/**
* For litespeed cache
* https://wordpress.org/plugins/litespeed-cache/
*
* @return void
*/
public static function check_litespeed() {
if ( ! defined( 'LSCWP_V' ) ) {
return;
}
/** Exclude json endpoints */
$exc_endpoints = get_option( 'litespeed.conf.cache-exc', '' );
$exc_endpoints = self::make_array( $exc_endpoints );
if ( defined( 'BWFAN_API_NAMESPACE' ) ) {
$exc_endpoints[] = "^/wp-json/" . BWFAN_API_NAMESPACE . "/";
}
$exc_endpoints[] = "^/wp-json/woofunnels/";
$exc_endpoints[] = "^/wp-json/funnelkit-automations/";
$exc_endpoints = self::maybe_clear_fb_endpoints( $exc_endpoints );
$exc_endpoints = self::unique( $exc_endpoints );
update_option( 'litespeed.conf.cache-exc', wp_json_encode( $exc_endpoints ) );
/** Exclude role */
$exc_role = get_option( 'litespeed.conf.cache-exc_roles', '' );
$exc_role = self::make_array( $exc_role );
$exc_role[] = "administrator";
$exc_role = self::unique( $exc_role );
update_option( 'litespeed.conf.cache-exc_roles', wp_json_encode( $exc_role ) );
/** Exclude query string */
$exc_qs = get_option( 'litespeed.conf.cache-exc_qs', '' );
$exc_qs = self::make_array( $exc_qs );
$exc_qs[] = "bwfan-track-id";
$exc_qs[] = "bwfan-track-action";
$exc_qs[] = "bwfan-link-trigger";
$exc_qs = self::unique( $exc_qs );
update_option( 'litespeed.conf.cache-exc_qs', wp_json_encode( $exc_qs ) );
}
/**
* For WordPress rest api authentication
* https://wordpress.org/plugins/wp-rest-api-authentication/
*
* @return void
*/
public static function check_wp_rest_api_authentication() {
if ( ! defined( 'MINIORANGE_API_AUTHENTICATION_VERSION' ) ) {
return;
}
/** json endpoints */
$endpoints = get_option( 'mo_api_authentication_protectedrestapi_route_whitelist', '' );
if ( empty( $endpoints ) ) {
return;
}
$endpoints = maybe_unserialize( $endpoints );
$exc_endpoints = [
"/woofunnels/v1",
"/autonami/v1",
"/autonami/v2",
"/funnelkit-automations",
];
$exc_endpoints = self::maybe_clear_fb_endpoints( $exc_endpoints, 'api-auth' );
$endpoints = array_filter( $endpoints, function ( $endpoint ) use ( $exc_endpoints ) {
foreach ( $exc_endpoints as $url ) {
if ( false !== strpos( $endpoint, $url ) ) {
return false;
}
}
return true;
} );
$endpoints = self::unique( $endpoints );
update_option( 'mo_api_authentication_protectedrestapi_route_whitelist', $endpoints );
}
/**
* For WP rocket cache
* https://wp-rocket.me/
*
* @return void
*/
public static function check_wp_rocket() {
if ( ! defined( 'WP_ROCKET_VERSION' ) || ! function_exists( 'get_rocket_option' ) || ! function_exists( 'update_rocket_option' ) || ! function_exists( 'rocket_generate_config_file' ) ) {
return;
}
$exc_endpoints = (array) get_rocket_option( 'cache_reject_uri', [] );
$exc_endpoints = self::make_array( $exc_endpoints );
if ( defined( 'BWFAN_API_NAMESPACE' ) ) {
$exc_endpoints[] = "^/wp-json/" . BWFAN_API_NAMESPACE . "/";
}
$exc_endpoints[] = "/wp-json/woofunnels/*";
$exc_endpoints[] = "/wp-json/funnelkit-automations/*";
$exc_endpoints = self::maybe_clear_fb_endpoints( $exc_endpoints, 'wp_rocket' );
$exc_endpoints = self::unique( $exc_endpoints );
/** Update the "Never cache the following pages" option */
update_rocket_option( 'cache_reject_uri', $exc_endpoints );
/** Update config file */
rocket_generate_config_file();
}
/**
* For WP fastest cache
* https://wordpress.org/plugins/wp-fastest-cache/
*
* @return void
*/
public static function check_wp_fastest_cache() {
if ( ! class_exists( 'WpFastestCache' ) ) {
return;
}
$existing_data = get_option( 'WpFastestCacheExclude' );
$existing_rules = self::make_array( $existing_data );
$new_rules_array = [
[
"prefix" => "contain",
"content" => "bwfan-action",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "bwfan-track-id",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "bwfan-link-trigger",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "bwfan-track-action",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "wp-json/woofunnels/",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "wp-json/autonami/",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "wp-json/funnelkit-automations",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "wp-json/funnelkit-app",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "wp-json/woofunnel_customer/",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "wp-json/autonami-app",
"type" => "page"
],
[
"prefix" => "contain",
"content" => "wp-json/autonami-webhook",
"type" => "page"
]
];
$new_rules = array_filter( $new_rules_array, function ( $new_rule ) use ( $existing_rules ) {
return ! in_array( $new_rule, $existing_rules, true );
} );
if ( empty( $new_rules ) ) {
return;
}
$updated_array = array_merge( $existing_rules, $new_rules );
$updated_json = wp_json_encode( $updated_array );
update_option( 'WpFastestCacheExclude', $updated_json );
}
/**
* Convert string/ json to array
*
* @param $value
*
* @return array
*/
public static function make_array( $value ) {
$value = self::is_json( $value ) ? json_decode( $value, true ) : $value;
return empty( $value ) || ! is_array( $value ) ? [] : $value;
}
/**
* Check if string is a json
*
* @param $string
*
* @return bool
*/
public static function is_json( $string ) {
if ( ! is_string( $string ) ) {
return false;
}
json_decode( $string );
return ( json_last_error() === JSON_ERROR_NONE );
}
/**
* Array unique and sort
*
* @param $value
*
* @return array|mixed
*/
public static function unique( $value ) {
if ( ! is_array( $value ) ) {
return $value;
}
$value = array_unique( $value );
sort( $value );
return $value;
}
/**
* @param $endpoints
* @param $plugin_slug
*
* @return array|mixed
*/
public static function maybe_clear_fb_endpoints( $endpoints, $plugin_slug = 'litespeed' ) {
if ( ! class_exists( 'WFFN_Core' ) ) {
return $endpoints;
}
$endpoints = ( ! is_array( $endpoints ) ) ? [] : $endpoints;
$db_options = get_option( 'bwf_gen_config', [] );
$cl_slug = is_array( $db_options ) && isset( $db_options['checkout_page_base'] ) ? $db_options['checkout_page_base'] : '';
$of_slug = is_array( $db_options ) && isset( $db_options['wfocu_page_base'] ) ? $db_options['wfocu_page_base'] : '';
if ( 'api-auth' === $plugin_slug ) {
$endpoints[] = "/funnelkit-app/";
if ( ! empty( $cl_slug ) ) {
$endpoints[] = '/' . $cl_slug . '/';
}
if ( ! empty( $of_slug ) ) {
$endpoints[] = '/' . $of_slug . '/';
}
return $endpoints;
}
if ( 'litespeed' === $plugin_slug ) {
$endpoints[] = "^/wp-json/funnelkit-app/";
if ( ! empty( $cl_slug ) ) {
$endpoints[] = '^/' . $cl_slug . '/';
}
if ( ! empty( $of_slug ) ) {
$endpoints[] = '^/' . $of_slug . '/';
}
return $endpoints;
}
if ( 'wp_rocket' === $plugin_slug ) {
$endpoints[] = "^/wp-json/funnelkit-app/(.*)";
if ( ! empty( $cl_slug ) ) {
$endpoints[] = '^/' . $cl_slug . '/(.*)';
}
if ( ! empty( $of_slug ) ) {
$endpoints[] = '^/' . $of_slug . '/(.*)';
}
return $endpoints;
}
return $endpoints;
}
}
}

View File

@@ -0,0 +1,112 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'BWF_Logger' ) ) {
#[AllowDynamicProperties]
class BWF_Logger {
private static $ins = null;
public $wc_logger = null;
public function __construct() {
}
public static function get_instance() {
if ( self::$ins === null ) {
self::$ins = new self;
}
return self::$ins;
}
public function log( $message, $file_name = '', $folder_prefix = 'fk-temp', $force = false ) {
if ( ! $force && false === apply_filters( 'bwf_logs_allowed', false, $file_name ) ) {
return;
}
$plugin_short_name = $folder_prefix . '-logs';
$transient_key = $file_name . '-' . gmdate( 'Y-m-d' );
$transient_key = $transient_key . '-' . hash_hmac( 'md5', $transient_key, defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : 'funnelkit-logs' );
$transient_value = gmdate( 'c', time() ) . ' - ' . $message . "\n";
$file_api = $this->is_writable( $plugin_short_name, $transient_key );
if ( false === $file_api ) {
return;
}
$old_content = $file_api->get_contents( $transient_key );
if ( ! empty( $old_content ) ) {
$old_content = maybe_unserialize( $old_content );
$transient_value = $old_content . $transient_value;
}
$transient_value = maybe_serialize( $transient_value );
$file_api->put_contents( $transient_key, $transient_value );
}
public function is_writable( $plugin_short_name, $transient_key ) {
if ( ! class_exists( 'WooFunnels_File_Api' ) ) {
return false;
}
$file_api = new WooFunnels_File_Api( $plugin_short_name );
$file_api->touch( $transient_key );
if ( $file_api->is_writable( $transient_key ) && $file_api->is_readable( $transient_key ) ) {
return $file_api;
}
return false;
}
public function get_log_options() {
$wp_dir = wp_upload_dir();
$woofunnels_uploads_directory = $wp_dir['basedir'];
$woofunnels_uploads_directory = $woofunnels_uploads_directory . '/funnelkit';
$final_logs_result = array();
$plugin_logs_directories = glob( $wp_dir['basedir'] . '/funnelkit/*-logs' );
foreach ( $plugin_logs_directories as $directory ) {
$result = array();
$directory_data = pathinfo( $directory );
if ( ! isset( $directory_data['basename'] ) ) {
continue;
}
$plugin_uploads_directory = $woofunnels_uploads_directory . '/' . $directory_data['basename'];
$files = @scandir( $plugin_uploads_directory ); // @codingStandardsIgnoreLine.
if ( ! is_array( $files ) || 0 === count( $files ) ) {
continue;
}
$file_timestamps = array();
foreach ( $files as $value ) {
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
$file_path = $plugin_uploads_directory . '/' . $value;
if ( ! is_dir( $file_path ) ) {
$file_timestamps[$value] = filemtime( $file_path );
}
}
}
// Sort files by modified time (newest first)
arsort( $file_timestamps );
foreach ( $file_timestamps as $file => $timestamp ) {
$result[$file] = $file;
}
if ( is_array( $result ) && count( $result ) > 0 ) {
$final_logs_result[ $directory_data['basename'] ] = $result;
}
}
return $final_logs_result;
}
}
}

View File

@@ -0,0 +1,102 @@
<?php
/*if ( ! class_exists( 'WFCO_Model' ) ) {
require_once __DIR__ . '/class-wfco-model.php';
}*/
if ( ! class_exists( 'WFCO_Model_Report_views' ) ) {
#[AllowDynamicProperties]
class WFCO_Model_Report_views extends WFCO_Model {
static $primary_key = 'ID';
public static function count_rows( $dependency = null ) {
global $wpdb;
$table_name = self::_table();
$sql = 'SELECT COUNT(*) FROM ' . $table_name;
if ( 'all' !== filter_input( INPUT_GET, 'status', FILTER_UNSAFE_RAW ) ) {
$status = filter_input( INPUT_GET, 'status', FILTER_UNSAFE_RAW );
$status = ( 'active' === $status ) ? 1 : 2;
$sql = $wpdb->prepare( "SELECT COUNT(*) FROM $table_name WHERE status = %d", $status ); //phpcs:ignore WordPress.DB.PreparedSQL
}
return $wpdb->get_var( $sql ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
}
private static function _table() {
global $wpdb;
$table_name = strtolower( get_called_class() );
$table_name = str_replace( 'wfco_model_', 'wfco_', $table_name );
return $wpdb->prefix . $table_name;
}
/**
* @param string $date Date(Y-m-d)
* @param string $object_id post_id or unique_id
* @param int $type 1=abandoned,2=upstroke,3=aero,4=bump
*/
public static function update_data( $date = '', $object_id = '', $type = 1 ) {
global $wpdb;
$where = [];
$insert = [];
if ( $date !== '' ) {
$where['date'] = "`date`='$date'";
$insert['date'] = $date;
} else {
$date = date( 'Y-m-d' );
$where['date'] = "`date`='$date'";
$insert['date'] = $date;
}
if ( $object_id !== '' ) {
$where['object_id'] = "`object_id`='$object_id'";
$insert['object_id'] = $object_id;
}
$where['type'] = "`type`='$type'";
$insert['type'] = $type;
$where_string = implode( ' and ', $where );
$table = self::_table();
$get_sql = "SELECT * FROM $table WHERE {$where_string};";
$result = $wpdb->get_results( $get_sql, ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
if ( ! empty( $result ) ) {
$primary_id = $result[0]['id'];
$sql = "UPDATE $table set no_of_sessions=no_of_sessions+1 where id ='{$primary_id}';";
$wpdb->query( $sql ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
} else {
$wpdb->insert( $table, $insert ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
}
public static function get_data( $date = '', $object_id = '', $type = 1, $interval = false ) {
$where = [];
if ( $date !== '' ) {
if ( true === $interval ) {
$where['date'] = $date;
} else {
$where['date'] = "`date`='$date'";
}
} else {
$date = date( 'Y-m-d' );
$where['date'] = "`date`='$date'";
}
if ( $object_id !== '' ) {
$where['object_id'] = "`object_id`='$object_id'";
}
$where['type'] = "`type`='$type'";
$where_string = implode( ' and ', $where );
global $wpdb;
$table = self::_table();
$sql = "select * from `{$table}` WHERE {$where_string};";
$data = $wpdb->get_results( $sql, ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
return $data;
}
}
}

View File

@@ -0,0 +1,118 @@
<?php
if ( ! class_exists( 'WFCO_Model' ) ) {
#[AllowDynamicProperties]
abstract class WFCO_Model {
static $primary_key = 'id';
static $count = 20;
static function get( $value ) {
global $wpdb;
return $wpdb->get_row( self::_fetch_sql( $value ), ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
}
private static function _fetch_sql( $value ) {
global $wpdb;
$sql = sprintf( 'SELECT * FROM %s WHERE %s = %%s', self::_table(), static::$primary_key );
return $wpdb->prepare( $sql, $value ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
}
private static function _table() {
global $wpdb;
$tablename = strtolower( get_called_class() );
$tablename = str_replace( 'wfco_model_', 'wfco_', $tablename );
return $wpdb->prefix . $tablename;
}
static function insert( $data ) {
global $wpdb;
$wpdb->insert( self::_table(), $data ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
static function update( $data, $where ) {
global $wpdb;
$wpdb->update( self::_table(), $data, $where ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
}
static function delete( $value ) {
global $wpdb;
$sql = sprintf( 'DELETE FROM %s WHERE %s = %%s', self::_table(), static::$primary_key );
return $wpdb->query( $wpdb->prepare( $sql, $value ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
}
static function insert_id() {
global $wpdb;
return $wpdb->insert_id;
}
static function now() {
return self::time_to_date( time() );
}
static function time_to_date( $time ) {
return gmdate( 'Y-m-d H:i:s', $time );
}
static function date_to_time( $date ) {
return strtotime( $date . ' GMT' );
}
static function num_rows() {
global $wpdb;
return $wpdb->num_rows;
}
static function count_rows( $dependency = null ) {
global $wpdb;
$sql = 'SELECT COUNT(*) FROM ' . self::_table();
if ( ! is_null( $dependency ) ) {
$sql .= ' INNER JOIN ' . $dependency['dependency_table'];
$sql .= ' on ' . self::_table() . '.' . $dependency['dependent_col'];
$sql .= ' =' . $dependency['dependency_table'] . '.' . $dependency['dependency_col'];
$sql .= ' WHERE ' . $dependency['dependency_table'] . '.' . $dependency['col_name'];
$sql .= ' =' . $dependency['col_value'];
if ( isset( $dependency['connector_id'] ) ) {
$sql .= ' AND ' . $dependency['connector_table'] . '.' . $dependency['connector_col'] . '=' . $dependency['connector_id'];
}
}
return $wpdb->get_var( $sql ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
}
static function get_specific_rows( $where_key, $where_value ) {
global $wpdb;
$table_name = self::_table();
$results = $wpdb->get_results( "SELECT * FROM $table_name WHERE $where_key = '$where_value'", ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
return $results;
}
static function get_results( $query ) {
global $wpdb;
$query = str_replace( '{table_name}', self::_table(), $query );
$results = $wpdb->get_results( $query, ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
return $results;
}
static function delete_multiple( $query ) {
global $wpdb;
$query = str_replace( '{table_name}', self::_table(), $query );
$wpdb->query( $query ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
}
static function update_multiple( $query ) {
global $wpdb;
$query = str_replace( '{table_name}', self::_table(), $query );
$wpdb->query( $query ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
}
}
}

View File

@@ -0,0 +1,93 @@
<?php
if ( ! class_exists( 'WooFunnels_Addons' ) ) {
/**
* Basic class that do operations and get data from wp core
* @since 1.0.0
* @package WooFunnels
* @author woofunnels
*/
#[AllowDynamicProperties]
class WooFunnels_Addons {
public static $installed_addons = array();
public static $update_available = array();
public static function init() {
add_filter( 'extra_plugin_headers', array( __CLASS__, 'extra_woocommerce_headers' ) );
}
/**
* Adding WooFunnels Header to tell WordPress to read one extra params while reading plugin's header info. <br/>
* Hooked over `extra_plugin_headers`
*
* @param array $headers already registered arrays
*
* @return type
* @since 1.0.0
*
*/
public static function extra_woocommerce_headers( $headers ) {
array_push( $headers, 'WooFunnels' );
array_push( $headers, 'WooFunnels' );
return $headers;
}
/**
* Getting all installed plugin that has woofunnels header within
* @return array Addons
*/
public static function get_installed_plugins() {
if ( ! empty( self::$installed_addon ) ) {
return self::$installed_addon;
}
wp_cache_delete( 'plugins', 'plugins' );
$plugins = self::get_plugins( true );
$plug_addons = array();
foreach ( $plugins as $plugin_file => $plugin_data ) {
if ( isset( $plugin_data['WooFunnels'] ) && $plugin_data['WooFunnels'] ) {
$plug_addons[ $plugin_file ] = $plugin_data;
}
}
self::$installed_addons = $plug_addons;
return $plug_addons;
}
/**
* Play it safe and require WP's plugin.php before calling the get_plugins() function.
*
* @return array An array of installed plugins.
*/
public static function get_plugins( $clear_cache = false ) {
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
$plugins = get_plugins();
if ( $clear_cache || ! self::plugins_have_woofunnels_plugin_header( $plugins ) ) {
$plugins = get_plugins();
}
return $plugins;
}
/**
* Checking Plugin header and Trying to find out the one with the header `WooFunnels`
*
* @param Array $plugins array of available plugins
*
* @return mixed
*/
public static function plugins_have_woofunnels_plugin_header( $plugins ) {
$plugin = reset( $plugins );
return $plugin && isset( $plugin['WooFunnels'] );
}
}
WooFunnels_Addons::init();
}

View File

@@ -0,0 +1,127 @@
<?php
if ( ! class_exists( 'WooFunnels_Admin_Notifications' ) ) {
/**
* Class that is responsible for pushing , removing and sometimes handling the way notifications comes from the core.
* @since 1.0.0
* @package WooFunnels
* @author woofunnels
*/
#[AllowDynamicProperties]
class WooFunnels_Admin_Notifications {
public static $all_notifications;
/**
* Add notification
* <br/> This function will add the notification
*
* @param array $args configuration for notification
*
* <br/>
*
* @since 1.0.0
*/
public static function add_notification( $args ) {
$default = array(
'type' => 'success',
'content' => '',
'is_dismissible' => true,
'callback' => null,
'show_only' => false,
);
self::$all_notifications[ key( $args ) ] = wp_parse_args( $args[ key( $args ) ], $default );
}
/**
* Hide notices to show under dashboard
* <br/> Its a handler function to any request come to hide the notice
* <br/> save the slug in Database so that it wont come again
*/
public static function hide_notices() {
if ( isset( $_GET['woofunnels-hide-notice'] ) && isset( $_GET['_woofunnels_notice_nonce'] ) ) {
if ( ! wp_verify_nonce( sanitize_text_field( $_GET['_woofunnels_notice_nonce'] ), 'woofunnels_hide_notices_nonce' ) ) {
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woofunnels' ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'Cheating huh?', 'woofunnels' ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
$hide_notice = sanitize_text_field( $_GET['woofunnels-hide-notice'] );
self::remove_notice( $hide_notice );
do_action( 'woofunnels_hide_' . $hide_notice . '_notice' );
}
}
/**
* Remove a notice from being displayed
*
* @param string $name
*/
public static function remove_notice( $name ) {
$has_notice_removed = get_option( 'woofunnels_admin_notices' );
if ( $has_notice_removed && ! empty( $has_notice_removed ) ) {
$array_to_push = array_push( $has_notice_removed, $name );
update_option( 'woofunnels_admin_notices', $array_to_push, false );
} else {
update_option( 'woofunnels_admin_notices', array( $name ), false );
}
}
/**
* Render all the notifications after filtering
* @since 1.0.0
*/
public static function render() {
self::filter_before_render();
if ( ! is_null( self::$all_notifications ) && ! empty( self::$all_notifications ) ) {
foreach ( self::$all_notifications as $slug => $notification ) {
?>
<div id="message" class="notice notice-<?php echo esc_attr($notification['type']); ?>"><?php echo wp_kses_post( $notification['content'] ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
<?php
}
}
}
/**
* Filter function that will filter pushed notification against the removed ones
*/
public static function filter_before_render() {
$clone = self::$all_notifications;
$get_all_removed = self::get_all_removed();
if ( ! is_null( self::$all_notifications ) && ! empty( self::$all_notifications ) && ! empty( $get_all_removed ) ) {
foreach ( self::$all_notifications as $slug => $notification ) {
if ( in_array( $slug, self::get_all_removed(), true ) ) {
unset( $clone[ $slug ] );
}
}
}
self::$all_notifications = $clone;
}
/**
* Get all removed notifications from database
* So that we can filter the push notification with the removed ones
* @return array
*/
public static function get_all_removed() {
return get_option( 'woofunnels_admin_notices' );
}
/**
* Check whether has notification pushed?
* @since 1.0.0
*/
public static function has_notification( $slug ) {
if ( is_null( self::$all_notifications ) ) :
return false;
endif;
return array_key_exists( $slug, self::$all_notifications );
}
}
}

View File

@@ -0,0 +1,228 @@
<?php
/**
* API handler for woofunnels
* @package WooFunnels
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( ! class_exists( 'WooFunnels_API' ) ) :
/**
* WooFunnels_License Class
*/
#[AllowDynamicProperties]
class WooFunnels_API {
public static $woofunnels_api_url = 'https://track.funnelkit.com';
public static $is_ssl = false;
/**
* Get all the plugins that can be pushed from the API
* @return Mixed False on failure and array on success
*/
public static function get_woofunnels_list() {
$woofunnels_modules = get_transient( 'woofunnels_get_modules' );
if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) {
$woofunnels_modules = '';
}
if ( ! empty( $woofunnels_modules ) ) {
return $woofunnels_modules;
}
$api_params = self::get_api_args( array(
'action' => 'get_woofunnels_plugins',
'attrs' => array(
'meta_query' => array(
array(
'key' => 'is_visible_in_dashboard',
'value' => 'yes',
'compare' => '=',
),
),
),
) );
$request_args = self::get_request_args( array(
'timeout' => 30,
'sslverify' => self::$is_ssl,
'body' => urlencode_deep( $api_params ),
) );
$request = wp_remote_post( self::get_api_url( self::$woofunnels_api_url ), $request_args );
if ( is_wp_error( $request ) ) {
return false;
}
$request = json_decode( wp_remote_retrieve_body( $request ) );
if ( ! $request ) {
return false;
}
$woofunnels_modules = $request;
set_transient( 'woofunnels_get_modules', $request, 60 * 60 * 12 );
return ! empty( $woofunnels_modules ) ? $woofunnels_modules : false;
}
/**
* Post tracking data to the Server
*
* @param $data
*
* @return array|void|WP_Error
*/
public static function post_tracking_data( $data ) {
if ( empty( $data ) ) {
return;
}
$api_params = self::get_api_args( array(
'action' => 'get_tracking_data',
'data' => $data,
) );
$request_args = self::get_request_args( array(
'timeout' => 30,
'sslverify' => self::$is_ssl,
'body' => urlencode_deep( $api_params ),
) );
$request = wp_remote_post( self::get_api_url( self::$woofunnels_api_url ), $request_args );
return $request;
}
/**
* @param $data
*
* @return array|bool|mixed|object|void|WP_Error|null
*/
public static function post_support_request( $data ) {
if ( empty( $data ) ) {
return;
}
$api_params = self::get_api_args( array(
'action' => 'submit_support_request',
'data' => $data,
) );
$request_args = self::get_request_args( array(
'timeout' => 30,
'sslverify' => self::$is_ssl,
'body' => urlencode_deep( $api_params ),
) );
$request = wp_remote_post( self::get_api_url( self::$woofunnels_api_url ), $request_args );
if ( ! is_wp_error( $request ) ) {
$request = json_decode( wp_remote_retrieve_body( $request ) );
return $request;
}
return false;
}
/**
* Filter function to modify args
*
* @param $args
*
* @return mixed|void
*/
public static function get_api_args( $args ) {
return apply_filters( 'woofunnels_api_call_args', $args );
}
/**
* Filter function for request args
*
* @param $args
*
* @return mixed|void
*/
public static function get_request_args( $args ) {
return apply_filters( 'woofunnels_api_call_request_args', $args );
}
/**
* All the data about the deactivation popups
*
* @param $deactivations
* @param $licenses
*
* @return array|WP_Error
*/
public static function post_deactivation_data( $deactivations ) {
$get_deactivation_data = array(
'site' => home_url(),
'deactivations' => $deactivations,
'logged_errors' => apply_filters( 'send_filter_deactivations_data', [] )
);
$api_params = self::get_api_args( array(
'action' => 'get_deactivation_data',
'data' => $get_deactivation_data,
'licenses' => [],
) );
$request_args = self::get_request_args( array(
'sslverify' => self::$is_ssl,
'body' => urlencode_deep( $api_params ),
) );
$request = wp_remote_post( self::get_api_url( self::$woofunnels_api_url ), $request_args );
return $request;
}
/**
* Get for API url
*
* @param string $link
*
* @return string
*/
public static function get_api_url( $link ) {
return apply_filters( 'woofunnels_api_call_url', $link );
}
public static function get_woofunnels_status() {
//do a woofunnels_status_check
return true;
}
/**
* @param $data
*
* @return array|void|WP_Error
*/
public static function post_optin_data( $data ) {
if ( empty( $data ) ) {
return;
}
$api_params = self::get_api_args( array(
'action' => 'woofunnelsapi_optin',
'data' => $data,
) );
$request_args = self::get_request_args( array(
'timeout' => 30,
'sslverify' => self::$is_ssl,
'body' => urlencode_deep( $api_params ),
) );
$request = wp_remote_post( self::get_api_url( self::$woofunnels_api_url ), $request_args );
return $request;
}
}
endif; // end class_exists check

View File

@@ -0,0 +1,75 @@
<?php
/**
* @author woofunnels
* @package WooFunnels
*/
if ( ! class_exists( 'WooFunnels_Cache' ) ) {
#[AllowDynamicProperties]
class WooFunnels_Cache {
protected static $instance;
protected $woofunnels_core_cache = array();
/**
* WooFunnels_Cache constructor.
*/
public function __construct() {
}
/**
* Creates an instance of the class
* @return WooFunnels_Cache
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Set the cache contents by key and group within page scope
*
* @param $key
* @param $data
* @param string $group
*/
public function set_cache( $key, $data, $group = '0' ) {
$this->woofunnels_core_cache[ $group ][ $key ] = $data;
}
/**
* Get the cache contents by the cache key or group.
*
* @param $key
* @param string $group
*
* @return bool|mixed
*/
public function get_cache( $key, $group = '0' ) {
if ( isset( $this->woofunnels_core_cache[ $group ] ) && isset( $this->woofunnels_core_cache[ $group ][ $key ] ) ) {
return $this->woofunnels_core_cache[ $group ][ $key ];
}
return false;
}
/**
* Reset the cache by group or complete reset by force param
*
* @param string $group
* @param bool $force
*/
function reset_cache( $group = '0', $force = false ) {
if ( true === $force ) {
$this->woofunnels_core_cache = array();
} elseif ( isset( $this->woofunnels_core_cache[ $group ] ) ) {
$this->woofunnels_core_cache[ $group ] = array();
}
}
}
}

View File

@@ -0,0 +1,929 @@
<?php
/**
* This class is a mail loader class for dashboard page , controls and sets up all the necessary actions
*
* @author woofunnels
* @package WooFunnels
*/
define( 'BWF_VERSION', '1.10.12.71' );
define( 'BWF_DB_VERSION', '1.0.6' );
if ( ! class_exists( 'WooFunnels_Dashboard' ) ) {
#[AllowDynamicProperties]
class WooFunnels_Dashboard {
public static $currentPage;
public static $parent;
public static $selected = '';
public static $pagefullurl = '';
public static $is_dashboard_page = false;
public static $loader_url = '';
public static $is_core_menu = false;
public static $classes = [];
protected static $expectedurl;
protected static $expectedslug;
/**
* Function Loads the html and required javascript to render on dashboard page
*/
public static function load_page() {
//do_action
do_action( 'woofunnels_before_dashboard_page' );
self::register_dashboard();
$model = apply_filters( 'woofunnels_tabs_modal_' . self::$selected, array() );
$all_valid_tabs = [ 'licenses', 'logs', 'plugins', 'support', 'tools' ];
if ( ! in_array( self::$selected, $all_valid_tabs, true ) ) {
return;
}
?>
<div class="wrap">
<div class="icon32" id="icon-themes"><br></div>
<div class="woofunnels_dashboard_tab_content" id="<?php echo esc_attr( self::$selected ); ?>">
<?php include_once self::$loader_url . 'views/woofunnels-tabs-' . self::$selected . '.phtml'; ?>
</div>
</div>
<?php
}
/**
* Register dashboard function just initializes the execution by firing some hooks that helps getting and rendering data
*/
public static function register_dashboard() {
//registering necessary hooks
//making sure these hooks loads only when register for dashboard happens (specific page)
self::woofunnels_dashboard_scripts();
add_action( 'woofunnels_tabs_modal_licenses', array( __CLASS__, 'woofunnels_licenses_data' ), 99 );
add_action( 'woofunnels_tabs_modal_support', array( __CLASS__, 'woofunnels_support_data' ), 99 );
add_action( 'woofunnels_tabs_modal_tools', array( __CLASS__, 'woofunnels_tools_data' ), 99 );
add_action( 'woofunnels_tabs_modal_logs', array( __CLASS__, 'woofunnels_logs_data' ), 99 );
add_action( 'woofunnels_tools_right_area', array( __CLASS__, 'show_right_area' ) );
add_filter( 'woofunnels_additional_tabs', array( __CLASS__, 'add_logs_tabs' ), 10, 1 );
}
/**
* Hooked over 'admin_enqueue_scripts' under the register function, cannot run on every admin page
* Enqueues `updates` handle script, core script that is responsible for plugin updates
*/
public static function woofunnels_dashboard_scripts() {
?>
<style type="text/css">
/* product grid */
.woofunnels_plugins_wrap .filter-links.filter-primary {
border-right: 2px solid #e5e5e5;
}
.woofunnels_plugins_wrap .wp-filter {
margin-bottom: 0;
}
.woofunnels_plugins_wrap .filter-links li {
border-bottom: 4px solid white;
}
.woofunnels_plugins_wrap .filter-links li a.current {
border-bottom: 4px solid #fff;
}
.woofunnels_plugins_wrap .filter-links li.current {
border-bottom-color: #666666;
}
.woofunnels_plugins_wrap .woofunnels_dashboard_tab_content {
float: left;
width: 54%;
}
.woofunnels_plugins_wrap .woofunnels_dashboard_license_content {
float: left;
width: 74%;
}
.woofunnels_plugins_wrap .woofunnels_dashboard_tab_content .woofunnels_core_tools {
width: 100% !important;
background: #fff;
}
.woofunnels_plugins_wrap .woofunnels_dashboard_tab_content .woofunnels_core_tools h2 {
margin-top: 0;
}
.woofunnels_plugins_wrap .woofunnels_plugins_status {
font-style: italic;
}
.woofunnels_plugins_wrap .woofunnels_plugins_features_div {
}
.woofunnels_plugins_wrap div#col-container.about-wrap {
max-width: 100%;
margin: 30px 20px 0 0;
width: auto;
margin-right: 0;
clear: both;
}
.woofunnels_plugins_wrap div#col-container.about-wrap .col-wrap {
float: left;
}
.woofunnels_dashboard_tab_content .woofunnels_plugins_wrap .woofunnels-area-right {
float: right;
width: 44%;
margin: 0;
}
.woofunnels_dashboard_tab_content#licenses .woofunnels_plugins_wrap .woofunnels-area-right {
width: 24%;
}
.woofunnels_plugins_wrap .woofunnels-area-right table {
padding: 15px;
}
.woofunnels_plugins_wrap .woofunnels-area-right table th, .woofunnels_plugins_wrap .woofunnels-area-right table td {
vertical-align: middle;
padding: 15px 0;
}
.woofunnels_plugins_wrap .woofunnels-area-right table td {
text-align: right;
}
.woofunnels_plugins_wrap .woofunnels_plugins_features {
margin-left: -10px;
margin-right: -10px;
}
.woofunnels_plugins_wrap .woofunnels_plugins_features .woofunnels_plugins_half_col {
width: 100%;
margin: 4px 0;
padding-left: 30px;
padding-right: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.woofunnels_plugins_wrap .woofunnels_plugins_features .woofunnels_plugins_half_col:before {
margin-left: -20px;
content: "\f147";
font: 400 20px/.5 dashicons;
speak: none;
display: inline-block;
padding: 0;
top: 4px;
left: -2px;
position: relative;
vertical-align: top;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
color: #444;
}
@media screen and (min-width: 481px) {
.woofunnels_plugins_wrap .woofunnels_plugins_features .woofunnels_plugins_half_col {
width: 50%;
float: left;
}
.woofunnels_plugins_wrap .woofunnels_plugins_features .woofunnels_plugins_half_col:nth-child(2n) {
text-align: right;
}
.woofunnels_plugins_wrap .woofunnels_plugins_features .woofunnels_plugins_half_col:nth-child(2n+1) {
clear: both;
}
}
.woofunnels_plugins_wrap .woofunnels_plugins_status_div {
padding-top: 8px;
padding-bottom: 8px;
border-color: rgba(221, 221, 221, 0.4);
background: #fff;
}
.woofunnels_plugins_wrap .woofunnels_plugins_status_div .woofunnels_plugins_status {
margin: 0;
}
.woofunnels_plugins_wrap .button-primary.woofunnels_plugins_renew_btn {
min-width: 120px;
text-align: center;
}
.woofunnels_plugins_wrap .button-primary.woofunnels_plugins_renew_btn:before {
content: "\f321";
font: 400 20px/.5 dashicons;
speak: none;
display: inline-block;
padding: 0;
top: 4px;
left: -2px;
position: relative;
vertical-align: top;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
color: #fff;
}
.woofunnels_plugins_wrap .button-primary.woofunnels_plugins_buy_btn {
min-width: 120px;
text-align: center;
}
.woofunnels_plugins_wrap .button-primary.woofunnels_plugins_buy_btn:before {
content: "\f174";
font: 400 20px/.5 dashicons;
speak: none;
display: inline-block;
padding: 0;
top: 4px;
left: -2px;
position: relative;
vertical-align: top;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
color: #fff;
}
.woofunnels_plugins_wrap .plugin-card-bottom.woofunnels_plugins_features_links_div {
background: #fff;
}
.woofunnels_plugins_wrap .plugin-card-bottom.woofunnels_plugins_features_links_div .woofunnels_plugins_features_links ul {
margin: 0;
}
.woofunnels_plugins_wrap .woofunnels_plugins_deactivate_add.woofunnels_plugins_features_links {
padding-right: 125px;
display: block;
position: relative;
}
.woofunnels_plugins_wrap .woofunnels_plugins_deactivate_add.woofunnels_plugins_features_links .woofunnels_plugins_deactivate {
color: #a00000;
display: inline-block;
line-height: 26px;
}
.clearfix:after, .clearfix:before {
display: table;
content: '';
}
.clearfix:after {
clear: both;
}
.woofunnels_plugins_wrap ul.woofunnels_plugins_options {
display: inline-block;
line-height: 26px;
float: right;
position: absolute;
z-index: 1;
right: 0;
}
.woofunnels_plugins_wrap ul.woofunnels_plugins_options li {
display: inline-block;
margin: 0;
}
.woofunnels_plugins_wrap .js_filters li a:focus {
box-shadow: none;
-webkit-box-shadow: none;
color: #23282d;
}
#licenses .column-product_status, .index_page_woothemes-helper-network .column-product_status {
width: 350px;
}
#licenses .below_input_message {
color: #9E0B0F;
padding-left: 1px;
}
#licenses .below_input_message a {
text-decoration: underline;
}
.woofunnels-updater-plugin-upgrade-notice {
font-weight: 400;
color: #fff;
background: #d54d21;
padding: 1em;
margin: 9px 0;
}
.woofunnels-updater-plugin-upgrade-notice:before {
content: "\f348";
display: inline-block;
font: 400 18px/1 dashicons;
speak: none;
margin: 0 8px 0 -2px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
vertical-align: top;
}
#support-request label:not(.radio) {
display: block;
font-weight: 600;
font-size: 14px;
line-height: 1.3;
}
#pdf-system-status {
overflow: hidden;
}
#pdf-system-status p {
clear: left;
}
#pdf-system-status span.details, #support-request span.details {
font-size: 95%;
color: #444;
margin-top: 7px;
display: inline-block;
clear: left;
}
#pdf-system-status span.details.path, #support-request span.details.path {
padding: 2px;
background: #f2f2f2;
}
#support-request input:not([type="radio"]), #support-request select {
width: 20em;
max-width: 350px;
width: 100%;
}
#support-request input[type="submit"] {
width: auto;
}
#support-request textarea {
width: 65%;
height: 150px;
}
#support-request input, #support-request textarea {
padding: 5px 4px;
}
#support-request #support-request-button {
padding: 0 8px;
}
#support-request .gfspinner {
vertical-align: middle;
margin-left: 5px;
}
#support-request textarea {
max-width: 350px;
width: 100%;
/* border: 1px solid #999;
color: #444;*/
}
#support-request :disabled, #support-request textarea:disabled {
color: #CCC;
border: 1px solid #CCC;
}
#support-request input.error, #support-request textarea.error, #support-request select.error {
color: #d10b0b;
border: 1px solid #d10b0b;
}
#support-request .form-table .radioBtns span {
margin-right: 10px;
display: inline-block;
}
#support-request .fa-times-circle {
vertical-align: middle;
}
.icon-spinner {
font-size: 18px;
margin-left: 5px;
}
#support-request span.msg {
margin-left: 5px;
color: #008000;
}
#support-request span.error {
margin-left: 5px;
color: #d10b0b;
}
#lv_pointer_target {
float: right;
background: #0e3f7a;
color: #fff;
border: none;
position: relative;
top: -6px;
}
#lv_pointer_target:focus {
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.woofunnels_plugins_wrap .filter-links li > a:focus {
-webkit-box-shadow: none;
box-shadow: none;
-moz-box-shadow: none;
}
@media (max-width: 1023px) {
#support-request .form-table .radioBtns span {
display: block;
margin-bottom: 4px;
}
}
@media screen and (max-width: 782px) {
.woofunnels_plugins_wrap .woofunnels_dashboard_tab_content {
float: none;
}
.woofunnels_plugins_wrap div#col-container.about-wrap {
margin-right: 0;
}
.woofunnels_plugins_wrap div#col-container.about-wrap .woofunnels-area-right {
float: none;
margin-right: 0;
width: 280px;
margin-left: 0;
margin: auto;
}
.woofunnels_plugins_wrap div#col-container.about-wrap .col-wrap {
float: left;
}
#support-request .form-table input[type="radio"] {
height: 16px;
width: 16px;
}
}
.woofunnels_core_tools .woofunnels_download_files_label {
display: inline-block;
padding-left: 10px;
vertical-align: -webkit-baseline-middle;
}
.woofunnels_core_tools .woofunnels_download_buttons {
display: inline-block;
padding-left: 5px;
}
</style>
<?php
}
/**
* Init function hooked on `admin_init`
* Set the required variables and register some important hooks
*/
public static function init() {
self::$loader_url = WooFunnel_Loader::$ultimate_path;
$selected = null !== sanitize_text_field( filter_input( INPUT_GET, 'tab', FILTER_UNSAFE_RAW ) ) ? sanitize_text_field( filter_input( INPUT_GET, 'tab', FILTER_UNSAFE_RAW ) ) : 'plugins';
self::$selected = $selected;
/**
* Function to trigger error message at WordPress plugins page when we have update but license invalid
*/
self::add_notice_unlicensed_product();
/**
* Initialize Localization
*/
add_action( 'init', array( __CLASS__, 'localization' ) );
add_action( 'admin_head', [ __CLASS__, 'apply_scroll_fix_css' ] );
}
/**
* Getting and parsing all our licensing products and checking if there update is available
*/
public static function add_notice_unlicensed_product() {
/**
* Getting necessary data
*/
$licenses = WooFunnels_licenses::get_instance()->get_data();
/**
* Looping over to check how many licenses are invalid and pushing notification and error accordingly
*/
if ( $licenses && count( $licenses ) > 0 ) {
foreach ( $licenses as $key => $license ) {
if ( $license['product_status'] === 'invalid' ) {
add_action( 'in_plugin_update_message-' . $key, array( __CLASS__, 'need_license_message' ), 10, 2 );
}
}
}
}
public static function localization() {
load_plugin_textdomain( 'woofunnels', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
/**
* Message displayed if license not activated. <br/>
*
* @param array $plugin_data
* @param object $r
*
* @return void
*/
public static function need_license_message( $plugin_data, $r ) {
if ( empty( $r->package ) ) {
echo wp_kses_post( '<div class="woofunnels-updater-plugin-upgrade-notice">' . __( 'To enable this update please activate your FunnelKit license by visiting the Dashboard Page.', 'woofunnels' ) . '</div>' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
}
/**
* Model function to fire over licensing page. <br/>
* Hooked over 'woofunnels_tabs_modal_licenses'. <br/>
* @return mixed false on failure and data on success
*/
public static function woofunnels_licenses_data() {
if ( false === WooFunnels_API::get_woofunnels_status() ) {
return;
}
$get_list = array();
$License = WooFunnels_licenses::get_instance();
return (object) array_merge( (array) $get_list, (array) array(
'additional_tabs' => apply_filters( 'woofunnels_additional_tabs', array(
array(
'slug' => 'tools',
'label' => __( 'Tools', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
),
) ),
'licenses' => $License->get_data(),
'current_tab' => self::$selected,
) );
}
/**
* Model function to fire over licensing page. <br/>
* Hooked over 'woofunnels_tabs_modal_licenses'. <br/>
* @return mixed false on failure and data on success
*/
public static function woofunnels_tools_data() {
if ( false === WooFunnels_API::get_woofunnels_status() ) {
return;
}
$get_list = array();
return (object) array_merge( (array) $get_list, (array) array(
'additional_tabs' => apply_filters( 'woofunnels_additional_tabs', array(
array(
'slug' => 'tools',
'label' => __( 'Tools', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
),
) ),
'current_tab' => self::$selected,
) );
}
/**
* Model function to fire over support page. <br/>
* Hooked over 'woofunnels_tabs_modal_support'. <br/>
* @return mixed false on failure and data on success
*/
public static function woofunnels_support_data( $data ) {
//getting plugins list and tabs data
$get_list = array();
return (object) array_merge( (array) $get_list, (array) array(
'additional_tabs' => apply_filters( 'woofunnels_additional_tabs', array(
array(
'slug' => 'tools',
'label' => __( 'Tools', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
),
) ),
'email' => get_bloginfo( 'admin_email' ),
'current_tab' => self::$selected,
) );
}
/**
* Model function to fire over support page. <br/>
* Hooked over 'woofunnels_tabs_modal_logs'. <br/>
* @return mixed false on failure and data on success
*/
public static function woofunnels_logs_data( $data ) {
//getting plugins list and tabs data
$get_list = array();
return (object) array_merge( (array) $get_list, (array) array(
'additional_tabs' => apply_filters( 'woofunnels_additional_tabs', array(
array(
'slug' => 'tools',
'label' => __( 'Tools', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
),
) ),
'current_tab' => self::$selected,
) );
}
public static function show_right_area() {
if ( wp_verify_nonce( filter_input( INPUT_GET, '_nonce', FILTER_UNSAFE_RAW ), 'bwf_tools_action' ) && isset( $_GET['woofunnels_transient'] ) && ( 'clear' === sanitize_text_field( $_GET['woofunnels_transient'] ) ) ) {
$woofunnels_transient_obj = WooFunnels_Transient::get_instance();
$woofunnels_transient_obj->delete_force_transients();
$message = __( 'All Plugins transients cleared.', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
?>
<div class="notice notice-success is-dismissible">
<p><?php echo esc_html( $message ); ?></p>
</div>
<?php
}
$nonce = wp_create_nonce( 'bwf_tools_action' );
$clear_transient_url = admin_url( 'admin.php?page=woofunnels&tab=tools&woofunnels_transient=clear&_nonce=' . $nonce );
$show_reset_tracking = apply_filters( 'woofunnels_show_reset_tracking', false );
?>
<table class="widefat" cellspacing="0">
<tbody class="tools">
<?php do_action( 'woofunnels_tools_add_tables_row_start' ); ?>
<tr>
<th>
<strong class="name"><?php esc_html_e( 'WooFunnels transients', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?></strong>
<p class="description"><?php esc_html_e( 'This tool will clear all the WooFunnels plugins transients cache.', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?></p>
</th>
<td class="run-tool">
<a href="<?php echo esc_url( $clear_transient_url ); ?>" class="button button-large"><?php esc_html_e( 'Clear transients', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?></a>
</td>
</tr>
<?php if ( true === $show_reset_tracking ) {
$reset_tracking_url = admin_url( 'admin.php?page=woofunnels&tab=tools&woofunnels_tracking=reset&_nonce=' . $nonce );
$is_opted = WooFunnels_OptIn_Manager::get_optIn_state();
if ( 'yes' === $is_opted ) {
$text_btn = __( 'Turn Off', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
} else {
$reset_tracking_url .= '&action=yes';
$text_btn = __( 'Turn On', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
?>
<tr>
<th>
<strong class="name"><?php esc_html_e( 'Usage Tracking', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?></strong>
<p class="description"><?php esc_html_e( 'This action controls Usage Tracking', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?></p>
</th>
<td class="run-tool">
<a href="<?php echo esc_url( $reset_tracking_url ); ?>" class="button button-large"><?php echo esc_html( $text_btn ); ?></a>
</td>
</tr>
<?php } ?>
<?php do_action( 'woofunnels_tools_add_tables_row' ); ?>
</tbody>
</table>
<?php
}
public static function add_logs_tabs( $tabs ) {
$tabs[] = array(
'slug' => 'logs',
'label' => __( 'Logs', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
);
return $tabs;
}
public static function autoloader( $class_name ) {
if ( 0 === strpos( $class_name, 'WooFunnels_' ) || 0 === strpos( $class_name, 'BWF_' ) ) {
$path = WooFunnel_Loader::$ultimate_path . 'includes/class-' . self::slugify_classname( $class_name ) . '.php';
$contact_path = WooFunnel_Loader::$ultimate_path . 'contact/class-' . self::slugify_classname( $class_name ) . '.php';
if ( is_file( $path ) ) {
require_once $path;
}
if ( is_file( $contact_path ) ) {
require_once $contact_path;
}
/**
* loading compatibility classes
*/
if ( false !== strpos( $class_name, 'Compatibility' ) || false !== strpos( $class_name, 'Compatibilities' ) ) {
$path = WooFunnel_Loader::$ultimate_path . 'compatibilities/class-' . self::slugify_classname( $class_name ) . '.php';
if ( is_file( $path ) ) {
require_once $path;
}
}
}
if ( 0 === strpos( $class_name, 'WFCO_' ) ) {
$path = WooFunnel_Loader::$ultimate_path . 'connector/class-' . self::slugify_classname( $class_name ) . '.php';
$model_path = WooFunnel_Loader::$ultimate_path . 'includes/class-' . self::slugify_classname( $class_name ) . '.php';
if ( is_file( $path ) ) {
require_once $path;
}
if ( is_file( $model_path ) ) {
require_once $model_path;
}
}
}
/**
* Slug-ify the class name and remove underscores and convert it to filename
* Helper function for the auto-loading
*
* @param $class_name
*
*
* @return mixed|string
* @see WooFunnels_Dashboard::autoloader();
*
*/
public static function slugify_classname( $class_name ) {
$classname = self::custom_sanitize_title( $class_name );
$classname = str_replace( '_', '-', $classname );
return $classname;
}
/**
* Custom sanitize title method to avoid conflicts with WordPress hooks on sanitize_title
*
* @param string $title The title to sanitize
* @return string The sanitized title
*/
private static function custom_sanitize_title( $title ) {
$title = remove_accents( $title );
$title = sanitize_title_with_dashes( $title );
return $title;
}
public static function load_core_classes() {
require dirname( __DIR__ ) . '/includes/bwf-functions.php';
require dirname( __DIR__ ) . '/contact/woofunnels-db-updater-functions.php';
require dirname( __DIR__ ) . '/contact/woofunnels-contact-functions.php';
require dirname( __DIR__ ) . '/contact/woofunnels-customer-functions.php';
$core_classes = array(
'WooFunnels_process',
'WooFunnels_Notifications',
'WooFunnels_DB_Updater',
'WooFunnels_DB_Tables',
'WFCO_Admin',
'WooFunnels_Funnel_Builder_Commons',
'BWF_Data_Tags',
'BWF_Ecomm_Tracking_Common',
'BWF_Logger',
);
foreach ( $core_classes as $class ) {
self::$classes[ $class ] = $class::get_instance();
}
$static_classes = array( 'WooFunnels_OptIn_Manager', 'WooFunnels_deactivate' );
foreach ( $static_classes as $class ) {
$class::init();
}
/** WooFunnels AS Data Store */
include_once dirname( __DIR__ ) . '/as-data-store/class-woofunnels-as-ds.php';
add_action( 'shutdown', [ __CLASS__, 'fetch_template_json' ] );
add_action( 'admin_init', array( __CLASS__, 'index_templates' ) );
}
public static function apply_scroll_fix_css() {
global $current_screen;
if ( $current_screen instanceof WP_Screen && strpos( $current_screen->base, 'woofunnels' ) !== false ) {
/** Allow for woofunnels pages */
} elseif ( false === apply_filters( 'bwf_scroll_fix_allow', false ) ) {
return;
}
ob_start();
?>
<style>
#adminmenuwrap {
position: relative !important;
top: 0 !important;
}
body, html {
height: auto;
position: relative
}
</style>
<?php
echo ob_get_clean(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
public static function index_templates() {
$get_templates = filter_input( INPUT_GET, 'wffn_parse_template', FILTER_UNSAFE_RAW );
if ( 'yes' === $get_templates && current_user_can( 'manage_options' ) ) {
self::get_all_templates( true );
wp_safe_redirect( admin_url( 'admin.php?page=woofunnels&tab=tools' ) );
exit;
}
}
public static function get_all_templates( $force = false ) {
$woofunnels_cache_object = WooFunnels_Cache::get_instance();
$get_transient_instance = WooFunnels_Transient::get_instance();
$transient = $woofunnels_cache_object->get_cache( '_bwf_fb_templates' );
if ( empty( $transient ) ) {
$transient = $get_transient_instance->get_transient( '_bwf_fb_templates' );
}
if ( empty( $transient ) || true === $force ) {
$templates = self::get_remote_templates();
if ( is_array( $templates ) ) {
$get_transient_instance->set_transient( '_bwf_fb_templates', count( $templates ), HOUR_IN_SECONDS * 12 );
}
return $templates;
}
return apply_filters( 'bwf_fb_templates', get_option( '_bwf_fb_templates' ) );
}
public static function get_remote_templates() {
$json_templates = [];
$endpoint_url = self::get_template_api_url();
$request_args = array(
'timeout' => 30, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
'sslverify' => false
);
$response = wp_safe_remote_get( $endpoint_url . 'templatesv3.json', $request_args );
BWF_Logger::get_instance()->log( 'API Call templates.json response::: ' . print_r( $response, true ), 'wffn_template_import' ); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
if ( ! is_wp_error( $response ) ) {
$body = wp_remote_retrieve_body( $response );
if ( ! empty( $body ) ) {
$json_templates = json_decode( $body, true );
if ( is_array( $json_templates ) ) {
update_option( '_bwf_fb_templates', $json_templates, false );
}
}
}
return $json_templates;
}
public static function get_template_api_url() {
return 'https://gettemplates.funnelkit.com/';
}
public static function fetch_template_json() {
if ( 'yes' === filter_input( INPUT_GET, 'activated', FILTER_UNSAFE_RAW ) ) {
flush_rewrite_rules(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
self::get_all_templates();
}
}
}
}
spl_autoload_register( array( 'WooFunnels_dashboard', 'autoloader' ) );
WooFunnels_dashboard::load_core_classes();
//Initialize the instance so that some necessary hooks can run on each load
add_action( 'admin_init', array( 'WooFunnels_dashboard', 'init' ), 11 );

View File

@@ -0,0 +1,202 @@
<?php
if ( ! class_exists( 'WooFunnels_Deactivate' ) ) {
/**
* Contains the logic for deactivation popups
* @since 1.0.0
* @author woofunnels
* @package WooFunnels
*/
#[AllowDynamicProperties]
class WooFunnels_Deactivate {
public static $deactivation_str;
/**
* Initialization of hooks where we prepare the functionality to ask use for survey
*/
public static function init() {
add_action( 'admin_init', array( __CLASS__, 'load_all_str' ) );
add_action( 'admin_footer', array( __CLASS__, 'maybe_load_deactivate_options' ) );
add_action( 'wp_ajax_woofunnels_submit_uninstall_reason', array( __CLASS__, '_submit_uninstall_reason_action' ) );
}
/**
* Localizes all the string used
*/
public static function load_all_str() {
self::$deactivation_str = array(
'deactivation-share-reason' => __( 'If you have a moment, please let us know why you are deactivating', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-no-longer-needed' => __( 'No longer need the plugin', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-found-a-better-plugin' => __( 'I found an alternate plugin', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-needed-for-a-short-period' => __( 'I only needed the plugin for a short period', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'placeholder-plugin-name' => __( 'Please share which plugin', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-broke-my-site' => __( 'Encountered a fatal error', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-suddenly-stopped-working' => __( 'The plugin suddenly stopped working', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-other' => _x( 'Other', 'the text of the "other" reason for deactivating the plugin that is shown in the modal box.', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'deactivation-modal-button-submit' => __( 'Submit & Deactivate', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'deactivate' => __( 'Deactivate', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'deactivation-modal-button-deactivate' => __( 'Deactivate', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'deactivation-modal-button-confirm' => __( 'Yes - Deactivate', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'deactivation-modal-button-cancel' => _x( 'Cancel', 'the text of the cancel button of the plugin deactivation dialog box.', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-cant-pay-anymore' => __( "I can't pay for it anymore", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'placeholder-comfortable-price' => __( 'What price would you feel comfortable paying?', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-couldnt-make-it-work' => __( "I couldn't understand how to make it work", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-great-but-need-specific-feature' => __( "The plugin is great, but I need specific feature that you don't support", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-not-working' => __( 'Couldn\'t get the plugin to work', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-not-what-i-was-looking-for' => __( "It's not what I was looking for", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-didnt-work-as-expected' => __( "The plugin didn't work as expected", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'placeholder-feature' => __( 'What feature?', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'placeholder-share-what-didnt-work' => __( "Kindly share what didn't work so we can fix it for future users...", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'placeholder-what-youve-been-looking-for' => __( "What you've been looking for?", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'placeholder-what-did-you-expect' => __( 'What did you expect?', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-didnt-work' => __( "The plugin didn't work", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'reason-dont-like-to-share-my-information' => __( "I don't like to share my information with you", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'conflicts-other-plugins' => __( "Conflicts with other plugins", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'temporary-deactivation' => __( "It's a temporary deactivation", 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
);
}
/**
* Checking current page and pushing html, js and css for this task
* @global string $pagenow current admin page
* @global array $VARS global vars to pass to view file
*/
public static function maybe_load_deactivate_options() {
global $pagenow;
if ( $pagenow === 'plugins.php' ) {
global $VARS;
$VARS = array(
'slug' => '',
'reasons' => self::deactivate_options(),
);
include_once dirname( dirname( __FILE__ ) ) . '/views/woofunnels-deactivate-modal.phtml';
}
}
/**
* deactivation reasons in array format
* @return array reasons array
* @since 1.0.0
*/
public static function deactivate_options() {
$reasons = array( 'default' => [] );
$reasons['default'] = array(
array(
'id' => 1,
'text' => self::load_str( 'reason-not-working' ),
'input_type' => '',
'input_placeholder' => self::load_str( 'placeholder-plugin-name' ),
),
array(
'id' => 2,
'text' => self::load_str( 'reason-found-a-better-plugin' ),
'input_type' => 'textfield',
'input_placeholder' => self::load_str( 'placeholder-plugin-name' )
),
array(
'id' => 3,
'text' => self::load_str( 'reason-no-longer-needed' ),
'input_type' => '',
'input_placeholder' => '',
),
array(
'id' => 4,
'text' => self::load_str( 'temporary-deactivation' ),
'input_type' => '',
'input_placeholder' => '',
),
array(
'id' => 5,
'text' => self::load_str( 'conflicts-other-plugins' ),
'input_type' => 'textfield',
'input_placeholder' => self::load_str( 'placeholder-plugin-name' )
),
array(
'id' => 6,
'text' => self::load_str( 'reason-broke-my-site' ),
'input_type' => '',
'input_placeholder' => '',
),
array(
'id' => 7,
'text' => self::load_str( 'reason-other' ),
'input_type' => 'textfield',
'input_placeholder' => __( 'Please share the reason', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
)
);
return $reasons;
}
/**
* get exact str against the slug
*
* @param $slug
*
* @return mixed
*/
public static function load_str( $slug ) {
return self::$deactivation_str[ $slug ];
}
/**
* Called after the user has submitted his reason for deactivating the plugin.
*
* @since 1.1.2
*/
public static function _submit_uninstall_reason_action() {
try {
check_admin_referer( 'bwf_secure_key', '_nonce' );
if ( ! current_user_can( 'install_plugins' ) ) {
wp_send_json_error();
}
if ( ! isset( $_POST['reason_id'] ) ) {
wp_send_json_error();
}
$reason_info = isset( $_POST['reason_info'] ) ? sanitize_textarea_field( stripslashes( bwf_clean( $_POST['reason_info'] ) ) ) : '';
$reason = array(
'id' => sanitize_text_field( $_POST['reason_id'] ),
'info' => substr( $reason_info, 0, 128 ),
);
$licenses = WooFunnels_addons::get_installed_plugins();
$version = 'NA';
$plugin_basename = isset( $_POST['plugin_basename'] ) ? bwf_clean( $_POST['plugin_basename'] ) : '';
if ( $licenses && count( $licenses ) > 0 ) {
foreach ( $licenses as $key => $license ) {
if ( $key === $plugin_basename ) {
$version = $license['Version'];
}
}
}
$deactivations = array(
$plugin_basename . '(' . $version . ')' => $reason,
);
WooFunnels_API::post_deactivation_data( $deactivations );
} catch ( Exception $e ) {
// Log the exception if necessary
}
wp_send_json_success();
}
}
}

View File

@@ -0,0 +1,211 @@
<?php
/**
* Including WordPress Filesystem API
*/
include_once ABSPATH . '/wp-admin/includes/file.php';
if ( function_exists( 'WP_Filesystem' ) ) {
WP_Filesystem();
}
if ( class_exists( 'WP_Filesystem_Direct' ) ) {
#[AllowDynamicProperties]
class WooFunnels_File_Api extends WP_Filesystem_Direct {
private $upload_dir;
private static $ins = null;
private $core_dir = 'funnelkit';
private $component = '';
public function __construct( $component ) {
$upload = wp_upload_dir();
$this->upload_dir = $upload['basedir'];
$this->woofunnels_core_dir = $this->upload_dir . '/' . $this->core_dir;
$this->set_component( $component );
$this->makedirs();
self::$ins = 1;
}
public function set_component( $component ) {
if ( '' !== $component ) {
$this->component = $component;
}
}
public function get_component_dir() {
return $this->woofunnels_core_dir . '/' . $this->component;
}
public function touch( $file, $time = 0, $atime = 0 ) {
$file = $this->file_path( $file );
return parent::touch( $file, $time, $atime );
}
public function file_path( $file ) {
$file_path = $this->woofunnels_core_dir . '/' . $this->component . '/' . $file;
return $file_path;
}
public function folder_path( $folder_name ) {
$folder_path = $this->woofunnels_core_dir . '/' . $folder_name . '/';
return $folder_path;
}
public function is_readable( $file ) {
$file = $this->file_path( $file );
return parent::is_readable( $file );
}
public function is_writable( $file ) {
$file = $this->file_path( $file );
return parent::is_writable( $file );
}
public function put_contents( $file, $contents, $mode = false ) {
$file = $this->file_path( $file );
return parent::put_contents( $file, $contents, $mode );
}
public function delete_file( $file, $recursive = false, $type = 'f' ) {
$file = $this->file_path( $file );
return parent::delete( $file, $recursive, $type );
}
public function delete_all( $folder_name, $recursive = false ) {
$folder_path = $this->folder_path( $folder_name );
return parent::rmdir( $folder_path, $recursive );
}
/**
* Gets details for files in a directory or a specific file.
*
* @param string $path Path to directory or file.
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
* Default true.
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
* Default false.
*
* @return array|false {
* Array of files. False if unable to list directory contents.
*
* @type string $name Name of the file or directory.
* @type string $perms *nix representation of permissions.
* @type int $permsn Octal representation of permissions.
* @type string $owner Owner name or ID.
* @type int $size Size of file in bytes.
* @type int $lastmodunix Last modified unix timestamp.
* @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
* @type int $time Last modified time.
* @type string $type Type of resource. 'f' for file, 'd' for directory.
* @type mixed $files If a directory and $recursive is true, contains another array of files.
* }
* @since 2.5.0
*
*/
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
if ( $this->is_file( $path ) ) {
$limit_file = basename( $path );
$path = dirname( $path );
} else {
$limit_file = false;
}
if ( ! $this->is_dir( $path ) ) {
return false;
}
$dir = dir( $path );
if ( ! $dir ) {
return false;
}
$ret = array();
while ( false !== ( $entry = $dir->read() ) ) {
$struc = array();
$struc['name'] = $entry;
if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
continue;
}
if ( ! $include_hidden && '.' == $struc['name'][0] ) {
continue;
}
if ( $limit_file && $struc['name'] != $limit_file ) {
continue;
}
$struc['perms'] = $this->gethchmod( $path . '/' . $entry );
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
$struc['number'] = false;
$struc['owner'] = $this->owner( $path . '/' . $entry );
$struc['group'] = $this->group( $path . '/' . $entry );
$struc['size'] = $this->size( $path . '/' . $entry );
$struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
$struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] );
$struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] );
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
if ( 'd' == $struc['type'] ) {
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
} else {
$struc['files'] = array();
}
}
$ret[ $struc['name'] ] = $struc;
}
$dir->close();
unset( $dir );
return $ret;
}
public function delete_folder( $folder_path, $recursive = false ) {
return parent::rmdir( $folder_path, $recursive );
}
public function exists( $file ) {
$file = $this->file_path( $file );
return parent::exists( $file );
}
public function get_contents( $file ) {
$file = $this->file_path( $file );
return parent::get_contents( $file );
}
public function makedirs() {
$component = $this->component;
if ( parent::is_writable( $this->upload_dir ) ) {
if ( false === $this->is_dir( $this->woofunnels_core_dir ) ) {
$this->mkdir( $this->woofunnels_core_dir );
$file_handle = @fopen( trailingslashit( $this->woofunnels_core_dir ) . '/.htaccess', 'w' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen
if ( $file_handle ) {
fwrite( $file_handle, 'deny from all' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
}
}
$dir = $this->woofunnels_core_dir . '/' . $component;
if ( false === $this->is_dir( $dir ) ) {
$this->mkdir( $dir );
}
}
}
}
}

View File

@@ -0,0 +1,88 @@
<?php
/**
* @author woofunnels
* @package WooFunnels
*/
if ( ! class_exists( 'WooFunnels_Funnel_Builder_Commons' ) ) {
#[AllowDynamicProperties]
class WooFunnels_Funnel_Builder_Commons {
protected static $instance;
/**
* WooFunnels_Cache constructor.
*/
public function __construct() {
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'show_woofunnels_total_in_order_listings' ), 99, 2 );
/**
* this is specific for the case when HPOS is enabled.
*/
add_action( 'manage_woocommerce_page_wc-orders_custom_column', array( $this, 'show_woofunnels_total_in_order_listings' ), 99, 2 );
add_action( 'admin_init', function () {
if ( class_exists( 'WFOCU_Admin' ) ) {
remove_filter( 'woocommerce_get_formatted_order_total', array( WFOCU_Core()->admin, 'show_upsell_total_in_order_listings' ), 999, 2 );
}
if ( class_exists( 'WFOB_Admin' ) ) {
remove_filter( 'woocommerce_get_formatted_order_total', array( WFOB_Core()->admin, 'show_bump_total_in_order_listings' ), 9999, 2 );
}
} );
}
/**
* Creates an instance of the class
* @return WooFunnels_Funnel_Builder_Commons
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
public function show_woofunnels_total_in_order_listings( $column_name, $post_id ) {
$total_woofunnels = 0;
$order = wc_get_order( $post_id );
$html = '';
if ( 'order_total' === $column_name ) {
$show_combined = true;
if ( class_exists( 'WFOCU_Admin' ) ) {
$result_in_order_currency = $order->get_meta( '_wfocu_upsell_amount_currency' );
if ( true === $show_combined && ! empty( $result_in_order_currency ) ) {
$total_woofunnels = $total_woofunnels + $result_in_order_currency;
}
}
if ( class_exists( 'WFOB_Admin' ) ) {
if ( true === $show_combined ) {
/**
* Check if bump accepted in order meta
*/
$bump_total = $order->get_meta( '_bump_purchase_item_total' );
if ( ! empty( $bump_total ) ) {
$total_woofunnels += $bump_total;
}
}
}
if ( ! empty( $total_woofunnels ) ) {
$html = '<br/>
<p style="font-size: 12px;"><em> ' . sprintf( esc_html__( 'FunnelKit: %s', 'woofunnels' ), wc_price( $total_woofunnels, array( 'currency' => get_option( 'woocommerce_currency' ) ) ) ) . '</em></p>'; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
}
}
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
}

View File

@@ -0,0 +1,696 @@
<?php
if ( ! class_exists( 'WooFunnels_License_check' ) ) {
#[AllowDynamicProperties]
class WooFunnels_License_check {
private $server_point = 'https://license.funnelkit.com/';
private $software_end_point = '';
private $update_end_point = '';
private $http = null;
private $license_data = array();
private $request_body = false;
private $request_args = array(
'timeout' => 30,
'sslverify' => false,
);
private $plugin_hash_key = '';
private $human_name = '';
private $version = '0.1.0';
private $name = '';
public $slug = '';
public $wp_override = null;
private $cache_key = '';
private $invalidate_cache = '';
private $default_keys = array(
'plugin_slug' => '',
'email' => '',
'license_key' => '',
'product_id' => '',
'api_key' => '',
'version' => '',
'activation_email' => '',
);
public function __construct( $hash_key = '', $data = array() ) {
$this->software_end_point = add_query_arg( array(
'wc-api' => 'am-software-api',
), $this->server_point );
$this->update_end_point = add_query_arg( array(
'wc-api' => 'upgrade-api',
), $this->server_point );
if ( '' !== $hash_key ) {
$this->set_hash( $hash_key );
}
if ( is_array( $data ) && count( $data ) > 0 ) {
$this->setup_data( $data );
}
$this->invalidate_cache = filter_input( INPUT_GET, 'bwf_clear_plugin_cache', FILTER_UNSAFE_RAW );
if ( 'yes' === $this->invalidate_cache ) {
delete_transient( 'update_plugins' );
delete_site_transient( 'update_plugins' );
}
WooFunnels_License_Controller::register_plugin( $hash_key, $this );
}
public function set_hash( $hash ) {
if ( '' !== $hash ) {
$this->plugin_hash_key = $hash;
}
}
public function setup_data( $data ) {
$default = array(
'plugin_slug' => '',
'plugin_name' => '',
'email' => '',
'license_key' => '',
'product_id' => '',
'api_key' => '',
'version' => '',
'activation_email' => '',
'platform' => $this->get_domain(),
'domain' => $this->get_domain(),
);
if ( isset( $data['email'] ) ) {
$data['activation_email'] = $data['email'];
}
if ( isset( $data['license_key'] ) ) {
$data['api_key'] = $data['license_key'];
}
$data['instance'] = $this->pass_instance();
$this->license_data = wp_parse_args( $data, $default );
}
public function get_domain() {
global $sitepress;
$domain = site_url();
if ( isset( $sitepress ) ) {
$default_language = $sitepress->get_default_language();
$domain = $sitepress->convert_url( $sitepress->get_wp_api()->get_home_url(), $default_language );
}
// Check if Polylang is active
if ( function_exists( 'pll_default_language' ) && function_exists( 'pll_home_url' ) ) {
// Get the default language
$default_language = pll_default_language();
// Get the home URL in the default language
$domain = pll_home_url( $default_language );
}
// Remove trailing slash if it exists
return rtrim( $domain, '/' );
}
public function pass_instance() {
$plugin = $this->get_hash();
$instances = self::get_plugins();
if ( is_array( $instances ) ) {
if ( isset( $instances[ $plugin ] ) && isset( $instances[ $plugin ]['instance'] ) && '' !== $instances[ $plugin ]['instance'] ) {
return $instances[ $plugin ]['instance'];
} else {
return md5( wp_generate_password( 12 ) );
}
}
return false;
}
public function get_hash() {
return $this->plugin_hash_key;
}
public static function get_plugins() {
return WooFunnels_License_Controller::get_plugins();
}
/**
* Find activated plugin license data using Encode basename of plugin
*
* @param $basename
*
* @return [] |null
*/
public static function find_licence_data_using_basename( $basename ) {
if ( is_multisite() ) {
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
if ( is_array( $active_plugins ) && ( in_array( $basename, apply_filters( 'active_plugins', $active_plugins ), true ) || array_key_exists( $basename, apply_filters( 'active_plugins', $active_plugins ) ) ) ) {
$activated_licences = get_blog_option( get_network()->site_id, 'woofunnels_plugins_info', [] );
} else {
$activated_licences = get_option( 'woofunnels_plugins_info', [] );
}
} else {
$activated_licences = get_option( 'woofunnels_plugins_info', [] );
}
if ( empty( $activated_licences ) ) {
return null;
}
if ( isset( $activated_licences[ $basename ] ) ) {
return $activated_licences[ $basename ];
}
return null;
}
public function start_updater() {
$data = $this->get_data();
$this->version = $data['version'];
$this->name = $data['plugin_slug'];
$this->human_name = $data['plugin_name'];
$this->slug = str_replace( '.php', '', basename( $data['plugin_slug'] ) );
$this->wp_override = false;
$this->cache_key = md5( maybe_serialize( $this->slug ) );
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 999, 3 );
}
public function get_data() {
return count( $this->license_data ) > 0 ? $this->license_data : $this->default_keys;
}
/**
* preform here license check for all installed plugin
*/
public function woofunnels_license_check() {
$plugins = $this->get_plugins();
$all_status = array();
if ( is_array( $plugins ) && count( $plugins ) > 0 ) {
foreach ( $plugins as $slug => $plugin ) {
$api_data = array(
'plugin_slug' => $slug,
'email' => $plugin['data_extra']['license_email'],
'license_key' => $plugin['data_extra']['api_key'],
'product_id' => $plugin['data_extra']['software_title'],
'version' => '0.1.0',
);
$this->setup_data( $api_data );
}
}
return $all_status;
}
public function license_status() {
//do nothing here as the login moved to License Controller class to batch this request
}
public function activate_license() {
$parse_data = $this->get_data();
$parse_data['request'] = 'activation';
$end_point_url = add_query_arg( $parse_data, $this->software_end_point );
$this->request_body = $this->http()->get( $end_point_url, $this->request_args );
$output = $this->build_output();
if ( false !== $output ) {
$this->save_license( $output );
}
WooFunnels_Process::get_instance()->maybe_clear_plugin_update_transients();
return $output;
}
public function http() {
if ( is_null( $this->http ) ) {
$this->http = new WP_Http();
}
return $this->http;
}
private function build_output( $is_serialize = false ) {
$output = $this->request_body;
if ( ! is_wp_error( $output ) ) {
$body = $output['body'];
if ( '' !== $body ) {
if ( false === $is_serialize ) {
$body = json_decode( $body, true );
if ( $body ) {
return $body;
}
} else {
$object = maybe_unserialize( $body );
if ( is_object( $object ) && count( get_object_vars( $object ) ) > 0 ) {
return $object;
}
return false;
}
}
}
return false;
}
/**
* Save plugin activation data in database
*
* @param $license_data
*/
private function save_license( $license_data ) {
if ( ! empty( $license_data ) && isset( $license_data['activated'] ) && 1 == $license_data['activated'] ) {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
$plugin_info[ $slug ] = $license_data;
$this->update_plugins( $plugin_info );
}
}
}
public static function update_plugins( $data ) {
WooFunnels_License_Controller::update_plugins( $data );
do_action( 'funnelkit_license_update' );
}
public function deactivate_license() {
$parse_data = $this->get_data();
$parse_data['request'] = 'deactivation';
$end_point_url = add_query_arg( $parse_data, $this->software_end_point );
$this->request_body = $this->http()->get( $end_point_url, $this->request_args );
$ouput = $this->build_output();
if ( is_array( $ouput ) && isset( $ouput['code'] ) && 100 === absint( $ouput['code'] ) ) {
/**
* removed plugin license info data form db if license key not found on server and api return code 100
*/
$this->removed_plugin_info_data();
} else if ( false !== $ouput ) {
$this->mark_license_deactiavted_manually();
}
return $this->build_output();
}
/**
*remove plugin license from database
*/
private function remove_license() {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
unset( $plugin_info[ $slug ] );
$this->update_plugins( $plugin_info );
}
}
}
/**
*remove plugin license from database
*/
private function invalidate_license() {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
unset( $plugin_info[ $slug ] );
$this->update_plugins( $plugin_info );
}
}
}
public function handle_license_check_response( $output ) {
if ( false !== $output ) {
/**
* $output['status_check']
* 1 == active and valid
* 2 == expired
* 3 == trial ended
* 0 == invalid
*/
if ( $output['status_check'] && 3 === absint( $output['status_check'] ) ) {
/**
* Trial license came with the info that trial ends and user did not renew the license
* Here we need to mark the data so that plugin gets abandoned.
*/
$this->remove_license();
} elseif ( 2 === absint( $output['status_check'] ) ) {
$this->mark_license_expired();
} elseif ( 0 === absint( $output['status_check'] ) ) {
$this->mark_license_invalid();
} else {
$this->mark_license_active();
}
if ( isset( $output['data_extra'] ) && is_array( $output['data_extra'] ) ) {
$this->update_data( $output["data_extra"] );
}
if ( 'active' === $output['status_check'] ) {
$activation_domain = $output['status_extra']['activation_domain'];
$activation_domain = str_replace( [ 'https://', 'http://' ], '', $activation_domain );
$activation_domain = trim( $activation_domain, '/' );
if ( strpos( $this->get_domain(), $activation_domain ) === false ) {
$this->mark_license_deactiavted_manually();
}
}
}
}
private function mark_license_expired() {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
unset( $plugin_info[ $slug ]["manually_deactivated"] );
$plugin_info[ $slug ]["expired"] = 1;
$this->update_plugins( $plugin_info );
do_action( 'fk_license_expired', $plugin_info, $slug );
}
}
}
private function mark_license_invalid() {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
unset( $plugin_info[ $slug ]["manually_deactivated"] );
$plugin_info[ $slug ]["activated"] = 0;
$plugin_info[ $slug ]["expired"] = 0;
$this->update_plugins( $plugin_info );
}
}
}
/**
* @return void
*/
private function removed_plugin_info_data() {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
unset( $plugin_info[ $slug ] );
$this->update_plugins( $plugin_info );
}
}
}
private function mark_license_deactiavted_manually() {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
$plugin_info[ $slug ]["activated"] = 0;
$plugin_info[ $slug ]["expired"] = 0;
$plugin_info[ $slug ]["manually_deactivated"] = 1;
$this->update_plugins( $plugin_info );
}
}
}
private function mark_license_active() {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
$plugin_info[ $slug ]["activated"] = 1;
$plugin_info[ $slug ]["expired"] = 0;
unset( $plugin_info[ $slug ]["manually_deactivated"] );
$this->update_plugins( $plugin_info );
}
}
}
public function update_data( $output_data_extra ) {
$slug = $this->get_hash();
if ( '' !== $slug ) {
$plugin_info = self::get_plugins();
if ( isset( $plugin_info[ $slug ] ) ) {
$plugin_info[ $slug ]["data_extra"] = $output_data_extra;
$this->update_plugins( $plugin_info );
}
}
}
public function check_plugin_info() {
$parse_data = $this->get_data();
$parse_data['request'] = 'pluginupdatecheck';
$end_point_url = add_query_arg( $parse_data, $this->update_end_point );
$this->request_body = $this->http()->get( $end_point_url, $this->request_args );
return $this->build_output( true );
}
public function check_update( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass;
}
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
return $_transient_data;
}
$version_info = $this->get_cached_version_info();
/**
* if we ever have the info blank it means we do not have any reponse
*/
if ( is_array( $version_info ) && count( $version_info ) === 0 ) {
return $_transient_data;
}
if ( 'yes' === $this->invalidate_cache || false === $version_info ) {
$output = $this->check_update_info();
/**
* if we found update info as blank array then set the cache as blank and return from here
*/
if ( is_array( $output ) && count( $output ) === 0 ) {
$this->set_version_info_cache( $output );
return $_transient_data;
}
/**
* validate a valid output
*/
if ( false !== $output ) {
$output->slug = str_replace( '.php', '', basename( $this->slug ) );
$version_info = $output;
$version_info->plugin = $this->name;
$this->set_version_info_cache( $version_info );
}
}
if ( ! is_object( $version_info ) ) {
return $_transient_data;
}
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->version ) ) {
if ( version_compare( $this->version, $version_info->version, '<' ) ) {
$_transient_data->response[ $this->name ] = $version_info;
}
$_transient_data->last_checked = current_time( 'timestamp' );
$_transient_data->checked[ $this->name ] = $this->version;
}
return $_transient_data;
}
public function get_cached_version_info( $cache_key = '' ) {
if ( 'yes' === $this->invalidate_cache ) {
return false;
}
if ( empty( $cache_key ) ) {
$cache_key = "_bwf_version_cache_" . $this->cache_key;
}
$cache = get_option( $cache_key );
if ( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
delete_option( $cache_key );
return false; // Cache is expired
}
return json_decode( $cache['value'] );
}
public function check_update_info() {
$output = WooFunnels_License_Controller::get_plugin_update_check( $this->get_hash() );
/**
* if we have blank array as output then return as it is
*/
if ( is_array( $output ) && count( $output ) === 0 ) {
return [];
}
if ( false !== $output ) {
/*
* IF any error from the API then return blank array
*/
if ( isset( $output->errors ) ) {
return [];
}
/**
* BY this level we can be sure that we have the api response
* check for any new available version
*/
if ( version_compare( $this->version, $output['new_version'], '<' ) ) {
$parse_data = $this->get_data();
if ( ! empty( $parse_data['domain'] ) ) {
global $wpdb;
$db_domain = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s", 'siteurl' ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
if ( ! empty( $db_domain ) && $db_domain !== $parse_data['domain'] ) {
$parse_data['db_domain'] = rtrim( $db_domain, '/' );
}
}
$parse_data['request'] = 'plugininformation';
$end_point_url = add_query_arg( $parse_data, $this->update_end_point );
$this->request_body = $this->http()->get( $end_point_url, $this->request_args );
$out = $this->build_output( true );
if ( false !== $out ) {
$out->new_version = $output['new_version'];
$out->package = $output['package'];
$out->download_link = $output['package'];
$out->access_expires = $output['access_expires'];
return $out;
}
}
}
return [];
}
public function set_version_info_cache( $value = '', $cache_key = '' ) {
if ( empty( $cache_key ) ) {
$cache_key = "_bwf_version_cache_" . $this->cache_key;
}
$data = array(
'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
'value' => wp_json_encode( $value ),
);
update_option( $cache_key, $data, 'no' );
}
/**
* Updates information on the "View version x.x details" page with custom data.
*
*
* @param mixed $_data
* @param string $_action
* @param object $_args
*
* @return object $_data
*/
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
if ( $_action !== 'plugin_information' ) {
return $_data;
}
if ( ! isset( $_args->slug ) || ( $_args->slug !== $this->slug ) ) {
return $_data;
}
$version_info = $this->get_cached_version_info();
/**
* if we ever have the info blank it means we do not have any reponse
*/
if ( is_array( $version_info ) && count( $version_info ) === 0 ) {
return $_data;
}
if ( false === $version_info ) {
$output = $this->check_update_info();
/**
* if we found update info as blank array then set the cache as blank and return from here
*/
if ( is_array( $output ) && count( $output ) === 0 ) {
$this->set_version_info_cache( $output );
return $_data;
}
if ( false !== $output ) {
$output->slug = str_replace( '.php', '', basename( $this->slug ) );
$_data = $output;
$_data->plugin = basename( $this->slug );
$this->set_version_info_cache( $_data );
}
} else {
$_data = $version_info;
}
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
$new_sections = array();
foreach ( $_data->sections as $key => $value ) {
$new_sections[ $key ] = $value;
}
$_data->sections = $new_sections;
}
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
$new_banners = array();
foreach ( $_data->banners as $key => $value ) {
$new_banners[ $key ] = $value;
}
$_data->banners = $new_banners;
}
return $_data;
}
/**
* Disable SSL verification in order to prevent download update failures
*
* @param array $args
* @param string $url
*
* @return $array
*/
public function http_request_args( $args, $url ) {
$verify_ssl = $this->verify_ssl();
if ( ! is_null( $url ) && ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) ) {
$args['sslverify'] = $verify_ssl;
}
return $args;
}
/**
* Returns if the SSL of the store should be verified.
*
* @return bool
* @since 1.6.13
*/
private function verify_ssl() {
return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
}
}
}

View File

@@ -0,0 +1,244 @@
<?php
if ( ! class_exists( 'WooFunnels_License_Controller' ) ) {
#[AllowDynamicProperties]
class WooFunnels_License_Controller {
/**
* @var WooFunnels_License_check[]
*/
public static $plugins = [];
/**
* @var WP_Http
*/
public static $http;
private static $server_point = 'https://license.funnelkit.com/';
private static $software_end_point = '';
private static $request_args = array(
'timeout' => 30,
'sslverify' => false,
);
private static $plugin_update_check_data;
private static $cached_site_url = null;
private $license_data = array();
private $request_body = false;
public static function register_plugin( $hash, $object ) {
if ( ! isset( self::$plugins[ $hash ] ) ) {
self::$plugins[ $hash ] = $object;
}
}
public static function get_all_plugins() {
return self::$plugins;
}
/**
* Get cached site URL to avoid duplicate database calls
* @return string|null
*/
private static function get_cached_site_url() {
if ( self::$cached_site_url === null ) {
global $wpdb;
self::$cached_site_url = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s", 'siteurl' ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
}
return self::$cached_site_url;
}
/**
* Run a batch request to check license status of all the plugin
* Then trigger handle license check response of child class so that they can process their data.
*/
public static function license_check() {
$parse_data = [];
$parse_data['plugins'] = [];
$plugins_to_send = [];
foreach ( self::$plugins as $hash => $plugin ) {
$data = $plugin->get_data();
if ( empty( $data['plugin_slug'] ) ) {
continue;
}
$parse_url = wp_parse_url( $data['domain'] );
/**
* prevent license check when domain is IP, it will help reducing domain mismatches
*/
if ( is_array( $parse_url ) && ! empty( $parse_url['host'] ) && ! empty( ip2long( $parse_url['host'] ) ) ) {
continue;
}
if ( ! empty( $data['domain'] ) ) {
$cached_site_url = self::get_cached_site_url();
if ( ! empty( $cached_site_url ) && $cached_site_url !== $data['domain'] ) {
$data['db_domain'] = rtrim( $cached_site_url, '/' );
}
}
$parse_data['plugins'][ $hash ] = $plugins_to_send[ $hash ] = $data;
}
$request = 'status_request_all';
$output = self::build_output( self::http()->post( self::get_software_endpoint( $request ), array_merge( [ 'body' => $parse_data ], self::$request_args ) ) );
if ( $output && is_array( $output ) && count( $output ) > 0 ) {
foreach ( $output as $hash => $output_plugin ) {
if ( isset( $plugins_to_send[ $hash ] ) ) {
self::$plugins[ $hash ]->handle_license_check_response( $output_plugin );
}
}
}
WooFunnels_Process::get_instance()->maybe_clear_plugin_update_transients();
}
private static function build_output( $response, $is_searilize = false ) {
if ( ! is_wp_error( $response ) ) {
$body = $response['body'];
if ( '' !== $body ) {
if ( false === $is_searilize ) {
$body = json_decode( $body, true );
if ( $body ) {
return $body;
}
} else {
$object = maybe_unserialize( $body );
if ( is_object( $object ) && count( get_object_vars( $object ) ) > 0 ) {
return $object;
}
return false;
}
}
}
return false;
}
public static function http() {
if ( is_null( self::$http ) ) {
self::$http = new WP_Http();
}
return self::$http;
}
public static function get_software_endpoint( $request = '' ) {
return add_query_arg( array(
'wc-api' => 'am-software-api',
'request' => $request,
), self::$server_point );
}
public static function get_plugin_update_check( $hash ) {
$get_data = self::license_update_check();
if ( ! isset( $get_data[ $hash ] ) ) {
return false;
}
return $get_data[ $hash ];
}
public static function license_update_check() {
if ( ! is_null( self::$plugin_update_check_data ) ) {
return self::$plugin_update_check_data;
}
$parse_data = [];
$parse_data['plugins'] = [];
$plugins_to_send = [];
$prepare_dummy = [];
foreach ( self::$plugins as $hash => $plugin ) {
$data = $plugin->get_data();
if ( empty( $data['plugin_slug'] ) ) {
continue;
}
if ( ! empty( $data['domain'] ) ) {
$cached_site_url = self::get_cached_site_url();
if ( ! empty( $cached_site_url ) && $cached_site_url !== $data['domain'] ) {
$data['db_domain'] = rtrim( $cached_site_url, '/' );
}
}
$parse_data['plugins'][ $hash ] = $plugins_to_send[ $hash ] = $data;
$prepare_dummy[ $hash ] = [];
}
$request = 'pluginupdatecheckall';
$output = self::build_output( self::http()->post( self::get_update_endpoint( $request ), array_merge( [ 'body' => $parse_data ], self::$request_args ) ) );
if ( $output ) {
self::$plugin_update_check_data = $output;
} else {
$output = $prepare_dummy;
self::$plugin_update_check_data = $output;
}
return $output;
}
public static function get_update_endpoint( $request = '' ) {
return add_query_arg( array(
'wc-api' => 'upgrade-api',
'request' => $request,
), self::$server_point );
}
public static function get_plugins() {
if ( is_multisite() ) {
$plugin_config = WooFunnel_Loader::get_the_latest();
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
if ( is_array( $active_plugins ) && is_array( $plugin_config ) && count( $plugin_config ) > 0 && ( in_array( $plugin_config['basename'], apply_filters( 'active_plugins', $active_plugins ), true ) || array_key_exists( $plugin_config['basename'], apply_filters( 'active_plugins', $active_plugins ) ) ) ) {
return get_blog_option( get_network()->site_id, 'woofunnels_plugins_info', [] );
} else {
return is_array( get_option( 'woofunnels_plugins_info', [] ) ) ? get_option( 'woofunnels_plugins_info', [] ) : [];
}
}
return is_array( get_option( 'woofunnels_plugins_info', [] ) ) ? get_option( 'woofunnels_plugins_info', [] ) : [];
}
public static function update_plugins( $data ) {
update_option( 'woofunnels_plugins_info', $data, 'yes' );
}
public static function get_basename_by_key( $hash ) {
if ( ! isset( self::$plugins[ $hash ] ) ) {
return __return_empty_string();
}
$data = self::$plugins[ $hash ]->get_data();
return $data['plugin_slug'];
}
/**
* Callback method to run license check manually
* @return void
*/
public static function license_check_api_call_init() {
try {
$check_transient = get_transient( 'fk_license_check_api_call_init' );
if ( ! empty( $check_transient ) ) {
wp_send_json( array( 'status' => 'failure', 'message' => 'lock exists' ) );
}
self::license_check();
set_transient( 'fk_license_check_api_call_init', 1, HOUR_IN_SECONDS );
$plugins = self::get_all_plugins();
wp_send_json( array( 'status' => 'success', 'message' => 'License check initiated', 'is_pro' => count( $plugins ) > 0 ? true : false ) );
} catch ( Exception|Error $e ) {
wp_send_json( array( 'status' => 'failure', 'message' => $e->getMessage() ) );
}
}
}
}

View File

@@ -0,0 +1,186 @@
<?php
if ( ! class_exists( 'WooFunnels_Licenses' ) ) {
/**
* Plugin licenses data class / we do not handle license activation and deactivation at this class
*
* @author woofunnels
* @package WooFunnels
*/
#[AllowDynamicProperties]
class WooFunnels_Licenses {
protected static $instance;
public $plugins_list;
public function __construct() {
//calling appropriate hooks by identifying the request
$this->maybe_submit();
$this->maybe_deactivate();
add_action( 'admin_notices', array( $this, 'maybe_show_invalid_license_error' ) );
}
/**
* Pass to submission
*/
public function maybe_submit() {
if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( bwf_clean( $_POST['_wpnonce'] ), 'woofunnels-activate-license' ) ) {
if ( isset( $_POST['action'] ) && $_POST['action'] === 'woofunnels_activate-products' ) {
do_action( 'woofunnels_licenses_submitted', $_POST );
}
}
}
/**
* Pass to deactivate hook
*/
public function maybe_deactivate() {
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( bwf_clean( $_GET['_wpnonce'] ), 'bwf-deactivate-product' ) ) {
if ( isset( $_GET['action'] ) && 'woofunnels_deactivate-product' === sanitize_text_field( $_GET['action'] ) ) {
do_action( 'woofunnels_deactivate_request', $_GET );
}
}
}
/**
* Creates and instance of the class
* @return WooFunnels_licenses
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
public function maybe_show_invalid_license_error() {
$get_plugins_data = $this->get_data();
if ( ! is_array( $get_plugins_data ) ) {
return;
}
if ( empty( $get_plugins_data ) ) {
return;
}
$plugins_need_license_woofunnels = $this->get_data( 'woofunnels' );
$plugins_need_license_autonami = $this->get_data( 'autonami' );
$plugins_need_license_woofunnels_titles = [];
$plugins_need_license_autonami_titles = [];
foreach ( $plugins_need_license_woofunnels as $plugin_data ) {
if ( 'active' !== $plugin_data['product_status'] || $this->is_expired( $plugin_data ) || $this->is_disabled( $plugin_data ) ) {
array_push( $plugins_need_license_woofunnels_titles, $plugin_data['plugin'] );
}
}
foreach ( $plugins_need_license_autonami as $plugin_data ) {
if ( 'active' !== $plugin_data['product_status'] || $this->is_expired( $plugin_data ) || $this->is_disabled( $plugin_data ) ) {
array_push( $plugins_need_license_autonami_titles, $plugin_data['plugin'] );
}
}
if ( ! empty( $plugins_need_license_woofunnels_titles ) ) {
$this->show_invalid_license_notice( $plugins_need_license_woofunnels_titles, 'woofunnels' );
}
if ( ! empty( $plugins_need_license_autonami_titles ) ) {
$this->show_invalid_license_notice( $plugins_need_license_autonami_titles, 'autonami' );
}
}
public function get_data( $type = 'all' ) {
if ( is_null( $this->plugins_list ) ) {
$this->get_plugins_list();
}
if ( 'all' === $type ) {
return $this->plugins_list;
}
if ( 'autonami' === $type || 'woofunnels' === $type ) {
$plugins_autonami = [];
$plugins_woofunnels = $this->plugins_list;
if ( is_array( $this->plugins_list ) && count( $this->plugins_list ) ) {
foreach ( $this->plugins_list as $key => $license ) {
if ( ! is_null( $license['plugin'] ) && false !== strpos( $license['plugin'], 'Automations' ) ) {
$plugins_autonami[ $key ] = $license;
unset( $plugins_woofunnels[ $key ] );
}
}
}
return ( 'autonami' === $type ) ? $plugins_autonami : $plugins_woofunnels;
}
}
public function get_plugins_list() {
$this->plugins_list = apply_filters( 'woofunnels_plugins_license_needed', array() );
$get_all_plugins_data = WooFunnels_License_Controller::get_plugins();
foreach ( array_keys( $this->plugins_list ) as $key ) {
if ( false === array_key_exists( $key, $get_all_plugins_data ) ) {
continue;
}
$this->plugins_list[ $key ]['_data'] = $get_all_plugins_data[ $key ];
}
}
public function is_expired( $license_data ) {
if ( isset( $license_data['_data'] ) && isset( $license_data['_data']['expired'] ) && ! empty( $license_data['_data']['expired'] ) ) {
return true;
}
return false;
}
public function is_disabled( $license_data ) {
if ( empty( $license_data['_data']['activated'] ) ) {
return true;
}
return false;
}
public function show_invalid_license_notice( $plugins, $type ) {
?>
<div class="bwf-notice notice error">
<p>
<?php
echo sprintf( __( '<strong>Invalid License Key: </strong> You are <i>not receiving</i> Latest Updates, New Features, Security Updates &amp; Bug Fixes for <strong>%1$s</strong>. <a href="%2$s">Click Here To Fix This</a>.', 'buildwoofunnels' ), implode( ', ', $plugins ), $this->license_url( $type ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.MissingTranslatorsComment, WordPress.WP.I18n.TextDomainMismatch
?>
</p>
</div>
<?php
}
public function license_url( $type ) {
if ( $type === 'woofunnels' && defined( 'WFFN_VERSION' ) ) {
return admin_url( '/admin.php?page=bwf&path=/settings/woofunnels_general_settings' );
} elseif ( $type === 'autonami' && defined( 'BWFAN_VERSION' ) && version_compare( BWFAN_VERSION, '2.0', '>=' ) ) {
return admin_url( '/admin.php?page=autonami&path=%2Fsettings' );
} else {
return admin_url( 'admin.php?page=woofunnels&tab=licenses' );
}
}
public function get_secret_license_key( $key ) {
$last_six = substr( $key, - 6 );
$initial_string = str_replace( $last_six, '', $key );
$initial_string_length = strlen( $initial_string );
$final_string = str_repeat( 'x', $initial_string_length ) . $last_six;
return $final_string;
}
}
}

View File

@@ -0,0 +1,470 @@
<?php
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WooFunnels_Notifications' ) ) {
#[AllowDynamicProperties]
class WooFunnels_Notifications {
private static $instance = null;
/** Notification listed array */
protected $notifications_list = [];
public function __construct() {
/** Inline styling for woofunnels notifications */
add_action( 'admin_head', [ $this, 'notification_inline_style' ] );
/** Inline javascript for woofunnels notifications */
add_action( 'admin_footer', [ $this, 'notification_inline_script' ] );
/** Ajax function dismiss to woofunnels notifications */
add_action( 'wp_ajax_wf_dismiss_link', array( $this, 'wf_dismiss_link' ) );
}
/**
* Instance of class
* @return WooFunnels_Notifications|null
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new WooFunnels_Notifications();
}
return self::$instance;
}
/**
* This will return all the notifications or the notifications based on the group id.
*
* @param string $notification_group Optional
*
* @return array
*/
public function get_all_notifications( $notification_group = '' ) {
if ( '' !== $notification_group && isset( $this->notifications_list[ $notification_group ] ) && ( is_array( $this->notifications_list[ $notification_group ] ) && count( $this->notifications_list[ $notification_group ] ) > 0 ) ) {
$notification_group_arr = [];
$notification_group_arr[ $notification_group ] = $this->notifications_list[ $notification_group ];
return $notification_group_arr;
}
return $this->notifications_list;
}
/**
* This is used to register a notification
*
* @param array $notification_value
* @param string $group
*
* @return array
*/
public function register_notification( $notification_value = [], $group = '' ) {
$error = [
'error' => 'Notification not register checkout your notification array or group name ',
];
if ( ( ! is_array( $notification_value ) || sizeof( $notification_value ) >= 2 ) || '' === $group ) {
$error['error'] = 'Check Your notification array format or notification group name';
return $error;
}
if ( ! is_array( $notification_value ) || count( $notification_value ) === 0 ) {
return $error;
}
$notice_key = key( $notification_value );
if ( isset( $this->notifications_list[ $group ][ $notice_key ] ) ) {
return $error;
}
$this->notifications_list[ $group ][ $notice_key ] = $notification_value[ $notice_key ];
return [
'success' => $notice_key . ' Key Set',
];
}
/**
* This is used to deregister a notification based on notification key and group
*
* @param string $notification_key
* @param string $notification_group
*
* @return array
*/
public function deregister_notification( $notification_key = '', $notification_group = '' ) {
$error = [
'error' => $notification_key . ' Key or notification group may be not Available.',
];
if ( '' === $notification_key || '' === $notification_group ) {
$error['error'] = 'Check your notification key and their group. Both are required for deletion';
return $error;
}
if ( ! isset( $this->notifications_list[ $notification_group ][ $notification_key ] ) || ! is_array( $this->notifications_list[ $notification_group ][ $notification_key ] ) || count( $this->notifications_list[ $notification_group ][ $notification_key ] ) === 0 ) {
return $error;
}
unset( $this->notifications_list[ $notification_group ][ $notification_key ] );
return [
'success' => $notification_key . ' Notices has been removed',
];
}
/**
* Display internal CSS
*/
public function notification_inline_style() {
?>
<style>
.notice.notice-error.wf_notice_cache_wrap {
position: relative;
overflow: hidden;
}
.wf_notice_cache_wrap a::before {
position: relative;
top: 18px;
left: -20px;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
.wf_notice_cache_wrap a.notice-dismiss {
position: static;
float: right;
top: 0;
right: 0;
padding: 0 15px 10px 28px;
margin-top: -10px;
font-size: 13px;
line-height: 1.23076923;
text-decoration: none;
}
/* cache setting */
.wf_notification_list_wrap h3.hndle {
text-align: left;
}
.wf_notification_wrap .swal2-icon.swal2-warning {
font-size: 6px;
line-height: 33px;
}
.wf_notification_content_sec p {
font-size: 14px;
line-height: 1.5;
position: relative;
padding-left: 20px;
margin-bottom: 11px;
}
.wf_notification_links a {
font-size: 15px;
font-weight: 100;
line-height: 1.5;
}
.wf_notification_wrap .wf_notification_btn_wrap a:hover {
background: #fafafa;
border-color: #999;
color: #23282d;
}
.wf_notification_wrap .inside {
padding: 0px 15px 30px;
}
.wf_notification_btn_wrap {
margin-bottom: 10px;
}
.wf_overlay_active {
z-index: 1;
position: absolute;
left: 0;
right: 0;
bottom: 0;
background: #ffffff5e;
top: 0;
display: none;
}
.wf_overlay_active.wf_show {
display: block;
}
.wf_notification_wrap a.notice-dismiss {
bottom: auto;
top: auto;
position: relative;
float: none;
right: 0;
padding: 0;
margin-top: 0;
font-size: 13px;
line-height: 20px;
text-decoration: none;
height: 20px;
display: inline-block;
margin-left: 20px;
}
.wf_notice_dismiss_link_wrap {
text-align: center;
}
.wf_notification_wrap a.notice-dismiss:before {
position: absolute;
top: 0px;
left: -20px;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
.wf_notification_content_sec:last-child {
margin-bottom: 0;
}
.wf_notification_content_sec {
margin-bottom: 30px;
position: relative;
}
.wf_notification_wrap.closed a.notice-dismiss {
display: none;
}
.wf_notification_wrap .wf_notification_btn_wrap a:last-child {
margin-bottom: 0;
}
.wf_notification_wrap .wf_notification_btn_wrap a {
color: #555;
border-color: #cccccc;
background: #f7f7f7;
box-shadow: 0 1px 0 #cccccc;
vertical-align: top;
display: block;
text-decoration: none;
font-size: 15px;
line-height: 20px;
padding: 8px 10px;
cursor: pointer;
margin: 0 0 11px;
border-width: 1px;
border-style: solid;
-webkit-appearance: none;
border-radius: 3px;
white-space: nowrap;
box-sizing: border-box;
text-align: center;
}
.wf_notification_wrap a.notice-dismiss + span {
display: block;
margin-top: 2px;
font-size: 14px;
line-height: 20px;
text-transform: capitalize;
}
.wf_notification_content_sec .wf_notification_html p:first-child:before {
width: 10px;
content: '';
height: 10px;
background: red;
position: absolute;
left: 0;
border-radius: 50%;
top: 6px;
}
.wf_notification_content_sec.wf_warning .wf_notification_html p:first-child:before {
background-color: orange;
}
.wf_notification_content_sec.wf_success .wf_notification_html > p:first-child:before {
background-color: green;
}
.wf_notification_content_sec.wf_error .wf_notification_html > p:first-child:before {
background-color: red;
}
.wf_notification_links a {
font-size: 15px;
font-weight: 100;
line-height: 1.5;
}
</style>
<?php
}
/**
* Display internal scripts
*/
public function notification_inline_script() {
?>
<script>
(function ($) {
function wf_dismiss_notice() {
jQuery(document).on('click', '.wf_notice_dismiss_link_wrap .notice-dismiss', function (e) {
var $this = jQuery(this);
var noticeGroup = $this.parents('.wf_notification_content_sec').attr('wf-noti-group');
var noticekey = $this.parents('.wf_notification_content_sec').attr('wf-noti-key');
var wf_count = $this.attr('wf-notice-count');
$this.parents('.wf_notification_content_sec').find('.wf_overlay_active ').addClass('wf_show');
if (noticeGroup === '' && noticeGroup === '') {
return;
}
jQuery.ajax({
url: ajaxurl,
type: "POST",
data: {
action: 'wf_dismiss_link',
noticeGroup: noticeGroup,
noticekey: noticekey,
_nonce: '<?php echo wp_create_nonce( 'bwf_notice_dismiss' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>',
},
success: function (result) {
if (result.status === 'success' && result.success === 'true') {
/** check if the right notification area has only 1 notification */
if (jQuery(".wf_notification_wrap .wf_notification_content_sec").length == 1) {
$this.parents('.wf_notification_list_wrap').remove();
return;
}
/** remove the self notification html after 500 ms delay */
setTimeout(function () {
$this.parents('.wf_notification_content_sec').remove();
}, 500);
} else {
$this.parents('.wf_notification_content_sec').find('.wf_overlay_active ').removeClass('wf_show');
jQuery(".wf_notice_dismiss_link_wrap").append("<span >" + result.msg + "</span >")
}
}
});
});
}
jQuery(document).ready(function () {
wf_dismiss_notice();
});
})(jQuery);
</script>
<?php
}
/**
* Dismiss the notification
*/
public function wf_dismiss_link() {
$results = array(
'status' => 'failed',
'success' => 'false',
'msg' => 'Problem With dismiss',
);
check_ajax_referer( 'bwf_notice_dismiss', '_nonce' );
if ( ( isset( $_POST['noticeGroup'] ) && $_POST['noticeGroup'] !== '' ) && ( isset( $_POST['noticekey'] ) && $_POST['noticekey'] !== '' ) ) {
$noticeGroup = sanitize_text_field( $_POST['noticeGroup'] );
$noticekey = str_replace( 'wf-', '', sanitize_text_field( $_POST['noticekey'] ) );
$notices_display = get_option( 'wf_notification_list_' . $noticeGroup, [] );
$notice = $this->get_notification( $noticekey, $noticeGroup );
if ( ! is_array( $notices_display ) ) {
unset( $notices_display );
$notices_display = [];
}
if ( is_array( $notice ) && count( $notice ) > 0 ) {
$notices_display[] = $noticekey;
update_option( 'wf_notification_list_' . $noticeGroup, $notices_display );
}
$results = array(
'status' => 'success',
'success' => 'true',
'msg' => $noticekey . ' Notification Deleted',
);
}
wp_send_json( $results );
}
/**
* This will return the notification based on notification key and the group id
*
* @param string $notification_key
* @param string $notification_group
*
* @return array
*/
public function get_notification( $notification_key = '', $notification_group = '' ) {
$error = [
'error' => $notification_key . ' Key or Notification group may be Not Available.',
];
if ( '' === $notification_key || '' === $notification_group ) {
$error['error'] = 'Check your Notification Key and Their group. Both are required';
}
if ( isset( $this->notifications_list[ $notification_group ][ $notification_key ] ) && is_array( $this->notifications_list[ $notification_group ][ $notification_key ] ) && count( $this->notifications_list[ $notification_group ][ $notification_key ] ) > 0 ) {
return $this->notifications_list[ $notification_group ][ $notification_key ];
}
return $error;
}
/**
* Return the updated dismiss notification keys
*
* @param $group
*
* @return array|mixed|void
*/
public function get_dismiss_notification_key( $group ) {
if ( '' === $group ) {
return [
'error' => 'Need to a notice group for update key',
];
}
$notices_display = get_option( 'wf_notification_list_' . $group, [] );
if ( ! is_array( $notices_display ) ) {
$notices_display = [];
}
return $notices_display;
}
/**
* Display the notifications HTML
*
* @param $notifications_list
*/
public function get_notification_html( $notifications_list ) {
include dirname( dirname( __FILE__ ) ) . '/views/woofunnels-notifications.php';
}
}
}

View File

@@ -0,0 +1,363 @@
<?php
/**
* OptIn manager class is to handle all scenarios occurs for opting the user
* @author: WooFunnels
* @since 0.0.1
* @package WooFunnels
*/
if ( ! class_exists( 'WooFunnels_OptIn_Manager' ) ) {
#[AllowDynamicProperties]
class WooFunnels_OptIn_Manager {
public static $should_show_optin = true;
/**
* Initialization to execute several hooks
*/
public static function init() {
//push notification for optin
add_action( 'admin_init', array( __CLASS__, 'maybe_push_optin_notice' ), 15 );
add_action( 'admin_init', array( __CLASS__, 'maybe_clear_optin' ), 15 );
// track usage user callback
add_action( 'fk_fb_every_day', array( __CLASS__, 'maybe_track_usage' ), 10, 2 );
add_action( 'bwf_track_usage_scheduled_single', array( __CLASS__, 'maybe_track_usage' ), 10, 2 );
//initializing schedules
add_action( 'admin_footer', array( __CLASS__, 'initiate_schedules' ) );
// For testing license notices, uncomment this line to force checks on every page load
/** optin ajax call */
add_action( 'wp_ajax_woofunnelso_optin_call', array( __CLASS__, 'woofunnelso_optin_call' ) );
// optin yes track callback
add_action( 'woofunnels_optin_success_track_scheduled', array( __CLASS__, 'optin_track_usage' ), 10 );
add_filter( 'cron_schedules', array( __CLASS__, 'register_weekly_schedule' ), 10 );
}
/**
* Set function to block
*/
public static function block_optin() {
update_option( 'bwf_is_opted', 'no', true );
}
public static function maybe_clear_optin() {
if ( wp_verify_nonce( filter_input( INPUT_GET, '_nonce', FILTER_UNSAFE_RAW ), 'bwf_tools_action' ) && isset( $_GET['woofunnels_tracking'] ) && ( 'reset' === sanitize_text_field( $_GET['woofunnels_tracking'] ) ) ) {
self::reset_optin();
wp_safe_redirect( admin_url( 'admin.php?page=woofunnels&tab=tools' ) );
exit;
}
}
/**
* Reset optin
*/
public static function reset_optin() {
$get_action = filter_input( INPUT_GET, 'action', FILTER_UNSAFE_RAW );
if ( 'yes' === $get_action ) {
self::Allow_optin();
} else {
delete_option( 'bwf_is_opted' );
}
}
/**
* Set function to allow
*/
public static function Allow_optin( $pass_jit = false, $product = 'FB' ) {
if ( 'yes' === self::get_optIn_state() ) {
return;
}
if ( false !== wp_next_scheduled( 'bwf_track_usage_scheduled_single' ) ) {
wp_clear_scheduled_hook( 'bwf_track_usage_scheduled_single' );
}
if ( true === $pass_jit ) {
wp_schedule_single_event( current_time( 'timestamp' ), 'bwf_track_usage_scheduled_single', array( 'yes', $product ) );
} else {
wp_schedule_single_event( current_time( 'timestamp' ), 'bwf_track_usage_scheduled_single', array( false, $product ) );
}
update_option( 'bwf_is_opted', 'yes', true );
}
/**
* Collect some data and let the hook left for our other plugins to add some more info that can be tracked down
*
* @return array data to track
*/
public static function collect_data() {
global $wpdb, $woocommerce;
$installed_plugs = WooFunnels_addons::get_installed_plugins();
$active_plugins = get_option( 'active_plugins' );
$licenses = WooFunnels_licenses::get_instance()->get_data();
$theme = array();
$get_theme_info = wp_get_theme();
$theme['name'] = $get_theme_info->get( 'Name' );
$theme['uri'] = $get_theme_info->get( 'ThemeURI' );
$theme['version'] = $get_theme_info->get( 'Version' );
$theme['author'] = $get_theme_info->get( 'Author' );
$theme['author_uri'] = $get_theme_info->get( 'AuthorURI' );
$ref = get_option( 'woofunnels_optin_ref', '' );
$sections = array();
if ( class_exists( 'WooCommerce' ) ) {
$payment_gateways = WC()->payment_gateways->payment_gateways();
foreach ( $payment_gateways as $gateway_key => $gateway ) {
if ( 'yes' === $gateway->enabled ) {
$sections[] = esc_html( $gateway_key );
}
}
}
/** Product Count */
$product_count = array();
if ( class_exists( 'WooCommerce' ) ) {
$product_count_data = wp_count_posts( 'product' );
$product_count['total'] = property_exists( $product_count_data, 'publish' ) ? $product_count_data->publish : 0;
$product_statuses = get_terms( 'product_type', array( 'hide_empty' => 0 ) );
if ( is_array( $product_statuses ) && count( $product_statuses ) > 0 ) {
foreach ( $product_statuses as $product_status ) {
$product_count[ $product_status->name ] = $product_status->count;
}
}
}
/** Order Count */
$order_count = array();
if ( class_exists( 'WooCommerce' ) && function_exists( 'wc_orders_count' ) ) {
foreach ( wc_get_order_statuses() as $status_slug => $status_name ) {
$order_count[ $status_slug ] = wc_orders_count( $status_slug );
}
}
/** Base country slug */
$base_country = '';
if ( class_exists( 'WooCommerce' ) ) {
$base_country = get_option( 'woocommerce_default_country', false );
if ( ! empty( $base_country ) ) {
$base_country = substr( $base_country, 0, 2 );
}
}
$return = array(
'url' => home_url(),
'email' => get_option( 'admin_email' ),
'installed' => $installed_plugs,
'active_plugins' => $active_plugins,
'license_info' => $licenses,
'theme_info' => $theme,
'users_count' => self::get_user_counts(),
'locale' => get_locale(),
'is_mu' => is_multisite() ? 'yes' : 'no',
'wp' => get_bloginfo( 'version' ),
'php' => phpversion(),
'mysql' => $wpdb->db_version(),
'WooFunnels_version' => WooFunnel_Loader::$version,
'notification_ref' => $ref,
'date' => date( 'd.m.Y H:i:s' ),
'bwf_order_index_status' => get_option( '_bwf_db_upgrade', '0' ),
'bwf_version' => defined( 'BWF_VERSION' ) ? BWF_VERSION : '0.0.0',
);
if ( class_exists( 'WooCommerce' ) ) {
$return['country'] = $base_country;
$return['currency'] = get_woocommerce_currency();
$return['wc'] = $woocommerce->version;
$return['calc_taxes'] = get_option( 'woocommerce_calc_taxes' );
$return['guest_checkout'] = get_option( 'woocommerce_enable_guest_checkout' );
$return['product_count'] = $product_count;
$return['order_count'] = $order_count;
$return['wc_gateways'] = $sections;
}
return apply_filters( 'woofunnels_global_tracking_data', $return );
}
/**
* Get user totals based on user role.
* @return array
*/
private static function get_user_counts() {
$user_count = array();
$user_count_data = count_users();
$user_count['total'] = $user_count_data['total_users'];
// Get user count based on user role
foreach ( $user_count_data['avail_roles'] as $role => $count ) {
$user_count[ $role ] = $count;
}
return $user_count;
}
public static function update_optIn_referer( $referer ) {
update_option( 'woofunnels_optin_ref', $referer, false );
}
/**
* Checking the opt-in state and if we have scope for notification then push it
*/
public static function maybe_push_optin_notice() {
if ( self::get_optIn_state() === false && apply_filters( 'woofunnels_optin_notif_show', self::$should_show_optin ) ) {
do_action( 'bwf_maybe_push_optin_notice_state_action' );
}
}
/**
* Get current optin status from database
*
* @return mixed|void
*/
public static function get_optIn_state() {
return get_option( 'bwf_is_opted' );
}
/**
* Callback function to run on schedule hook
*/
public static function maybe_track_usage( $is_jit = false, $product = 'FB' ) {
//checking optin state
if ( true === self::is_optin_allowed() && 'yes' === self::get_optIn_state() ) {
$data = self::collect_data();
if ( $is_jit === 'yes' ) {
$data['jit'] = 'yes';
}
$data['product'] = $product;
//posting data to api
WooFunnels_API::post_tracking_data( $data );
}
}
/**
* Initiate schedules in order to start tracking data regularly.
*
*/
public static function initiate_schedules() {
// Run only in the admin dashboard
try {
if ( ! is_admin() ) {
return;
}
if ( ! current_user_can( 'administrator' ) ) {
return;
}
if ( ! wp_next_scheduled( 'fk_fb_every_day' ) ) {
wp_schedule_event( self::get_midnight_store_time(), 'daily', 'fk_fb_every_day' );
} else {
$scheduled_time = wp_next_scheduled( 'fk_fb_every_day' );
$midnight_time = self::get_midnight_store_time();
if ( $scheduled_time && abs( $scheduled_time - $midnight_time ) > 3600 ) {
do_action( 'fk_fb_every_day' );
wp_clear_scheduled_hook( 'fk_fb_every_day' );
}
}
$legacy_schedules = array(
'wfocu_schedule_mails_for_bacs_and_cheque',
'wfocu_schedule_pending_emails',
'wfocu_schedule_normalize_order_statuses',
'wfocu_schedule_thankyou_action',
'wfocu_remove_orphaned_transients',
'wffn_remove_orphaned_transients',
'bwf_maybe_track_usage_scheduled',
'woofunnels_license_check',
);
foreach ( $legacy_schedules as $schedule ) {
if ( strpos( $schedule, 'wfocu_' ) === 0 && ! wp_next_scheduled( 'fk_fb_every_4_minute' ) ) {
continue;
}
if ( wp_next_scheduled( $schedule ) ) {
wp_clear_scheduled_hook( $schedule );
}
}
} catch ( Exception $e ) {
}
}
/**
* @return int|void
*/
public static function get_midnight_store_time() {
try {
$timezone = new DateTimeZone( wp_timezone_string() );
$date = new DateTime();
$date->modify( '+1 days' );
$date->setTimezone( $timezone );
$date->setTime( 0, 0, 0 );
return $date->getTimestamp();
} catch ( Exception $e ) {
}
}
public static function is_optin_allowed() {
return apply_filters( 'buildwoofunnels_optin_allowed', true );
}
public static function woofunnelso_optin_call() {
check_ajax_referer( 'bwf_secure_key' );
if ( is_array( $_POST ) && count( $_POST ) > 0 ) {
$_POST['domain'] = home_url();
$_POST['ip'] = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( $_SERVER['REMOTE_ADDR'] ) : '';
WooFunnels_API::post_optin_data( $_POST );
/** scheduling track call when success */
if ( isset( $_POST['status'] ) && 'yes' === sanitize_text_field( $_POST['status'] ) ) {
wp_schedule_single_event( time() + 2, 'woofunnels_optin_success_track_scheduled' );
}
}
wp_send_json( array(
'status' => 'success',
) );
exit;
}
/**
* Callback function to run on schedule hook
*/
public static function optin_track_usage() {
/** update week day for tracking */
$track_week_day = date( 'w' );
update_option( 'woofunnels_track_day', $track_week_day, false );
$data = self::collect_data();
//posting data to api
WooFunnels_API::post_tracking_data( $data );
}
public static function maybe_default_optin() {
return;
}
public static function register_weekly_schedule( $schedules ) {
$schedules['weekly_bwf'] = array(
'interval' => WEEK_IN_SECONDS,
'display' => __( 'Weekly BWF', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
);
return $schedules;
}
}
// Initialization
WooFunnels_optIn_Manager::init();
}

View File

@@ -0,0 +1,744 @@
<?php
if ( ! class_exists( 'WooFunnels_Process' ) ) {
/**
* Basic process class that detect request and pass to respective class
*
* @author woofunnels
* @package WooFunnels
*/
#[AllowDynamicProperties]
class WooFunnels_Process {
private static $ins = null;
public $in_update_messages = array();
/**
* Initiate hooks
*/
public function __construct() {
add_action( 'admin_init', array( $this, 'parse_request_and_process' ), 14 );
add_filter( 'admin_notices', array( $this, 'maybe_show_advanced_update_notification' ), 999 );
add_action( 'admin_head', array( $this, 'register_in_update_plugin_message' ) );
add_action( 'fk_fb_every_day', array( 'WooFunnels_License_Controller', 'license_check' ) );
add_action( 'wp_ajax_nopriv_fk_init_license_request', array( 'WooFunnels_License_Controller', 'license_check_api_call_init' ) );
add_action( 'funnelkit_license_update', array( $this, 'maybe_clear_plugin_update_transients' ) );
add_action( 'funnelkit_delete_transients', array( $this, 'maybe_clear_plugin_update_transients' ) );
add_action( 'woocommerce_thankyou', array( $this, 'fire_thankyou_ajax' ), 10 );
add_action( 'wp_ajax_bwf_thankyou_ajax', array( $this, 'handle_thankyou_ajax' ), 10 );
add_action( 'wp_ajax_nopriv_bwf_thankyou_ajax', array( $this, 'handle_thankyou_ajax' ), 10 );
add_action( 'admin_init', array( $this, 'maybe_set_options_auto_loading_false' ) );
add_action( 'admin_head', array( $this, 'maybe_swap_order_to_make_it_correct' ), - 2 );
add_action( 'admin_head', array( $this, 'maybe_correct_submenu_order' ), - 1 );
add_action( 'admin_head', array( $this, 'correct_sub_menu_order' ), 999 );
add_action( 'admin_head', array( $this, 'correct_sub_menu_order_legacy' ), 999 );
add_action( 'admin_init', array( $this, 'hide_plugins_update_notices' ) );
add_action( 'admin_footer', array( $this, 'print_css' ), 9999 );
}
public static function get_instance() {
if ( self::$ins === null ) {
self::$ins = new self;
}
return self::$ins;
}
public function parse_request_and_process() {
//Initiating the license instance to handle submissions (submission can redirect page two that can cause "header already sent" issue to be arised)
// Initiating this to over come that issue
if ( 'woofunnels' === filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW ) && 'licenses' === filter_input( INPUT_GET, 'tab', FILTER_UNSAFE_RAW ) ) {
WooFunnels_licenses::get_instance();
}
//Handling Optin
if ( isset( $_GET['woofunnels-optin-choice'] ) && isset( $_GET['_woofunnels_optin_nonce'] ) ) {
if ( ! wp_verify_nonce( sanitize_text_field( $_GET['_woofunnels_optin_nonce'] ), 'woofunnels_optin_nonce' ) ) {
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woofunnels' ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'Cheating huh?', 'woofunnels' ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
$optin_choice = sanitize_text_field( $_GET['woofunnels-optin-choice'] );
if ( $optin_choice === 'yes' ) {
WooFunnels_optIn_Manager::Allow_optin();
if ( isset( $_GET['ref'] ) ) {
WooFunnels_optIn_Manager::update_optIn_referer( filter_input( INPUT_GET, 'ref', FILTER_UNSAFE_RAW ) );
}
} else {
WooFunnels_optIn_Manager::block_optin();
}
do_action( 'woofunnels_after_optin_choice', $optin_choice );
}
//Initiating the license instance to handle submissions (submission can redirect page two that can cause "header already sent" issue to be arised)
// Initiating this to over come that issue
if ( isset( $_GET['page'] ) && 'woofunnels' === sanitize_text_field( $_GET['page'] ) && isset( $_GET['tab'] ) && 'support' === sanitize_text_field( $_GET['tab'] ) && isset( $_POST['woofunnels_submit_support'] ) ) {
$instance_support = WooFunnels_Support::get_instance();
if ( filter_input( INPUT_POST, 'choose_addon', true ) === '' || filter_input( INPUT_POST, 'comments', true ) === '' ) {
$instance_support->validation = false;
}
}
}
public function maybe_show_advanced_update_notification() {
$screen = get_current_screen();
$plugins_installed = WooFunnels_Addons::get_installed_plugins();
$hide_notice = get_option( 'woofunnel_hide_update_notice', 'no' );
if ( 'yes' !== $hide_notice && is_object( $screen ) && 'index.php' === $screen->parent_file ) {
$plugins = get_site_transient( 'update_plugins' );
if ( isset( $plugins->response ) && is_array( $plugins->response ) ) {
$plugins = array_keys( $plugins->response );
$plugin_names = [];
foreach ( $plugins_installed as $basename => $installed ) {
if ( is_array( $plugins ) && count( $plugins ) > 0 && in_array( $basename, $plugins, true ) ) {
$plugin_names[] = $installed['Name'];
}
}
if ( count( $plugin_names ) > 0 ) {
?>
<div class="woofunnel-notice-message notice notice-warning">
<a class="woofunnel-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'woofunnel-update-notice', 'hide' ), 'woofunnel_update_notice_nonce', '_woofunnel_update_notice_nonce' ) ); ?>">
<?php esc_html_e( 'Dismiss', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
</a>
<p>
<?php
_e( sprintf( 'Attention: There is an update available of <strong>%s</strong> plugin. &nbsp;<a href="%s" class="">Go to updates</a>', implode( ', ', $plugin_names ), admin_url( 'plugins.php?s=funnelkit&plugin_status=all' ) ), 'woofunnels' ); // phpcs:ignore WordPress.Security.EscapeOutput, WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment, WordPress.WP.I18n.NonSingularStringLiteralText
?>
</p>
</div>
<style>
div.woofunnel-notice-message {
overflow: hidden;
position: relative;
}
.woofunnel-notice-message a.woofunnel-message-close {
position: static;
float: right;
padding: 0px 15px 5px 28px;
margin-top: -10px;
line-height: 14px;
text-decoration: none;
}
.woofunnel-notice-message a.woofunnel-message-close:before {
position: relative;
top: 18px;
left: -20px;
transition: all .1s ease-in-out;
}
</style>
<?php
}
}
}
}
/**
* Set option for hide woofunnel plugin update notice
*/
public static function hide_plugins_update_notices() {
if ( isset( $_GET['woofunnel-update-notice'] ) && isset( $_GET['_woofunnel_update_notice_nonce'] ) ) {
if ( ! wp_verify_nonce( sanitize_text_field( $_GET['_woofunnel_update_notice_nonce'] ), 'woofunnel_update_notice_nonce' ) ) {
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woofunnels' ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
update_option( 'woofunnel_hide_update_notice', 'yes' );
wp_safe_redirect( admin_url( 'index.php' ) );
exit;
}
}
public function register_in_update_plugin_message() {
$get_in_update_message_support = apply_filters( 'woofunnels_in_update_message_support', array() );
if ( empty( $get_in_update_message_support ) ) {
return;
}
$this->in_update_messages = $get_in_update_message_support;
$get_basenames = array_keys( $get_in_update_message_support );
foreach ( $get_basenames as $basename ) {
add_action( 'in_plugin_update_message-' . $basename, array( $this, 'in_plugin_update_message' ), 10, 2 );
}
}
/**
* Show plugin changes on the plugins screen. Code adapted from W3 Total Cache.
*
* @param array $args Unused parameter.
* @param stdClass $response Plugin update response.
*/
public function in_plugin_update_message( $args, $response ) {
$changelog_path = $this->in_update_messages[ $args['plugin'] ];
$current_version = $args['Version'];
$upgrade_notice = $this->get_upgrade_notice( $response->new_version, $changelog_path, $current_version );
echo apply_filters( 'woofunnels_in_plugin_update_message', $upgrade_notice ? '</br>' . wp_kses_post( $upgrade_notice ) : '', $args['plugin'] ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<style>span.woofunnels_plugin_upgrade_notice::before {
content: ' . '"\f463";
margin-right: 6px;
vertical-align: bottom;
color: #f56e28;
display: inline-block;
font: 400 20px/1 dashicons;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
vertical-align: top;
}</style>';
}
/**
* Get the upgrade notice from WordPress.org.
*
* @param string $version WooCommerce new version.
*
* @return string
*/
protected function get_upgrade_notice( $version, $path, $current_version ) {
$transient_name = 'woofunnels_upgrade_notice_' . $version . md5( $path );
$upgrade_notice = get_transient( $transient_name );
if ( false === $upgrade_notice ) {
$response = wp_safe_remote_get( $path );
if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
$upgrade_notice = $this->parse_update_notice( $response['body'], $version, $current_version );
set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
}
}
return $upgrade_notice;
}
/**
* Parse update notice from readme file.
*
* @param string $content WooCommerce readme file content.
* @param string $new_version WooCommerce new version.
*
* @return string
*/
private function parse_update_notice( $content, $new_version, $current_version ) {
$version_parts = explode( '.', $new_version );
$check_for_notices = array(
$version_parts[0] . '.0', // Major.
$version_parts[0] . '.0.0', // Major.
$version_parts[0] . '.' . $version_parts[1], // Minor.
);
$notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
$upgrade_notice = '';
foreach ( $check_for_notices as $check_version ) {
if ( version_compare( $current_version, $check_version, '>' ) ) {
continue;
}
$matches = null;
if ( preg_match( $notice_regexp, $content, $matches ) ) {
$notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
if ( version_compare( trim( $matches[1] ), $check_version, '=' ) ) {
$upgrade_notice .= '<span class="woofunnels_plugin_upgrade_notice">';
foreach ( $notices as $line ) {
$upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
}
$upgrade_notice .= '</span>';
}
break;
}
}
return wp_kses_post( $upgrade_notice );
}
public function fire_thankyou_ajax( $order_id ) {
$action = 'bwf_thankyou_ajax';
$nonce = wp_create_nonce( 'bwf_thankyou_ajax' );
$ajaxurl = admin_url( 'admin-ajax.php' );
$bwfUrlAjaxThankYou = $ajaxurl . '?action=' . $action . '&nonce=' . $nonce . '&order_id=' . $order_id;
?>
<script>
document.addEventListener("DOMContentLoaded", function (event) {
var xhr = new XMLHttpRequest();
var bwfUrlAjaxThankYou = '<?php echo $bwfUrlAjaxThankYou; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>';
xhr.open("POST", bwfUrlAjaxThankYou, true);
//Send the proper header information along with the request
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send();
});
</script>
<?php
}
public function handle_thankyou_ajax() {
check_ajax_referer( 'bwf_thankyou_ajax', 'nonce' );
$get_order_id = filter_input( INPUT_GET, 'order_id', FILTER_SANITIZE_NUMBER_INT );
if ( empty( $get_order_id ) ) {
return;
}
/**
* Fires a generic WC thankyou hook
*/
do_action( 'woofunnels_woocommerce_thankyou', $get_order_id );
wp_send_json( array( 'success' => true ) );
}
/**
* @hooked over 'admin_init'
* Mark the customizer data to not autoload on WP load as its only needed on specific pages.
*/
public function maybe_set_options_auto_loading_false() {
$should_run_query = get_option( '_bwf_upgrade_1_9_14', 'no' );
if ( 'yes' === $should_run_query ) {
return;
}
global $wpdb;
/**
* Update session table with the data
*/
$query = $wpdb->prepare( "UPDATE `" . $wpdb->prefix . "options` SET `autoload` = %s WHERE (`option_name` LIKE '%wfocu_c_%' OR `option_name` LIKE '%wfacp_c_%') AND `autoload` LIKE 'yes' AND `option_name` NOT LIKE 'wfacp_css_migrated'", 'no' );
$wpdb->query( $query ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
update_option( '_bwf_upgrade_1_9_14', 'yes' );
}
public function maybe_swap_order_to_make_it_correct() {
global $menu, $submenu;
if ( ! isset( $submenu['woofunnels'] ) ) {
return;
}
$get_parent_position = $this->get_parent_position( $menu );
$get_autonami_position = $this->get_autonami_position( $menu );
if ( false === $get_parent_position ) {
return;
}
if ( ! isset( $menu[ $get_autonami_position ] ) || ! is_array( $menu[ $get_autonami_position ] ) || 'autonami' !== $menu[ $get_autonami_position ][2] ) {
return;
}
$this->array_swap( $menu, $get_parent_position, $get_autonami_position );
}
/**
* @hooked over admin_head::-1
* Handles menu order for woofunnels submenu as it gets registered by the different plugin on different priorities
*/
public function maybe_correct_submenu_order() {
global $submenu, $menu, $woofunnels_menu_slug;
if ( ! isset( $submenu['woofunnels'] ) ) {
return;
}
$woofunnels_menu_slug = 'woofunnels';
$get_all_submenu = $submenu['woofunnels'];
/**
* get the top slug/submenu to play as parent menu
*/
$get_slug = $this->get_top_slug( $get_all_submenu );
if ( empty( $get_slug ) ) {
return;
}
/**
* get 'woofunnels' parent menu position so that we can alter it
*/
$get_parent_position = $this->get_parent_position( $menu );
if ( false === $get_parent_position ) {
return;
}
/**
* Assign found submenu in place of woofunnels to be shown as first menu in the series
*/
$menu[ $get_parent_position ][2] = $get_slug;
/**
* Unset woofunnels we do not need it
*/
unset( $submenu['woofunnels'] );
/**
* get the menu order sorted by placing license at the bottom
*/
$get_all_submenu = $this->get_current_order( $get_all_submenu );
/**
* Manage menu URL
*/
$get_all_submenu = array_map( function ( $val ) {
$val[2] = 'admin.php?page=' . $val[2];
return $val;
}, $get_all_submenu );
/**
* Place correct submenu in the global
*/
$submenu[ $get_slug ] = $get_all_submenu;
$woofunnels_menu_slug = $get_slug;
/**
* manage highlighting the menus
*/ global $parent_file, $plugin_page, $submenu_file, $current_page;
if ( true === $this->is_our_submenu( $plugin_page, $get_all_submenu ) ) :
$parent_file = $get_slug;//phpcs:ignore
$submenu_file = 'admin.php?page=' . $plugin_page;//phpcs:ignore
endif;
}
public function get_top_slug( $submenu ) {
if ( isset( $submenu[1][2] ) ) {
return $submenu[1][2];
}
return '';
}
function array_swap( &$array, $swap_a, $swap_b ) {
list( $array[ $swap_a ], $array[ $swap_b ] ) = array( $array[ $swap_b ], $array[ $swap_a ] );
}
public function get_parent_position( $menus ) {
$found = false;
foreach ( $menus as $key => $menu ) {
if ( 'woofunnels' === $menu[2] ) {
$found = $key;
break;
}
}
return $found;
}
public function get_autonami_position( $menus ) {
$found = false;
foreach ( $menus as $key => $menu ) {
if ( 'autonami' === $menu[2] ) {
$found = $key;
break;
}
}
return $found;
}
public function get_current_order( $get_all_submenu ) {
$get_license_config = $get_all_submenu[0];
array_shift( $get_all_submenu );
$get_all_submenu[ count( $get_all_submenu ) ] = $get_license_config;
return $get_all_submenu;
}
public function is_our_submenu( $plugin_page, $get_all_submenu ) {
$found = false;
foreach ( $get_all_submenu as $menu ) {
if ( 'admin.php?page=' . $plugin_page === $menu[2] ) {
$found = true;
break;
}
}
return $found;
}
public function correct_sub_menu_order() {
global $submenu, $menu;
/**
* change the title of the woofunnels to the new menu
*/
foreach ( $menu as &$men ) {
if ( isset( $men[5] ) && $men[5] === 'toplevel_page_woofunnels' ) {
$men[0] = 'FunnelKit';
$men[3] = 'FunnelKit';
}
}
if ( ! isset( $submenu['bwf'] ) ) {
return;
}
$new_sub_menu = [];
$any_external = false;
$max_count = 90;
$additional_break = false;
foreach ( $submenu['bwf'] as $key => $sub_item ) {
if ( ! current_user_can( $sub_item[1] ) ) {
continue;
}
if ( "admin.php?page=woofunnels" === $sub_item[2] ) {
continue;
}
switch ( $sub_item[2] ) {
case "admin.php?page=bwf":
$sub_item[4] = '';
$new_sub_menu[0] = $sub_item;
break;
case "admin.php?page=bwf&path=/funnels":
$new_sub_menu[10] = $sub_item;
break;
case "admin.php?page=bwf&path=/store-checkout":
$new_sub_menu[11] = $sub_item;
$new_sub_menu[11][4] = 'bwf_store_checkout';
break;
case "admin.php?page=bwf&path=/analytics":
$new_sub_menu[12] = $sub_item;
break;
case "admin.php?page=bwf&path=/templates":
$new_sub_menu[13] = $sub_item;
break;
case "admin.php?page=bwf_ab_tests":
$new_sub_menu[20] = $sub_item;
$any_external = true;
break;
case "admin.php?page=bwfcrm-contacts":
$sub_item[4] = 'bwf_admin_menu_b_top';
$new_sub_menu[70] = $sub_item;
$any_external = true;
break;
case "admin.php?page=autonami":
$new_sub_menu[80] = $sub_item;
$any_external = true;
break;
case "admin.php?page=bwf-campaigns":
$new_sub_menu[90] = $sub_item;
$any_external = true;
break;
case "admin.php?page=wfacp":
$any_external = true;
$new_sub_menu[40] = $sub_item;
break;
case "admin.php?page=wfch":
$any_external = true;
$new_sub_menu[45] = $sub_item;
break;
case "admin.php?page=wfob":
$any_external = true;
$new_sub_menu[50] = $sub_item;
break;
case "admin.php?page=upstroke":
$any_external = true;
$new_sub_menu[55] = $sub_item;
break;
default:
if ( false === $additional_break ) {
$additional_break = $max_count + 1;
}
$new_sub_menu[ $max_count + 1 ] = $sub_item;
$max_count ++;
break;
}
}
if ( ! empty( $new_sub_menu ) && count( $new_sub_menu ) > 0 ) {
/** Assigning class above native plugins */
if ( isset( $new_sub_menu[40] ) ) {
$new_sub_menu[40][4] = 'bwf_admin_menu_b_top';
} elseif ( isset( $new_sub_menu[45] ) ) {
$new_sub_menu[45][4] = 'bwf_admin_menu_b_top';
} elseif ( isset( $new_sub_menu[50] ) ) {
$new_sub_menu[50][4] = 'bwf_admin_menu_b_top';
} elseif ( isset( $new_sub_menu[55] ) ) {
$new_sub_menu[55][4] = 'bwf_admin_menu_b_top';
}
ksort( $new_sub_menu );
$submenu['bwf'] = $new_sub_menu;
ob_start();
?>
<style>
#adminmenu li.bwf_admin_menu_b_top {
border-top: 1px dashed #65686b;
padding-top: 5px;
margin-top: 5px
}
#adminmenu li.bwf_admin_menu_b_bottom {
border-bottom: 1px dashed #65686b;
padding-bottom: 5px;
margin-bottom: 5px
}
</style>
<?php
echo ob_get_clean(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
public function correct_sub_menu_order_legacy() {
global $submenu;
if ( ! isset( $submenu['bwf_dashboard'] ) ) {
return;
}
$new_sub_menu = [];
$section = filter_input( INPUT_GET, 'section', FILTER_UNSAFE_RAW );
$aero_settings = filter_input( INPUT_GET, 'tab', FILTER_UNSAFE_RAW );
$aero_page = filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW );
foreach ( $submenu['bwf_dashboard'] as $key => $sub_item ) {
if ( ! current_user_can( $sub_item[1] ) ) {
continue;
}
switch ( $sub_item[2] ) {
case "admin.php?page=bwf_dashboard":
$sub_item[4] = 'bwf_admin_menu_b_bottom';
$new_sub_menu[0] = $sub_item;
break;
case "admin.php?page=bwf_funnels":
$new_sub_menu[10] = $sub_item;
break;
case "admin.php?page=bwf_ab_tests":
$new_sub_menu[20] = $sub_item;
break;
case "admin.php?page=bwfcrm-contacts":
$sub_item[4] = 'bwf_admin_menu_b_top';
$new_sub_menu[70] = $sub_item;
break;
case "admin.php?page=autonami":
$new_sub_menu[80] = $sub_item;
break;
case "admin.php?page=bwf-campaigns":
$new_sub_menu[90] = $sub_item;
break;
case "admin.php?page=woofunnels_settings":
$sub_item[4] = 'bwf_admin_menu_b_top';
if ( in_array( $section, [ 'bwf_settings', 'lp-settings', 'op-settings', 'ty-settings' ] ) ) {
$sub_item[4] .= ' current';
} elseif ( 'settings' === $aero_settings && 'wfacp' === $aero_page ) {
$sub_item[4] .= ' current';
}
$new_sub_menu[140] = $sub_item;
break;
case "admin.php?page=woofunnels":
$new_sub_menu[150] = $sub_item;
break;
case "admin.php?page=wfacp":
$new_sub_menu[40] = $sub_item;
break;
case "admin.php?page=wfch":
$new_sub_menu[45] = $sub_item;
break;
case "admin.php?page=wfob":
$new_sub_menu[50] = $sub_item;
break;
case "admin.php?page=upstroke":
$new_sub_menu[55] = $sub_item;
break;
}
}
if ( ! empty( $new_sub_menu ) && count( $new_sub_menu ) > 0 ) {
/** Assigning class above native plugins */
if ( isset( $new_sub_menu[40] ) ) {
$new_sub_menu[40][4] = 'bwf_admin_menu_b_top';
} elseif ( isset( $new_sub_menu[45] ) ) {
$new_sub_menu[45][4] = 'bwf_admin_menu_b_top';
} elseif ( isset( $new_sub_menu[50] ) ) {
$new_sub_menu[50][4] = 'bwf_admin_menu_b_top';
}
ksort( $new_sub_menu );
$submenu['bwf_dashboard'] = $new_sub_menu;
ob_start();
?>
<style>
#adminmenu li.bwf_admin_menu_b_top {
border-top: 1px dashed #65686b;
padding-top: 5px;
margin-top: 5px
}
#adminmenu li.bwf_admin_menu_b_bottom {
border-bottom: 1px dashed #65686b;
padding-bottom: 5px;
margin-bottom: 5px
}
</style>
<?php
echo ob_get_clean(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
public function maybe_clear_plugin_update_transients() {
delete_transient( 'update_plugins' );
delete_site_transient( 'update_plugins' );
global $wpdb;
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name LIKE %s", '%_bwf_version_cache_%' ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
}
public function print_css() {
?>
<style>
.wp-admin #adminmenu .toplevel_page_woofunnels .wp-menu-image:before {
content: none;
}
.wp-admin #adminmenu .toplevel_page_woofunnels .wp-not-current-submenu .wp-menu-image {
background-image: url("<?php echo esc_url( plugin_dir_url( WooFunnel_Loader::$ultimate_path ) . 'woofunnels/assets/img/bwf-icon-grey.svg'); ?>") !important;
}
.wp-admin #adminmenu .toplevel_page_woofunnels .wp-has-current-submenu .wp-menu-image {
background-image: url("<?php echo esc_url( plugin_dir_url( WooFunnel_Loader::$ultimate_path ) . 'woofunnels/assets/img/bwf-icon-white.svg'); ?>") !important;
}
.wp-admin #adminmenu .toplevel_page_woofunnels .wp-menu-image {
background-repeat: no-repeat;
position: relative;
top: 5px;
background-position: 50% 25%;
background-size: 60%;
}
</style> <?php
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
if ( ! class_exists( 'WooFunnels_Support' ) ) {
/**
* @author woofunnels
* @package WooFunnels
*/
#[AllowDynamicProperties]
class WooFunnels_Support {
protected static $instance;
public $validation = true;
public $is_submitted;
/**
*
* WooFunnels_Support constructor.
*/
public function __construct() {
}
/**
* Creates and instance of the class
* @return WooFunnels_Support
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Processing support request
*
* @param $posted_data
*
* @uses WooFunnels_API used to fire api request to generate request
* @uses WooFunnels_admin_notifications pushing success and failure notifications
* @since 1.0.4
*/
public function woofunnels_maybe_push_support_request( $posted_data ) {
}
public function fetch_tools_data() {
}
public function js_script() {
}
}
}

View File

@@ -0,0 +1,196 @@
<?php
/**
* @author woofunnels
* @package WooFunnels
*/
if ( ! class_exists( 'WooFunnels_Transient' ) ) {
#[AllowDynamicProperties]
class WooFunnels_Transient {
protected static $instance;
/**
* WooFunnels_Transient constructor.
*/
public function __construct() {
}
/**
* Creates an instance of the class
* @return WooFunnels_Transient
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Set the transient contents by key and group within page scope
*
* @param $key
* @param $value
* @param int $expiration | default 1 hour
* @param string $plugin_short_name
*/
public function set_transient( $key, $value, $expiration = 3600, $plugin_short_name = 'bwf' ) {
$transient_key = '_woofunnels_transient_' . $plugin_short_name . '_' . $key;
$transient_value = array(
'time' => time() + (int) $expiration,
'value' => $value,
);
$file_writing = $this->is_file_saving_enabled();
if ( class_exists( 'WooFunnels_File_Api' ) && true === $file_writing ) {
$file_api = new WooFunnels_File_Api( $plugin_short_name . '-transient' );
$file_api->touch( $transient_key );
if ( $file_api->is_writable( $transient_key ) && $file_api->is_readable( $transient_key ) ) {
$transient_value = maybe_serialize( $transient_value );
$file_api->put_contents( $transient_key, $transient_value );
} else {
// woofunnels file api folder not writable
update_option( $transient_key, $transient_value, false );
}
} else {
// woofunnels file api method not available
update_option( $transient_key, $transient_value, false );
}
}
/**
* Get the transient contents by the transient key or group.
*
* @param $key
* @param string $plugin_short_name
*
* @return bool|mixed
*/
public function get_transient( $key, $plugin_short_name = 'bwf' ) {
if ( true === apply_filters( 'bwf_disable_woofunnels_transient', false, $plugin_short_name ) ) {
return false;
}
$transient_key = '_woofunnels_transient_' . $plugin_short_name . '_' . $key;
$file_writing = $this->is_file_saving_enabled();
if ( class_exists( 'WooFunnels_File_Api' ) && true === $file_writing ) {
$file_api = new WooFunnels_File_Api( $plugin_short_name . '-transient' );
if ( $file_api->is_writable( $transient_key ) && $file_api->is_readable( $transient_key ) ) {
$data = $file_api->get_contents( $transient_key );
$data = maybe_unserialize( $data );
$value = $this->get_value( $transient_key, $data );
if ( false === $value ) {
$file_api->delete( $transient_key );
}
return $value;
}
/**
* Restricted get value search only file if saving file enabled
*/
return false;
}
// woofunnels file api method not available
$data = get_option( $transient_key, false );
if ( false === $data ) {
return false;
}
return $this->get_value( $transient_key, $data, true );
}
public function get_value( $transient_key, $data, $db_call = false ) {
$current_time = time();
if ( is_array( $data ) && isset( $data['time'] ) ) {
if ( $current_time > (int) $data['time'] ) {
if ( true === $db_call ) {
delete_option( $transient_key );
}
return false;
} else {
return $data['value'];
}
}
return false;
}
/**
* Delete the transient by key
*
* @param $key
* @param string $plugin_short_name
*/
public function delete_transient( $key, $plugin_short_name = 'bwf' ) {
$transient_key = '_woofunnels_transient_' . $plugin_short_name . '_' . $key;
$file_writing = $this->is_file_saving_enabled();
if ( class_exists( 'WooFunnels_File_Api' ) && true === $file_writing ) {
$file_api = new WooFunnels_File_Api( $plugin_short_name . '-transient' );
if ( $file_api->exists( $transient_key ) ) {
$file_api->delete_file( $transient_key );
}
}
// removing db transient
delete_option( $transient_key );
}
/**
* Delete all the transients
*
* @param string $plugin_short_name
*/
public function delete_all_transients( $plugin_short_name = '' ) {
global $wpdb;
/** removing db transient */
$query = "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE '%_woofunnels_transient_{$plugin_short_name}%'";
$wpdb->query( $query ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
/** removing files if file api exist */
$file_writing = $this->is_file_saving_enabled();
if ( class_exists( 'WooFunnels_File_Api' ) && true === $file_writing ) {
$file_api = new WooFunnels_File_Api( $plugin_short_name . '-transient' );
$file_api->delete_all( $plugin_short_name . '-transient', true );
}
}
/**
* Delete all woofunnels plugins transients
*/
public function delete_force_transients() {
global $wpdb;
/** removing db transient */
$query = "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE '%_woofunnels_transient_%'";
$wpdb->query( $query ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL
/** removing files if file api exist */
$file_writing = $this->is_file_saving_enabled();
if ( class_exists( 'WooFunnels_File_Api' ) && true === $file_writing ) {
$file_api = new WooFunnels_File_Api( 'bwf-transient' );
$file_api->delete_folder( $file_api->woofunnels_core_dir, true );
}
}
/**
* Can modify the file writing via filter hook
*
* @return bool
*/
protected function is_file_saving_enabled() {
return apply_filters( '_bwf_transient_file_saving', true );
}
}
}

View File

@@ -0,0 +1,245 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
if ( ! class_exists( 'WooFunnels_Updater_Licenses_Table' ) ) {
/**
* Class WooFunnels_Updater_Licenses_Table
* @package WooFunnels
*/
#[AllowDynamicProperties]
class WooFunnels_Updater_Licenses_Table extends WP_List_Table {
public $per_page = 100;
public $data;
/**
* Constructor.
* @since 1.0.0
*/
public function __construct( $args = array() ) {
global $status, $page;
parent::__construct( array(
'singular' => 'license', //singular name of the listed records
'plural' => 'licenses', //plural name of the listed records
'ajax' => false, //does this table support ajax?
) );
$status = 'all';
$page = $this->get_pagenum();
$this->data = array();
// Make sure this file is loaded, so we have access to plugins_api(), etc.
require_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
parent::__construct( $args );
}
// End __construct()
/**
* Text to display if no items are present.
* @return void
* @since 1.0.0
*/
public function no_items() {
echo wpautop( __( 'No plugins available for activation.', 'woofunnels' ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.TextDomainMismatch
}
// End no_items(0)
/**
* The content of each column.
*
* @param array $item The current item in the list.
* @param string $column_name The key of the current column.
*
* @return string Output for the current column.
* @since 1.0.0
*/
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'plugin':
case 'product_status':
case 'product_version':
case 'license_expiry':
return $item[ $column_name ];
break;
}
}
// End column_default()
/**
* Content for the "product_name" column.
*
* @param array $item The current item.
*
* @return string The content of this column.
* @since 1.0.0
*/
public function column_plugin( $item ) {
return wpautop( '<strong>' . $item['plugin'] . '</strong>' );
}
// End get_sortable_columns()
/**
* Content for the "product_version" column.
*
* @param array $item The current item.
*
* @return string The content of this column.
* @since 1.0.0
*/
public function column_product_version( $item ) {
if ( isset( $item['latest_version'], $item['product_version'] ) && version_compare( $item['product_version'], $item['latest_version'], '<' ) ) {
$version_text = '<strong>' . $item['product_version'] . '<span class="update-available"> - ' . sprintf( __( 'version %1$s available', 'woofunnels' ), esc_html( $item['latest_version'] ) ) . '</span></strong>' . "\n"; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
} else {
$version_text = '<strong class="latest-version">' . $item['product_version'] . '</strong>' . "\n";
}
return wpautop( $version_text );
}
// End get_columns()
/**
* Content for the "status" column.
*
* @param array $item The current item.
*
* @return string The content of this column.
* @since 1.0.0
*/
public function column_product_status( $item ) {
$response = '';
$input_text = '<input name="license_keys[' . esc_attr( $item['product_file_path'] ) . '][key]" id="license_keys-' . esc_attr( $item['product_file_path'] ) . '" type="text" size="37" aria-required="true" value="' . $item['existing_key']['key'] . '" placeholder="' . esc_attr__( '
Place your license key here', 'woofunnels' ) . '" />' . "\n"; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
if ( $this->is_license_expire( $item ) ) {
$response_notice = '';
$response_notice .= $input_text;
$response_notice .= '<span class="below_input_message">' . sprintf( __( 'This license has expired. Login to <a target="_blank" href="%s">Your Account</a> and renew your license.', 'woofunnels' ), 'https://myaccount.funnelkit.com/' ) . '</span>'; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
$response .= apply_filters( 'woofunnels_license_notice_bewlow_field', $response_notice, $item );
} elseif ( 'active' === $item['product_status'] ) {
if ( empty( $item['_data']['activated'] ) ) {
$response_notice = '';
$response_notice .= $input_text;
if ( ! isset( $item['_data']['manually_deactivated'] ) || empty( $item['_data']['manually_deactivated'] ) ) {
$response_notice .= '<span class="below_input_message">' . sprintf( __( 'This license is no longer valid. Login to <a target="_blank" href="%s">Your Account</a> and renew your license.', 'woofunnels' ), 'https://myaccount.funnelkit.com/' ) . '</span>'; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment
}
$response .= apply_filters( 'woofunnels_license_notice_bewlow_field', $response_notice, $item );
} else {
$deactivate_url = wp_nonce_url( add_query_arg( 'action', 'woofunnels_deactivate-product', add_query_arg( 'filepath', $item['product_file_path'], add_query_arg( 'page', filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW ), add_query_arg( 'tab', 'licenses' ), network_admin_url( 'admin.php' ) ) ) ), 'bwf-deactivate-product' );
if ( isset( $item['existing_key'] ) && isset( $item['existing_key']['key'] ) ) {
$license_obj = WooFunnels_Licenses::get_instance();
$license_key = $license_obj->get_secret_license_key( $item['existing_key']['key'] );
$response = $license_key . '<br/>';
}
$response .= '<a href="' . esc_url( $deactivate_url ) . '">' . __( 'Deactivate', 'woofunnels' ) . '</a>' . "\n"; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
} else {
$response = $input_text;
}
return $response;
}
public function is_license_expire( $item ) {
if ( isset( $item['existing_key']['expires'] ) && $item['existing_key']['expires'] !== '' && ( strtotime( $item['existing_key']['expires'] ) < current_time( 'timestamp' ) ) ) {
return true;
}
if ( isset( $item['_data']['expired'] ) && ! empty( $item['_data']['expired'] ) ) {
return true;
}
return false;
}
public function column_product_expiry( $item ) {
if ( $this->is_license_expire( $item ) ) {
$date_string = __( 'Expire', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
try {
$date = new DateTime( $item['existing_key']['expires'] );
$date_string = $date->format( get_option( 'date_format' ) );
} catch ( Exception $e ) {
}
return $date_string;
} else {
if ( '' === $item['existing_key']['key'] ) {
return __( 'N/A', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
} elseif ( '' === $item['existing_key']['expires'] ) {
return __( 'Lifetime', 'woofunnels' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
} else {
$date = new DateTime( $item['existing_key']['expires'] );
$date_string = $date->format( get_option( 'date_format' ) );
return $date_string;
}
}
}
/**
* Retrieve an array of possible bulk actions.
* @return array
* @since 1.0.0
*/
public function get_bulk_actions() {
$actions = array();
return $actions; // End column_status()
}
/**
* Prepare an array of items to be listed.
* @since 1.0.0
*/
public function prepare_items() {
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array( $columns, $hidden, $sortable );
$total_items = is_array( $this->data ) ? count( $this->data ) : 0;
$this->set_pagination_args( array(
'total_items' => $total_items, //WE have to calculate the total number of items
'per_page' => $total_items, //WE have to determine how many items to show on a page
) );
$this->items = $this->data;
}
public function get_columns() {
$columns = array(
'plugin' => __( 'Plugin', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'product_version' => __( 'Version', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'product_status' => __( 'Key', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
'product_expiry' => __( 'Renews On', 'woofunnels' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
);
return $columns;
}
// End get_bulk_actions()
public function get_sortable_columns() {
return array();
}
}
}

View File

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