Archives - December, 2011



31 Dec 11

I think 2011 was a great year for RedTeamDesign and for me also. I published quite many articles here and just to recap some of my best content, here are my top 10 of 2011:

Just some other awesome CSS3 buttons

Just some other awesome CSS3 buttons

CSS3 dropdown menu

CSS3 dropdown menu

Slick login form with HTML5 & CSS3

Slick login form with HTML5 & CSS3

Cool notification messages with CSS3 & jQuery

Cool notification messages with CSS3 & jQuery

CSS3 animated dropdown menu

CSS3 animated dropdown menu

How to create slick effects with CSS3 box-shadow

How to create slick effects with CSS3 box-shadow

Practical CSS3 tables with rounded corners

Practical CSS3 tables with rounded corners

Sexy CSS3 menu

Sexy CSS3 menu

How to create a cool CSS3 search box

How to create a cool and usable CSS3 search box

Cross-browser CSS gradient buttons

Cross-browser CSS gradient buttons

Thank you all!

In the end, I would also like to thank everyone who has supported me over the year. Especially, I would like to thank those who have sent encouragements by email, those who have tweeted my articles, those who have commented on my articles, those who are liking RTD on facebook, those who have subscribed to my RSS feed, and to anyone who has read my articles.

It is you who encourage me to go further and I will continue to write and publish articles for 2012.


Filed under: Design

Trackback Uri






30 Dec 11


This is a list of other capabilities that can be used. Adding more than one cap just add a new line $role->add_cap( 'new_cap_name' ); Thanks to Andrea Bersi for submitting.
snippet :  PHPcopy
function add_theme_caps() {
   $role = get_role( 'author' );
   $role->add_cap( 'edit_others_posts' );
}
add_action( 'admin_init', 'add_theme_caps');




Give author capabilities including editing other authors posts?u=rss">Visit wpsnipp.com for details on how to setup this WordPress snippet.

Share this post.


Give author capabilities including editing other authors posts">Facebook | Give author capabilities including editing other authors posts">StumbleUpon | Give author capabilities including editing other authors posts">Delicious | Give author capabilities including editing other authors posts @wpsnipp">Tweet It | Give author capabilities including editing other authors posts">Digg This | Give author capabilities including editing other authors posts">DesignBump-It | Give author capabilities including editing other authors posts">DesignPoke-it

© wpsnipp.com All Rights reserved.

source: wpsnipp.com


Filed under: Themes & Templates,Web Development

Trackback Uri






29 Dec 11


snippet :  PHPcopy
add_filter('widget_title', 'change_widget_title', 10, 3);
function change_widget_title($title, $instance, $wid){
    return $title = str_replace('Widget Title', '<span style="color: red">Custom</span>', $title);
}




Replace widget title with custom title and HTML?u=rss">Visit wpsnipp.com for details on how to setup this WordPress snippet.

Share this post.


Replace widget title with custom title and HTML">Facebook | Replace widget title with custom title and HTML">StumbleUpon | Replace widget title with custom title and HTML">Delicious | Replace widget title with custom title and HTML @wpsnipp">Tweet It | Replace widget title with custom title and HTML">Digg This | Replace widget title with custom title and HTML">DesignBump-It | Replace widget title with custom title and HTML">DesignPoke-it

© wpsnipp.com All Rights reserved.

source: wpsnipp.com


Filed under: Themes & Templates,Web Development

Trackback Uri






29 Dec 11

In keeping with tradition, it's time once again to dust off my crystal ball and see what the coming year will bring for software developers. Mind you, the spirits don't always offer the clearest vision of the tech industry, but they didn't let us down too badly last time around. Let's see what they have to offer for 2012.

read more


Filed under: General,Web Development

Trackback Uri






28 Dec 11

Mixing Nut Butter Nut Butter In Jar Sealed Nut Butter Jar Banana and Nut Butter

I got a food processor for Christmas. This is my first attempt at a nut butter. I used walnuts, almonds, a little stevia extract, and coconut oil. Of course, I then spread it on a banana!


Filed under: Web Development

Trackback Uri






28 Dec 11


