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 / 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 / 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 : {};
},
<?php
// If you are using Composer
require 'vendor/autoload.php';
use SendGrid\Mail;
$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
@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' ) ) :
@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 / 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 / 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 / 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 / gist:adf155edd4e6400e97382533abd8a274
Created February 20, 2018 05:55 — forked from betweenbrain/gist:5405671
Use cURL and SimpleXML to retrieve and parse Wordpress RSS feed
<?php
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://blogs.guggenheim.org/map/feed/',
CURLOPT_USERAGENT => 'spider',
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
@ruman
ruman / Dockerfile
Created July 8, 2017 07:46
Laradock with nginx mysql phpmyadmin mailhog and install openssl
FROM nginx:alpine
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
ADD nginx.conf /etc/nginx/
ARG PHP_UPSTREAM=php-fpm
# fix a problem--#397, change application source from dl-cdn.alpinelinux.org to aliyun source.
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories