Skip to content

Instantly share code, notes, and snippets.

View hsquareweb's full-sized avatar

Hassan Elhassan hsquareweb

View GitHub Profile
@hsquareweb
hsquareweb / gist:2050535
Created March 16, 2012 15:27
CSS/JS: Twitter Search Feed
<style>
/* TWITTER */
.twtr-doc, .twtr-timeline, #twtr-widget-1 .twtr-doc,
#twtr-widget-1 .twtr-hd a, #twtr-widget-1 h3, #twtr-widget-1 h4 {
border:none; border-radius: 0; background: transparent !important;}
.twtr-hd, .twtr-ft {display:none !important;}
</style>
<script type="text/javascript" charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script>
<script type="text/javascript">
@hsquareweb
hsquareweb / gist:2167882
Created March 23, 2012 07:13
WP: Latest Tweets
<h2>Twitter Feed</h2>
<?php
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=djakeed');
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul id="twitter_update_list">
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else foreach ( $rss_items as $item ) : ?>
@hsquareweb
hsquareweb / gist:2168032
Created March 23, 2012 07:43
WP: Popular Posts
<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
@hsquareweb
hsquareweb / gist:2244418
Created March 29, 2012 22:33
WP: Shortcode Function
// Shortcode to insert the latest article in the prayer corner section
function sc_prayercorner (){
$args = array(
'numberposts' => 1,
'post_type' => 'prayer_corner',
'post_status' => 'publish',
'orderby' => 'post_date'
);
$postslist = get_posts( $args );
foreach($postslist as $post) : setup_postdata($post);
@hsquareweb
hsquareweb / gist:2422038
Created April 19, 2012 16:13
jQuery: Navigation Slide
// NAVIGATION SLIDE
$('nav ul li').hover(function(){
$(this).find('ul').slideToggle('fast');
});
@hsquareweb
hsquareweb / gist:2424772
Created April 19, 2012 23:04
jQuery: Placeholder Fallback For Modernizer
//Placeholders fallback
$(function() {
// check placeholder browser support
if (!Modernizr.input.placeholder) {
// set placeholder values
$(this).find('[placeholder]').each(function() {
if ($(this).val() == '') { $(this).val( $(this).attr('placeholder') ); }
});
// focus and blur of placeholders
$('[placeholder]').focus(function() {
@hsquareweb
hsquareweb / gist:2502448
Created April 26, 2012 19:41
WP: Pull Posts
<ul>
<?php global $post;
$args = array( 'numberposts' => 4, 'category' => 6, 'orderby' => 'post_date', 'post_status' => 'publish' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li>
<div class="cal">
<span class="month"><?php the_time('M'); ?></span>
<span class="day"><?php the_time('j'); ?></span>
</div>
@hsquareweb
hsquareweb / functions.php
Created April 28, 2012 22:14
WP: Disable Admin Bar
// DISABLE ADMIN BAR
if (!function_exists('disableAdminBar')) {
function disableAdminBar(){
remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); // for the admin page
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // for the front end
function remove_admin_bar_style_backend() { // css override for the admin page
echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
}
add_filter('admin_head','remove_admin_bar_style_backend');
function remove_admin_bar_style_frontend() { // css override for the frontend
@hsquareweb
hsquareweb / gist:2651122
Created May 10, 2012 05:00
WP: Related Posts
<!-- post this code wherever you would like the related posts to be shown but usually inside single.php -->
<?php //for use in the loop, list 5 post titles related to first tag on current post
$backup = $post; // backup the current object
$tags = wp_get_post_tags($post->ID);
$tagIDs = array();
if ($tags) {
$tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i++) {
$tagIDs[$i] = $tags[$i]->term_id;
}
@hsquareweb
hsquareweb / gist:2651070
Created May 10, 2012 04:43
jQuery: Horizontal Drop Down Menu
// HORIZONTAL DROP DOWN MENU
var timeout = 3000;
var closetimer = 0;
var navitem = 0;
function nav_open(){
nav_canceltimer();
nav_close();
navitem = $(this).find('ul').css('visibility', 'visible');
}