| Server IP : 178.63.100.251 / Your IP : 216.73.216.228 Web Server : LiteSpeed System : Linux dobby.thevpsserver.com 4.18.0-553.16.1.lve.el8.x86_64 #1 SMP Tue Aug 13 17:45:03 UTC 2024 x86_64 User : truewayi ( 1855) PHP Version : 7.4.33 Disable Function : show_source,system,shell_exec,passthru,exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/truewayi/public_html/wp-content/themes/omexo/inc/ |
Upload File : |
<?php
/**
* Functions which enhance the theme by hooking into WordPress
*
* @package omexo
*/
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function omexo_body_classes( $classes ) {
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
// Adds a class of no-sidebar when there is no sidebar present.
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'no-sidebar';
}
return $classes;
}
add_filter( 'body_class', 'omexo_body_classes' );
/**
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
*/
function omexo_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
}
add_action( 'wp_head', 'omexo_pingback_header' );
if ( ! function_exists( 'wp_body_open' ) ) {
function wp_body_open() {
do_action( 'wp_body_open' );
}
}
/**
* Header array get
*/
if (!function_exists('omexo_array_get')) {
function omexo_array_get($array, $key, $default = null)
{
if (!is_array($array)) {
return $default;
}
return array_key_exists($key, $array) ? $array[$key] : $default;
}
}
/**
* WooCommerce products number per row to 3
*/
if (!function_exists('loop_columns')) {
function omexo_product_per_row() {
return 3; // 3 products per row
}
}
add_filter('loop_shop_columns', 'omexo_product_per_row', 999);
/**
* Change number of products that are displayed per page (shop page)
*/
function new_loop_shop_per_page( $cols ) {
$cols = 9 ;
return $cols;
}
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
/**
* Remove WooCommerce shop page default title
*/
add_filter( 'woocommerce_show_page_title', 'remove_shop_page_title' );
function remove_shop_page_title() {
return boolval(!is_shop());
}
//WooCommerce ajax mini add to cart
function omexo_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
omexo_wc_mini_cart();
$fragments['a.cart-button'] = ob_get_clean();
return $fragments;
}
function omexo_wc_mini_cart() {
global $woocommerce;
?>
<a href="<?php echo esc_attr(wc_get_cart_url());?>" class="cart-button">
<i class="fa fa-shopping-cart"></i>
<span class="cart-total-number"><?php echo esc_html(WC()->cart->cart_contents_count);?></span>
</a>
<?php
}
add_filter('add_to_cart_fragments', 'omexo_add_to_cart_fragment');
/**
* Declare WooCommerce support
*/
function omexo_woocommerce_support() {
add_theme_support('woocommerce');
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
add_action( 'after_setup_theme', 'omexo_woocommerce_support' );
/**
* Change WooCoomerce product markup
*/
function omexo_before_shop_loop_item_title() {
echo '<div class="omexo-wc-product-info">';
woocommerce_template_loop_add_to_cart();
echo '<h2 class="woocommerce-loop-product__title omexo-wc-title"><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h2>';
}
add_action( 'woocommerce_before_shop_loop_item_title', 'omexo_before_shop_loop_item_title', 10 );
function omexo_after_shop_loop_item_title() {
echo '</div>';
}
add_action( 'woocommerce_after_shop_loop_item_title', 'omexo_after_shop_loop_item_title', 10 );
function omexo_before_shop_loop_item() {
echo '<div class="product-content">';
}
add_action( 'woocommerce_before_shop_loop_item', 'omexo_before_shop_loop_item', 10 );
function omexo_after_shop_loop_item(){
echo '</div>';
}
add_action( 'woocommerce_after_shop_loop_item', 'omexo_after_shop_loop_item', 10 );
/**
* WooCommerce Search Field
*
*/
function omexo_custom_product_searchform( $form ) {
$form = '
<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '">
<div class="wc-search-form">
<label class="screen-reader-text" for="s">' . __( 'Search for:', 'omexo' ) . '</label>
<input class="wc-search-input" type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'Search', 'omexo' ) . '"/>
<button class="wc-search-btn" type="submit" id="searchsubmit"><i class="fa fa-search"></i></button>
<input type="hidden" name="post_type" value="product" />
</div>
</form>';
return $form;
}
add_filter( 'get_product_search_form' , 'omexo_custom_product_searchform' );
/**
* Tutor LMS Course Single Titles
*
*/
function omexo_course_single_topic_title() {
$omexo_option = get_option('omexo_opt');
echo esc_html__($omexo_option['single-course-content-title'], 'tutor');
}
add_filter('tutor_course_topics_title', 'omexo_course_single_topic_title');
function omexo_course_single_benefit_title() {
$omexo_option = get_option('omexo_opt');
echo esc_html__($omexo_option['single-course-what-learn-title'], 'tutor');
}
add_filter('tutor_course_benefit_title', 'omexo_course_single_benefit_title');
function omexo_course_single_description_title() {
$omexo_option = get_option('omexo_opt');
echo esc_html__($omexo_option['single-course-desc-title'], 'tutor');
}
add_filter('tutor_course_about_title', 'omexo_course_single_description_title');
/**
* Set price decimals to 0 if not set in WooCommerce settings
*
* This function is attached to the 'wc_get_price_decimals' filter hook.
*
* @param int $decimals
* @return int
*/
function custom_default_price_decimals($decimals){
$saved_decimals = get_option('woocommerce_price_num_decimals', '');
return ($saved_decimals === '') ? 0 : $decimals;
}
add_filter('wc_get_price_decimals', 'custom_default_price_decimals');
/**
* Use custom LearnDash course template if exists
*
* @param string $template
* @return string
*/
function custom_learndash_course_template($template)
{
if (is_singular('sfwd-courses')) {
$theme_template = get_stylesheet_directory() . '/learndash/course.php';
if (file_exists($theme_template)) {
return $theme_template;
}
}
return $template;
}
add_filter('template_include', 'custom_learndash_course_template');