Skip to content

Instantly share code, notes, and snippets.

View ruman's full-sized avatar
:octocat:

Mohammad Mahbubur Rahman ruman

:octocat:
View GitHub Profile
@ruman
ruman / csutom_post_status.php
Created November 3, 2018 07:29
Custom Post Status
// Registering custom post status
function wpb_custom_post_status(){
register_post_status('inactive', array(
'label' => _x(
'Inactive', 'post' ),
'public' => false,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>' ),
@ruman
ruman / docker-cleanup-resources.md
Created April 16, 2020 15:21 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ruman
ruman / apache2_docker.conf
Last active June 5, 2020 08:29
SSL configuration for APACHE2 Docker:
apt-get update && apt-get install openssl
openssl genrsa -out "/etc/ssl/certs/yourdevsite.local.key" 2048 && openssl req -new -key "/etc/ssl/certs/yourdevsite.local.key" -out "/etc/ssl/certs/yourdevsite.local.csr" -subj "/CN=yourdevsite.local/O=yourdevsite.local/C=UK" && openssl x509 -req -days 365 -in "/etc/ssl/certs/yourdevsite.local.csr" -signkey "/etc/ssl/certs/yourdevsite.local.key" -out "/etc/ssl/certs/yourdevsite.local.crt"
in defualt.apache.conf:
<VirtualHost *:80>
ServerName yourdevsite.local
DocumentRoot /var/www/yourdevsite/public/
@ruman
ruman / heartbeat-api-demo.php
Created August 11, 2020 03:00 — forked from strangerstudios/heartbeat-api-demo.php
Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
<?php
/*
Plugin Name: Heartbeat API Demo
Plugin URI: http://www.strangerstudios.com/wp/heartbeat-api-demo
Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
Version: .1
Author: strangerstudios
If logged in as a user and viewing the frontend of your website,
every 15 seconds you should see the following in your Javascript console:
@ruman
ruman / theme-options.php
Created September 5, 2020 06:08 — forked from kirandash/theme-options.php
Custom Theme Options
<?php
/**
* VSP functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package VSP
*/
if ( ! function_exists( 'vsp_setup' ) ) :
<?php
// If you are using Composer
require 'vendor/autoload.php';
use SendGrid\Mail;
$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
@ruman
ruman / resumejs.js
Last active January 27, 2021 04:36
VideoJS with resume functionality ( Modified from https://github.com/embedly/player.js/blob/gh-pages/scripts/resume.js for videoJS player )
/*global jQuery:true, videojs:true */
(function($, document, window){
// Wrap localStorage.
var storage = {
_get: function(){
var data = JSON.parse(window.localStorage.getItem('resume'));
return data ? data : {};
},
@ruman
ruman / remove_custom_table_data_wordpress
Last active April 15, 2021 09:14
Remove custom table data when post deleted or updated.
/*
Delete data from custom_table upon deleting the post
*/
add_action( 'admin_init', 'custom_table_admin_init' );
function custom_table_admin_init() {
add_action( 'delete_post', 'custom_table_data_delete', 10 );
}
function custom_table_data_delete( $pid ) {
@ruman
ruman / functions.php
Created June 2, 2021 16:19 — forked from contemplate/functions.php
WooCommerce - Allow guest checkout for certain products when Guest checkout is Disabled globally
/*--------------------------------------
Woocommerce - Allow Guest Checkout on Certain products
----------------------------------------*/
// Display Guest Checkout Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
@ruman
ruman / sample-php-headers.php
Created September 9, 2021 00:39 — forked from ScottPhillips/sample-php-headers.php
PHP Header Examples
301 moved permanently (redirect):
<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com');
die();
?>
302 moved temporarily(redirect):
<?php
header('Location: http://www.example.com');