芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/wp-content/themes/dexolix/functions.php
tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support('title-tag'); /* * 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'); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'menu-1' => esc_html__('Main Menu', 'dexolix'), ) ); /* * 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', 'style', 'script', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'dexolix_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for selective refresh for widgets. add_theme_support('customize-selective-refresh-widgets'); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ add_theme_support( 'custom-logo', array( 'height' => 250, 'width' => 250, 'flex-width' => true, 'flex-height' => true, ) ); // Default Blog Style add image size add_image_size('dexolix-default-blog-thumbnail', 882, 397, true); add_image_size('dexolix-default-blog-single-thumbnail', 1920, 760, true); // Dexolix Custom Image Size add_image_size('dexolix-blog-archive-thumbnail', 640, 448, true); add_image_size('dexolix-blog-single-thumbnail', 1172, 662, true); } add_action('after_setup_theme', 'dexolix_setup'); add_filter('woocommerce_get_image_size_gallery_thumbnail', function ($size) { return array( 'width' => 150, // Adjust to your desired width 'height' => 170, // Adjust to your desired height 'crop' => 1, ); }, 999); /** * 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 dexolix_content_width() { $GLOBALS['content_width'] = apply_filters('dexolix_content_width', 640); } add_action('after_setup_theme', 'dexolix_content_width', 0); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function dexolix_widgets_init() { register_sidebar( array( 'name' => esc_html__('Sidebar', 'dexolix'), 'id' => 'sidebar-1', 'description' => esc_html__('Add widgets here.', 'dexolix'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '
', 'after_title' => '
', ) ); register_sidebar( array( 'name' => esc_html__('Product Archive Sidebar', 'dexolix'), 'id' => 'product_archive', 'description' => esc_html__('Add widgets here.', 'dexolix'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '
', 'after_title' => '
', ) ); } add_action('widgets_init', 'dexolix_widgets_init'); /** * Enqueue scripts and styles. */ function dexolix_scripts() { // Theme Default CSS AND JS wp_enqueue_style('bootstrap-min', DEXOLIX_URL . '/assets/css/theme-default-css/bootstrap.min.css', array(), _S_VERSION); wp_enqueue_style('fontawesome', DEXOLIX_URL . '/assets/css/theme-default-css/all.min.css', array(), _S_VERSION); wp_enqueue_style('lity-min-css', DEXOLIX_URL . '/assets/css/theme-default-css/lity.min.css', array(), _S_VERSION); wp_enqueue_style('dexolix-style', get_stylesheet_uri(), array(), _S_VERSION); wp_style_add_data('dexolix-style-rtl', 'rtl', 'replace'); wp_enqueue_style('theme-default-style', DEXOLIX_URL . '/assets/css/theme-default-css/theme-default-style.css', array(), _S_VERSION); wp_enqueue_style('iconsax-icons', DEXOLIX_URL . '/assets/css/theme-default-css/iconsax-icons.css', array(), _S_VERSION); wp_enqueue_script('dexolix-navigation', DEXOLIX_URL . '/js/navigation.js', array(), _S_VERSION, true); wp_enqueue_script('bootstrap-bundle-min', DEXOLIX_URL . '/assets/js/theme-default-js/bootstrap.bundle.min.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('lity-min-js', DEXOLIX_URL . '/assets/js/theme-default-js/lity.min.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('theme-default-script', DEXOLIX_URL . '/assets/js/theme-default-js/theme-default.js', array("jquery"), _S_VERSION, true); $ajax_url = admin_url('admin-ajax.php', 'relative'); $main_values = array(); $woo_msg = esc_attr__('You have added the item to your shopping cart!', 'dexolix'); $main_values['dataAddCartMsg'] = $woo_msg; $script_params = array( 'ajax_url' => $ajax_url ); if (class_exists('WooCommerce')) { wp_enqueue_style('dexolix-flickity', DEXOLIX_URL . '/assets/css/theme-default-css/flickity.css', false, _S_VERSION, 'all'); wp_enqueue_script('dexolix-flickity', DEXOLIX_URL . '/assets/js/theme-default-js/flickity.pkgd.min.js', array(), _S_VERSION, true); if (!wp_script_is('wc-cart-fragments', 'enqueued') && wp_script_is('wc-cart-fragments', 'registered')) { // Enqueue the wc-cart-fragments script wp_enqueue_script('wc-cart-fragments'); } wp_enqueue_script('dexolix-woo', DEXOLIX_URL . '/assets/js/theme-default-js/dexolix-wc.js', array('jquery'), _S_VERSION, true); wp_enqueue_script('dexolix-mini-cart', DEXOLIX_URL . '/assets/js/theme-default-js/dexolix-mini-cart.js', array('jquery'), _S_VERSION, true); wp_localize_script('dexolix-mini-cart', 'dexolix_params', $script_params); wp_localize_script('dexolix-woo', 'dexolix_main_object', $main_values); } // Dexolix Style and JS wp_enqueue_style('dexolix-google-fonts', '//fonts.googleapis.com/css2?family=Anton&family=Antonio:wght@100..700&family=Archivo:ital,wght@0,100..900;1,100..900&family=Instrument+Sans:ital,wght@0,400..700;1,400..700&display=swap', array(), null); wp_enqueue_style('iconly.min', DEXOLIX_URL . '/assets/css/iconly.min.css', array(), _S_VERSION); wp_enqueue_style('swiper', DEXOLIX_URL . '/assets/css/swiper-slider.css', array(), _S_VERSION); wp_enqueue_style('aos.min', DEXOLIX_URL . '/assets/css/aos.css', array(), _S_VERSION); wp_enqueue_style('jquery-accordion-menu', DEXOLIX_URL . '/assets/css/jquery-accordion-menu.css', array(), _S_VERSION); wp_enqueue_style('style', DEXOLIX_URL . '/assets/css/style.css', array(), _S_VERSION); wp_enqueue_style('responsive', DEXOLIX_URL . '/assets/css/responsive.css', array(), _S_VERSION); wp_enqueue_script('swiper', DEXOLIX_URL . '/assets/js/swiper.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('aos', DEXOLIX_URL . '/assets/js/aos.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('gsap.min', DEXOLIX_URL . '/assets/js/gsap.min.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('ScrollTrigger.min', DEXOLIX_URL . '/assets/js/ScrollTrigger.min.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('jquery-accordion-menu', DEXOLIX_URL . '/assets/js/jquery-accordion-menu.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('counterUp2', DEXOLIX_URL . '/assets/js/counterup2.js', array("jquery"), _S_VERSION, true); wp_enqueue_script('custom-script-file', DEXOLIX_URL . '/assets/js/custom-script-file.js', array("jquery"), _S_VERSION, true); if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } } add_action('wp_enqueue_scripts', 'dexolix_scripts', 90); /** * Enqueue Admin Scripts */ function dexolix_admin_enqueue_scripts() { wp_enqueue_style('theme-admin-style-css', DEXOLIX_URL . '/assets/css/theme-default-css/theme-admin-style.css'); wp_enqueue_style('teconce-wizard-admin-css', DEXOLIX_URL . '/assets/css/theme-default-css/tecon-admin.css'); } add_action('admin_enqueue_scripts', 'dexolix_admin_enqueue_scripts'); /** * Implement the Custom Header feature. */ require get_template_directory() . '/inc/custom-header.php'; /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Functions which enhance the theme by hooking into WordPress. */ require get_template_directory() . '/inc/template-functions.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * Load Jetpack compatibility file. */ if (defined('JETPACK__VERSION')) { require get_template_directory() . '/inc/jetpack.php'; } /** * Load WooCommerce compatibility file. */ if (class_exists('WooCommerce')) { require DEXOLIX_PATH . '/inc/woocommerce.php'; require DEXOLIX_PATH . '/inc/vendor/woo-single-product-structure.php'; } /** * Comment Form Markup */ function custom_comment_form($args) { $args['fields'] = array( 'author' => '
', 'email' => '
', // You can add the URL field here if needed, or remove it: 'url' => '', ); $args['comment_field'] = '
</textarea>
'; $args['submit_button'] = '
Post Comment
'; $args['class_form'] = 'row align-items-center g-4'; $args['class_container'] = 'blog-review-form'; $args['format'] = 'html5'; $args['title_reply'] = 'Add A Review'; return $args; } add_filter('comment_form_defaults', 'custom_comment_form'); function custom_comment_form_order($fields) { // Unset all fields to reset the order $author_field = $fields['author']; // Save author field $email_field = $fields['email']; // Save email field $comment_field = $fields['comment']; // Save comment field unset($fields['author']); unset($fields['email']); unset($fields['comment']); // Reorder fields $fields['author'] = $author_field; $fields['email'] = $email_field; $fields['comment'] = $comment_field; return $fields; } add_filter('comment_form_fields', 'custom_comment_form_order'); /* * Contact Form 7 Auto P remove */ add_filter('wpcf7_autop_or_not', '__return_false'); function tecon_theme_params() { return array( 'name' => 'Dexolix', 'slug' => 'dexolix', ); } /* * Print_r function beautify with proper indent */ if (!function_exists('adiv_pretty_print_with_indent')) { function adiv_pretty_print_with_indent($data): void { // Get the raw print_r output $output = print_r($data, true); // 1. Fix opening bracket to be on same line as "Array" $output = preg_replace('/(Array|[\w]+ Object)\n\s+\(/', '$1 (', $output); // 2. Standardize all indentation to tabs $output = str_replace(' ', "\t", $output); // 3. Align closing brackets vertically $lines = explode("\n", $output); $indent_level = 0; $result = []; foreach ($lines as $line) { // Track indentation level if (preg_match('/^\s*\)/', $line)) { $indent_level--; } // Rebuild line with proper indentation $result[] = str_repeat("\t", max(0, $indent_level)) . trim($line); // Update indentation for next line if (strpos($line, 'Array (') !== false || strpos($line, 'Object (') !== false) { $indent_level++; } } $output = implode("\n", $result); // Style the output echo '
'; echo wp_kses_post($output); echo '
'; } }