Skip to content

Instantly share code, notes, and snippets.

View geekz's full-sized avatar
😀
Just WordPress

Murali Kumar geekz

😀
Just WordPress
View GitHub Profile
@geekz
geekz / mount_aws_nvme_ephemeral.sh
Created October 14, 2022 16:10 — forked from fideloper/mount_aws_nvme_ephemeral.sh
Find, format, and mount an AWS Ephemeral NVMe disk within ec2 in user data
#!/usr/bin/env bash
###
## This mounts a (single) ephemral NVMe drive in an EC2 server.
## It's meant to be run once, within user-data
## For EBS drives (non-ephemeral storage), see: https://gist.github.com/jalaziz/c22c8464cb602bc2b8d0a339b013a9c4
#
@geekz
geekz / excerpt_more filter
Created May 21, 2020 12:10
excerpt_more filter
function wpboys_excerpt_more( $more ) {
return sprintf( '<a href="%1$s" class="more-link">%2$s</a>',
esc_url( get_permalink( get_the_ID() ) ),
sprintf( __( 'Continue reading %s', 'wpdocs' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
);
}
add_filter( 'excerpt_more', 'wpboys_excerpt_more' );
@geekz
geekz / list-videos.php
Created May 19, 2020 18:48
List of Youtube Videos loop
$videos=array();
$videos[]=array('id'=>1,'title'=>'Video Title 1','description'=>'Video Description 1','embed_link'=>"https://www.youtube.com/embed/g6cAwDiuwos");
$videos[]=array('id'=>2,'title'=>'Video Title 2','description'=>'Video Description 2','embed_link'=>"https://www.youtube.com/embed/g6cAwDiuwos");
$videos[]=array('id'=>3,'title'=>'Video Title 3','description'=>'Video Description 3','embed_link'=>"https://www.youtube.com/embed/g6cAwDiuwos");
echo '<ul>';
foreach($videos as $video):
echo '<ul>';
echo '<li>Title : '.$video['title'].'</li>';
echo '<li>Description : '.$video['description'].'</li>';
echo '<li><iframe width="560" height="315" src="'.$video['embed_link'].'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></li>';
@geekz
geekz / README.md
Created June 29, 2019 18:35 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@geekz
geekz / yoast_seo_breadcrumb_add_woo_shop.php
Created June 17, 2019 04:19 — forked from amboutwe/yoast_seo_breadcrumb_add_woo_shop.php
Multiple examples of how to customize the Yoast SEO breadcrumbs
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
@geekz
geekz / redis.md
Created May 1, 2019 22:05 — forked from geraldvillorente/redis.md
How to test if Redis is working

In order to check if Redis is really working.

First, flush all keys stored in redis in order to remove old cache entries

$ redis-cli FLUSHALL

Monitor REDIS realtime.

$ redis-cli MONITOR
@geekz
geekz / digitalocean.md
Created October 26, 2018 20:04 — forked from cole007/digitalocean.md
Digital Ocean internal migration - moving files between droplets over SSH/SCP

If you need to move a lot of files between DO server you can move these through SCP over the internal private Digital Ocean network.

NB both droplets need to be within the same region

To do this you need:

  1. enable private network for each droplet (if not done at creation, note the droplet needs to be off for this to be enabled once live)
  2. ensure that eth1 is enabled for both droplets if not already - see https://www.digitalocean.com/community/tutorials/how-to-enable-digitalocean-private-networking-on-existing-droplets
  3. scp files from the source server to the destination server are sent like:
@geekz
geekz / functions.php
Last active September 23, 2018 20:54
Assign role to a WordPress User
<?php
/* Assign a role to User*/
$user_id = 1; // add user id here
$u = new WP_User( $user_id );
// set a user role that you want to assign. default WordPress roles are subscriber,contributor, editor, author or administrator,
$u->set_role( 'administrator' );
?>
@geekz
geekz / custom-post-taxonomy-permalinks.php
Created September 5, 2018 04:11 — forked from kasparsd/custom-post-taxonomy-permalinks.php
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
@geekz
geekz / wp-reset-roles.php
Created September 2, 2018 23:21 — forked from AKTed/wp-reset-roles.php
The following code will reset a WordPress default role to it's default capabilities. Note: these defaults are for WordPress 3.5, any other versions might have different defaults. To be safe, only use this code on WordPress 3.5. Warning: This cannot be undone! The role, in it's current state, is removed and recreated with the WordPress default ro…
<?php
/*
* example usage: $results = reset_role_WPSE_82378( 'subscriber' );
* per add_role() (WordPress Codex), $results "Returns a WP_Role object
* on success, null if that role already exists."
*
* possible $role values:
* 'administrator'
* 'editor'
* 'author'