Skip to content

Instantly share code, notes, and snippets.

View ravishakya's full-sized avatar
😈
Code Devil

Code Devil ravishakya

😈
Code Devil
View GitHub Profile
@ravishakya
ravishakya / gist:a44c4f6faac5a794da19
Created October 14, 2015 03:54 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@ravishakya
ravishakya / readme.md
Created March 2, 2016 10:54 — forked from hitautodestruct/readme.md
Generate a custom structure for Wordpress menus.

This gist is for showing an example of a custom wordpress menu.

If you want to get more from the menu item simply have a look at the $item object. i.e:

// Will return a large object with lots of props like title, url, description, id etc.
var_dump( $item );

This code works on Wordpress 4.1.1 as of 31st of March 2015

<?php
add_action( 'woocommerce_product_query', 'so_27971630_product_query' );
function so_27971630_product_query( $q ){
$meta_query = $q->get( 'meta_query' );
$meta_query[] = array(
'key' => 'custom_acf_key',
'value' => 'custom_acf_value',
'compare' => '='
function tryParseJSON(jsonString){
try {
var o = JSON.parse(jsonString);
// Handle non-exception-throwing cases:
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
// but... JSON.parse(null) returns null, and typeof null === "object",
// so we must check for that, too. Thankfully, null is falsey, so this suffices:
if (o && typeof o === "object") {
return o;
}
@ravishakya
ravishakya / PHP Countries Array
Created December 1, 2016 10:15 — forked from DHS/PHP Countries Array
PHP array of all country names
<?php
$countries = array("Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Island
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@ravishakya
ravishakya / multidimentionalArrayMap.php
Last active January 30, 2021 14:48
array_map for multidimensional array
function multidimentional_array_map( $function, $arr ){
$result = array();
foreach ($arr as $key => $val){
$result[$key] = (is_array($val) ? multidimentional_array_map($function, $val) : $function($val));
}
return $result;
}
add_action( 'init' , 'hotelica_get_kirki_fields' );
function hotelica_get_kirki_fields(){
Kirki::add_config( 'my_theme',
array(
'capability' => 'edit_theme_options',
'option_type' => 'theme_mod',
)
);
@ravishakya
ravishakya / .htaccess
Created August 15, 2017 09:36
Redirect all subdomain to http and other to https
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:[a-z0-9-])?cyclonethemes\.com
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
// http://site1.example.com
// https://example.com
@ravishakya
ravishakya / fontawesome-5.php
Last active April 23, 2019 09:14
Fontawesome 5 icons ( Free & PRO ) php array
<script>
/**
* Paste the code in console here https://fontawesome.com/icons?d=gallery&c=vehicles,weather,winter,writing
* it will give icons in json
*/
var icon = [];
jQuery('ul.list li').each(function(){
icon.push(jQuery(this).find('i').attr('class'));
console.log(JSON.stringify(icon))
})