Skip to content

Instantly share code, notes, and snippets.

View manchumahara's full-sized avatar
🎯
Focusing

Sabuj Kundu manchumahara

🎯
Focusing
View GitHub Profile
@manchumahara
manchumahara / gist:9293231
Created March 1, 2014 17:10
Sometimes we need to play post edit link for admin, editor or author himself. To place the edit link on frontend it's need to take care a bit so that the edit link is not visible to any unauthorized user. So my choice is showing the edit link who has other post edit permission and the author himself.
global $post, $current_user;
get_currentuserinfo();
if(current_user_can( 'edit_others_posts', $post->ID ) || ($post->post_author == $current_user->ID)) {
//show edit link
}
/*
We are requesting for 46,66,80,128,237,247,272,285
Available The codes are:
11 - Group created.
12 - Event created.
46 - Status update. *
56 - Post on Timeline from another user.
@manchumahara
manchumahara / gist:9718860
Created March 23, 2014 04:37
Wordpress default archive widget doesn't have any option for showing author archive widget. This small code snippet will convert default archive widget into a author archive widget. For showing the link I hooked only for month link, same filter can be applied to other archive link for day or year archive link for any author. This works on author…
add_filter('getarchives_where', 'getarchives_where_author');
add_filter('month_link', 'month_link_author');
/**
* Custom function to filter query for author archive widget, this works on author page only
*
* @param $where
* @return string
*/
function getarchives_where_author($where){
<?php
$fonts = '<div class="row">
<div class="col-md-4 col-sm-6 col-lg-3">
<i class="fa fa-fw"></i>
fa-glass
<span class="muted">(&amp;#xf000;)</span>
</div>
<div class="col-md-4 col-sm-6 col-lg-3">
@manchumahara
manchumahara / gist:9910185
Last active August 29, 2015 13:57
Search user in wordpress sidewide (at least at backend and if you use wp user query any where ) for user's display name , if you are here you know why I used this filter
add_filter('user_search_columns', 'user_search_columns_bd' , 10, 3);
function user_search_columns_bd($search_columns, $search, $this){
//if(!in_array($search_columns, 'display_name')){
if(!in_array('display_name', $search_columns)){
$search_columns[] = 'display_name';
}
return $search_columns;
}
@manchumahara
manchumahara / gist:10569985
Last active August 29, 2015 13:59
for style use this ul.plainyearbasedtimelinelist{ border-left: 4px solid #E5E5E5 !important; margin-left: 20px; padding-left: 30px; }
<?php
$last_changed = wp_cache_get( 'last_changed', 'posts' );
if ( ! $last_changed ) {
$last_changed = microtime();
wp_cache_set( 'last_changed', $last_changed, 'posts' );
}
global $wpdb;
Old way:
$option = JRequest::getCmd('option');
New way:
$app = JFactory::getApplication();
$option = $app->input->getCmd('option', '');
//old way
$app = JFactory::getApplication();
$offline = $app->getCfg('offline');
or
$config =& JFactory::getConfig();
echo 'Site name is ' . $config->getValue( 'config.sitename' );
//New way
//use get()
@manchumahara
manchumahara / google drive picker response
Last active August 29, 2015 14:02
google drive picker response
PDF:
===========================
description ""
embedUrl "https://docs.google.com...PRG-KARZb4gQojr/preview"
iconUrl "https://ssl.gstatic.com...es/icon_10_pdf_list.png"
id "1z75Y9TZ1tE55mEoIxU7Yl8...njuVsdAoPRG-KARZb4gQojr"
lastEditedUtc 1378370893566
mimeType "application/pdf"
name "Buzz-0001.pdf"
@manchumahara
manchumahara / gist:c1ab38508a6e4ff31c38
Last active August 29, 2015 14:05
adding visual editor to kazzo template wordpress plugin
function Kazoo_TemplateEDIT($id) {
global $wpdb;
$r = null;
if ($id > 0) {
$q = "SELECT id,name,date,code FROM kazoo_tpl WHERE id=$id";
$r = $wpdb->get_row($q,OBJECT);
}