snippet :  PHPcopy
function commentCount($type = ‘comments’){
	if($type == ‘trackbacks’):
		$typeSql = ‘comment_type = "trackback"’;
		$oneText = ‘One :trackback’;
		$moreText = ‘% :trackbacks’;
		$noneText = ‘No :trackbacks’;
	elseif($type == ‘pingbacks’):
		$typeSql = ‘comment_type = "pingback"’;
		$oneText = ‘One :pingback’;
		$moreText = ‘% :pingbacks’;
		$noneText = ‘No :pingbacks’;
	endif;
	global $wpdb;
    $result = $wpdb->get_var(‘
        SELECT
            COUNT(comment_ID)
        FROM
            ‘.$wpdb->comments.’
        WHERE
            ‘.$typeSql.’ AND
            comment_approved="1" AND
            comment_post_ID= ‘.get_the_ID()
    );
	if($result == 0):
		echo str_replace(‘%’, $result, $noneText);
	elseif($result == 1):
		echo str_replace(‘%’, $result, $oneText);
	elseif($result > 1):
		echo str_replace(‘%’, $result, $moreText);
	endif;
}
add_filter(‘manage_posts_columns’, ‘posts_columns_counts’, 1);
add_action(‘manage_posts_custom_column’, ‘posts_custom_columns_counts’, 1, 2);
function posts_columns_counts($defaults){
    $defaults['wps_post_counts'] = __(‘Counts’);
    return $defaults;
}
function posts_custom_columns_counts($column_name, $id){
	if($column_name === ‘wps_post_counts’){
		commentCount(‘trackbacks’); echo "<br />";
		commentCount(‘pingbacks’);
          }
}
source →




Total pingbacks, trackbacks within admin post columns?u=rss">Visit wpsnipp.com for details on how to setup this WordPress snippet.

Share this post.


Total pingbacks, trackbacks within admin post columns">Facebook | Total pingbacks, trackbacks within admin post columns">StumbleUpon | Total pingbacks, trackbacks within admin post columns">Delicious | Total pingbacks, trackbacks within admin post columns @wpsnipp">Tweet It | Total pingbacks, trackbacks within admin post columns">Digg This | Total pingbacks, trackbacks within admin post columns">DesignBump-It | Total pingbacks, trackbacks within admin post columns">DesignPoke-it

© wpsnipp.com All Rights reserved.

source: wpsnipp.com


Filed under: Themes & Templates,Web Development

Trackback Uri






28 Dec 11

imageThe HTML5 Canvas element is a 2D drawing interface supported by most modern web browsers. Canvas enables a web developer to draw anything directly into a web browser natively, without the need for Java or Flash plugins.

While the Canvas API is fairly simple and straight forward, it is very robust.  Given its flexibility and freedom from plugins, I predict that Canvas is likely to become  the base building block of choice, that developers will leverage in constructing future web applications on desktop, tablet, and mobile devices.

To demonstrate the basic capabilities of the Canvas API, I have created a simple QR code widget, which can be used on websites, or printed out and placed on marketing materials.  To learn more about QR codes, please visit my two previous posts: Create a Quick Response Code (QR Code) image using Google Chart and Branding a Quick Response Code (QR Code) with a custom logo.
 
 
 
This blog post will introduce you to the following Canvas concepts
  •  Creating a Canvas context
  •  Writing text on the context
  •  Adding images to the context
  • Shadow and rotation treatments
 
 
Creating the context
 
We start by placing a Canvas element within the body of our webpage, and giving it an element ID that our Javascript will use as a reference.
 
<canvas id="myCanvas" width="350" height="350">
    Your browser does not support HTML5 Canvas element.
</canvas>
 
On the page load, we first verify that the browser supports the HTML5 Canvas element, then we get the context of the Canvas, to be used for all subsequent drawing operations.
 
var element = document.getElementById('myCanvas');
if (!element || !element.getContext) {
    return;
}

var context = element.getContext('2d');
if (!context || !context.drawImage) {
    return;
}
 
 
Drawing text

Before we begin to draw text on the context, let's first set a nice background color and fill the Canvas by drawing a rectangle over the top of the entire Canvas surface.  Next we will set the color and font of the text, set it's position, and finally draw this text onto the context.  In my example, I have written out the URL to my blog.  We use the fillText API to draw my blog's URL string onto the context.
 
context.fillStyle   = '#CC5422'; // set canvas background color
context.fillRect  (0,   0, 350, 350);  // now fill the canvas
context.fillStyle    = '#FFFFFF';  // set text color
context.font         = 'bold 9px sans-serif';  // set text font
context.textBaseline = 'top';  // set text position
context.fillText  ('https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah', 10, 335);  // set the text with my blogs URL

 
Adding images
 
