Skip to content

Instantly share code, notes, and snippets.

View mlbd's full-sized avatar
🏠
Working from home

Mohammad Limon mlbd

🏠
Working from home
View GitHub Profile
@mlbd
mlbd / code.php
Created April 11, 2019 10:58 — forked from dtbaker/code.php
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(
@mlbd
mlbd / csv_stream.php
Created March 19, 2019 13:22 — forked from damncabbage/csv_stream.php
CSV via File Handle
<?php
class CSVStream {
/**
* List of available source fields.
*
* @var array
*/
protected $fields = array();
/**
* First of all change prefix if you have different one. As default WordPress has `wp_`
*/
# Update post meta to another meta key
# Transfer one post meta to another meta key
UPDATE wp_postmeta SET meta_key = 'new_key_name' WHERE meta_key = 'old_key_name';
// Update home and siteurl.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
$fullsize_path = get_attached_file( 40 );
echo "<pre>";
$csv_stream = new CSVStream($fullsize_path, array(), array('header_rows' => 1));
for ($index=0; $index < $csv_stream->computeCount(); $index++) {
$csv_stream_data = $csv_stream->getNextRow();
if ( email_exists( $csv_stream_data->email ) ) {
$user = get_user_by( 'email', $csv_stream_data->email );
@mlbd
mlbd / webstoemp-gulpfile.js
Created January 7, 2019 05:53 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@mlbd
mlbd / fontawesome5-php-array.php
Created November 21, 2018 11:34 — forked from smartcatdev/fontawesome5-php-array.php
Font Awesome 5 - Icon PHP Array
function fa_icons() {
return array (
'fab fa-500px' => __( '500px', 'buildr' ),
'fab fa-accessible-icon' => __( 'accessible-icon', 'buildr' ),
'fab fa-accusoft' => __( 'accusoft', 'buildr' ),
'fas fa-address-book' => __( 'address-book', 'buildr' ),
'far fa-address-book' => __( 'address-book', 'buildr' ),
'fas fa-address-card' => __( 'address-card', 'buildr' ),
'far fa-address-card' => __( 'address-card', 'buildr' ),
/**
* Create Programmatically WP nav menu from API
*
* 1. First retrieve data from url
* 2. Then Clean nav menu items if already have any
* 3. Add nav menu items dynamically by using wp_update_nav_menu_item()
*
* @package binAmmer
* @author mlimon
*/
@mlbd
mlbd / Create Programmatically WordPress Nav menu
Last active July 21, 2023 13:25
Programmatically create wp nav menu from external json file
/**
* Registers a wp nav menu Programmatically.
*
* @link https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_object
* @link https://codex.wordpress.org/Function_Reference/wp_create_nav_menu
* @link https://developer.wordpress.org/reference/functions/wp_update_nav_menu_item/
* @link https://developer.wordpress.org/reference/functions/wp_remote_get/
* @link https://codex.wordpress.org/Function_API/wp_remote_retrieve_body
*
* @since 1.0
/**
* First of all change prefix if you have different one. As default WordPress has `wp_`
*/
// Update home and siteurl.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
// Update posts guid.
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
$spaceamounts: ('none', 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 75, 80, 100, 150); // Adjust this to include the pixel amounts you need.
$sides: (top, bottom, left, right); // Leave this variable alone
@each $space in $spaceamounts {
@each $side in $sides {
.m-#{str-slice($side, 0, 1)}-#{$space} {
@if $space == 'none' {
margin-#{$side}: 0px !important;
} @else {
margin-#{$side}: #{$space}px !important;