Skip to content

Commit

Permalink
2.4.6 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Whywilson committed Feb 3, 2023
1 parent af41707 commit 7ef9759
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 105 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-bulb-finder.zip
97 changes: 24 additions & 73 deletions auto-bulb-finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Auto Bulb Finder for WP & WC
Plugin URI: https://auto.mtoolstec.com
Description: Year/Make/Model/BodyType/Qualifer automoive bulb size querying system for vehicles from 1960 to 2022. Online database or custom vehicle list. Add to any page or content by a shortcode <code>[abf]</code>.
Version: 2.4.5
Version: 2.4.6
Author: MTools Tec
Author URI: https://shop.mtoolstec.com/about-us/
License: GPL
Expand Down Expand Up @@ -53,54 +53,48 @@ function () {
);


register_activation_hook(__FILE__, 'auto_bulb_finder_install');
register_activation_hook(__FILE__, 'abfinder_plugin_install');

register_deactivation_hook(__FILE__, 'auto_bulb_finder_deactive');
register_deactivation_hook(__FILE__, 'abfinder_plugin_deactive');

function auto_bulb_finder_install()
function abfinder_plugin_install()
{
add_option("enable_vehicle_post", "false");
add_option("app_promotion_html", get_default_app_promotion_html());
add_option("app_promotion_html", abfinder_get_default_app_promotion_html());
}

function auto_bulb_finder_deactive()
function abfinder_plugin_deactive()
{
delete_option('enable_vehicle_post');
delete_option('app_promotion_html');
unregister_post_type('vehicle');
}

function get_default_app_promotion_html()
function abfinder_get_default_app_promotion_html()
{
return ' <hr class="solid" style="margin-bottom: 12px"> <p>Get Full Bulb Size on Auto Bulb Finder App.</p> <p style="text-align: left;"> <a class="bullet-btn" style="background-image: linear-gradient(#3bc5ff, #5c8feb); color: white;" href="https://apps.apple.com/us/app/anyvalue/id1547269180" target="_blank" rel="noopener">App Store</a> <a class="bullet-btn" style="background-image: linear-gradient(#0FBEFC, #19E46C); color: white;" href="https://play.google.com/store/apps/details?id=com.automotive.mtools&hl=en_US&gl=US" target="_blank" rel="noopener">Play Store</a> </p> <style type="text/css"> .bullet-btn { border-radius: 20px; border-width: 2px; padding: 4px 12px; color: white; background-color: dodgerblue; text-decoration: none } </style>';
}

add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'abf_add_settings_link');
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'add_ab_finder_adaptions_link');
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'add_ab_finder_vehicles_link');
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'abfinder_add_settings_link');
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'abfinder_add_adaptions_link');
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'abfinder_add_vehicles_link');

function abf_add_settings_link($links)
function abfinder_add_settings_link($links)
{
return array_merge($links, array('<a href="' . admin_url('admin.php?page=auto-bulb-finder') . '">Settings</a>',));
}

function add_ab_finder_adaptions_link($links)
function abfinder_add_adaptions_link($links)
{
return array_merge($links, array('<a href="' . admin_url('admin.php?page=auto-bulb-finder-adaption') . '">Adaptions</a>',));
}

function add_ab_finder_vehicles_link($links)
function abfinder_add_vehicles_link($links)
{
return array_merge($links, array('<a href="' . admin_url('admin.php?page=auto-bulb-finder-vehicle') . '">Vehicles</a>',));
}


function auto_bulb_finder_config_html()
{
require dirname(__FILE__) . '/templates/admin/settings/class-abfinder-setting.php';
}

function abf_add_jquery()
function abfinder_add_jquery()
{
if (!is_admin()) {
wp_enqueue_script('jquery');
Expand All @@ -111,11 +105,11 @@ function abf_add_jquery()
wp_register_style('abf-settings-style', plugins_url('assets/css/style-setting.css', __FILE__));
}
}
add_action('init', 'abf_add_jquery');
add_action('init', 'abfinder_add_jquery');

add_filter('autoptimize_filter_js_exclude', 'abf_jquery_toggle');
add_filter('autoptimize_filter_js_exclude', 'abfinder_jquery_toggle');

