Skip to content

Instantly share code, notes, and snippets.

View mehedidb's full-sized avatar

Mehedi Hasan Nahid mehedidb

View GitHub Profile
@woogists
woogists / woocommerce_add_to_cart_button_text.php
Last active December 6, 2023 09:57
Change the 'Add to Cart' button text on either single product or archives pages.
<?php
// Change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_add_to_cart_button_text_single' );
function woocommerce_add_to_cart_button_text_single() {
return __( 'Add to Cart Button Text', 'woocommerce' );
}
// Change add to cart text on product archives page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_add_to_cart_button_text_archives' );
@obiPlabon
obiPlabon / elementor-disable-all-wp-widgets.php
Last active December 20, 2020 17:39
Disable or remove elementor widget from editor panel
<?php
/**
* Disable elementor registered widget.
*
* This will disable all WordPress native widgets
*
* @param \Elementor\Widgets_Manager $widgets_manager Instance of elementor widgets manager
*
* @author obiPlabon <https://obiPlabon.im>
*
<?php
/*
Using the native WordPress functions and Script Manager (`WP_Scripts`).
Functions include:
wp_register_script
wp_deregister_script
wp_enqueue_script
wp_dequeue_script
wp_add_inline_script
@obiPlabon
obiPlabon / wp-remove-schema-attr.php
Created May 31, 2018 13:29
Remove schema attributes from WordPress the_custom_logo generated logo html
<?php
/**
* Remove schema attributes from custom logo html
*
* @param string $html
* @return string
*/
function op_remove_custom_logo_schema_attr( $html ) {
return str_replace( array( 'itemprop="url"', 'itemprop="logo"' ), '', $html );
}
@cezarpopa
cezarpopa / autoplay multiple youtube vimeo videos on hover
Last active January 6, 2021 08:39
autoplay multiple youtube / vimeo videos on hover
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
</head>
@dtbaker
dtbaker / code.php
Last active May 21, 2022 10:48
Add a custom control to an existing Elementor widget
// This example will add a custom "select" drop down to the "Image Box"
// This will change the class="" on the rendered image box so we can style the Image Box differently
// based on the selected option from the editor.
// The class will be "my-image-box-style-blue" or "my-image-box-style-green" based on the selected option.
add_action('elementor/element/before_section_end', function( $section, $section_id, $args ) {
if( $section->get_name() == 'image-box' && $section_id == 'section_image' ){
// we are at the end of the "section_image" area of the "image-box"
$section->add_control(
@designnify
designnify / function.php
Last active August 16, 2022 00:12
Genesis Responsive Menu Navigation - How to create a collapsible responsive menu for a genesis child theme
<?php
//* Do NOT include the opening php tag
//* Activate the use of Dashicons
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
function load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}
//* Enqueue scripts for Responsive menu
/**
* navigation.js
*
* Handles toggling the navigation menu for small screens and enabling tab support for dropdown menus.
*/
( function() {
var container, button, menu, links;
container = document.getElementById( 'site-navigation' );
if ( ! container )
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {
@mikejolley
mikejolley / gist:2044109
Last active April 10, 2024 13:17 — forked from jameskoster/header.php
WooCommerce - Update number of items in cart and total after Ajax
<?php
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
ob_start();
?>
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
<?php