File: /mnt/data/truelysell-wp/multipurpose/wp-content/themes/truelysell/functions.php
<?php
/**
* truelysell functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package truelysell
*/
update_option( 'Tselling_new_lic_Key', 'activated' );
if ( ! function_exists( 'truelysell_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
global $wpdb;
function truelysell_setup() {
load_theme_textdomain( 'truelysell', get_template_directory() . '/languages' );
if(in_array('redux-framework/redux-framework.php', apply_filters('active_plugins', get_option('active_plugins'))))
{
require_once( dirname(__FILE__).'/inc/options-init.php' );
}
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size(900, 500, true); //size of thumbs
add_image_size( 'truelysell-avatar', 590, 590 );
add_image_size( 'truelysell-blog-post', 1200, 670 );
add_image_size( 'truelysell-blog-related-post', 577, 866 );
add_image_size( 'truelysell-post-thumb', 150, 150, true );
add_editor_style();
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'truelysell_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
add_theme_support( 'customize-selective-refresh-widgets' );
}
endif;
add_action( 'after_setup_theme', 'truelysell_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function truelysell_content_width() {
$GLOBALS['content_width'] = apply_filters( 'truelysell_content_width', 760 );
}
add_action( 'after_setup_theme', 'truelysell_content_width', 0 );
/**
* Register widget area.
*/
function truelysell_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'truelysell' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
'before_widget' => '<div id="%1$s" class="card widget %2$s"><div class="card-body">',
'after_widget' => '</div></div>',
'before_title' => '<h4 class="side-title">',
'after_title' => '</h4>',
) );
register_sidebar(
array(
'name' => esc_html__( 'Footer Style2 Area1', 'truelysell' ),
'id' => 'footerarea-1',
'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
'before_widget' => '<section id="%1$s" class="widget %2$s footer-widget footer-content">',
'after_widget' => '</section>',
'before_title' => '<h2 class="footer-title">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Style2 Area2', 'truelysell' ),
'id' => 'footerarea-2',
'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
'before_widget' => '<section id="%1$s" class="widget %2$s footer-menu">',
'after_widget' => '</section>',
'before_title' => '<h2 class="footer-title">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Style2 Area3', 'truelysell' ),
'id' => 'footerarea-3',
'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
'before_widget' => '<section id="%1$s" class="widget %2$s footer-contact">',
'after_widget' => '</section>',
'before_title' => '<h2 class="footer-title">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Style2 Area4', 'truelysell' ),
'id' => 'footerarea-4',
'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
'before_widget' => '<section id="%1$s" class="widget %2$s ">',
'after_widget' => '</section>',
'before_title' => '<h2 class="footer-title">',
'after_title' => '</h2>',
)
);
// register_sidebar(
// array(
// 'name' => esc_html__( 'Footer Style2 Area1', 'truelysell' ),
// 'id' => 'footerareastwo-1',
// 'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
// 'before_widget' => '<section id="%1$s" class="widget %2$s ">',
// 'after_widget' => '</section>',
// 'before_title' => '<h2 class="footer-title">',
// 'after_title' => '</h2>',
// )
// );
// register_sidebar(
// array(
// 'name' => esc_html__( 'Footer Style2 Area2', 'truelysell' ),
// 'id' => 'footerareastwo-2',
// 'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
// 'before_widget' => '<section id="%1$s" class="widget %2$s ">',
// 'after_widget' => '</section>',
// 'before_title' => '<h2 class="footer-title">',
// 'after_title' => '</h2>',
// )
// );
// register_sidebar(
// array(
// 'name' => esc_html__( 'Footer Style2 Area3', 'truelysell' ),
// 'id' => 'footerareastwo-3',
// 'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
// 'before_widget' => '<section id="%1$s" class="widget %2$s ">',
// 'after_widget' => '</section>',
// 'before_title' => '<h2 class="footer-title">',
// 'after_title' => '</h2>',
// )
// );
// register_sidebar(
// array(
// 'name' => esc_html__( 'Footer Style2 Area4', 'truelysell' ),
// 'id' => 'footerareastwo-4',
// 'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
// 'before_widget' => '<section id="%1$s" class="widget %2$s ">',
// 'after_widget' => '</section>',
// 'before_title' => '<h2 class="footer-title">',
// 'after_title' => '</h2>',
// )
// );
// register_sidebar(
// array(
// 'name' => esc_html__( 'Footer Style2 Area5', 'truelysell' ),
// 'id' => 'footerareastwo-5',
// 'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
// 'before_widget' => '<section id="%1$s" class="widget %2$s ">',
// 'after_widget' => '</section>',
// 'before_title' => '<h2 class="footer-title">',
// 'after_title' => '</h2>',
// )
// );
register_sidebar(
array(
'name' => esc_html__( 'Footer Copyright Menu', 'truelysell' ),
'id' => 'footerarea-copyright-menu',
'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
'before_widget' => '<section id="%1$s" class="widget %2$s copyright-menu policy-menu">',
'after_widget' => '</section>',
'before_title' => '<h2 class="footer-title">',
'after_title' => '</h2>',
)
);
// register_sidebar(
// array(
// 'name' => esc_html__( 'Bookmark Widget', 'truelysell' ),
// 'id' => 'bookmark_widget',
// 'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
// 'before_widget' => '<section id="%1$s" class="widget %2$s">',
// 'after_widget' => '</section>',
// 'before_title' => '<h2 class="footer-title">',
// 'after_title' => '</h2>',
// )
// );
// register_sidebar(
// array(
// 'name' => esc_html__( 'Bookservice Widget', 'truelysell' ),
// 'id' => 'bookservice_widget',
// 'description' => esc_html__( 'Add widgets here.', 'truelysell' ),
// 'before_widget' => '<section id="%1$s" class="listing-widget %2$s">',
// 'after_widget' => '</section>',
// 'before_title' => '<h2 class="footer-title">',
// 'after_title' => '</h2>',
// )
// );
}
add_action( 'widgets_init', 'truelysell_widgets_init' );
add_action('after_switch_theme', 'truelysell_setup_options');
function truelysell_setup_options () {
update_option('truelysell_activation_date',time());
}
/**
* Enqueue scripts and styles.
*/
function truelysell_scripts() {
$my_theme = wp_get_theme();
$ver_num = 2.1;
wp_enqueue_style( 'google-font-roboto', 'https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;0,900;1,400;1,500;1,700;1,900&display=swap',array(), $ver_num );
wp_enqueue_style( 'google-font-poppins', 'https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap',array(), $ver_num );
if ( is_rtl() ) {
wp_enqueue_style('bootstrap-rtl', get_template_directory_uri() . '/assets/css/bootstrap.rtl.min.css', array(), '5.3.3');
} else {
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), '5.3.3');
}
wp_enqueue_style( 'tagsinput', get_template_directory_uri().'/assets/css/bootstrap-tagsinput.css',array(), $ver_num );
wp_enqueue_style( 'meanmenu', get_template_directory_uri().'/assets/css/meanmenu.css',array(), $ver_num );
wp_enqueue_style( 'truelysellanimate', get_template_directory_uri().'/assets/css/animate.css',array(), $ver_num );
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/plugins/fontawesome/css/fontawesome.min.css',array(), $ver_num );
wp_enqueue_style( 'allmin', get_template_directory_uri().'/assets/plugins/fontawesome/css/all.min.css',array(), $ver_num );
wp_enqueue_style( 'feather', get_template_directory_uri().'/assets/css/feather.css',array(), $ver_num );
wp_enqueue_style( 'tabler-icons', get_template_directory_uri().'/assets/plugins/tabler-icons/tabler-icons.css',array(), $ver_num );
wp_enqueue_style( 'select2', get_template_directory_uri().'/assets/plugins/select2/css/select2.min.css',array(), $ver_num );
wp_enqueue_style( 'owl-carousel', trailingslashit(get_template_directory_uri()).'/assets/css/owl.carousel.min.css',array(), $ver_num );
wp_enqueue_style( 'aos', get_template_directory_uri().'/assets/plugins/aos/aos.css',array(), $ver_num );
wp_enqueue_style( 'bootstrap-datetimepicker', get_template_directory_uri().'/assets/css/bootstrap-datetimepicker.min.css',array(), $ver_num );
wp_enqueue_style( 'truelysell-fancybox', trailingslashit(get_template_directory_uri()).'/assets/plugins/fancybox/jquery.fancybox.min.css',array(), $ver_num );
wp_enqueue_style( 'datatables', get_template_directory_uri().'/assets/plugins/datatables/datatables.min.css',array(), $ver_num );
wp_enqueue_style( 'fullcalendar', get_template_directory_uri().'/assets/plugins/fullcalendar/main.min.css',array(), $ver_num );
wp_enqueue_style( 'fullcalendar-bootstrap', get_template_directory_uri().'/assets/plugins/fullcalendar/bootstrap-icons.css',array(), $ver_num );
wp_enqueue_style( 'truelysell-default', get_template_directory_uri().'/assets/css/default-css.css',array(), $ver_num );
wp_enqueue_style( 'truelysell-woocommerce', get_template_directory_uri().'/assets/css/theme-woocommerce.css',array(), $ver_num );
wp_enqueue_style( 'truelysell-main', get_template_directory_uri().'/assets/css/style.css',array(), $ver_num );
wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,1&display=swap', false);
wp_enqueue_style( 'truelysell-mainnew', get_template_directory_uri().'/assets/css/style-new.css',array(), $ver_num );
wp_enqueue_style( 'truelysell-responsive', get_template_directory_uri().'/assets/css/responsive.css',array(), $ver_num );
//3rd party js
wp_enqueue_script('bootstrap-bundle', trailingslashit(get_template_directory_uri()) . '/assets/js/bootstrap.bundle.min.js', false, false, true);
wp_enqueue_script('slimscroll', trailingslashit(get_template_directory_uri()) . '/assets/js/jquery.slimscroll.min.js', false, false, true);
wp_enqueue_script('tagsinput', trailingslashit(get_template_directory_uri()) . '/assets/js/bootstrap-tagsinput.js', false, false, true);
wp_enqueue_script('truelysellwow', trailingslashit(get_template_directory_uri()) . 'assets/js/wow.min.js', false, false, true);
wp_enqueue_script('owl-carousel', trailingslashit(get_template_directory_uri()) . '/assets/js/owl.carousel.min.js', false, false, true);
wp_enqueue_script('aos', trailingslashit(get_template_directory_uri()) . '/assets/plugins/aos/aos.js', false, false, true);
wp_enqueue_script('backToTopjs', trailingslashit(get_template_directory_uri()) . '/assets/js/backToTop.js', false, false, true);
wp_enqueue_script('select2', trailingslashit(get_template_directory_uri()) . '/assets/plugins/select2/js/select2.min.js', false, false, true);
wp_enqueue_script('meanmenu', trailingslashit(get_template_directory_uri()) . '/assets/js/jquery.meanmenu.min.js', false, false, true);
wp_enqueue_script('fullcalendar', trailingslashit(get_template_directory_uri()) . '/assets/plugins/fullcalendar/main.min.js', false, false, true);
//wp_enqueue_script('fullcalendar_global', trailingslashit(get_template_directory_uri()) . '/assets/plugins/fullcalendar/index.global.min.js', array('jquery'),null,true);
wp_enqueue_script('bootstrap-datetimepicker', trailingslashit(get_template_directory_uri()) . '/assets/js/bootstrap-datetimepicker.min.js', false, false, true);
wp_enqueue_script('resizesensor', trailingslashit(get_template_directory_uri()) . '/assets/plugins/theia-sticky-sidebar/ResizeSensor.js', false, false, true);
wp_enqueue_script('theia-sticky-sidebar', trailingslashit(get_template_directory_uri()) . '/assets/plugins/theia-sticky-sidebar/theia-sticky-sidebar.js', false, false, true);
wp_enqueue_script('jquery-fancybox', trailingslashit(get_template_directory_uri()) . '/assets/plugins/fancybox/jquery.fancybox.min.js', false, false, true);
wp_enqueue_script('jquery-dataTables', trailingslashit(get_template_directory_uri()) . '/assets/plugins/datatables/jquery.dataTables.min.js', false, false, true);
wp_enqueue_script('datatables', trailingslashit(get_template_directory_uri()) . '/assets/plugins/datatables/datatables.min.js', false, false, true);
if ( is_rtl() ) {
wp_enqueue_script('truelysell-script-rtl', get_template_directory_uri() . '/assets/js/script-rtl.js', array('jquery'), $ver_num, true);
wp_enqueue_style( 'truelysell-style-rtl', get_template_directory_uri().'/assets/css/style-rtl.css',array(), $ver_num );
} else {
wp_enqueue_script('truelysell-script', trailingslashit(get_template_directory_uri()) . '/assets/js/script.js', false, false, true);
}
$enable_staff_module = truelysell_fl_framework_getoptions('enable_staff_module');
wp_localize_script('truelysell-script', 'truelysell_scr', array(
'ajaxurl' => admin_url('admin-ajax.php'),
// 'post_id' => $post_id,
'enable_staff_module' => $enable_staff_module,
));
if(get_option('truelysell_iconsmind')!='hide'){
wp_enqueue_style( 'truelysell-iconsmind');
}
wp_register_script( 'chosen', get_template_directory_uri() . '/assets/js/chosen.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'select2', get_template_directory_uri() . '/assets/plugins/select2/js/select2.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'counterup', get_template_directory_uri() . '/assets/js/counterup.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'counterupj', get_template_directory_uri() . '/assets/js/jquery.counterup.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'jquery-scrollto', get_template_directory_uri() . '/assets/js/jquery.scrollto.js', array( 'jquery' ), $ver_num );
wp_register_script( 'datedropper', get_template_directory_uri() . '/assets/js/datedropper.js', array( 'jquery' ), $ver_num );
wp_register_script( 'dropzone', get_template_directory_uri() . '/assets/js/dropzone.js', array( 'jquery' ), $ver_num );
wp_register_script( 'isotope', get_template_directory_uri() . '/assets/js/isotope.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'jquery-countdown', get_template_directory_uri() . '/assets/js/jquery.countdown.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'quantitybuttons', get_template_directory_uri() . '/assets/js/quantityButtons.js', array( 'jquery' ), $ver_num );
wp_register_script( 'rangeslider', get_template_directory_uri() . '/assets/js/rangeslider.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'timedropper', get_template_directory_uri() . '/assets/js/timedropper.js', array( 'jquery' ), $ver_num );
wp_register_script( 'tooltips', get_template_directory_uri() . '/assets/js/tooltips.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'waypoints', get_template_directory_uri() . '/assets/js/waypoints.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'slick', get_template_directory_uri() . '/assets/js/slick.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'mmenu', get_template_directory_uri() . '/assets/js/mmenu.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'moment', get_template_directory_uri() . '/assets/js/moment.min.js', array( 'jquery' ), $ver_num );
wp_register_script( 'daterangepicker', get_template_directory_uri() . '/assets/js/daterangepicker.js', array( 'jquery','moment' ), $ver_num );
wp_register_script( 'flatpickr', get_template_directory_uri() . '/assets/js/flatpickr.js', array( 'jquery' ), $ver_num );
wp_register_script( 'bootstrap-slider', get_template_directory_uri() . '/assets/js/bootstrap-slider.min.js', array( 'jquery' ), $ver_num );
wp_enqueue_script( 'select2' );
wp_enqueue_script( 'counterup' );
wp_enqueue_script( 'counterupj' );
wp_enqueue_script( 'datedropper' );
wp_enqueue_script( 'dropzone' );
if ( is_page_template( 'template-comming-soon.php' ) ) {
wp_enqueue_script( 'jquery-countdown' );
}
wp_enqueue_script( 'mmenu' );
wp_enqueue_script( 'slick' );
wp_enqueue_script( 'quantitybuttons' );
wp_enqueue_script( 'rangeslider' );
wp_enqueue_script( 'timedropper' );
wp_enqueue_script( 'jquery-scrollto' );
wp_enqueue_script( 'waypoints' );
wp_enqueue_script( 'tooltips' );
wp_enqueue_script( 'moment' );
wp_enqueue_script( 'daterangepicker' );
wp_enqueue_script( 'bootstrap-slider' );
wp_enqueue_script( 'flatpickr' );
wp_enqueue_script( 'truelysell-themescript');
wp_enqueue_script( 'truelysell-custom', get_template_directory_uri() . '/assets/js/custom.js', array('jquery'), '20170821', true );
$convertedData = truelysell_get_datetime_wp_format();
// add converented format date to javascript
wp_localize_script( 'truelysell-custom', 'wordpress_date_format', $convertedData );
$ajax_url = admin_url( 'admin-ajax.php', 'relative' );
wp_localize_script( 'truelysell-custom', 'truelysell',
array(
'ajaxurl' => $ajax_url,
'theme_url' => get_template_directory_uri(),
)
);
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'truelysell_scripts' );
add_action( 'admin_enqueue_scripts', 'truelysell_admin_scripts' );
function truelysell_admin_scripts($hook){
if($hook=='edit-tags.php' || $hook == 'term.php'|| $hook == 'post.php' || $hook == 'toplevel_page_truelysell_settings' || $hook = 'truelysell-core_page_truelysell_license'){
wp_enqueue_style( 'truelysell-icons', get_template_directory_uri(). '/assets/css/all.css' );
wp_enqueue_style( 'truelysell-icons-fav4', get_template_directory_uri(). '/assets/css/fav4-shims.min.css' );
}
}
function truelysell_add_editor_styles() {
add_editor_style( 'custom-editor-style.css' );
}
add_action( 'admin_init', 'truelysell_add_editor_styles' );
require get_template_directory() . '/inc/shop-func.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/theme-addon.php';
/**
* Custom meta-boxes
*/
require get_template_directory() . '/inc/add-demo-metaboxes.php';
/**
* Customizer additions.
*/
////require get_template_directory() . '/inc/theme-options.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
function truelysell_add_apple_google_pay()
{
return array(
'simple',
'variable',
'variation',
'subscription',
'variable-subscription',
'subscription_variation',
'listing_booking',
'listing_package_subscription',
'booking',
'bundle',
'composite'
);
}
add_filter('wc_stripe_payment_request_supported_types', 'truelysell_add_apple_google_pay');
/**
* Load TGMPA file.
*/
require get_template_directory() . '/inc/tgmpa.php';
/**
* Load woocommerce
*/
require get_template_directory() . '/inc/woocommerce.php';
/**
* Setup Wizard
*/
// Enable shortcodes in text widgets
add_filter('widget_text','do_shortcode');
function truelysell_new_customer_data($new_customer_data){
$new_customer_data['role'] = 'owner';
return $new_customer_data;
}
add_filter( 'woocommerce_new_customer_data', 'truelysell_new_customer_data');
function truelysell_noindex_for_products()
{
if ( is_singular( 'product' ) ) {
global $post;
if( function_exists('wc_get_product') ){
$product = wc_get_product( $post->ID );
//listing_booking, listing_package_subscription, listing_package
if( $product->is_type( 'listing_booking' ) || $product->is_type( 'listing_package_subscription' ) || $product->is_type( 'listing_package' ) ){
echo '<meta name="robots" content="noindex, follow">';
}
}
}
}
add_action('wp_head', 'truelysell_noindex_for_products');
function truelysell_header_menu() {
register_nav_menu('header_menu',esc_html( 'Header Menu' ));
}
add_action( 'init', 'truelysell_header_menu' );
function truelysell_category_pagination() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="pagination"><ul>' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li class="arrow pagination_arrow">%s</li>' . "\n", get_previous_posts_link( __( '<i class="fas fa-angle-left"></i>', 'truelysell' ) ) );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="arrow pagination_arrow">%s</li>' . "\n", get_next_posts_link( __( '<i class="fas fa-angle-right"></i>', 'truelysell' ) ) );
echo '</ul></div>' . "\n";
}
function truelysell_blog_pagination_search() {
if( is_singular() )
return;
if (isset($_GET['s']) && $_GET['s'] != "")
{
$list_s = $_GET['s'];
}
$args_search = array('post_type' => 'post','s'=>$list_s);
$wp_query_search = new WP_Query($args_search);
/** Stop execution if there's only 1 page */
if( $wp_query_search->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query_search->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="blog-pagination"><nav><ul class="pagination justify-content-center">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li class="page-item pagination_arrow">%s</li>' . "\n", get_previous_posts_link( __( '<i class="fas fa-angle-left"></i>', 'truelysell' ) ) );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="page-item active"' : '';
$class_active = 1 == $paged ? ' active' : '';
printf( '<li%s class="page-item"><a href="%s" class="page-link '.$class_active.'" >%s</a></li>' . "\n", $class_active, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li class="page-item dots-page-item"><span href="#" class="page-link dots" >…</span></li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="page-item active "' : '';
$class_active = $paged == $link ? ' active' : '';
printf( '<li%s class="page-item"><a href="%s" class="page-link '.$class_active.'">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li class="page-item dots-page-item"><span href="#" class="page-link dots" >…</span></li>' . "\n";
$class = $paged == $max ? ' class="page-item active"' : '';
printf( '<li%s class="page-item"><a class="page-link" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="page-item pagination_arrow">%s</li>' . "\n", get_next_posts_link( __( '<i class="fas fa-angle-right"></i>', 'truelysell' ) ) );
echo '</ul></nav></div>' . "\n";
}
function truelysell_blog_pagination() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="blog-pagination"><nav><ul class="pagination justify-content-center">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li class="page-item pagination_arrow">%s</li>' . "\n", get_previous_posts_link( __( '<i class="fas fa-angle-left"></i>', 'truelysell' ) ) );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="page-item active"' : '';
$class_active = 1 == $paged ? ' active' : '';
printf( '<li%s class="page-item"><a href="%s" class="page-link '.$class_active.'" >%s</a></li>' . "\n", $class_active, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li class="page-item dots-page-item"><span href="#" class="page-link dots" >…</span></li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="page-item active "' : '';
$class_active = $paged == $link ? ' active' : '';
printf( '<li%s class="page-item"><a href="%s" class="page-link '.$class_active.'">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li class="page-item dots-page-item"><span href="#" class="page-link dots" >…</span></li>' . "\n";
$class = $paged == $max ? ' class="page-item active"' : '';
printf( '<li%s class="page-item"><a class="page-link" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="page-item pagination_arrow">%s</li>' . "\n", get_next_posts_link( __( '<i class="fas fa-angle-right"></i>', 'truelysell' ) ) );
echo '</ul></nav></div>' . "\n";
}
add_filter( 'woocommerce_should_load_paypal_standard', '__return_true' );
// add_filter('woocommerce_payment_gateways', 'add_custom_payment_gateway');
// function add_custom_payment_gateway($gateways) {
// // Ensure PayPal Standard is included in the gateways
// if (!in_array('paypal', $gateways)) {
// $gateways[] = 'paypal'; // or your custom payment class
// }
// return $gateways;
// }
add_theme_support( 'woocommerce' );
function truelysell_cat_count_span( $links ) {
// $links = str_replace( '</a> (', '</a><span class="post-count">(', $links );
// $links = str_replace( ')', ')</span>', $links );
return $links;
}
add_filter( 'wp_list_categories', 'truelysell_cat_count_span' );
/**
* Filter the archives widget to add a span around post count
*/
function truelysell_archive_count_span( $links ) {
$links = str_replace( '</a> (', '</a><span class="post-count">(', $links );
$links = str_replace( ')', ')</span>', $links );
return $links;
}
add_filter( 'get_archives_link', 'truelysell_archive_count_span' );
function truelysell_searchfilter($query) {
if ($query->is_search && is_page_template('search.php')) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','truelysell_searchfilter');
add_filter('wpcf7_autop_or_not', '__return_false');
function truelysell_hex2RGB($hex)
{
preg_match("/^#{0,1}([0-9a-f]{1,6})$/i",$hex,$match);
if(!isset($match[1]))
{
return false;
}
if(strlen($match[1]) == 6)
{
list($r, $g, $b) = array($hex[0].$hex[1],$hex[2].$hex[3],$hex[4].$hex[5]);
}
elseif(strlen($match[1]) == 3)
{
list($r, $g, $b) = array($hex[0].$hex[0],$hex[1].$hex[1],$hex[2].$hex[2]);
}
else if(strlen($match[1]) == 2)
{
list($r, $g, $b) = array($hex[0].$hex[1],$hex[0].$hex[1],$hex[0].$hex[1]);
}
else if(strlen($match[1]) == 1)
{
list($r, $g, $b) = array($hex.$hex,$hex.$hex,$hex.$hex);
}
else
{
return false;
}
$color = array();
$color['r'] = hexdec($r);
$color['g'] = hexdec($g);
$color['b'] = hexdec($b);
return $color;
}
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function truelysell_theme_options_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
}
add_action( 'customize_register', 'truelysell_theme_options_register' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function truelysell_js_customize() {
wp_enqueue_script( 'truelysell_customizer', get_template_directory_uri() . 'assets/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'truelysell_js_customize' );
function theme_customize_register( $wp_customize ) {
$wp_customize->add_section( 'mytheme_new_section_name' , array(
'title' => __( 'Visible Section Name', 'truelysell' ),
'priority' => 30,
) );
// Text color
$wp_customize->add_setting( 'primary_color', array(
'default' => '#4c40ed',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_color', array(
'section' => 'colors',
'label' => esc_html__( 'Primary color', 'truelysell' ),
'show_opacity' => true,
) ) );
// Text color
$wp_customize->add_setting( 'secondarybg_color', array(
'default' => '#111827',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'secondarybg_color', array(
'section' => 'colors',
'label' => esc_html__( 'Secondary Background color', 'truelysell' ),
'show_opacity' => true,
) ) );
// Text color
$wp_customize->add_setting( 'primary_hover_color', array(
'default' => '#2229C1',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_hover_color', array(
'section' => 'colors',
'label' => esc_html__( 'Primary Hover color', 'truelysell' ),
'show_opacity' => true,
) ) );
// Gradient 'From' Color
$wp_customize->add_setting( 'gradient_from_color', array(
'default' => '#FD2692', // Default 'From' color
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'gradient_from_color', array(
'section' => 'colors',
'label' => esc_html__( 'Gradient From Color', 'truelysell' ),
) ) );
// Gradient 'To' Color
$wp_customize->add_setting( 'gradient_to_color', array(
'default' => '#0A67F2', // Default 'To' color
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'gradient_to_color', array(
'section' => 'colors',
'label' => esc_html__( 'Gradient To Color', 'truelysell' ),
) ) );
// Text color
$wp_customize->add_setting( 'secondary_color', array(
'default' => '#F7F7FF',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'secondary_color', array(
'section' => 'colors',
'label' => esc_html__( 'Secondary color', 'truelysell' ),
) ) );
// Text color
$wp_customize->add_setting( 'breadcrumb_color', array(
'default' => '#F7F7FF',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'breadcrumb_color', array(
'section' => 'colors',
'label' => esc_html__( 'Breadcrumb color', 'truelysell' ),
) ) );
// Text color
$wp_customize->add_setting( 'text_color', array(
'default' => '#74788D',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'text_color', array(
'section' => 'colors',
'label' => esc_html__( 'Text color', 'truelysell' ),
) ) );
// Link color
$wp_customize->add_setting( 'link_color', array(
'default' => '#4c40ed',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
'section' => 'colors',
'label' => esc_html__( 'Link color', 'truelysell' ),
) ) );
// Border color
$wp_customize->add_setting( 'heading_color', array(
'default' => '#28283C',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'heading_color', array(
'section' => 'colors',
'label' => esc_html__( 'Heading color', 'truelysell' ),
) ) );
// Sidebar background
$wp_customize->add_setting( 'sidebar_background', array(
'default' => '#F7F7FF',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sidebar_background', array(
'section' => 'colors',
'label' => esc_html__( 'Sidebar Background', 'truelysell' ),
) ) );
}
add_action( 'customize_register', 'theme_customize_register' );
function theme_get_customizer_css() {
ob_start();
$primary_color = get_theme_mod( 'primary_color', '#4C40ED' );
if ( ! empty( $primary_color ) ) {
?>
:root {
--ts_primary_color: <?php echo esc_html($primary_color); ?>;
--ts_primary_trans_color: <?php echo esc_html($primary_color); ?>99;
--ts_primary_trans20_color: <?php echo esc_html($primary_color); ?>20;
}
<?php
}
$secondarybg_color = get_theme_mod( 'secondarybg_color', '#111827' );
if ( ! empty( $secondarybg_color ) ) {
?>
:root {
--ts_secondarybg_color: <?php echo esc_html($secondarybg_color); ?>;
}
<?php
}
$primary_hover_color = get_theme_mod( 'primary_hover_color', '#2229C1' );
if ( ! empty( $primary_hover_color ) ) {
?>
:root {
--ts_primary_hover_color: <?php echo esc_html($primary_hover_color); ?>;
}
<?php
}
$gradient_from_color = get_theme_mod( 'gradient_from_color', '#FD2692' );
if ( ! empty( $gradient_from_color ) ) {
?>
:root {
--ts_gradient_from_color: <?php echo esc_html($gradient_from_color); ?>;
}
<?php
}
$gradient_to_color = get_theme_mod( 'gradient_to_color', '#0A67F2' );
if ( ! empty( $gradient_to_color ) ) {
?>
:root {
--ts_gradient_to_color: <?php echo esc_html($gradient_to_color); ?>;
}
<?php
}
$secondary_color = get_theme_mod( 'secondary_color', '#F7F7FF' );
if ( ! empty( $secondary_color ) ) {
?>
:root {
--ts_secondary_color: <?php echo esc_html($secondary_color); ?>;
}
<?php
}
$breadcrumb_color = get_theme_mod( 'breadcrumb_color', '#F7F7FF' );
if ( ! empty( $breadcrumb_color ) ) {
?>
:root {
--ts_breadcrumb_color: <?php echo esc_html($breadcrumb_color); ?>;
}
<?php
}
$text_color = get_theme_mod( 'text_color', '#74788D' );
if ( ! empty( $text_color ) ) {
?>
:root {
--ts_text_color: <?php echo esc_html($text_color); ?>;
}
<?php
}
$link_color = get_theme_mod( 'link_color', '#4C40ED' );
if ( ! empty( $link_color ) ) {
?>
:root {
--ts_link_color: <?php echo esc_html($link_color); ?>;
}
<?php
}
$heading_color = get_theme_mod( 'heading_color', '#28283c' );
if ( ! empty( $heading_color ) ) {
?>
:root {
--ts_heading_color: <?php echo esc_html($heading_color); ?>;
}
<?php
}
$sidebar_background = get_theme_mod( 'sidebar_background', '#F7F7FF' );
if ( ! empty( $sidebar_background ) ) {
?>
:root {
--ts_sidebar_bgcolor: <?php echo esc_html($sidebar_background); ?>;
}
<?php
}
$css = ob_get_clean();
return $css;
}
// Modify our styles registration like so:
function theme_enqueue_styles() {
wp_enqueue_style( 'theme-styles', get_stylesheet_uri() ); // This is where you enqueue your theme's main stylesheet
$custom_css = theme_get_customizer_css();
wp_add_inline_style( 'theme-styles', $custom_css );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
add_action( 'category_add_form_fields', 'category_add_form_fields_callback' );
function category_add_form_fields_callback() {
$image_id = null;
?>
<div id="category_custom_image"></div>
<input
type="hidden"
id="category_custom_image_url"
name="category_custom_image_url">
<div style="margin-bottom: 20px;">
<span>Category Image </span>
<a href="#"
class="button custom-button-upload"
id="custom-button-upload">Upload image</a>
<a href="#"
class="button custom-button-remove"
id="custom-button-remove"
style="display: none">Remove image</a>
</div>
<?php
}
/*** user can register auto ***/
add_action('init', 'truelysell_update_can_register');
function truelysell_update_can_register() {
update_option('users_can_register', true);
}
/*** user can register auto ***/
/*** OCDI ***/
require_once get_template_directory(). '/inc/truelysell-demo-content.php';
function remove_ocdi_about_notice() {
echo '<style type="text/css">
.ocdi__theme-about {display: none}
</style>';
}
add_action('admin_head', 'remove_ocdi_about_notice');
/*** OCDI ***/
if( !function_exists('truelysell_fl_framework_getoptions') )
{
function truelysell_fl_framework_getoptions($get_text)
{
global $truelysell_theme_options;
if(isset($truelysell_theme_options[$get_text]) && $truelysell_theme_options[$get_text] !=""):
return $truelysell_theme_options[$get_text];
else:
return false;
endif;
}
}
function enqueue_search_script() {
wp_enqueue_script('search-script', get_template_directory_uri() . '/assets/js/autocomplete.js', array('jquery'), null, true);
}
add_action('wp_enqueue_scripts', 'enqueue_search_script');
function dynamic_search_handler() {
// Sanitize input
$query = sanitize_text_field($_POST['query']);
// Define search arguments
$args = array(
'post_type' => 'listing',
's' => $query,
'posts_per_page' => 10,
);
// Perform the search query
$search_query = new WP_Query($args);
// Display results
if ($search_query->have_posts()) {
echo '<ul>';
while ($search_query->have_posts()) {
$search_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
echo '<ul>';
echo '<li>No results found</li>';
echo '</ul>';
}
// Reset post data and terminate the request
wp_reset_postdata();
wp_die();
}
add_action('wp_ajax_dynamic_search', 'dynamic_search_handler');
add_action('wp_ajax_nopriv_dynamic_search', 'dynamic_search_handler');
add_action('wp_ajax_dynamic_search', 'dynamic_search_handler');
add_action('wp_ajax_nopriv_dynamic_search', 'dynamic_search_handler');
function custom_search_rewrite_rule() {
add_rewrite_rule('provider-list/([^/]+)/?', 'index.php?pagename=provider-list&s=$matches[1]', 'top');
}
add_action('init', 'custom_search_rewrite_rule');
function enqueue_user_management_scripts() {
// Enqueue your script (replace 'your-script-handle' with your script handle)
wp_enqueue_script('user-management', get_template_directory_uri() . '/assets/js/staff-remove.js', ['jquery'], null, true);
// Pass the AJAX URL and nonce to the script
wp_localize_script('user-management', 'ajax_object', [
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('delete_controlled_user_nonce'),
]);
}
add_action('wp_enqueue_scripts', 'enqueue_user_management_scripts');
add_action('wp_ajax_delete_controlled_user', 'delete_controlled_user');
function delete_controlled_user() {
// Check user permissions
if (!is_user_logged_in()) {
wp_send_json_error(['message' => 'You must be logged in to perform this action.']);
}
$current_user_id = get_current_user_id();
$current_user = wp_get_current_user();
// Get the user ID to delete from the request
$user_id_to_delete = isset($_POST['user_id']) ? intval($_POST['user_id']) : 0;
if (!$user_id_to_delete) {
wp_send_json_error(['message' => 'Invalid user ID.']);
}
// Check if the user has permission to delete
// Allow users with the 'register owner' role to delete users
if (in_array('register_owner', (array) $current_user->roles)) {
// Proceed with deletion
} else {
// Check if the user ID is under the current user's control
$parent_id = get_user_meta($user_id_to_delete, 'parent_id', true);
if ($parent_id != $current_user_id) {
wp_send_json_error(['message' => 'You do not have permission to delete this user.']);
}
}
// Delete the user
$deleted = wp_delete_user($user_id_to_delete);
if ($deleted) {
wp_send_json_success(['message' => 'User deleted successfully.']);
} else {
wp_send_json_error(['message' => 'Failed to delete the user.']);
}
wp_die();
}
add_action('wp_ajax_get_available_staff', 'get_available_staff');
add_action('wp_ajax_nopriv_get_available_staff', 'get_available_staff');
function get_available_staff() {
// Check if the required parameters are set
if (!isset($_POST['date']) || !isset($_POST['time']) || !isset($_POST['post_id'])) {
error_log('Invalid parameters: ' . json_encode($_POST)); // Log the invalid parameters
wp_send_json_error('Invalid parameters');
return;
}
$date = sanitize_text_field($_POST['date']);
$time = sanitize_text_field($_POST['time']);
$post_id = intval($_POST['post_id']);
// Split the time into start and end
$time_parts = explode(" - ", $time);
if (count($time_parts) !== 2) {
error_log('Invalid time format: ' . $time); // Log the invalid time format
wp_send_json_error('Invalid time format');
return;
}
$start_time = $time_parts[0];
$end_time = $time_parts[1];
// Combine date and time to create full datetime strings
$date_start = $date . ' ' . $start_time;
$date_end = $date . ' ' . $end_time;
// Get all staff IDs from post meta
$staff_ids_serialized = get_post_meta($post_id, '_staffs_id', true);
if (is_serialized($staff_ids_serialized)) {
$staff_ids = unserialize($staff_ids_serialized);
} else {
error_log('Invalid staff IDs format for post ID ' . $post_id); // Log the invalid staff IDs format
wp_send_json_error('Invalid staff IDs format');
return;
}
// Query the bookings table to find booked staff for the selected date and time
global $wpdb;
$booked_staff_ids = $wpdb->get_col($wpdb->prepare(
"SELECT staff_id FROM {$wpdb->prefix}bookings_calendar
WHERE (date_start < %s AND date_end > %s) OR
(date_start < %s AND date_end > %s) OR
(date_start >= %s AND date_end <= %s)",
$date_end, $date_start,
$date_end, $date_start,
$date_start, $date_end
));
// Log the booked staff IDs
error_log('Booked staff IDs: ' . implode(', ', $booked_staff_ids));
// Filter out booked staff IDs
$available_staff_ids = array_diff($staff_ids, $booked_staff_ids);
// Prepare the response
$available_staff = [];
foreach ($available_staff_ids as $staff_id) {
$user = get_userdata($staff_id);
if ($user) {
$available_staff[] = [
'id' => $staff_id,
'name' => trim($user->first_name . ' ' . $user->last_name),
];
}
}
// Log the available staff IDs
error_log('Available staff IDs: ' . implode(', ', array_column($available_staff, 'id')));
// If no staff is available, return an error message
if (empty($available_staff)) {
error_log('No available staff for the selected date and time: ' . $date . ' ' . $time); // Log the error
wp_send_json_error('No available staff for the selected date and time.');
}
wp_send_json_success($available_staff);
}
add_filter( 'site_status_tests', function( $tests ) {
unset( $tests['direct']['persistent_object_cache'] );
return $tests;
});
add_filter( 'site_status_tests', function( $tests ) {
unset( $tests['async']['background_updates'] );
return $tests;
});
add_filter( 'site_status_tests', function( $tests ) {
// Remove WooCommerce Action Scheduler late cron check
if ( isset( $tests['async']['action_scheduler_queue_runner'] ) ) {
unset( $tests['async']['action_scheduler_queue_runner'] );
}
return $tests;
}, 20 );