This file contains 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
// only author can see their own post | |
function ravs_parse_query_useronly( $wp_query ) { | |
if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { | |
if ( !current_user_can( 'level_10' ) ) { | |
global $current_user; | |
$wp_query->set( 'author', $current_user->id ); | |
} | |
} | |
} |
This file contains 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
//Display variation dropdown as table | |
function woocommerce_variable_add_to_cart() { | |
global $product, $post; | |
$variations = $product->get_available_variations(); | |
foreach ($variations as $key => $value) { | |
?> | |
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"method="post" enctype='multipart/form-data'> | |
<input type="hidden" name="variation_id" value="<?php echo $value['variation_id']?>" /> | |
<input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" /> | |
<?php |
This file contains 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
Important Note: | |
----------------------------- | |
a). Latitude and Logitude stored as post meta. | |
b). skeleton for $seached_post and $all_post is same: | |
//paste this code in wordpress loop to collect required data of searched posts. | |
$searched_post[] = array( | |
'id' => get_the_ID(), // post id | |
'lat'=> $lat, // latitude value |
This file contains 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
Paste this code in functios.php | |
( copy /wp-content/plugins/gravityformsuserregistration/includes/activate.php file in /wp-content/themes/<your_theme>/ and edit activate.php as your html layout ) | |
/* overwrite user activation template */ | |
function ravs_user_activation_template(){ | |
$template_path = TEMPLATEPATH.'/activate.php'; | |
if( file_exists($template_path) && rgget('page') == 'gf_activation') |
This file contains 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 change_post_menu_label() { | |
global $menu; | |
$menu[2][0] = 'Edit My Ads'; | |
echo ''; | |
} | |
function change_admin_bar_menu_label() { | |
global $wp_admin_bar; | |
$wp_admin_bar->remove_node( 'dashboard' ); | |
//Add a link called 'Edit My Ads'... | |
$wp_admin_bar->add_menu( array( |
This file contains 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 GetMultiCellHeight($w, $h, $txt, $border=null, $align='J') { | |
// Calculate MultiCell with automatic or explicit line breaks height | |
// $border is un-used, but I kept it in the parameters to keep the call | |
// to this function consistent with MultiCell() | |
$cw = &$this->CurrentFont['cw']; | |
if($w==0) | |
$w = $this->w-$this->rMargin-$this->x; | |
$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; | |
$s = str_replace("\r",'',$txt); | |
$nb = strlen($s); |
This file contains 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 list_hooked_functions($tag=false){ | |
global $wp_filter; | |
if ($tag) { | |
$hook[$tag]=$wp_filter[$tag]; | |
if (!is_array($hook[$tag])) { | |
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); | |
return; | |
} | |
} | |
else { |
This file contains 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
add_action('wp_head', 'smashing_buffer_start'); | |
add_action('wp_footer', 'smashing_buffer_end'); | |
function smashing_buffer_start() { | |
ob_start( 'smashing_callback' ); | |
} | |
function buffer_end() { | |
ob_end_flush(); | |
} |
This file contains 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
/** | |
* Debugging plugin error | |
* | |
*/ | |
function save_error() { | |
update_option( 'plugin_error', ob_get_contents() ); | |
} | |
add_action( 'activated_plugin', 'save_error' ); |
This file contains 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 relative_time($date, $postfix = ' ago', $fallback = 'F Y') | |
{ | |
$diff = time() - strtotime($date); | |
if($diff < 60) | |
return $diff . ' second'. ($diff != 1 ? 's' : '') . $postfix; | |
$diff = round($diff/60); | |
if($diff < 60) | |
return $diff . ' minute'. ($diff != 1 ? 's' : '') . $postfix; | |
$diff = round($diff/60); | |
if($diff < 24) |
OlderNewer