This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Recursive function to generate a unique username. | |
* | |
* If the username already exists, will add a numerical suffix which will increase until a unique username is found. | |
* | |
* REF: https://gist.github.com/philipnewcomer/59a695415f5f9a2dd851deda42d0552f | |
* | |
* @param string $username | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WorpPress post query result | |
* @since 1.0.0 | |
* @author Razon Komar Pal | |
* @return string - like: Showing 1–12 Of 29 Results | |
*/ | |
if (get_query_var('paged')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('ABSPATH') || die('Cheatin’ uh?'); // Cannot access pages directly. | |
/** | |
* Restrict access to admin pages | |
* @author Razon Kommar Pal | |
*/ | |
add_action('admin_init', 'slug_restrict_access_for_specific_path'); | |
function slug_restrict_access_for_specific_path() | |
{ | |
$requested_url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://ngrok.com/docs#http-bind-tls | |
#https://ngrok.com/docs#http-host-header | |
ngrok http -bind-tls=false -host-header=rewrite wp.local:80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WordPress WP-CLI cheat sheet | |
UPCOMING MORE... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
"use strict"; | |
$(document).ready(function () { | |
// Sending Data to the Server | |
jQuery(document).on('heartbeat-send', function (event, data) { | |
// Add additional data to Heartbeat data. | |
data.myplugin_customfield = 'some_data'; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$product_id = 10; | |
$product = wc_get_product($product_id); | |
$variations = $product->get_available_variations(); | |
$variation_names = array(); | |
foreach ( $variations as $variation ) { | |
// Get attribute taxonomies | |
$taxonomies = array_keys($variation['attributes']); | |
// Loop through variation taxonomies to get variation name and slug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter content if find any certain word. | |
* @author Razon Komar Pal | |
*/ | |
function ic_filter_content_sample($content) | |
{ | |
// for single post | |
if (is_single()) { | |
$new_content = '<p>This is added to the bottom of all post and page content</p>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet Woocommerce hide price & add to cart if not logged in | |
* @author Razon Komar pal | |
*/ | |
add_action('init', 'woo_hide_price_add_cart_for_not_logged_in_user'); | |
add_action('template_redirect', 'woo_hide_price_add_cart_for_not_logged_in_user'); | |
function woo_hide_price_add_cart_for_not_logged_in_user() | |
{ |