We will be using Google Chart to dynamically create and return the QR code image, and also brand the experience with a small developerWorks icon, which we will load as a traditional web resource.  We use the drawImage API to add each image to the context.

// create and draw the google generated qr-code image 
var google_img = new Image();
google_img.addEventListener('load', function () {
   context.drawImage(this, 35, 25, 275, 275);
},false);
google_img.src = "https://chart.googleapis.com/chart?chs=275x275&cht=qr&chl=https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah?lang=en&choe=UTF-8";

// create amd draw the branding image for the qr-code
var branding_img = new Image();
branding_img.addEventListener('load', function () {
   context.drawImage(this, 312, -8, 30, 30);
},false);
branding_img.src = "https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah/resource/dw-small.png";
 
 
Shadow and rotation treatments
 
Since Canvas is a two dimensional drawing service, I've added a shadow treatment to make the QR code "pop out" at the user.  I also twisted the images ever so slightly, using the rotate API, simply for artistic flair.

context.shadowOffsetX = 10; // set x offset for my shadow
context.shadowOffsetY = 10; // set y offset for my shadow
context.shadowBlur = 10;  // set blur intensity
context.shadowColor = "black";  // set blur color
context.rotate(0.05)  // get artsy and rotate context slightly

 
The compete code
 
<html>
<head>
<title>HTML5 Canvas example</title>
<script type="text/javascript">
  window.addEventListener('load', function () {
    var element = document.getElementById('myCanvas');
    if (!element || !element.getContext) {
      return;
    }

    var context = element.getContext('2d');
    if (!context || !context.drawImage) {
       return;
    }

    context.fillStyle   = '#CC5422'; // set canvas background color
    context.fillRect  (0,   0, 350, 350);  // now fill the canvas

    context.fillStyle    = '#FFFFFF';  // set text color
    context.font         = 'bold 9px sans-serif';  // set text font
    context.textBaseline = 'top';  // set text position
    context.fillText  ('https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah', 10, 335);  // set the text with my blogs URL

    context.shadowOffsetX = 10; // set x offset for my shadow
    context.shadowOffsetY = 10; // set y offset for my shadow
    context.shadowBlur = 10;  // set blur intensity
    context.shadowColor = "black";  // set blur color

    context.rotate(0.05)  // get artsy and rotate context slightly


    // create and draw the google generated qr-code image 
    var google_img = new Image();
    google_img.addEventListener('load', function () {
       context.drawImage(this, 35, 25, 275, 275);
    },false);
    google_img.src = "https://chart.googleapis.com/chart?chs=275x275&cht=qr&chl=https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah?lang=en&choe=UTF-8";

    // create amd draw the branding image for the qr-code
    var branding_img = new Image();
    branding_img.addEventListener('load', function () {
       context.drawImage(this, 312, -8, 30, 30);
    },false);
    branding_img.src = "https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah/resource/dw-small.png";

  },false);
</script>
</head>

<body>
<div style="padding:35px;">
<canvas id="myCanvas" width="350" height="350">
    Your browser does not support HTML5 Canvas element.
</canvas>
</div>
</body>
</html>
 
 
Next steps
 
You can run my example online by clicking here.  This blog post has only scratched the surface on the capabilities and promise of the Canvas API.  To learn more on Canvas, I would suggest you begin by reading the complete HTML Canvas 2D Context specification at W3C.  To download my example, please click here.
 
Enjoy!

Filed under: Web Development

Trackback Uri






27 Dec 11

You can now create stunning animations with CSS3. But, I bet you know that. The keyword when it comes about CSS3 animations is the CSS3 @keyframes rule and in this article you will learn how to create an awesome CSS3 animated header using it.

View demo

also, you can download the .psd concept

The HTML

The markup is minimal and quite self explanatory. Please, don’t blame me for divitis. :)

<div class="header">
	<div class="wrapper">
		<div class="christmas-tree tree1"></div>
		<div class="christmas-tree tree2"></div>
		<div class="christmas-tree tree3"></div>
		<div class="snowman"></div>
		<div class="christmas-tree tree4"></div>
		<div class="christmas-tree tree5"></div>
		<div class="christmas-tree tree6"></div>
	</div>
</div>

Image resources