function abf_jquery_toggle($in)
function abfinder_jquery_toggle($in)
{
if (is_front_page() || strpos($_SERVER['REQUEST_URI'], 'test-page') !== false) {
return $in . ', js/jquery/jquery.js';
Expand All @@ -124,7 +118,7 @@ function abf_jquery_toggle($in)
}
}

function abf_locate_template($template_name, $template_path = '', $default_path = '')
function abfinder_locate_template($template_name, $template_path = '', $default_path = '')
{
// Set variable to search in woocommerce-plugin-templates folder of theme.
if (!$template_path) :
Expand All @@ -150,7 +144,7 @@ function abf_locate_template($template_name, $template_path = '', $default_path
return apply_filters('wcpt_locate_template', $template, $template_name, $template_path, $default_path);
}

function abf_get_template($template_name, $args = array(), $tempate_path = '', $default_path = '')
function abfinder_get_template($template_name, $args = array(), $tempate_path = '', $default_path = '')
{
if (is_array($args) && isset($args)) :
extract($args);
Expand All @@ -163,7 +157,7 @@ function abf_get_template($template_name, $args = array(), $tempate_path = '', $
include $template_file;
}

function abf_vehicle_post_type()
function abfinder_vehicle_post_type()
{
register_post_type(
'vehicle',
Expand Down Expand Up @@ -193,7 +187,7 @@ function abf_vehicle_post_type()
}

if (get_option('enable_vehicle_post', 'false') == "true") {
add_action('init', 'abf_vehicle_post_type');
add_action('init', 'abfinder_vehicle_post_type');
}

final class ABFINDER
Expand Down Expand Up @@ -257,6 +251,7 @@ public function abfinder_includes()
require_once ABFINDER_PLUGIN_FILE . 'helper/class-abfinder-database.php';
require_once ABFINDER_PLUGIN_FILE . 'helper/class-abfinder-adaptions.php';
require_once ABFINDER_PLUGIN_FILE . 'helper/class-abfinder-vehicles.php';
require_once ABFINDER_PLUGIN_FILE . 'includes/blocks/custom-block.php';

if ($this->abfinder_is_request('frontend')) {
wp_enqueue_script('jquery');
Expand All @@ -282,15 +277,13 @@ private function abfinder_is_request($type)
register_activation_hook(__FILE__, array($schema_handler, 'init'));
}

require_once ABFINDER_PLUGIN_FILE . 'includes/blocks/custom-block.php';

function abf_add_abfinder_ajax_actions()
function abfinder_add_abfinder_ajax_actions()
{
add_action('wp_ajax_' . 'auto_bulb_finder', 'abfinder_ajax_function');
add_action('wp_ajax_nopriv_' . 'auto_bulb_finder', 'abfinder_ajax_function');
}

add_action('init', 'abf_add_abfinder_ajax_actions');
add_action('init', 'abfinder_add_abfinder_ajax_actions');

function abfinder_ajax_function()
{
Expand Down Expand Up @@ -352,48 +345,6 @@ function is_woocommerce_activated()
}
}

//Get Product Button
function get_flatsome_lightbox_button()
{
if (get_theme_mod('disable_quick_view', 0)) {
return;
}

// Run Quick View Script.
wp_enqueue_script('wc-add-to-cart-variation');

global $product;
return ' <a target="_blank" class="quick-view primary is-small mb-0 button product_type_simple add_to_cart_button ajax_add_to_cart is-flat text_replaceable" data-prod="' . $product->get_id() . '" href="' . get_permalink($product->get_id()) . '">' . __('Buy Now', 'flatsome') . '</a>';
}

//Return quick view button for viariable product
function flatsome_woocommerce_loop_add_to_cart_link_variable_quick_view($link, $product, $args)
{
if (!doing_action('flatsome_product_box_actions') && !doing_action('flatsome_product_box_after')) {
return $link;
}

switch (get_theme_mod('add_to_cart_icon', 'disabled')) {
case 'show':
$insert = '<div class="cart-icon tooltip is-small" title="' . esc_html($product->add_to_cart_text()) . '"><strong>+</strong></div>';
$link = preg_replace('/(<a.*?>).*?(<\/a>)/', '$1' . $insert . '$2', $link);
break;
case 'button':
if ($product->product_type == 'variable') {
$link = '<div class="add-to-cart-button"> ' . get_flatsome_lightbox_button() . '</div>';
} else {
$link = '<div class="add-to-cart-button">' . $link . '</div>';
}
break;
default:
return $link;
}

return $link;
}

add_filter('woocommerce_loop_add_to_cart_link', 'flatsome_woocommerce_loop_add_to_cart_link_variable_quick_view', 10, 3);

if (!function_exists('str_contains')) {
function str_contains($haystack, $needle)
{
Expand Down
4 changes: 2 additions & 2 deletions helper/class-abfinder-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function query_similar_bulbs($search = "")
return $json;
}

function get_token($code)
public function get_token($code)
{
$url = $this->base_url . 'getToken?';

Expand Down Expand Up @@ -381,7 +381,7 @@ function get_token($code)
return $json;
}

function revoke_token()
public function revoke_token()
{
delete_option('abf_code_status');
delete_option('abf_code_expired');
Expand Down
13 changes: 2 additions & 11 deletions includes/admin/class-abfinder-admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
// require_once ABFINDER_PLUGIN_FILE . 'helper/adaptions/class-abfinder-adaptions.php';
}

if (!function_exists('str_contains')) {
function str_contains($haystack, $needle)
{
return $needle !== '' && mb_strpos($haystack, $needle) !== false;
}
}

if (!class_exists('ABFinder_Admin_Functions')) {
/**
* Admin functions class
Expand All @@ -54,14 +47,12 @@ public function __construct()

public function auto_bulb_finder_admin_menu()
{
$hook = add_menu_page('Auto Bulb Finder', 'Auto Bulb', 'manage_options', 'auto-bulb-finder', array($this, 'abfinder_config_menu'), ABFINDER_PLUGIN_URL . 'assets/images/lightbulb-fill.svg', 20);
add_menu_page('Auto Bulb Finder', 'Auto Bulb', 'manage_options', 'auto-bulb-finder', array($this, 'abfinder_config_menu'), ABFINDER_PLUGIN_URL . 'assets/images/lightbulb-fill.svg', 20);
add_submenu_page('auto-bulb-finder', 'Adaptions', 'Adaptions', 'edit_pages', 'auto-bulb-finder-adaption', array($this, 'auto_bulb_finder_adaption_menu'));
add_submenu_page('auto-bulb-finder', 'Vehicles', 'Vehicles', 'edit_pages', 'auto-bulb-finder-vehicle', array($this, 'auto_bulb_finder_adaption_menu'));

// add_action( "admin_print_styles-$hook", array( $this, 'auto_bulb_finder_admin_scripts' ) );
}

function auto_bulb_finder_admin_scripts()
function abfinder_admin_script()
{
wp_enqueue_style('abf-settings-style');
}
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-abfinder-admin-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct() {
require_once ABFINDER_PLUGIN_FILE . 'includes/admin/class-abfinder-admin-functions.php';
$function_handler = new ABFinder_Admin_Functions();
add_action( 'admin_menu', array( $function_handler, 'auto_bulb_finder_admin_menu' ) );
add_action( 'admin_menu', array( $function_handler, 'auto_bulb_finder_admin_scripts' ) );
add_action( 'admin_menu', array( $function_handler, 'abfinder_admin_script' ) );
add_action( 'abfinder_add_adaption', array( $function_handler, 'abfinder_create_adaption' ), 10, 1 );
add_action( 'abfinder_add_vehicle', array( $function_handler, 'abfinder_create_vehicle' ), 10, 1 );
}
Expand Down
22 changes: 11 additions & 11 deletions includes/blocks/custom-block.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
function shortcode_auto_bulb_finder($atts = [], $content = null, $tag = '')
function abfinder_shortcode_abf($atts = [], $content = null, $tag = '')
{
wp_register_style('chosen-css', ABFINDER_PLUGIN_URL . 'assets/css/chosen.min.css');
wp_register_script('chosen-js', ABFINDER_PLUGIN_URL . 'assets/js/chosen.jquery.min.js');
Expand Down Expand Up @@ -33,9 +33,9 @@ function getSizeAndProducIdByVid($vid = '', $year = '', $make = '', $model = '',
return $result;
}

add_shortcode('abf', 'shortcode_auto_bulb_finder');
add_shortcode('abf', 'abfinder_shortcode_abf');

function shortcode_auto_bulb_finder_vehicle($atts = [], $content = null, $tag = '')
function abfinder_shortcode_abf_vehicle($atts = [], $content = null, $tag = '')
{
$atts = array_change_key_case((array)$atts, CASE_LOWER);
$bs_atts = shortcode_atts(
Expand All @@ -55,10 +55,10 @@ function shortcode_auto_bulb_finder_vehicle($atts = [], $content = null, $tag =
return $bs_atts['year'] . ' <> ' . $bs_atts['make'] . ' <> ' . $bs_atts['model'];
}

add_shortcode('abf_vehicle', 'shortcode_auto_bulb_finder_vehicle');
add_shortcode('abf_vehicle', 'abfinder_shortcode_abf_vehicle');

add_shortcode('abf_products', 'abf_products_shortcode');
function abf_products_shortcode($atts)
add_shortcode('abf_products', 'abfinder_products_shortcode');
function abfinder_products_shortcode($atts)
{
$atts = shortcode_atts(array(
'ids' => '',
Expand Down Expand Up @@ -129,9 +129,9 @@ function abf_products_shortcode($atts)
);
}, 10, 2);

function abf_ux_builder_element()
function abfinder_ux_builder_element()
{
add_ux_builder_shortcode('abf_ux_shortcode', array(
add_ux_builder_shortcode('abfinder_ux_shortcode', array(
'name' => __('Auto Bulb Finder', 'auto-bulb-finder'),
'category' => __('Content'),
'options' => array(
Expand All @@ -143,9 +143,9 @@ function abf_ux_builder_element()
),
));
}
add_action('ux_builder_setup', 'abf_ux_builder_element');
add_action('ux_builder_setup', 'abfinder_ux_builder_element');

function abf_ux_shortcode_func($atts)
function abfinder_ux_shortcode_func($atts)
{
extract(shortcode_atts(array(
'title' => 'Find My Vehicle'
Expand All @@ -154,7 +154,7 @@ function abf_ux_shortcode_func($atts)
wp_enqueue_script('abf-app-js');
echo do_shortcode(force_balance_tags('[abf]' . $title . '[/abf]'));
}
add_shortcode('abf_ux_shortcode', 'abf_ux_shortcode_func');
add_shortcode('abfinder_ux_shortcode', 'abfinder_ux_shortcode_func');

if (!function_exists('is_woocommerce_activated')) {
function is_woocommerce_activated()
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Donate link: https://auto.mtoolstec.com/donate
Requires at least: 6.0
Tested up to: 6.1.1
Requires PHP: 7.4
Stable tag: 2.4.5
Stable tag: 2.4.6
License: GPL v2
License URI: https://auto.mtoolstec.com/license

Expand Down
2 changes: 1 addition & 1 deletion templates/admin/settings/class-abfinder-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<td>
<label>Promotion Content(Html or ShortCode)</label>
<?php
$content = get_option("app_promotion_html", get_default_app_promotion_html());
$content = get_option("app_promotion_html", abfinder_get_default_app_promotion_html());
$editor_id = 'app-promotion';
$settings = array(
'textarea_name' => 'app-promotion',
Expand Down
4 changes: 2 additions & 2 deletions templates/front/class-abfinder-dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use ABFinder\Helper\ABFinder_Database; ?>

<?php echo file_get_contents(ABFINDER_PLUGIN_FILE . 'templates/front/class-abfinder-preloader.php'); ?>
<?php include ABFINDER_PLUGIN_FILE . 'templates/front/class-abfinder-loader.php'; ?>
<div id="abf-block" style="background: transparent;">
<?php
if ($content) {
Expand Down Expand Up @@ -51,7 +51,7 @@
</div>
<div id="app_promotion" style="display: none;padding: 10px;">
<?php
$appPromotion = get_option("app_promotion_html", get_default_app_promotion_html());
$appPromotion = get_option("app_promotion_html", abfinder_get_default_app_promotion_html());
if ($appPromotion) {
echo wp_kses_post($appPromotion);
}
Expand Down
Loading

0 comments on commit 7ef9759

Please sign in to comment.