Skip to content

Instantly share code, notes, and snippets.


Sobuj sobujbd

  • Bangladesh
View GitHub Profile
sobujbd / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
View Mark parent navigation active when on custom post type single page
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Get post ID, if nothing found set to NULL
$id = ( isset( $post->ID ) ? get_the_ID() : NULL );
sobujbd /
Created Jul 16, 2020 — forked from mbleigh/
Firebase Hosting Fetch All Files

Fetch All Files from Firebase Hosting

This script fetches all of the files from the currently deployed version of a Firebase Hosting site. You must be signed in via the Firebase CLI and have "Site Viewer" permission on the site in question to be able to properly run the script.

Running via NPX

npx <site_name>
sobujbd / csv-to-json.php
Created Jul 30, 2019 — forked from robflaherty/csv-to-json.php
Convert CSV to JSON
View csv-to-json.php
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on
header('Content-type: application/json');
// Set your CSV feed
sobujbd /
Created Jun 1, 2019 — forked from JeffreyWay/
PHP: Set value if not exist

You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:

name = name || 'joe';

This is quite common and very helpful. Another option is to do:

name || (name = 'joe');
# Setup Variables
sobujbd /
Created Apr 8, 2019 — forked from LostinOrchid/
Create database backup in Wordpress
#!/usr/bin/env bash
# echo $(wp --version)
wp --version >/dev/null 2>&1 || {
echo "I need 'wp' command to be able to execute further"
exit 1
# Check if it is a wordpress directory or is installed
sobujbd / unzip.php
Created Nov 14, 2017 — forked from trajche/unzip.php
Unzip a file on with PHP
View unzip.php
$unzip = new ZipArchive;
$out = $unzip->open('');
if ($out === TRUE) {
echo 'File unzipped';
} else {
echo 'Something went wrong?';
sobujbd / install.php
Created Sep 30, 2017 — forked from tschoffelen/install.php
A simple PHP script that automatically downloads and unzips the latest version of Wordpress in the current directory (./), so that I don't have to download it and upload it to my server through FTP manually.
View install.php
echo '<pre>';
echo '<span style="color:blue">DOWNLOADING...</span>'.PHP_EOL;
// Download file
file_put_contents('', file_get_contents(''));
$zip = new ZipArchive();
$res = $zip->open('');
if ($res === TRUE) {