Skip to content

Instantly share code, notes, and snippets.

View anandkumar's full-sized avatar

Anand Kumar anandkumar

View GitHub Profile
@anandkumar
anandkumar / functions.php
Created October 8, 2013 15:51
Remove (unhook) Genesis Comments from Posts
<?php
//* Do NOT include the opening php tag
//* Remove posted comments from Genesis
remove_action( 'genesis_comments', 'genesis_do_comments' );
@anandkumar
anandkumar / functions.php
Created October 2, 2013 07:53
Move Genesis Comments
/** Move Genesis Comments */
add_action( 'genesis_before_comments' , 'eo_move_comments' );
function eo_move_comments ()
{
if ( is_single() && have_comments() )
{
remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
add_action( 'genesis_comments', 'genesis_do_comment_form', 5 );
}
}
@anandkumar
anandkumar / disqus.js
Last active December 23, 2015 10:19
disqus lazy load
<script type="text/javascript">
var comments = document.getElementsByClassName('comments')[0],
disqusLoaded=false;
function loadDisqus() {
var disqus_shortname = 'netrival';
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
@anandkumar
anandkumar / functions.php
Last active December 22, 2015 04:58
bbPress Membership levels, Basic, Premium and Lifetime Premium. Based on some codes in bbPress forums.
<?php
function my_custom_get_dynamic_roles( $bbp_roles )
{
/* Add a role called Community Contributor */
$bbp_roles['bbp_basic_member'] = array(
'name' => 'Basic Member',
'capabilities' => my_custom_get_caps_for_role( 'bbp_basic_member' )
);
@anandkumar
anandkumar / functions.php
Created August 23, 2013 14:13
Hide bbPress topics / replies / forums from public or non-logged in users.
function pj_hla_logged_in_topics($have_posts){
if (!is_user_logged_in()){
$have_posts = null;
echo 'Login to see replies';
}
return $have_posts;
}
add_filter('bbp_has_topics', 'pj_hla_logged_in_topics');
add_filter('bbp_has_forums', 'pj_hla_logged_in_topics');
@anandkumar
anandkumar / functions.php
Created August 21, 2013 12:30
Force full width layout on bbPress forums
/** Force full width layout on bbPress forums */
add_filter( 'genesis_pre_get_option_site_layout', 'child_do_layout' );
function child_do_layout( $opt ) {
if ( is_bbpress() ) {
$opt = 'full-width-content'; // Change this to any Genesis layout
return $opt;
}
}
@anandkumar
anandkumar / header.js
Created August 14, 2013 11:55
Color table using javascript.
<script type="text/javascript">jQuery(document).ready(function ($) {
$('table').css({
'border-collapse':'collapse'
});
$('tr th').css({'background':'#666666', 'color':'#ffffff', 'font-family':'verdana', 'font-weight':'normal'});
// Here using jquery selectors
$('tr:even').css({'background':'#f5f5f5'});
<html>
<head>
....
YOUR ADSENSE CSS CODE HERE
</head>
<body>
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
....
<!-- Adsense Ad Unit 1 -->
@anandkumar
anandkumar / adsense.html
Last active December 20, 2015 18:18
official responsive Adsense ad unit format - Async
<style>
.adsense-ad-unit-1 { width: 320px; height: 50px; }
@media(min-width: 500px) { .adsense-ad-unit-1 { width: 468px; height: 60px; } }
@media(min-width: 800px) { .adsense-ad-unit-1 { width: 728px; height: 90px; } }
</style>
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Adsense Ad Unit 1 -->
<ins class="adsense-ad-unit-1"
@anandkumar
anandkumar / gist:6097680
Created July 28, 2013 06:40
.htaccess domain change
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.com$
RewriteRule (.*)$ http://www.new-domain.com/$1 [R=301,L]
</IfModule>