Skip to content

Instantly share code, notes, and snippets.

View yousufansa's full-sized avatar

Yusuf Ansari yousufansa

View GitHub Profile
@yousufansa
yousufansa / functions.php
Created January 29, 2021 15:46
WooCommerce - Adding <span> wrap on order item variation name
if ( ! function_exists( 'around_wc_order_item_name' ) ) {
function around_wc_order_item_name( $name, $item ){
$variation_id = $item['variation_id'];
if( $variation_id > 0 ) {
$product_id = $item['product_id'];
$_product = wc_get_product( $product_id );
$product_name = $_product->get_title();
$_name = $product_name;
$variation_name = str_replace( $product_name . ' -', '', $item->get_name() );
$_name .= '<span class="your-class">' . $variation_name . '</span>';
@yousufansa
yousufansa / functions.php
Created January 28, 2021 04:50
Jobhunt - Company Logo Resize
if ( ! function_exists( 'jobhunt_template_company_logo' ) ) {
function jobhunt_template_company_logo() {
?>
<div class="company-logo">
<a href="<?php the_company_permalink(); ?>">
<?php the_company_logo( 'medium' ); ?>
</a>
</div>
<?php
}
@yousufansa
yousufansa / functions.php
Created January 27, 2021 17:02
MAS Videos - Upload Date Structure Data Issue Fix
function masvideos_structured_data_video_object_upload_date( $data, $post_object ) {
$data['uploadDate'] = $post_object->get_date_created()->date( 'c' );
return $data;
}
add_filter( 'masvideos_structured_data_movie', 'masvideos_structured_data_video_object_upload_date', 10, 2 );
add_filter( 'masvideos_structured_data_video', 'masvideos_structured_data_video_object_upload_date', 10, 2 );
add_filter( 'masvideos_structured_data_tv_show', 'masvideos_structured_data_video_object_upload_date', 10, 2 );
add_filter( 'masvideos_structured_data_episode', 'masvideos_structured_data_video_object_upload_date', 10, 2 );
@yousufansa
yousufansa / functions.php
Created January 25, 2021 15:15
Jobhunt - Make all the filter widgets closed on refresh
if( ! function_exists( 'jh_child_make_sidebar_filters_collapse_close' ) ) {
function jh_child_make_sidebar_filters_collapse_close() {
ob_start(); ?>
(function ($) {
"use strict";
$(document).ready(function () {
$( '.widget_jobhunt_wpjm_layered_nav .widget-title, .widget_jobhunt_wpjmr_layered_nav .widget-title, .widget_jobhunt_wpjmc_layered_nav .widget-title, .widget_jobhunt_wpjm_date_filter .widget-title, .widget_jobhunt_wpjmr_date_filter .widget-title, .widget_jobhunt_wpjmc_date_filter .widget-title' ).each( function( index ) {
if( index <= 2 ) {
$( this ).parent().addClass( 'closed' );
}
@yousufansa
yousufansa / functions.php
Created January 25, 2021 15:01
Front - Change the Custom Story Post Type Slug
if( ! function_exists( 'front_child_customize_customer_story_slug' ) ) {
function front_child_customize_customer_story_slug( $args ) {
if( isset( $args['rewrite'] ) && isset( $args['rewrite']['slug'] ) ) {
$args['rewrite']['slug'] = 'team';
}
return $args;
}
}
add_filter( 'front_extensions_register_post_type_customer_story', 'front_child_customize_customer_story_slug' );
@yousufansa
yousufansa / functions.php
Created January 22, 2021 06:07
Cartzilla - Display the vendor banner on frontend
if ( ! function_exists( 'cartzilla_dokan_dashboard_page_title' ) ) {
function cartzilla_dokan_dashboard_page_title( $user_id = null ) {
if ( ! $user_id ) {
$user_id = dokan_get_current_user_id();
}
$user_data = get_userdata( $user_id );
$user_registered = $user_data->user_registered;
$store_info = dokan_get_store_info( $user_id );
$storename = isset( $store_info['store_name'] ) && ! empty( $store_info['store_name'] ) ? $store_info['store_name'] : ( is_object( $user_data ) ? $user_data->display_name : '' );
@yousufansa
yousufansa / functions.php
Created January 15, 2021 09:09
WooCommerce - Show 6 woocommerce orders per page in "my account" page
if ( ! function_exists( 'wc_customize_my_account_orders_limit' ) ) {
function wc_customize_my_account_orders_limit( $args ) {
// Set the posts per page
$args['posts_per_page'] = 6;
return $args;
}
}
add_filter( 'woocommerce_my_account_my_orders_query', 'wc_customize_my_account_orders_limit' );
@yousufansa
yousufansa / style.css
Created January 15, 2021 08:49
Cartzilla - Hide Topbar on Mobile
@media (max-width: 767.98px) {
.topbar {
display: none !important;
}
}
@yousufansa
yousufansa / functions.php
Created January 13, 2021 05:29
Tokoo - Display Top bar on Handheld Header
if ( ! function_exists( 'tokoo_header_handheld' ) ) {
/**
* Displays HandHeld Header
*/
function tokoo_header_handheld() {
if( tokoo_has_handheld_header() ) : ?>
<div class="handheld-only">
<?php tokoo_top_bar(); ?>
<div class="container">
@yousufansa
yousufansa / functions.php
Created January 12, 2021 16:23
Jobhunt - Post a Job Button Custom URL
if ( ! function_exists ( 'jh_child_custom_header_post_a_job_button_url' ) ) {
function jh_child_custom_header_post_a_job_button_url( $url ) {
return "#"; //replace # with your url
}
}
add_filter( 'jobhunt_header_post_a_job_button_url', 'jh_child_custom_header_post_a_job_button_url' );