Untitled
unknown
plain_text
2 years ago
7.3 kB
7
Indexable
<?php /** * Theme functions and definitions * */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } // if ( ! isset( $content_width ) ) { // $content_width = 800; // pixels // } /* * Set up theme support */ if ( ! function_exists( 'hello_elementor_theme_setup' ) ) { function hello_elementor_theme_setup() { if ( apply_filters( 'hello_elementor_theme_load_textdomain', true ) ) { load_theme_textdomain( 'elementor-hello-theme', get_template_directory() . '/languages' ); } if ( apply_filters( 'hello_elementor_theme_register_menus', true ) ) { register_nav_menus( array( 'menu-1' => __( 'Primary', 'hello-elementor' ) ) ); } if ( apply_filters( 'hello_elementor_theme_add_theme_support', true ) ) { add_theme_support( 'post-thumbnails' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'custom-logo' ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); add_theme_support( 'custom-logo', array( 'height' => 100, 'width' => 350, 'flex-height' => true, 'flex-width' => true, ) ); /* * Editor Style */ add_editor_style( 'editor-style.css' ); /* * WooCommerce */ if ( apply_filters( 'hello_elementor_theme_add_woocommerce_support', true ) ) { // WooCommerce in general: add_theme_support( 'woocommerce' ); // Enabling WooCommerce product gallery features (are off by default since WC 3.0.0): // zoom: add_theme_support( 'wc-product-gallery-zoom' ); // lightbox: add_theme_support( 'wc-product-gallery-lightbox' ); // swipe: add_theme_support( 'wc-product-gallery-slider' ); } } } } add_action( 'after_setup_theme', 'hello_elementor_theme_setup' ); /* * Theme Scripts & Styles */ if ( ! function_exists( 'hello_elementor_theme_scripts_styles' ) ) { function hello_elementor_theme_scripts_styles() { if ( apply_filters( 'hello_elementor_theme_enqueue_style', true ) ) { wp_enqueue_style( 'elementor-hello-theme-style', get_stylesheet_uri() ); } } } add_action( 'wp_enqueue_scripts', 'hello_elementor_theme_scripts_styles' ); /* * Register Elementor Locations */ if ( ! function_exists( 'hello_elementor_theme_register_elementor_locations' ) ) { function hello_elementor_theme_register_elementor_locations( $elementor_theme_manager ) { if ( apply_filters( 'hello_elementor_theme_register_elementor_locations', true ) ) { $elementor_theme_manager->register_all_core_location(); } } } add_action( 'elementor/theme/register_locations', 'hello_elementor_theme_register_elementor_locations' ); add_action('pre_get_posts','custom_query_vars'); function custom_query_vars($query) { $query->set('current_date', date('Y-m-d')); return $query; } /* ALLOW SVG UPLOAD */ function enable_svg_upload( $upload_mimes ) { $upload_mimes['svg'] = 'image/svg+xml'; $upload_mimes['svgz'] = 'image/svg+xml'; return $upload_mimes; } add_filter( 'upload_mimes', 'enable_svg_upload', 10, 1 ); /* DISABLE GUTTENBURG */ add_filter('use_block_editor_for_post', '__return_false', 10); /* DISABLE WP AUTOMATIC IMAGE SCALE */ add_filter( 'big_image_size_threshold', '__return_false' ); // DISABLE DASHICON add_action( 'wp_enqueue_scripts', 'aiooc_crunchify_dequeue_dashicon' ); function aiooc_crunchify_dequeue_dashicon() { if ( current_user_can( 'update_core' ) ) { return; } wp_deregister_style( 'dashicons' ); } /* ADD SEARCH RESULT COUNT */ // function result_count() { // add_filter( 'wpex_post_subheading', function( $subheading ) { // if ( is_search() ) { // global $wp_query; // $posts_per_page = $wp_query->query_vars['posts_per_page']; // $posts_found = $wp_query->found_posts; // if ( $posts_found ) { // $subheading = sprintf( // esc_html__( 'Displaying results 1-%1$s out of %2$s for %3$s', 'total' ), // $posts_per_page, // $posts_found, // get_search_query( false ) // ); // } // } // return $subheading; // var_dump($subheading); // } ); // } // add_shortcode('result_count','result_count'); // function control_search_results($subheading) { // if ( is_search() ) { // global $wp_query; // $posts_per_page = $wp_query->query_vars['posts_per_page']; // $posts_found = $wp_query->found_posts; // if ( $posts_found ) { // $subheading = sprintf( // esc_html__( 'Displaying results 1-%1$s out of %2$s for %3$s', 'total' ), // $posts_per_page, // $posts_found, // get_search_query( false ) // ); // } // } // return $subheading; // } // add_filter('pre_get_posts', 'control_search_results'); // /* ADD SEARCH RESULT COUNT */ function search_result_count() { global $wp_query; $not_singular = $wp_query->found_posts > 1 ? 'results' : 'result'; // if found posts is greater than one echo results(plural) else echo result (singular) echo "Found "; echo $wp_query->found_posts . " $not_singular"; echo ' for "'; the_search_query(); echo '"'; } add_shortcode('result_count', 'search_result_count'); //Scroll Elementor add_action( 'wp_footer', function() { if ( ! defined( 'ELEMENTOR_VERSION' ) ) { return; } ?> <script> window.addEventListener('elementor/frontend/init', function() { elementorFrontend.hooks.addFilter( 'frontend/handlers/menu_anchor/scroll_top_distance', function( scrollTop ) { return scrollTop - 90; } ); } ); </script> <?php } ); //REGISTER SCRIPT function my_theme_enqueue_scripts() { wp_enqueue_style('dashicons'); wp_register_script('jquery', 'https://code.jquery.com/jquery-3.7.0.js', array(), '3.7.0', true); } // Hook the function to the appropriate action add_action('wp_enqueue_scripts', 'my_theme_enqueue_scripts'); //GET EXCERPT function replace_excerpt_with_meta_description($excerpt) { $post_id = get_the_ID(); $meta_wds_metadesc = get_post_meta($post_id, '_wds_metadesc', true); $meta__wds_trimmed_excerpt = get_post_meta($post_id, '_wds_trimmed_excerpt', true); if (empty($meta_wds_metadesc)) { echo $meta__wds_trimmed_excerpt; } else { echo $meta_wds_metadesc; } } add_shortcode('the_excerpt', 'replace_excerpt_with_meta_description'); //READ TIME function count_read_time(){ $post_content = get_the_content(); $content_length = str_word_count( strip_tags( $post_content ) ); $reading_time = ceil( $content_length / 200 ); if($reading_time == 1){ $time = 'Min Read'; } else { $time = 'Mins Read'; } echo $reading_time .' '. $time; } add_shortcode('read_time','count_read_time'); //PLACEHOLDER function custom_elementor_placeholder_image() { return 'https://base.bravefactor.com/wp-content/uploads/2022/11/screenshot.jpg'; } add_filter( 'elementor/utils/get_placeholder_image_src', 'custom_elementor_placeholder_image' ); // CUSTOM ADMIN LOGIN HEADER LOGO function my_custom_login_logo() { echo '<style> .login h1 a { background-image: url(/wp-content/uploads/2022/12/Logo.svg)!important; margin: 0; width: 100%; background-size: contain;} </style>'; } add_action('login_head', 'my_custom_login_logo'); add_filter( 'login_headerurl', 'my_custom_login_url' ); function my_custom_login_url($url) { return get_site_url(); }
Editor is loading...