Skip to content

Instantly share code, notes, and snippets.

View mahafuz's full-sized avatar
🐜
Hey there!

Mahafuzur Rahaman mahafuz

🐜
Hey there!
View GitHub Profile
@mahafuz
mahafuz / UploaderComponent.js
Created January 17, 2022 16:17
WordPress media uploader React Component
import React, { useState, useEffect } from "react";
import { __ } from "@wordpress/i18n";
import "./index.scss";
const index = (props) => {
let frame;
const [logo, setLogo] = useState({});
useEffect(() => {
@mahafuz
mahafuz / ArrayHelpers.php
Last active February 2, 2023 07:12
This file contains very useful array methods to work.
<?php
class Arr {
/**
* Taken from Illuminate\Support\Arr (Laravel Framework)
*/
/**
* Check if an item or items exist in an array using "dot" notation.
*
@mahafuz
mahafuz / elementor-data.php
Last active December 5, 2024 04:30
Retrieve all elementor widgets name that used on a page.
<?php
function page_data() {
global $post;
$used_section = [];
$data = (get_metadata( 'post', $post->ID, '_elementor_data' ));
if( empty($data) ) {
$data = [];
}else {
@mahafuz
mahafuz / possible-social-icons.js
Created July 26, 2018 05:38
Social icons only in FontAwesome 4.7
const iconsList = [
'fa fa-apple',
'fa fa-behance',
'fa fa-bitbucket',
'fa fa-codepen',
'fa fa-cloud',
'fa fa-delicious',
'fa fa-deviantart',
'fa fa-digg',
'fa fa-drupal',
@mahafuz
mahafuz / post-search.php
Last active January 21, 2022 17:36
WordPress Custom Post Search Form
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<select name="category_name">
<option value="">Select your theme</option>
<?php $documentation_categories = get_terms( 'category' ); if(! empty( $documentation_categories ) && ! is_wp_error( $documentation_categories )) : foreach($documentation_categories as $documentation_category) : ?>
<option value="<?php echo $documentation_category->slug; ?>"><?php echo $documentation_category->name; ?></option>
<?php endforeach; endif; ?>
</select>
<input type="search" value="<?php echo get_search_query(); ?>" name="s" placeholder="& Type keywords">
@mahafuz
mahafuz / index.php
Last active January 11, 2022 09:49
Functions for woocommerce varius pages links
<?php
/* ***********************
(1) Shop URL
**************************/
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
/* ***********************
@mahafuz
mahafuz / index.php
Last active July 16, 2023 13:41
Woocommerce Helper Code Snippets
<?php
/*
* Hide "Products" in WooCommerce breadcrumb
*/
function woo_custom_filter_breadcrumbs_trail ( $trail ) {
foreach ( $trail as $k => $v ) {
if ( strtolower( strip_tags( $v ) ) == 'products' ) {
unset( $trail[$k] );
break;
@mahafuz
mahafuz / index.php
Last active January 11, 2022 09:47
Replace default product placeholder image
<?php
/*
* goes in theme functions.php or a custom plugin. Replace the image filename/path with your own 🙂
*
**/
add_action( 'init', 'custom_fix_thumbnail' );
function custom_fix_thumbnail() {
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
@mahafuz
mahafuz / related-post.php
Last active January 21, 2022 16:53
Code for getting WordPress related posts
<?php
/*
Plugin Name: Related Post
*/
function pippin_related_posts($taxonomy = '') {