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.
*
* @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( '' . __( 'To enable this update please activate your FunnelKit license by visiting the Dashboard Page.', 'woofunnels' ) . '
' ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
}
}
/**
* Model function to fire over licensing page.
* Hooked over 'woofunnels_tabs_modal_licenses'.
* @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.
* Hooked over 'woofunnels_tabs_modal_licenses'.
* @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.
* Hooked over 'woofunnels_tabs_modal_support'.
* @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.
* Hooked over 'woofunnels_tabs_modal_logs'.
* @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
?>
'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();
?>
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 );