Skip to content

Instantly share code, notes, and snippets.

View hsquareweb's full-sized avatar

Hassan Elhassan hsquareweb

View GitHub Profile
@hsquareweb
hsquareweb / gist:2048111
Created March 16, 2012 01:54
CSS: Pseudo Links For Printing
/* CSS Pseudo Links For Printing */
p a:after {content: " (http://www.url.com/" attr(href) ")";} /* internal links will start with main site url */
p a[href^="http://"]:after, a[href^="https://"]:after {content: " (" attr(href) ")";} /* show external links */
p a[href^="javascript:"]:after, p a[href^=""]:after {content: "";} /* hide JavaScript and empty links */
p a[href^="#"]:after {display: none;} /* hide internal links */
p a {word-wrap: break-word;} /* break long links */
@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 / header.html
Created March 26, 2012 22:03
Apple Touch Icons, Windows Icons, and Splash Screens
<link rel="shortcut icon" href="/images/favicon.ico"/>
<!-- Apple Touch Icons -->
<link rel="apple-touch-icon" href="/images/touch-icon-57.png" sizes="57x57"/>
<link rel="apple-touch-icon" href="/images/touch-icon-72.png" sizes="72x72"/>
<link rel="apple-touch-icon" href="/images/touch-icon-76.png" sizes="76x76"/>
<link rel="apple-touch-icon" href="/images/touch-icon-114.png" sizes="114x114"/>
<link rel="apple-touch-icon" href="/images/touch-icon-120.png" sizes="120x120"/>
<link rel="apple-touch-icon" href="/images/touch-icon-144.png" sizes="144x144"/>
<link rel="apple-touch-icon" href="/images/touch-icon-152.png" sizes="152x152"/>
@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