Below, you can find the images you will use in order to create the header:

The CSS

As you read at the beginning of this article, the @keyframes rule does all the magic. Also, to keep the following code as clean as possible, I will not add the prefixed versions too (-moz-, -webkit-, -ms-).

You can find the full CSS3 code when viewing page source for the demo.

To achieve the snow effect, you will need to animate the background-position property for the first .header background. As a quick note, for the browsers that do not support multiple backgrounds, the snow will not be visible for this example.

.header{
	margin: 0 0 30px;
	background: url(header-bg.png);
	background: url(snow-bg.png) repeat-y center, url(header-bg.png);
	animation: animate-snow 9s linear infinite;
}

@keyframes animate-snow
{
	0% { background-position: center 0, 0 0;}
	100% { background-position: center 885px, 0 0;}
}

The .wrapper element basically holds all our Christmas trees together with the snowman. Please note the position: relative declaration:

.wrapper{
	width: 960px;
	height: 315px;
	margin: auto;
	overflow: hidden;
	position: relative;
	background: url(wrapper-bg.png) no-repeat bottom;
}

For the Christmas trees, the animation-duration value was randomly changed in order to create a cool effect:

@keyframes animate-drop {
	0% {opacity:0;transform: translate(0, -315px);}
	100% {opacity:1;transform: translate(0, 0);}
}	

.christmas-tree,
.snowman {
	position: absolute;
	animation: animate-drop 1s linear;
}

.christmas-tree {
	width: 112px;
	height: 137px;
	background: url(christmas-tree.png);
}

.snowman {
	width: 115px;
	height: 103px;
	top: 195px;
	left: 415px;
	background: url(snowman.png);
	animation-duration: .6s;
}	

.tree1 {
	top: 165px;
	left: 35px;
	animation-duration: .6s;
}

.tree2 {
	left: 185px;
	top: 175px;
	animation-duration: .9s;
}

.tree3 {
	left: 340px;
	top: 125px;
	animation-duration: .7s;
}

.tree4 {
	left: 555px;
	top: 155px;
	animation-duration: .8s;
}

.tree5 {
	left: 710px;
	top: 170px;
	animation-duration: .7s;
}

.tree6 {
	left: 855px;
	top: 125px;
	animation-duration: .6s;
}

View demo

also, you can download the .psd concept

Browser support

Here’s the support at this time: Firefox 5+, IE 10+, Chrome 6+, Safari 5+. For non-supported browsers, you don’t have to worry, everything will be just fine as long as you provide decent fallbacks.

Why to use animations?

Simple answer: to draw the user’s attention. Get inspired by another example, here is one of my previous articles, where I also used CSS3 keyframes: Cool notification messages with CSS3 & jQuery.

Happy Holidays!

We’re getting close to New Year’s and, with this article, I want to wish you all the best and Happy Holidays. Thank you all for reading my articles!


Filed under: Design

Trackback Uri






23 Dec 11

About a week ago, I began working on a new article about Backbone.js. It was due to cover some concepts and insights intermediate or advanced users might appreciate, but I found myself wanting to reference topics beginners might need to … Continue reading

Filed under: Web Development

Trackback Uri






23 Dec 11



PHP

<?php
if($images =& get_children( 'post_type=attachment' )){
   foreach($images as $id => $attachment ){
	   echo '<div>';
	   echo wp_get_attachment_image( $id, 'thumb' )."<br />";
           $meta = wp_get_attachment_metadata($id);
           echo "Credit:  ".$meta[image_meta][credit]."<br /> ";
           echo "Camera:  ".$meta[image_meta][camera]."<br />";
           echo "Focal length:  ".$meta[image_meta][focal_length]."<br />";
           echo "Aperture:  ".$meta[image_meta][aperture]."<br />";
           echo "ISO:  ".$meta[image_meta][iso]."<br />";
           echo "Shutter speed:  ".$meta[image_meta][shutter_speed]."<br />";
           echo "Time Stamp:  ".$meta[image_meta][created_timestamp]."<br />";
           echo "Copyright:  ".$meta[image_meta][copyright];
	   echo '</div>';
   }
}
?>




Visit wpsnipp.com for details on how to setup this WordPress snippet.

Share this post.


Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It | DesignPoke-it

© wpsnipp.com All Rights reserved.

source: wpsnipp.com


Filed under: Themes & Templates,Web Development

Trackback Uri