Skip to content

Instantly share code, notes, and snippets.

View UmeshSingla's full-sized avatar
🏠
Working from home

Umesh Kumar UmeshSingla

🏠
Working from home
View GitHub Profile
@UmeshSingla
UmeshSingla / function.php
Last active December 17, 2015 20:29
Wordpress Popular Post(No. of Post Views)
<?php
/* Add this code to function.php file */
/* Post View Increment */
function rtp_popular_post(){
global $post;
$count_key = '_rtp_post_view_count';
if(is_single()){
$view_count = get_post_meta($post->ID, $count_key, true);
if($view_count==''){
@UmeshSingla
UmeshSingla / template.php
Created May 29, 2013 05:33
Wordpress Popular Post Sorted by Comment Count
<?php
/* Add this where you want to display popular post sorted by comment count */
$args = array( 'orderby' => 'comment_count', 'numberposts' => $rtp_post_count, 'post_status' => 'publish' );
$posts = get_posts($args); ?>
<!-- Output Markup -->
<ul class="rtp-most-popular-wrapper"><?php
$count=1;
for($i=0; $i<sizeof($posts); $i++){?>
<li>
<a href="<?php echo get_permalink($posts[$i]->ID); ?>" title="<?php echo $posts[$i]->post_title; ?>" target="_blank"><?php echo $count.'. '.$posts[$i]->post_title; ?></a>
@UmeshSingla
UmeshSingla / recent-post.php
Created May 29, 2013 05:42
Wordpress Recent Post
<?php
$args = array(
'numberposts' => 10,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => ,
'exclude' => ,
'meta_key' => ,
@UmeshSingla
UmeshSingla / function.php
Created June 7, 2013 07:28
Wordpress- Remove Widgets Form Dashboard
<?php
/* Add to remove default Widgets from Dashboard */
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
@UmeshSingla
UmeshSingla / function.php
Created June 7, 2013 07:30
Wordpress - Remove Logo from Admin Bar
<?php
/*
* Remove the WordPress Logo from the WordPress Admin Bar
*/
function remove_wp_logo() {
global $wp_admin_bar;
if(!is_super_admin()){
$wp_admin_bar->remove_menu('wp-logo');
}
}
@UmeshSingla
UmeshSingla / function.php
Created June 7, 2013 07:59
Wordpress- Custom Message in Admin Bar
<?php
/* Custom Info Admin Bar */
function rtp_role_info() {
global $wp_admin_bar, $wpdb;
$message = '';
if(current_user_can('basic_contributor')){
$message = "Basic User";
}elseif(current_user_can('premium')){
$message = "Premium User";
}
@UmeshSingla
UmeshSingla / function.php
Created June 7, 2013 12:51
Wordpress- Remove Admin Notices
<?php
add_action('admin_menu','wphidenag');
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
?>
@UmeshSingla
UmeshSingla / custom.js
Created June 9, 2013 13:10
Select all Checkboxes, Unselect all Checkboxes
jQuery('body').on('click','.topic-checkbox input[type="checkbox"]', function(){
var current_checkbox = jQuery(this);
var id = current_checkbox.attr('id');
var checked = current_checkbox.prop('checked');
if(id=="checkbox-input-all" && checked){
jQuery('.topic-checkbox input[type="checkbox"]').prop('checked', true);
}else if(id=="checkbox-input-all" && !checked){
jQuery('.topic-checkbox input[type="checkbox"]').prop('checked', false);
}else if(id!="checkbox-input-all" && !checked){
jQuery('#checkbox-input-all').prop('checked', false);
@UmeshSingla
UmeshSingla / URL
Created June 12, 2013 13:36
JS Timezone Detect
https://bitbucket.org/pellepim/jstimezonedetect
@UmeshSingla
UmeshSingla / functions.php
Last active December 18, 2015 19:08
Country, State, Timezone List
<?php
function get_country_state_list($c = '',$only_country = FALSE) {
$countries = array(
'select_one' => __('Select one...', 'rtPanel'),
'AF' => __('Afghanistan', 'rtPanel'),
'AX' => __('&#197;land Islands', 'rtPanel'),
'AL' => __('Albania', 'rtPanel'),
'DZ' => __('Algeria', 'rtPanel'),
'AS' => __('American Samoa', 'rtPanel'),
'AD' => __('Andorra', 'rtPanel'),