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 | |
/** | |
* Customize wp_die so it doesn't look so cheesy | |
*/ | |
function my_custom_die_handler($message, $title = '', $args = array()) { | |
// Get the path to the custom die template | |
$template = get_theme_root() . '/' . get_template() . '/custom_die.php'; | |
// If not an admin page, and if the custom die template exists | |
if (!is_admin() && file_exists($template)) { |
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 | |
//Add Search Form To A WordPress Menu | |
add_filter('wp_nav_menu_items', 'add_search_form', 10, 2); | |
function add_search_form($items, $args) { | |
if( $args->theme_location == 'CHANGE-THIS-TO-YOUR-MENU-NAME' ) | |
$items .= '<li class="search"> | |
<form role="search" method="get" id="searchform" action="'.home_url( '/' ).'"> | |
<input type="text" value="search" name="s" id="s" /> |
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 | |
//Simple shortcodes | |
function HelloWorldShortcode() { | |
return '<p>Hello World!</p>'; | |
} | |
add_shortcode('helloworld', 'HelloWorldShortcode'); | |
//usage |
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
MySQL command line | |
Copy the SQL fiel into C:\xampp\mysql\bin path | |
then run mysql using command | |
C:\xampp\mysql\bin> mysql -u root -p | |
mysql> use db_name; | |
mysql> source backup-file.sql; |
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 | |
add_filter('woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1); | |
add_filter('woocommerce_prevent_admin_access', '_wc_prevent_admin_access', 10, 1); | |
function _wc_prevent_admin_access($prevent_admin_access) { | |
$user_data = get_userdata( get_current_user_id() ); | |
$user_roles = $user_data->roles; | |
$customer_role = get_role( 'customer' ); | |
// For "customer" WooCommerce user role only | |
if (in_array('customer', $user_roles)) { |
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
<Files *.php> | |
Order Deny,Allow | |
Deny from all | |
Allow from 127.0.0.1 | |
</Files> | |
<Files index.php> | |
Order Allow,Deny | |
Allow from all | |
</Files> |
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 | |
if (!function_exists('getAvatar')) { | |
/** | |
* Get either a Gravatar URL or complete image tag for a specified email address. | |
* ------------------------------------------------ | |
* @param string $email The email address | |
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] | |
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] | |
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ] |
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 | |
if (!function_exists('isValidateDate')) { | |
/** | |
* Validate Date (i/p format YYYY-MM-DD) | |
* ------------------------------------------------ | |
* '2013-13-01' - false | |
* '20132-13-01' - false | |
* '2013-11-32' - false |
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 | |
if (!function_exists('getControllerName')) { | |
function getControllerName($string) { | |
$pices = explode('\\', $string); | |
$pices1 = explode('@', end($pices)); | |
$controller_name = current($pices1); | |
return ucfirst(str_replace('Controller', '', $controller_name)); | |
} | |
} |
OlderNewer